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

monsters drop empty bags

zaptos

New Member
Joined
May 16, 2019
Messages
36
Reaction score
4
is there a way to fix this? using tfs 1.3 8.6

Code:
    <loot>
        <item id="2148" countmax="10" chance="23000"/><!-- gold coin -->
        <item id="2229" countmax="2" chance="55500"/><!-- skull -->
        <item id="2379" chance="81000"/><!-- dagger -->
        <item id="2467" chance="43000"/><!-- leather armor -->
        <item id="2691" chance="26000"/><!-- brown bread -->
        <item id="2385" chance="22000"/><!-- sabre -->
        <item id="1987" chance="100000"><!-- bag -->
            
        <item id="2526" chance="7000"/><!-- studded shield -->
        <item id="2050" chance="5000"/><!-- torch -->
        <item id="2125" chance="500"/><!-- crystal necklace -->
        <item id="2147" chance="200"/><!-- small ruby -->   
            
        </item>
    </loot>
</monster>
Post automatically merged:

i want bags to drop only when there is loot inside of them
 
Last edited:
There is one solution without changing sources. Let's say you want a 10% shield inside the bag and a 5% sword. You change the bag chance to 10%, the shield to 100% and the sword to 50%, so they will have the same % as before, because they can only be dropped with the bag (i guess), and the bag has 10% chance.
The only problem is that there will always be a shield inside the bag when it drops.
 
Last edited:
As an experiment, I just set the wyvern's bag loot to this:

Code:
<item id="1987" chance="10000"><!-- bag -->
           
        <item id="2187" chance="10000"/><!-- wand of inferno -->
        <item id="7408" chance="750"/><!-- wydern fang -->
        <item id="1976" chance="5000"/><!-- gemmed book -->
        <item id="2127" chance="300"/><!-- emerald bangle -->
           
</item>

Which basically means a wand of inferno should drop 100% of the times a bag is dropped, but a bag only drops 10% of the time, which in turn lowers the WoI loot % to 10% as well.

After killing some wyverns, as predicted, around 1 in every 10 wyverns dropped a bag with a WoI inside.

In it's original state, this is the bag loot:
Code:
<item id="1987" chance="100000"><!-- bag -->
           
        <item id="2187" chance="1000"/><!-- wand of inferno -->
        <item id="7408" chance="750"/><!-- wydern fang -->
        <item id="1976" chance="5000"/><!-- gemmed book -->
        <item id="2127" chance="300"/><!-- emerald bangle -->
           
</item>

This means that even when no item drops, the loot still has an empty bag!

I wish there was a way around this. :(
 
As an experiment, I just set the wyvern's bag loot to this:

Code:
<item id="1987" chance="10000"><!-- bag -->
        
        <item id="2187" chance="10000"/><!-- wand of inferno -->
        <item id="7408" chance="750"/><!-- wydern fang -->
        <item id="1976" chance="5000"/><!-- gemmed book -->
        <item id="2127" chance="300"/><!-- emerald bangle -->
        
</item>

Which basically means a wand of inferno should drop 100% of the times a bag is dropped, but a bag only drops 10% of the time, which in turn lowers the WoI loot % to 10% as well.

After killing some wyverns, as predicted, around 1 in every 10 wyverns dropped a bag with a WoI inside.

In it's original state, this is the bag loot:
Code:
<item id="1987" chance="100000"><!-- bag -->
        
        <item id="2187" chance="1000"/><!-- wand of inferno -->
        <item id="7408" chance="750"/><!-- wydern fang -->
        <item id="1976" chance="5000"/><!-- gemmed book -->
        <item id="2127" chance="300"/><!-- emerald bangle -->
        
</item>

This means that even when no item drops, the loot still has an empty bag!

I wish there was a way around this. :(
Just replace container.lua with this ->
Lua:
function Container.isContainer(self)
    return true
end

function Container.createLootItem(self, item)
    if self:getEmptySlots() == 0 then
        return true
    end

    local itemCount = 0
    local randvalue = getLootRandom()
    if randvalue < item.chance then
        if ItemType(item.itemId):isStackable() then
            itemCount = randvalue % item.maxCount + 1
        else
            itemCount = 1
        end
    end

    if itemCount > 0 then
        local tmpItem = self:addItem(item.itemId, math.min(itemCount, 100))
        if not tmpItem then
            return false
        end

        if tmpItem:isContainer() then
            for i = 1, #item.childLoot do
                if not tmpItem:createLootItem(item.childLoot[i]) then
                    tmpItem:remove()
                    return false
                end
            end
            if tmpItem:getSize() == 0 then
                tmpItem:remove()
            end
        end

        if item.subType ~= -1 then
            tmpItem:setAttribute(ITEM_ATTRIBUTE_CHARGES, item.subType)
        end

        if item.actionId ~= -1 then
            tmpItem:setActionId(item.actionId)
        end

        if item.text and item.text ~= "" then
            tmpItem:setText(item.text)
        end
    end
    return true
end
Just be careful, this also removes empty backpacks in corpses e.g. wisps moon backpack. So you can always just specify the id of a bag, and just remove that one.
 
Last edited:
Just replace container.lua with this ->
Lua:
function Container.isContainer(self)
    return true
end

function Container.createLootItem(self, item)
    if self:getEmptySlots() == 0 then
        return true
    end

    local itemCount = 0
    local randvalue = getLootRandom()
    if randvalue < item.chance then
        if ItemType(item.itemId):isStackable() then
            itemCount = randvalue % item.maxCount + 1
        else
            itemCount = 1
        end
    end

    if itemCount > 0 then
        local tmpItem = self:addItem(item.itemId, math.min(itemCount, 100))
        if not tmpItem then
            return false
        end

        if tmpItem:isContainer() then
            for i = 1, #item.childLoot do
                if not tmpItem:createLootItem(item.childLoot[i]) then
                    tmpItem:remove()
                    return false
                end
            end
            if tmpItem:getSize() == 0 then
                tmpItem:remove()
            end
        end

        if item.subType ~= -1 then
            tmpItem:setAttribute(ITEM_ATTRIBUTE_CHARGES, item.subType)
        end

        if item.actionId ~= -1 then
            tmpItem:setActionId(item.actionId)
        end

        if item.text and item.text ~= "" then
            tmpItem:setText(item.text)
        end
    end
    return true
end
Just be careful, this also removes empty backpacks in corpses e.g. wisps moon backpack. So you can always just specify the id of a bag, and just remove that one.


Can I just change line 33 to
Lua:
if tmpItem:getSize() == 0 and tmpItem.itemid == 1987 then

so it targets only the bag I am referring to?

Thanks a lot for the help.
 
Back
Top