Hello, I'm trying to make an NPC, and I don't know how I would make the actual hitbox of the NPC smaller than the sprite?
I know I can change npc.width and npc.height, but I'm hesitant to in case that breaks the animation. Plus I'm wanting the hitbox offset from (0, 0) on the sprite anyway.
item.name is not a thing - there is no 'name' variable in Item. Also, there is no AddTooltip method in ModItem.
Delete those and do this:
public override void SetStaticDefaults()
Tooltip.SetDefault("A plate equipped with tech stuff");
// Override UseItem in ModItem
public override bool UseItem(Player player)
player.AddBuff(Terraria.ID.BuffID.Hunter, 360); // Add the Hunter buff to the player for 6 seconds
player.AddBuff(Terraria.ID.BuffID.Horrified, 360); // Add the Horrified buff the the player for 6 seconds...
You can probably locate the vanilla sprites in Main (assuming you have access to the source code) and then in your mod, I guess in your mod's Load() method? you can replace those sprites with your own, for example: Main.dukeFishronTexture = ModContent.GetTexture("ModFolder/pathToImage");
In your magic weapon item's class, you'll need to override the Shoot method like so:
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
// Check for that 10% chance
I can certainly try to help you with any questions you have, but the best way to learn is to just jump into it. Do have at least a quick look at a C# tutorial (tutorialspoint has a good one I think) as I had no idea how to code when I started modding, and didn't have a look at any tutorials, and...
You seem to be checking if player.miscEquips is true, but it's an Item array, and it can't convert that to a boolean. What exactly is the if(player.miscEquips) meant to be checking?
tModLoader doesn't have a decompiler (that I'm aware of), so you're going to have to use something like ilspy...
Probably be useful to create a Helper class with some commonly used/useful functions in, like hasInInventory and hasEquippedAccessory
You can probably change that in GlobalTile, but I wouldn't know how sorry
You'll need a static global bool like public static bool hasGeneratedOre in one of your classes, and only generate ore when that boss is defeated if hasGeneratedOre is false, and then you'll obviously need to set it to true after that. To keep this variable across each time you enter the world...
I think for that you're going to have to subclass GlobalNPC and in AI() you'll have to first check the NPC type (if it's the one you want to detect accessories) and loop through Main.player and check each players inventory, maybe only if the player is within a certain distance of the NPC (or...
Some vanilla accessories will change a variable in player, like player.accFlipper for the flipper accessory, but for all others, I spotted some Item in Player called inventory, miscEquips and armor. You'll have to loop through the correct one out of them (there might be others I missed) and...
Have a look at Vanilla sprite sheets, and also have a look at how other mods have done it. tModLoader will likely do them the same as Terraria handles it's NPC sprites, so using that should get you what you want. I haven't made an NPC, so I can't help too much here
My mistake, I thought that your code was in ModItem for some reason :/
public override void OnHitNPC(Item item, NPC target, int damage, float knockback, bool crit)
int amountToHeal = damage / 10; // Heal tenth of damage
if (amountToHeal +...