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

Lua loot randomize

Moody

Member
Joined
Feb 8, 2020
Messages
60
Reaction score
5
i have very many bosses with big loot list like this here
XML:
    <loot capacity="5000">
        <item id="2142" chance="3500" />
        <item id="2231" chance="9000" />
        <item id="2144" countmax="15" chance="15000" />
        <item id="2158" chance="1500" />
        <item id="2195" chance="4000" />
        <item id="2186" chance="3500" />
        <item id="2192" chance="2500" />
        <item id="2125" chance="1500" />
        <item id="2124" chance="5500" />
        <item id="2520" chance="15500" />
        <item id="2462" chance="11000" />
        <item id="2387" chance="20000" />
        <item id="2434" chance="4500" />
        <item id="2167" chance="13500" />
        <item id="2432" chance="17000" />
        <item id="2393" chance="12500" />
        <item id="2148" countmax="100" chance="99900" />
        <item id="2148" countmax="100" chance="88800" />
        <item id="2148" countmax="100" chance="77700" />
        <item id="2148" countmax="100" chance="66600" />
        <item id="2179" chance="8000" />
        <item id="2470" chance="5000" />
        <item id="2418" chance="4500" />
        <item id="2182" chance="3500" />
        <item id="2155" chance="1500" />
        <item id="2188" chance="2500" />
        <item id="2396" chance="7500" />
        <item id="2177" chance="1000" />
        <item id="2162" chance="11500" />
        <item id="2472" chance="3000" />
        <item id="2514" chance="7500" />
        <item id="2164" chance="5000" />
        <item id="2178" chance="4000" />
        <item id="2176" chance="12000" />
        <item id="2171" chance="4500" />
        <item id="2200" chance="4500" />
        <item id="1982" chance="2600" />
        <item id="2214" chance="13000" />
        <item id="2123" chance="3500" />
        <item id="2170" chance="13000" />
        <item id="2402" chance="15500" />
        <item id="2436" chance="5000" />
        <item id="2150" countmax="20" chance="13500" />
        <item id="2145" countmax="5" chance="9500" />
        <item id="2149" countmax="10" chance="15500" />
        <item id="2146" countmax="10" chance="13500" />
        <item id="2165" chance="9500" />
        <item id="2197" chance="4000" />
        <item id="2174" chance="2500" />
        <item id="2151" countmax="7" chance="14000" />
        <item id="2112" chance="14500" />
        <item id="2421" chance="13500" />
        <item id="2377" chance="20000" />
        <item id="3955" chance="100" />
        <item id="2185" chance="3500" />
        <item id="2143" countmax="15" chance="12500" />
    </loot>
can some1 help me make onkill or any script so it split and randomize half loot in bag or backpack of my choose? i have many many like this and to add bag one after one will take so long
Post automatically merged:

backpack in monsters loot not in my containers
Post automatically merged:

i try edit this or this and no work all for 0.4
i try edit Monster:eek:nDropLoo event but i fail there
 
Last edited:
Solution
i took many monsters of high client and this high client have no bags but coprse size 60 or 50 if i make this in 8.6 max 36 so big boss no show all loots and some deleted i have 200 boss no bags and no show all loot so need if no space in corpse container. auto add bag and add items to bag no delete or unshow
Lua:
function Monster:onDropLoot(corpse)
    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end

    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    local loot_corpse = corpse
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()
        for i = 1, #monsterLoot do
            if loot_corpse:getEmptySlots() == 1 then...

I don't fully understand what you are wanting to do.
But, this is what I came up with.

If you want something different, let me know.
 
almost what i wanted only can split loot? 50% in never ending backpack and too 50% in loot normal monster corpse?
 
almost what i wanted only can split loot? 50% in never ending backpack and too 50% in loot normal monster corpse?
Well, I can put 50% into each bag?
Does that work?
Lua:
function Monster:onDropLoot(corpse)
    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end
    
    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()
        local backpack2, backpack1 = corpse:addItem(1987), corpse:addItem(1993)
        for i = 1, #monsterLoot do
            local slots1, slots2 = backpack1:getEmptySlots(), backpack2:getEmptySlots()
            if slots2 == slots1 then
                if backpack1:getEmptySlots() == 1 then
                    backpack1 = backpack1:addItem(1993)
                end
                local item = backpack1:createLootItem(monsterLoot[i])
                if not item then
                    print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
                end
            else
                if backpack2:getEmptySlots() == 1 then
                    backpack2 = backpack2:addItem(1987)
                end
                local item = backpack2:createLootItem(monsterLoot[i])
                if not item then
                    print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
                end
            end
        end
    
        if player then
            local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                player:sendTextMessage(MESSAGE_LOOT, text)
            end
        end
    else
        local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            player:sendTextMessage(MESSAGE_LOOT, text)
        end
    end
end
 
its very good but can monster corpse have loot outside bag. not move all loot in bag. half and half. look natural
 
its very good but can monster corpse have loot outside bag. not move all loot in bag. half and half. look natural
Well idk. lmao
idk how your monsters have infinite space in them.
Mine have a max of 8 🤷‍♀️ anything more then 8 loot is auto deleted, so I can't do it like you ask.
 
so you can make 8 item out of container? and all other go in never end backpack? or when no more space in corpse loot no auto deleted go in backpack but if there space keep natural
 
so you can make 8 item out of container? and all other go in never end backpack? or when no more space in corpse loot no auto deleted go in backpack but if there space keep natural
How about we do this a different way.

You tell me what your actual issue is, so I can solve x instead of creating a solution for Y.
 
i took many monsters of high client and this high client have no bags but coprse size 60 or 50 if i make this in 8.6 max 36 so big boss no show all loots and some deleted i have 200 boss no bags and no show all loot so need if no space in corpse container. auto add bag and add items to bag no delete or unshow
 
i took many monsters of high client and this high client have no bags but coprse size 60 or 50 if i make this in 8.6 max 36 so big boss no show all loots and some deleted i have 200 boss no bags and no show all loot so need if no space in corpse container. auto add bag and add items to bag no delete or unshow
Lua:
function Monster:onDropLoot(corpse)
    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end

    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    local loot_corpse = corpse
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()
        for i = 1, #monsterLoot do
            if loot_corpse:getEmptySlots() == 1 then
                loot_corpse = loot_corpse:addItem(1987)
            end
            local item = loot_corpse:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end
        
        if player then
            local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                player:sendTextMessage(MESSAGE_LOOT, text)
            end
        end
    else
        local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            player:sendTextMessage(MESSAGE_LOOT, text)
        end
    end
end
 
Solution
🤷‍♀️

Tell cipsoft client to suck it up and stop crashing.

-_-

ps - I have no idea why adding loot to a container would debug a client.
Someone else would have to explain that.
 
i try rat-rabbit-rotworm and bosses all debug cipsoft client
Post automatically merged:

@Xikini myb cuz it add loot very fast it makes debug? can you make wait 100 or 200ms?
and this my debug log myb some1 know why or how i fix it
Code:
Debug Assertion 8.60 Talk.cpp 80
Mon Aug 31 15:39:27 2020
Graphic Engine: DirectX9 (2)
Operating System: Windows Vista Family in USA
Processor: Intel Core i7
Video Card: Intel (R) HD GR
Last Packet Types: 163 108 180 106 106 108 161 140 180 132
Last Packet: 108 112 000 120 000 007 001 106 112 000 120 000 007 001 070 011
Player Position: [111,120,7]
Player Name: Druid Sample (Forgotten)
Player Action: 049 050 055 046 048 046 048 046 049 058 055 049 055 050
Player.cpp 361: exception occurred, reason:
Player.cpp 465: exception occurred, reason:
Control.cpp 1728: exception occurred (MessageType: 0 MaW: E28120 MoW: 0), reason:
Control.cpp 1723: exception occurred, reason:
Control.cpp 386: exception occurred (Force?1:0 = 0), reason:
MainWindow.cpp 138: exception occurred (Surface = 1), reason:
ConsoleWindow.cpp 1682: exception occurred (Surface = 1), reason:
ConsoleWindow.cpp 800: exception occurred, reason:
GUI.cpp 1575: exception occurred, reason:
ConsoleWindow.cpp 147: exception occurred, reason:
ConsoleWindow.cpp 378: exception occurred, reason:
Talk.cpp 80: none is talking
 
Last edited:
Back
Top