Forum

> > CS2D > Scripts > Killed By a NPC
Forums overviewCS2D overview Scripts overviewLog in to reply

English Killed By a NPC

8 replies
To the start Previous 1 Next To the start

old Killed By a NPC

J_Lucas
User Off Offline

Quote
hi , im tryng to do a zombie mod
and i need know , if is possible , when got killed by a NPC , add a customkill like :
• sheep NPC headcrab

this is possible ? and if yes , what hook is needed be used ?

Thanks For The Time ... and Help

old Re: Killed By a NPC

Rainoth
Moderator Off Offline

Quote
1
2
3
4
5
6
addhook("kill","magicpotato")
function magicpotato(kil,vic,wep,x,y)
	if object(kil,"health")==INSERTHEADCRABSHEALTHHERE then
	parse("custom kill -- etc. etc.)
	end
end

You can find NPC health's in editor.
Edit : Tho I think you need to check if hp is bigger than zero and less than the limit. Also I'm pretty sure it would fail if you got killed by a turret that has same ammount of health so be wary of that.

old Re: Killed By a NPC

J_Lucas
User Off Offline

Quote
i tried
1
2
3
4
5
6
7
8
addhook('die','a')
function a()
for id = 1 ,32 do
if (object(obj,"type")==30) then
parse('customkill '..id..' Zombie '..id..'')
end
end
end

But say
Creature sheep
sheep Zombie

I suicided and got killed by a creature in the same time

old Re: Killed By a NPC

Avo
User Off Offline

Quote
You have to use "hit" hook, not "die". (in hit hook you have to check if player's hp - damage <= 0)

old Re: Killed By a NPC

VADemon
User Off Offline

Quote
Last time I tested that:
CS2D uses IDs (1-32) ONLY for players/bots. All editor/object stuff has just its own WEAPON ID, look for it. // As far as I know

old Re: Killed By a NPC

J_Lucas
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
equip = {}
equip[1] = '69'

addhook('hit','zm_zom_die_ct')
function zm_zom_die_ct(obj,id)
for id = 1,32 do
local x = player(id,'x')
local y = player(id,'y')
if player(id,'health') == 10 then
if object(obj,"type")==30 then
parse('customkill '..id..' Zombie '..id..'')
parse('maket '..id..'')
parse('spawnplayer '..id..' '..x..' '..y..'')
parse('strip '..id..' '..equip[1]..'')
parse('equip '..id..' '..equip[1]..'')
return 1
end
end
end
end

It Worked Good
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview