Weapon Damages
#1

Hi, I'm creating custom damages right now, but the problem is when I shoot any bodyparts that shouldn't take armor, but health straightly are killing the player instantly. Headshot is supposed to be instant kill though (100 damage) and legs and arms are supposed to take a little bit less damage. I printed the damages and the damages are like 100000000000. It works good if I shoot bodyparts that take armor though. This is what I got under OnPlayerGiveDamage:
Код:
		switch (weaponid)
		{
			case 22: amount = 30;
			case 23: amount = 40;
			case 24: amount = 50;
			case 25: amount += 25;
			case 26: amount += 20;
			case 27: amount += 30;
			case 28: amount = 25;
			case 29: amount = 30;
			case 30: amount = 45;
			case 31: amount = 40;
			case 32: amount = 25;
			case 33: amount = 60;
			case 34: amount = 80;
			case 38: amount = 65;
		}
		switch (bodypart)
		{
			case 9: amount = 100;
			case 5, 6: amount -= 10;
			case 7, 8: amount -= 15;
		}
What's up?
Reply
#2

Could you show the full code for this? have you made any other alterations to the amount variables? Also some of those values seem extremely high.
Reply
#3

Quote:
Originally Posted by azzerking
Посмотреть сообщение
Could you show the full code for this? have you made any other alterations to the amount variables? Also some of those values seem extremely high.
There's nothing above it that could cause it. Only ifs that check if player is dead etc.

EDIT: Nevermind, I'm not sure if the damages are like 100000000, I just realized that I printed a float with %d. But still it's instant kill for legs and arms for some reason.

Here's what I got below it:
Код:
		switch (bodypart)
		{
			case 5..9: // bodyparts that take health regardless of armor
			{
				if (PlayerInfo[damagedid][pHealth] > amount) SetCustomHealth(damagedid, PlayerInfo[damagedid][pHealth] - amount);
				else SetDeathState(damagedid, DEATH_STATE_INJURED);
			}
			case 3, 4: // these take armor
			{
				if (PlayerInfo[damagedid][pArmor] > amount) SetCustomArmor(damagedid, PlayerInfo[damagedid][pArmor] - amount);
				else if (PlayerInfo[damagedid][pArmor])
				{
					amount -= PlayerInfo[damagedid][pArmor];
					SetCustomArmor(damagedid, 0.0);
					
					if (amount)
					{
						if (PlayerInfo[damagedid][pHealth] > amount) SetCustomHealth(damagedid, PlayerInfo[damagedid][pHealth] - amount);
						else SetDeathState(damagedid, DEATH_STATE_INJURED);
					}
				}
				else if (PlayerInfo[damagedid][pHealth] > amount) SetCustomHealth(damagedid, PlayerInfo[damagedid][pHealth] - amount);
				else SetDeathState(damagedid, DEATH_STATE_INJURED);
			}
		}
Reply
#4

What weapons are you using to test this? and what are the printed damaged values for that weapon?

The only thing I can see is that maybe the amount variable is being altered somewhere else to be more? or the players health from the variable PlayerInfo[damagedid][pHealth] might be incorrect or handled incorrectly.
Reply
#5

It happens with any weapon. Chest and torso are working properly because they "got armor on them", but other bodyparts are instant kills. I'll print the damages tomorrow, I can't at the moment.
Reply
#6

What does this PlayerInfo[damagedid][pHealth] equal at the time? I have a feeling is less then amount and thats why SetDeathState is being called? Could I ask exactly what SetDeathState does?
Reply
#7

It puts player in injured mode. And no, pHealth is good, I have custom health and armor bars that show pHealth and pArmor value so it's all good. I'll just print the damages tomorrow.
Reply
#8

The problem was that I was subtracting an integer from a float using -= so the damage was like 100000000 for some reason. I could fix it by subtracting a float from amount instead of an integer. (like 15.0 and 10.0 instead of 15 and 10).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)