Page 1 of 1

"Summoned" creature not appearing until a turn later

Posted: Sun Aug 01, 2010 7:19 pm
by yufra
I believe this to be a nuanced when-things-are-displayed-to-screen bug, and rather than poke around in the Map internals until I will my hair out I figured I would ask around first. :)

I am implementing the conversion from human to zombie in my module, and decided to put the code in mod.class.NPC.act function. The code looks like this:

Code: Select all

	-- Check if we should turn into a ZOMBIE?!
	if self.type == "humanoid" and self.subtype ~= "zombie" and self.vload >= self.max_vload then
		-- Create the replacement zombie
		local z = game.zone:makeEntityByName(game.level, "actor", "ZOMBIE")
		game.zone:addEntity(game.level, z, "actor", self.x, self.y)
		game.level.map:particleEmitter(self.x, self.y, 1, "acid")
		
		game.logPlayer(game.player, "%s just turned into a zombie!", self.name)
		self:die()
	end
The net effect is that the NPC explodes in a pretty green splash, the original character disappears and... nothing else. The area where the zombie "z" should have been added is just showing the terrain. If I then move the player character and cause the game to tick the zombie character appears after it moves towards the player. I tried looking at the ToME summoning talents since they have the behavior that I want but I do not see the difference. Any ideas?

Re: "Summoned" creature not appearing until a turn later

Posted: Sun Aug 01, 2010 7:38 pm
by darkgod
Classic bug :)

What happens is that a spot on that map can only contain one actor, here is what happens at coord self.x, self.y:
* human is in the map
* zombie is created
* zombie is added to the map, removing the entry for the human
* human :die(), this removes the actor from the map at the location self.x, self.y

But at this time it was the zombie that was there not the human.
You just need to do things in order:
* human:die()
* THEN add the zombe

Re: "Summoned" creature not appearing until a turn later

Posted: Sun Aug 01, 2010 7:43 pm
by yufra
Voila! Thanks DG... so much easier than trying to figure that out on my own. :D