Forum

> > CS2D > Scripts > Check HP of NPC's
Forums overviewCS2D overview Scripts overviewLog in to reply

English Check HP of NPC's

2 replies
To the start Previous 1 Next To the start

old Check HP of NPC's

AtomKuh
User Off Offline

Quote
Hey us ,

is it possible to check the HP of NPC's with a script? I want to respawn a NPC after it is dead.

Atom

old Re: Check HP of NPC's

Bowlinghead
User Off Offline

Quote
NPCs are objects with object-type 30. Their player mode is what they make Zombies/.../etc.
1
2
3
4
5
6
7
8
9
10
11
addhook("objectkill","respawnNPC")
function respawnNPC(id)
	if (object(id,"type") == 30) then -- if NPC
		local x = object(id,"x") -- maybe tilex
		local y = object(id,"y") -- maybe tiley
		local player = object(id,"player")
		local rot = object(id,"rot")
		parse("spawnobject 30 "..x.." "..y.." "..rot.." 0 0 "..player)
	end
end
--untested

For checking HP:
1
object(id,"health")

http://www.cs2d.com/help.php?hookcat=all&hook=objectkill#hook
http://www.cs2d.com/help.php?luacat=all&luacmd=object#cmd
http://www.cs2d.com/help.php?cat=all&cmd=spawnobject#cmd
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview