• 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 Creature summons random monsters.

Moj mistrz

Monster Creator
Joined
Feb 1, 2008
Messages
932
Solutions
10
Reaction score
295
Location
Poland
#edit
How is it possible for monster to summon random creature from table with random chance? how to configure doSummonCreature()?
Code:
local chance = math.random(1,100)
local summon = "Demon Skeleton"[chance < 40], "Lich"[chance < 20], "Vampire"[chance < 10], "Vampire Bride"[chance < 10], "Vampire Viscount[chance < 10], "Undead Dragon"[chance < 5]
doSummonCreature("summon.chance", getCreaturePosition(cid))
NOTE: THIS IS AN EXAMPLE NOT A SCRIPT.


#down
thx
 
Last edited:
Yes, you can use onStatsChange()

Code:
function onStatsChange(cid, attacker, type, combat, value)
    if(isPlayer(cid)) then
        doSendAnimatedText(getCreaturePosition(cid), value, 255)
    end
    return true
end
 
Code:
local summons = {
    [1] = {name = "Demon Skeleton"},
    [2] = {name = "Lich"},
    [3] = {name = "Vampire"},
    [4] = {name = "Vampire Bride"},
    [5] = {name = "Vampire Viscount"},
    [6] = {name = "Undead Dragon"}
}
math.randomseed(os.time())

TFS 0.3.x/0.4
doSummonCreature(summons[math.random(#summons)].name, getThingPos(cid))

TFS 1.0
Game.createMonster(summons[math.random(#summons)].name, Player(cid):getPosition())
Something like that? Otherwise I diden't really understand what you ment.
 
Code:
local summons = {
    [1] = {name = "Demon Skeleton"},
    [2] = {name = "Lich"},
    [3] = {name = "Vampire"},
    [4] = {name = "Vampire Bride"},
    [5] = {name = "Vampire Viscount"},
    [6] = {name = "Undead Dragon"}
}
math.randomseed(os.time())

TFS 0.3.x/0.4
doSummonCreature(summons[math.random(#summons)].name, getThingPos(cid))

TFS 1.0
Game.createMonster(summons[math.random(#summons)].name, Player(cid):getPosition())
Something like that? Otherwise I diden't really understand what you ment.
he wanted that + chances on monsters haha
 
he wanted that + chances on monsters haha
Haha diden't read everything just read the code and diden't notice the numbers :)
Code:
local summons = {
    -- Monster name, percentage
    {"Demon Skeleton", 60},
    {"Lich", 50},
    {"Vampire", 50},
    {"Vampire Bride", 45},
    {"Vampire Viscount", 35},
    {"Undead Dragon", 30},
    {"Vampire", 25},
    {"Vampire Bride", 20},
    {"Vampire Viscount", 10},
    {"Undead Dragon", 1}   
}

local Max = 0
for i, v in pairs(summons) do
    summons[i][3] = Max
    Max = Max + v[2]
end

math.randomseed(os.time())
local monster = math.random(0, Max)
for _, v in pairs(summons) do
    if(monster >= v[3] and monster < (v[2] + v[3])) then
        doSummonCreature(v[1], getThingPos(cid))
        break
    end
end

Not tested but should work, remember to change doSummonCreature to Game.createMonster if you are using tfs 1.0 and getThingPos(cid) with Player(cid):getPosition().
 
Back
Top