[Movement] Modify combat reach calculation

This commit is contained in:
Yunfan Li
2024-10-04 01:50:38 +08:00
parent 55cd5ab923
commit ff68a92fe9

View File

@@ -827,11 +827,12 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
float shortenTo = distance;
// Avoid walking too far when moving towards each other
if (bot->GetDistance(tx, ty, tz) >= 10.0f)
shortenTo = std::max(distance, bot->GetDistance(tx, ty, tz) / 2);
float disToGo = bot->GetExactDist(tx, ty, tz) - distance;
if (disToGo >= 10.0f)
shortenTo = disToGo / 2 + distance;
if (bot->GetExactDist(tx, ty, tz) <= shortenTo)
return false;
// if (bot->GetExactDist(tx, ty, tz) <= shortenTo)
// return false;
path.ShortenPathUntilDist(G3D::Vector3(tx, ty, tz), shortenTo);
G3D::Vector3 endPos = path.GetPath().back();
@@ -2313,7 +2314,7 @@ bool TankFaceAction::Execute(Event event)
if (!bot->GetGroup())
return false;
if (!bot->IsWithinMeleeRange(target))
if (!bot->IsWithinMeleeRange(target) || target->isMoving())
return false;
if (!AI_VALUE2(bool, "has aggro", "current target"))
@@ -2513,7 +2514,7 @@ bool SetBehindTargetAction::Execute(Event event)
if (target->GetVictim() == bot)
return false;
if (!bot->IsWithinMeleeRange(target))
if (!bot->IsWithinMeleeRange(target) || target->isMoving())
return false;
float deltaAngle = Position::NormalizeOrientation(target->GetOrientation() - target->GetAngle(bot));