From ff68a92fe944210e82196d571299a1f2b52954ef Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Fri, 4 Oct 2024 01:50:38 +0800 Subject: [PATCH] [Movement] Modify combat reach calculation --- src/strategy/actions/MovementActions.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/strategy/actions/MovementActions.cpp b/src/strategy/actions/MovementActions.cpp index e07fc79a..569d7fcc 100644 --- a/src/strategy/actions/MovementActions.cpp +++ b/src/strategy/actions/MovementActions.cpp @@ -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));