Check if spawned monster is dead [Solved]
Re: Check if spawned monster is dead
I guess I have another problem the monstergroup doesn't have a connectors so I can't add "onDie" connector. any suggestions?
Last edited by Jouki on Thu Nov 06, 2014 10:40 pm, edited 1 time in total.
Re: Check if spawned monster is dead
still havn't figured out how to work with monster Groups...
this is as far as i've come.
It seems that, the monstergroup doesn't spawn the actual monsters until the next frame, so, if you don't call "spawnNow" there are no monsters to add events to.
And... if you call "spawnNow" the monstergroup destroys itself after creating the monster pair.
so.. i Think the above code is the way to do it.
this is as far as i've come.
Code: Select all
function spawner(c)
enemySkeleton2 = c.go:spawn("skeleton_trooper_pair")
enemySkeleton2.monstergroup:spawnNow()
-- print(enemySkeleton2.id) -- this gives "Bad object error"
for e in self.go.map:entitiesAt(c.go.x, c.go.y) do
if e.monster then e.monster:addConnector("onDie",self.go.id,"deadCheckerSkeleton") end
end
end
function deadCheckerSkeleton()
print ("moo")
hudPrint("Moo!")
end
And... if you call "spawnNow" the monstergroup destroys itself after creating the monster pair.
so.. i Think the above code is the way to do it.
Links to my YouTube playlist of "tutorials" and to my forum thread.
Re: Check if spawned monster is dead
how can I set coords of spawning position?Prozail wrote:still havn't figured out how to work with monster Groups...
this is as far as i've come.It seems that, the monstergroup doesn't spawn the actual monsters until the next frame, so, if you don't call "spawnNow" there are no monsters to add events to.Code: Select all
function spawner(c) enemySkeleton2 = c.go:spawn("skeleton_trooper_pair") enemySkeleton2.monstergroup:spawnNow() -- print(enemySkeleton2.id) -- this gives "Bad object error" for e in self.go.map:entitiesAt(c.go.x, c.go.y) do if e.monster then e.monster:addConnector("onDie",self.go.id,"deadCheckerSkeleton") end end end function deadCheckerSkeleton() print ("moo") hudPrint("Moo!") end
And... if you call "spawnNow" the monstergroup destroys itself after creating the monster pair.
so.. i Think the above code is the way to do it.
- SnowyOwl47
- Posts: 148
- Joined: Fri Sep 12, 2014 10:41 pm
Re: Check if spawned monster is dead
I use this in my dungeons.
What I used was on die trigger yes but if you want to do more I had a loop that would check to see if the monsters health == 0 and if not it would restart the function.
I don't remember why I used this instead of onDie...
Something like that...
What I used was on die trigger yes but if you want to do more I had a loop that would check to see if the monsters health == 0 and if not it would restart the function.
I don't remember why I used this instead of onDie...
Code: Select all
function dead()
while monster.monster:getHealth() == not 0 do
else
--something...
end
end
Re: Check if spawned monster is dead
actaully the problem with 'onDie' is solved, only and I'm almost sure LAST problem is how can I set coords on skeleton_trooper_pair. it's working what prozail sent but last thing is how to set position. I've been trying combinations but no success I feel I'm almost on the end this whole tunnel of problems
Re: Check if spawned monster is dead
You don't HAVE to use the caller-references, you can go with the hardcoded approach, since i don't really know how you've set tings up.
Code: Select all
function spawner(c)
enemySkeleton2 = spawn("skeleton_trooper_pair", 1 , 10,10,0,0 )
enemySkeleton2.monstergroup:spawnNow()
for e in self.go.map:entitiesAt(10,10) do
if e.monster then e.monster:addConnector("onDie",self.go.id,"deadCheckerSkeleton") end
end
end
function deadCheckerSkeleton()
hudPrint("Moo!")
end
Links to my YouTube playlist of "tutorials" and to my forum thread.
Re: Check if spawned monster is dead
Prozail wrote:You don't HAVE to use the caller-references, you can go with the hardcoded approach, since i don't really know how you've set tings up.
Code: Select all
function spawner(c) enemySkeleton2 = spawn("skeleton_trooper_pair", 1 , 10,10,0,0 ) enemySkeleton2.monstergroup:spawnNow() for e in self.go.map:entitiesAt(10,10) do if e.monster then e.monster:addConnector("onDie",self.go.id,"deadCheckerSkeleton") end end end function deadCheckerSkeleton() hudPrint("Moo!") end
I've tried this (even something similar), it doesn't crash the game but the troopers still spawning on the pressure plate (same location)
Re: Check if spawned monster is dead
disableSelf
Re: Check if spawned monster is dead
I dont mean troopers are spawning again and again (I can handle that ) what I mean is that these coordinates doesnt working, I have absolutely no idea why it doesntNutJob wrote:disableSelf
Re: Check if spawned monster is dead
Are you sure you're connected to the right script?
I just ran that one.. differnet hardcoded coords, but still, and that worked fine. (and it was a kinda small room and i got overrun by skeletons pretty quickly )
I just ran that one.. differnet hardcoded coords, but still, and that worked fine. (and it was a kinda small room and i got overrun by skeletons pretty quickly )
Links to my YouTube playlist of "tutorials" and to my forum thread.