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

monster spwan

ConAn Edujawa

Member
Joined
Feb 23, 2015
Messages
457
Reaction score
17
how i can make mosnter skull but the monster have red skull have more hp and more damge

exampile

if normal hunter have hp 100 and hit like 50

the hunter with red skull will have hp 200 and hit like 100

but the 2 monster have same name but one with skull and normal no have skull

i know bad english sorry for this

useing 0.4 C ~8.60
 
Just copy and paste the hunter.xml, change only the name of file (dont change the name inside of file) ex. hunter2.xml. In file hunter2.xml set the damage as u want and add this skull="3" after "experience". Remember to update yours monsters.xml.
Btw. Im not sure if skull = 3 is red or otherone ;o, you need to check it.
 
Just copy and paste the hunter.xml, change only the name of file (dont change the name inside of file) ex. hunter2.xml. In file hunter2.xml set the damage as u want and add this skull="3" after "experience". Remember to update yours monsters.xml.
Btw. Im not sure if skull = 3 is red or otherone ;o, you need to check it.

its nice idea but i need to do it random this time spawn normal hunter next time spawn hunter with skull like this





what this?
 
Ok, make another file of monster (as I said few comments above).
Add this to globalevents:
xml:
Code:
<globalevent name="MonsterBoosting" interval="1000" event="script" value="MonsterBoosting.lua"/>
MonsterBoosting.lua:
Code:
--Script made by GarQet--
function onThink(interval, lastExecution, thinkInterval)
   for _, monster in ipairs(checkSpawnMonster()) do
       if isMonster(monster) and getCreatureStorage(monster, 110) ~= 1 then
           doCreatureSetStorage(monster, 110, 1)
           local percent = math.random(0, 2)
           local buff = math.random(1, 20)
           doCreatureSetStorage(monster, 111, buff / 100)
           if percent > 1 then
               if buff >= 15 then
                   doCreatureSetSkullType(monster, 5)
               elseif buff >= 10 then
                   doCreatureSetSkullType(monster, 4)
               elseif buff >= 5 then
                   doCreatureSetSkullType(monster, 3)
               end
               local correct = buff / 100
               setCreatureMaxHealth(monster, getCreatureHealth(monster) + (getCreatureHealth(monster) * correct))
               doCreatureAddHealth(monster, getCreatureHealth(monster) * correct)
               registerCreatureEvent(monster, "MonsterBoosted")
           end
       end
   end
   return true
end
Add this to creaturescripts:
xml:
Code:
<event type="statschange" name="MonsterBoosted" event="script" value="MonsterBoosted.lua"/>
MonsterBoosted.lua:
Code:
--Script made by GarQet--
function onStatsChange(cid, attacker, type, combat, value)
   if isMonster(attacker) and (type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) then
       local buff = getCreatureStorage(attacker, 111)
       local correct = value + (value * buff)
       doTargetCombatHealth(attacker, cid, combat, correct, correct, 255)
       return false
   end
   return true
end
I didn't test, you need to check how it works and if it works :D

#Edit
How it works? Every creature getting check and randomly getting the "power" (50% percent of chance) to be "better" - bigger damage and health (max as in config 20%).
 
Last edited:
Ok, make another file of monster (as I said few comments above).
Add this to globalevents:
xml:
Code:
<globalevent name="MonsterBoosting" type="startup" event="script" value="MonsterBoosting.lua"/>
MonsterBoosting.lua:
Code:
--Script made by GarQet--
function onStartup()
   local config = {
       traditional_name = "Hunter",
       boosted_monster = "Hunter2"
   }
   for _, monster in pairs(getWorldCreatures(1)) do
       if isMonster(monster) and getCreatureName(monster) == config.traditional_name then
           registerCreatureEvent(monster, "DeathMonsterBoosted")
           local p = getCreaturePosition(monster)
           doCreatureSetStorage(monster, 111, p.x)
           doCreatureSetStorage(monster, 112, p.y)
           doCreatureSetStorage(monster, 113, p.z)
           local percent = math.random(1, 2)
           if percent > 1 then
               local pos = getCreaturePosition(monster)
               doRemoveCreature(monster)
               doCreateMonster(config.boosted_monster, pos)
           end
       end
   end
   return true
end
Add this to creaturescripts:
xml:
Code:
<event type="kill" name="DeathMonsterBoosted" event="script" value="DeathMonsterBoosted.lua"/>
DeathMonsterBoosted.lua:
Code:
--Script made by GarQet--
function onKill(cid, target)
   local monsters = {"Hunter", "Hunter2"}
   local boosted_monster = "Hunter2"
   local respawn = 60 -- the time which u put in RME (respawn of this creature), you need to use one respawn for all Hunters
   if(isInArray(getCreatureName(cid), monsters) then
       local posx, posy, posz = getCreatureStorage(cid, 111), getCreatureStorage(cid, 112), getCreatureStorage(cid, 113)
       addEvent(function(posx, posy, posz)
           local creature = getTopCreature({x = posx, y = posy, z = posz})
           if isMonster(creature.uid) and isInArray(getCreatureName(creature.uid), monsters) then
               registerCreatureEvent(creature.uid, "DeathMonsterBoosted")
               doCreatureSetStorage(creature.uid, 111, posx)
               doCreatureSetStorage(creature.uid, 112, posy)
               doCreatureSetStorage(creature.uid, 113, posz)
               local percent = math.random(1, 2)
               if percent > 1 then
                   doRemoveCreature(creature.uid)
                   doCreateMonster(boosted_monster, {x = posx, y = posy, z = posz})
               end    
           end
       end, 1000 * respawn, posx, posy, posz)
   end
   return true
end
I didn't test, you need to check how it works and if it works :D

#Edit
How it works? When server is going to start, each Hunter getting check and randomly getting the "power" (50% percent of chance) to be "better" - Hunter2. When monster dies, the script waiting till respawn and doing the same as on start up.

its nice but i need to add more monster not only hunter or all monster
 
First of all check if it works, if yes I can easly add more creatures like this.
28qxidh.jpg
 
all monster with name hunter spawned with red skull and all same hp and no normal hunter spawned

now i add in monster.xml
<monster name="" file="hunter2.xml" />

but in hunter2 xml add name hunter

and all hunter spwan with normal one but when die don't spawn again
 
Last edited:
Are you sure that all hunters was "boosted"? Change in both scripts "math.random(1, 2)" change to "math.random(0, 2)", lets see what happen.
 
now monster spawned again but no thing happen :S always spawn with normal hunter

when server start gor this error
54w3gl.jpg
 
Last edited by a moderator:
now monster spawned again but no thing happen :S always spawn with normal hunter

When server start gor this error
54w3gl.jpg
in data/globalevents/scripts/MonstersBoosting.lua at line 7 you aren't giving a table as a argument of pairs.

Code:
for _, monster in pairs(getWorldCreatures(1)) do
You should check output of getWorldCreatures(1) function. Make sure that it is implemented on your TFS.
 
Let's try the other way. Add this to your sources:
luascript.cpp, after this line:
Code:
int32_t LuaInterface::luaGetPlayersOnline(lua_State* L)
{
    //getPlayersOnline()
    ScriptEnviroment* env = getEnv();
    AutoList<Player>::iterator it = Player::autoList.begin();

    lua_newtable(L);
    for(int32_t i = 1; it != Player::autoList.end(); ++it, ++i)
    {
        lua_pushnumber(L, i);
        lua_pushnumber(L, env->addThing(it->second));
        pushTable(L);
    }
    return 1;
}
add this:
Code:
int32_t LuaInterface::luaCheckSpawnMonster(lua_State* L)
{
    ScriptEnviroment* env = getEnv();
    AutoList<Monster>::iterator it = Monster::autoList.begin();
    lua_newtable(L);
    for(int32_t i = 1; it != Monster::autoList.end(); ++it, ++i)
    {
        lua_pushnumber(L, i);
        lua_pushnumber(L, env->addThing(it->second));
        pushTable(L);
    }
    return 1;
}
luascript.h, after this line:
Code:
    //getPlayersOnline()    lua_register(m_luaState, "getPlayersOnline", LuaInterface::luaGetPlayersOnline);
add this:
Code:
    //checkSpawnMonster()    lua_register(m_luaState, "checkSpawnMonster", LuaInterface::luaCheckSpawnMonster);
still in luascript.h, after this line:
Code:
static int32_t luaGetPlayersOnline(lua_State* L);
add this:
Code:
static int32_t luaCheckSpawnMonster(lua_State* L);
then compile and use the updated code (my 1st post)
 
Let's try the other way. Add this to your sources:
luascript.cpp, after this line:
Code:
int32_t LuaInterface::luaGetPlayersOnline(lua_State* L)
{
    //getPlayersOnline()
    ScriptEnviroment* env = getEnv();
    AutoList<Player>::iterator it = Player::autoList.begin();

    lua_newtable(L);
    for(int32_t i = 1; it != Player::autoList.end(); ++it, ++i)
    {
        lua_pushnumber(L, i);
        lua_pushnumber(L, env->addThing(it->second));
        pushTable(L);
    }
    return 1;
}
add this:
Code:
int32_t LuaInterface::luaCheckSpawnMonster(lua_State* L)
{
    ScriptEnviroment* env = getEnv();
    AutoList<Monster>::iterator it = Monster::autoList.begin();
    lua_newtable(L);
    for(int32_t i = 1; it != Monster::autoList.end(); ++it, ++i)
    {
        lua_pushnumber(L, i);
        lua_pushnumber(L, env->addThing(it->second));
        pushTable(L);
    }
    return 1;
}
luascript.h, after this line:
Code:
    //getPlayersOnline()    lua_register(m_luaState, "getPlayersOnline", LuaInterface::luaGetPlayersOnline);
add this:
Code:
    //checkSpawnMonster()    lua_register(m_luaState, "checkSpawnMonster", LuaInterface::luaCheckSpawnMonster);
still in luascript.h, after this line:
Code:
static int32_t luaGetPlayersOnline(lua_State* L);
add this:
Code:
static int32_t luaCheckSpawnMonster(lua_State* L);
then compile and use the updated code (my 1st post)


same error :S
 
Back
Top