"Summoned" creature not appearing until a turn later

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
yufra
Perspiring Physicist
Posts: 1332
Joined: Tue Jul 13, 2010 2:53 pm

"Summoned" creature not appearing until a turn later

#1 Post 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?
<DarkGod> lets say it's intended

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

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

#2 Post 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
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

yufra
Perspiring Physicist
Posts: 1332
Joined: Tue Jul 13, 2010 2:53 pm

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

#3 Post by yufra »

Voila! Thanks DG... so much easier than trying to figure that out on my own. :D
<DarkGod> lets say it's intended

Post Reply