• 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 [1.2] Adding skull to monster

Cornwallis

Member
Joined
Jan 3, 2010
Messages
480
Reaction score
16
Hello, so I'm trying to add a skull to different monsters with little luck. I've tried doing skull="white", skull="3", skull="SKULL_WHITE", flag_skull="SKULL_WHITE", etc,. and basically nothing in the monsters .xml file will work for me, so if someone knows how that'd be great. I looked in the monster.cpp and it supports the skull so perhaps I'm wording it wrong. I came up with this code:
Code:
Game.createMonster("strong " .. v .. "", k[1], false, true):setSkull(SKULL_WHITE)
and it adds a skull to the monster if the player is in view of the monster whenever it's spawned, but if the player walks out of view or isn't present during the spawn time then the skull is absent.
 
it randomly spawns monsters across the map based on a chance

EDIT; well it will whenever i get it working lol
I recommend you use in events monster.lua :
Code:
Monster:onSpawn(position)

Example:

Code:
function Monster:onSpawn(position)
skullType = SKULL_RED
local namesSkulls = {"Dragon", "Hero"}
if isInArray(namesSkulls) then
self:setSkull(skullType)
return true
end
end
 
I don't think "Monster:eek:nSpawn" exists on my distro, I searched but can't find it. And I'm not sure how to use it, and why is it self:setSkull(skullType)? Here's the code I'm trying to get working:
Code:
local t = {
[{{x = 998, y = 1006, z = 7}, 95000}] = "rat"
}


function onThink(interval, lastExecution)
    local chance = math.random(100000)
    local lvlChance = math.random(100)
    for k, v in pairs(t) do
        if chance >= 1 then
            if lvlChance <= 60 then
                Game.createMonster("strong " .. v .. "", k[1], false, true):setSkull(SKULL_WHITE)
                return true
            elseif lvlChance > 60 and lvlChance <= 90 then
                Game.createMonster("trained " .. v .. "", k[1], false, true):setSkull(SKULL_RED)
                return true
            elseif lvlChance > 90 then
                Game.createMonster("alpha " .. v .. "", k[1], false, true):setSkull(SKULL_BLACK)
                return true
            end
        else
            return false
          
        end
    end
end
 
Try this:
Code:
local monsters = {
   name = "rat",
   position = {x = 998, y = 1006, z = 7},
   chance = 95 * 1000,

   ["alpha"] = SKULL_BLACK,
   ["trained"] = SKULL_RED,
   ["strong"] = SKULL_WHITE
}

function onThink(interval, lastExecution)
   local chance = math.random(0, 100 * 1000)
   if chance == 0 then
       return false
   end

   local levelChance = math.random(1, 100)
   local prefix = levelChance > 90 and "alpha" or levelChance > 60 and "trained" or "strong"

   local monster = Game.createMonster(prefix .. monsters.name, Position(monsters.position), false, true)
   if not monster then
       return false
   end

   monster:setSkull(monsters[prefix])
   return true
end
 
Last edited:
Try this:
Code:
local monsters = {
   name = "rat",
   position = {x = 998, y = 1006, z = 7},
   chance = 95 * 1000,

   ["alpha"] = SKULL_BLACK,
   ["trained"] = SKULL_RED,
   ["strong"] = SKULL_WHITE
}

function onThink(interval, lastExecution)
   local chance = math.random(0, 100 * 1000)
   if chance == 0 then
       return false
   end

   local levelChance = math.random(1, 100)
   local prefix = levelChance > 90 and "alpha" or levelChance > 60 and "trained" or "strong"

   local monster = Game.createMonster(prefix .. monster.name, Position(monster.position), false, true)
   if not monster then
       return false
   end

   monster:setSkull(monsters[prefix])
   return true
end

monsters.name, Position(monsters.position)
 
I don't think "Monster:eek:nSpawn" exists on my distro, I searched but can't find it
check my signature 0.0
anyways wouldn't matter with my code or this because skulls from setSkull doesn't update once you come back on screen apparently
skull="red" is valid inside monster.xml, you have to put it on the same line as speed="xx"
C++:
SkullNames skullNames[] = {
    {"none",    SKULL_NONE},
    {"yellow",    SKULL_YELLOW},
    {"green",    SKULL_GREEN},
    {"white",    SKULL_WHITE},
    {"red",        SKULL_RED},
    {"black",    SKULL_BLACK},
    {"orange",    SKULL_ORANGE},
};
 
check my signature 0.0
anyways wouldn't matter with my code or this because skulls from setSkull doesn't update once you come back on screen apparently
skull="red" is valid inside monster.xml, you have to put it on the same line as speed="xx"
C++:
SkullNames skullNames[] = {
    {"none",    SKULL_NONE},
    {"yellow",    SKULL_YELLOW},
    {"green",    SKULL_GREEN},
    {"white",    SKULL_WHITE},
    {"red",        SKULL_RED},
    {"black",    SKULL_BLACK},
    {"orange",    SKULL_ORANGE},
};
none of the skulls are working for me in the monsters.xml, perhaps it's because I'm using TFS 1.2 on 8.6? Here's the first line of my monster:
Code:
<monster name="Strong Rat" nameDescription="a strong rat" race="blood" experience="1500" speed="135" manacost="200" skull="red">

bump
 
Last edited by a moderator:
Back
Top