public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
{
if (dodgeAccessory) {
Main.NewText("Effect has activated", 175, 75, 255, false);
return false;
}
return true;
}
Well that answers of it works or not i guess lolIt looks correct, to further test it try removing the random chance and see if it does anything. Chance PreHurt to this code below. What this does is remove the random chance from seeing if the accessory works, as well as outputting a message in game. You'll see the message if it worked correctly.
Code:public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource) { if (dodgeAccessory) { Main.NewText("Effect has activated", 175, 75, 255, false); return false; } return true; }
Well i'd certainly be curious to know how to do the movement thing even if it is complex but i'll deff add/adjust the immunity time to stop it spamming if i knew where to look for references etcThe way you have the code, when you return false, your character won't get hit based on whatever would have hit them at the moment. You should consider changing the immunity time as well otherwise it'll just trigger over and over as they are constantly making contact with the NPC and / or projectile.
If you mean a dodge like the player character actually moving out of the way, it's more complex but you can do that as well.
I guess that would be inside the {} where the text bit is as to where i would put player.velocity.X and YJust add or subtract to player.velocity.X and player.velocity.Y, based on how you want the player to move.
public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
{
//The effect & Chance percentage of the effect activating
if (dodgeAccessory && Main.rand.NextFloat() < 0.80f)
{
player.velocity.X something something here example
//For the Debugging purposes to tell if the effect is working correctly, Will probably be commented out for release
Main.NewText("Effect has activated", 175, 75, 255, false);
return false;
}
return true;
}