Left 4 Dead 2 script functions

From Source Entities
Jump to navigation Jump to search

This table is adapted from the list generated by the script_help console command. Any changes are welcome.

Function Signature Description
AddThinkToEnt void AddThinkToEnt(handle, string) Adds a late bound think function to the C++ think tables for the obj
CDirector::ClearCachedBotQueries void CDirector::ClearCachedBotQueries() Mark all cached bot query results as invalid
CDirector::ForceNextStage void CDirector::ForceNextStage() Push the ScriptedMode to next stage - i.e. request GNSS be called
CDirector::GetAveragedSurvivorSpan float CDirector::GetAveragedSurvivorSpan() Get the distance between the lead and trailing survivors, smoothed over time
CDirector::GetAveragedSurvivorSpeed float CDirector::GetAveragedSurvivorSpeed() Get the rate at which the lead survivor is moving along the flow, smoothed over time
CDirector::GetCommonInfectedCount int CDirector::GetCommonInfectedCount() Returns number fo infected currently spawned
CDirector::GetFurthestSurvivorFlow float CDirector::GetFurthestSurvivorFlow() Get the maximum distance along the flow that the survivors have reached
CDirector::GetGameMode string CDirector::GetGameMode() Get the current game mode
CDirector::GetHoldoutCooldownEndTime float CDirector::GetHoldoutCooldownEndTime() Get the end time of the cooldown timer
CDirector::GetPendingMobCount int CDirector::GetPendingMobCount() Returns tnumber of infected waiting to spawn
CDirector::HasAnySurvivorLeftSafeArea bool CDirector::HasAnySurvivorLeftSafeArea() True when one or more survivors have left the starting safe area
CDirector::IsAnySurvivorInCombat bool CDirector::IsAnySurvivorInCombat() Returns true if any survivor recently dealt or took damage
CDirector::IsPlayingOnConsole bool CDirector::IsPlayingOnConsole() Return true if game is running on a console (such as Xbox 360)
CDirector::IsSinglePlayerGame bool CDirector::IsSinglePlayerGame() Return true if game is in single player
CDirector::IsTankInPlay bool CDirector::IsTankInPlay() Returns true if any tanks are aggro on survivors
CDirector::L4D1SurvivorGiveItem void CDirector::L4D1SurvivorGiveItem() Let the L4D1 survivors know that now is a good time to give the players an item
CDirector::PlayMegaMobWarningSounds void CDirector::PlayMegaMobWarningSounds() Plays a horde scream sound and asks survivors to speak 'incoming horde' lines
CDirector::ResetMobTimer void CDirector::ResetMobTimer() Trigger a mob as soon as possible when in BUILD_UP
CDirector::ResetSpecialTimers void CDirector::ResetSpecialTimers() Reset all special timers (by type and by slot) so that hopefully mobs will spawn asap
CDirector::SetHoldoutCooldownEndTime void CDirector::SetHoldoutCooldownEndTime(float) Set the end time of the cooldown timer
CDirector::UserDefinedEvent1 void CDirector::UserDefinedEvent1() generic user defined event fired from a squirrel script
CDirector::UserDefinedEvent2 void CDirector::UserDefinedEvent2() generic user defined event fired from a squirrel script
CDirector::UserDefinedEvent3 void CDirector::UserDefinedEvent3() generic user defined event fired from a squirrel script
CDirector::UserDefinedEvent4 void CDirector::UserDefinedEvent4() generic user defined event fired from a squirrel script
CEntities::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
CEntities::FindByClassnameNearest handle CEntities::FindByClassnameNearest(string, Vector, float) Find entities by class name nearest to a point.
CEntities::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
CEntities::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
CEntities::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
CEntities::FindByNameNearest handle CEntities::FindByNameNearest(string, Vector, float) Find entities by name nearest to a point.
CEntities::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 entity to continue a search
CEntities::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
CEntities::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
CEntities::First handle CEntities::First() Begin an iteration over the list of entities
CEntities::Next handle CEntities::Next(handle) Continue an iteration over the list of entities, providing reference to a previously found entity
CNavMesh::UnblockRescueVehicleNav void CNavMesh::UnblockRescueVehicleNav() Unblock the rescue vehicle nav areas so bots can path through them
CNetPropManager::GetPropArraySize int CNetPropManager::GetPropArraySize(handle, string) Arguments: ( entity, propertyName )
CNetPropManager::GetPropEntity handle CNetPropManager::GetPropEntity(handle, string) Arguments: ( entity, propertyName ) - returns an entity
CNetPropManager::GetPropEntityArray handle CNetPropManager::GetPropEntityArray(handle, string, int) Arguments: ( entity, propertyName, arrayElement ) - returns an entity
CNetPropManager::GetPropFloat float CNetPropManager::GetPropFloat(handle, string) Arguments: ( entity, propertyName )
CNetPropManager::GetPropFloatArray float CNetPropManager::GetPropFloatArray(handle, string, int) Arguments: ( entity, propertyName, arrayElement )
CNetPropManager::GetPropInt int CNetPropManager::GetPropInt(handle, string) Arguments: ( entity, propertyName )
CNetPropManager::GetPropIntArray int CNetPropManager::GetPropIntArray(handle, string, int) Arguments: ( entity, propertyName, arrayElement )
CNetPropManager::GetPropString string CNetPropManager::GetPropString(handle, string) Arguments: ( entity, propertyName )
CNetPropManager::GetPropStringArray string CNetPropManager::GetPropStringArray(handle, string, int) Arguments: ( entity, propertyName, arrayElement )
CNetPropManager::GetPropType string CNetPropManager::GetPropType(handle, string) Arguments: ( entity, propertyName ) - return the prop type as a string
CNetPropManager::GetPropVector Vector CNetPropManager::GetPropVector(handle, string) Arguments: ( entity, propertyName )
CNetPropManager::GetPropVectorArray Vector CNetPropManager::GetPropVectorArray(handle, string, int) Arguments: ( entity, propertyName, arrayElement )
CNetPropManager::HasProp bool CNetPropManager::HasProp(handle, string) Arguments: ( entity, propertyName )
CNetPropManager::SetPropEntity void CNetPropManager::SetPropEntity(handle, string, handle) Arguments: ( entity, propertyName, value )
CNetPropManager::SetPropEntityArray void CNetPropManager::SetPropEntityArray(handle, string, handle, int) Arguments: ( entity, propertyName, value, arrayElement )
CNetPropManager::SetPropFloat void CNetPropManager::SetPropFloat(handle, string, float) Arguments: ( entity, propertyName, value )
CNetPropManager::SetPropFloatArray void CNetPropManager::SetPropFloatArray(handle, string, float, int) Arguments: ( entity, propertyName, value, arrayElement )
CNetPropManager::SetPropInt void CNetPropManager::SetPropInt(handle, string, int) Arguments: ( entity, propertyName, value )
CNetPropManager::SetPropIntArray void CNetPropManager::SetPropIntArray(handle, string, int, int) Arguments: ( entity, propertyName, value, arrayElement )
CNetPropManager::SetPropString void CNetPropManager::SetPropString(handle, string, string) Arguments: ( entity, propertyName, value )
CNetPropManager::SetPropStringArray void CNetPropManager::SetPropStringArray(handle, string, string, int) Arguments: ( entity, propertyName, value, arrayElement )
CNetPropManager::SetPropVector void CNetPropManager::SetPropVector(handle, string, Vector) Arguments: ( entity, propertyName, value )
CNetPropManager::SetPropVectorArray void CNetPropManager::SetPropVectorArray(handle, string, Vector, int) Arguments: ( entity, propertyName, value, arrayElement )
ClearSavedTables void ClearSavedTables() Remove all saved tables
CommandABot bool CommandABot(handle) Pass table - Inputs: bot, target, pos, cmd -- cmd BOT_CMD_MOVE, _ATTACK, _RETREAT, _RESET
Convars::GetClientConvarValue string Convars::GetClientConvarValue(string, int) GetClientConvarValue(name) : returns the convar value for the entindex as a string.
Convars::GetFloat <unknown> Convars::GetFloat(string) GetFloat(name) : returns the convar as a float. May return null if no such convar.
Convars::GetStr <unknown> Convars::GetStr(string) GetFloat(name) : returns the convar as a string. May return null if no such convar.
Convars::SetValue void Convars::SetValue(string, <unknown>) SetValue(name, value) : sets the value of the convar. Supported types are bool, int, float, string.
DebugDrawBox void DebugDrawBox(Vector, Vector, Vector, int, int, int, int, float) Draw a debug overlay box
DebugDrawBoxDirection void DebugDrawBoxDirection(Vector, Vector, Vector, Vector, Vector, float, float) Draw a debug forward box (cent, min, max, forward, vRgb, a, duration)
DebugDrawCircle void DebugDrawCircle(Vector, Vector, float, float, bool, float) Draw a debug circle (center, rad, vRgb, a, ztest, duration)
DebugDrawClear void DebugDrawClear() Try to clear all the debug overlay info
DebugDrawLine void DebugDrawLine(Vector, Vector, int, int, int, bool, float) Draw a debug overlay line
DebugDrawLine_vCol void DebugDrawLine_vCol(Vector, Vector, Vector, bool, float) Draw a debug line using color vec (start, end, vRgb, a, ztest, duration)
DebugDrawScreenTextLine void DebugDrawScreenTextLine(float, float, int, string, int, int, int, int, float) Draw text with a line offset
DebugDrawText void DebugDrawText(Vector, string, bool, float) Draw text in 3d (origin, text, bViewCheck, duration)
Decider::AddRule bool Decider::AddRule(handle) AddRule(CRule) : Add a CRule object (defined in rulescript_base.nut)
Decider::FindAllMatches handle Decider::FindAllMatches(handle, float) Binding_FindAllMatches(query,leeway) : Returns an array of all matching responses. If leeway is nonzero, all results scoring within 'leeway' of the best score return.
Decider::FindBestMatch handle Decider::FindBestMatch(handle) Binding_FindBestMatch(query) : Query the database and return the best result found. If multiple of equal score found, an arbitrary one returns.
DoIncludeScript bool DoIncludeScript(string, handle) Execute a script (internal)
DropFire void DropFire(Vector) Drop a fire pool from the specified location
DropSpit void DropSpit(Vector) Drop a spit pool from the specified location
EmitSoundOn void EmitSoundOn(string, handle) Play named sound on Entity
EmitSoundOnClient void EmitSoundOnClient(string, handle) Play named sound only on the client for the passed in player
EntFire function EntFire(target, action, value, delay, activator) Generate and entity i/o event
EntIndexToHScript handle EntIndexToHScript(int) Turn an entity index integer to an HScript representing that entity's script instance.
FileToString string FileToString(string) Reads a string from a file to send to script
FireGameEvent bool FireGameEvent(string, handle) Fire a game event to a listening callback function in script. Parameters are passed in a squirrel table.
GetAverageSurvivorFlowDistance float GetAverageSurvivorFlowDistance() Gets the average flow distance of all the survivors.
GetCharacterDisplayName string GetCharacterDisplayName(handle) Return null if not a survivor, else the survivors 'real name'
GetCurrentFlowDistanceForPlayer float GetCurrentFlowDistanceForPlayer(handle) Gets the distance of how far the given player has made it to the goal.
GetCurrentFlowPercentForPlayer float GetCurrentFlowPercentForPlayer(handle) Gets the percentage of how far the given player has made it to the goal.
GetFlowDistanceForPosition float GetFlowDistanceForPosition(Vector) Gets distance from the start of the map for a given position.
GetFlowPercentForPosition float GetFlowPercentForPosition(Vector, bool) Gets the percent of where in the flow a given position is.
GetFrameCount int GetFrameCount() Returns the engines current frame count
GetFriction float GetFriction(handle) Returns the Friction on a player entity, meaningless if not a player
GetInfectedStats void GetInfectedStats(handle) Fill passed in table with current stats about infected in the world
GetInvTable void GetInvTable(handle, handle) Put Player's inventory data into a passed in table
GetMaxFlowDistance float GetMaxFlowDistance() Gets the max flow distance for the entire map.
GetPhysAngularVelocity Vector GetPhysAngularVelocity(handle) Get Angular Velocity for VPHYS or normal object
GetPhysVelocity Vector GetPhysVelocity(handle) Get Velocity for VPHYS or normal object
GetPlayerFromCharacter handle GetPlayerFromCharacter(int) Given a character type, return the entity, or null
GetPlayerFromUserID handle GetPlayerFromUserID(int) Given a user id, return the entity, or null
HUDManageTimers void HUDManageTimers(int, int, float) anage the system timers
HUDPlace void HUDPlace(int, float, float, float, float) Place the HUD element for Slot at X,Y,W,H
HUDReadTimer float HUDReadTimer(int) Read value from a system timer
HUDSetLayout void HUDSetLayout(handle) Pass the HUD definition table for your mode
IsPlayerABot bool IsPlayerABot(handle) Is this player/entity a bot
PickupObject void PickupObject(handle, handle) Have a player pickup a nearby named entity
PlayerInstanceFromIndex handle PlayerInstanceFromIndex(int) Get a script instance of a player by index.
PrecacheEntityFromTable bool PrecacheEntityFromTable(handle) Precache an entity from KeyValues in table
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
ReapplyInfectedFlags void ReapplyInfectedFlags(int, handle) Apply passed flags to passed infected or all commons if 2nd param is null
RegisterScriptGameEventListener void RegisterScriptGameEventListener(string) Register as a listener for a game event from script.
ReloadMOTD void ReloadMOTD() Reloads the MotD file
RestoreTable void RestoreTable(string, handle) Put saved data back into the passed in table
RotateOrientation QAngle RotateOrientation(QAngle, QAngle) Rotate a QAngle by another QAngle.
RotatePosition Vector RotatePosition(Vector, QAngle, Vector) Rotate a Vector around a point.
SaveTable void SaveTable(string, handle) Save the passed in table
Say void Say(handle, string, bool) Have Entity say string, and teamOnly or not
SendToConsole void SendToConsole(string) Send a string to the console as a client command
SendToServerConsole void SendToServerConsole(string) Send a string to the console as a server command
ShowMessage void ShowMessage(string) Print a hud message on all clients
SpawnEntityFromTable handle SpawnEntityFromTable(string, handle) Spawn entity from KeyValues in table - 'name' is entity name, rest are KeyValues for spawn.
SpawnEntityGroupFromTable bool SpawnEntityGroupFromTable(handle) Hierarchically spawn an entity group from a set of spawn tables.
StartAssault void StartAssault() Tells all existing nextbots to swap into assault mode and not hide/dither/loiter
StopSoundOn void StopSoundOn(string, handle) Stop named sound on Entity
StringToFile bool StringToFile(string, string) Store a string to a file for later reading
Time float Time() Get the current server time
TraceLine bool TraceLine(handle) Pass table - Inputs: start, end, mask, ignore -- outputs: pos, fraction, hit, enthit, startsolid
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.
ZSpawn bool ZSpawn(handle) Does a z_spawn like spawn based on an input table
rr_AddDecisionRule bool rr_AddDecisionRule(handle) Add a rule to the decision database.
rr_CommitAIResponse bool rr_CommitAIResponse(handle, handle) Commit the result of QueryBestResponse back to the given entity to play. Call with params (entity, airesponse)
rr_GetResponseTargets handle rr_GetResponseTargets() Retrieve a table of all available expresser targets, in the form { name : handle, name: handle }.
rr_QueryBestResponse handle rr_QueryBestResponse(handle, handle) Params: (entity, query) : tests 'query' against entity's response system and returns the best response found (or null if none found).