Detection Formula

A page outlining values impacting Detection.

Detection Formula
The factors that impact detection are skill, visibility, and sound. These 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.

Detection Value = fSneakBaseValue + Sound Factor + Visual Factor + ((Detector Skill Factor - Target Skill Factor) * fSneakSkillMult)

Distance Attenuation
Sound is further attenuated if there is no line of sight between the actor and the target using fSneakSoundLosMult (0.1). ((fSneakMaxDistance - distance) / fSneakMaxDistance) ^ fSneakDistanceAttenuationExponent

Sound
Sound is made up of two factors, including movement and action. Movement is the sound made when moving. If the target is stationary, this is 0. Action is the "action sound" made by the target -- the sound of any weapon being used.

Movement Sound = (fSneakBootWeightBase + fSneakBootWeightMult * armor weight) Running = fSneakRunningMult (unless player has Silent Running perk) Action Sound = Action * fSneakActionMult Sound factor = Distance Attenuation * fSneakSoundsMult * (Movement Sound + Action Sound)

Visual
The visual factor is determined as follows. If can't see target, visual element is 0. Movement Multiplier: 1 + Moving * fSneakLightMoveMult + Running * fSneakLightRunMult Light: (fDetectionSneakLightMod + (light level * night eye bonus) * fSneakLightMult Blindness: ( 100 - blindness )/100 Stealthboy: If Stealthboy == 1, multiply by fSneakStealthboyMult Visual factor = Distance Attenuation * Visual Contact * Light * Movement Multiplier * Blindness * Stealthboy


 * Characteristics
 * Blindness - Variable is set to 0 in New Vegas and has no effect on the visual factor, i.e. (100 - 0) / 100 = 1.
 * Night eye bonus' - Multiplies the light level by fDetectionNightEyeBonus and caps it at 100 if detecting actor's NightEye actor value is non-zero.

Detector Skill
The actor running detection uses Perception (not Sneak skill) to determine a base "perception skill" value. 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.

Perception Skill = fSneakPerceptionSkillMin + (fSneakPerceptionSkillMax - fSneakPerceptionSkillMin) * (Perception / 10)

Detector Skill = Perception Skill * ((1 + Combat * fSneakAlertMod) + (Sleeping * fSneakSleepBonus) + (Combat Target * fSneakCombatMod))

Detector Skill Factor = Detector Skill * Distance Attenuation

Target Skill
The target is the actor while sneaking.

Fallout 3 - Target Skill Factor = Sneak * IsSneaking

New Vegas - Target Skill Factor = ((Sneak + iSneakLevelBonus * (Target Level - Detector Level)) + max(iSneakStartBonus - iSneakStartBonusLevelPenatly * Target Level, 0) - Armor Penalty) * IsSneaking

Detection States
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:
 * Normal: Default state of all actors.
 * Alert: I am aware of a Detection Event. May include search behavior, but always includes "weapon out". Actors have increased Perception when in this state.
 * Combat: I am in combat with at least one actor in my target list.
 * Lost: 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 to Alert: This transition happens when a hostile actor (an actor that I would attack if I detected it) either:
 * 1) 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.
 * 2) Creates a "Detection Event" that I detect (e.g. firing a weapon). Add the detection event to my alert list.
 * 3) Damages me. Add a detection event to my alert list at the enemy's current location with magnitude of current detection.
 * Normal to 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 to Combat: This transition happens when I detect any actor to which I'm hostile.
 * Alert to Normal: This transition happens when my alert list is empty -- all detection events have expired.
 * Combat to 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 to 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 to Normal: This transition occurs whenever all my targets < Alert Threshold AND the Alert Timer has expired.
 * Lost to Combat: This transition occurs whenever the player detects any targets (detection > 0).

Target List
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.

Actor Behavior

 * Alert State: 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.
 * Lost State: 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.

Voice and Sound Cues
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?" There also default detection topics for the transitions between detection states: NormalToAlert, AlertToCombat, NormalToCombat, AlertToNormal, CombatToNormal, CombatToLost, LostToNormal, and LostToCombat.

Detection Events
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.

Procedure

 * A detection event is generated when:
 * 1) A projectile impacts something -- grenade, rocket, Fat Man. Action rating = taken from the projectile.
 * 2) A world object explodes (car, fuel tank, etc.). Action rating = taken from the exploding object. Owner = whoever caused the object to blow up.
 * 3) CreateDetectionEvent is called.
 * 4) 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.
 * 5) 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.


 * A detection event is not generated when:
 * 1) When an enemy is within my "Alert Threshold", every time I finish a complete search of the "search area" recenter the search area based on the enemy's current location.
 * 2) 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.