Thanks Bugsy!
Exactly what I was trying to do!
Was quickly testing yours and noticed that when you are hit, players don't spill blood or slow down so I just moved some things around and added a few things.
The only downside to this is when you are using a 3rd party plugin which displays the damage dealt to the victim. It doesn't display anything until the last hit where the victim drops dead. Anyway around this if that is possible?
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <hamsandwich>
#include <fun>
public plugin_init()
{
register_plugin("Damage Absorption ", "1.0", "Mazza")
RegisterHam(Ham_TakeDamage,"player", "fw_HamTakeDamage")
}
public fw_HamTakeDamage( iVictim , iInflictor , iAttacker , Float:fDamage , iDmgBits )
{
// client_print(iVictim, print_chat, "Dmg Type: %i", iDmgBits)
if(iDmgBits & DMG_GENERIC || /*iVictim == iAttacker ||*/ !is_user_alive(iVictim) || !is_user_connected(iAttacker))
return HAM_IGNORED
new iDmgHP = floatround( fDamage * 0.3 );
new iDmgArmor = floatround( ( fDamage * 0.7 ) * 0.5 ); //or 0.35
new iHealth = get_user_health( iVictim );
new CsArmorType: ArmorType, iArmor = cs_get_user_armor( iVictim, ArmorType)
if(iArmor)
{
if ( ( iHealth - iDmgHP ) <= 0 )
{
//enough damage to kill player so a deathmsg is displayed
SetHamParamFloat( 4 , fDamage );
return HAM_HANDLED;
}
else
{
ExecuteHam(Ham_TakeDamage, iVictim, iInflictor, iAttacker, 0.0, DMG_BULLET | DMG_NEVERGIB);
set_user_health( iVictim , iHealth - iDmgHP );
cs_set_user_armor( iVictim , clamp( iArmor - iDmgArmor , 0 , 100 ), ArmorType );
return HAM_SUPERCEDE;
}
}
return HAM_IGNORED
}
__________________