Help with weapon damage system thanks
#1

pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
        new Float:HP;
    GetPlayerHealth(playerid, HP);
    if(issuerid != INVALID_PLAYER_ID)
    {
                switch(weaponid)
                {
                    case 22:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-13); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-8); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-26); // Head
                                }
                        }
                    case 23:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-15); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-12); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-25); // Head
                                }
                        }
                    case 24:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-23); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-20); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-15); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-15); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-15); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-15); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-67); // Head
                                }
                        }
                    case 25:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-30); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-27); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-23); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-23); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-22); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-22); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-70); // Head
                                }
                        }
                    case 27:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-20); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-14); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-10); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-10); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-9); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-9); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-70); // Head
                                }
                        }
                    case 28:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-10); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-8); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-20); // Head
                                }
                        }
                    case 29:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-10); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-8); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-20); // Head
                                }
                        }
                    case 30:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-21); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-14); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-9); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-9); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-8); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-8); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-40); // Head
                                }
                        }
                    case 31:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-21); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-14); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-9); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-9); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-8); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-8); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-40); // Head
                                }
                        }
                    case 32:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-10); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-8); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-20); // Head
                                }
                        }
                    case 33:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-26); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-15); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-10); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-14); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-10); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-14); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-40); // Head
                                }
                        }
                    case 34:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-33); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-28); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-20); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-20); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-20); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-20); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-100); // Head
                                }
                        }
                }
    }
    return 1;
}


How could i make this so it checks if you have armour and the takes it off armour but if you don't have armour it takes it from health. +rep
Reply
#2

Anyone please?
Reply
#3

pawn Code:
new armour;//defines the armour var..
GetPlayerArmour(playerid, armour);//Get the players armour
if(armour >= x)//Check if the armour is above a certain ammount (change the x.)
SetPlayerArmour(playerid, armour-ammount);//If the armour is higher than the ammount you checked, decrease it with the ammount you like..

//If the armour check is not higher, take the ammount form the health
Reply
#4

So would this work

pawn Code:
case 3: if(armour >= 0)
                    SetPlayerArmour(playerid, armour-10);
                    else SetPlayerHealth(playerid, HP-33); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-28); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-20); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-20); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-20); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-20); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-100); // Head
Reply
#5

The best way to do that is to check if the player armour is more then the you want to take off.

For example:

Your armour is: 30
Your health is 100
Your damage: 40

You first check to see if you have more armour then damage, if you have less then you get the player armour and take it away from the damage and then apply the remaining damage to health.

pawn Code:
new float:hp, float:armor;
GetPlayerHealth(playerid, hp);
GetPlayerArmor(playerid, armour);

if(armour > amount)
{
      armour - amount;
      SetPlayerArmor(playerid, armour);
}
else if(armour >= 0 && armour < amount)
{
      amount - armour;
      SetPlayerHealth(playerid, HP - amount);
}
This is untested but should work, unless I have missed something. If anyone finds anything wrong. Fell free to correct it.
Reply
#6

could you please link that up to the case because i need it to be linked up to the bodyparts thanks
Reply
#7

Well could you help me link it up to the damage system please +rep
Reply
#8

You should just throw away all the code you have right now because it's all junk and is not how this kind of system should work. You need to use OnPlayerGiveDamage() the new lag compensation system isn't very reliable so it requires a helper system of course in doing this you can do a lot of other things such as specific damage amounts and completely server sided damage. In my opinion OnPlayerTakeDamage() is obsolete with lag comp enabled as there is significant missed shots when clearly the skin has been shot. We identified this issue very early on and you will see here on this server dedi.slice-vps.nl:8888 "Anti-lag enabled" in the bottom right corner.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)