• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Random monster color outfit at spawn

vexler222

Active Member
Joined
Apr 22, 2012
Messages
715
Solutions
15
Reaction score
47
Hi, can someone tell me how to set random color outfit for monster at spawn?
Im tried add it inside a <script></script> in monster file, but im not understand how this tag working :(
 

Alpha

Relentless
Premium User
Joined
Apr 3, 2011
Messages
737
Solutions
38
Reaction score
565
Location
South Korea

Novap

Learning LUA
Joined
Apr 24, 2011
Messages
55
Reaction score
4
OP
OP
vexler222

vexler222

Active Member
Joined
Apr 22, 2012
Messages
715
Solutions
15
Reaction score
47
You can do the outfit change here forgottenserver/monster.lua at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/data/events/scripts/monster.lua#L11)

Just add something like
Lua:
local outfit = self:getOutfit()

outfit.lookHead = math.random(0, 132)
outfit.lookBody = math.random(0, 132)
outfit.lookLegs = math.random(0, 132)
outfit.lookFeet = math.random(0, 132)

self:setOutfit(outfit)
I forgotte, i want it only for one monster
tfs req?

"self:" in syntax hm
Tfs 1.5 8.6
 

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,801
Solutions
18
Reaction score
524
Location
Poland
My example from my custom project, but if you can read you can edit:
Lua:
function Monster:onSpawn(position, startup, artificial)
    -- Random head colour
    if (artificial or startup == true or false) and (self:getName() == "random hair coloured guy") then
        local headColors = {0, 19, 38}
        self:setOutfit({lookType = 276, lookHead = headColors[math.random(#headColors)]})
    end
    return true
    --[[    
    -- Random Outfit
    local outfitId = {29, 35, 37, 39, 41, 43, 45, 47}
    if (artificial or startup == true or false) and (self:getName() == "random outfit guy") then
    self:setOutfit({lookType=outfitId[math.random(#outfitId)]})
    end
    return true
    ]]--
end
 
Top