Left 4 Dead 2/Scripting/Script Functions
< Left 4 Dead 2 | Scripting
Jump to navigation
Jump to search
This list contains all engine-related Squirrel variables, functions, and constants available for VScript in
Left 4 Dead 2 . Some can be printed in-game with the
scipt_help
command when the game is run in debug mode with the -allowdebug
parameter, or with script g_ModeScript.DeepPrintTable(getroottable())
. Others have been found from data mining.
Variables
Instance | Type | Description |
---|---|---|
Convars
|
CConvars
|
|
Director
|
CDirector
|
|
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
|
|
g_ClearoutTable
|
table (null )
|
|
g_MapScript
|
table | Script scope for map specific vscripts. |
g_ModeScript
|
table | Script scope for mode specific vscripts. It also contains a lot of utility functions. |
g_RoundState
|
table | |
g_rr
|
table | |
NavMesh
|
CNavMesh
|
|
print_indent
|
||
_PublishedHelp
|
table | |
ScriptDebugTraceAllOn
|
boolean | |
ScriptDebugTraces
|
table | |
ScriptDebugText
|
array | |
ScriptDebugTextFilters
|
table | |
ScriptDebugTextIndent
|
boolean | |
ScriptDebugWatches
|
array | |
ScriptEventCallbacks
|
table |
Classes
CBaseAnimating
Extends CBaseEntity
CBaseEntity
This is a script handle for a game entity. All entities in-game are accessible from Entities
Base Methods
Function | Signature | Description |
---|---|---|
ApplyAbsVelocityImpulse
|
void ApplyAbsVelocityImpulse(Vector impulse)
|
Apply a Velocity Impulse. |
ApplyLocalAngularVelocityImpulse
|
void ApplyLocalAngularVelocityImpulse(Vector impulse)
|
Apply an Ang Velocity Impulse. |
ConnectOutput
|
void ConnectOutput(string, string)
|
Adds an I/O connection that will call the named function when the specified output fires. |
DisconnectOutput
|
void DisconnectOutput(string, string)
|
Removes a connected script function from an I/O event. |
FirstMoveChild
|
handle FirstMoveChild()
|
|
GetAngles
|
handle QAngle GetAngles()
|
Returns the orientation of the entity in the world. |
GetBaseVelocity
|
Vector GetBaseVelocity()
|
Get Base? velocity |
GetClassname
|
string GetClassname()
|
Returns the entity class. This includes player and infected .
|
GetContext
|
unknown GetContext(string)
|
GetContext( name ): looks up a context and returns it if available. May return string, float, or null (if the context isn't found) |
GetEntityHandle
|
unknown GetEntityHandle()
|
Get the entity as an EHANDLE. Todo: What is this?
|
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()
|
|
GetLocalAngularVelocity
|
QAngle GetLocalAngularVelocity()
|
Maybe local angvel |
GetLocalVelocity
|
Vector GetLocalVelocity()
|
Get Entity relative velocity |
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 script-side data associated with an entity. |
GetVelocity
|
Vector GetVelocity()
|
|
IsPlayer
|
bool IsPlayer()
|
Does this entity belong to the player class. |
Kill
|
void Kill()
|
|
NextMovePeer
|
handle NextMovePeer()
|
|
OverrideFriction
|
void OverrideFriction(float duration, float friction)
|
Takes duration, value for a temporary override |
PrecacheModel
|
void PrecacheModel(string filename)
|
|
PrecacheScriptSound
|
void PrecacheScriptSound(string)
|
Todo: Is this for raw files or soundscripts?
|
SetAngles
|
void SetAngles(QAngle direction)
|
|
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 0 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 0 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)
|
|
SetOrigin
|
void SetOrigin(Vector position)
|
|
SetVelocity
|
void SetVelocity(Vector velocity)
|
|
ValidateScriptScope
|
bool ValidateScriptScope()
|
Ensure that an entity's script scope has been created. |
Player Class Methods
These methods are only available for player entities.
Todo: Add the new methods from the EMS update.
CCallChainer
CDirector
Function | Signature | Description |
---|---|---|
GetAveragedSurvivorSpan
|
float CDirector::GetAveragedSurvivorSpan()
|
Get the distance between the lead and trailing survivors, smoothed over time |
GetAveragedSurvivorSpeed
|
float CDirector::GetAveragedSurvivorSpeed()
|
Get the rate at which the lead survivor is moving along the flow, smoothed over time |
GetCommonInfectedCount
|
int CDirector::GetCommonInfectedCount()
|
Returns number fo infected currently spawned |
GetFurthestSurvivorFlow
|
float CDirector::GetFurthestSurvivorFlow()
|
Get the maximum distance along the flow that the survivors have reached |
GetGameMode
|
string CDirector::GetGameMode()
|
Get the current game mode |
GetPendingMobCount
|
int CDirector::GetPendingMobCount()
|
Returns tnumber of infected waiting to spawn |
HasAnySurvivorLeftSafeArea
|
bool CDirector::HasAnySurvivorLeftSafeArea()
|
True when one or more survivors have left the starting safe area |
IsAnySurvivorInCombat
|
bool CDirector::IsAnySurvivorInCombat()
|
Returns true if any survivor recently dealt or took damage |
IsPlayingOnConsole
|
bool CDirector::IsPlayingOnConsole()
|
Return true if game is running on a console (such as Xbox 360) |
IsSinglePlayerGame
|
bool CDirector::IsSinglePlayerGame()
|
Return true if game is in single player |
IsTankInPlay
|
bool CDirector::IsTankInPlay()
|
Returns true if any tanks are aggro on survivors |
L4D1SurvivorGiveItem
|
void CDirector::L4D1SurvivorGiveItem()
|
Let the L4D1 survivors know that now is a good time to give the players an item |
PlayMegaMobWarningSounds
|
void CDirector::PlayMegaMobWarningSounds()
|
Plays a horde scream sound and asks survivors to speak 'incoming horde' lines |
ResetMobTimer
|
void CDirector::ResetMobTimer()
|
Trigger a mob as soon as possible when in BUILD_UP |
UserDefinedEvent1
|
void CDirector::UserDefinedEvent1()
|
generic user defined event fired from a squirrel script |
UserDefinedEvent2
|
void CDirector::UserDefinedEvent2()
|
generic user defined event fired from a squirrel script |
UserDefinedEvent3
|
void CDirector::UserDefinedEvent3()
|
generic user defined event fired from a squirrel script |
UserDefinedEvent4
|
void CDirector::UserDefinedEvent4()
|
generic user defined event fired from a squirrel script |
CEntities
Function | Signature | Description |
---|---|---|
FindByClassname
|
handle CEntities::FindByClassname(handle, string)
|
Find entities by class name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
FindByClassnameNearest
|
handle CEntities::FindByClassnameNearest(string, Vector, float)
|
Find entities by class name nearest to a point. |
FindByClassnameWithin
|
handle CEntities::FindByClassnameWithin(handle, string, Vector, float)
|
Find entities by class name within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
FindByModel
|
handle CEntities::FindByModel(handle, string)
|
Find entities by model name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
FindByName
|
handle CEntities::FindByName(handle, string)
|
Find entities by name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
FindByNameNearest
|
handle CEntities::FindByNameNearest(string, Vector, float)
|
Find entities by name nearest to a point. |
FindByNameWithin
|
handle CEntities::FindByNameWithin(handle, string, Vector, float)
|
Find entities by name within a radius. Pass 'null' to start an iteration, or reference to a previously found continue a search |
FindByTarget
|
handle CEntities::FindByTarget(handle, string)
|
Find entities by targetname. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
FindInSphere
|
handle CEntities::FindInSphere(handle, Vector, float)
|
Find entities within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
First
|
handle CEntities::First()
|
Begin an iteration over the list of entities |
Next
|
handle CEntities::Next(handle)
|
Continue an iteration over the list of entities, providing reference to a previously found entity |
CEnvEntityMaker
Function | Signature | Description |
---|---|---|
UnblockRescueVehicleNav
|
void CNavMesh::UnblockRescueVehicleNav()
|
Unblock the rescue vehicle nav areas so bots can path through them |
Convars
CSimpleCallChainer
Decider
regxp
LateBinder
QAngle
Quaternion
Vector
Vector2D
Vector4D
Other functions
Engine specific
Function | Signature | Description |
---|---|---|
DebugDrawBox
|
void DebugDrawBox(Vector, Vector, Vector, int, int, int, int, float)
|
Draw a debug overlay box |
DebugDrawLine
|
void DebugDrawLine(Vector, Vector, int, int, int, bool, float)
|
Draw a debug overlay box |
DoIncludeScript
|
bool DoIncludeScript(string, handle)
|
Execute a script (internal) |
EntFire
|
function EntFire(target, action, value, delay, activator)
|
Generate and entity i/o event |
RandomFloat
|
float RandomFloat(float, float)
|
Generate a random floating point number within a range, inclusive |
RandomInt
|
int RandomInt(int, int)
|
Generate a random integer within a range, inclusive |
SendToConsole
|
void SendToConsole(string)
|
Send a string to the console as a command |
ShowMessage
|
void ShowMessage(string)
|
Print a hud message on all clients |
Time
|
float Time()
|
Get the current server time |
UniqueString
|
function UniqueString(string)
|
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. |
Standard Squirrel libary
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 |