• 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+ Bad reaction/dodge from monsters

Drucken

Member
Joined
Mar 7, 2023
Messages
45
Solutions
1
Reaction score
15
Monsters in TFS 1.5 have a very different reaction(dodge, in TFS 0.4 the monster could dodge the players, which is quite necessary, in TFS 1.5 (it may happen the same in some other TFS) this doesn't happen... Besides other bugs which were seen by @Levi999x

Well, I have added the changes of @Gesior.pl in the post of:

It has improved the reaction when the monster escapes, but the problem of dodge is still there, the monster gets stuck in the corners.

giphy.gif

 
Last edited:
Solution
Monsters in TFS 1.5 have a very different reaction(dodge, in TFS 0.4 the monster could dodge the players, which is quite necessary, in TFS 1.5 (it may happen the same in some other TFS) this doesn't happen... Besides other bugs which were seen by @Levi999x

Well, I have added the changes of @Gesior.pl in the post of:

It has improved the reaction when the monster escapes, but the problem of dodge is still there, the monster gets stuck in the corners.

giphy.gif

I'm pretty sure that there are some extra IFs in new TFS to...
Yes, maybe someone could help us with this, I have tried a few TFS 1.X+ and they have the same problem...
 
Monsters in TFS 1.5 have a very different reaction(dodge, in TFS 0.4 the monster could dodge the players, which is quite necessary, in TFS 1.5 (it may happen the same in some other TFS) this doesn't happen... Besides other bugs which were seen by @Levi999x

Well, I have added the changes of @Gesior.pl in the post of:

It has improved the reaction when the monster escapes, but the problem of dodge is still there, the monster gets stuck in the corners.

giphy.gif

I'm pretty sure that there are some extra IFs in new TFS to make monsters stuck in these edge cases (between 2 walls and in corner). It was probably requested by someone to mimic RL tibia 12+ behaviour. IDK, I never logged on 12+ RL Tibia.
Reaction time is limited by path recalculation limit added in TFS 1.x (1 time per second). It worked fast on TFS 0.4, but 10 players fighting 15 Demons each make CPU goes 100%. You can add my code from Solved - Weird monster behaviour in TFS 1.1? (https://otland.net/threads/weird-monster-behaviour-in-tfs-1-1.228021/page-3#post-2703201) to make it react faster, but it will use more CPU.
EDIT:
"Stuck in corner" algorithm:
There was no such thing in 0.4 (Monster::getDistanceStep). It always called A* algorithm, which easily found way to run from any corner.
 
Last edited:
Solution
Yeah @Gesior.pl, the changes you have made (work great) I already have them added and therefore the reaction works well, but the monster stays stuck around the corner instead of dodging and running to other sides, it would be good to know how to reverse that changes.

The GIF what i made is with your changes (showing both TFS 0.4 and in this case 1.5)...
giphy.gif


And this video of @ralke, is a TFS 1.5 with TFS A* Algorithm

 
@Gesior.pl thanks for your comment! That comment that you made has helped me to realize how the codes differed...

I have solved it
by removing Monster::getDistanceStep from Creature::goToFollowCreature, in the end it would look like this:


Solving Dodge
Replace function Creature::goToFollowCreature() in creature.cpp
C++:
void Creature::goToFollowCreature()
{
    if (followCreature)
    {
        FindPathParams fpp;
        getPathSearchParams(followCreature, fpp);

        listWalkDir.clear();

        if (getPathTo(followCreature->getPosition(), listWalkDir, fpp))
        {
            hasFollowPath = true;
            startAutoWalk(listWalkDir);
        }
        else
            hasFollowPath = false;
    }

    onFollowCreatureComplete(followCreature);
}

Solving Reaction

EDIT: added "listWalkDir.clear();" for inaccuracy of the follow in Creature::goToFollowCreature()
 
Last edited:
I've been looking for hours and I can't figure it out. So what was the code you replaced? Was it in creature.cpp? Or in another file?
Lua:
void Creature::goToFollowCreature()
{
    if (followCreature) {
        FindPathParams fpp;
        getPathSearchParams(followCreature, fpp);

        Monster* monster = getMonster();
        if (monster && !monster->getMaster() && (monster->isFleeing() || fpp.maxTargetDist > 1)) {
            Direction dir = DIRECTION_NONE;

            if (monster->isFleeing()) {
                monster->getDistanceStep(followCreature->getPosition(), dir, true);
            } else { // maxTargetDist > 1
                if (!monster->getDistanceStep(followCreature->getPosition(), dir)) {
                    // if we can't get anything then let the A* calculate
                    listWalkDir.clear();
                    if (getPathTo(followCreature->getPosition(), listWalkDir, fpp)) {
                        hasFollowPath = true;
                        startAutoWalk();
                    } else {
                        hasFollowPath = false;
                    }
                    return;
                }
            }

            if (dir != DIRECTION_NONE) {
                listWalkDir.clear();
                listWalkDir.push_back(dir);

                hasFollowPath = true;
                startAutoWalk();
            }
        } else {
            listWalkDir.clear();
            if (getPathTo(followCreature->getPosition(), listWalkDir, fpp)) {
                hasFollowPath = true;
                startAutoWalk();
            } else {
                hasFollowPath = false;
            }
        }
    }

    onFollowCreatureComplete(followCreature);
}
to this
Lua:
void Creature::goToFollowCreature()
{
    if (followCreature)
    {
        FindPathParams fpp;
        getPathSearchParams(followCreature, fpp);

        if (getPathTo(followCreature->getPosition(), listWalkDir, fpp))
        {
            hasFollowPath = true;
            startAutoWalk(listWalkDir);
        }
        else
            hasFollowPath = false;
    }

    onFollowCreatureComplete(followCreature);
}
 
Updated the function Creature::goToFollowCreature() for the inaccuracy of the follow, adding:
listWalkDir.clear();

above of:
if (getPathTo(followCreature->getPosition(), listWalkDir, fpp))

The change is here ↓

@Levi999x, in the video where you post the bad reaction "following/click somewhere", is still a issue.

giphy.gif
 
Updated the function Creature::goToFollowCreature() for the inaccuracy of the follow, adding:
listWalkDir.clear();

above of:
if (getPathTo(followCreature->getPosition(), listWalkDir, fpp))

The change is here ↓

@Levi999x, in the video where you post the bad reaction "following/click somewhere", is still a issue.

giphy.gif
can you post the changes you've made? please?
 
@Levi999x, in the video where you post the bad reaction "following/click somewhere", is still a issue.

giphy.gif
Since the fix is kinda the same than Fir3lement sources we could see if that following/click can be searched there too. Anyways I don't know which bool could be related to that. Good job there I will apply the goToFollow creature commit to test it with @Itutorial A* algoryhm to see how it goes too ^^

Regards
 
@Drucken Test with two players. Couldn't test with more people online since the player amount decreases during the week, but it seems that it runs good. As soon I get more player activity I will tell you guys if there's too much lag. Using a* algorythm from Itutorial.


 
Updated the function Creature::goToFollowCreature() for the inaccuracy of the follow, adding:
listWalkDir.clear();

above of:
if (getPathTo(followCreature->getPosition(), listWalkDir, fpp))

The change is here ↓

@Levi999x, in the video where you post the bad reaction "following/click somewhere", is still a issue.

giphy.gif

Found a solution yet about it?
 
Back
Top