Pathing & Targeting

From Legion TD 2 Wiki
Jump to navigation Jump to search

Pathing

Units attempt to take the shortest route to their destination. In Legion TD 2, the path is usually fairly straightforward since there are generally no walls that block a unit from where it wants to go.

Units steer around obstacles (i.e. other units) by using a flocking algorithm called Boids, which consists of steering, alignment, cohesion, along with goal seeking & obstacle avoidance. Legion TD 2 is configured to prioritize smoothness, even if it means having some units walk through each other sometimes, because this leads to more reliable outcomes in battle.

Targeting

Every unit has an acquisition range and an attack range. The acquisition range is typically a bit higher than the attack range, especially for melee units. The attack range is what you see in-game.

Target acquisition logic is fairly straightforward in the case of single targets:

  1. If a unit has an attack target within range, it will simply attack that target.
  2. If a unit has no targets in range, but has a target is in acquisition range, it will approach that target. Along the way, if the unit finds a better target, it may switch to the new target.
  3. If a unit has no targets in range, and no targets in acquisition range, it will approach its destination (usually the next waypoint on the map).

Breaking Ties

If multiple units are in attack range, ties are broken using the following criteria:

  1. Missing More Health: Pick the target with higher missing flat health
    1. Flat health, rather than percent health, is used to ensure that squishy units aren't prioritized before tanky ones. (Consider a Golem that has taken 100 damage and a Doppelganger that has taken 90 damage. If it percent health was used, the Doppelganger would be mistakenly focused first. )
  2. Closer Position: If we are a ranged unit, pick the target that is closer
    1. This criteria is skipped for melee units, since it isn't meaningful to differentiate between a unit that is, say, 95 range away compared to 99 range.
  3. Further Forward Tower Position: If we are a wave/mercenary attacking a fighter, pick the target whose tower unit was placed further forward in the lane
    1. This means that the Golem you have placed in front of your Doppelganger should tend to be targeted first.

If multiple units are in acquisition range, but not attack range, ties are broken by picking the closest target.

The "no run-around" rule

A unit will never "run around" a valid target in order to reach a preferred target further away. The unit will simply switch to the valid target instead. The system is designed this way to avoid weird looking situations where units dance around each other instead of hitting a target right in front of them.

While intuitive in most situations, the no run-around rule sometimes results in an unexpected outcome.

Consider you have a Golem in front of your Doppelganger. Then you receive a Snail.

  1. The Golem stops to attack the Snail
  2. By the time the Doppelganger reaches the Snail, the Snail is dead, so the Doppelganger keeps walking forward.
  3. The Doppelganger ends up reaching the enemy wave faster than the Golem, since the Golem paused for a moment to hit the Snail.
  4. The enemy wave may prefer to hit the Golem, due to tiebreaks, but it will often switch to the Doppelganger if it can't reach the Golem yet, but it can hit the Doppelganger.
  5. And so, your Doppelganger (tragically) dies before the Golem whom you wanted to tank the wave.

This is a fairly common scenario. To minimize the chances of this happening, position your DPS/carry unit (in this case, Doppelganger) on the side of your lane, while your tank (in this case, Golem) is at least one column towards the center of your lane. This gives your Golem a shorter path to reach the wave, and that is typically enough to ensure it gets targeted first.

(todo: record a video of some different positionings)

Special Cases

Some special cases do exist, such as:

  • Power mercenaries (Brute, Safety Mole, etc.) tend to be targeted later
  • Sea Serpent & Deepcoiler: replaces the Further Forward Tower Position criteria with special values so it isn't targeted too quickly
  • Great Boar & Red Eyes: replaces the Further Forward Tower Position criteria with special values so it is targeted quickly
  • Anything that revives/splits on death: replaces the Further Forward Tower Position criteria with special values so it is targeted quickly

King Targeting

The King has its own unique targeting logic, which is based on the threat level of the target, along with the number of hits it will take the king to kill the target. The king's targeting logic has been polished over many patches, and it performs optimally in almost every situation.