Detection is a complicated process involving many variables. The factors break down into three categories: skill, visibility, sound. These three factors are added together to determine whether one actor detects another. Actors can also detect Detection Events -- sounds directly or indirectly generated by a target actor -- even if they don't detect the target directly.
The basic formula is as follows:
Detection Value = fSneakBaseValue + (Sound factor * Distance attenuation ) + (Visual factor * Distance attenuation) + (Actor Skill factor * Distance attenuation) - ( Target Skill factor )
Each of the three detection factors is modified by distance using the following formula:
( ( fSneakMaxDistance - distance ) / fSneakMaxDistance ) ^ fSneakDistanceAttenuationExponent
Sound is further attenuated if there is no line of sight between the actor and the target using fSneakSoundLosMult (0.1).
Sound is made up of 2 factors: movement and action.
Movement is the sound made when moving. If the target is stationary, this is 0. Otherwise:
Movement Sound = ( fSneakBootWeightBase + fSneakBootWeightMult * armor weight)
If running, use fSneakRunningMult (unless player has Silent Running perk)
Action is the "action sound" made by the target -- the sound of any weapon being used.
Action Sound = Action * fSneakActionMult
Sound factor = Attenuation * fSneakSoundsMult * (Movement + Action)
The visual factor is determined as follows:
Visual Contact: If can't see target, visual element is 0 Movement Multiplier: 1 + Moving * fSneakLightMoveMult + Running * fSneakLightRunMult Light: ( fDetectionSneakLightMod + light level ) * fSneakLightMult Blindness: ( 100 - blindness )/100 Stealthboy: If Stealthboy == 1, multiply by fSneakStealthboyMult
Visual factor = Attenuation * VisualContact * Light * Movement * Blindness * Stealthboy
The actor running detection uses Perception (not Sneak skill) to determine a base "perception skill" value:
Base Perception Skill = fSneakPerceptionSkillMin + (fSneakPerceptionSkillMax - fSneakPerceptionSkillMin) * Perception / 10
This can be further modified by various factors: is the actor in the Alert state; is the actor sleeping; is the actor in combat with something else.
Modified Perception Skill = Base Perception Skill * (1 + Alert * fSneakAlertMod + Sleeping * fSneakSleepBonus + NotCombatTarget * fSneakCombatMod)
The detection value is used to determine when an actor changes its detection state.
Actors pass through 4 detection states: Normal->Alert->Combat->Lost->Normal. Actors enter the Alert state when they either "almost" detect an enemy, or detect a "detection event" generated by an enemy. Alerted actors will search towards detection events, which will allow them to detect enemies and enter the Combat state. If all targets become undetected, an actor will drop out of combat into the Lost state, searching towards the last known locations of its targets until it either redetects them or a timer expires and they return to Normal state.
Actors are always in one of the following detection states:
- Default state of all actors.
- I am aware of a Detection Event. May include search behavior, but always includes "weapon out". Actors have increased Perception when in this state.
- I am in combat with at least one actor in my target list.
- I've transitioned from Combat because all of my targets became undetected. Similar to Alert state in most respects.
Actors transition between detection states according to the following rules:
Normal --> Alert
This transition happens when a hostile actor (an actor that I would attack if I detected it) either:
- Crosses the "Alert Threshold" (fSneakNoticedMin = -20). Add a detection event to my alert list at the actor's current location with the magnitude of current detection.
- Creates a "Detection Event" that I detect (e.g. firing a weapon). Add the detection event to my alert list.
- Damages me. Add a detection event to my alert list at the enemy's current location with magnitude of current detection.
Normal --> Combat
This transition happens when a hostile actor suddenly becomes detected without triggering the Alert state on me. For example, a sneaky character fires a gun nearby, going from -30 detection to 20 all at once.
Alert --> Combat
This transition happens when I detect any actor to which I'm hostile.
Alert --> Normal
This transition happens when my alert list is empty -- all detection events have expired.
Combat --> Normal
This transition occurs whenever I have no targets in my combat list (i.e. they're all dead or no longer considered hostile), and I have nothing in my alert list.
Combat --> Lost
This transition occurs whenever all my targets are undetected (detection < 0) AND their timers have all expired (see below), and I have events in my alert list.
Lost --> Normal
This transition occurs whenever all my targets < Alert Threshold AND the Alert Timer has expired.
Lost --> Combat
This transition occurs whenver I detect any of my targets (detection > 0).
Actors in combat (which includes Alert, Combat, and Lost states) hold a list of hostile actors in their target list.
Whenever an actor in my target list becomes undetected (detection < -20), start running a timer on that target. If timer expires and target is still undetected AND not currently being searched for (either I'm searching for someone else, or still in combat with someone else), remove the target from my list.
The Alert State is a combat state -- the actor is in combat, although it has not located a target to attack. If allowed by its current package, the actor will engage in search behavior towards detection events in its alert list (see Combat Search).
The Lost State is also a combat state -- the actor remains in combat, but has lost detection on its targets. If allowed by its current package, the actor will engage in search behavior (starting with its current combat target if more than one target remains in its list) (see Combat Search); otherwise it should return to its package location, but remain Alert.
When actors are in a combat search (Alert or Lost states), they will occasionally use these default Detection topics for dialogue barks.
- LostIdle: Used when actors are in the Lost state. Examples: "Nothing yet.", "Keep looking. He's got to be here somewhere."
- AlertIdle: Used when actors are in the Alert state. Examples: "I could have sworn I heard something.", "Hmm. Maybe I'm just hearing things.", "I'll check over here.", "Anybody there?"
Transitions: there also default Detection topics for the transitions between detection states:
A detection event is a sound/action at a location, that can be detected by an actor in a similar manner that it detects other actors. In general, actors will only respond to a detection event if it was produced by an actor that they are aggressive towards.
A Detection Event has the following data attached to it:
- Owner -- Actor that caused it
- Action rating -- this plugs into the detection formula, and is the main component of how "loud" the event is. This comes from the projectile or explosion.
- Location -- used by alerted actors as the location of their search.
Generating a Detection Event
A detection event is generated when:
- A projectile impacts something -- grenade, rocket, Fat Man. Action rating = taken from the projectile.
- A world object explodes (car, fuel tank, etc.). Action rating = taken from the exploding object. Owner = whoever caused the object to blow up.
What doesn't generate a detection event?
- When an enemy is within my "Alert Threshold", every time I finish a complete search of the "search area" (see Combat Search), recenter the search area based on the enemy's current location.
- When an enemy damages me, if I can't detect the enemy, I start searching anyway. I will still do a complete search before dropping out of combat even though I have no detection on the enemy.
What happens when a detection event is generated?
- Actors within the detection radius (fSneakMaxDistance) run detection on the event to see if they detect it. Actors who would not respond aggressively toward the detection event owner ignore the event, as do actors who are already in Combat state.
- If an actor detects the event (>fSneakNoticedMin), they are immediately put into Alert state. If they are already Alert, add the event owner to their target list.