Forum

> > CS2D > Scripts > Zombie Health
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Zombie Health

8 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Zombie Health

sCy
User Off Offline

Zitieren
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?
2× editiert, zuletzt 12.02.12 17:42:53

Admin/Mod Kommentar

You can stop constantly pushing your thread now.

alt Re: Zombie Health

Yates
Reviewer Off Offline

Zitieren
Yes, shotgun shoots 5 bullets which is over 100 hp damage. Return the damage and then remove it from the extra HP.
1× editiert, zuletzt 12.02.12 14:47:36

alt Re: Zombie Health

sCy
User Off Offline

Zitieren
-.- I didnt mean that, I just was saying that is complicated and I dont understand.. BTW, dont go offtopic...

alt Re: Zombie Health

Yates
Reviewer Off Offline

Zitieren
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.

alt Re: Zombie Health

sCy
User Off Offline

Zitieren
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
1× editiert, zuletzt 12.02.12 22:39:20
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht