Shooting distance?
#1

How can I make if player is far away from shooter he will receive lower amount of damage? And if he is closer he will receive bigger amount of damage? (if is even possible)
Reply
#2

Yes, but is not fully functional. The Blood of the player will have to come down, then up.
Reply
#3

It is possible with these functions:

pawn Код:
OnPlayerTakeDamage
OnPlayerGiveDamage
SetPlayerTeam
Reply
#4

I think you didn't understand what I want, let me try to ask again, DISTANCE between shooter and target, for example if they are close enough (1-3 meters) shooter will kill him instantly if distance is more then 3 meters he will receive lower amount of damage.
Reply
#5

Use the callbacks such as "OnPlayerGiveDamage" and "OnPlayerTakeDamage" to do that. And if you want to lower the damage being done than default damage, I suggest you to set player's team and then manage the damage. While using these callbacks, use GetPlayerDistanceFromPoint function to determine how meters you're away from the player.


For 3z:
Use OnPlayerWeaponShot. And here's an example:

pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    if(hittype == HIT_TYPE_PLAYER)
    {
        new
            Float:X, Float:Y, Float:Z;
        GetPlayerPos(hitid, X, Y, Z);
        if(GetPlayerDistanceFromPoint(playerid, X, Y, Z) < 4.0)
        {
            //More damage?
        }
        else
        {
            //If more than 3m.
        }
    }
    return 1;
}
The same can be done on with "OnPlayerGiveDamage" or "OnPlayerTakeDamage" in case if it's not for 3x or for 3z versions with lagcompmode Off.
Reply
#6

I will try that + I can't see example, you forgot to post it :P
Reply
#7

Yes but you must disable "normal system" and replace it by your own. For example under OnPlayerTakeDamage you will count distance between shooter and target. After it you will decrease the amount of health in spite of distance.
Reply
#8

Example taken from my TF2 Gamemode:

http://pastebin.com/VaS1qSAG

That's a complete scriptside health system where all the damage is recalculated and modified, I do have a distance reduction formula too; The only downside with this is that you need a custom player label system, since if you set a player's health to infinite the other players will not see the health bar of the player decrease when being damaged.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)