local config = {
corpseTempPosition = Position(999, 1004, 5),
delay = 1000,
key = "corpseIdentifier"
}
local corpseidentifier = 0
local function moveCorpse(position, corpseIdentifier)
local tileItems = Tile(config.corpseTempPosition):getItems()
for _, corpse in pairs(tileItems) do
local identifier = corpse:getCustomAttribute(config.key)
if identifier == corpseIdentifier then
corpse:moveTo(position)
corpse:removeAttribute(config.key)
return
end
end
if corpseidentifier == corpseIdentifier then
corpseidentifier = 0
end
end
local creatureevent = CreatureEvent ("MonsterDeathAnimation")
function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
if corpse and corpse:isItem() then
local position = creature:getPosition()
position:sendMagicEffect(106)
corpseidentifier = corpseidentifier + 1
corpse:moveTo(config.corpseTempPosition)
corpse:setCustomAttribute(config.key, corpseidentifier)
addEvent(moveCorpse, config.delay, position, corpseidentifier)
end
return true
end
creatureevent:register()
local eventcallback = EventCallback
eventcallback.onSpawn = function(self, position, startup, artificial)
self:registerEvent("MonsterDeathAnimation")
return true
end
eventcallback:register()