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

Daily monster draw with percentage bonus experience and random loot.

ikaro22

New Member
Joined
Dec 17, 2019
Messages
22
Reaction score
0
Good morning, I would like help with a script that would draw a daily monster with X daily experience bonus and random loot between 0 and 40%.

example: image below.

base: tibia 8.60, otx.
 

Attachments

Solution
Lua:
local loot_bonus = math.random(10, 40)  --  10% to 40%
local ignoredList = {1987}
function addBonusLoot(position, name)
        for i = 0, 255 do
        position.stackpos = i
        corpse = getTileThingByPos(position)
        if corpse.uid > 0 and isCorpse(corpse.uid) then
            break
        end
    end
        local newRate = (1 + (loot_bonus/100)) * getConfigValue("rateLoot")
        local monsterLoot = getMonsterLootList(name)
        local mainbp = doCreateItemEx(1987, 1)
        for i, loot in pairs(monsterLoot) do
            if math.random(1, 100000) <= newRate * loot.chance then
                if #ignoredList > 0 then
                    if (not isInArray(ignoredList, loot.id)) then...
I thought it was just like that, but always when i open dont change. Always the same, same with that change you send me.
When you run the server, in console do you see
"Today's monster boosted is: monster name!" ?
 
When you run the server, in console do you see
"Today's monster boosted is: monster name!" ?
Today's boosted monster is: phyculos

but it doesn't always change. Now i have other error. EXP BOOST and Loot BOOST its same always.
loot_bonus = math.random(1,30) = 11%
experienceBonus = math.random(1,30) = 27%
 
Today's boosted monster is: phyculos

but it doesn't always change. Now i have other error. EXP BOOST and Loot BOOST its same always.
loot_bonus = math.random(1,30) = 11%
experienceBonus = math.random(1,30) = 27%
Lua's math.random isn't actually true random.. you can read about it here math.random isn't random question? (https://scriptinghelpers.org/questions/35236/mathrandom-isnt-random-question)

So.. honestly if I were to guess, somewhere in your scripts math.randomseed is set as a global variable instead of a local one, which is causing issues with your other scripts, since their seed isn't changing.

You could continue to use math.randomseed(os.time()) inside your scripts in order to stop that, but that seed only changes once per second, so if your script triggers 5 times in 1 second, all of them will have the same result.

🤷‍♂️ Unless someone else has a better / more plausible explanation, I'm not sure what else to try.
 
Back
Top