
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