NPC Mental States

Introduction

Description of NPC behavior in a group or when single in all mental states (except for danger).


Disturbed

The NPC plays VO lines to report this state. No specific behavior is required and it’s best not to interrupt free behavior in this case.


Light Alert

Overview

The main point of this state is to examine the threat source.

Additional points:

  • If several NPCs share the same threat source, they turn to group behavior when checking it out – i.e. wait until one of them examines the threat.
  • If the threat source is not visible due to geometry or large objects in the way, then the NPC will try to find a place from where they can see the threat.
  • The NPC must not stare into a wall when examining the threat.

General Flow Of the State:

Flow for the whole AI group.

Identifying Threat → Distributing Roles → Acting Out the Roles

Identifying Threat

  • Threat position is evaluated.
  • A group of NPCs that share the same threat is formed. These are NPCs that are in the same AI group, in the light alert state and have the same threat (threat with the same source). Referred to as LA (Light Alert) group below.

Distributing roles

  • The NPC in the LA group that is the closest to the threat and can see it (raypick) is selected. The NPC is assigned the role of a looker. Only one NPC in each LA group can be the looker.
    1. If there is no NPC among the LA group that sees (raypick) the threat, then the role of the looker is assigned to the one closest (by distance) to the threat.
    2. If there is no access to the threat and no one sees it (raypick the looker role is assigned to the one closest to the threat.
    3. If there’s only one NPC in the LA group, this NPC automatically becomes the looker.
  • All other NPCs in an LA group are assigned the sub-looker role.

Acting Out the Roles

  • Entities act out their assigned roles.

Acting Out the Looker Role

Reaction → Looking for the threat → Threat Inspection → Calming Down

Reaction

  1. Interest is directed at the threat.
  2. The NPC turns to the threat.
    • If the NPC is at a wall, but there’s nowhere to back away to, the NPC turns to the threat without backing away.
    • If there’s nowhere to back away, the NPC turns toward it without backing away.
    • If the NPC is at a wall, when turning toward the threat, the NPC backs away from the wall (with an AI map check).
    • If the threat is very close to the NPC, when turning to it, the NPC also backs away from it (with an AI map check).
  3. At the end of the motion, the NPC enters the next state.

Checking on whether the NPC is at a wall:

During the reaction, use raypick to check that there is no obstacle at the eye level in the direction of the threat. If there is, play the motion of backing away from the obstacle. The raypick distance is 3 meters.

As a result, the NPC turns in the direction of the threat and during the turn moves back a little.

Checking on whether the NPC is very close to the threat:

Distance to the threat <2 meters.

Motions:

  • Motions of a turn towards the threat

free_idle_turn.../ man_freegun_idle_turn...

  • Motions of backing away

m_free_threat_reaction_blocked_.../m_freegun_threat_reaction_blocked_...

Looking For the Threat

  • If the threat is not visible (raypick), a path to the threat is plotted. While walking along the path, the NPC constantly checks for visibility of the threat. If the threat is at a distance of more than 20m, the path to it is not plotted. 
  • If the threat is visible but there is no path to it or the threat is further than 20m away, this state is skipped.

Checking on whether the threat is visible:

Raypick from the NPC’s eyes to the threat up to a distance of 15 meters. If there are no obstacles, the threat is visible. If there are any obstacles, it’s not visible.


Threat Inspection

  • If the threat is nearby, the motions of the NPC looking around are played. At the end of the motions, the NPC goes into the next state. The motions can be very long and vary in length, so here you need an additional timer tallying time spent in the inspection state which should end either at the end of the motions or once the timer elapses.
  • If the threat is not nearby and visible (raypick) - motions of looking at the threat are played. At the end of the motions, the NPC enters the next state.
  • If the threat is not nearby and invisible (raypick) and there’s no obstacle right in front of the NPC (has already checked whether the NPC is standing right next to the wall), the motions of looking around are played. At the end of the motions, the NPC enters the next state.
  • If the threat is not nearby and not visible and there is an obstacle in front of the NPC, the NPC plays the motions of looking around, after which it turns to face the direction that is free of obstacles, after which the motions of looking around are once again played. At the end of the motions, the NPC enters the next state.


Threat nearby:

The distance to the threat  3 meters. The path is built by path find.

Checking on whether the threat is visible:

As described above.

Looking for an unobstructed direction:

Raypick from the NPC’s eyes in different directions up to the distance of 5 meters. Of the directions determined free from obstacles, the nearest is selected and the NPC faces it.

Motions:

  • motions of looking around.

m_free_threat_wait_look_around_.../m_freegun_threat_wait_look_around_...

  • motions of looking at the threat.

m_free_threat_look_at_.../m_freegun_threat_look_at_...

  • motions of looking around.

m_free_threat_look_blocked_.../m_freegun_threat_look_blocked_...

  • turning motions.

free_idle_turn.../ man_freegun_idle_turn...

Calming Down

  1. Short motions are played showing that the NPC is calming downIMPORTANT: The NPC only switches to the free state once this motion is over.

Motions:

  • motions of calming down.

man_free_idle_stand_0 (trim in AS to no longer than 3 sec).

Acting Out the Sub-Looker Role

Reaction → Threat Inspection → Waiting for Results

Reaction 

  • Same as looker.

Threat Inspection

  • If the threat is nearby, the motions of the NPC looking around are played.
  • If the threat is not nearby and visible (raypick)  motions of looking at the threat and, sometimes, the motions of looking at the looker (if the looker’s visible, raypick) are played.
  • If the threat is not nearby and invisible (raypick) and there’s no obstacle right in front of the NPC (has already checked whether the NPC is standing right next to the wall), the motions of waiting and, from time to time, interest motions directed at the looker (if the looker’s visible, raypick) are played.
  • If the threat is not nearby and not visible and there is an obstacle in front of the NPC, the NPC plays the motions of looking around, after which it turns to face the direction free of obstacles, then it will play motions of waiting and, from time to time, interest motions directed at the looker (if the looker’s visible, raypick). 

The mechanic of looking at the looker:

If the looker is in the sub-looker’s frustum (60 degree angle),the looker’s visible (raypick), and the distance to them is  10, then the sub-looker looks at the looker (just interest animations) for 3 to 5 seconds. After that, the NPC stops looking at the looker and starts a cooldown timer (5-7 seconds), during which the NPC will not look at the looker. The timers are reset once the threat changes.

Motions:

  • Motions of looking around

Same as described above.

  • Motions of looking at the threat

Same as described above.

  • Motions of looking around

Same as described above.

  • Turning motions

Same as described above.

  • Motions of waiting.

human\mocap_ai\m_free_threat_wait_in_...

human\mocap_ai\m_free_threat_wait_...

human\mocap_ai\m_free_threat_wait_out_...

Waiting for Results

  • If the looker calms down, all their sub-lookers will calm down with them.
    1. IMPORTANT: the NPC only switches to the free state once the motion is over.
    2. Short motions are played, showing that the NPC is calming down.
  • If the looker dies (and none of the sub-lookers sees this), then after a while (4 to 6 seconds) all sub-lookers switch to alert with a threat point set on the corpse of the looker. This is not a separate state but a transition to alert for the remaining NPCs (sub-looker), with a fake threat set to the corpse and separate VO lines.

Motions:

  • Calming down motions.

Same as described above.


Alert

Overview

The main goal of this state is to inspect the threat source.

Additional points:

  • If several NPCs share the same threat source, they turn to group behavior when checking it out – i.e. wait until one of them examines the threat; they may also go check it out together.
  • The NPCs react to the checker performing their actions.
  • No NPC must stare into a wall when examining the threat.

General Flow of the State:

Flow for the whole AI group.

Identifying Threat → Distributing Roles → Acting Out the Roles

Identifying Threat

  • The threat's position is evaluated.
  • A group is formed of NPCs with the same threat. These are NPCs that are in the same AI group, in the alert state and have the same threat (threat with the same source). Referred to as A (Alert) group below.

Distributing Roles

  • Of the A group, an NPC that is the closest to the threat and can go check it out is selected (pathfind). The NPC is assigned the role of an investigator. Only one NPC in one A group can be the investigator.
    • If there is no NPC among the A group who can check the threat (pathfind), then the role of the investigator is assigned to the one who can see the threat (raypick) without moving.
    • If there is no NPC among the A group who can check the threat (pathfind) or see it (raypick), then the role of the investigator is assigned to the one closest to the threat.
    • If there’s only one NPC in the A group, the NPC automatically becomes the investigator.
  • If there is an investigator in the group who has a path to the threat, that path is long, and there are other free NPCs in the A group, the investigator receives one more NPC as backup, referred to as the investigator partner.
    • The NPC closest to the investigator takes the investigator partner role.
    • If there is no NPC who can plot a path to the investigator, or it is further than 10m from any NPC, the investigator partner role is not assigned.
  • All other NPCs in the A group who are not assigned the roles of the investigator or the investigator partner are assigned the sub-investigator role.

Acting Out the Roles

  • Entities act out their assigned roles.


Checking on whether the threat is visible:

Raypick from the NPC’s eyes to the threat up to a distance of 15 meters. If there are no obstacles, the threat is visible. If there are any, it’s not.

Checking on whether the path is long enough (when an investigator partner is needed):

Path to the threat plotted with pathfind is  10 m.

Acting Out the Investigator Role

Reaction → Looking for the Threat → Threat Inspection → Calming Down

Reaction

Same as in looker but with different motions.

Motions:

  • Motions turning to face the threat from alert into alert.

m_alert_idle_turn90_left

m_alert_idle_turn90_right

m_alert_idle_turn180_left/m_alert_idle_turn180_right

  • Motions turning to face the threat from free into alert.

man_freetoalert_scared_back_1

man_freetoalert_scared_front_1

man_freetoalert_scared_left_1

man_freetoalert_scared_right_1

  • Motions turning to face the threat from freegun into alert.

man_freeguntoalert_scared_back_1

man_freeguntoalert_scared_front_1

man_freeguntoalert_scared_left_1

man_freeguntoalert_scared_right_1

  • Motions of backing up from free into alert.

m_free_to_alert_threat_reaction_blocked_...

  • Motions of backing up from freegun into alert.

m_freegun_to_alert_threat_reaction_blocked_...

  • Motions of backing up from alert into alert.

m_alert_threat_reaction_blocked_...

Looking For the Threat

  • A path to the threat is plotted and the NPC follows that path. While walking along the path, the NPC constantly checks the threat’s visibility to look at it.
    1. If the threat is not visible, the NPC looks in the direction the path is taking them, examining the interest points along the way.
    2. If the threat is visible, the NPC looks in the direction of the threat.
    3. If the threat is too far, the path to it is not plotted. 
  • If there is no path plotted to the threat or the threat is too far, this state is skipped.
  • Once the NPC comes within close range of the threat, the NPC stops and switches to the next state.

Checking on whether the threat is visible:

Raypick from the NPC’s eyes to the threat up to the distance of 15 meters. If there are no obstacles, the threat is visible. If there are any, it’s not.

 

Close range to stop at:

The length of path plotted with pathfind is  2m.

The threat is too far:

The distance to the threat or the length of path plotted with pathfind is  20m.


Trit Inspection

  • If the threat is nearby, the motions of the NPC looking around are played. Once the motions are over, the NPC switches to the next state.
  • If the threat is not nearby and visible (raypick)  motions of looking at the threat. Once the motions are over, the NPC switches to the next state.
  • If the threat is not nearby and invisible (raypick) and there’s no obstacle right in front of the NPC (has already checked whether the NPC is standing right next to the wall), motions of looking at the threat are played. Once the motions are over, the NPC switches to the next state.
  • If the threat is not nearby and not visible and there is an obstacle in front of the NPC, the NPC plays the motions of looking around, after which turns to face the direction free of obstacles, then the motions of looking at the threat are played. Once the motions are over, the NPC switches to the next state.
  • If the looker is in the sub-looker’s frustrum (60 degree angle), they are visible (raypick), and the distance to them is ≤ 10, then the sub-looker looks at the looker (just interest animations) for 3 to 5 seconds. After that, the NPC stops looking at the looker and starts a cooldown timer (5-7 seconds) during which they will not look at the looker. The timers are reset once the threat changes.

Threat nearby:

The length of the path to the threat plotted with pathfind is  3m.

Check if the threat is visible:

Already described above.

Search the direction that is free of obstacles:

Raypick from the NPC’s eyes in different directions up to the distance of 5 meters. Of the directions determined free from obstacles, the nearest is selected and the NPC faces it.

Motions: 

  • motions of looking around

m_alert_threat_look_around_...

  • motions of looking at the threat.

m_alert_threat_look_at_...

  • motions of looking around

m_alert_threat_look_blocked_...

  • turning motions.

m_alert_idle_turn90_left

m_alert_idle_turn90_right

m_alert_idle_turn180_left/m_alert_idle_turn180_right


Calming Down.

  1. Short motions are played showing that the NPC is calming downIMPORTANT: the NPC only switches to the free state once the motion is over.

Motions:

  • motions of calming down into free.

man_alerttofree

  • motions of calming down into freegun.

man_alerttofreegun_0

Acting Out the Sub-Investigator Role

Reaction → Threat Inspection → Waiting for Results

Reaction 

  • Same as investigator.

Threat Inspection

  • If the threat is nearby, the motions of the NPC looking around are played.
  • If the threat is not nearby and visible (raypick motions of looking at the threat and, sometimes, the motions of looking at the investigator (if they're visible, raypick) are played.
  • If the threat is not nearby and invisible and there’s no obstacle right in front of the NPC (has already checked whether the NPC is standing right next to the wall), the motions of waiting and, from time to time, interest motions directed at the investigator (if they're visible, raypick) are played.
  • If the threat is not nearby and not visible and there is an obstacle in front of the NPC, the NPC plays the motions of looking around, after which turns to face the direction free of obstacles, then it plays the motions of waiting and, from time to time, interest motions directed at the investigator (if they're visible, raypick). 

The mechanic of looking at the investigator:

If the investigator is in the sub-investigator’s frustrum (60 degree angle), they're visible (raypick) and the distance to them is  10, then the sub-investigator looks at the investigator (just interest animations) for 3 to 5 seconds. After that, the NPC stops looking at the investigator and starts a cooldown timer (5-7 seconds) during which they will not look at the investigator. The timers are reset once the threat changes.

Motions:

  • motions of looking around

same as described above

  • motions of looking at the threat

same as described above

  • motions of looking around

same as described above

  • turning motions

same as described above

  • motions of waiting.

m_alert_threat_wait_in_0

m_alert_threat_wait_0

m_alert_threat_wait_out_0


Waiting For Results

  • If the investigator calms down, all their sub-investigators calm down with them.
    1. IMPORTANT: The NPC only switches to the free state once the motion is over.
    2. Short motions are played, showing that the NPC is calming down.
  • If the investigator dies (and none of the sub-investigators see this), then after a while (4 to 6 seconds) all sub-investigators switch to alert with a threat point set on the corpse of the investigator. This is not a separate state but a transition to alert for the remaining NPCs (sub-investigator) with a fake threat set to the corpse and separate VO lines.

Motions:

  • Motions of calming down.

Same as described above.

Acting Out the Investigator Partner Role

Reaction → Looking For the Threat → Threat Inspection → Waiting for Results

Reaction 

  • Same as investigator.

Looking For the Threat

  • A path to the investigator is plotted and the NPC follows that path. While walking along the path, the NPC constantly checks the threat’s visibility to look at it and updates the path.
    1. If the threat is not visible, the NPC looks in the direction the path is taking them, examining the interest points along the way.
    2. If the threat is visible, the NPC looks in the direction of the threat.
    3. When the NPC reaches the investigator, the investigator partner stops and plays the motions of looking around and,once the investigator walks further away again, the investigator partner resumes following him.
  • Once the NPC comes within close range of the threat or the investigator reaches the threat, the investigator partner stops and switches to the next state.
  • Close range to the threat:

The length of the path plotted with pathfind is  2m.

  • Close range to the investigator:

The length of the path plotted with pathfind is  2m.

  • The investigator is far:

The length of path plotted with pathfind is  4m

Threat Inspection

  • Same as the investigator, although the investigator partner does not calm down by themselves, waiting for the corresponding command from the investigator instead.

Waiting for Results

  • If the investigator calms down, all their investigator partners calm down too.
    1. IMPORTANT: The NPC only switches to the free state once the motion is over.
    2. Short motions are played showing that the NPC is calming down.

Motions:

  • Motions of calming down.

Same as described above.

Uber Alert

The main goal of this state is to look for the enemy. The NPCs are sure the enemy is around.

The search has two states:

  • Inspecting the actual threat location.
  • Inspecting the surrounding territory.

Overview

When in the uber alert state, an NPC may or may not know the threat’s location. The reason for this is because the NPC could switch to uber alert after hearing a sound or seeing something dangerous, in which case the location of the threat is already known to them. If the NPC has switched to uber alert after finding a corpse or has already checked the known threat location and found nothing there, they do not know where the threat is anymore.

Thus, if an NPC is in uber alert and KNOWS where the threat is, they're in the Alarm State.

If the same NPC is in uber alert and DOESN’T KNOW where the threat is, they're in the Search State.

General Flow Of the State:

Flow for the whole AI group.

Identifying Threat → Distributing Roles → Acting Out the Roles → Re-distributing Roles

Identifying Threat

  • Threat position is evaluated.
  • A group of NPCs is formed with the same threat. These are NPCs that are in the same AI group, in uber alert state and have the same threat (threat with the same source or several threats located close to each other). Referred to as UA (Uber Alert) group below.

Distributing Roles

  • Same as in Alert but with different role names.

A group = UA group
investigator = checker
investigator partner = checker partner
sub-investigator = sub-checker

Acting Out the Roles

  • Entities act out their assigned roles.

Re-distributing Roles

  • After the alarm phase, the search phase is entered where roles are re-distributed.
  • The alarm phase might not always happen (a corpse is found).

NPCs in the Search State receive the role of the searcher and distribute among themselves groups of search covers, taking into account their current threat and location.


Search cover groups distribution mechanic

Description
1

Relative to the threat

  1. The closest terminal cover within the radius of 50 meters (exposed in engine.cfg) from the current threat which belongs to a free search cover group is identified.
  2. An NPC nearest (according to pathfind) to the previously identified cover is found within the 50m radius (exposed in engine.cfg).
  3. The NPC is assigned to a search cover group which the previously identified terminal cover belongs to.
  4. The loop is repeated.

If there’s no terminal cover belonging to a free search cover group in the radius,the NPCs distribute the search cover groups between themselves in accordance to their location.

2

Relative to location

The NPC uses pathfind to find the closest terminal cover within a 50m radius (exposed in engine.cfg) which the NPC can plot a path to.

  1. If the search cover group of the cover is free, the NPC is assigned to it as the searcher.
  2. If the search cover group of the cover already has a searcher, the NPC is assigned to it as a search partner.
  3. If the search cover group of the cover already has a searcher and a search partner, the NPC will attempt to find other nearby search cover groups and restart the loop (one search cover group can have no more than 1 and 1 search partner).


If there are no (or not enough) search covers available, the behavior is described in the corresponding role.

  • A search cover group is a set of search covers connected by links. i.e. if one cover is linked with any other cover, they belong to the same cover group (every search group is temporarily united into a cover group).
  • A free search cover group is simply one that still has no NPC assigned to it.
  • A terminal cover is a cover that only has one exit.
    1. If there are no terminal covers in a group (i.e. all the group’s covers are cyclically connected), two covers furthest from each other in this cover group are selected and set as terminal covers.
    2. If there is only one terminal cover in a group (and all the rest of the group’s covers are cyclically connected), a cover that’s furthest from the terminal one within the group is set as its second terminal cover.

Acting Out the Checker Role

Reaction → Safe Position → Looking For the Threat → Inspecting the Threat

Reaction 

Same as the reaction in the looker role. The only difference is the motions. 

It’s better to use separate positions for uber alert, avoiding having the same logic as the regular alert.

Motions:

  • Motions turning to face the threat from alert-uber alert into uber alert.

m_alert_idle_turn90_left

m_alert_idle_turn90_right

m_alert_idle_turn180_left/m_alert_idle_turn180_right

  • Motions turning to face the threat from free into uber alert.

man_freetoalert_scared_back_1

man_freetoalert_scared_front_1

man_freetoalert_scared_left_1

man_freetoalert_scared_right_1

  • Motions turning to face the threat from freegun into uber alert.

man_freeguntoalert_scared_back_1

man_freeguntoalert_scared_front_1

man_freeguntoalert_scared_left_1

man_freeguntoalert_scared_right_1

  • Motions of backing up from free to uber alert.

m_free_to_alert_threat_reaction_blocked_...

  • Motions of backing up from freegun into uber alert.

m_freegun_to_alert_threat_reaction_blocked_...

  • Motions of backing up from uber alert into uber alert.

m_alert_threat_reaction_blocked_...


Safe Position

  • The NPC takes a nearby combat cover and looks towards the direction of the threat. The cover is selected in relation to the threat, i.e. must be facing the threat.
  • Waits until the waiting delay elapses, after which it switches to the Looking For the Threat state.

If there are no combat covers available:

  • NPC plays the cautious retreat motions.
  • NPC plays the motions of looking at the threat.

Once the motions are over, the NPC switches to the Looking For the Threat state.


Waiting delay = 5 seconds.

No combat covers:

  • They are absent
  • They are all taken
  • They are all further than 20m away.


Looking For the Threat

Same as:

The investigator role of Looking For the Threat.


Threat Inspection

Same as: 

The investigator role of Threat Inspection.

Except:

  • The NPC does not calm down in the end, instead switching to the Search state along with all of their sub-checkers.
  • If the checker dies (and none of the sub-checkers see that), after a delay (4-6 seconds) all sub-checkers switch to the Search state.

Motions:

  • cautious retreat motions.

m_alert_idle_look_arnd_agrs_wlk_bwd_1

  • motions of looking around.

m_alert_threat_look_around_+

  • motions of looking at the threat.

m_alert_threat_look_at_+

  • motions of looking around.

m_alert_threat_look_blocked_+

  • turning motions.

m_alert_idle_turn90_left

m_alert_idle_turn90_right

m_alert_idle_turn180_left/m_alert_idle_turn180_right

Acting Out the Checker Partner Role

Reaction → Safe Position → Looking For the Threat → Inspecting the Threat

Reaction

Same as the checker.

Safe Position 

Same as the checker.

Looking For the Threat and Inspecting the Threat 

Should use the same mechanic as the investigation partner in alert.


Reaction → Safe position → Wait

Reaction

Same as the checker.

Safe Position

  • The NPC takes a nearby combat cover and looks at the direction of the threat. The cover is selected in relation to the threat, i.e. must be facing the threat.

If there are no combat covers available:

  • The NPC plays the cautious retreat motions.

If there is no need to take cover on account of that particular threat (threat rating too low):

  • The NPC skips the state, switching to the Wait state immediately.

Wait

  • The NPC stays in cover, periodically peeking out using the existing mechanics.
  • It would be nice to have the NPC change covers when an opportunity arises to approach the threat source cautiously.

If the NPC is not in a combat cover:

  • While the NPC is in this state, they sequentially play one of the motions of looking at the threat, then one of the motions for looking around, in a loop.

Acting Out the Searcher Role

Cover Group Selection → Search → Loop → Calming Down

Cover Group Selection

If there’s a search cover for the NPC:

  • NPC gets a cover group according to Search cover groups distribution mechanic relative to the threat or Search cover groups distribution mechanic relative to the location described above.

If there are no search covers available or not enough of them for this NPC:

  • The state is skipped and the NPC switches to the Search state directly.

Search

If there’s a search cover for the NPC:

  • The NPC moves through the search covers of the cover group they selected.

MechanicGoalImplementation
1

The mechanic of progressing through the search covers

The NPC investigates territory carefully.

  • Terminal covers (covers that only have one exit) are selected in a cover group. The NPC plots a path into one of the still unchecked terminal covers (the one closest to the threat position). Having reached it, the NPC marks the cover as checked and plays the animation of looking around. Then the NPC proceeds to the next still unchecked terminal cover (if the NPC doesn’t switch to a different search group).
  • Once the NPC checks the last still unchecked terminal cover, all the checked terminal covers reset to Unchecked.
  • Once the NPC switches to a new threat, all the checked terminal covers reset to Unchecked.
2

The mechanic of switching to a new search group

The NPC moves to another free territory, having checked the one they were working on.

  • The NPC checks whether there’s a free cover group every time the NPC marks a terminal cover as checked but only after the NPC has at least once checked all other terminal covers, i.e. the place has already been searched. The NPC looks for a new group using the Search cover groups distribution mechanic relative to the location mechanic, excluding the group the NPC's currently assigned to.
  • If the NPC can’t find a new group to switch to, they stay in the current one but continue to look for a new one under the conditions described above.
  • Once the NPC switches to a new threat, all the checked terminal covers reset to Unchecked.
3

The mechanic of taking a search group

NPCs should never congregate anywhere in mass.

  • Once an NPC takes a cover group, it becomes marked as taken for other NPCs.
4

The mechanic of freeing a search group

Movement of NPCs through the whole level, not just one zone.

  • If there are no NPCs checking a search group, it is considered free.
  • Once the NPC that checks a particular group dies or switches to a different group, it becomes free for taking by other NPCs.


If there are no search covers available or not enough of them for this NPC:

  • The NPC plays one motion of looking at the threat and then one motion of looking around.
  • Once done, the NPC switches to the previous state of cover group selection,i.e. goes looking for a search cover group to check.

Calming Down

  • Once the timer of switching from uber alert to free elapses, the NPC calms down and makes other NPCs sharing the same threat source calm down.
  • Short motions are played showing that the NPC is calming down.

Acting Out the Searcher Partner Role


The same mechanic as in alert investigation partner.

On this page:

Placing Search Covers in a Location

Goal

  1. Distribute NPCs across the territory so that they cover it all during the search.
  2. Create enough search paths so that NPCs could migrate from one to another.

Workflow

  1. Divide the territory into many sub-territories that the NPCs will be checking during the search. Note the places where we would like the NPCs to stop and look around. For example, rooms where the player could be hiding, notable open areas, vista spots.
  2. Plot patrol routes using covers (human_search).
    •  There should be more than one inspection site on one patrol path.
    • The covers should be connected with each other by double links.
    • The direction of the covers (their rotation) does not matter. 
    • Covers that are linked with only one other cover are inspection sites (places where the NPCs will stop to check them thoroughly). They are called "terminal covers".
    • Covers that are linked with 2 or more other covers are simply waypoints, the NPCs will not stop at them.
  3. All covers interconnected by links are combined into one cover group (general/cover group) with an arbitrary name. This group makes up 1 route to be taken when being distributed between the NPCs to avoid them all crowding together. There should be at least half as many groups as the maximum number of NPCs at the location (e.g. if there are 10 NPCs, you need at least 5 search groups).

Returning from Danger to Uber Alert

General Idea:

If the enemy is lost, then the task of the NPCs is to check the last place where the enemy was noticed.

If the enemy was killed, then the NPCs scout the territory in search for other opponents.

Reasons for Returning from Danger to Uber Alert:

  1. The enemy contact was lost. Subsequently, the enemy contact was not re-established for the Danger → Uber Alert Inertia interval.
  2. The enemy was killed.

Behavior When the Enemy Contact is Lost:

  1. When the enemy contact is lost (the enemy is not dead), NPCs enter the alarm state and their missing danger threat becomes an uber alert threat located at where the enemy was last seen.
    1. IMPORTANT: the enemy timer is set to the maximum value so that this threat does not get interrupted by others that may occur during combat.
    2. If the NPC is not in cover, they plays the motion of switching from danger to uber and then continues their previous behavior.
  2. The NPCs do not rush to covers appropriate for this threat.
    1. The NPCs behave accordingly when there are no covers.
  3. The NPCs do not respond to this threat as a new one, that is, they should not use activities common for a new threat.
    1. the NPCs should run the uber alert investigate logic with all their activities.
  4. The NPCs already in cover will remain there unless they become checkers or checker followers.

Behavior in Case the Enemy is Killed:

When the enemy is dead and the NPC has no other threats that they can switch to, they gradually calm down and switch to the Search state.

    1. The NPC calms down as the Uber Alert Search (Kill) Inertia timer elapses or at the end of the transition motion.
    2. The Search state should begin with the leader activity uber_alert_search_start, like an ordinary search routine.
    3. If the NPC is not in a cover, it plays a motion of switching from danger to uber and then goes to the Search state.
    4. If the NPC is in the cover, it waits until the Uber Alert Search (Kill) Inertia timer elapses and then switches to the Search state.



Finding Corpses and Knocked-Out Allies

General Rules

  1. A corpse is considered to be found, if an NPC sees it after it has been lying there for a certain time.

     Why?

    If an NPC’s corpse is found immediately after their death, it means the actual kill was witnessed which is covered by a completely different case. 

  2. If a group member checks a corpse, a cooldown is imposed on the entire group, during which the corpse that’s been checked is not perceived as a threat. The only reaction to the corpse is VO.

     Why?

    So that the NPCs don’t keep running from one corpse to another indefinitely. 

  3. If a group member checks a corpse or simply sees it when checking it was not an option, the corpse is marked for the entire AI group and is no longer perceived by the group as a threat.

     Why?

    So that the NPCs don’t get repeatedly alarmed by the same corpse. 

Behavior When Finding a Corpse (Free  Alert):

Main Goal

The main idea is that finding a corpse is a surprise for the NPCs in free  alert states. Finding one means the NPC is not alone in the area and there is an enemy around.

Ideal Behavior

The NPC who discovers the corpse is worried and goes to check it, while everyone else becomes alert/starts looking around and waiting for a command from the checker to start searching the territory.

Behavior Logic

Reaction → Approaching the Corpse → Corpse Inspection → Search

StateBehavior logic

Reaction

The first NPC who discovers the corpse switches to uber alert following the standard visual uber alert threat flow. The NPCs who were told about the corpse switch to uber alert following the standard audio uber alert threat flow (implemented via speech manager) without taking cover.

Approaching the corpse

If the corpse is too far or a path to it can’t be plotted, the NPC plays the motions of looking at a threat, then switches to the Search state.

 Why?

So the NPCs don’t wander too far and don’t remain in this state for too long.

If the distance to the corpse is not too long, then the NPC immediately heads to the corpse and upon reaching it goes into the Corpse inspection state.

IMPORTANT: The NPCs must not take cover in this state.

Corpse inspection

The NPC plays the corpse inspection animation (sitting down), then plays the motions of looking around before finally switching to the Search state.

Search

The NPC, along with all of their sub and follower NPCs, switches to the Search state.

 

Corpse too far:

  • Net distance to the corpse of pathfind is  25m.

Reaching the corpse: 

  • Net distance to the body center is  2m.

Behavior When Finding a Corpse (Uber Alert):

The general idea is that while in uber alert, finding a corpse is not a shock to an NPC, compared to finding one in the free – alert state.

Behavior logic

Depending on the state of the NPC in uber alert, the NPC may react to finding a corpse differently.

The state that the corpse was noticed in

Behavior

Alarm State

  • The NPC ignores the corpse as a threat but performs corresponding activities.

     Why?

    The Alarm state is a state of increased alertness and it is best, if the NPC doesn't change position from reacting to the current threat to reacting to the corpse.

Investigate

  • The NPC ignores the corpse as a threat but performs corresponding activities.

     Зачем?

    It would be better if the NPCs don't all take cover immediately after discovering a corpse while in uber alert, since a corpse merely confirms their suspicions that there’s an enemy around. 

Search State

  • For an NPC, a corpse is a default alert threat. Upon reaching a corpse the NPC is investigating, the NPC will play the Corpse Inspection logic instead of Threat Inspection.

     Why?

    It's better, if the NPCs don't all take cover immediately after discovering a corpse while in uber alert, since a corpse merely confirms their suspicions that there’s an enemy around. They can’t ignore the corpse but they shouldn't focus entirely on it either.

Behavior When Finding a Knocked-Out Ally

Same as when finding a corpse, the only difference being the VO lines used.


“Scary” Reactions to Threats

Scary – “startled” reactions to threats appearing unexpectedly for the NPC.

The "scary" reactions are used when

  1. The NPC is in a free/disturb/light alert state and receives an alert threat.
  2. The NPC is in a free/disturb/light alert state and receives a danger threat.
  3. The NPC is in a free/disturb/light alert/alert state and receives an uber alert threat.
  4. The NPC is in a free/disturb/light alert/alert state and receives a danger threat.
  5. The NPC is in an uber alert search state or investigate state and receives an uber alert threat.
  6. The NPC is in an uber alert search state or investigate state and receives a danger threat.

Particularities

  1. The reaction depends on the threat, however if the location of the source of the threat is known, then it depends on it.
  2. Motions may be long and they can’t be easily interrupted (a new threat should be stronger or appear in a completely different location).
  3. At first, the NPCs will always try to play motions on the move, but if they can’t, they’ll play the motions on the spot.
  4. Depending on whether the NPC was in freegun or not, they will play different motions.

Kill in Sight

General Rules

  1. An NPC is considered killed in sight, if their corpse was seen very soon after their death.
  2. If the NPCs of an AI group already knew of the corpse (saw it or heard of it), it is not perceived as a new threat when seen.

     Why?

    So the NPCs don’t get repeatedly alarmed by the same corpse. 

  3. If the NPC was killed in another NPC’s sight, a Ghost is placed at the killer’s position.

Eye-Killing Behavior

Reaction

The first NPC that sees the corpse switches to visual uber alert with the killer’s position. The NPCs who were told about the corpse switch to uber alert following the standard audio uber alert threat flow.


 Why?

So the NPCs don’t keep getting repeatedly alarmed by the same corpse. 

NPC Movement During Investigate & Search.

If:Then:

Initial distance to the target  6m

Use walk_slowly.

Initial distance to the target > 6m

While distance to target > 6m – use walk.

When distance to target  4 – use walk_slowly.

“Distance” refers to the pathfind path length.

Working With Other Entities

NPC + Cannibal/Savage Logic

NPCs, along with cannibals and tribals, support the following mechanics:

MechanicDescription

Kill in sight

NPCs perceive a tribal/cannibal being killed in their sight as an NPC from their group being killed in sight.

The cannibals/tribals perceive an NPC being killed in their sight as a cannibal/tribal from their group being killed in sight.

Corpse found

NPCs perceive a tribal/cannibal corpse found as a corpse of an NPC from their group.

The cannibals/tribals perceive an NPC corpse found as a corpse of a cannibal/tribal from their group.

Transmission of threats and threat timers

NPCs can receive visual and audio threats (and synchronize them) from tribals/cannibals (ONLY in uber alert), just like the NPCs from their own group.

The cannibals/tribals can receive visual and audio threats (and synchronize them) from the NPCs (ONLY in uber alert), just like they can from the cannibals/tribals in their own group.

They use all other mechanics as separate entities (that is, disregarding each other).

For the mechanic to work, the cannibals, and the NPCs must be placed in one AI group.

NPC + Dog Logic

The main idea is that when a dog is partnered with an NPC, it tries synchronizing its behavior with the NPC, receiving threats from the NPC.

MechanicDescription

Transmission of threats and threat timers

The dog transmits its alert threat (with its timer and position), sound, and vision only to its leader.

The dog transmits its uber alert threat (with its timer and position), sound, and vision as an alert threat only to its leader.

The dog receives an alert threat (with its timer and position), sound, and vision from its leader.

The dog receives an uber alert threat (with its timer and position), sound, and vision from all NPCs in its leader’s group.

Since the logic and motions of different entities cause the NPCs and the dog to calm down, and transition to the free state in different ways (and taking different amounts of time for that), the threats must only be transmitted, if they are new or updated. This saves the entities from entering an endless mutually induced aggro loop.

Important: the timers pertaining to one threat must be synchronized.

Dog goes missing

If the dog attached to the leader dies and the leader does not see it getting killed, after a while the leader starts commenting on the loss (but takes no action).

Blocked return to free state

If the leader can’t exit the uber alert state because the leader saw a corpse, the dog also uses the same logic.

Search with a leader

If the dog’s leader is alive and in uber alert search, and the dog does not have a threat of its own, it uses the search with a leader mechanic (described in Monster Mental States).

Corpse found

If the dog is killed, the NPCs from the leader’s group perceive its corpse as an NPC corpse of their group (using special VO lines).

The dog perceives a corpse of an NPC from the leader’s group as a corpse of a dog from its own group (switches to uber alert, approaches a corpse and investigates it).

The dog perceives a corpse of its leader group as a corpse of a dog from its own group, additionally creating a sound alert threat at the corpse’s location (once it investigates it), so that the other NPCs can check it too (the threat is heard by the NPCs from the leader’s group).

Kill in sight

The NPCs perceive a dog being killed in their sight as an NPC from their group being killed in sight.

The dog perceives its leader’s group members being killed in its sight as a dog from its own group being killed.

The dog perceives its leader being killed in its sight as a dog from its own group being killed, additionally creating a sound alert threat at the corpse’s location.



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