Reinforcements

Reinforcements are units that are deployed onto the map after the battle begins, unlike starting units. Both the ally and the enemy team can deploy reinforcements, but depends on the map. Currently, the only maps in which ally reinforcements can be deployed are the ones used in Rival Domains and Grand Conquest. Enemies also deploy reinforcements on those maps in addition to certain Story, Paralogue, and Special maps.

Reinforcements may appear as early as Turn 1, depending on the conditions of the map. Reinforcements for a side are always deployed at the end of their respective turns; allied reinforcements will be deployed at the end of the player phase, while enemy reinforcements will be deployed at the end of the enemy phase. Reinforcements that are not currently deployed do not count toward a map's win condition of defeating all enemies. This means that it is entirely possible to avoid certain reinforcements from appearing at all by either beating the map quickly enough or by saving certain enemies for last.

Reinforcements do not gain boosts from Legendary Effects.

Deploy triggers
Foes from a map may be separated into initial units or reinforcements. At the end of each enemy phase, the game iterates through the list of reinforcement entries, checks if each entry satisfies all of the following requirements, and spawns a foe in that case:


 * Spawn location: The map must contain a free space for the reinforcement to spawn (see Spawn location below).
 * Spawn count: Each reinforcement entry spawns the same unit for a fixed number of times. Most entries only spawn 1 unit, but some may spawn as many as 3. One unit is spawned on each turn per entry until the maximum amount of spawns is reached.
 * Spawn turn: Reinforcements may have to wait for a number of turns before any unit can be spawned.
 * Alive target: A reinforcement entry is allowed to check the number of units with a given name that are alive by the end of each enemy phase, and spawn a foe only if units with that name are not present at all. In particular, an entry may check for the existence of the same unit it spawns; in this case, both initial enemies and reinforcements with this unit's name must be killed in order for new reinforcements to spawn.
 * Kill target: Similarly, a reinforcement entry may check the number of units with a given name that have been killed by the end of each enemy phase, and spawn a foe only if that kill count exceeds a given value. A reinforcement entry may only specify either an alive target or a kill target, never both at the same time. If multiple entries share the same target but have different kill counts, and more than one target unit is killed on the same turn, then both entries will spawn their enemies simultaneously, for example in Legion: Masked Maniac (map).

There are currently three trigger mechanisms for causing reinforcements to be deployed: turn-based, kill-based, and spawn-based. Turn-based reinforcements will be deployed at the end of a designated turn, which varies based on map. Kill-based reinforcements will be deployed at the end of a turn after a specific unit is killed. Spawn-based reinforcements will be deployed as long as certain spawn tiles are not blocked and deploying those units would not exceed the maximum for the map. Spawn-based reinforcements cycle through a brigade of 20 different units. If a specific unit is already deployed, it will be skipped as a reinforcement until the currently deployed one dies.

Rival Domains and Grand Conquest are the only modes to use spawn-based reinforcements, with the spawn tiles being the cluster of warp tiles centered on the primary fort. Most other reinforcement maps use turn-based triggers, while some use kill-based reinforcements or a combination of both turn-based and kill-based triggers.

Slot order
The slot index is a unique integer value assigned to each unit, which increases by 1 for each unit spawned, including initial units. Reinforcements always have greater slot indices than units that have appeared before them; among reinforcements spawned on the same turn, units defined later in the map files have greater slot indices than units defined earlier. Killing a unit does not free up its slot index; newer reinforcements, including those from the same reinforcement entry, will occupy new slot indices. For instance, if there are 4 starting enemy units and a reinforcement appears on Turn 2, that reinforcement will be in the 5th slot. Player units also have slot indices which are defined according to their team/brigade's unit order.

Arena and Rival Domains maps place their initial units according to the slot indices of both teams and the internal order of the initial spawn positions. The slot index is also the final tiebreaker for several AI actions; therefore, the relative slot order between units spawned together can be determined empirically, without reading the map files.

If there are multiple reinforcements that would be deployed in the same turn, if they share same trigger (for example, two reinforcements that appear on Turn 2, or two reinforcements from killing Legion), then they will have a pre-determined arbitrary slot order based on the map. If they do not share the same trigger (for example, one reinforcement comes from killing a red mage, while another comes from killing a blue mage), then their slot order depends on their respective deploy mechanisms. If two reinforcements result from two different kill triggers like in the previous example, then their slot order is respective to the slot order of their kill trigger targets. If two reinforcements result from a kill trigger and a turn-based trigger, then the reinforcement resulting from the kill trigger will take precedence over the turn-based one for slot order.

Deploy location
When a unit is considered for spawning, its designated cell might be occupied and the game has to search for a free cell to place the unit. This is done by ordering all cells on the map that are unoccupied by units, as shown below:


 * 1) Cells accessible by the unit's move type have higher priority over inaccessible cells. Among these (in)accessible cells,
 * 2) Cells with the shortest distance to the spawn position are considered first. Distance is calculated as the number of spaces between the cell under consideration and the spawn position, ignoring terrain movement costs; unreachable cells due to inaccessible terrain are all considered to have positive infinite distance. Among these cells with the same distance,
 * 3) Cells closer to the top have higher priority over cells closer to the bottom. Among cells on the same row,
 * 4) Cells closer to the right have higher priority over cells to the left.

The cell with the highest priority is then used to spawn the unit. In most cases the spawn position is unoccupied, and the search stops at step 2. Each reinforcement entry finishes spawning before the next entry checks for an unoccupied cell. If all cells are occupied (which does not occur through normal gameplay), the unit is not spawned and waits until any cell is unoccupied at the end of an enemy phase.

If multiple reinforcements use the same tile for deployment and both were triggered for the same turn's deployment, the one with the lower slot number takes priority. The others go through the process outlined above as if the space was already occupied. This means that if there is a kill-based reinforcement as well a turn-based reinforcement to deploy on the same tile, the kill-based reinforcement will use that tile while the turn-based one will deploy nearby.

For spawn-based deployment, each spawn tile has a priority number, and a reinforcement with the lower slot number will spawn in the tile with the lower number. If a tile is blocked, reinforcements will not spawn on that tile. If a reinforcement would exceed the deployment limit for its team, that reinforcement will not spawn until at least 1 unit on that team dies.

If a reinforcement is set to spawn on a player's starting position space, the reinforcement will instead spawn in the closest available space.

Trivia

 * It was previously possible for reinforcements to spawn on a starting space, resulting in two units occupying the same space if the player deployed again while a reinforcement was present in that space (such as during chain challenges), but this glitch was fixed in an update.