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?
Spawning a new monster on top of a dying one?
-
Ixnatifual
Re: Spawning a new monster on top of a dying one?
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?
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?
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?
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.
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?
Damn, a scrolling text saying "+0 XP" pops up when you kill it. Not what I want.Ixnatifual wrote:But then again I can just set the first monster's XP value to 0.
Re: Spawning a new monster on top of a dying one?
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
"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?
Glad to be of servicemsyblade wrote:Interesting stuff, thanx for the feed.
Re: Spawning a new monster on top of a dying one?
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?
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.
