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

TFS 1.X+ Monsters Behavior

endziu2222

Active Member
Joined
Nov 2, 2010
Messages
167
Solutions
1
Reaction score
44
Does anybody know how to change monster behavior so it moves around when player is not on the screen??

Latest TFS.
 
Solution
When I edit this or increase distance server start to lag.
Of course it will lag. That's why monsters go 'idle', when there are no players within some range. What does it change for players, if monsters move, when they are not on screen? Nothing. Default distance is 11 sqm, 3-4 sqm more than range visible in client, so monsters move, even when players can't see them in client.

With 500 players online you got around 1-2k monsters 'active'. Rest of monsters - often 50-150k - is idle. If you make all monsters active, you will increase number of creatures 'to process' by server each second 50-100 TIMES.

Anyway, if you want to disable idle state:
1. Change ( forgottenserver/src/monster.cpp at master ·...
Anyone know how can I increase Creatures detection range?
So player can be detected not from basic 12 to more distance?
 
I believe it's a terrible idea to make monsters walks when the player is off-screen due to unnecessary resource consumption. Just imagine the strain on resources with thousands of monsters in motion when no one is on screen
 
I was thinking this was a solution but not. When I edit this or increase distance server start to lag.
i do not use these sources myself so i could be providing the wrong cpp file, try a search for 'cansee' and peak around.
btw, @Stanos makes a good point, did you increase it by 1? or by much? ^^
 
When I edit this or increase distance server start to lag.
Of course it will lag. That's why monsters go 'idle', when there are no players within some range. What does it change for players, if monsters move, when they are not on screen? Nothing. Default distance is 11 sqm, 3-4 sqm more than range visible in client, so monsters move, even when players can't see them in client.

With 500 players online you got around 1-2k monsters 'active'. Rest of monsters - often 50-150k - is idle. If you make all monsters active, you will increase number of creatures 'to process' by server each second 50-100 TIMES.

Anyway, if you want to disable idle state:
1. Change ( forgottenserver/src/monster.cpp at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/src/monster.cpp#L189) ):
C++:
setIdle(true);
to:
C++:
setIdle(false);

2. Change ( forgottenserver/src/monster.cpp at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/src/monster.cpp#L751) )
C++:
setIdle(true);
to:
C++:
setIdle(false);
3. Replace ( forgottenserver/src/monster.cpp at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/src/monster.cpp#L679-L689) )
C++:
void Monster::updateIdleStatus()
{
    bool idle = false;
    if (!isSummon() && targetList.empty()) {
        // check if there are aggressive conditions
        idle = std::find_if(conditions.begin(), conditions.end(),
                            [](Condition* condition) { return condition->isAggressive(); }) == conditions.end();
    }

    setIdle(idle);
}
with:
C++:
void Monster::updateIdleStatus()
{
    setIdle(false);
}
 
Solution
What does it change for players, if monsters move, when they are not on screen? Nothing.
That's true. The only thing I can think of is monsters position being more random when you get to their spawn. Instead of expected mob at the same position every time respawn happens, it would be moving around so next time you encounter it, it might end up somewhere else. Its more RPG feeling/immersion thing than actual usefulness of the feature.
But if that's what OP is aiming for, then he might as well give random path to mobs once they spawn and make them move.
 
That's true. The only thing I can think of is monsters position being more random when you get to their spawn. Instead of expected mob at the same position every time respawn happens, it would be moving around so next time you encounter it, it might end up somewhere else. Its more RPG feeling/immersion thing than actual usefulness of the feature.
But if that's what OP is aiming for, then he might as well give random path to mobs once they spawn and make them move.

Might there be some overhead with having thousands of monsters just moving around randomly when absolutely no one is around?

I could understand wanting them to still move around if a player changes floor, like how they changed it from 7.4-ish to 7.7, but tens of thousands of randomly wandering 100% of the time seems excessive... Idk if that really makes much difference though
 
That's true. The only thing I can think of is monsters position being more random when you get to their spawn. Instead of expected mob at the same position every time respawn happens, it would be moving around so next time you encounter it, it might end up somewhere else. Its more RPG feeling/immersion thing than actual usefulness of the feature.
But if that's what OP is aiming for, then he might as well give random path to mobs once they spawn and make them move.
I will test what gesior advised and see how it affects the server. Currently I have over 50k monsters on my ots. I did heard you can give monsters a path they have to follow but I have not seen any example on how to do it.

@Gesior.pl thanks.
Post automatically merged:

Of course it will lag. That's why monsters go 'idle', when there are no players within some range. What does it change for players, if monsters move, when they are not on screen? Nothing. Default distance is 11 sqm, 3-4 sqm more than range visible in client, so monsters move, even when players can't see them in client.

With 500 players online you got around 1-2k monsters 'active'. Rest of monsters - often 50-150k - is idle. If you make all monsters active, you will increase number of creatures 'to process' by server each second 50-100 TIMES.

Anyway, if you want to disable idle state:
1. Change ( forgottenserver/src/monster.cpp at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/src/monster.cpp#L189) ):
C++:
setIdle(true);
to:
C++:
setIdle(false);

2. Change ( forgottenserver/src/monster.cpp at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/src/monster.cpp#L751) )
C++:
setIdle(true);
to:
C++:
setIdle(false);
3. Replace ( forgottenserver/src/monster.cpp at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/src/monster.cpp#L679-L689) )
C++:
void Monster::updateIdleStatus()
{
    bool idle = false;
    if (!isSummon() && targetList.empty()) {
        // check if there are aggressive conditions
        idle = std::find_if(conditions.begin(), conditions.end(),
                            [](Condition* condition) { return condition->isAggressive(); }) == conditions.end();
    }

    setIdle(idle);
}
with:
C++:
void Monster::updateIdleStatus()
{
    setIdle(false);
}
I have tested now. You was right lags became HUGE after this. So yeah is not worth it.
 
Last edited:
Back
Top