G4M3R57
Terrarian
Mr. @bluemagic123, I have a question, how to change gun position in the hand?
And how to change the size of an item in coding?
And how to change the size of an item in coding?
Last edited:
The item.width and item.height for your second question, change that a little bit and you can find a size that works for your item. As for the first question, I think it would be vectors, I haven't done that type of coding yet, so I'm not sure.Mr. @bluemagic123, I have a question, how to change gun position in the hand?
And how to change the size of an item in coding?
The item.width and item.height for your second question, change that a little bit and you can find a size that works for your item. As for the first question, I think it would be vectors, I haven't done that type of coding yet, so I'm not sure.
You'll probably want to use this method. Just return a Vector2 containing your offset variables and you're good to go.Thanks for you quickly reply, but I know change size item for 'item.width' and 'item.height'
If the item is 112 width x 56 height, even if you change the size in half (56x28) it will not change in the game.
And I don't know how to change the position of the weapon in the hand, that's why I call Mr. @bluemagic123, maybe he can help me.
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace EpicnessModRemastered.Projectiles
{
public class PoisonSpell : ModProjectile
{
public override void SetDefaults()
{
projectile.name = "Poison Spell";
projectile.width = 8;
projectile.height = 21;
projectile.aiStyle = 1;
projectile.friendly = true;
projectile.hostile = false;
projectile.ranged = false;
projectile.melee = false;
projectile.magic = true;
projectile.penetrate = 1;
projectile.timeLeft = 600000;
projectile.light = 0.5f;
projectile.tileCollide = true;
projectile.extraUpdates = 1;
ProjectileID.Sets.TrailCacheLength[projectile.type] = 5;
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
}
public override bool OnTileCollide(Vector2 oldVelocity)
{
for (int i = 0; i < 5; i++)
{
int a = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, Main.rand.Next(1, 1), Main.rand.Next(1, 1), mod.ProjectileType ("PoisonRing"), (int)(projectile.damage * .5f), projectile.owner);
}
Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PoisonSpell"), projectile.position);
return true;
}
}
}
You can explain me with an example?
// Help, my gun isn't being held at the handle! Adjust these 2 numbers until it looks right.
public override Vector2? HoldoutOffset()
{
return new Vector2(10, 0);
}
From ExampleMod's ExampleGun
Code:// Help, my gun isn't being held at the handle! Adjust these 2 numbers until it looks right. public override Vector2? HoldoutOffset() { return new Vector2(10, 0); }
oh, I just read your original question.Thanks, I'll try this method.
Thanks for the quickly reply, I will try this useful tips.oh, I just read your original question.
item.width and height should match the actual dimensions of the moditem texture, since they define the hitbox, not how large it will be drawn.
holdoutoffset only affects guns, if your swung weapon is wrong, you need to fix the texture.
You can mess with item.scale (= 0.7f or something), but I'd suggest fixing the texture first.
Hi, I'm having a technical issue when playing with tModLoader 0.9.1 installed - every time that a menu or other type of UI is up on the screen (such as the Item/NPC browsers from the Cheat Sheet mod) Terraria's FPS drops to 15-20 from 45 and the game becomes incredibly laggy. The lag goes away once the menus/UI are closed and not being drawn on the screen anymore.
I can confirm that it works fine on my laptop; my desktop is the one with this issue. Desktop specs: Core i5 processor, 16 GB RAM, and Radeon 6900 2 GB video card.
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace EpicnessModRemastered.Projectiles
{
public class PoisonRing : ModProjectile
{
public override void SetDefaults()
{
projectile.name = "Poison Ring";
projectile.width = 57;
projectile.height = 50;
projectile.friendly = true;
projectile.hostile = false;
projectile.ranged = false;
projectile.melee = false;
projectile.magic = true;
projectile.penetrate = -1;
projectile.timeLeft = 600;
projectile.light = 0.5f;
projectile.tileCollide = false;
}
}
}
You can always override an AI method and set the velocity to zero manually:How do I get a projectile to stay still? When I shoot it it moves down.
Here is the projectile's code:
Code:using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace EpicnessModRemastered.Projectiles { public class PoisonRing : ModProjectile { public override void SetDefaults() { projectile.name = "Poison Ring"; projectile.width = 57; projectile.height = 50; projectile.friendly = true; projectile.hostile = false; projectile.ranged = false; projectile.melee = false; projectile.magic = true; projectile.penetrate = -1; projectile.timeLeft = 600; projectile.light = 0.5f; projectile.tileCollide = false; } } }
public override bool PreAI()
{
projectile.velocity = Vector2.Zero;
return false;
}
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace PupusyaviysMod.Items.Weapons
{
public class DirtSword : ModItem
{
public override void SetDefaults()
{
item.name = "Dirt Sword";
item.damage = 1;
item.melee = true;
item.width = 40;
item.height = 40;
item.toolTip = "It's a dirt sword, what do you think?";
item.useTime = 70;
item.useAnimation = 70;
item.useStyle = 1; ,
item.knockBack = 2;
item.value = 1;
item.rare = 1;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
}
public override void AddRecipes()
{
ModRecipie recipe = new ModRecipie(mod);
recipe.AddIngredient(ItemID.DirtBlock, 10);
recipe.AddTiles(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipie();
}
}
}
Terraria\ModLoader\Mod Sources\PupusyaviysMod\Items\Weapons\DirtSword.cs(30,4) : error CS0246: The type or namespace name 'ModRecipie' could not be found (are you missing a using directive or an assembly reference?)
Terraria\ModLoader\Mod Sources\PupusyaviysMod\Items\Weapons\DirtSword.cs(30,28) : error CS0246: The type or namespace name 'ModRecipie' could not be found (are you missing a using directive or an assembly reference?)