Created
May 5, 2020 14:55
-
-
Save Sajgon/cb37284ee249a1e7adac05708f67dfae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified) | |
if player:hasFlag(PlayerFlag_NotGenerateLoot) then | |
return true | |
end | |
local hasRedSkull = table.contains({SKULL_RED}, player:getSkull()) | |
if hasRedSkull then | |
--// 100% dropchance on everything | |
for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do | |
local item = player:getSlotItem(i) | |
if item then | |
if not item:moveTo(corpse) then | |
item:remove() | |
end | |
end | |
end | |
else | |
--// NOT redskull | |
local amulet = player:getSlotItem(CONST_SLOT_NECKLACE) | |
local lossPercent = player:getLossPercent() | |
if lossPercent == 0 then | |
--// Has full blessings, do nothing. | |
player:sendTextMessage(MESSAGE_INFO_DESCR, "You were protected by all blessings and lost no items.") | |
elseif amulet and amulet.itemid == ITEM_AMULETOFLOSS then | |
--// 0% dropchance cus AOL | |
player:removeItem(ITEM_AMULETOFLOSS, 1, -1, false) | |
else | |
--// Not full blessed, and no AOL | |
for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do | |
local item = player:getSlotItem(i) | |
if item then | |
--// Do not drop exercise weapons | |
if table.contains({7717, 7718, 7719}, item:getId()) == false then | |
if math.random(item:isContainer() and 100 or 1000) <= lossPercent then | |
if not item:moveTo(corpse) then | |
item:remove() | |
end | |
end | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment