Random Damages
#1

Hey, i want to make a random damage script so.. as i thought about.. i need to use OnPlayerTakeDamage but.. how to make the weapon hit random hits each bullet for example.. i have m4 i shot on someone a bullet it did 30 damage i shot another it did 50 damage that is what i mean.. i tried to make a random array but failed so.. any help?
Reply
#2

Damage the player gets is calculated by angle and distance

let me see
pawn Код:
//try this under take damage
new Float:loosedamage;
GetPlayerHealth(playerid, loosedamage);
SetPlayerHealth(playerid, loosedamage + amount);
new x = 1 + random(50); //made change here
SetPlayerHealth(loosedamage - x); //change here
Reply
#3

Quote:
Originally Posted by Glad2BeHere
Посмотреть сообщение
Damage the player gets is calculated by angle and distance

let me see
pawn Код:
//try this under take damage
new Float:loosedamage;
GetPlayerHealth(playerid, loosedamage);
SetPlayerHealth(playerid, loosedamage + amount);
new x = random(1+50);
SetPlayerHealth(loosedamage + x);
the (1+50) means? cuz i got confused
Reply
#4

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        new Float: Dpos[3];
        GetPlayerPos(issuerid, Dpos[0], Dpos[1], Dpos[2]);
        new Float:dmg=0.0;
        switch(weaponid)
        {
            //you would change these IDs around or whatever
            //dmg=5+random(maxrandomvalue); - i use 5+the random to ensure we will always at least do 5 damage
            case 2,3,5..7,10..16: dmg=15.0;
            case 8: dmg=50.0;
            case 22, 30: dmg=40.0;
            case 23, 31: dmg=30.0;
            case 24: dmg=80.0;
            case 28,29,32: dmg=25.0;
            case 33,34: dmg=70.0;
            case 41,42: dmg=0.2;
            default: dmg=amount; //this is for weapon ID's we don't specify
        }
        if(GetPlayerDistanceFromPoint(playerid, Dpos[0], Dpos[1], Dpos[2]) < 2.0) dmg = 2.0; //if they go up and hit the player, we don't want it to do the full damage of the weaponid

        new Float:old_hp, Float:old_armor;
        GetPlayerHealth(playerid, old_hp);
        GetPlayerArmour(playerid, old_armor);

        if(old_armor >= dmg) SetPlayerArmour(playerid, (old_armor-dmg));
        else if(old_armor < dmg)
        {
            new Float:tmp_amount=(old_armor-dmg);
            SetPlayerArmour(playerid, 0);
            SetPlayerHealth(playerid, (old_hp+tmp_amount));
        }
        else if(old_hp > dmg) SetPlayerHealth(playerid, (old_hp-dmg));
        else SetPlayerHealth(playerid, 0.0);
    }
    return 1;
}
I'm not sure how well SetPlayerHealth works inside of OnPlayerTakeDamage. Worth a shot anyway.

Also, you need to set everyone to the same team
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)