sCy User Offline
Well, it has a BIG problem. Even when nz_maxHealth haves value of like 5000, the 1 shotgun blast still kills it (and shotgun dmg is 25.
The 3 parts of code what cooperate:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function nz_updateHealth(id)
	if (nz_health[id] < 250 and nz_maxHealth[id] < 251) then
		parse('setmaxhealth '..id..' '..nz_maxHealth[id])
		parse('sethealth '..id..' '..nz_health[id])
		return 1
	end
end
nz_health[id] = nz_maxHealth[id]
function nz_hit(id, source, weapon, healthDamage, armorDamage)
	if (player(id, "team") == 1 and player(source, "team") == 2) then
		local damage = itemtype(weapon, "dmg")
		
		if (nz_health[id] > damage) then
			nz_health[id] = nz_health[id] - damage
			
			nz_updateHealth(id)
			
			return 1
		end
	end
	
	if (weapon == 255) then
		setPos(id, nz_lastTileX[id] * 32 + 16, nz_lastTileY[id] * 32 + 16)
		
		nz_slow(id, -100, 500)
		
		return 1
	end
end
Any ideas what cause this? edited 2×, last 12.02.12 05:42:53 pm
Admin/mod comment
You can stop constantly pushing your thread now. Yes, shotgun shoots 5 bullets which is over 100 hp damage. Return the damage and then remove it from the extra HP. edited 1×, last 12.02.12 02:47:36 pm
sCy User Offline
In english please? As I dont understand much lua =P sCy has written
In english please?
You stupid? THAT IS FUCKING ENGLISH. sCy has written
In english please? As I dont understand much lua =P
sCy User Offline
-.- I didnt mean that, I just was saying that is complicated and I dont understand.. BTW, dont go offtopic... A shotgun shoots 5 bullets, so that's 25 multiplied by 5 = 125. Which would kill anything with 100 HP. If you want to stop this, return the damage (return 1) and then remove the damage caused on the extra HP you have. Meaning, the person won't die. But the HP still gets removed. sCy User Offline
Got it! Heres the fixed version:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
parse("mp_wpndmg 255 0")
function nz_updateHealth(id)
	local percent = math.floor((nz_health[id] / nz_maxHealth[id]) * 100)
	
	if (percent < 1) then
		percent = 1
	end
	
	parse("sethealth "..id.." "..percent)
end
function nz_hit(id, source, weapon, healthDamage, armorDamage)
	if (player(id, "team") == 1 and player(source, "team") == 2) then
		local damage = itemtype(weapon, "dmg")
		
		if (nz_health[id] > damage) then
			nz_health[id] = nz_health[id] - damage
			
			nz_updateHealth(id)
			
			return 1
		end
	end
	
	if (weapon == 255) then
		parse("setpos "..id.." "..(nz_lastTileX[id]*32+16).." "..(nz_lastTileY[id]*32+16))
		
		return 1
	end
end
edited 1×, last 12.02.12 10:39:20 pm