Re: Check if spawned monster is dead
Posted: Fri Oct 31, 2014 6:36 pm
I guess I have another problem the monstergroup doesn't have a connectors so I can't add "onDie" connector. any suggestions?
Official Legend of Grimrock Forums
http://grimrock.net/forum/
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
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.
Code: Select all
function dead()
while monster.monster:getHealth() == not 0 do
else
--something...
end
end
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
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 dont mean troopers are spawning again and again (I can handle thatNutJob wrote:disableSelf