Enemy AI routines

; Exploring Task Force, a disassembly project

The following is a desecription of the enemy’s decision-making process.

  1. Overview
  2. Activation
  3. Moving
  4. Shooting

Overview

Enemies are of five types, detailed in the combat mechanics article, which determines their weapon loadout, but not their stats. If they have a grenade, they have a 2/3 chance to fire it at a target exactly 5 squares away (adjacent square counts as 0 squares away). Otherwise, They always use the longest range weapon and have a 25% chance to fire, unless they’re in Sentry Mode.

Enemies have stats like players do, which determines their Combat Skill, Mobility, etc. They also have an Alertness range of between 3 and 12, within which they will notice; and an Initiative stat, which determines their aggression: whether they will remain still in Sentry Mode (and not fire), run away in a random direction, move toward an ally, or move toward their target. Those stats are higher on higher difficulties.

Activation

Each round, a directional flag is set to either 0 or -1 (50% chance of each). It toggles each step an enemy moves.

Each enemy is handled in order they were added to the map at the start of the mission. This occurs one row at a time, from left to right. This means that the soldier on the left will move before the soldier on the right, and both will move below the soldier further south.

Each enemy then checks against each of the five squad members in order. The range is calculated by adding the difference in both X and Y coordinates with that squad member, minus one. For example, an enemy adjacent to you has a distance of 0.

This distance is compared to the enemy’s an Alertness stat, randomly generated for each soldier at mission start. It is between 3 and 12, with a modifier for the current difficulty setting (Easy -1, Normal +0, Hard +1, Mega +2). If the soldier’s Alertness stat is equal to or greater than the range, the soldier moves.

Each soldier has an Initiative stat which determines how brave they are. It is randomly generated for each enemy and ranges from 1 to 8, tending toward, plus difficulty modifier; it can occasionally be as low as 0 on Easy or 10 on Mega. Initiative is checked when a soldier moves, and determines their actions.

When checked, Initiative is read and modified by a random number from -1 to 2, then halved (rounded down), then logically anded with 3 to give a number from 0 to 3, determining their action:

Higher Initiative stat tends toward higher results; however, a result of 8 loops around to 0 again (e.g. Initiative 6, roll of 2, normal difficulty) and a result of -1 loops around to 3 (e.g. Initiative 1 or 2, -1 roll, -1 easy mode).

Moving

If the enemy spots multiple squad members, it appears that it will check for each of them and set the last one as its target. This means it should prefer to move toward the green-haired squad member above other members.

Once the target is selected, unless the enemy is on sentry mode, it moves toward the enemy. Like players, the enemy is limited by its Mobility stat, ranging from 2 to 7 (and the difficulty modifier of -1 to +2).

Shooting

Each enemy then checks for the nearest squad member to get its range.

If they are exactly 5 squares away, they may throw a grenade, if they have one. There is a 2/3 chance they will do so. Grenades are used up when fired. Note that adjacent counts as zero range. For example, three left and three down counts as five.

If a grenade is not selected, they will select their longest range non-grenade weapon. If the target is within range, they have a 3/4 chance to fire. It uses the standard combat calculation mentioned in combat mechanics.

Enemy bazookas start with 3 as normal. It appears that they only fire directly at targets, which gives an advantage to the player, who can land a bazooka one square away and kill the enemy with the blast radius.

See “enemy types” under combat mechanics for weapon loadout. The rule about enemies using their most long-range weapon, if I have interpreted it correctly, only comes into play when they have multiple non-grenade weapons, which can only occur in two circumstances:


« Back to index page