From Valve Developer Community
Jump to: navigation, search
Ai goal lead.png
ai_goal_lead_weapon is a point entity available in all Source games. This is a version of ai_goal_lead that requires the player to have the specified weapon before the Actor(s) will lead the player to their target. A good example of its use is in Half-Life 2 on d2_coast_11 when the vortigaunt tells the player to pick up the bugbait.
Bug: In the aforementioned use, if the player does not collect the bugbait in a certain amount of time, the game will automatically give it to them. The weapon given is hardcoded to be weapon_bugbait however. The only workaround is to Kill the weapon_bugbait entity immediately when it's given. See line 541 in ai_behavior_lead.cpp. The behavior is present in Alien Swarm's code as well, but the bugbait is not a weapon available in that game at least.

This entity is not available in <Left 4 Dead> <Left 4 Dead 2>.

In code, it is represented by class CAI_LeadGoal_Weapon, defined in ai_behavior_lead.cpp.



  • 1: No def success
  • 2: No def failure
  • 4: Use goal facing

To do: Clarify what these do?


Weapon (WeaponName) <choices>
Weapon Name. Turn off SmartEdit to insert any weapon classname (e.g. weapon_crowbar)
  • 1: Bugbait
  • 2: SMG1
  • 3: AR2
Missing weapon concept modifier (MissingWeaponConceptModifier) <string>
To do: add description


Target Entity (goal) <targetname>
The name of the entity that the NPC will lead the player to (i.e. an info_target).
Point to wait at if the target's not visible (WaitPointName) <targetname>
If the NPC loses line-of-sight to the player, it will return to this entity (i.e. an info_target).
Wait until player gets this close (WaitDistance) <float>
The player must be within this distance of the NPC before the NPC initially begins leading them.
Lead Distance (LeadDistance) <float>
The player is considered to be too far behind if they're beyond this distance. Past this distance, the leader will nag the player to hurry up.
Retrieve Distance (RetrieveDistance) <float>
The distance from the player that the NPC should return to when retrieving a lagging player. Must be between ('Lead Distance' + 24) and ('Lead Distance' * 4) to avoid the leader ping-ponging.
Success Distance (SuccessDistance) <float>
The distance from the player (to the NPC) that the player must be within for the Lead to succeed, once the NPC has reached the goal. If set to 0, it'll use the lead distance instead (for legacy support).
Run instead of Walk (Run) <choices>
Should the NPC run instead of walk?
  • 1: No
  • 2: Yes
Retrieve player? (Retrieve) <choices>
Retrieve player?
  • 1: No, just idle and wait
  • 2: Yes, move to retrieve
Before Coming Back, Wait for Speech? (ComingBackWaitForSpeak) <choices>
Before Coming Back, Wait for Speech?
  • 1: No, come back while speaking
  • 2: Yes, wait for speech to finish
On Retrieve, Wait for Speech? (RetrieveWaitForSpeak) <choices>
On Retrieve, Wait for Speech?
  • 1: No, start leading while speaking
  • 2: Yes, wait for speech to finish
Speak start greeting? (DontSpeakStart) <choices>
On Retrieve, Wait for Speech?
  • 1: No, don`t speak the greeting
  • 2: Yes, speak the greeting
Leading during combat? (LeadDuringCombat) <choices>
Leading during combat?
  • 1: No. Stop to fight, resume leading when safe
  • 2: Yes, lead while fighting.
Gag leader? (GagLeader) <choices>
  • 1: No. Speak lead concepts normally, respecting other lead speech settings.
  • 2: Yes, don't speak any lead concepts at all, overriding all other lead speech settings.
Attract player concept modifier (AttractPlayerConceptModifier) <string>
Appended to the keyvalues passed into the response rules when the TLK_LEAD_ATTRACTPLAYER concept is spoken.
Player wait over concept modifier (WaitOverConceptModifier) <string>
Appended to the keyvalues passed into the response rules when the TLK_LEAD_WAITOVER concept is spoken.
Arrival concept modifier (ArrivalConceptModifier) <string>
Appended to the keyvalues passed into the response rules when the TLK_LEAD_ARRIVAL concept is spoken.
Post-arrival concept modifier (PostArrivalConceptModifier) <string>
Confirm:Seems to not be fully implemented?
Success concept modifier (SuccessConceptModifier) <string>
Appended to the keyvalues passed into the response rules when the TLK_LEAD_SUCCESS concept is spoken.
Failure concept modifier (FailureConceptModifier) <string>
Appended to the keyvalues passed into the response rules when the lead_fail concept is spoken.
Coming Back concept modifier (ComingBackConceptModifier) <string>
Appended to the keyvalues passed into the response rules when the TLK_LEAD_RETRIEVE concept is spoken. Spoken as the NPC starts returning to the player to retrieve them.
Retrieve concept modifier (RetrieveConceptModifier) <string>
Appended to the keyvalues passed into the response rules when the TLK_LEAD_COMINGBACK concept is spoken. Spoken when NPC has finally reached the player to retrieve them.


Classname (classname) <string>
The classname defines the type of entity. Classnames can be changed using AddOutput, which will influence how the engine deals with the entity in certain circumstances.
Name (targetname) <string>
The name that other entities refer to this entity by.
Global Entity Name (globalname) <string>
Name by which this entity is linked to another entity in a different map. When the player transitions to a new map, entities in the new map with globalnames matching entities in the previous map will have the previous map's state copied over their state.
Parent (parentname) <targetname>
Specifies a movement parent. An entity will maintain its initial offset from its parent. An attachment point can be added to the end of the name, separated by a comma. Every entity can be parented, even point entities. Entities which are parented will be forced to transition to the next map, such as from a trigger_transition. Some entities which aren't intended to be parented may not function correctly. phys_constraint can be used as a workaround to parenting.
Origin (X Y Z) (origin) <coordinates>
The position of this entity's center in the world. Rotating entities typically rotate around their origin.
Pitch Yaw Roll (X Y Z) (angles) <angle>
This entity's orientation in the world. Pitch is rotation around the Y axis, yaw is the rotation around the Z axis, roll is the rotation around the X axis.
Note:This works on brush entities, although Hammer doesn't show the new angles.
Flags (spawnflags) <integer>
Toggles features of an entity, its specific number is determined by the combination of flags added.
Response Contexts (ResponseContext) <string>
Pre-defined response system contexts for this entity. Format is key:value,key:value,.... Contexts may be filtered.
Effects (effects) <integer> !FGD
Combination of effect flags to use.
Local Time (ltime) <float> !FGD
The local time of the entity, independent of the global clock. Used mainly for physics calculations.
Next Think (nextthink) <float> !FGD
Amount of time before the entity thinks again.
Hammer ID (hammerid) <integer> !FGD
The entity's Hammer ID. Mainly used by plugins and debugging commands, such as ent_keyvalue. Can be manually assigned with the "hammerid" or "id" keyvalue. Entities spawned at run-time are not assigned any Hammer ID.
Disable for Xbox 360 (disableX360) <boolean> (New with Left 4 Dead 2) !FGD
If Yes, disables this entity on the Xbox 360 version of Source.
Entity Scripts (vscripts) <scriptlist> (New with Left 4 Dead 2)
Space delimited list of VScript files (without file extension) that are executed after all entities have spawned. The scripts are all executed in the same script scope, later ones overwriting any identical variables and functions.
Script think function (thinkfunction) <string> (New with Left 4 Dead 2)
Name of a function in this entity's script which will be called automatically every 100 milliseconds (ten times a second) for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call. Try to avoid expensive operations in this function, as it may cause performance problems.
Lag Compensation (LagCompensate) <boolean> (New with Left 4 Dead 2) !FGD
Set to Yes to lag compensate this entity. Should be used very sparingly!
Is Automatic-Aim Target (is_autoaim_target) <boolean> (New with Counter-Strike: Global Offensive) !FGD
If set to 1, this entity will slow down aiming movement for consoles and joystick controllers when the entity is under the crosshairs.



Notify success of leading. Not required, use only if the standard code for detecting success does not meet your needs or fails.
Notify failure of leading.
Note:Not implemented.


Removes this entity and any entities parented to it from the world.
Functions the same as Kill, although this entity and any entities parented to it are killed on the same frame.
SetParent  <string>
Move with this entity. See Entity Hierarchy (parenting).
SetParentAttachment  <string>
Change this entity to attach to a specific attachment point on its parent. The entity will teleport so that the position of its root bone matches that of the attachment. Entities must be parented before being sent this input.
SetParentAttachmentMaintainOffset  <string>
As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.
Removes this entity from the the movement hierarchy, leaving it free to move independently.
AddOutput  <string>
Evaluates a keyvalue/output on this entity.
Format: <key> <value>
Format: <output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire, -1 means infinite>
FireUser1 to FireUser4
Fire the OnUser outputs; see User Inputs and Outputs.
Use  !FGD
Same as a player invoking +use; may not do anything. Can also be invoked by creating an output that does not specify an input.
This input is not included in Valve's FGDs.
DispatchEffect  <string> !FGD
Dispatches a special effect from the entity's origin. Removed and replaced entirely by the particle system since <Left 4 Dead>.
DispatchResponse  <string> !FGD
Dispatches a response to the entity. See Response and Concept.
AddContext  <string>
Adds to the entity's list of response contexts. Format is <key>:<value>.
RemoveContext  <string>
Remove a context from this entity's list. The name should match the key of an existing context.
ClearContext  <string>
Removes all contexts from this entity's list.
RunScriptFile  <script> (New with Left 4 Dead 2)
Execute a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.
RunScriptCode  <string> (New with Left 4 Dead 2)
Execute a string of VScript source code in the scope of the entity receiving the input. String quotation may be needed when fired via console.
Bug:  In <Left 4 Dead 2>, the code is executed in the script scope of the entity that fires the output, not the one receiving the input.
Warning: Never try to pass string parameters to a script function with this input. It will corrupt the VMF structure because of the nested quotation marks, which then must be removed manually with a text editor.
CallScriptFunction  <string> (New with Left 4 Dead 2) !FGD
Execute a VScript function in the scope of the receiving entity.
SetLocalOrigin  <coordinates> (New with Portal 2) !FGD
Send this entity to a spot in the map. If the entity is parented to something, it will be offset from the parent by this amount.
SetLocalAngles  <angles> (New with Portal 2) !FGD
Set this entity's angles.



Fired when NPC reaches the lead point. (Player may still be behind)
Fired when NPC has played out any arrival speech.
Fired when NPC achieves the goal.
Fired when NPC fails to achieve the goal.
Fired when NPC completes behavior (any post-success or fail acting is complete).


OnUser1 to OnUser4
These outputs each fire in response to the firing of the like-numbered FireUser1 to FireUser4 Input; see User Inputs and Outputs.