local config = {
["rat"] = {name = "Rotworm", count = 1, chance = 100},
["cave rat"] = {name = "Rotworm Queen", count = 1, chance = 100}
}
local born = CreatureEvent("BornExample")
function born.onDeath(monster)
local bornConfig = config[monster:getName():lower()]
if not bornConfig then return true end
if bornConfig.count and bornConfig.count <= 0 then return true end
local chance = bornConfig.chance or 100
if math.random(100) > chance then return true end
local pos = monster:getPosition()
for i = 1, bornConfig.count do
Game.createMonster(bornConfig.name, pos, true)
end
return true
end
born:register()
local event = EventCallback
function event.onSpawn(monster, position, startup, artificial)
if config[monster:getName():lower()] then
monster:registerEvent("BornExample")
end
return true
end
event:register()