• 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 A* Algorithm :D

3) My pathfinding algorithm is so much faster than the original one that you could have it run thousands more times.
You can mess with this value for different results in the path updating speed.
C++:
static constexpr int32_t EVENT_CREATURE_PATH_INTERVAL = 20;
Gave a second read to this, does changing
C++:
static constexpr int32_t EVENT_CREATURE_PATH_INTERVAL = 20;
Will affect RAM performance? If so, raising the value to 30 will make the pathfinding consume less RAM, and decreasing it to 10 for example will make it increase RAM?, and also which values are good choises to place on EVENT_CREATURE_PATH_INTERVAL.

Thanks in advance!
 
Gave a second read to this, does changing
C++:
static constexpr int32_t EVENT_CREATURE_PATH_INTERVAL = 20;
Will affect RAM performance? If so, raising the value to 30 will make the pathfinding consume less RAM, and decreasing it to 10 for example will make it increase RAM?, and also which values are good choises to place on EVENT_CREATURE_PATH_INTERVAL.

Thanks in advance!
Yes, it would effect ram usage. However, making it 10 would still be more efficient than using TFS pathfinding especially if you added marks "fix" so the monsters wouldn't lag for a full second before updating their path.

To state why in an easy explanation. These are the fixes that were critical to performance.

1) The old system would check 100 nodes every second as long as the creature was within range (about 12sqm from the target) and there was no path to the target OR it was too far away but is still in range of awareness.

2) The old system used over 10x as many nodes to draw each path.

3) In my system I was able to get even more speed by making paths that aren't blocked (something in between the start and end) ignore nodes it doesn't need to check with some conditional logic.

4) Instead of ALL creatures checking their paths, that EVENT_CREATURE_PATH_INTERVAL will only execute on creatures that NEED to check their path again.
 
Last edited:
@Itutorial I've been implementing those changes, but something is wrong with this:
C++:
void Game::checkCreaturesPath(size_t index)
{
    g_scheduler.addEvent(createSchedulerTask(EVENT_CREATURE_PATH_INTERVAL,
                                             [=, this]() { checkCreatures((index + 1) % EVENT_CREATURECOUNT); }));

    auto& checkCreatureList = checkCreatureLists[index];
    auto it = checkCreatureList.begin(), end = checkCreatureList.end();
    while (it != end) {
        Creature* creature = *it;
        if (creature->getHealth() > 0) {
            creature->checkPath();
        }
        ++it;
    }

    cleanup();
}

Code:
Error    C3791    'this' cannot be explicitly captured when the default capture mode is by copy (=)
 
I have some time so I am working on this system again. I believe I was able to fix all the problems with summons, fleeing creatures, and creatures that keep distance from their targets. You can follow the progress here: Optimize pathfinding by NRH-AA · Pull Request #4637 · otland/forgottenserver (https://github.com/otland/forgottenserver/pull/4637)
Is that TFS 1.5 12.87, or Nekiro 1.5? I tried to find it but couldn't, and some are different from my source. Lol.
 
I have some time so I am working on this system again. I believe I was able to fix all the problems with summons, fleeing creatures, and creatures that keep distance from their targets. You can follow the progress here: Optimize pathfinding by NRH-AA · Pull Request #4637 · otland/forgottenserver (https://github.com/otland/forgottenserver/pull/4637)
Cool thanks btw off topic you don't have cast system commits I have yours system to your server bug I have an error that won't make me log in I debug it but don't know how to fix it would you lend me a hand? I use TFS 1.4 or 1.5 not sure
 
Guys sorry for digging up the topic but I have this huge problem with summons, but my summons are lagged for about 3 seconds after I lock the target. They attack reaction is very slow. The problem is on tfs 1.5 nekiro. @Itutorial
 
Last edited:
Guys sorry for digging up the topic but I have this huge problem with summons, I'm using Gesior Algo 3 Solved - Weird monster behaviour in TFS 1.1? (https://otland.net/threads/weird-monster-behaviour-in-tfs-1-1.228021/page-2#posts) but my summons are lagged for about 3 seconds after I lock the target. Sometimes they don't even react to player attacking at all and just stay in one place, zero movement. The problem is on tfs 1.5 nekiro. @Itutorial
Are you sure that you added all the commits property and in the right order nottignheters posted it in the thread 2
Post automatically merged:

In that order:

.
 
I made the changes, but the behavior of the monsters was strange, instead of the monster sticking to the person, he runs and attacks from afar
 
Made all changes and there is definite improvement in summon and monster behavior.
 
Last edited:
@Itutorial I've been implementing those changes, but something is wrong with this:
C++:
void Game::checkCreaturesPath(size_t index)
{
    g_scheduler.addEvent(createSchedulerTask(EVENT_CREATURE_PATH_INTERVAL,
                                             [=, this]() { checkCreatures((index + 1) % EVENT_CREATURECOUNT); }));

    auto& checkCreatureList = checkCreatureLists[index];
    auto it = checkCreatureList.begin(), end = checkCreatureList.end();
    while (it != end) {
        Creature* creature = *it;
        if (creature->getHealth() > 0) {
            creature->checkPath();
        }
        ++it;
    }

    cleanup();
}

Code:
Error    C3791    'this' cannot be explicitly captured when the default capture mode is by copy (=)
Try changing this
C++:
g_scheduler.addEvent(createSchedulerTask(EVENT_CREATURE_PATH_INTERVAL,
                                             [=, this]() { checkCreatures((index + 1) % EVENT_CREATURECOUNT); }));

for one of these
C++:
g_scheduler.addEvent(createSchedulerTask(EVENT_CREATURE_PATH_INTERVAL,
                                             [=, this]() { checkCreaturesPath((index + 1) % EVENT_CREATURECOUNT); }));

g_scheduler.addEvent(createSchedulerTask(EVENT_CREATURE_PATH_INTERVAL,
                                             [=]() { checkCreaturesPath((index + 1) % EVENT_CREATURECOUNT); }));


I made the changes, but the behavior of the monsters was strange, instead of the monster sticking to the person, he runs and attacks from afar

Same fix
 
Last edited:
I have some time so I am working on this system again. I believe I was able to fix all the problems with summons, fleeing creatures, and creatures that keep distance from their targets. You can follow the progress here: Optimize pathfinding by NRH-AA · Pull Request #4637 · otland/forgottenserver (https://github.com/otland/forgottenserver/pull/4637)

Going to give this a try today and report back on how it's working, this is something that's been needed for awhile - glad to see the efforts still there! Thanks for your contributions 😊👌
 
Anyone have chronologically order of changes that should be applied straight from zero (if I've never messed with it before)?
Thanks :rolleyes:
 
Anyone have chronologically order of changes that should be applied straight from zero (if I've never messed with it before)?
Thanks :rolleyes:
I wish there was a better way to say it other than, "Look up.." (literally two posts above yours and would have been the second to last before commenting) 🤦‍♂️
 
After some testing it seems like things are working pretty good, much better than before. However one issue seems to be showing, when the player stops moving the monsters return to delayed behavior. Almost feels like it should wait until there is no players on screen to begin that behavior; I've included a video to show you what I mean.
View attachment blazera_Y90Z8mukQZ.mp4
 
In that order:

did you added all these?
 
After some testing it seems like things are working pretty good, much better than before. However one issue seems to be showing, when the player stops moving the monsters return to delayed behavior. Almost feels like it should wait until there is no players on screen to begin that behavior; I've included a video to show you what I mean.
View attachment 83231
I am on it. Thanks for testing
Post automatically merged:

did you added all these?
No it only includes the two repos by gigastar (me). Those are also old and I didn't have to do everything I did in those repos. You should be able to add any of those other changes by other authors after you install my system
 
I am on it
Post automatically merged:


No it only includes the two repos by gigastar (me). Those are also old and I didn't have to do everything I did in those repos. You should be able to add any of those other changes by other authors after you install my system
Wonderful, Ill give it a test when its updated and report back <3
 
Back
Top