mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 00:18:43 +01:00
re-enable CreatureAI::MovementInform for Chase/FollowMovementGenerator - didn't realize any AI used this
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "ChaseMovementGenerator.h"
|
||||
#include "Creature.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "G3DPosition.hpp"
|
||||
#include "MotionMaster.h"
|
||||
#include "MoveSpline.h"
|
||||
@@ -33,6 +34,13 @@ static bool IsMutualChase(Unit* owner, Unit* target)
|
||||
return (static_cast<ChaseMovementGenerator const*>(target->GetMotionMaster()->top())->GetTarget() == owner);
|
||||
}
|
||||
|
||||
static void DoMovementInform(Unit* owner, Unit* target)
|
||||
{
|
||||
if (Creature* cOwner = owner->ToCreature())
|
||||
if (CreatureAI* ai = cOwner->AI())
|
||||
ai->MovementInform(CHASE_MOTION_TYPE, target->GetGUID().GetCounter());
|
||||
}
|
||||
|
||||
static bool PositionOkay(Unit* owner, Unit* target, Optional<float> minDistance, Optional<float> maxDistance, Optional<ChaseAngle> angle)
|
||||
{
|
||||
float const distSq = owner->GetExactDistSq(target);
|
||||
@@ -96,6 +104,7 @@ bool ChaseMovementGenerator::Update(Unit* owner, uint32 diff)
|
||||
_path = nullptr;
|
||||
owner->StopMoving();
|
||||
owner->SetInFront(target);
|
||||
DoMovementInform(owner, target);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -107,6 +116,7 @@ bool ChaseMovementGenerator::Update(Unit* owner, uint32 diff)
|
||||
_path = nullptr;
|
||||
owner->ClearUnitState(UNIT_STATE_CHASE_MOVE);
|
||||
owner->SetInFront(target);
|
||||
DoMovementInform(owner, target);
|
||||
}
|
||||
|
||||
// if the target moved, we have to consider whether to adjust
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "FollowMovementGenerator.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "MoveSpline.h"
|
||||
#include "MoveSplineInit.h"
|
||||
#include "Optional.h"
|
||||
@@ -27,6 +28,14 @@
|
||||
FollowMovementGenerator::FollowMovementGenerator(Unit* target, float range, ChaseAngle angle) : AbstractFollower(ASSERT_NOTNULL(target)), _range(range), _angle(angle) {}
|
||||
FollowMovementGenerator::~FollowMovementGenerator() = default;
|
||||
|
||||
static void DoMovementInform(Unit* owner, Unit* target)
|
||||
{
|
||||
if (owner->GetTypeId() != TYPEID_UNIT)
|
||||
return;
|
||||
if (UnitAI* ai = owner->GetAI())
|
||||
static_cast<CreatureAI*>(ai)->MovementInform(FOLLOW_MOTION_TYPE, target->GetGUID().GetCounter());
|
||||
}
|
||||
|
||||
static bool PositionOkay(Unit* owner, Unit* target, float range, Optional<ChaseAngle> angle = {})
|
||||
{
|
||||
if (owner->GetExactDistSq(target) > square(owner->GetCombatReach() + target->GetCombatReach() + range))
|
||||
@@ -70,6 +79,7 @@ bool FollowMovementGenerator::Update(Unit* owner, uint32 diff)
|
||||
{
|
||||
_path = nullptr;
|
||||
owner->StopMoving();
|
||||
DoMovementInform(owner, target);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -79,6 +89,7 @@ bool FollowMovementGenerator::Update(Unit* owner, uint32 diff)
|
||||
{
|
||||
_path = nullptr;
|
||||
owner->ClearUnitState(UNIT_STATE_FOLLOW_MOVE);
|
||||
DoMovementInform(owner, target);
|
||||
}
|
||||
|
||||
if (_lastTargetPosition.GetExactDistSq(target->GetPosition()) > 0.0f)
|
||||
|
||||
Reference in New Issue
Block a user