Skip to content

Commit

Permalink
Add backwards paramater on MoveAway (apply only on FleeAction)
Browse files Browse the repository at this point in the history
  • Loading branch information
liyunfan1223 committed Dec 31, 2024
1 parent 8dc5bdb commit cc5a3e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
14 changes: 4 additions & 10 deletions src/strategy/actions/MovementActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1522,14 +1522,8 @@ void MovementAction::ClearIdleState()
context->GetValue<PositionMap&>("position")->Get()["random"].Reset();
}

bool MovementAction::MoveAway(Unit* target, float distance)
bool MovementAction::MoveAway(Unit* target, float distance, bool backwards)
{
// MotionMaster& mm = *bot->GetMotionMaster();
// mm.Clear();
// mm.MoveBackwards(target, distance);
// botAI->SetNextCheckDelay(3000);
// // bot->GetSpeed()
// return true;
if (!target)
{
return false;
Expand All @@ -1551,7 +1545,7 @@ bool MovementAction::MoveAway(Unit* target, float distance)
dz = bot->GetPositionZ();
exact = false;
}
if (MoveTo(target->GetMapId(), dx, dy, dz, false, false, true, exact, MovementPriority::MOVEMENT_COMBAT, false, true))
if (MoveTo(target->GetMapId(), dx, dy, dz, false, false, true, exact, MovementPriority::MOVEMENT_COMBAT, false, backwards))
{
return true;
}
Expand All @@ -1573,7 +1567,7 @@ bool MovementAction::MoveAway(Unit* target, float distance)
dz = bot->GetPositionZ();
exact = false;
}
if (MoveTo(target->GetMapId(), dx, dy, dz, false, false, true, exact, MovementPriority::MOVEMENT_COMBAT, false, true))
if (MoveTo(target->GetMapId(), dx, dy, dz, false, false, true, exact, MovementPriority::MOVEMENT_COMBAT, false, backwards))
{
return true;
}
Expand Down Expand Up @@ -1774,7 +1768,7 @@ const Movement::PointsArray MovementAction::SearchForBestPath(float x, float y,
bool FleeAction::Execute(Event event)
{
// return Flee(AI_VALUE(Unit*, "current target"));
return MoveAway(AI_VALUE(Unit*, "current target"));
return MoveAway(AI_VALUE(Unit*, "current target"), true);
}

bool FleeAction::isUseful()
Expand Down
2 changes: 1 addition & 1 deletion src/strategy/actions/MovementActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MovementAction : public Action
bool Flee(Unit* target);
void ClearIdleState();
void UpdateMovementState();
bool MoveAway(Unit* target, float distance = sPlayerbotAIConfig -> fleeDistance);
bool MoveAway(Unit* target, float distance = sPlayerbotAIConfig -> fleeDistance, bool backwards = false);
bool MoveFromGroup(float distance);
bool Move(float angle, float distance);
bool MoveInside(uint32 mapId, float x, float y, float z, float distance = sPlayerbotAIConfig->followDistance, MovementPriority priority = MovementPriority::MOVEMENT_NORMAL);
Expand Down

0 comments on commit cc5a3e4

Please sign in to comment.