Forgottenserver: Wrong behavior of monsters with distance attacks.

Created on 24 Nov 2019  路  6Comments  路  Source: otland/forgottenserver

This issue is reproducible on Tfs 1.2

Steps to reproduce (include any configuration/script required to reproduce)
Look for some monster that needs distance from you to attack.
Example: Warlocks

Expected behaviour - I will upload a movie here, this will make understanding easier
https://streamable.com/h2uxk

In this case, the monster tries to go to the player to attack him.

Actual behaviour [Wrong] - the movie here.
https://streamable.com/3jlj3

the monster is standing attacking the target, when he should go to the player and come back.

Environment
Using Windows 10, 64 bits.

Does anyone have any suggestions to fix this?
what is the function responsible for this behavior?

bug

Most helpful comment

and here is some footage from both RL tibia and latest TFS:
Rvg6GAY
XM4kGNl

As far as I can see, this is related to:
https://github.com/otland/forgottenserver/issues/1690
https://github.com/otland/forgottenserver/issues/922

It seems the behaviour of isSightClear() is not the same as real tibia(?)

Which means ranged monsters can still hit you when around a corner 2sqm away in TFS.
Whereas in real tibia they can't - the corner cuts line of sight.

This explains both monster movement and spell area/wall behaviour.

All 6 comments

I think this is the code responsible for it:

https://github.com/otland/forgottenserver/blob/1af9c7dae4937f2c27c6117cc4a6e4e870a993d8/src/monster.cpp#L1130-L1139

and here is some footage from both RL tibia and latest TFS:
Rvg6GAY
XM4kGNl

If you add this it will have a behavior that is too similar to that of tibia RL

search function bool Monster::getDanceStep(const Position& creaturePos, Direction& direction, bool keepAttack /*= true*/, bool keepDistance /*= true*/) on monster.cpp

just above this code if (!dirList.empty()) { std::shuffle(dirList.begin(), dirList.end(), getRandomGenerator()); direction = dirList[uniform_random(0, dirList.size() - 1)]; return true; }

add the code mentioned above: if (dirList.empty()) { // extra dancing for (uint8_t i = 0; i < 3; i++) { Direction dir = static_cast<Direction>(i); if (canWalkTo(creaturePos, dir)) { dirList.push_back(dir); } } }

example of final code: https://image.prntscr.com/image/tHF5MmABStGDURwv8053YQ.png
If someone manages to improve this, or create something different and better, I will be grateful

If you add this it will have a behavior that is too similar to that of tibia RL

search function bool Monster::getDanceStep(const Position& creaturePos, Direction& direction, bool keepAttack /*= true*/, bool keepDistance /*= true*/) on monster.cpp

just above this code if (!dirList.empty()) { std::shuffle(dirList.begin(), dirList.end(), getRandomGenerator()); direction = dirList[uniform_random(0, dirList.size() - 1)]; return true; }

add the code mentioned above: if (dirList.empty()) { // extra dancing for (uint8_t i = 0; i < 3; i++) { Direction dir = static_cast<Direction>(i); if (canWalkTo(creaturePos, dir)) { dirList.push_back(dir); } } }

example of final code: https://image.prntscr.com/image/tHF5MmABStGDURwv8053YQ.png
If someone manages to improve this, or create something different and better, I will be grateful

maybe this is the way, but the creature is a little slow compared to RL Tibia movie

change this creature.h: static constexpr int32_t EVENT_CREATURE_THINK_INTERVAL = 1000;
and staticattack="90" of monster.xml
if the verification is faster, the monster's actions will be faster

Also the issue is more intense when you summon melee monster and you attack a ranged monster.
Test it with different movement speed monsters and summons.

And enjoy the dance :D what are they they doing :D

and here is some footage from both RL tibia and latest TFS:
Rvg6GAY
XM4kGNl

As far as I can see, this is related to:
https://github.com/otland/forgottenserver/issues/1690
https://github.com/otland/forgottenserver/issues/922

It seems the behaviour of isSightClear() is not the same as real tibia(?)

Which means ranged monsters can still hit you when around a corner 2sqm away in TFS.
Whereas in real tibia they can't - the corner cuts line of sight.

This explains both monster movement and spell area/wall behaviour.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mishimalisa picture mishimalisa  路  5Comments

EPuncker picture EPuncker  路  3Comments

irenicus30 picture irenicus30  路  5Comments

EPuncker picture EPuncker  路  5Comments

EPuncker picture EPuncker  路  4Comments