tModLoader Lifesteal effect not working.

I'm trying to create a weapon with a lifesteal effect, but no matter what I do I usually get this error:

c:\Users\******************\Documents\My Games\Terraria\ModLoader\Mod Sources\GrisGuns\Items\Shotbun.cs(54,23) : error CS0115: 'GrisGuns.Items.Shotbun.DamageNPC(Terraria.Player, Terraria.NPC, int, ref int, ref float, ref bool, ref float)': no suitable method found to override

I apologize if this is a simple problem but I'm still new to this so I don't know how to fix this.

The code I used is here:

public override void DamageNPC(Player p, NPC npc, int hitDir, ref int damage, ref float knockback, ref bool crit, ref float critMult)
{
p.statLife += (int)damage/6; //You will gain health based on damage divided by 6. Change this to whatever you want
p.HealEffect((int)(damage/6));
}

I have used multiple variations of this code and none with success.
 
Try
public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit)
{
int lifeSteal = damage / 5;
player.statLife += lifeSteal;
player.HealEffect(lifeSteal);

}
 
Back
Top Bottom