Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function playerDeathInfo(info)
- local file = io.open("data/logs/itemdrop.txt", "a")
- if not file then
- return true
- end
- io.output(file)
- io.write(info)
- io.close(file)
- end
- function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
- if getPlayerFlagValue(player, PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
- return true
- end
- local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
- local amulets = {ITEM_AMULETOFLOSS, 2131, 18407, 18402}
- if amulet and isInArray(amulets, amulet.itemid) and not isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
- local isPlayer = false
- if killer then
- if killer:isPlayer() then
- isPlayer = true
- else
- local master = killer:getMaster()
- if master and master:isPlayer() then
- isPlayer = true
- end
- end
- end
- if amulet.itemid == ITEM_AMULETOFLOSS then
- if not isPlayer or not player:hasBlessing(6) then
- player:removeItem(ITEM_AMULETOFLOSS, 1, -1, false)
- end
- end
- else
- local lossPercent = player:getLossPercent()
- playerDeathInfo(string.format("Player Name: %s, Skull Type: %d, Blessings: %d, Loss Percent: %d.\n", player:getName(), player:getSkull(), player:getBlessings(), lossPercent))
- for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
- local item = player:getSlotItem(i)
- if item then
- if hasSkull or math.random(item:isContainer() and 100 or 1000) <= lossPercent then
- if not item:moveTo(corpse) then
- item:remove()
- end
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement