• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved How to make a Custom Amulet of Loss? |TFS 1.3| |8.6|

chyssler

Member
Joined
May 8, 2012
Messages
41
Reaction score
7
Hello there, I was wondering if you guys would be able to help me out here, I have Amulet of Loss fully working as I want it to, But its only 1 item (I want more Amulets, for upgrades etc) So If im making a Custom Amulet, How do I make it so it was the same effect as the Amulet of Loss (Not loosing Items Upon death, And levels)
 
You'd want to edit droploot.lua

function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
if getPlayerFlagValue(player, PlayerFlag_NotGenerateLoot) then --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(5) then

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
local bag = player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
end
return true
end

Im assuming that I need to add an additional row somewhere, to locate if the player got the other necklace. but im not 100% sure
Post automatically merged:

Im assuming that I need to add an additional row somewhere, to locate if the player got the other necklace. but im not 100% sure
Can I add it like this instead?

local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
if amulet and amulet.itemid == 2173, 12681 and not isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
local isPlayer = false
 
This should be what you want:
Lua:
local amulets = {2173, 12681}

function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return true
    end

    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
    local isRedOrBlack = isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull())
    if not amulet or (amulet and not isInArray(amulets, amulet.itemid)) or isRedOrBlack then
        for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
            local item = player:getSlotItem(i)
            local lossPercent = player:getLossPercent()
            if item then
                if isRedOrBlack or math.random(item:isContainer() and 100 or 1000) <= lossPercent then
                    if (isRedOrBlack or lossPercent ~= 0) and 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
 
This should be what you want:
Lua:
local amulets = {2173, 12681}

function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return true
    end

    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
    local isRedOrBlack = isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull())
    if not amulet or (amulet and not isInArray(amulets, amulet.itemid)) or isRedOrBlack then
        for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
            local item = player:getSlotItem(i)
            local lossPercent = player:getLossPercent()
            if item then
                if isRedOrBlack or math.random(item:isContainer() and 100 or 1000) <= lossPercent then
                    if (isRedOrBlack or lossPercent ~= 0) and 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
Thank you so much again :D
 
Back
Top