Core/Movement: reworked chase movement

* the destination prediction is now much more reliable
* the movement generator will now more frequently check for valid positions to match retail behavior
* the catch-up mechanic will now adapt its speed to the target's one when being close enough to hit it
* temporarily disabled backwards movement when being too close to a target to avoid some edge cases that need additional research
* fixed the pathfinding reaching behavior so that they no longer follow you to unreachable obstacles and return home when they can't reach you anymore

closes #345
closes #260
This commit is contained in:
Ovahlord committed 2023-08-24 20:16:41 +02:00
1 parent 63be5a888c
commit 0840143137
9 files changed
+204 -120

No files matched your search

@@ -1669,12 +1669,15 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
float attackDistance = float(e.action.setRangedMovement.distance);
float attackAngle = float(e.action.setRangedMovement.angle) / 180.0f * float(M_PI);
Optional<ChaseAngle> angle;
if (attackAngle != 0.f)
angle = ChaseAngle(attackAngle);
for (WorldObject* target : targets)
if (Creature* creature = target->ToCreature())
if (IsSmart(creature) && creature->GetVictim())
if (ENSURE_AI(SmartAI, creature->AI())->CanCombatMove())
creature->GetMotionMaster()->MoveChase(creature->GetVictim(), attackDistance, attackAngle);
creature->GetMotionMaster()->MoveChase(creature->GetVictim(), attackDistance, angle);
break;
}