Question about DMG
#5

Something like this might work, haven't tested it.

PHP код:
stock Float:GetDistanceBetweenPlayers(playeridtargetid)
{
    new
        
Float:x1Float:y1Float:z1,
        
Float:x2Float:y2Float:z2;
        
    if(
GetPlayerPos(playeridx1y1z1) && GetPlayerPos(targetidx2y2z2))
    {
        return 
VectorSize(x1 x2y1 y2z1 z2);
    }
    
    return 
Float:0x7f800000// infinity
}
    
public 
OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    if(
issuerid != INVALID_PLAYER_ID && weaponid == WEAPON_SHOTGUN)
    {
        new
            
Float:multiplier 1.0,
            
Float:distance GetDistanceBetweenPlayers(playeridissuerid),
            
Float:extraDamage 100.0 distance amount// - amount to account for damage already taken
            
        
switch(bodypart)
        {
            case 
34    multiplier 1.10// chest, +10% damage
            
case 56    multiplier 0.85// arms, -15% damage
            
case 78    multiplier 0.75// legs, -25% damage
            
case 9        multiplier 1.50// head, +50% damage
        
}
        
        
extraDamage *= multiplier;
        
        if(
extraDamage 0.0)
        {
            new 
Float:currentHealth;
            
GetPlayerHealth(playeridcurrentHealth);
            
SetPlayerHealth(playeridcurrentHealth extraDamage)
        }
    }

Reply


Messages In This Thread
Question about DMG - by AndreiWow - 18.01.2017, 15:44
Re: Question about DMG - by Vince - 18.01.2017, 15:48
Re: Question about DMG - by Logic_ - 18.01.2017, 15:50
Re: Question about DMG - by AndreiWow - 18.01.2017, 15:58
Re: Question about DMG - by Vince - 18.01.2017, 17:14
Re: Question about DMG - by GoldenLion - 18.01.2017, 19:53

Forum Jump:


Users browsing this thread: 1 Guest(s)