Raised This Month: $ Target: $400
 0% 

Damage Absorption


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-14-2010 , 20:50   Re: Damage Absorption
Reply With Quote #6

Quote:
Originally Posted by Mini_Midget View Post
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:fDisplayDamage33 ];

public 
plugin_init() 
{
    
register_plugin("Damage Absorption ""1.0""Mazza")
    
    
RegisterHam(Ham_TakeDamage,"player""fw_HamTakeDamage")
    
RegisterHam(Ham_TakeDamage,"player""fw_HamTakeDamage_Post" )
}

public 
fw_HamTakeDamage_PostiVictim iInflictor iAttacker Float:fDamage iDmgBits 

    if ( 
fDisplayDamageiVictim ] )
    {
        
set_peviVictim pev_dmg_take fDisplayDamageiVictim ] );
        
fDisplayDamageiVictim ] = 0.0;
    }
}

public 
fw_HamTakeDamageiVictim iInflictor iAttacker Float:fDamage iDmgBits 

    if ( 
iDmgBits DMG_GENERIC || /*iVictim == iAttacker ||*/ !is_user_aliveiVictim ) || !is_user_connectediAttacker ) ) 
        return 
HAM_IGNORED;

    new 
CsArmorTypeArmorTypeiArmor cs_get_user_armoriVictim ArmorType );
    
    if( !
iArmor )
        return 
HAM_IGNORED;
        
    new 
iDmgHP floatroundfDamage 0.3 ); 
    new 
iDmgArmor floatround( ( fDamage 0.7 ) * 0.5 ); //or 0.35 
    
new iHealth get_user_healthiVictim );

    if ( ( 
iHealth iDmgHP ) > )
    { 
        
ExecuteHamHam_TakeDamage iVictim iInflictor iAttacker 0.0 DMG_BULLET DMG_NEVERGIB );
        
set_user_healthiVictim iHealth iDmgHP ); 
        
cs_set_user_armoriVictim clampiArmor iDmgArmor 100 ), ArmorType ); 
        
fDisplayDamageiVictim ] = floatiDmgHP );

        
//*** for testing ***
        
client_printprint_chat "Adjusted Damage = %d" iDmgHP );
        
        return 
HAM_SUPERCEDE;     
    } 
    
    return 
HAM_IGNORED

__________________

Last edited by Bugsy; 06-14-2010 at 23:13.
Bugsy is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode