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

Compiling How i add new item as amulet of loss? TFS 1.2

digomaciel

New Member
Joined
Dec 5, 2008
Messages
28
Reaction score
0
Location
HUEHUE LANDIA
Last edited:
data\creaturescripts\scripts\droploot
Lua:
local amulets = {2173, 2138, 2218, 2196, 7890, 8297, 8298, 8299, 2126, 8372, 8373, 8374}
local forevers = {2196, 7890, 8297, 8298, 8299, 2126, 8372, 8373, 8374,}

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

    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
        local isRedOrBlack = false
    if amulet and isInArray(amulets, amulet.itemid) and not isRedOrBlack 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
            if not isInArray(forevers, amulet.itemid) then
                amulet:remove()
            end
        end
    else
        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
You do not need to compile to add a new AOL
 
data\creaturescripts\scripts\droploot
Lua:
local amulets = {2173, 2138, 2218, 2196, 7890, 8297, 8298, 8299, 2126, 8372, 8373, 8374}
local forevers = {2196, 7890, 8297, 8298, 8299, 2126, 8372, 8373, 8374,}

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

    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
        local isRedOrBlack = false
    if amulet and isInArray(amulets, amulet.itemid) and not isRedOrBlack 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
            if not isInArray(forevers, amulet.itemid) then
                amulet:remove()
            end
        end
    else
        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
You do not need to compile to add a new AOL
i dont have droploot, so i added it.
at creaturescripts.xml, added:
XML:
<event type="death" name="droploot" script="droploot.lua"/>
also include my aol id to amulets and dont work
 
i dont have droploot, so i added it.
at creaturescripts.xml, added:
XML:
<event type="death" name="droploot" script="droploot.lua"/>
also include my aol id to amulets and dont work
local amulets = {2173, 2138, 2218, 2196, 7890, 8297, 8298, 8299, 2126, 8372, 8373, 8374} --Here add aol

items xml
XML:
<item id="2138" article="a" name="Starlight Amulet">
        <attribute key="weight" value="5200"/>
        <attribute key="slotType" value="necklace"/>
        <attribute key="charges" value="1"/>
    </item>
 
i dont have droploot, so i added it.
Where do you all get "TFS 1.2"? It's 10th thread about TFS 1.2 where someone post some C++ or Lua code that is not TFS 1.2 code.
Is it some downgrade? otservbr or something?
This is official TFS 1.2 and droploot.lua is there:

You can't edit:
C++:
ITEM_AMULETOFLOSS = 3057,
in C++ and put more than 1 value in it.
You got to find what script uses that value and edit it to use 2 values.
 
Don't forget to add the new aol in movements.xml
Lua:
<movevent event="Equip" itemid="2138" slot="necklace" function="onEquipItem" />
<movevent event="DeEquip" itemid="2138" slot="necklace" function="onDeEquipItem" />
 
Where do you all get "TFS 1.2"? It's 10th thread about TFS 1.2 where someone post some C++ or Lua code that is not TFS 1.2 code.
Is it some downgrade? otservbr or something?
This is official TFS 1.2 and droploot.lua is there:

You can't edit:
C++:
ITEM_AMULETOFLOSS = 3057,
in C++ and put more than 1 value in it.
You got to find what script uses that value and edit it to use 2 values.
íts SabrehavenServer-master, 8.0. dont have item.xml have item.srv
 
i solved using this at data/creaturescripts/scripts
Lua:
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified)
    local player = creature:getPlayer()
    if player then
        local skullType = player:getSkull()
        local necklace = player:getSlotItem(CONST_SLOT_NECKLACE)
        if necklace and necklace.itemid == 17554 and skullType ~= SKULL_RED then
            player:setDropLoot(false)
            necklace:transform(17553)
            return true
        end
    end
    return true
end

where 17553 is id of custom AOL

at data/movements XML add this:

XML:
    <movevent event="Equip" itemid="17553" slot="necklace" function="onEquipItem" />
    <movevent event="DeEquip" itemid="17553" slot="necklace" function="onDeEquipItem" />
 
Back
Top