Sergio Rosendo
Member
- Joined
- Dec 13, 2015
- Messages
- 45
- Reaction score
- 13
I'm trying to make it so that when the player dies, it will drop all the gold he is carrying (even with aol and/or full blessings).
So the file that takes care of this is droploot.lua, as you can see in the comments inside the code, I edited it.
The idea is pretty simple, but its my first try at making something up all by myself. So be nice please.
creaturescripts/scripts/others/droploot.lua:
I don't have my server up atm to test it myself.
Is this gonna work? Is it performace inneficient?
Thanks for your help.
So the file that takes care of this is droploot.lua, as you can see in the comments inside the code, I edited it.
The idea is pretty simple, but its my first try at making something up all by myself. So be nice please.
creaturescripts/scripts/others/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
-- Upon death player drops all the money he is carrying
-- THIS IS WHAT I ADDED
local coins = player:getMoney()
player:removeMoney(coins)
while coins > 10000 do
local cc = cc + 1
coins = coins - 10000
end
while coins > 100 do
local pc = pc + 100
coins = coins - 100
end
while coins > 0 do
local gc = gc + 1
coins = coins - 1
end
ContainerAddItem(corpse, 2160, cc)
ContainerAddItem(corpse, 2152, pc)
ContainerAddItem(corpse, 2148, gc)
-- Nothing else was changed after this line
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
I don't have my server up atm to test it myself.
Is this gonna work? Is it performace inneficient?
Thanks for your help.
Last edited: