Spawning a new monster on top of a dying one?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
Ixnatifual

Spawning a new monster on top of a dying one?

Post by Ixnatifual »

I have a monster where I've changed the onDie hook so it spawns a different monster on top of where it died. There's a problem with this approach, namely that the player, if spamming the forward key, can walk in and occupy the square where the monster is spawned as the previous one dies!

Anyone know of a way to prevent this?
Ixnatifual

Re: Spawning a new monster on top of a dying one?

Post by Ixnatifual »

OK I figured I'd use the onDamage hook instead. Unfortunately the game crashes when I attempt to call the destroy() command.

Can anyone see what I'm doing wrong?

Code: Select all

  onDamage = function(self, amount, type)
    hudPrint("What?! I'm a snail?!!")
    spawn("snail", self.level, self.x, self.y, self.facing)
    self:destroy() -- If I remove this line it works.
  end
Ixnatifual

Re: Spawning a new monster on top of a dying one?

Post by Ixnatifual »

Meh, I don't think that would work anyway. Even if I spawn the second monster on top of the current monster and then teleport the first monster away as it takes damage, the player can still move into the square.
Ixnatifual

Re: Spawning a new monster on top of a dying one?

Post by Ixnatifual »

I discovered when you spawn a monster on top of another, it stops blocking for a bit. That's why you can enter the square. When I teleported the original monster away before spawning the new one, it worked.

I can then call self:setHealth(0) to kill it off. However this awards the player experience, which I'd prefer it didn't. But then again I can just set the first monster's XP value to 0.
Ixnatifual

Re: Spawning a new monster on top of a dying one?

Post by Ixnatifual »

Ixnatifual wrote:But then again I can just set the first monster's XP value to 0.
Damn, a scrolling text saying "+0 XP" pops up when you kill it. Not what I want.
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Spawning a new monster on top of a dying one?

Post by msyblade »

Interesting stuff, thanx for the feed. :)
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
Ixnatifual

Re: Spawning a new monster on top of a dying one?

Post by Ixnatifual »

msyblade wrote:Interesting stuff, thanx for the feed. :)
Glad to be of service :mrgreen:
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Spawning a new monster on top of a dying one?

Post by Komag »

you could teleport it away, then set a very short 0.05s timer which THEN does destroy() on it, and I don't think you get XP from that.
Finished Dungeons - complete mods to play
Ixnatifual

Re: Spawning a new monster on top of a dying one?

Post by Ixnatifual »

I was hoping to avoid that. But it works - thanks! My guess is it's a problem to delete an entity from within a script attached to said entity.
Post Reply