Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StaticFlags: Implement DONT_REPOSITION_IF_MELEE_TARGET_IS_TOO_CLOSE #547

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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