Issue with custom damage system (pistolwhipping)
#7

In case the health/armor "overhead" is still an issue, you first subtract the damage from the armor variable, even if it's 0.0.
If the result is negative (< 0.0), there was more damage done than the player had armor. In that case subtract the absolute value of the armor from the health.

This way you don't have to add a special case if the player has armor, since an armor of 0.0 will still do 100% damage to health.

For example:

Код:
new Float:damage = 50.0, Float:health = 75.0, Float:armor = 25.0; // Example starting values

armor = armor - damage; // Subtract damage from armor

if(armor < 0.0) // Armor is negative, so the negative amount is the damage that has to be done to health
{
	health += armor; // Since armor is negative, this is actually a subtraction

	armor = 0.0; // Revert it to 0.0

	if(health < 0.0) // health dropped below 0.0, set it to 0.0 to avoid negative health
	{
		health = 0.0;
	}
}
else
{
	// Health damage
}

// Update player health and armor, etc
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)