Quote:
Originally Posted by Mini_Midget
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?
|
This works for me.
If you are concerned with that we will also need to correct the damage value displayed since we are modifying the issued damage. Setting the damage amount to pev_dmg_take in TakeDamage-post will alter what amx_super displays as damage; it will work in TakeDamage pre as well but the value is not always accurate. I can't guarantee it will work for all damage-display plugins but you can experiment.
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <hamsandwich>
#include <fun>
new Float:fDisplayDamage[ 33 ];
public plugin_init()
{
register_plugin("Damage Absorption ", "1.0", "Mazza")
RegisterHam(Ham_TakeDamage,"player", "fw_HamTakeDamage")
RegisterHam(Ham_TakeDamage,"player", "fw_HamTakeDamage_Post" , 1 )
}
public fw_HamTakeDamage_Post( iVictim , iInflictor , iAttacker , Float:fDamage , iDmgBits )
{
if ( fDisplayDamage[ iVictim ] )
{
set_pev( iVictim , pev_dmg_take , fDisplayDamage[ iVictim ] );
fDisplayDamage[ iVictim ] = 0.0;
}
}
public fw_HamTakeDamage( iVictim , iInflictor , iAttacker , Float:fDamage , iDmgBits )
{
if ( iDmgBits & DMG_GENERIC || /*iVictim == iAttacker ||*/ !is_user_alive( iVictim ) || !is_user_connected( iAttacker ) )
return HAM_IGNORED;
new CsArmorType: ArmorType, iArmor = cs_get_user_armor( iVictim , ArmorType );
if( !iArmor )
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 );
if ( ( iHealth - iDmgHP ) > 0 )
{
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 );
fDisplayDamage[ iVictim ] = float( iDmgHP );
//*** for testing ***
client_print( 0 , print_chat , "Adjusted Damage = %d" , iDmgHP );
return HAM_SUPERCEDE;
}
return HAM_IGNORED
}
__________________