AI Learning: CombineSoldier

From Valve Developer Community
Jump to: navigation, search
English (en)Español (es)
... Icon-Important.png
Npc combine s.jpg
Category:AI

Combine Soldiers

Combine Soldiers are regularly seen throughout the Half-Life 2 series, there are four variations, including the "Regular", "Elite", "Prison Guard" and "Shotgunner".

They often work in squads together and flank the player by spreading around and using frag grenades.

Squad Interactions

Squad slots are the way squad-based npcs operate. They allow npcs to trade roles and take turns. An npc will typically hold a squad slot for the duration of a Schedule.

Combine squads have 6 primary squad slots: SQUAD_SLOT_ATTACK1, SQUAD_SLOT_ATTACK2, SQUAD_SLOT_ATTACK_OCCLUDER, SQUAD_SLOT_GRENADE1, SQUAD_SLOT_OVERWATCH, and SQUAD_SLOT_SPECIAL_ATTACK.

  • SQUAD_SLOT_ATTACK1 and SQUAD_SLOT_ATTACK2 are the slots soldiers must have to be able to shoot at an enemy or advance in most cases. Over longer distances soldiers will advance regardless of squad slots, and soldiers can lose their attack slot while moving and shooting. This is intended behavior, but can cause problems in expansive tight environments.
  • SQUAD_SLOT_ATTACK_OCCLUDER is the slot a soldier occupies when shooting out an opponent's cover. They do this to breakable objects they can see through, such as prop_physics held by the Gravity Gun or windows.
  • SQUAD_SLOT_OVERWATCH is a strange squad slot that rarely comes into effect. It seems that it only applies to squad leaders. After reading comments inside the Half-Life 2 source files, the use of the Overwatch slot comes to light. It is used to for advanced AI techniques, such as providing covering fire when teammates reload or sitting and aiming at a player's last visible location. For more information, 🖿npc_combine.cpp has good notes.
  • SQUAD_SLOT_GRENADE1 and SQUAD_SLOT_SPECIAL_ATTACK are used by soldiers to throw grenades or launch energy balls. For difficulty reasons, whenever these slots are used they'll stop the entire squad from committing similar attacks for a period of time.

If a soldier is not using a squad slot they'll take cover.

Worthy to note is that squad slots are handled per enemy. This means a squad could potentially split up and attack different targets, but this all depends on who each squad member is prioritizing (which is influenced by distance, ai_relationship strength, enemy filters, and who/what attacked the NPC last).

Squad slots can also be exchanged rapidly. For example, soldiers on an assault might exchange attack slots rapidly to keep a constant stream of fire at an opponent.

Understanding squad slots is useful to know when setting up combat encounters. For example, a level designer might want a group of soldiers on a roof to shoot and throw grenades independent of soldiers on the ground (be mindful of friendly fire).

Weapon Interactions

Combine soldiers have a variety of weapons, each filling out a certain role and having a different effect on the AI

AR2

  • Accuracy cone when used by soldiers:
    • 5 degrees (Episodic)/ 9 degrees (Half-Life 2)
  • The AR2 has a far AI engagement range, so these soldiers tend to keep their distance.

SMG

  • Accuracy cone when used by soldiers:
    • 16.6 degrees
  • Smg soldiers are the most inaccurate of all the combine forces and tend to engage at a medium distance. They are used often by Valve because they act almost like "meat shields" for the deadlier combine, causing the player to choose between targets of opportunity.

Shotgun

  • Accuracy cone when used by soldiers:
    • 10 degrees (the same as the player)
  • The Shotgun has a really short AI engagement range, so this triggers slightly different behavior in the soldier AI. They'll charge straight at an opponent regardless of the damage they're taking. They can deal a lot of damage and fill a role similar to a melee unit.


Soldiers also have several different reactions when engaged with certain weapons. If hit by the .357, AR2, or half the pellets from the Shotgun, their AI will consider it Heavy Damage. This typically means they'll stop shooting or flanking and play a dramatic flinch animation (this is slightly different for shotgunners). This is useful to understand when considering the player's arsenal at certain points in a level.

Design Philosophy

A good way to understand some of the decisions that went into the design of the Combine Soldier is by looking at the other "military" AI: HL1 Grunts, Metrocops, and Previous iterations.

Valve knew about the reputation their soldiers had in the original Half-Life, and they wanted to expand on this. Interestingly, a lot of the code in the Combine Soldier is directly copy-pasted from the human grunt, which explains why there appears to be a lot of unnecessary bits of code, since the Combine Soldier must have been worked on since the beginning of HL2's development.

Take a look at the Combine Elite; the normal soldiers has 50 health, while the Elite has 70. Why? An enemy with the exact same AI, but different health. There is no other comparison to this in any of HL's enemies. This must mean health plays a vital role in their design. Throw in the SMG soldier's horrible inaccuracy, and a picture forms. The Human Grunts could take and deal a lot of damage if not handled quickly or carefully, this made them bad "filler" enemies. That enemy that draws the player's attention upward suddenly becomes all they focus on. So Valve nerfed their damage output and quickened their response. Now the focus is more on the squad, and less on the individual squad member. Throw in the source engine's ability to allow the AI to do more than take cover and run at an enemy, and now you have a coordinated group of enemies that can intelligently flank the player and cover each other.

Valve probably liked the AR2 and SMG combat variety, but it probably became boring after awhile. This article mentions how a game development team added an enemy that charged the player at last minute to add more fun to a firefight. Valve probably had similar reasons behind the development of the Shotgunner AI. Similar to melee enemies like the fast zombie, The shotgunner will charge the player, forcing them to retreat or risk losing a lot of health. This was probably happening around the same time the gesture system came online, allowing enemies to move and shoot at the same time. Now the combine can shoot while flanking, instead of having to stop and standstill while shooting like the Human Grunt. Thus creating the Blitzkrieg style Combine Soldier of today. This might also explain why the wide open engagement areas of Highway 17 are the soldier's "premiere level", similar to how the storage rooms of "We've Got Hostiles!" are the "premiere level" of the Human Grunt.

The Metrocops inherited the Human Grunt's defensiveness, while the Combine Soldier inherited their aggresiveness: encouraging the run and gun gameplay that is the foundation of Half-Life.

Rappeling notes

Combine soldiers are able to rappel as metrocops do, but in a more advanced way, use scripted sequences to play them. Check the Useful Links section to read a tutorial in Interlopers.net Extra animations and their height in Source Engine units:

   * rappel_a - 648
   * rappel_b - 480
   * rappel_c - 456
   * rappel_d - 552
   * rappel_e - 384
   * rappel_f - 480

Useful Links