• 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 0.X Put different chance rate in this script

gabriel28

Member
Joined
Mar 16, 2012
Messages
199
Solutions
6
Reaction score
24
I don't now how to get informations from a table like that, so I want someone to help me with that.
I need each monster with an individual chance.
Here are the script:

Lua:
local config = {
    chance = 2,  
    bosses = {
        --["monster_name"] = "boss",
        ["Dragon Lord"] = "Demondras", --Like ["Dragon Lord"] = "Demondras", chance = 15
        ["Juggernaut"] = "Massacre", --["Juggernaut"] = "Massacre",  chance = 3
    },
}
function onSpawn(cid)
    if isMonster(cid) then
        addEvent(function()
            if isCreature(cid) then
                local boss = config.bosses[getCreatureName(cid)]
                if math.random(1, 100) <= config.chance then
                    local pos = getThingPos(cid)
                    doRemoveCreature(cid)
                    doCreateMonster(boss, pos)
                end
            end
        end, 5)
    end
    return true
end
 
Solution
I don't now how to get informations from a table like that, so I want someone to help me with that.
I need each monster with an individual chance.
Here are the script:

Lua:
local config = {
    chance = 2,
    bosses = {
        --["monster_name"] = "boss",
        ["Dragon Lord"] = "Demondras", --Like ["Dragon Lord"] = "Demondras", chance = 15
        ["Juggernaut"] = "Massacre", --["Juggernaut"] = "Massacre",  chance = 3
    },
}
function onSpawn(cid)
    if isMonster(cid) then
        addEvent(function()
            if isCreature(cid) then
                local boss = config.bosses[getCreatureName(cid)]
                if math.random(1, 100) <= config.chance then
                    local pos = getThingPos(cid)...
I don't now how to get informations from a table like that, so I want someone to help me with that.
I need each monster with an individual chance.
Here are the script:

Lua:
local config = {
    chance = 2,
    bosses = {
        --["monster_name"] = "boss",
        ["Dragon Lord"] = "Demondras", --Like ["Dragon Lord"] = "Demondras", chance = 15
        ["Juggernaut"] = "Massacre", --["Juggernaut"] = "Massacre",  chance = 3
    },
}
function onSpawn(cid)
    if isMonster(cid) then
        addEvent(function()
            if isCreature(cid) then
                local boss = config.bosses[getCreatureName(cid)]
                if math.random(1, 100) <= config.chance then
                    local pos = getThingPos(cid)
                    doRemoveCreature(cid)
                    doCreateMonster(boss, pos)
                end
            end
        end, 5)
    end
    return true
end
Something like this should do it
Lua:
local config = {
    bosses = {
        --["monster_name"] = {name = "boss", chance = 100}
        ["Dragon Lord"] = {name = "Demondras", chance = 15},
        ["Juggernaut"] = {name = "Massacre",  chance = 3}
    },
}
function onSpawn(cid)
    if isMonster(cid) then
        addEvent(function()
            if isCreature(cid) then
                local boss = config.bosses[getCreatureName(cid)]
                if math.random(1, 100) <= boss.chance then
                    local pos = getCreaturePosition(cid)
                    doRemoveCreature(cid)
                    doCreateMonster(boss.name, pos)
                end
            end
        end, 5)
    end
    return true
end
 
Last edited:
Solution
Back
Top