Sergio Rosendo
Member
- Joined
- Dec 13, 2015
- Messages
- 45
- Reaction score
- 13
Distro Name: TFS 1.2
Script type: Lua script
Description of the script: Upon death the script would check if player has certain itens in his backpack. For each of those itens the script would have a 5% chance to remove them from the player and add them to the player's dead body. (this drop chance would still be taken in consideration even with amulet of loss and full blessings)
File: data/creaturescripts/scripts/others/droploot.lua
example of IDs of itens the script would consider: {2195, 2187, 8878} (boh, wand of inferno, crystaline armor}
unedited droploot.lua
Thanks for your help.
Script type: Lua script
Description of the script: Upon death the script would check if player has certain itens in his backpack. For each of those itens the script would have a 5% chance to remove them from the player and add them to the player's dead body. (this drop chance would still be taken in consideration even with amulet of loss and full blessings)
File: data/creaturescripts/scripts/others/droploot.lua
example of IDs of itens the script would consider: {2195, 2187, 8878} (boh, wand of inferno, crystaline armor}
unedited droploot.lua
Code:
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)
if amulet and amulet.itemid == ITEM_AMULETOFLOSS 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 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)
if item then
if isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) or math.random(item:isContainer() and 100 or 1000) <= player:getLossPercent() then
item:moveTo(corpse)
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
Thanks for your help.