Opened 7 years ago

Last modified 5 years ago

#4725 new defect

Issues with Unit AI and ranged units

Reported by: temple Owned by:
Priority: Should Have Milestone: Backlog
Component: Simulation Keywords:
Cc: Patch:

Description

There's a number of problems with Unit AI and ranged units. Here's a list of some of them.

  1. The general issue is that the range query doesn't always coincide with the units we want to consider. So either targets aren't considered even though we can attack them, or targets are considered even though we can't attack them.
  1. If we're idle, there's a los range update that lets us consider new targets. In the second case of (1), we consider some targets but can't attack them right now, so we ignore them. Later they walk closer and we should be able to attack them, but there isn't a los range update that tells us that, so instead we remain idle.
  1. Ranged units use parabolic range tests within Unit AI, but they use the regular (not parabolic) query of Range Manager. So if the ranged unit is on a hill, there can be targets that they should be able to attack but which are outside their normal range, so they aren't found by the query. And if the ranged unit is in a valley, then there can be targets that are within their normal range, but which they can't actually hit. If they're in the standground stance, then this is the situation in (2) and they won't respond when the unit later comes into parabolic range.
  1. Vision uses the regular range, which means that it's possible to have the parabolic attack range greater than the vision range. (Building AI uses a parabolic query, plus towers have an elevation bonus, so on flat ground towers can attack beyond their vision range as long as some other unit can see the target.) This will cause some problems like (2) if we change to a parabolic query to fix (3), because we can find targets that we can't see and so won't attack, although we'll want to attack them later when they get closer.
  1. In the violent and aggressive stances we want to search our visual range to chase after targets, so we shouldn't use a parabolic query. In the defensive stance (hold ground) we want to attack a target if we can reach them from within a circle of radius vision/2 around the held position. It's not clear how to correctly search for targets in this case.
  1. Ignoring parabolic range, there's a problem with defensive stance and units with long range. The current regular query is for vision/2 + range, and if this is larger than vision (i.e., if range > vision/2) then we're in the second half of (1) again, where units are considered and then ignored even if they come closer. I think min(vision/2 + range, vision) would work better for the query (I haven't tested it), but because the query uses the unit's position and our circle is around the held position, I think this still won't be completely accurate. And of course adding in parabolic range makes it even messier.

There may be some extra issues with pack/unpacking, see #4359 (#2802). And #4028 has concerns about moving to the correct range. There could be other related tickets, too.

There was some discussion about line of sight in the original thread about parabolic range.

Change History (8)

comment:1 by Imarok, 6 years ago

Just to add it somewhere:

There may be a use case for units with higher attack range than vision range, that can attack anything in the players LOS:

With that these units would need other units providing them sight on the battleground. (This was also discussed somewhere in the staff forums)

comment:2 by elexis, 6 years ago

Is this really a use case? It seems both unreasonable in reality and ingame to me. If someone can aim at something he doesn't see (guesstimate), then it should also be possible if there is no vision range at all (but we don't want that afaik).

in reply to:  2 comment:3 by Imarok, 6 years ago

Replying to elexis:

Is this really a use case? It seems both unreasonable in reality and ingame to me. If someone can aim at something he doesn't see (guesstimate), then it should also be possible if there is no vision range at all (but we don't want that afaik).

I don't know, I just remember someone planned that some time ago in the staff forums, so I thought I'd mention it here...

comment:4 by Stan, 6 years ago

From a modding pic it could be nice for cannons with a fun system of spies.

comment:5 by mimo, 6 years ago

having no attack range bigger that vision range is a choice (valid for vanilla 0ad) that should be done through templates but not be imposed code-wise as any mod with later time-frame would like to have artillery for example.

comment:6 by temple, 6 years ago

In 21584:

Don't exceed vision range in hold ground and stand ground query ranges

Differential Revision: https://code.wildfiregames.com/D1394
Reviewed by: bb
Comments by: elexis
Refs: #4725

comment:7 by temple, 6 years ago

(Units can still attack outside their vision range, they just won't tryt to do it on their own.)

Last edited 6 years ago by temple (previous) (diff)

comment:8 by Imarok, 5 years ago

Component: UI & SimulationSimulation

Move tickets to Simulation as UI & Simulation got some sub components.

Note: See TracTickets for help on using tickets.