Skip to content

Commit

Permalink
StaticFlags: Implement DONT_REPOSITION_IF_MELEE_TARGET_IS_TOO_CLOSE (#…
Browse files Browse the repository at this point in the history
…547)

* StaticFlags: Implement DONT_REPOSITION_IF_MELEE_TARGET_IS_TOO_CLOSE

* StaticFlags: cache backpedal enablement
  • Loading branch information
insunaa authored Nov 12, 2024
1 parent 3f9e706 commit c23a9f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/game/MotionGenerators/TargetedMovementGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ void ChaseMovementGenerator::Initialize(Unit& owner)
_setLocation(owner);
i_target->GetPosition(i_lastTargetPos.x, i_lastTargetPos.y, i_lastTargetPos.z);
m_fanningEnabled = !(owner.GetTypeId() == TYPEID_UNIT && static_cast<Creature&>(owner).IsWorldBoss());
m_backpedalEnabled = !(owner.GetTypeId() == TYPEID_UNIT && static_cast<Creature&>(owner).GetSettings().HasFlag(CreatureStaticFlags4::DONT_REPOSITION_IF_MELEE_TARGET_IS_TOO_CLOSE));
}

void ChaseMovementGenerator::Finalize(Unit& owner)
Expand Down Expand Up @@ -394,6 +395,9 @@ void ChaseMovementGenerator::Backpedal(Unit& owner)
if (!owner.AI() || owner.AI()->GetCombatScriptStatus())
return;

if (!m_backpedalEnabled)
return;

m_closenessExpired = false;
m_closenessAndFanningTimer = CHASE_CLOSENESS_TIMER; // Just in case path doesnt generate
float targetDist = std::min(this->i_target->GetCombinedCombatReach(&owner, false), 3.75f);
Expand Down
3 changes: 2 additions & 1 deletion src/game/MotionGenerators/TargetedMovementGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ChaseMovementGenerator : public TargetedMovementGeneratorMedium<Unit, Chas
public:
ChaseMovementGenerator(Unit& target, float offset, float angle, bool moveFurther = true, bool walk = false, bool combat = true)
: TargetedMovementGeneratorMedium<Unit, ChaseMovementGenerator >(target, offset, angle), m_moveFurther(moveFurther), m_walk(walk), m_combat(combat), m_currentMode(CHASE_MODE_NORMAL),
m_fanningEnabled(true), m_closenessAndFanningTimer(0), m_closenessExpired(false), m_reachable(true) {}
m_fanningEnabled(true), m_backpedalEnabled(true), m_closenessAndFanningTimer(0), m_closenessExpired(false), m_reachable(true) {}
~ChaseMovementGenerator() {}

MovementGeneratorType GetMovementGeneratorType() const override { return CHASE_MOTION_TYPE; }
Expand Down Expand Up @@ -166,6 +166,7 @@ class ChaseMovementGenerator : public TargetedMovementGeneratorMedium<Unit, Chas
bool m_combat;
bool m_reachable;
bool m_fanningEnabled;
bool m_backpedalEnabled;

uint32 m_closenessAndFanningTimer;
bool m_closenessExpired;
Expand Down

0 comments on commit c23a9f7

Please sign in to comment.