endziu2222
Active Member
- Joined
- Nov 2, 2010
- Messages
- 175
- Solutions
- 1
- Reaction score
- 46
Does anybody know how to change monster behavior so it moves around when player is not on the screen??
Latest TFS.
Latest TFS.
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.When I edit this or increase distance server start to lag.
have a look at this,Anyone know how can I increase Creatures detection range?
So player can be detected not from basic 12 to more distance?
I was thinking this was a solution but not. When I edit this or increase distance server start to lag.have a look at this,
forgottenserver/src/monster.cpp at master · otland/forgottenserver
A free and open-source MMORPG server emulator written in C++ - otland/forgottenservergithub.com
i do not use these sources myself so i could be providing the wrong cpp file, try a search for 'cansee' and peak around.I was thinking this was a solution but not. 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.When I edit this or increase distance server start to lag.
setIdle(true);
setIdle(false);
setIdle(true);
setIdle(false);
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);
}
void Monster::updateIdleStatus()
{
setIdle(false);
}
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.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.
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.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 have tested now. You was right lags became HUGE after this. So yeah is not worth it.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) ):
to:C++:setIdle(true);
C++:setIdle(false);
2. Change ( forgottenserver/src/monster.cpp at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/src/monster.cpp#L751) )
to:C++:setIdle(true);
3. Replace ( forgottenserver/src/monster.cpp at master · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/master/src/monster.cpp#L679-L689) )C++:setIdle(false);
with: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); }
C++:void Monster::updateIdleStatus() { setIdle(false); }