doesnt:
SetEventInt(event,"dmg_health", altereddamage);
change dmg_health... so when you do this:
new health = eventhealth + dmg_health - altereddamage;
your not actually doing anything (adding and subtracting the same value)?
you should be setting the dmg_health after the calculations are done.
also..
if you change the if (health > 1) to if (health < 1), you can partially fix cases that would cause to much damage. change this:
PHP Code:
{
altereddamage = RoundToNearest(dmg_health * multiplierWeapon);
SetEventInt(event,"dmg_health", altereddamage); // for correct stats.
if (eventhealth > 1) // dont bother if the player dies
{
new health = eventhealth + dmg_health - altereddamage;
// health calculation: first revert damage done by adding dmg_health, then subtract the changed damage
if (health > 1)
{
SetEntityHealth(client, health);
DebugPrintToAll("Changed weapon %s damage used by %N on %N, was %i, is now %i, oldhealth %i, newhealth %i", weaponname, attacker, client, dmg_health, altereddamage, eventhealth, health);
}
}
}
to this:
PHP Code:
{
altereddamage = RoundToNearest(dmg_health * multiplierWeapon);
if (eventhealth > 1) // dont bother if the player dies
{
new health = eventhealth + dmg_health - altereddamage;
// health calculation: first revert damage done by adding dmg_health, then subtract the changed damage
if (health < 1)
{
// adjust the damage done so theres 1 health left
altereddamage += health - 1;
health = 1;
}
SetEntityHealth(client, health);
DebugPrintToAll("Changed weapon %s damage used by %N on Tank %N, was %i, is now %i, oldhealth %i, newhealth %i", weaponname, attacker, client, dmg_health, altereddamage, eventhealth, health);
}
SetEventInt(event,"dmg_health", altereddamage); // for correct stats.
}
..fixes both points.