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

Droploot and Twist of Fate

icekis

Member
Joined
Jan 18, 2018
Messages
95
Reaction score
6
On my server(OTX3.9) if player only has twist of fate and dies for another player, it loses loot anyway.

How can I do this check?

My droploot:
LUA:
function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if getPlayerFlagValue(player, PlayerFlag_NotGenerateLoot) then -- or player:getVocation():getId() == VOCATION_NONE
        return true
    end

    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
    if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not table.contains({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 table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) or math.random(item:isContainer() and 100 or 1000) <= player:getLossPercent() 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
 
Solution
If i want to do this modification. Can be easily made?
You should be able to do it if you check if the player has twist of fate blessing and if the killer is a player, and then just return true whitout adding items to the body. give me some time and ill try to come up whit some code... hopefully :p

like the script check if the player has the "PlayerFlag_NotGenerateLoot" flag

edit:
@icekis This should prevent the player from droping items if he got only twist of fate.
You should test and see if it still works if the player get killed by a summon by an other player

LUA:
function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if getPlayerFlagValue(player, PlayerFlag_NotGenerateLoot)...
On my server(OTX3.9) if player only has twist of fate and dies for another player, it loses loot anyway.

How can I do this check?

My droploot:
LUA:
function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if getPlayerFlagValue(player, PlayerFlag_NotGenerateLoot) then -- or player:getVocation():getId() == VOCATION_NONE
        return true
    end

    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
    if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not table.contains({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 table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) or math.random(item:isContainer() and 100 or 1000) <= player:getLossPercent() 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
Thats is how its suposed to work, Twist of fate is just to keep your regular blessings when you die to pvp. If you dont have any regular blessings then there is nothing that prevents the player from droping items.
 
If i want to do this modification. Can be easily made?
You should be able to do it if you check if the player has twist of fate blessing and if the killer is a player, and then just return true whitout adding items to the body. give me some time and ill try to come up whit some code... hopefully :p

like the script check if the player has the "PlayerFlag_NotGenerateLoot" flag

edit:
@icekis This should prevent the player from droping items if he got only twist of fate.
You should test and see if it still works if the player get killed by a summon by an other player

LUA:
function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if getPlayerFlagValue(player, PlayerFlag_NotGenerateLoot) then -- or player:getVocation():getId() == VOCATION_NONE
        return true
    end
   
    -- This should prevent the player from droping items if he got twist of fate, even whitout any other blessings
    local TWIST_OF_FATE = 6
    if player:hasBlessing(TWIST_OF_FATE) and not table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        if killer:isPlayer() then
            return true
        else
            local summonKiller = killer:getMaster()
            if summonKiller and summonKiller:isPlayer() then
                return true
            end
        end
    end

    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
    if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not table.contains({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 table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) or math.random(item:isContainer() and 100 or 1000) <= player:getLossPercent() 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
 
Last edited:
Solution
You should be able to do it if you check if the player has twist of fate blessing and if the killer is a player, and then just return true whitout adding items to the body. give me some time and ill try to come up whit some code... hopefully :p

like the script check if the player has the "PlayerFlag_NotGenerateLoot" flag

edit:
@icekis This should prevent the player from droping items if he got only twist of fate.
You should test and see if it still works if the player get killed by a summon by an other player

LUA:
function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if getPlayerFlagValue(player, PlayerFlag_NotGenerateLoot) then -- or player:getVocation():getId() == VOCATION_NONE
        return true
    end
   
    -- This should prevent the player from droping items if he got twist of fate, even whitout any other blessings
    local TWIST_OF_FATE = 6
    if player:hasBlessing(TWIST_OF_FATE) then
        if killer:isPlayer() then
            return true
        else
            local summonKiller = killer:getMaster()
            if summonKiller and summonKiller:isPlayer() then
                return true
            end
        end
    end

    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
    if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not table.contains({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 table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) or math.random(item:isContainer() and 100 or 1000) <= player:getLossPercent() 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

Perfect!! One last question, if i am red skull and have twist of fate, i will drop anyway? i hope yes
 
Perfect!! One last question, if i am red skull and have twist of fate, i will drop anyway? i hope yes
Oh i didnt even account for that, im sure you wont drop anything if you are red or black skull and got the twist of fate blessing.

but its a quick and easy fix

change this line
LUA:
if player:hasBlessing(TWIST_OF_FATE) then

to this and you should drop your items whit red/black skull
LUA:
if player:hasBlessing(TWIST_OF_FATE) and not table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) then

main post updated aswell
 

Similar threads

Replies
1
Views
125
Xikini
X
Back
Top