mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-06-20 15:39:25 +02:00
fix(Core/Movement): ChaseTo tries mmap path before MoveChase
This commit is contained in:
parent
f656c3d9ef
commit
ec6e412f35
@ -1423,9 +1423,7 @@ bool MovementAction::Follow(Unit* target, float distance, float angle)
|
|||||||
bool MovementAction::ChaseTo(WorldObject* obj, float distance)
|
bool MovementAction::ChaseTo(WorldObject* obj, float distance)
|
||||||
{
|
{
|
||||||
if (!IsMovingAllowed())
|
if (!IsMovingAllowed())
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (obj)
|
if (obj)
|
||||||
EmitDebugMove("ChaseTo", "chase", obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ());
|
EmitDebugMove("ChaseTo", "chase", obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ());
|
||||||
@ -1435,8 +1433,6 @@ bool MovementAction::ChaseTo(WorldObject* obj, float distance)
|
|||||||
VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(bot);
|
VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(bot);
|
||||||
if (!seat || !seat->CanControl())
|
if (!seat || !seat->CanControl())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// vehicle->GetMotionMaster()->Clear();
|
|
||||||
vehicle->GetBase()->GetMotionMaster()->MoveChase((Unit*)obj, 30.0f);
|
vehicle->GetBase()->GetMotionMaster()->MoveChase((Unit*)obj, 30.0f);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1452,10 +1448,34 @@ bool MovementAction::ChaseTo(WorldObject* obj, float distance)
|
|||||||
botAI->InterruptSpell();
|
botAI->InterruptSpell();
|
||||||
}
|
}
|
||||||
|
|
||||||
// bot->GetMotionMaster()->Clear();
|
// Try a chained mmap probe first — for targets behind obstacles
|
||||||
bot->GetMotionMaster()->MoveChase((Unit*)obj, distance);
|
// this routes the bot around terrain instead of straight-charging
|
||||||
|
// into a wall. Falls back to engine MoveChase for short/clear
|
||||||
|
// chases where target tracking matters more than path routing.
|
||||||
|
float const targetDist = bot->GetExactDist(obj);
|
||||||
|
if (targetDist > distance + 3.0f)
|
||||||
|
{
|
||||||
|
float const angle = obj->GetAngle(bot);
|
||||||
|
float x = obj->GetPositionX();
|
||||||
|
float y = obj->GetPositionY();
|
||||||
|
float z = obj->GetPositionZ();
|
||||||
|
obj->GetNearPoint(bot, x, y, z, bot->GetObjectSize(), distance, angle);
|
||||||
|
|
||||||
// TODO shouldnt this use "last movement" value?
|
PathGenerator path(bot);
|
||||||
|
path.CalculatePath(x, y, z, false);
|
||||||
|
PathType type = path.GetPathType();
|
||||||
|
if ((type & (PATHFIND_NORMAL | PATHFIND_INCOMPLETE | PATHFIND_SHORTCUT)) &&
|
||||||
|
path.GetPath().size() >= 2)
|
||||||
|
{
|
||||||
|
Movement::PointsArray points = path.GetPath();
|
||||||
|
bot->GetMotionMaster()->Clear();
|
||||||
|
bot->GetMotionMaster()->MoveSplinePath(&points, FORCED_MOVEMENT_RUN);
|
||||||
|
WaitForReach(targetDist - distance);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bot->GetMotionMaster()->MoveChase((Unit*)obj, distance);
|
||||||
WaitForReach(bot->GetExactDist2d(obj) - distance);
|
WaitForReach(bot->GetExactDist2d(obj) - distance);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user