Opened 12 years ago

Last modified 5 years ago

#1488 reopened defect

Ranged unit AI should use attack priorities

Reported by: Peter Owned by:
Priority: Should Have Milestone: Backlog
Component: Simulation Keywords:
Cc: Priqvel@… Patch:

Description

While units move they will not care about anything around, they will completly ignore all enemies even if enemies will attack them. And they will not redirect fire from building to attacking enemies.

Change History (6)

comment:1 by Kieran P, 12 years ago

Milestone: Backlog
Resolution: wontfix
Status: newclosed

Prior to Alpha 10, units used to stop and attack anything that attacked it. This caused big problems if you wanted to retreat, because the units would turn right back around and start attacking again. From Alpha 10 onward, units always obey a user given command, so if you task units to walk somewhere, they'll go to that point no matter what (even if they get attacked along the way). Or if you task them to finish a building, they'll finish it before attacking (this helps push to make a tower or something, rather than have your units abandon it).

So this issue isn't actually an issue, but how it's meant to work.

comment:2 by historic_bruno, 12 years ago

Component: Core engineUI & Simulation
Keywords: ui redirect fire removed
Milestone: Backlog
Priority: Release BlockerShould Have
Resolution: wontfix
Status: closedreopened
Summary: AI of unitsRanged unit AI should use attack priorities

I think what Priqvel was saying is that once UnitAI locks onto attacking a certain target (mostly true for ranged units) it won't change, even if there's a better target. A good example is buildings, if you have a bunch of ranged units brought into range of a building they attack it, and they won't stop if attacked by other units. Melee attacks do switch targets by priority unless ordered by the player.

I don't know what the most desired solution is, but at least we should make the distinction in priority between attacking buildings vs units (although most units won't be able to attack buildings anyway once we have capturing).

comment:3 by FeXoR, 12 years ago

The best way to solve this would be a attack move command. If you give a move order units SHOULD ignore attacks. Otherwise fleeing would be impossible.

Another case is what historic_bruno is refering to and he is right while "better target" has to be carefully defined. For me it would be:

  • (1) If enemy that can attack you in your attack range choose the one that would loose most health if attacked by you (and can attack you) until it leaves your range or dies. Then check for a target again.
  • (2) If not (1) do (1) including enemies that can't attack you as long as no unit that can attack you without moving, then skip to 3. (the higher priority in combination with the skip check is to avoid unneeded risk for melee units while they can do damage without much risk).
  • (3) Repeat (1) with attack range replaced with visual range and prefer closer targets. After a short time restart the check at (1) because the situation might have changed after moving.
  • (4) Repeat (3) including enemies that can't attack you. Repeat the check after each attack.

Some other things like the damage "you" gain by other units could be considered (or if you "are safe" at state (3)+ to check if allies inside your visual range are attacked), but the key is to maximize damage dealed in a short time period. For the over all optimization the player has to act - and I don't think it can be determined by the unit AI well.

Some general things (in that order):

  • Don't break a swing/shot if the target is still alive. Apply the command/check for better targets AFTER this single attack (would include a gather animation as well).
  • Prefer user given commands over unit AI.
  • Prefer actually dealing damage over moving if the damaged target can damage you (This is what would be removed by the planed priorising target system I fear).
  • Prefer short ways over efficiency (Do not charge stupidly).
  • Prefer target checks over moving (so recheck while moving with the aim to attack an AI chosen target).
  • Prefer targeting units that can damage you.
  • Prefer targets you damage well (yes, this late! Ranged units will often get to this check).
  • Prefer targets that can deal lots of damage per time to you (will rarely occur since that late in the list).

Ofc. it's always about damage/time but a unit has a fixed attack time despite the target (I hope!) so in most cases can be ignored.

Last edited 12 years ago by FeXoR (previous) (diff)

comment:4 by fatherbushido, 7 years ago

is that fixed?

comment:5 by elexis, 6 years ago

If the player orders a unit to attack a certain target, it shoud follow that order. For instance if you want to kill the enemy hero.

I don't know how unitAI behaves for melee or ranged units if it has picked a certain target on it's own however. That maybe subject to change. It should be well discussed however.

The attack-move order was certainly implemented.

comment:6 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.