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

TFS 1.X+ Script for extra loot is ok?

damian00912

New Member
Joined
Sep 11, 2009
Messages
87
Reaction score
4
Hallo! I have script for extra drop from every monsters, and it's item with id xxxx and have 5% chance to drop from every monsters, but players write me about it's not true, and that weak monsters have a greater drop of this item, and stronger monsters have less of these items, can someone experienced please comment?

Lua:
math.randomseed(os.time())
local extra_loot = {
    {items = {
        {id = 40407, chance = 5000}
    }}
}

local extra_loot_d = CreatureEvent("extra_loot_d")

function Container:addExtraLoot(c, t)
    if t.hasName then
        local cn = c:getName():lower()
        local cm = t.hasName:lower()
        if not cn:match(cm) then
            return true
        end
    end
  
    for i = 1, #t.items do
        local count = 1
        if t.items[i].count then
            if t.items[i].countMax then
                count = math.random(t.items[i].count, t.items[i].countMax)
            else
                count = t.items[i].count
            end
        else
            if t.items[i].countMax then
                count = math.random(1, t.items[i].countMax)
            end
        end
      
        if math.random(0, 100000) <= t.items[i].chance then
            self:addItem(t.items[i].id, count)
        end
    end
end

function extra_loot_d.onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if not creature:isMonster() then
    return true
    end

        if creature:getMaster() then
        return true
        end
          
            if corpse then
            local itemType = corpse:getType()
            if itemType:isCorpse() and itemType:isContainer() then
            for i = 1, #extra_loot do
            corpse:addExtraLoot(creature, extra_loot[i])
            end
      
        end
    return true
end
end

extra_loot_d:register()


Thanks you!
 

Sarah Wesker

ค∂vαηcε รүηтαx ❤
Support Team
Joined
Mar 16, 2017
Messages
1,073
Solutions
107
Reaction score
1,142
Location
London
GitHub
MillhioreBT
Twitch
millhiore_bt
I think it executes math.randomseed(os.time()) here it is not necessary, it is already done in global.lua
running it twice will not make the seed a more random

The same happens if you want to change the seed every so often in short intervals of time, changing the seed even worsens the chance of things, it does not improve it
 
Top