NPC Combat

Introduction

All combat states described below are entered when an NPC perceives a certain threat and its mental state enters the Danger mode. While in this state, the NPC acts in accordance with rules and scenarios described below.


Initial State

Before switching to the Danger mode, the NPC can be in any of the states listed below. That initial state defines the way the transition to Danger happens (namely, which VO lines and motions will be used in the process).


Danger Mental State

Overview

The Danger mental state means that an NPC’s life is currently threatened, thus throughout all combat activities, all NPCs are in the Danger mental state.

Conditions Of Switching To Danger

  • The NPC can switch to the Danger mode at a scripted signal.
  • The NPC instantly goes into the Danger mode after taking a non-fatal hit from any weapon (or script).
  • The NPC goes into the Danger mode after establishing direct visual contact with an enemy.
  • The NPC goes into the Danger mode after colliding with an enemy (if the player fails at stealth).
  • The NPC goes into the Danger mode once the accumulated visual threat level is high enough (the player is trying to stealth in the view of the NPC with a luminosity index>0.15).
  • The NPC goes into the Danger mode after being hit by a Decoy can.

Danger Mental State Flow


Enter the Danger mode → Combat  → Exit the combat


Entering the Danger mode 

Upon detecting an enemy, the NPC switches to the Danger mode. The transition is accompanied by a corresponding VO comments and animations.

Combat

The main phase this mental state is designed for. The combat itself can be subdivided into 3 types (arranged in the order of priority):

  • Static combat.
  • Cover combat.
  • Common combat.

During combat, the NPC can use these additional combat mechanics:

  • Flanking.
  • Grenade throwing.
  • Suppressing. 
  • Wounded.
  • Surrender.
  • Switching weapons.

Exiting combat

An NPC can exit combat in several cases:

  1. The NPC has killed the enemy (Monster or an NPC enemy).
  2. The NPC has lost sight of the enemy for a long time and downgraded to Uber Alert (Search).
  3. The NPC has received the command to exit combat via a scripted signal.
  4. The NPC died in the combat.

Combat

The NPCs combat priority:

Static → Cover → Common

That is, if static combat is turned off, the NPC will automatically enter cover combat and start checking conditions as well as search for cover. If the conditions are not met or there is no cover to be found, the NPC switch to common combat.

Static Combat

Universal combat.

You set the shooting positions, reload, and that's it. The NPC will try to stand still and shoot. The mechanic is universal but its functionality is minimized for better controllability and simplicity.

Cover-Based Combat

This type of combat is next in the order of priority after the Static one and, if static combat is disabled, the NPC will, after its initial reaction to the enemy, employ this type of combat.

In this type of Combat, NPCs use cover of the "human combat" type.

Cover Combat Conditions

In order for an NPC to use a particular combat cover, several conditions must be met:

  • The combat cover must be on the same AI map as the NPC.
  • The cover should be directed at the enemy.
  • There must be free cover with suitable weight.
  • The distance between the NPC and the enemy is more than eight meters (> 8m).

Вес Combat Cover

This formula considers many factors that influence the choice of a suitable cover. Some of these factors are of critical importance:

Recalculating Weights

  • While combat is ongoing, the weights of a cover within 50 meters are recalculated every 3-6 seconds.
  • Every time the NPC takes a hit, the weights of a cover are recalculated.
  • When a cover’s weight decreases by 10000 conventional units, the weights of a cover are recalculated.
  1. The distance from the Cover to the Enemy  3 meters. If the enemy is located within a radius of 3 meters from the cover when recalculating the weights, the cover takes a large penalty and is ignored by the NPC. 
  2. The combat cover has a clear direction. If the angle between the direction of the cover and the location of the enemy reaches 35 degrees, the cover takes a large penalty and is ignored by the NPC.
  3. The maximum distance between the cover and the NPC can also greatly affect the weight of the cover. Depending on the "role" of the NPC, this distance varies from 10 to 25 meters. If the distance exceeds the maximum allowed value, the cover takes a large penalty and is ignored by the NPC.
  4. The cover always considers the direction the enemy is facing. If the cover looks the wrong way, it is automatically ignored by the NPC.

 !!! Verbose formula description

The settings for cover finding are stored in config.lua behaviour_type

Depending on the type of behavior, the NPC will use the corresponding parameters to calculate the weight of the cover:

  • ["assault"]
  • ["ranged_assault"]
  • ["support"]    
  • ["suppress_assault"]
  • ["storm_trooper"]
  • ["wounded"]    
  • ["uber_alert_search"]
  • ["hide"]
  • ["stealth"]
  • ["ranged_support"]


The weight of the cover is calculated with this formula:

result = general + effectiveness + protection + movement


1. general  general penalty

- If the distance from the cover to the enemy is closer than enemy_is_in_cover_distance, then general  enemy_is_in_cover.

- If another NPC from the same group is in a cover closer to the target than member_cover_distance and can block the current NPC's cover, then general  friendly_cover_is_too_close (turned off).

- If the cover is in a dangerous area, then general  penalty. Dangerous areas are defined as those where NPCs from the same group have been hit (penalty = 1000) or where other NPCs' corpses are located (penalty = 10000). The penalty value decreases over time and with the distance to the zone.

- If the player can see the cover then general  cover_visible_penalty.


2. effectiveness  effectiveness penalty (like effective distance and fire point openness)

If the distance from the cover to the enemy is within the min_effective_dist - max_effective_dist range, the cover is deemed to be within the effective distance.

For each permitted cover position, a penalty value is calculated that measures how difficult it is to attack the enemy from this position (from 0 - convenient to 1 - inconvenient) and multiplied by direction_of_fire_is_closed_effective, if the cover is at an effective distance, and direction_of_fire_is_closed, if not.

If there are obstacles on the AI map (putting holes in the AI map) between the cover and the enemy’s position, then the line_of_fire_is_invalid_effective penalty is added, if the cover is at an effective distance, and line_of_fire_is_invalid, if not. The negative value of this penalty denotes the effectiveness of the position.

If the max_schema parameter is not 0, then the maximum position efficiency is taken as the cover efficiency.

If the max_schema parameter = 0, the effectiveness of the cover is defined as the mean of the efficiency of the allowed positions.


In addition to this:

- If the distance from the cover to the enemy is less than min_effective_dist, then effectiveness ≤ cover_is_close_than_effective_dist.

- If the distance from the cover to the enemy is greater than max_effective_dist, then effectiveness  cover_is_further_than_effective_dist.


Also:

- Effectiveness  (c2e_dist - max_effective_dist) * cover_to_effective_dist_penalty, where c2e_dist is the distance from the cover to the enemy.


3. protection  protection degree of cover

c2e_dot  cosine of the angle between the direction of the cover and the direction from the cover toward the enemy.

- If c2e_dot> = cover_direction_border_nopenalty, then the penalty is not calculated and protection = 0.

- Otherwise, if c2e_dot> = 0, then protection - = params.cover_direction_penalty * (1.f - c2e_dot).

- if c2e_dot <0, then protection - = 2 * cover_direction_penalty * (1 - c2e_dot).


4. movement  movement related penalties (distance, convenience to move)

s2c_pe  distance from an NPC to a cover.

dir_dot  cosine of the angle between the direction from the NPC to the enemy and from the NPC to the cover. If s2c_pe <min_cover_dist, then movement - = cover_is_close_than_move_dist.

- If min_cover_dist <= s2c_pe && s2c_pe <= max_cover_dist, then movement - = (s2c_pe - min_cover_dist) * self_to_cover_move_penalty.

- If max_cover_dist <s2c_pe, then movement - = cover_is_further_than_move_dist.

- If the angle between the direction to the cover and the direction of the NPC is more than 45 degrees, then the movement -= no_direct_path_penalty.

- If dir_dot> walk_through_enemy_dot and the enemy is closer than the cover, then the movement -= walk_through_enemy_penalty (the NPC will run past the enemy on the way to the cover).

If the NPC does not find a suitable cover or the enemy comes too close, the NPC switches to Common combat.

Cover Combat Activities

Search for a cover → Move to the cover → Enter the cover → Peek out → Get scared / hide → Shooting → Cover change.

Common Combat

The third type of combat has the lowest priority after the Static and Cover options.

It is used by NPCs, if there is no suitable combat cover around, or if the enemy is at a distance that precludes the usage of cover-based combat.

Common Combat Conditions

In order for an NPC to use Common combat, several conditions must be met:

  • As a result of activating the script, the NPC has cover combat disabled.
  • The NPC has not found any combat cover on its AI map.
  • The combat cover is found but it is located further than the maximum distance to the cover set in its "role" (combat preset).
  • The combat cover is found but it is not aimed at the threat.
  • The combat cover is found but its weight is unsuitable.
  • The distance between the NPC and the enemy is less than/equal to eight meters ( 8m).

While in the Common combat state, the checks for the possibility of reverting to Cover combat will continue at all times!

Reverting from Common to Cover combat

Conditions under which the NPC switches from Common to Cover combat:

  • A script enables Cover combat for the NPC.
  • As a result of a routine check, the NPC has found cover with a suitable weight.
  • The distance between the NPC and the enemy has become more than 12 meters (> 12m).

Common Combat Activities

Squat → Dodge → Sprint → Flip → Approaching enemy → Jumping to retreat → Melee Attack.


Additional Combat Mechanics

  • Flanking.
  • Grenade throwing.
  • Suppressing. 
  • Wounded.
  • Surrender.
  • Switching weapons.

Flanking

A prerequisite for the activation of this mechanic is the presence of at least two NPCs, i.e. a group. Thus, the impression should be that the first NPC distracts the player while the second one flanks the player.

Grenade Throwing

This allows an NPC to throw a fastdrop item. The NPC can throw either a Grenade or a Molotov. The number of fast drops an NPC carries is always strictly limited and cannot be infinite.

In addition to the NPC settings, the map where the fight takes place must includes special fastdrop item covers which should be connected by links indicating the direction of the fastdrop item to be thrown in. There are 2 types of fastdrop item throw covers:

  • Grenade target.
  • Grenade source.

The Grenade target cover by its name indicates that the NPC's fastdrops are supposed to be thrown in its direction. It should be connected by a link, as a target, with a regular combat cover. If the combat cover is not present on the map for this mechanic to work, then the map must have a Grenade source cover connected by a link with the target. The cover has a radius. If an enemy (player) enters it, the NPC tries to throw a fast drop item.

Grenade source is a cover that is placed on the AI map when the map lacks combat covers and the NPCs need to throw a fastdrop item. A link to the Grenade target cover must originate from this cover.

Suppressing 

This mechanic allows the player to “suppress” the NPC in a cover, make the player sit down and stop peeking for some time. It is activated, if the player accurately shoots at a cover where the NPC is hiding.

Wounded

As a result of combat, an NPC can get critically wounded which activates this special mechanics. Essentially, upon taking a grievous wound, the NPC starts re-evaluating cover, looking for one within 10 meters of the NPC's current position where the NPC can retreat to and lie down or die. If no such cover is found, then the NPC either immediately dies or lies down. In this animated state, the NPC can continue firing at the enemy and can move slowly.

Upon transitioning into the Wounded state, a timer starts (1 minute) and once that elapses, the NPC dies loudly from blood loss. If the player approaches within 5 meters, the NPC dies within 2-3 seconds.

Surrender

This mechanic in the game is present in 2 forms.

  • Scripted surrender (e.g. The Church on the Bridge level).
  • Universal surrender.

The Universal surrender mechanic is activated if, during combat, the player kills all but one NPC, making the last one surrender. During surrender, the NPC says “don't shoot, you won”, and raise their arms.

If the player does not see the NPC surrender, then the NPC will stand there for a while until:

  • surrender is deactivated with a script.
  • returns to the free mode (upon the player's exit of the playing area).
  • a monster/enemy enters the zone.
  • or until the player finds the NPC.

If the player sees the surrender, the NPC lowers the weapon and kneels. Once the NPC puts the weapon on the ground, the NPC will not be able to return to combat or free mode again.

If the player accidentally/intentionally hits the NPC, the NPC will comment on the attack.

Switching Weapons

Some NPCs, depending on their combat role, have two weapons.

  1. Sniper  long range weapon / close range weapon.
  2. Cannibal  ranged weapon / melee weapon.
  3. Forest Child  Helsing / Melee weapon.

The weapon swap is activated by a script or by the player approaching the NPC at the distance of 10-12 meters.

On this page:


Exodus SDK © 2005-2023, 4A Games Limited. Developed by 4A Games®.
4A Games® is a registered trademark, and 4A Games Limited, Exodus SDK and their respective logos are trademarks of 4A Games Limited.
Published by Deep Silver. Deep Silver is a division of PLAION GmbH, Austria. Deep Silver and Plaion are registered trademarks of PLAION GmbH.
Metro Exodus is inspired by the internationally best-selling novels METRO 2033 and METRO 2034 by Dmitry Glukhovsky.
All other trademarks, logos and copyrights are property of their respective owners. All rights reserved.
By using this site, downloading or using the Exodus SDK or related content, you are agreeing to be bound by the terms of the End User License Agreement.


EULA