Question about DMG
#1

Can I use prox detector for dmg? I want to make the DMG for shotgun and I want to deal more DMG from close range and less from far.
Reply
#2

GetDistanceBetweenPlayers(). Then use something like damage = 100 - distance. Optionally add a negative or positive multiplier to decrease/increase the damage, e.g. x0.85 for 85% damage or x1.25 for 125% damage.
Reply
#3

Use OnPlayer(Give/ Take)Damage callback and some calculation to interfere with the damage.
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
GetDistanceBetweenPlayers(). Then use something like damage = 100 - distance. Optionally add a negative or positive multiplier to decrease/increase the damage, e.g. x0.85 for 85% damage or x1.25 for 125% damage.
Can I get an example please?
Reply
#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
#6

What I do for shotguns is take the amount float from the callback and add like 20 to it like this:
Код:
amount += 20.0
then decrease the new amount from player's health. The default shotgun's damage depends on how many bullets hit the player. So basically if all bullets hit then the damage is going to be 70 (around 50 is the default damage and 20 is the additional damage. Or if you were far and shot a player the damage could be 25 (around 5 is the default damage and 20 is additional). This is the easiest way to do it in my opinion.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)