Treat min range in the same manner as max range when computing goal

Problem description:
When unit gets command to move to the range exactly X units from some
point/entity, what means minRange == maxRange, that triggers computing
goal when distance < minRange with result distance(goal, target) >
maxRange, because minRange computation uses clearance even when is
treating target as circle.

Solution:
Do not use clearance when treating target as circle, so computation when
distance < minimum range is done in same way as computation when
distance > maximum range and so computed goal has correct position.

Reported on forum:
https://wildfiregames.com/forum/index.php?/topic/27384-strange-landing-on-the-island-and-unable-to-attack/
Differential Revision: https://code.wildfiregames.com/D2512
Tested by: gameboy
This was SVN commit r23283.
This commit is contained in:
Angen 2019-12-26 21:03:15 +00:00
parent de5d5f39c4
commit b1a78ce285

View file

@ -1320,18 +1320,17 @@ bool CCmpUnitMotion::ComputeGoal(PathGoal& out, const MoveRequest& moveRequest)
// min-range is not 0 and max-range is not infinity.
if (distance < moveRequest.m_MinRange)
{
// Distance checks are nearest edge to nearest edge, so we need to account for our clearance
// and we must make sure diagonals also fit so multiply by slightly more than sqrt(2)
entity_pos_t goalDistance = moveRequest.m_MinRange + m_Clearance * 3 / 2;
if (ShouldTreatTargetAsCircle(moveRequest.m_MinRange, circleRadius))
{
// We are safely away from the obstruction itself if we are away from the circumscribing circle
out.type = PathGoal::INVERTED_CIRCLE;
out.hw = circleRadius + goalDistance;
out.hw = circleRadius + moveRequest.m_MinRange;
}
else
{
// Distance checks are nearest edge to nearest edge, so we need to account for our clearance
// and we must make sure diagonals also fit so multiply by slightly more than sqrt(2)
entity_pos_t goalDistance = moveRequest.m_MinRange + m_Clearance * 3 / 2;
out.type = PathGoal::INVERTED_SQUARE;
out.hw = targetObstruction.hw + goalDistance;
out.hh = targetObstruction.hh + goalDistance;