Add backwards paramater on MoveAway (apply only on FleeAction)

This commit is contained in:
Yunfan Li
2024-12-31 20:56:25 +08:00
parent 8dc5bdb4c1
commit cc5a3e4c76
2 changed files with 5 additions and 11 deletions

View File

@@ -1522,14 +1522,8 @@ void MovementAction::ClearIdleState()
context->GetValue<PositionMap&>("position")->Get()["random"].Reset(); 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) if (!target)
{ {
return false; return false;
@@ -1551,7 +1545,7 @@ bool MovementAction::MoveAway(Unit* target, float distance)
dz = bot->GetPositionZ(); dz = bot->GetPositionZ();
exact = false; 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; return true;
} }
@@ -1573,7 +1567,7 @@ bool MovementAction::MoveAway(Unit* target, float distance)
dz = bot->GetPositionZ(); dz = bot->GetPositionZ();
exact = false; 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; return true;
} }
@@ -1774,7 +1768,7 @@ const Movement::PointsArray MovementAction::SearchForBestPath(float x, float y,
bool FleeAction::Execute(Event event) bool FleeAction::Execute(Event event)
{ {
// return Flee(AI_VALUE(Unit*, "current target")); // 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() bool FleeAction::isUseful()

View File

@@ -51,7 +51,7 @@ protected:
bool Flee(Unit* target); bool Flee(Unit* target);
void ClearIdleState(); void ClearIdleState();
void UpdateMovementState(); 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 MoveFromGroup(float distance);
bool Move(float angle, 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); bool MoveInside(uint32 mapId, float x, float y, float z, float distance = sPlayerbotAIConfig->followDistance, MovementPriority priority = MovementPriority::MOVEMENT_NORMAL);