2020-06-08 22:07:08 -03:00
|
|
|
function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
|
2017-12-19 20:47:29 -02:00
|
|
|
if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
|
2015-02-01 14:08:15 +01:00
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
|
2020-04-30 18:44:47 -03:00
|
|
|
local isRedOrBlack = table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull())
|
|
|
|
|
if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not isRedOrBlack then
|
2015-02-01 14:08:15 +01:00
|
|
|
local isPlayer = false
|
2015-06-23 10:40:38 +02:00
|
|
|
if killer then
|
|
|
|
|
if killer:isPlayer() then
|
2015-02-01 14:08:15 +01:00
|
|
|
isPlayer = true
|
2015-06-23 10:40:38 +02:00
|
|
|
else
|
|
|
|
|
local master = killer:getMaster()
|
|
|
|
|
if master and master:isPlayer() then
|
|
|
|
|
isPlayer = true
|
|
|
|
|
end
|
2015-02-01 14:08:15 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if not isPlayer or not player:hasBlessing(6) then
|
|
|
|
|
player:removeItem(ITEM_AMULETOFLOSS, 1, -1, false)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
|
|
|
|
|
local item = player:getSlotItem(i)
|
2020-04-30 18:44:47 -03:00
|
|
|
local lossPercent = player:getLossPercent()
|
2015-02-01 14:08:15 +01:00
|
|
|
if item then
|
2020-04-30 18:44:47 -03:00
|
|
|
if isRedOrBlack or math.random(item:isContainer() and 100 or 1000) <= lossPercent then
|
|
|
|
|
if (isRedOrBlack or lossPercent ~= 0) and not item:moveTo(corpse) then
|
2015-03-15 14:26:38 +01:00
|
|
|
item:remove()
|
|
|
|
|
end
|
2015-02-01 14:08:15 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if not player:getSlotItem(CONST_SLOT_BACKPACK) then
|
|
|
|
|
player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
|
|
|
|
|
end
|
|
|
|
|
return true
|
|
|
|
|
end
|