mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Make backwards movement for flee
This commit is contained in:
@@ -177,7 +177,7 @@ bool MovementAction::MoveToLOS(WorldObject* target, bool ranged)
|
||||
}
|
||||
|
||||
bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, bool react, bool normal_only,
|
||||
bool exact_waypoint, MovementPriority priority, bool lessDelay)
|
||||
bool exact_waypoint, MovementPriority priority, bool lessDelay, bool backwards)
|
||||
{
|
||||
UpdateMovementState();
|
||||
if (!IsMovingAllowed(mapId, x, y, z))
|
||||
@@ -208,8 +208,16 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
{
|
||||
MotionMaster& mm = *vehicleBase->GetMotionMaster(); // need to move vehicle, not bot
|
||||
mm.Clear();
|
||||
mm.MovePoint(0, x, y, z, generatePath);
|
||||
float delay = 1000.0f * (distance / vehicleBase->GetSpeed(MOVE_RUN));
|
||||
if (!backwards)
|
||||
{
|
||||
mm.MovePoint(0, x, y, z, generatePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
mm.MovePointBackwards(0, x, y, z, generatePath);
|
||||
}
|
||||
float speed = backwards ? vehicleBase->GetSpeed(MOVE_RUN_BACK) : vehicleBase->GetSpeed(MOVE_RUN);
|
||||
float delay = 1000.0f * (distance / speed);
|
||||
if (lessDelay)
|
||||
{
|
||||
delay -= botAI->GetReactDelay();
|
||||
@@ -235,8 +243,15 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
}
|
||||
MotionMaster& mm = *bot->GetMotionMaster();
|
||||
mm.Clear();
|
||||
mm.MovePoint(0, x, y, z, generatePath);
|
||||
float delay = 1000.0f * MoveDelay(distance);
|
||||
if (!backwards)
|
||||
{
|
||||
mm.MovePoint(0, x, y, z, generatePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
mm.MovePointBackwards(0, x, y, z, generatePath);
|
||||
}
|
||||
float delay = 1000.0f * MoveDelay(distance, backwards);
|
||||
if (lessDelay)
|
||||
{
|
||||
delay -= botAI->GetReactDelay();
|
||||
@@ -270,8 +285,15 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
||||
MotionMaster& mm = *bot->GetMotionMaster();
|
||||
G3D::Vector3 endP = path.back();
|
||||
mm.Clear();
|
||||
mm.MovePoint(0, endP.x, endP.y, endP.z, generatePath);
|
||||
float delay = 1000.0f * MoveDelay(distance);
|
||||
if (!backwards)
|
||||
{
|
||||
mm.MovePoint(0, x, y, z, generatePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
mm.MovePointBackwards(0, x, y, z, generatePath);
|
||||
}
|
||||
float delay = 1000.0f * MoveDelay(distance, backwards);
|
||||
if (lessDelay)
|
||||
{
|
||||
delay -= botAI->GetReactDelay();
|
||||
@@ -1265,20 +1287,20 @@ bool MovementAction::ChaseTo(WorldObject* obj, float distance, float angle)
|
||||
return true;
|
||||
}
|
||||
|
||||
float MovementAction::MoveDelay(float distance)
|
||||
float MovementAction::MoveDelay(float distance, bool backwards)
|
||||
{
|
||||
float speed;
|
||||
if (bot->isSwimming())
|
||||
{
|
||||
speed = bot->GetSpeed(MOVE_SWIM);
|
||||
speed = backwards ? bot->GetSpeed(MOVE_SWIM_BACK) : bot->GetSpeed(MOVE_SWIM);
|
||||
}
|
||||
else if (bot->IsFlying())
|
||||
{
|
||||
speed = bot->GetSpeed(MOVE_FLIGHT);
|
||||
speed = backwards ? bot->GetSpeed(MOVE_FLIGHT_BACK) : bot->GetSpeed(MOVE_FLIGHT);
|
||||
}
|
||||
else
|
||||
{
|
||||
speed = bot->GetSpeed(MOVE_RUN);
|
||||
speed = backwards ? bot->GetSpeed(MOVE_RUN_BACK) :bot->GetSpeed(MOVE_RUN);
|
||||
}
|
||||
float delay = distance / speed;
|
||||
return delay;
|
||||
@@ -1502,6 +1524,12 @@ void MovementAction::ClearIdleState()
|
||||
|
||||
bool MovementAction::MoveAway(Unit* target, float distance)
|
||||
{
|
||||
// MotionMaster& mm = *bot->GetMotionMaster();
|
||||
// mm.Clear();
|
||||
// mm.MoveBackwards(target, distance);
|
||||
// botAI->SetNextCheckDelay(3000);
|
||||
// // bot->GetSpeed()
|
||||
// return true;
|
||||
if (!target)
|
||||
{
|
||||
return false;
|
||||
@@ -1523,7 +1551,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))
|
||||
if (MoveTo(target->GetMapId(), dx, dy, dz, false, false, true, exact, MovementPriority::MOVEMENT_COMBAT, false, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -1545,7 +1573,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))
|
||||
if (MoveTo(target->GetMapId(), dx, dy, dz, false, false, true, exact, MovementPriority::MOVEMENT_COMBAT, false, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user