Jump to content

[BUG] Mobs follow on fly


byterider

Recommended Posts

Mangos Version: 9034 (linux x86_32)

SD2 Version: 1513

Database Version: YTDB 524

Hello there,

When in fly on the ground and a mob gonna attack me, the mob follows me into the sky.

The combat should stop when I gonna fly into the sky.

Here a image.

Thank you for reading.

Greetz

byte

Link to comment
Share on other sites

creatures leave combat if the attacker takes off.

Can you be more specific on this?

- is it instant evade or do they stand still for a little while (like 2-5 seconds) before they evade?

- are there cases where creature attempt use ranged spell and can possibly knock player off the mount so he fall back on to the ground?

Link to comment
Share on other sites

Lol, just some test code i figured wouldn't hurt to try:

 src/game/TargetedMovementGenerator.cpp |    6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/game/TargetedMovementGenerator.cpp b/src/game/TargetedMovementGenerator.cpp
index 10f2597..1a3b0c9 100644
--- a/src/game/TargetedMovementGenerator.cpp
+++ b/src/game/TargetedMovementGenerator.cpp
@@ -65,6 +65,12 @@ TargetedMovementGenerator<T>::_setTargetLocation(T &owner)
        i_target->GetClosePoint(x,y,z,owner.GetObjectSize(),i_offset,i_angle);
    }

+    if (owner.GetTypeId() == TYPEID_UNIT && !((Creature*)&owner)->canFly())
+    {
+        const Map* pMap = owner.GetBaseMap();
+        z = std::max(pMap->GetHeight(x, y, MAX_HEIGHT), pMap->GetWaterLevel(x, y));
+    }
+
    /*
        We MUST not check the distance difference and avoid setting the new location for smaller distances.
        By that we risk having far too many GetContactPoint() calls freezing the whole system.

It pretty much glue them to ground and follow you from there, instead of going up in to the air. For correctness, it's probably not right, but at least can give some idea how to make them move on the ground instead of following up in the air. No idea if it have any side-effects, but i assume there are.

Link to comment
Share on other sites

i've been thinking about trying to add something like that too, because there are unpretty things going on not only if you fly away.

If there's some vale or hill between you and the mob it will currently still just run to you in a straight line, either jumping through the air or sinking into the ground, and actually also die right there if killed with ranged attacks, possibly being unlootable.

Though you probably distort movement speed quite a bit by only adjusting the z value with constant horizontal movement speed...not to mention you'll have a lot of fun with proper vmap support-

Link to comment
Share on other sites

You must not mix up _destination point_ with the points in between. i_destinationHolder.SetDestination(traveller, x, y, z); is the destination, and it is in fact correct for this function.

What you are talking about is pathfinding, the generated points between current location and destination location, which is a far more complex issue, not really related to this topic at all :)

Link to comment
Share on other sites

So this should work like this:

While you are in the air, non-flying npcs will aggro you only if they have a ranged spell and as long as you are in range of that spell. Once you gain height and get out of range they stop casting, evade and return to their original location. Pathing NPCs continue the path they were following.

Non flying NPCs that don't have any ranged spells won't aggro you until you are in melee range or if you are floating closely above the ground in aggro range. It will start hitting and following you until you gain height again. After you get out of range and thus out of combat, the NPC immediately evades and returns to its original place.

Getting dismounted by other players or NPCs trough transforming spells, knockbacks, stuns, nets etc. is not possible while flying. An exception are the bombing run quests.

In any case, NPCs that are NOT flagged for flying should not leave the ground whatsoever.

Link to comment
Share on other sites

  • 5 weeks later...
  • 1 month later...
  • 3 weeks later...

This was on my list of things to do with pathfinding, but I think that there are other, faster ways to fix it similar to what NoFantasy posted above.

However, there is a problem with checking JUST the height.

Some monsters can throw you into the air high enough that they need to follow to keep attacking. (see http://www.wowhead.com/npc=5474#abilities)

If the target isn't in range, that ogre will just evade and reset even though the player wasn't really out of range.

So, you need to see if the player is actually flying, versus if he is falling, knocked back, etc.

Link to comment
Share on other sites

  • 1 month later...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use