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

Solved Which or where is is the code or file c++ in charge of re-spawn monsters after death?

Felipe93

Ghost Member
Joined
Mar 21, 2015
Messages
1,990
Solutions
9
Reaction score
334
Location
Chile
Hello

Can somebody please help me with this, I need to know Which or where is the code or file c++ in charge of re-spawn monsters after death? In tfs 1.5
i have scrub up something maybe in sources files because i've checked my config.lua file and my spawn.xml file and everything seems to be good in there.
I've made a lot of source changes, so i might scrub something inside c++ files. Can somebody tell me where to look for in order to solve this, please?
config.lua
Lua:
rateSpawn = 1

-- Monster Despawn Config
-- despawnRange is the amount of floors a monster can be from its spawn position
-- despawnRadius is how many tiles away it can be from its spawn position
-- removeOnDespawn will remove the monster if true or teleport it back to its spawn position if false
-- walkToSpawnRadius is the allowed distance that the monster will stay away from spawn position when left with no targets, 0 to disable
deSpawnRange = 2 --2
deSpawnRadius = 50 --50
removeOnDespawn = true
walkToSpawnRadius = 15

world-spawn.xml
Code:
<?xml version="1.0"?>
<spawns>
    <spawn centerx="32355" centery="31646" centerz="1" radius="5">
        <monster name="valkyrie" x="1" y="-2" z="1" spawntime="60" />
        <monster name="valkyrie" x="-1" y="-1" z="1" spawntime="60" />
        <monster name="valkyrie" x="-1" y="0" z="1" spawntime="60" />
        <monster name="amazon" x="1" y="0" z="1" spawntime="60" />
    </spawn>
    <spawn centerx="32536" centery="31772" centerz="1" radius="1">
        <npc name="Thanita" x="0" y="0" z="1" spawntime="60" />
    </spawn>
    <spawn centerx="32583" centery="31924" centerz="1" radius="1">
        <monster name="dwarf guard" x="1" y="0" z="1" spawntime="60" />

Thanks in advance
 
 
Thank you @EvulMastah for such quick reply. By mistake i committed an important part of the code trying to remove few warnings from the console like these:
Lua:
>> Initializing gamestate
[Warning - Spawns::startup] Couldn't spawn monster "fire elemental" on position: ( 33248 / 31594 / 012 ).
[Warning - Spawns::startup] Couldn't spawn monster "fire elemental" on position: ( 33248 / 31594 / 012 ).
[Warning - Spawns::startup] Couldn't spawn monster "fire elemental" on position: ( 33247 / 31597 / 012 ).
[Warning - Spawns::startup] Couldn't spawn monster "fire elemental" on position: ( 33247 / 31597 / 012 ).
[Warning - Spawns::startup] Couldn't spawn monster "tiger" on position: ( 32528 / 32785 / 007 ).
[Warning - Spawns::startup] Couldn't spawn monster "tiger" on position: ( 32528 / 32785 / 007 ).

the issue was that i commited this
Code:
bool Spawn::spawnMonster(uint32_t spawnId, MonsterType* mType, const Position& pos, Direction dir, bool startup/*= false*/)
{
    std::unique_ptr<Monster> monster_ptr(new Monster(mType));
    if (!g_events->eventMonsterOnSpawn(monster_ptr.get(), pos, startup, false)) {
        return false;
    }

    if (startup) {
        //No need to send out events to the surrounding since there is no one out there to listen! //agregado removido x error
        /*if (!g_game.internalPlaceCreature(monster_ptr.get(), pos, true)) {
            std::cout << "[Warning - Spawns::startup] Couldn't spawn monster \"" << monster_ptr->getName() << "\" on position: " << pos << '.' << std::endl;
            return false;
        }
    } *///else {
        if (!g_game.placeCreature(monster_ptr.get(), pos, false, true)) {
            return false;
        }
    }

i reverted it and issue was solved. thank you
 
Thank you @EvulMastah for such quick reply. By mistake i committed an important part of the code trying to remove few warnings from the console like these:
Lua:
>> Initializing gamestate
[Warning - Spawns::startup] Couldn't spawn monster "fire elemental" on position: ( 33248 / 31594 / 012 ).
[Warning - Spawns::startup] Couldn't spawn monster "fire elemental" on position: ( 33248 / 31594 / 012 ).
[Warning - Spawns::startup] Couldn't spawn monster "fire elemental" on position: ( 33247 / 31597 / 012 ).
[Warning - Spawns::startup] Couldn't spawn monster "fire elemental" on position: ( 33247 / 31597 / 012 ).
[Warning - Spawns::startup] Couldn't spawn monster "tiger" on position: ( 32528 / 32785 / 007 ).
[Warning - Spawns::startup] Couldn't spawn monster "tiger" on position: ( 32528 / 32785 / 007 ).

the issue was that i commited this
Code:
bool Spawn::spawnMonster(uint32_t spawnId, MonsterType* mType, const Position& pos, Direction dir, bool startup/*= false*/)
{
    std::unique_ptr<Monster> monster_ptr(new Monster(mType));
    if (!g_events->eventMonsterOnSpawn(monster_ptr.get(), pos, startup, false)) {
        return false;
    }

    if (startup) {
        //No need to send out events to the surrounding since there is no one out there to listen! //agregado removido x error
        /*if (!g_game.internalPlaceCreature(monster_ptr.get(), pos, true)) {
            std::cout << "[Warning - Spawns::startup] Couldn't spawn monster \"" << monster_ptr->getName() << "\" on position: " << pos << '.' << std::endl;
            return false;
        }
    } *///else {
        if (!g_game.placeCreature(monster_ptr.get(), pos, false, true)) {
            return false;
        }
    }

i reverted it and issue was solved. thank you
Those messages are probably there because engine is trying to spawn monsters on tile where is no map or no place to spawn this monster in spawn radius (PZ or unpassable).
 
Those messages are probably there because engine is trying to spawn monsters on tile where is no map or no place to spawn this monster in spawn radius (PZ or unpassable).
yep i know. that why i removed the warning but i removed something else by mistake the issue is solved
 
Back
Top