ai_script_conditions

From Source Entities
Jump to navigation Jump to search

Code classes:

ai_script_conditions is a point entity present in all games except the L4d.pngL4d2-small.pngLeft 4 Dead games. It allows a mapper to define a list of conditions relating to the player, an NPC (actor), and a third entity, that trigger events when the conditions are fulfilled. Conditions include being able to see one another and proximity to objects.

An example of its use is on Hl2.pngd2_coast_03. When Odessa holds out the rocket launcher for Gordon to grab, an ai_script_conditions is used to tell how close the player is to Odessa. When the player is within a very small range, Odessa drops the weapon. 99% percent of the time, the player will be close enough that they will then automatically pick up the weapon_rpg.

Note: Distances do account for crouching. A proximity condition that is fulfilled while not crouching might be unfulfilled while crouching.

Note: notarget may affect LOS conditions.

ConVars/Commands[edit | edit source]

ConVar/CommandParameters or default valueParameter TypeEffect
ai_debugscriptconditions00 disables, 1 enablesPrints to the console what conditions need to be met, when conditions are satisfied, etc. Requires developer 1 in the console before taking effect.

Flags[edit | edit source]

  • 1: Fire outputs with the Actor as !activator. Otherwise the activator will be the ai_script_conditions. (only available in Hl2.pngEpisodic)

Keyvalues[edit | edit source]

Actor (Actor) <target_destination>
NPC we should be concerned with.
Actor in Vehicle (ActorInVehicle) <choices>
Checks if actor is in a vehicle.
  • 0: No
  • 1: Yes
  • 2: Don't care
Actor in Player's PVS (ActorInPVS) <choices>
Checks that the actor is in the player's PVS.
  • 0: No
  • 1: Yes
  • 2: Don't care
Actor is running a script? (ScriptStatus) <choices>
Checks if NPC is currently involved in a scripted sequence.
  • 0: No
  • 1: Yes
  • 2: Don't care
Actor see Player (ActorSeePlayer) <choices>
Does Actor need to have LOS to player?
  • 0: No
  • 1: Yes
  • 2: Don't care
Actor Sees Target (ActorSeeTarget) <choices>
Should the NPC see the target entity?
  • 0: No
  • 1: Yes
  • 2: Don't care
Target (target) <target_destination>
Optional third entity to include in conditions.
Target distance (ActorTargetProximity) <float>
The distance the actor must be within from the target. Negative values mean the actor must not be within this distance. 0 means ignore this value.
Player distance (from Actor) (PlayerActorProximity) <float>
The distance the player must be within from the actor. Negative values mean the player must not be within this distance. 0 means ignore this value.
Player distance from Target (PlayerTargetProximity) <float>
The distance the player must be within from the Target. Negative values the player must not be within this distance. 0 means ignore this value.
Player FOV for Actor (PlayerActorFOV) <float>
Specify width of view cone in degrees. Negative values mean the Actor must not be in this view cone.
Player FOV for Target (PlayerTargetFOV) <float>
Specify width of view cone in degrees. Negative values mean the target must not be in this view cone.
Player FOV to actor is a true view cone (PlayerActorFOVTrueCone) <choices>
Player's view cone is evaluated as a true cone, not pie slice.
  • 0: No - Tall pie slice (Ignores the Z position of things being looked at. Could potentially include objects directly above or below the player even if player can't see them on the screen.)
  • 1: Yes - True view cone (See objects by an actual cone)
Player FOV to target is a true view cone (PlayerTargetFOVTrueCone) <choices>
Player's view cone is evaluated as a true cone, not pie slice.
  • 0: No - Tall pie slice (Ignores the Z position of things being looked at. Could potentially include objects directly above or below the player even if player can't see them on the screen.)
  • 1: Yes - True view cone (See objects by an actual cone)
Player has LOS to Actor (PlayerActorLOS) <choices>
Checks that the player has a clear line of sight to the Actor.
  • 0: No
  • 1: Yes
  • 2: Don't care
Player has LOS to Target (PlayerTargetLOS) <choices>
Checks that the player has a clear line of sight to the Target.
  • 0: No
  • 1: Yes
  • 2: Don't care
Player in Vehicle (PlayerInVehicle) <choices>
Checks if player is in a vehicle.
  • 0: No
  • 1: Yes
  • 2: Don't care
Player blocking Actor (PlayerBlockingActor) <choices>
Checks that the player is blocking the Actor's path.
  • 1: No
  • 2: Yes
  • 3: Don't care
Required Time (RequiredTime) <float>
Duration of time that all the conditions must be true for the entity to consider them fulfilled.
Minimum State (MinimumState) <choices>
Minimum readiness state of the Actor - if for example alert is set, the conditions will not be met if the NPC is idle.
  • 1: Idle
  • 2: Alert
  • 3: Combat
Maximum State (MaximumState) <choices>
Maximum readiness state of the Actor - if for example alert is set, the conditions will not be met if the NPC is in combat.
  • 1: Idle
  • 2: Alert
  • 3: Combat
Minimum time out (MinTimeout) <float>
Minimum time after the entity is enabled/spawned, before OnConditionsTimeout is fired. 0 means no timing out.
Maximum time out (MaxTimeout) <float>
Maximum time after the entity is enabled/spawned, before OnConditionsTimeout is fired. If you don't specify this, conditions will time out at exactly Minimum time out. If you DO specify this, timeout will occur randomly between the minimum and maximum.)
Start Disabled (StartDisabled) <boolean>
Stay inactive until Enabled.

Inputs[edit | edit source]

Enable
Makes the entity active.
Disable
Makes the entity inactive.

Outputs[edit | edit source]

OnConditionsSatisfied
Fires when all conditions have been satisfied. When this fires, the entity will then disable itself. Send the Enable input to check conditions again.
OnConditionsTimeout
Fires when conditions are taking too long to be satisfied. Time to wait is determined by the Minimum and Maximum time out keyvalues. When this fires, the entity will then disable itself. Send the Enable input to check conditions again.
NoValidActors
Fires if/when there are no matching actors in the map.