mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 13:23:56 -07:00
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:
parent
de5d5f39c4
commit
b1a78ce285
1 changed files with 4 additions and 5 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue