• 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!

Amulet of Loss PvE Only

krafttomten

Well-Known Member
Joined
Jul 23, 2017
Messages
103
Solutions
1
Reaction score
75
Location
Sweden
I need a script that makes it so that the AoL only triggers if the player was killed by monsters. If the player was killed by another player, the player should still drop items just like as if he has no AoL. I'm running the forgotten server 8.6 compiled with tfs-sdk-3.2 and this is the .lua script I already have related to dropping loot.

Lua:
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 hasSkull = isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull())
    if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not hasSkull 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
        local lossPercent = player:getLossPercent()
        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

I've changed around everything I cound think of in this script to make it work but I've been unable to fix it myself, I'm also suspecting that the AoL script itself might be hidden in other files (compiled?) that I'm way too noob to handle yet.. If anyone can help in any way I would be very happy indeed!
 
Solution
Lua:
if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not hasSkull then

Lua:
if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not hasSkull and killer:isMonster() then
Lua:
if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not hasSkull then

Lua:
if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not hasSkull and killer:isMonster() then
 
Solution
Back
Top