Page 2 of 4

Re: Check if spawned monster is dead

Posted: Fri Oct 31, 2014 6:36 pm
by Jouki
I guess I have another problem the monstergroup doesn't have a connectors so I can't add "onDie" connector. any suggestions?

Re: Check if spawned monster is dead

Posted: Fri Oct 31, 2014 6:59 pm
by Prozail
still havn't figured out how to work with monster Groups...

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

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.

Re: Check if spawned monster is dead

Posted: Fri Oct 31, 2014 8:14 pm
by Jouki
Prozail wrote:still havn't figured out how to work with monster Groups...

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

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.
how can I set coords of spawning position?

Re: Check if spawned monster is dead

Posted: Fri Oct 31, 2014 8:58 pm
by SnowyOwl47
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...

Code: Select all

function dead()
     while monster.monster:getHealth() == not 0 do
     else
           --something...
     end
end
Something like that...

Re: Check if spawned monster is dead

Posted: Fri Oct 31, 2014 9:13 pm
by Jouki
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 :cry: :cry: I feel I'm almost on the end this whole tunnel of problems :evil:

Re: Check if spawned monster is dead

Posted: Fri Oct 31, 2014 9:38 pm
by Prozail
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

Re: Check if spawned monster is dead

Posted: Fri Oct 31, 2014 10:17 pm
by Jouki
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) :cry:

Re: Check if spawned monster is dead

Posted: Fri Oct 31, 2014 10:19 pm
by NutJob
disableSelf

Re: Check if spawned monster is dead

Posted: Fri Oct 31, 2014 10:23 pm
by Jouki
NutJob wrote:disableSelf
I dont mean troopers are spawning again and again (I can handle that :P) what I mean is that these coordinates doesnt working, I have absolutely no idea why it doesnt :shock:

Re: Check if spawned monster is dead

Posted: Fri Oct 31, 2014 10:26 pm
by Prozail
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 :lol: )