Thread: True Armor
View Single Post
DarkSidero
Junior Member
Join Date: Jul 2009
Location: Romania
Old 07-29-2009 , 04:41   Re: True Armor
Reply With Quote #15

Code:
public passDamage(this, id, attacker, Float:damage, damagebits)
{
    new Float:armor = float(get_user_armor(this))
    if(armor>0)
    {
        new Float:new_armor = armor - (damage / get_pcvar_float(pPerc))
        if(new_armor<0)
        {
            set_user_armor(this, 0)
            
            ExecuteHam(Ham_TakeDamage, this, id, attacker, (-new_armor)*get_pcvar_float(pPerc), damagebits);
        }
        
        else
            set_user_armor(this, floatround(armor-new_armor))
    }
    else
        ExecuteHam(Ham_TakeDamage, this, id, attacker, damage, damagebits);
    
}
Isn't this wrong? Imo, it should be:

Code:
public passDamage(this, id, attacker, Float:damage, damagebits)
{
    new Float:armor = float(get_user_armor(this))
    if(armor>0)
    {
        new Float:new_armor = armor - (damage / get_pcvar_float(pPerc))
        if(new_armor<0)
        {
            set_user_armor(this, 0)
            
            ExecuteHam(Ham_TakeDamage, this, id, attacker, (-new_armor)*get_pcvar_float(pPerc), damagebits);
        }
        
        else
            set_user_armor(this, floatround(new_armor))
    }
    else
        ExecuteHam(Ham_TakeDamage, this, id, attacker, damage, damagebits);
    
}
1st way: the player's armor will be set to the damage that the player should've taken. Example: player takes 23 damage and he's got 100 armor, his armor is set to "23", not to "77" as intended.

2nd way: the player's armor will be set to armor minus the damage that the player should've taken. Example: player takes 23 damage and he's got 100 armor, his armor is set to "77".

Other than that, very cool plugin, inspired me .

Last edited by DarkSidero; 07-29-2009 at 04:42. Reason: highlighted mistakes
DarkSidero is offline
Send a message via Yahoo to DarkSidero