List of L4D2 Script Functions
Contents
- 1 Variables
- 2 Constants
- 3 Classes
- 3.1 CBaseEntity
- 3.2 CBaseAnimating
- 3.3 CBaseFlex
- 3.4 CTerrorPlayer
- 3.5 CTerrorWeapon
- 3.6 CBaseTrigger
- 3.7 AI_Response
- 3.8 CCallChainer
- 3.9 CDirector
- 3.10 CEntities
- 3.11 CEnvEntityMaker
- 3.12 CInfoItemPosition
- 3.13 CNavMesh
- 3.14 CNetPropManager
- 3.15 CScriptResponseCriteria
- 3.16 Convars
- 3.17 CPointTemplate
- 3.18 CPointScriptTemplate
- 3.19 CSimpleCallChainer
- 3.20 CPointScriptUseTarget
- 3.21 Decider
- 3.22 regexp
- 3.23 LateBinder
- 3.24 QAngle
- 3.25 Quaternion
- 3.26 Vector
- 3.27 Vector2D, Vector4D
- 4 Scripted Mode
- 5 Global Functions
- 6 See also
This list contains engine-related Squirrel variables, functions, and constants available for
Left 4 Dead 2 VScripts.
Some can be printed in-game with the scipt_help
command when the game is run in developer mode with the -dev
or -allowdebug
parameters. Others have been found from data mining, for example with script g_ModeScript.DeepPrintTable(getroottable())
, and from the Expanded Mutation System documentation.
Variables
Instance | Type | Description |
---|---|---|
Convars
|
Convars
|
Provides an interface to read and change the values of console variables. |
Director
|
CDirector
|
Provides a limited interface to the Director. |
DirectorScript
|
table | Script scope for Director scripts. Contains the active DirectorOptions table. |
Documentation
|
table | Contains the printed strings from the script_help command.
|
Entities
|
CEntities
|
Provides access to currently spawned entities. |
g_ClearoutTable
|
table (null )
|
|
g_MapScript
|
table | Script scope for map specific vscripts. It also contains a lot of utility functions. |
g_ModeScript
|
table | Script scope for mode specific vscripts. Only fully available in Scripted Mode. |
g_RoundState
|
table | |
g_rr
|
table | |
NavMesh
|
CNavMesh
|
Provides a method to unblock the rescue vehicle. |
NetProps
|
CNetPropManager
|
Allows reading and updating the network properties of an entity. |
print_indent
|
integer | |
_PublishedHelp
|
table | |
ResponseCriteria
|
CScriptResponseCriteria
|
Allows reading the response criteria of an entity. |
ScriptDebugTraceAllOn
|
bool | |
ScriptDebugTraces
|
table | |
ScriptDebugText
|
array | |
ScriptDebugTextFilters
|
table | |
ScriptDebugTextIndent
|
integer | |
ScriptDebugWatches
|
array | |
ScriptEventCallbacks
|
table |
Constants
Instance | Type | Description |
---|---|---|
_charsize_
|
integer | |
_floatsize_
|
integer | |
_intsize_
|
integer | |
_version_
|
string | The version of squirrel. |
_versionnumber_
|
integer | The version of squirrel as an integer. |
RAND_MAX
|
integer | |
SPAWN_FLAGS
|
table |
Classes
CBaseEntity
This is a script handle class for entities. All entities spawned have a script handle using this or one of its subclasses.
All script handles in-game are accessible from Entities. Entity Scripts can use self
to access their own script handle.
Methods
Function | Signature | Description |
---|---|---|
__KeyValueFromInt
|
bool __KeyValueFromInt(string key, int value)
|
Sets an entity Keyvalue from an integer. This simply changes the value without executing any code that may be needed for the entity to process the Keyvalue, so there may be unintended side effects. |
__KeyValueFromFloat
|
bool __KeyValueFromFloat(string key, float value)
|
Sets an entity Keyvalue from a float. This simply changes the value without executing any code that may be needed for the entity to process the Keyvalue, so there may be unintended side effects. |
__KeyValueFromString
|
bool __KeyValueFromString(string key, string value)
|
Sets an entity Keyvalue from a string. This simply changes the value without executing any code that may be needed for the entity to process the Keyvalue, so there may be unintended side effects. |
__KeyValueFromVector
|
bool __KeyValueFromVector(string key, Vector value)
|
Sets an entity Keyvalue from a Vector. This simply changes the value without executing any code that may be needed for the entity to process the Keyvalue, so there may be unintended side effects. |
ApplyAbsVelocityImpulse
|
void ApplyAbsVelocityImpulse(Vector impulse)
|
Apply a Velocity Impulse as a world space impulse vector. |
ApplyLocalAngularVelocityImpulse
|
void ApplyLocalAngularVelocityImpulse(Vector impulse)
|
Apply an Angular Velocity Impulse in entity local space. The direction of the input vector is the rotation axis, and the length is the magnitude of the impulse. |
ConnectOutput
|
void ConnectOutput(string output, string function)
|
Adds an I/O connection that will call the named function when the specified output fires. |
DisconnectOutput
|
void DisconnectOutput(string output, string function)
|
Removes a connected script function from an I/O event. |
FirstMoveChild
|
handle FirstMoveChild()
|
Returns the first entity parented to this one. |
GetAngles
|
QAngle GetAngles()
|
Returns the orientation of the entity in the world. |
GetBaseVelocity
|
Vector GetBaseVelocity()
|
Get Base? velocity To do |
GetClassname
|
string GetClassname()
|
Returns the entity class. This includes player and infected .
|
GetContext
|
variable GetContext(string name)
|
Looks up a response context and returns it if available. May return string, float, or null (if the context isn't found). |
GetEntityHandle
|
unknown GetEntityHandle()
|
Get a C++ EHANDLE reference of the entity. This is an opaque type not directly usable by Squirrel, not a normal script handle. |
GetEntityIndex
|
int GetEntityIndex()
|
Returns the entity index. This is the same type of index used in most game events. |
GetForwardVector
|
Vector GetForwardVector()
|
Get the forward vector of the entity. |
GetHealth
|
int GetHealth()
|
Returns the current health of the entity (does not include survivor temporary health). |
GetLocalAngles
|
QAngle GetLocalAngles()
|
Returns the orientation of the entity relative to it's parent or attachment point. |
GetLocalAngularVelocity
|
QAngle GetLocalAngularVelocity()
|
Maybe local angvel |
GetLocalOrigin
|
Vector GetLocalOrigin()
|
Returns the origin of the entity relative to it's parent or attachment point. |
GetLocalVelocity
|
Vector GetLocalVelocity()
|
Get Entity relative velocity |
GetMaxHealth
|
int GetMaxHealth()
|
Returns the maximum health of the entity. |
GetModelName
|
string GetModelName()
|
Returns the file name of the model used by the entity (if applicable). |
GetMoveParent
|
handle GetMoveParent()
|
If in hierarchy, retrieves the entity's parent |
GetName
|
string GetName()
|
Returns the targetname of the entity. |
GetOrigin
|
Vector GetOrigin()
|
Returns the origin of the entity in the world. |
GetOwnerEntity
|
handle GetOwnerEntity()
|
Get the owner entity, if there is one. |
GetPreTemplateName
|
string GetPreTemplateName()
|
Get the entity name stripped of template unique decoration. |
GetRootMoveParent
|
handle GetRootMoveParent()
|
If in hierarchy, walks up the hierarchy to find the root parent. |
GetScriptId
|
string GetScriptId()
|
Retrieve the unique identifier used to refer to the entity within the scripting system. |
GetScriptScope
|
handle GetScriptScope()
|
Retrieve the table storing the Entity Script associated with this entity. |
GetVelocity
|
Vector GetVelocity()
|
Returns a local velocity Vector. |
IsPlayer
|
bool IsPlayer()
|
Does this entity belong to the player class. |
IsValid
|
bool IsValid()
|
Whether the handle belongs to a valid entity. |
Kill
|
void Kill()
|
Removes the entity. |
NextMovePeer
|
handle NextMovePeer()
|
Returns the next child of this entity's parent. Used to continue iteration from FirstMoveChild(). |
OverrideFriction
|
void OverrideFriction(float duration, float friction)
|
Takes duration, value for a temporary override |
PrecacheModel
|
void PrecacheModel(string filename)
|
|
PrecacheScriptSound
|
void PrecacheScriptSound(string)
|
To do: Is this for raw files or soundscripts? |
SetAngles
|
void SetAngles(QAngle direction)
|
Sets the orientation of the entity. |
SetContext
|
void SetContext(string name, string value, float duration)
|
Stores any key/value pair in this entity's dialog contexts. Value must be a string. Will last for duration (set -1 to mean 'forever'). |
SetContextNum
|
void SetContextNum(string name, float value, float duration)
|
Stores any key/value pair in this entity's dialog contexts. Value must be a number (int or float). Will last for duration (set -1 to mean 'forever'). |
SetForwardVector
|
void SetForwardVector(Vector direction)
|
Set the orientation of the entity to have this forward vector. |
SetFriction
|
void SetFriction(float friction)
|
Set PLAYER friction, ignored for objects. |
SetGravity
|
void SetGravity(float gravity)
|
Set PLAYER gravity, ignored for objects. |
SetHealth
|
void SetHealth(int health)
|
Changes the health value of the entity. Does not check whether to kill players. |
SetLocalAngles
|
void SetLocalAngles(QAngle direction)
|
Sets the entity orientation relative to it's parent or attachment point. |
SetLocalOrigin
|
void SetLocalOrigin(Vector position)
|
Sets the entity position relative to it's parent or attachment point. |
SetMaxHealth
|
void SetMaxHealth(int health)
|
Changes the maximum health value of the entity. |
SetModel
|
void SetModel(string modelName)
|
Changes the model of the entity (if applicable). |
SetOrigin
|
void SetOrigin(Vector position)
|
Sets the world entity position. |
SetVelocity
|
void SetVelocity(Vector velocity)
|
Sets the entity velocity. |
TakeDamage
|
void TakeDamage(float damage, int damageType, CBaseEntity attacker)
|
Damages the entity. |
ValidateScriptScope
|
bool ValidateScriptScope()
|
Ensure that an entity's script scope has been created. |
Hooks
If one of these functions are declared in an Entity Script, the entity will run this function automatically in the appropriate situation.
Function | Signature | Description |
---|---|---|
InputInputName
|
bool InputInputName()
|
Called when the entity receives an input from the I/O system. The name of the function needs to be Input followed by the name of the input in CamelCase, for example InputFireUser1 for the FireUser1 input. When the function is called, the activating and calling entities Script Handles are written to the receiving entitys Script Scope in the activator and caller variables. The function needs to return a boolean value. Setting it to true allows the entity to process the input, while false cancels it.
|
OnEntText
|
string OnEntText()
|
If ent_text is used on an entity and this function exists, it will be called every tick. Returns a string that gets displayed as part of the ent_text overlay. This is a handy feature for displaying script data on objects when you ent_text the object, or running arbitrary code (such as turning on additional debugging visualizations) is using ent_text. NOTE: ent_text_allow_script 1 must be set in order for this feature to be active. |
OnPostSpawn
|
void OnPostSpawn()
|
Called immediately after the entity spawns. This could be used to have an entity register itself with a master script, or adjusting the entity parameters in a programmatic way. |
Precache
|
void Precache()
|
Called after the script executes. Can be used to call precache functions for models and sounds on map load. |
CBaseAnimating
Extends CBaseEntity
Script handle class for animating entities such as props.
Methods
Function | Signature | Description |
---|---|---|
FindBodygroupByName
|
int FindBodygroupByName(string name)
|
Find a bodygroup ID by name. Returns -1 if the bodygroup does not exist. |
GetAttachmentAngles
|
QAngle GetAttachmentAngles(int ID)
|
Get the attachment ID's angles as a QAngle. |
GetAttachmentBone
|
int GetAttachmentBone(int ID)
|
Get the attachment ID's parent bone index. |
GetAttachmentOrigin
|
Vector GetAttachmentOrigin(int ID)
|
Get the attachment ID's origin as a Vector. |
GetBodygroup
|
int GetBodygroup(int ID)
|
Get the bodygroup value by bodygroup ID. |
GetBodygroupName
|
string GetBodygroupName(int ID)
|
Get the bodygroup ID's name. |
GetBodygroupPartName
|
string GetBodygroupPartName(int group, int part)
|
Get name by group and part. |
GetBodygroupName
|
string GetBodygroupName(int ID)
|
Get the bodygroup ID's name. |
GetBoneAngles
|
QAngle GetBoneAngles(int ID)
|
Get the bone ID's angles as a QAngle. |
GetBoneOrigin
|
Vector GetBoneOrigin(int ID)
|
Get the bone ID's origin Vector. |
GetModelScale
|
float GetModelScale()
|
Get the model scale. |
GetSequence
|
int GetSequence()
|
Get the currently playing sequence ID. |
GetSequenceActivityName
|
string GetSequenceActivityName(int ID)
|
Get the activity name for a sequence by sequence ID. |
GetSequenceDuration
|
float GetSequenceDuration(int ID)
|
Get a sequence duration in seconds by sequence ID. |
GetSequenceName
|
string GetSequenceName(int ID)
|
Get a sequence name by sequence ID. |
IsSequenceFinished
|
bool IsSequenceFinished()
|
Returns true if the current sequence has finished playing. |
LookupActivity
|
int LookupActivity(string activity)
|
Get the named activity index. Returns -1 if the activity does not exist. |
LookupAttachment
|
int LookupAttachment(string name)
|
Get the named attachment index. Returns 0 if the attachment does not exist. |
LookupBone
|
int LookupBone(string bone)
|
Get the named bone index. Returns -1 if the bone does not exist. |
LookupSequence
|
int LookupSequence(string name)
|
Looks up a sequence by sequence name or activity name. Returns -1 if the sequence does not exist. |
ResetSequence
|
void ResetSequence(int ID)
|
Reset a sequence by sequence ID. If the ID is different than the current sequence, switch to the new sequence. |
SetBodygroup
|
void SetBodygroup(int ID, int value)
|
Set the bodygroup by ID. |
SetModelScale
|
void SetModelScale(float scale, float change_duration)
|
Changes a model's scale over time. Set the change duration to 0.0 to change the scale instantly. |
SetPoseParameter
|
float SetPoseParameter(int ID, float value)
|
Sets a pose parameter value. Returns the effective value after clamping or looping. |
SetSequence
|
void SetSequence(int ID)
|
Plays a sequence by sequence ID. |
CBaseFlex
Extends CBaseAnimating
Animated characters who have vertex flex capability (e.g., facial expressions).
Methods
Function | Signature | Description |
---|---|---|
GetCurrentScene
|
handle GetCurrentScene()
|
Returns the instance of the oldest active scene entity (if any). |
GetSceneByIndex
|
handle GetSceneByIndex(int index)
|
Returns the instance of the scene entity at the specified index. |
PlayScene
|
float PlayScene(string sceneFile, float delay)
|
Play the specified .vcd file. |
CTerrorPlayer
Extends CBaseFlex
Script handle class for player entities. Both survivors and special infected belong to this.
Methods
Function | Signature | Description |
---|---|---|
DropItem
|
void DropItem(string classname)
|
Make the player drop an item/weapon by classname. |
Extinguish
|
void Extinguish()
|
Extinguish a burning player. |
EyeAngles
|
QAngle EyeAngles()
|
Returns the direction the player is looking. |
EyePosition
|
Vector EyePosition()
|
Returns the players eye position in the world. |
GetActiveWeapon
|
handle GetActiveWeapon()
|
Get the player's active weapon entity. |
GetButtonMask
|
int GetButtonMask()
|
Returns a bitfield of currently pressed buttons. Recognized buttons are: IN_ATTACK, IN_ATTACK2, IN_JUMP, IN_DUCK, IN_FORWARD, IN_BACK, IN_USE, IN_MOVELEFT, IN_MOVERIGHT, IN_RELOAD
|
GetHealthBuffer
|
int GetHealthBuffer()
|
Returns the current temporary health of a survivor. To do: Does temp health work on SI? |
GetNetworkIDString
|
string GetNetworkIDString()
|
Get the player's network (i.e. Steam) ID. |
GetPlayerName
|
string GetPlayerName()
|
Get the players name. |
GetPlayerUserId
|
int GetPlayerUserId()
|
Get the players userID. |
GetSenseFlags
|
int GetSenseFlags()
|
Get the current bits for the bot sense flags: BOT_CANT_SEE, BOT_CANT_HEAR, BOT_CANT_FEEL
|
GetSurvivorSlot
|
int GetSurvivorSlot()
|
Get the player's slot number. |
GetZombieType
|
int GetZombieType()
|
If an infected, find out what type. Recognized ZombieTypes are: Smoker = 1, Boomer = 2, Hunter = 3, Spitter = 4, Jockey = 5, Charger = 6, Witch = 7, Tank = 8, Survivor = 9 |
GiveAmmo
|
void GiveAmmo(int amount)
|
Adds ammo for the player's primary weapon ammo pool. |
GiveItem
|
void GiveItem(string itemname)
|
Give an item/weapon by name. Uses the same names as the give console command(health, katana, rifle_ak47 , etc.).
|
GiveItemWithSkin
|
void GiveItemWithSkin(string classname, int skin)
|
Gives the player a skinned weapon. |
GiveUpgrade
|
void GiveUpgrade(int upgradeType)
|
Give a primary weapon upgrade: UPGRADE_INCENDIARY_AMMO, UPGRADE_EXPLOSIVE_AMMO, UPGRADE_LASER_SIGHT
|
HitWithVomit
|
void HitWithVomit()
|
Target a player with a boomer vomit attack. |
IsDead
|
bool IsDead()
|
Returns a bool indicating dead state. |
IsDying
|
bool IsDying()
|
Returns a bool indicating dying state. |
IsIncapacitated
|
bool IsIncapacitated()
|
Returns a bool indicating incapacitated state. |
IsHangingFromLedge
|
bool IsHangingFromLedge()
|
Returns a bool indicating ledge hang state. |
IsGhost
|
bool IsGhost()
|
Returns a bool indicating ghost infected state. |
IsOnFire
|
bool IsOnFire()
|
Returns a bool indicating if a player is on fire. |
IsSuppressingFallingDamage
|
bool IsSuppressingFallingDamage()
|
Returns a bool indicating if falling damage is currently suppressed. |
IsSurvivor
|
bool IsSurvivor()
|
On the survivor team (Otherwise, infected). |
RemoveUpgrade
|
void RemoveUpgrade(int upgradeType)
|
Remove a primary weapon upgrade: UPGRADE_INCENDIARY_AMMO, UPGRADE_EXPLOSIVE_AMMO, UPGRADE_LASER_SIGHT
|
ReviveByDefib
|
void ReviveByDefib()
|
Revive a dead player by defib. |
ReviveFromIncap
|
void ReviveFromIncap()
|
Revive an incapacitated player. |
SetFriction
|
void SetFriction(int friction)
|
Set player friction. |
SetGravity
|
void SetGravity(int gravity)
|
Set player gravity. |
SetHealthBuffer
|
void SetHealthBuffer(float health)
|
Sets the temporary health of a survivor. Does not incapacitate or kill when set to zero. |
SetReviveCount
|
void SetReviveCount(int count)
|
Sets the number of times a survivor has been revived, and updates third-strike state and effects. |
SetSenseFlags
|
void SetSenseFlags(int flags)
|
Set the current bits for the bot sense flags: BOT_CANT_SEE, BOT_CANT_HEAR, BOT_CANT_FEEL
|
SnapEyeAngles
|
void SnapEyeAngles(QAngle angles)
|
Sets the view angles. Supports rolling the view. |
Stagger
|
void Stagger(Vector position)
|
Stagger a player away from a position. Use Vector(0,0,0) to just stagger forward. |
SwitchToItem
|
bool SwitchToItem(string classname)
|
Make the player switch to an item/weapon by classname. Returns true if the switch was performed. |
TryGetPathableLocationWithin
|
Vector TryGetPathableLocationWithin(float radius)
|
Get a location on the nav the player can path to within the desired radius. |
UseAdrenaline
|
void UseAdrenaline(float duration)
|
Causes Adrenaline's speed and visual effect, no change to health. |
CTerrorWeapon
Extends CBaseAnimating
Methods
Function | Signature | Description |
---|---|---|
Clip1
|
int Clip1()
|
Get the current amount of ammo in weapon's primary clip. |
Clip2
|
int Clip2()
|
Get the current amount of ammo in weapon's secondary clip. |
GetDefaultClip1
|
int GetDefaultClip1()
|
Get the default amount of ammo placed in the primary clip when a new weapon is picked up. |
GetDefaultClip2
|
int GetDefaultClip2()
|
Get the default amount of ammo placed in the secondary clip when a new weapon is picked up. |
GetMaxClip1
|
int GetMaxClip1()
|
Get the max amount of ammo the primary clip for weapon can hold. |
GetMaxClip2
|
int GetMaxClip2()
|
Get the max amount of ammo the secondary clip for weapon can hold. |
GiveDefaultAmmo
|
void GiveDefaultAmmo()
|
Sets the current ammo count in the clips to their default values. |
Reload
|
bool Reload()
|
Forces the weapon to reload if it is not full. Returns true if the weapon had to be reloaded. |
SetClip1
|
void SetClip1(int amount)
|
Set the current amount of ammo in weapon's primary clip. |
SetClip2
|
void SetClip2(int amount)
|
Set the current amount of ammo in weapon's primary clip. |
CBaseTrigger
Extends CBaseEntity
Entity class for triggers.
Methods
Function | Signature | Description |
---|---|---|
Disable
|
void Disable()
|
Disable the trigger |
Enable
|
void Enable()
|
Enable the trigger |
IsTouching
|
bool IsTouching(handle entity)
|
Checks whether the passed entity is touching the trigger. |
AI_Response
Opaque type representing a return value from the old response system.
Methods
Function | Signature | Description |
---|---|---|
GetMatchScore
|
Relative score of this match's quality (based on number of criteria matched)). |
CCallChainer
To do
Methods
Function | Signature | Description |
---|---|---|
constructor
|
To do constructor()
|
|
PostScriptExecute
|
To do PostScriptExecute()
|
|
Call
|
To do Call()
|
Members
Instance | Type | Description |
---|---|---|
chains
|
null
|
|
prefix
|
null
|
|
scope
|
null
|
CDirector
Game Instance: Director
Provides methods for reading information and forcing events in the AI Director. To influence the Director behavior, the DirectorOptions
table is used instead.
Methods
Function | Signature | Description |
---|---|---|
ClearCachedBotQueries
|
void ClearCachedBotQueries()
|
Mark all cached bot query results as invalid. |
ForceNextStage
|
void ForceNextStage()
|
Push the ScriptedMode to next stage - i.e. request GNSS be called. |
GetAveragedSurvivorSpan
|
float GetAveragedSurvivorSpan()
|
Get the distance between the lead and trailing survivors, smoothed over time. |
GetAveragedSurvivorSpeed
|
float GetAveragedSurvivorSpeed()
|
Get the rate at which the lead survivor is moving along the flow, smoothed over time. |
GetCommonInfectedCount
|
int GetCommonInfectedCount()
|
Returns number for infected currently spawned. |
GetFurthestSurvivorFlow
|
float GetFurthestSurvivorFlow()
|
Get the maximum distance along the flow that the survivors have reached. |
GetGameMode
|
string GetGameMode()
|
Get the current game mode. If called in a mutation, it returns the current mutation, not the base mode. |
GetGameModeBase
|
string GetGameModeBase()
|
Get the current base game mode. Does not return the current mutation. |
GetHoldoutCooldownEndTime
|
To do float? GetHoldoutCooldownEndTime()
|
Get the end time of the cooldown timer. |
GetMapName
|
string GetMapName()
|
Get the current map name. |
GetPendingMobCount
|
int GetPendingMobCount()
|
Returns the number of infected waiting to spawn. |
GetSurvivorSet
|
int GetSurvivorSet()
|
Get the current survivor set. L4D1 Survivors = 1, L4D2 Survivors = 2. |
HasAnySurvivorLeftSafeArea
|
bool HasAnySurvivorLeftSafeArea()
|
True when one or more survivors have left the starting safe area. |
IsAnySurvivorInCombat
|
bool IsAnySurvivorInCombat()
|
Returns true if any survivor recently dealt or took damage. |
IsPlayingOnConsole
|
bool IsPlayingOnConsole()
|
Return true if game is running on a console (such as Xbox 360). |
IsSinglePlayerGame
|
bool IsSinglePlayerGame()
|
Return true if game is in single player. |
IsValid
|
bool IsValid()
|
Whether the handle belongs to a valid entity. |
IsTankInPlay
|
bool IsTankInPlay()
|
Returns true if any tanks are aggro on survivors. |
L4D1SurvivorGiveItem
|
void L4D1SurvivorGiveItem()
|
Let the L4D1 survivors know that now is a good time to give the players an item. |
PlayMegaMobWarningSounds
|
void PlayMegaMobWarningSounds()
|
Plays a horde scream sound and asks survivors to speak incoming horde lines. |
ResetMobTimer
|
void ResetMobTimer()
|
Trigger a mob as soon as possible when in BUILD_UP .
|
ResetSpecialTimers
|
void ResetSpecialTimers()
|
Reset all special timers (by type and by slot) so that hopefully mobs will spawn asap. |
SetHoldoutCooldownEndTime
|
void SetHoldoutCooldownEndTime(float time? To do)
|
|
UserDefinedEvent1
|
void UserDefinedEvent1()
|
These trigger the appropriate output from the info_director entity when called. |
UserDefinedEvent2
|
void UserDefinedEvent2()
|
|
UserDefinedEvent3
|
void UserDefinedEvent3()
|
|
UserDefinedEvent4
|
void UserDefinedEvent4()
|
|
WarpAllSurvivorsToBattlefield
|
void WarpAllSurvivorsToBattlefield()
|
Warp all Survivors to the battlefield. |
WarpAllSurvivorsToCheckpoint
|
void WarpAllSurvivorsToCheckpoint()
|
Warp all Survivors to the exit checkpoint. |
WarpAllSurvivorsToFinale
|
void WarpAllSurvivorsToFinale()
|
Warp all Survivors to the finale radio. |
CEntities
Game Instance: Entities
An interface to find and iterate over the script handles for the entities in play.
To iterate over a set of entities, pass null
to the previous argument in the appropriate method to start an iteration, or reference to a previously found entity to continue a search.
Methods
Function | Signature | Description |
---|---|---|
FindByClassname
|
handle FindByClassname(handle previous, string class)
|
Find entities by class name. |
FindByClassnameNearest
|
handle FindByClassnameNearest(string class, Vector origin, float radius)
|
Find the entity with the given class name nearest to the specified point. |
FindByClassnameWithin
|
handle FindByClassnameWithin(handle previous, string class, Vector origin, float radius)
|
Find entities by class name within a radius. |
FindByModel
|
handle FindByModel(handle previous, string filename)
|
Find entities by model name. |
FindByName
|
handle FindByName(handle previous, string name)
|
Find entities by name. |
FindByNameNearest
|
handle FindByNameNearest(string name, Vector origin, float radius)
|
Find entities by name nearest to a point. |
FindByNameWithin
|
handle FindByNameWithin(handle previous, string name, Vector origin, float radius)
|
Find entities by name within a radius. |
FindByTarget
|
handle FindByTarget(handle previous, string targetname)
|
Find entities by its target. |
FindInSphere
|
handle FindInSphere(handle previous, Vector origin, float radius)
|
Find entities within a radius. |
First
|
handle First()
|
Begin an iteration over the list of entities. |
Next
|
handle Next(handle previous)
|
Continue an iteration over the list of entities, providing reference to a previously found entity. |
IsValid
|
bool IsValid()
|
Whether the handle belongs to a valid entity. |
CEnvEntityMaker
Extends CBaseEntity
Script handle class for env_entity_maker.
Methods
Function | Signature | Description |
---|---|---|
SpawnEntity
|
void SpawnEntity()
|
Create an entity at the location of the maker. |
SpawnEntityAtEntityOrigin
|
void SpawnEntityAtEntityOrigin(CBaseEntity entity)
|
Create an entity at the location of a specified entity instance. |
SpawnEntityAtLocation
|
void SpawnEntityAtLocation(Vector origin, QAngle orientation)
|
Create an entity at a specified location and orientation. |
SpawnEntityAtNamedEntityOrigin
|
void SpawnEntityAtNamedEntityOrigin(string name)
|
Create an entity at the location of a named entity. |
CInfoItemPosition
Extends CBaseEntity
Script handle class for info_item_position.
Methods
Function | Signature | Description |
---|---|---|
GetGroup
|
Get the group number for this item position | |
GetRarity
|
Get the rarity for this item position. | |
GetReplaceParm
|
Get a replacement parameter by index. | |
SetGroup
|
Set the group number for this item position. | |
SetRarity
|
Set the rarity for this item position. |
Game Instance: NavMesh
Methods
Function | Signature | Description |
---|---|---|
IsValid
|
bool IsValid()
|
Whether the handle belongs to a valid entity. To do: Does the nav mesh have an entity? |
UnblockRescueVehicleNav
|
void UnblockRescueVehicleNav()
|
Unblock the rescue vehicle nav areas so bots can path through them. |
CNetPropManager
Game Instance: NetProps
Allows reading and updating the network properties of an entity.
If the entity has multiple netprops with the same name, the data table name can be prepended with a dot to specify which one to use (e.g. "m_itTimer.m_timestamp").

Methods
Function | Signature | Description |
---|---|---|
GetPropArraySize
|
int GetPropArraySize(CBaseEntity entity, string propertyName)
|
Returns the size of an netprop array, or -1. |
GetPropEntity
|
CBaseEntity GetPropEntity(CBaseEntity entity, string propertyName)
|
Reads an EHANDLE valued netprop (21 bit integer). Returns the script handle of the entity. |
GetPropEntityArray
|
CBaseEntity GetPropEntityArray(CBaseEntity entity, string propertyName, int arrayElement)
|
Reads an EHANDLE valued netprop (21 bit integer) from an array. Returns the script handle of the entity. |
GetPropFloat
|
float GetPropFloat(CBaseEntity entity, string propertyName)
|
Reads a float valued netprop. |
GetPropFloatArray
|
float GetPropFloatArray(CBaseEntity entity, string propertyName, int arrayElement)
|
Reads a float valued netprop from an array. |
GetPropInt
|
int GetPropInt(CBaseEntity entity, string propertyName)
|
Reads an integer valued netprop. |
GetPropIntArray
|
int GetPropIntArray(CBaseEntity entity, string propertyName, int arrayElement)
|
Reads an integer valued netprop from an array. |
GetPropString
|
string GetPropString(CBaseEntity entity, string propertyName)
|
Reads an string valued netprop. |
GetPropStringArray
|
string GetPropStringArray(CBaseEntity entity, string propertyName, int arrayElement)
|
Reads an string valued netprop from an array. |
GetPropType
|
string GetPropType(CBaseEntity entity, string propertyName)
|
Returns the name of the netprop type as a string. |
GetPropVector
|
Vector GetPropVector(CBaseEntity entity, string propertyName)
|
Reads a 3D vector valued netprop. To do: Does it work for other dimensions too? |
GetPropVectorArray
|
Vector GetPropVectorArray(CBaseEntity entity, string propertyName, int arrayElement)
|
Reads a 3D vector valued netprop from an array. |
HasProp
|
bool HasProp(CBaseEntity entity, string propertyName)
|
Checks if a netprop exists. |
SetPropEntity
|
void SetPropEntity(CBaseEntity entity, string propertyName, CBaseEntity value)
|
Sets an EHANDLE valued netprop (21 bit integer) to reference the specified entity. |
SetPropEntityArray
|
void SetPropEntityArray(CBaseEntity entity, string propertyName, CBaseEntity value, int arrayElement)
|
Sets an EHANDLE valued netprop (21 bit integer) from an array to reference the specified entity. |
SetPropFloat
|
void SetPropFloat(CBaseEntity entity, string propertyName, float value)
|
Sets a netprop to the specified float. |
SetPropFloatArray
|
void SetPropFloatArray(CBaseEntity entity, string propertyName, float value, int arrayElement)
|
Sets a netprop from an array to the specified float. |
SetPropInt
|
void SetPropInt(CBaseEntity entity, string propertyName, int value)
|
Sets a netprop to the specified integer. |
SetPropIntArray
|
void SetPropInt(CBaseEntity entity, string propertyName, int value, int arrayElement)
|
Sets a netprop from an array to the specified integer. |
SetPropString
|
void SetPropString(CBaseEntity entity, string propertyName, string value)
|
Sets a netprop to the specified string. |
SetPropStringArray
|
void SetPropStringArray(CBaseEntity entity, string propertyName, string value, int arrayElement)
|
Sets a netprop from an array to the specified string. |
SetPropVector
|
void SetPropVector(CBaseEntity entity, string propertyName, Vector value)
|
Sets a netprop to the specified vector. |
SetPropVectorArray
|
void SetPropVectorArray(CBaseEntity entity, string propertyName, Vector value, int arrayElement)
|
Sets a netprop from an array to the specified vector. |
CScriptResponseCriteria
Game Instance: ResponseCriteria
Allows reading the response rules of an entity.
Methods
Function | Signature | Description |
---|---|---|
GetTable
|
void GetTable(CBaseEntity entity, table)
|
Fills the passed table with all criteria. |
GetValue
|
string GetValue(CBaseEntity entity, string criteriaName)
|
Returns a string. |
HasCriterion
|
bool HasCriterion(CBaseEntity entity, string criteriaName)
|
Returns true if the criterion exists. |
Convars
Game Instance: Convars
Provides an interface for getting and setting convars on the server.
To do: The class for this doesn't seem to be directly available.
Methods
Function | Signature | Description |
---|---|---|
GetClientConvarValue
|
string GetClientConvarValue(string name, int entindex)
|
Returns the convar value for the entindex as a string. Only works with client convars with the FCVAR_USERINFO flag. |
GetStr
|
string GetStr(string name)
|
Returns the convar as a string. May return null if no such convar. |
GetFloat
|
float GetFloat(string name)
|
Returns the convar as a float. May return null if no such convar. |
SetValue
|
void SetValue(string name, value)
|
Sets the value of the convar. Supported types are bool, int, float, string. |
CPointTemplate
Extends CBaseEntity
Script handle class for point_template.
Hooks
table PreSpawnInstance(string entityClass, string entityName)
- If this is defined, it will be called right before the entity is created, and any KeyValues returned will be assigned to the entity.
- This could be used to dynamically assign target names, colors, even models. Unfortunately, models don't work like one would think. Yes, it is possible to change that gas tank into a football model, will even keep the weapon_gascan class, but it won't behave like one.
function PreSpawnInstance( entityClass, entityName )
{
return
{
rendercolor = "0 255 0"
targetname = "mySpawnedEntity"
};
}
void PostSpawn(table entities)
- Called after the entities are spawned. A table with the handles of the spawned entities indexed by name is passed to the function. Could use this to connect outputs or do whatever needs to be done after the entity was created.
function PostSpawn( entities )
{
foreach( name, handle in entities )
{
printl( name + ": " + handle );
}
}
CPointScriptTemplate
Extends CBaseEntity
Script handle class for point_script_template.
Methods
Function | Signature | Description |
---|---|---|
AddTemplate
|
void AddTemplate(string, handle)
|
Add an entity to the template spawner. |
SetGroupSpawnTables
|
void SetGroupSpawnTables(handle, handle)
|
Cache the group spawn tables. |
CSimpleCallChainer
Seems to have the same members as CCallChainer. To do
CPointScriptUseTarget
Extends CBaseEntity
Script handle class for the point_script_use_target entity.
Methods
Function | Signature | Description |
---|---|---|
CanShowBuildPanel
|
void CanShowBuildPanel(bool showPanel)
|
Sets if the UI panel for the button is shown. |
GetUseModelName
|
string GetUseModelName()
|
Get the entity name of the prop bound to this button. |
SetProgressBarText
|
void SetProgressBarText(string text)
|
Sets the use text for the button UI. |
SetProgressBarSubText
|
void SetProgressBarText(string text)
|
Sets the subtext below the progress bar for the button UI. |
SetProgressBarFinishTime
|
void SetProgressBarFinishTime(float time)
|
Sets the total time the button takes to use. If '0', no progress bar will be displayed. |
SetProgressBarCurrentProgress
|
void SetProgressBarCurrentProgress(float time)
|
Sets the current use progress. It can be used to save the use progress when the user releases the use key. |
StopUse
|
void StopUse()
|
Stop the current use action. |
Members
These variables are only available in the Entity Script after the entity has spawned. They contain entity handles, which differ from normal script handles, and can be compared with the output of the CBaseEntity::GetEntityHandle()
method.
Instance | Type | Description |
---|---|---|
UseModelEntity
|
entity handle
|
The Use Model prop associated with this entity. |
PlayerUsingMe
|
entity handle
|
The current using player. Set to 0 if not being used. |
Hooks
These VScript methods are called on the script set in the Entity Scripts keyvalue for the point_script_use_target.
Function | Signature | Description |
---|---|---|
OnUseFinished
|
void OnUseFinished()
|
Called when the player has used this button for at least 'FinishTime' seconds. |
OnUseStart
|
bool OnUseStart()
|
Called when the player begins to use this button. Return false to disable the third-person use animation.![]() point_script_use_target cannot be interacted with, though OnUseStart() will still be ran. Use ConnectOutput() and hook a function to the OnUseStarted output instead. |
OnUseStop
|
void OnUseStop(float timeUsed)
|
Called when the player stops using this button. Passes the time this button has been used (time between StartUse and now). |
Precache
|
void Precache()
|
Called by the game engine when the entity first spawns, immediately after this script is run. |
Decider
An isolated instance of a rulescript database.
Methods
Function | Signature | Description |
---|---|---|
constructor
|
||
AddRule
|
bool AddRule(handle CRule)
|
Add a CRule object (defined in rulescript_base.nut) |
FindAllMatches
|
handle FindAllMatches(handle query, float leeway)
|
Returns an array of all matching responses. If leeway is nonzero, all results scoring within 'leeway' of the best score return. |
FindBestMatch
|
handle FindBestMatch(handle query)
|
Query the database and return the best result found. If multiple of equal score found, an arbitrary one returns. |
IsValid
|
bool IsValid()
|
Whether the object belongs to a valid entity(?). |
regexp
The built-in Squirrel class for regular expressions.
Methods
Function | Signature | Description |
---|---|---|
constructor
|
regexp()
|
|
capture
|
[table] capture(str, [start])
|
Returns an array of tables containing two indexes ("begin" and "end") of the first match of the regular expression in the string str. An array entry is created for each captured sub expressions. If no match occurs returns null. The search starts from the index start of the string, if start is omitted the search starts from the beginning of the string. |
match
|
bool match(str)
|
Returns a true if the regular expression matches the string str, otherwise returns false. |
search
|
table search(str, [start])
|
Returns a table containing two indexes ("begin" and "end") of the first match of the regular expression in the string str, otherwise if no match occurs returns null. The search starts from the index start of the string, if start is omitted the search starts from the beginning of the string. |
subexpcount
|
LateBinder
Methods
Function | Signature | Description |
---|---|---|
Begin
|
||
End
|
||
EstablishDelegation
|
||
HookRootMetamethod
|
||
UnhookRootMetamethod
|
||
RemoveDelegation
|
||
Resolve
|
Members
Instance | Type | Description |
---|---|---|
m_bindNamesStack
|
array
|
|
m_fixupSet
|
array
|
|
m_log
|
bool
|
|
m_logIndent
|
int
|
|
m_targetTable
|
table?(null)
|
QAngle
Squirrel equivalent of the C++ QAngle class.
Represents a three-dimensional orientation as Euler angles.
Has overloaded arithmetic operations with both QAngles and scalar values.
Methods
Function | Signature | Description |
---|---|---|
constructor
|
QAngle()
|
Creates a new QAngle facing the positive x-axis. |
constructor
|
QAngle(float pitch, float yaw, float roll)
|
Creates a new QAngle. |
Forward
|
Vector Forward()
|
Returns the Forward Vector of the angles. |
Left
|
Vector Left()
|
Returns the left Vector of the angles. |
Pitch
|
float Pitch()
|
Returns the pitch angle in degrees. |
Roll
|
float Roll()
|
Returns the roll angle in degrees. |
ToKVString
|
string ToKVString()
|
Returns a string with the values separated by one space. |
ToQuat
|
Quaternion ToQuat()
|
Returns a quaternion representaion of the orientation. |
Up
|
Vector Up()
|
Returns the Up Vector of the angles. |
Yaw
|
float Yaw()
|
Returns the yaw angle in degrees. |
Members
Instance | Type | Description |
---|---|---|
x
|
float
|
Pitch in degrees. |
y
|
float
|
Yaw in degrees. |
z
|
float
|
Roll in degrees. |
Quaternion
Quarternions[1] represent rotations in three-dimensional space.
Methods
Function | Signature | Description |
---|---|---|
constructor
|
Quarternion()
|
Creates a new identity quarternion. |
constructor
|
Quarternion(float x,float y,float z,float w)
|
Creates a new quarternion of the form w + xi + yj + zk .
|
Dot
|
float Dot(Quarternion factor)
|
The 4D scalar product of two quaternions. represents the angle between the quaternions in the range [1, 0]. |
Invert
|
Quarternion Invert()
|
Returns a quaternion with the complimentary rotation. |
Norm
|
Quarternion Norm()
|
Normalizes the 4D vector length. To do: What effect does this have in quaternions? |
SetPitchYawRoll
|
void SetPitchYawRoll(float pitch, float yaw, float roll)
|
Recomputes the quaternion from the supplied Euler angles. |
ToKVString
|
string ToKVString()
|
Returns a string with the values separated by one space. |
ToQAngle
|
QAngle ToQAngle()
|
Returns the angles resulting from the rotation. |
Members
Instance | Type | Description |
---|---|---|
x
|
float
|
Vector component along the i axis. |
y
|
float
|
Vector component along the j axis. |
z
|
float
|
Vector component along the k axis. |
w
|
float
|
Scalar part. |
Vector
Squirrel equivalent of the C++ Vector class.
Three-dimensional vector.
Has overloaded arithmetic operations with both Vectors and scalar values.

Methods
Function | Signature | Description |
---|---|---|
constructor
|
Vector()
|
Creates a new null vector. |
constructor
|
Vector(float x, float y, float z)
|
Creates a new vector with the specified Cartesian coordiantes. |
Cross
|
float Cross(Vector factor)
|
The vector product of two vectors. Returns a vector orthogonal to the input vectors. |
Dot
|
float Dot(Vector factor)
|
The scalar product of two vectors. |
Length
|
float Length()
|
Magnitude of the vector. |
LengthSqr
|
float LengthSqr()
|
The magnitude of the vector squared. Faster than the above method. |
Length2D
|
float Length2D()
|
Returns the magnitude of the vector on the x-y plane. |
Length2DSqr
|
float Length2DSqr()
|
Returns the square of the magnitude of the vector on the x-y plane. Faster than the above method. |
Norm
|
float Norm()
|
Seems to also return the vector length. |
Scale
|
Vector Scale(float factor)
|
Scales the vector magnitude. |
ToKVString
|
string ToKVString()
|
Returns a string without separations commas. |
tostring
|
string tostring()
|
Returns a human readable string. |
Members
Instance | Type | Description |
---|---|---|
x
|
float
|
Cartesian X axis. |
y
|
float
|
Cartesian Y axis. |
z
|
float
|
Cartesian Z axis. |
Vector2D, Vector4D
Two and four-dimensional equivalents to Vector.
Methods
Function | Signature | Description |
---|---|---|
constructor
|
VectorXD(float x, float y, ...)
|
Creates a new vector with the specified Cartesian coordiantes. |
Dot
|
float Dot(VectorXD factor)
|
The scalar product of two vectors. |
Length
|
float Length()
|
Magnitude of the vector. |
LengthSqr
|
float LengthSqr()
|
The magnitude of the vector squared. Faster than the above method. |
Norm
|
float Norm()
|
Seems to also return the vector length. |
ToKVString
|
string ToKVString()
|
Returns a string without separations commas. |
Scripted Mode
Enabling Scripted Mode makes a lot of features available in the g_ModeScript
scope.
sm_utilities.nut
Available in the g_ModeScript
scope, always loaded in.
sm_utilities contains many wrapper functions for manipulating different features. Only a few of them are listed here, see the EMS tutorial for more examples.
Function | Signature | Description |
---|---|---|
DeepPrintTable
|
void DeepPrintTable(handle table, string prefix = "")
|
Print out a table (and subtables) to the console. This works with classes as well (not instances). |
DuplicateTable
|
table DuplicateTable(table source)
|
This returns a deep copy of the passed in table. |
InjectTable
|
void InjectTable(table override, table base)
|
Inject the override data into the base table - i.e. add any new ones, overwrite dupes. |
TimeToDisplayString
|
string TimeToDisplayString(float disp_time)
|
Convert a # of seconds to a displayable time string form m:ss |
Hooks
These hook functions are only available in the g_ModeScript
scope, in Scripted Mode, which is enabled for a game mode by adding a mode specific VScript (<mode_name>.nut). They are used by simply adding a function with the same name and arguments to the script, and are called back by the C++ code at the appropriate moments.
AllowBash
int AllowBash(handle basher, handle bashee)
: called whenever melee bash is used. Returns these values:
- ALLOW_BASH_ALL - normal melee behavior
- ALLOW_BASH_NONE - do nothing at all
- ALLOW_BASH_PUSHONLY - applies physics push but deals no damage (including prevention of insta-kill ambush behavior)
AllowTakeDamage
bool AllowTakeDamage(table damageTable)
: Adding a function with this name in the script causes C++ to call it on all damage events. The damageTable is actually defined in scriptedmode.nut and filled in as appropriate before each call.
ScriptedDamageInfo <-
{
Attacker = null // hscript of the entity that attacked
Victim = null // hscript of the entity that was hit
Inflictor = null // hscript of the entity that was the inflictor
DamageDone = 0 // how much damage done
DamageType = -1 // of what type
Location = Vector(0,0,0) // where
Weapon = null // by what - often Null (say if attacker was a common)
}
Returning "false" causes the damage will be stopped and nothing will be done to the target (though animation/bloodstains/decals will probably still happen, sorry about that). The only fields read back by the C++ is DamageDone, so it can be used to change the damage value before it is applied, and DamageType, so it can be used to change the type of damage. The Type field is a bitfield, of which several key #def's are exported to script (DMG_HEADSHOT, DMG_BULLET, DMG_BUCKSHOT, DMG_MELEE, DMG_STUMBLE, DMG_BLAST, DMG_BLAST_SURFACE, DMG_BURN ).
BotQuery
bool BotQuery(int queryflag, handle entity, bool defaultvalue)
: Hook to control survivor bot behavior. Only one known flag is supported.
BOT_QUERY_NOTARGET
- Fired when a bot wants to bash a prop. Returningfalse
disallows the bashing.
CanPickupObject
bool CanPickupObject(handle object)
: Hook function for deciding whether a given prop should be pickupable (HL2 style). Returning true
makes the players able to pick up the object. Only functional for server side props. If this is defined it must return true in order the PickupObject() function to work.
InterceptChat
void InterceptChat(string message, CTerrorPlayer speaker)
: If you put a function with this name in your script, C++ will call it on all chat messages. Passing in the (annotated) chat string and the handle of the speaker. If the function returns false, it will prevent other players from seeing the chat message except for the player who entered it.
UserConsoleCommand
void UserConsoleCommand(handle playerScript, arg)
: when a user does a <scripted_user_func argument> at console (or bound to a key) this function is called (if it exists). The playerscript is which players console it came from. You can pass strings or whatever, of course. So could do a switch statement off <arg> to give players special controls, etc.
OnGameEvent_x
void OnGameEvent_x(table params)
: A callback that is called when the game event x is fired. See scripts\gameevents.res
and scripts\modeevents.res
for valid events. The callback functions can be registered independently from Scripted Mode, using: __CollectEventCallbacks(this, "OnGameEvent_", "GameEventCallbacks", RegisterScriptGameEventListener)
See L4D2_EMS/Appendix:_Game_Events for more information.
Global Functions
Printing and Drawing
Function | Signature | Description |
---|---|---|
ClientPrint
|
void ClientPrint(CTerrorPlayer player, int destination, string message)
|
Print a client message. If you pass null instead of a valid player, the message will be sent to all clients. |
DebugDrawBox
|
void DebugDrawBox(Vector origin, vector min, vector max, int r, int g, int b, int alpha, float duration)
|
Draw a debug overlay box. |
DebugDrawBoxAngles
|
void DebugDrawBoxAngles(Vector origin, Vector min, Vector max, QAngle direction, Vector rgb, int alpha, float duration)
|
Draw a debug oriented box (cent, min, max, angles(p,y,r), vRgb, a, duration). |
DebugDrawBoxDirection
|
void DebugDrawBoxDirection(Vector center, Vector min, Vector max, Vector forward, Vector rgb, float alpha, float duration)
|
Draw a debug forward box. |
DebugDrawCircle
|
void DebugDrawCircle(Vector center, Vector rgb, float alpha, float radius, bool ztest, float duration)
|
Draw a debug circle. |
DebugDrawClear
|
void DebugDrawClear()
|
Try to clear all the debug overlay info. |
DebugDrawLine
|
void DebugDrawLine(Vector start, Vector end, int red, int green, int blue', bool zTest, float time)
|
Draw a debug overlay line. |
DebugDrawLine_vCol
|
void DebugDrawLine_vCol(Vector start, vector end, vector rgb, bool ztest, float duration)
|
Draw a debug line using color vec. |
DebugDrawScreenTextLine
|
void DebugDrawScreenTextLine(float x, float y, int lineOffset, string text, int r, int g, int b, int a, float duration)
|
Draw text with a line offset. |
DebugDrawText
|
void DebugDrawText(Vector origin, string text, bool useViewCheck, float duration)
|
Draw text on the screen, starting on the position of origin. |
__DumpScope
|
void __DumpScope(int indentation, handle scope)
|
Dumps contents of everything in the scope. |
DumpObject
|
void DumpObject(handle object)
|
Dumps information about a class or instance. |
HUDManageTimers
|
void HUDManageTimers(int timerID, int command, float value)
|
Manages the HUD timers. Valid command enumerations are: TIMER_DISABLE, TIMER_COUNTUP, TIMER_COUNTDOWN, TIMER_STOP, TIMER_SET |
HUDPlace
|
void HUDPlace(int slot, float x, float y, float width, float height)
|
Sets the position of a HUD element. See L4D2_EMS/Appendix:_HUD |
HUDReadTimer
|
float HUDReadTimer(int timerID)
|
Returns the value of a HUD timer. See L4D2_EMS/Appendix:_HUD |
HUDSetLayout
|
void HUDSetLayout(table HUDTable)
|
Applies a HUD to the screen. See L4D2_EMS/Appendix:_HUD |
Msg
|
void Msg(string message)
|
Prints message to console without any line feed after. |
print
|
void print(string message)
|
Prints message to console without any line feed after. |
printl
|
void printl(string message)
|
Prints message to console with a line feed after. |
realPrint
|
void realPrint(string message)
|
Identical to print. print seems to be a wrapper for this. |
ShowMessage
|
void ShowMessage(string message)
|
Print a HUD message on all clients. ![]() |
Say
|
void Say(CTerrorPlayer player, string message, bool teamOnly)
|
Calling this will have the specified player send the message to chat, either to teamOnly (true) or to everyone. |
SendToConsole
|
void SendToConsole(string command)
|
Send a string to the console as a command. |
SendToServerConsole
|
void SendToServerConsole(string command)
|
Send a string to the server console as a command. |
Ticker_AddToHud
|
void Ticker_AddToHud(table hudTable, string strInit, bool blink)
|
Adds ticker data to a passed in HUDTable. |
Ticker_NewStr
|
void Ticker_NewStr(string newStr, float newTimeout)
|
Sets the current Ticker string, w/an optional timeout value. |
Entity Manipulation
Function | Signature | Description |
---|---|---|
AddThinkToEnt
|
void AddThinkToEnt(handle entity, string FuncName)
|
This will put a think function onto an entity, or pass null to remove it. This is NOT chained, so be careful. |
CommandABot
|
bool CommandABot(table commandTable)
|
Issues commands to bots based on a table configuration. |
ConnectOutputs
|
void ConnectOutputs(table)
|
sets output functions for entity by table To do |
DoEntFire
|
void DoEntFire(string target, string action, string value, float delay, handle activator, handle caller)
|
Generate an entity I/O event. The caller argument takes a script handle, so it can be used with target set to !self to fire inputs to entities without usable targetnames. |
EntFire
|
void EntFire(string target, string action, string value = null, float delay = 0, handle activator = null)
|
Wrapper for DoEntFire() that sets activator and caller to null. |
DropFire
|
void DropFire(Vector location)
|
Drop a fire pool from the specified Vector location. |
DropSpit
|
void DropSpit(Vector location)
|
Drop a spit pool from the specified Vector location. |
EmitAmbientSoundOn
|
void EmitAmbientSoundOn(string soundName, float volume, int soundlevel, int pitch, handle entity)
|
Play named ambient sound on an entity. |
StopAmbientSoundOn
|
void StopAmbientSoundOn(string soundName, handle entity)
|
Stop named ambient sound on an entity. |
EmitSoundOnClient
|
void EmitSoundOnClient(string soundScript, handle player)
|
Play named sound only on the client for the specified player. |
EmitSoundOn
|
void EmitSoundOn(string soundScript, handle entity)
|
Play named sound on an entity. |
StopSoundOn
|
void StopSoundOn(string soundScript, handle entity)
|
Stop named sound on an entity. |
EntIndexToHScript
|
CBaseEntity EntIndexToHScript(int entIndex)
|
Returns the script handle for the given entity index. |
GetListenServerHost
|
handle GetListenServerHost()
|
Get the host player on a listen server. |
GetFriction
|
float GetFriction(CTerrorPlayer player)
|
Returns the Friction on a player entity, meaningless if not a player. |
GetInvTable
|
void GetInvTable(CTerrorPLayer player,table invTable)
|
Fills invTable with the specified player's inventory. |
GetPhysVelocity
|
Vector GetPhysVelocity(handle entity)
|
Returns the velocity of the entity. |
GetPhysAngularVelocity
|
Vector GetPhysAngularVelocity(handle entity)
|
Returns the Angular velocity of the entity. |
GetPlayerFromCharacter
|
handle GetPlayerFromCharacter(int characterType)
|
Given a character type, return the entity, or null. |
GetPlayerFromUserID
|
handle GetPlayerFromUserID(int ID)
|
Given a user id, return the entity, or null. |
IsPlayerABot
|
bool IsPlayerABot(handle player)
|
Is this player/entity a bot. |
PickupObject
|
void PickupObject(handle player, handle entity)
|
Object from world is put into the "Held" slot of the player. Warning: it will smoothly interpolate from where it is to the players hand - which is a bit goofy if it is on other side of level. |
PlayerInstanceFromIndex
|
CTerrorPlayer PlayerInstanceFromIndex(int index)
|
Get a script handle of a player using the player index. |
PrecacheEntityFromTable
|
bool PrecacheEntityFromTable(table keyvalues)
|
Precache an entity from KeyValues in a table. |
RotateOrientation
|
QAngle RotateOrientation(QAngle, QAngle)
|
Rotate a QAngle by another QAngle. |
RotatePosition
|
Vector RotatePosition(Vector origin, QAngle rotation, Vector input)
|
Rotate the input Vector around an origin. |
SetFakeClientConVarValue
|
void SetFakeClientConVarValue(handle bot, string cvar, string value)
|
Sets a USERINFO client ConVar for a fakeclient. |
SpawnEntityFromTable
|
handle SpawnEntityFromTable(string name, handle keyvalues)
|
Native function for entity spawning. See L4D2_EMS/Appendix:_Spawning. |
SpawnEntityGroupFromTable
|
bool SpawnEntityGroupFromTable(handle entityGroup)
|
Native function for entity group spawning. See L4D2_EMS/Appendix:_Spawning. |
SpawnStartBox
|
handle SpawnStartBox(centerobjname, useFloating, width, depth, barriermodel, min_gap)
|
Auto-create a startbox that will give you a callback when the first player exits it. |
TeleportPlayersToStartPoints
|
void TeleportPlayersToStartPoints(string spawnpointName)
|
Teleport players to start entities named by the argument - must have 4 spawnpoints. |
ZSpawn
|
bool ZSpawn(table spawnTable)
|
Spawn a zombie. |
Other
Function | Signature | Description |
---|---|---|
AddToScriptHelp
|
||
Assert
|
void Assert(bool value, string optional message)
|
Test value and if not true, throws exception, optionally with message. |
CheckForSpecialStage
|
void CheckForSpecialStage(level, stage_list, stage_info)
|
Helper for picking a random special stage based on stage_info table. |
CheckOrSetMapCallback
|
void CheckOrSetMapCallback(cb_name, cb_default)
|
Pass a callback and default @ for it, if it doesnt exist in current table, place it there. |
ClearGameEventCallbacks
|
void ClearGameEventCallbacks()
|
Empties the tables of game event callback functions. |
ClearSavedTables
|
void ClearSavedTables()
|
Removes any tables saved with SaveTable() .
|
developer
|
bool developer()
|
If developer mode is on. |
Document
|
void Document(unknown symbolOrTable, unknown itemIfSymbol = null, string descriptionIfSymbol = null)
|
|
DoIncludeScript
|
void DoIncludeScript(string file, handle scope)
|
Execute a script (internal) |
DoUniqueString
|
string DoUniqueString(string input)
|
Called by UniqueString, prob want to call that instead. |
FileToString
|
string FileToString(string file)
|
Reads a string from file. Returns the string from the file, null if no file or file is greater than 16384 bytes. The game will crash to desktop if the file is exactly 16384 bytes. |
FireGameEvent
|
string FireGameEvent(string event, table params)
|
Fire a game event to a listening callback function in script. Parameters are passed in a squirrel table. |
FireScriptEvent
|
void FireScriptEvent(event, params)
|
Wrapper for __RunEventCallbacks()
|
ForceScavengeStart
|
void ForceScavengeStart()
|
Starts the scavenge round, even if the setup timer hasn't elapsed. |
ForceSurvivalStart
|
void ForceSurvivalStart()
|
Starts the survival round, even if the survivors haven't activated the radio. |
ForceVersusStart
|
void ForceVersusStart()
|
Starts the versus round, even if the survivors haven't left the safe room. |
GetCharacterDisplayName
|
string GetCharacterDisplayName(CTerrorPlayer player)
|
Return null if not a survivor, else the survivor characters name.
|
GetCurrentFlowDistanceForPlayer
|
float GetCurrentFlowDistanceForPlayer(CTerrorPlayer player)
|
Returns the navigation flow distance from the start to the specified player. |
GetCurrentFlowPercentForPlayer
|
float GetCurrentFlowPercentForPlayer(CTerrorPlayer player)
|
Returns how far in the navigation flow from the start to the end the player is. |
GetFlowDistanceForPosition
|
float GetFlowDistanceForPosition(Vector position)
|
Returns the navigation flow distance from the start to the specified point. |
GetFlowPercentForPosition
|
float GetCurrentFlowPercentForPosition(Vector position, bool unknown)
|
Returns how far in the navigation flow from the start to the end the position is. |
GetMaxFlowDistance
|
float GetMaxFlowDistance()
|
Returns the navigation flow distance from the start to the end of the level. |
GetAverageSurvivorFlowDistance
|
float GetAverageSurvivorFlowDistance()
|
Returns the navigation flow distance from the start to the survivors position averaged. |
GetFrameCount
|
void GetFrameCount()
|
Returns the engine's current frame count. |
GetFunctionSignature
|
||
GetInfectedStats
|
void GetInfectedStats(table statTable)
|
Fills statTable with some infected counts/etc... Right now the list is Witches, Tanks, Specials, Commons, though we may add more as requested going forward. |
GetSoundDuration
|
float GetSoundDuration(string soundname, string actormodel)
|
Returns float duration of the sound. Takes soundname and optional actormodelname. |
HasPlayerControlledZombies
|
bool HasPlayerControlledZombies()
|
Returns true if the current mode supports player controlled zombies. |
IncludeScript
|
void IncludeScript(string file, handle scope = null)
|
Wrapper for DoIncludeScript |
IsDedicatedServer
|
bool IsDedicatedServer()
|
Returns true if this is a dedicated server. |
IsModelPrecached
|
bool IsModelPrecached(string modelname)
|
Checks if the modelname is precached. |
IsSoundPrecached
|
bool IsSoundPrecached(string soundname)
|
Checks if the soundname is precached. |
IsWeakref
|
||
LocalTime
|
void LocalTime(table)
|
Fills out a table with the local time (second, minute, hour, day, month, year, dayofweek, dayofyear, daylightsavings). |
MakeNamespace
|
||
PrecacheModel
|
void PrecacheModel(string filename)
|
Precache a model. |
PrecacheSound
|
void PrecacheSound(string soundName)
|
Precache a sound. |
QueueSpeak
|
void QueueSpeak(handle entity, string concept, float delay, string criteria)
|
Queue a speech concept. |
RandomFloat
|
float RandomFloat()
|
Generate a random floating point number. |
RandomFloat
|
float RandomFloat(float min, float max)
|
Generate a random floating point number within a range, inclusive. |
RandomInt
|
int RandomInt()
|
Generate a random integer. |
RandomInt
|
int RandomInt(int min, int max)
|
Generate a random integer within a range, inclusive. |
ReapplyInfectedFlags
|
ReapplyInfectedFlags(int flags, handle infected)
|
Apply Infected Flags from DirectorOptions. Applies to all common (spawned and unspawned) unless a handle to a specific infected is specified. |
RegisterFunctionDocumentation
|
void RegisterFunctionDocumentation(unknown func, string name, string signature, string description)
|
|
RegisterScriptGameEventListener
|
void RegisterScriptGameEventListener(string eventName)
|
Register as a listener for a game event from script. It's what __CollectGameEventCallbacks() uses to register event callbacks to the C++ code.
|
ReloadMOTD
|
void ReloadMOTD()
|
Reloads the MotD file. |
RestoreTable
|
void RestoreTable(string identifier, table)
|
See L4D2_EMS/Appendix:_Table_Save_Restore. |
RetrieveNativeSignature
|
unknown RetrieveNativeSignature(string nativeFunction)
|
|
rr_AddDecisionRule
|
bool rr_AddDecisionRule(RRule rule)
|
Add a rule to the decision database. Takes a RRule object from rulescript_base.nut. |
rr_CommitAIResponse
|
bool rr_CommitAIResponse(handle entity, table airesponse)
|
Supposed to commit the result of QueryBestResponse back to the given entity to play. Takes a table needing the keys response with a ResponseSingle object (defined in response_testbed.nut) and orig_query with an unknown content. |
rr_GetResponseTargets
|
table rr_GetResponseTargets()
|
Retrieve a table of all available expresser targets, in the form { name : handle, name: handle }. |
rr_QueryBestResponse
|
unknown rr_QueryBestResponse(handle entity, table query)
|
Tests query against entity's response system and returns the best response found (or null if none found). Returns a pointer with a null type, that is apparently not usable anywhere. Possibly supposed to return a AI_Response object. |
RushVictim
|
void RushVictim(handle hVictim, float range)
|
Make all common zombies in range rush the victim. (If hVictim isn't set, a random survivor will be chosen.) |
SaveTable
|
void SaveTable(string identifier, table)
|
See L4D2_EMS/Appendix:_Table_Save_Restore. |
ScreenFade
|
void ScreenFade(handle player, int red, int green, int blue, int alpha, float fadeTime, float fadeHold, int flags)
|
Start a screenfade with the following parameters. |
ScreenShake
|
void ScreenShake(Vector vecCenter, float flAmplitude, float flFrequency, float flDuration, float flRadius, int eCommand, bool bAirShake)
|
Start a screenshake with the following parameters. |
StageInfo_Execute
|
void StageInfo_Execute(stageInfo, stageDefaults)
|
Execute a stage table, i.e. move parameters to DirectorOptions, do callbacks and so on. |
StartAssault
|
void StartAssault()
|
Tells all existing nextbots to swap into assault mode and not hide/dither/loiter. |
StringToFile
|
void StringToFile(string file, string string)
|
Stores the string into the file. |
Time
|
float Time()
|
Get the current server time. |
TraceLine
|
bool TraceLine(table traceTable)
|
Uses a configuration table to do a raytrace, puts return information into the table for return usage. |
UniqueString
|
string UniqueString(string input)
|
Generate a string guaranteed to be unique across the life of the script VM, with an optional root string. Useful for adding data to tables when not sure what keys are already in use in that table. |
VSquirrel_OnCreateScope
|
table VSquirrel_OnCreateScope(value, table scope)
|
Creates a new scope with the name of value in the submitted table (includes unique params). |
VSquirrel_OnReleaseScope
|
void VSquirrel_OnReleaseScope(table createdScope)
|
Removes a scope created via VSquirrel_OnCreateScope. |
__CollectEventCallbacks
|
void __CollectEventCallbacks(scope)
|
Registers callbacks for OnGameEvent_x functions. |
__CollectEventCallbacks
|
void __CollectEventCallbacks(scope, prefix, globalTableName, regFunc)
|
Overloaded function, used by the above one like this: __CollectEventCallbacks(scope, "OnGameEvent_", "GameEventCallbacks", ::RegisterScriptGameEventListener)
|
__ExecutePreSpawn
|
||
__FinishSpawn
|
||
__ReplaceClosures
|
void __ReplaceClosures(script, scope)
|
|
__RunEventCallbacks
|
void __RunEventCallbacks(event, params, prefix, globalTableName, bWarnIfMissing)
|
Call all functions in the callback array for the given game event. |
__RunGameEventCallbacks
|
void __RunGameEventCallbacks(event, params
|
Wrapper for __RunEventCallbacks()
|
Debugging functions
Functions for interacting with the debugger. Some of them are documented here.
- BeginScriptDebug
- EndScriptDebug
- ScriptDebugAddTextFilter
- ScriptDebugAddTrace
- ScriptDebugAddWatch
- ScriptDebugAddWatches
- ScriptDebugAddWatchPattern
- ScriptDebugClearTraces
- ScriptDebugClearWatches
- ScriptDebugDraw
- ScriptDebugDrawWatches
- ScriptDebugDumpKeys
- ScriptDebugHook
- ScriptDebugIterateKeys
- ScriptDebugIterateKeysRecursive
- ScriptDebugRemoveTextFilter
- ScriptDebugRemoveTrace
- ScriptDebugRemoveWatch
- ScriptDebugRemoveWatches
- ScriptDebugRemoveWatchPattern
- ScriptDebugTextDraw
- ScriptDebugTextPrint
- ScriptDebugTextTrace
- ScriptDebugTraceAll
- __VScriptServerDebugHook
Standard Squirrel library
Standard Squirrel library functions (consult official Squirrel language league for more details):
Function |
---|
abs |
acos |
array |
asin |
assert |
atan |
atan2 |
ceil |
collectgarbage |
compilestring |
cos |
exp |
fabs |
floor |
format |
getconsttable |
getroottable |
getstackinfos |
log |
log10 |
lstrip |
pow |
rand |
rstrip |
setconsttable |
seterrorhandler |
setroottable |
type |
sin |
split |
sqrt |
srand |
strip |
suspend |
tan |