Modifying weapon damage based on projectile behavior

POCKETS

Terrarian
I know there's a ModifyWeaponDamage hook I can use to add damage to the weapon itself in the actual ModItem (weapon's class), and there's also an OnHitNPC inside my ModProjectile.

How would I tie these two things together so that I can add or subtract weapon damage based on whether or not a projectile has, say, hit an NPC, or collides with a tile, or some other behavior that is set inside the ModProjectile class?
 
OK, so I'm starting to understand this a bit more, but I still need a little help.

I created a bool in my projectile code, and then I created an if statement inside the OnHitNPC method that sets the bool variable to true.

Then, I did something like this inside the ModifyWeaponDamage hook in my ModItem class -

C#:
public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat)
{
    if (ModProjectile.variableName)
    {
        add += 1f;
    }
}

This does work. However, this only works one time. Is there a way I can keep adding damage to the weapon over and over again using this particular method? Conversely, is it possible to subtract damage from the weapon using something like add -= 1f?


EDIT: Mods can lock this thread. I've found what I'm looking for :)
 
Last edited:
Back
Top Bottom