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-08-2010 , 13:43   Re: Damage Absorption
Reply With Quote #4

I think the easiest way is to determine the damage/reduction values for health and armor (based on a % of damage passed to TakeDamage) and set the users health/armor accordingly and then return HAM_SUPERCEDE so the actual damage passed in HamTakeDamage does not affect the player. The damage passed to TakeDamage, as you probably already know, is total damage without factoring armor so altering the value (SetHamParamFloat()) doesn't give you any control over how it is distributed by the engine (inflicted to hp or armor).

Something like this, untested.
PHP Code:
public fw_HamTakeDamageiVictim iInflictor iAttacker Float:fDamage iDmgBits )
{
    new 
iDmgHP floatroundfDamage 0.3 );
    new 
iDmgArmor floatround( ( fDamage 0.7 ) * 0.5 ); //or 0.35
    
new iHealth get_user_healthiVictim );

    
set_user_armoriVictim clampget_user_armoriVictim ) - iDmgArmor 100 ) );
    ( ( 
iHealth iDmgHP ) <= ) ? user_killiVictim ) : set_user_healthiVictim iHealth iDmgHP );

    return 
HAM_SUPERCEDE;
}

or

public 
fw_HamTakeDamageiVictim iInflictor iAttacker Float:fDamage iDmgBits )
{
    new 
iDmgHP floatroundfDamage 0.3 );
    new 
iDmgArmor floatround( ( fDamage 0.7 ) * 0.5 ); //or 0.35
    
new iHealth get_user_healthiVictim );
 
    if ( ( 
iHealth iDmgHP ) <= )    
    {
        
//enough damage to kill player so a deathmsg is displayed
        
SetHamParamFloat500.0 );
        return 
HAM_HANDLED;
    }
    else
    {
        
set_user_healthiVictim iHealth iDmgHP );
        
set_user_armoriVictim clampget_user_armoriVictim ) - iDmgArmor 100 ) );
        return 
HAM_SUPERCEDE;    
    }

__________________

Last edited by Bugsy; 06-08-2010 at 21:58.
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