Left 4 Dead 2/Scripting/Script Functions: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
(→‎Classes: Added player methods, and claned up the other classes.)
Line 113: Line 113:
|-
|-
| <code>ConnectOutput</code>
| <code>ConnectOutput</code>
| <code>void ConnectOutput(string, string)</code>
| <code>void ConnectOutput(string, string {{TODO}})</code>
| Adds an I/O connection that will call the named function when the specified output fires.
| Adds an I/O connection that will call the named function when the specified output fires.
|-
|-
| <code>DisconnectOutput</code>
| <code>DisconnectOutput</code>
| <code>void DisconnectOutput(string, string)</code>
| <code>void DisconnectOutput(string, string {{TODO}})</code>
| Removes a connected script function from an I/O event.
| Removes a connected script function from an I/O event.
|-
|-
Line 258: Line 258:
| <code>SetVelocity</code>
| <code>SetVelocity</code>
| <code>void SetVelocity(Vector ''velocity'')</code>
| <code>void SetVelocity(Vector ''velocity'')</code>
|  
| Sets the entity velocity.
|-
|-
| <code>ValidateScriptScope</code>
| <code>ValidateScriptScope</code>
Line 265: Line 265:
|}
|}
==== Player Class Methods ====
==== Player Class Methods ====
These methods are only available for player entities.
The following methods only work on player entities. Player entities belong to the CBaseEntity class, but return ''player'' from the <code>GetClassname()</code> method. Trying to use these methods on other entities will cause an exception.
{{TODO|Add the new methods from the EMS update.}}


{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
| <code>Extinguish</code>
| <code>void Extinguish()</code>
| Extinguish a burning player.
|-
| <code>EyePosition</code>
| <code>Vector? EyePosition()</code>
| Try and get the current eye position.
|-
| <code>EyePosition</code>
| <code>handle GetActiveWeapon()</code>
| Get the player's active weapon entity.
|-
| <code>GetButtonMask</code>
| <code>int GetButtonMask()</code>
| Returns a bitfield of currently pressed buttons. Recognized buttons are: <code>IN_ATTACK, IN_ATTACK2, IN_JUMP, IN_DUCK, IN_FORWARD, IN_BACK, IN_USE, IN_MOVELEFT, IN_MOVERIGHT, IN_RELOAD</code>
|-
| <code>GetHealthBuffer</code>
| <code>int GetHealthBuffer()</code>
| Returns the current temporary health of a survivor. {{TODO|Does temp health work on SI?}}
|-
| <code>GetPlayerUserId</code>
| <code>int GetPlayerUserId()</code>
| Get the player's userID.
|-
| <code>GetSenseFlags</code>
| <code>int GetSenseFlags()</code>
| Get the current bits for the bot sense flags: <code>BOT_CANT_SEE, BOT_CANT_HEAR, BOT_CANT_FEEL</code>
|-
| <code>GetSurvivorSlot</code>
| <code>int GetSurvivorSlot()</code>
| Get the player's slot.
|-
| <code>GetZombieType</code>
| <code>int GetZombieType()</code>
|  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
|-
| <code>GiveAmmo</code>
| <code>void GiveAmmo(int ''amount'')</code>
| Adds ammo for the player's currently equipped weapon. Double the value set in amount is added.
|-
| <code>GiveItem</code>
| <code>void GiveItem(string ''itemname'')</code>
| Give an item/weapon by name. (<code>health, katana, rifle_ak47</code>, etc.)
|-
| <code>GiveUpgrade</code>
| <code>void GiveUpgrade(string ''upgrade'')</code>
| give a primary weapon upgrade: <code>UPGRADE_INCENDIARY_AMMO, UPGRADE_EXPLOSIVE_AMMO, UPGRADE_LASER_SIGHT</code>
|-
| <code>HitWithVomit</code>
| <code>void HitWithVomit()</code>
| Target a player with a boomer vomit attack.
|-
| <code>IsDead</code>
| <code>bool IsDead()</code>
| Returns a bool indicating dead state.
|-
| <code>IsDying</code>
| <code>bool IsDying()</code>
| Returns a bool indicating dying state.
|-
| <code>IsIncapacitated</code>
| <code>bool IsIncapacitated()</code>
| Returns a bool indicating incapacitated state.
|-
| <code>IsHangingFromLedge</code>
| <code>bool IsHangingFromLedge()</code>
| Returns a bool indicating ledge hang state.
|-
| <code>IsGhost</code>
| <code>bool IsGhost()</code>
| Returns a bool indicating ghost infected state.
|-
| <code>IsOnFire</code>
| <code>bool IsOnFire()</code>
| Returns a bool indicating if a player is on fire.
|-
| <code>IsSurvivor</code>
| <code>bool IsSurvivor()</code>
| On the survivor team (Otherwise, infected).
|-
| <code>RemoveUpgrade</code>
| <code>void RemoveUpgrade(string ''upgrade'')</code>
| Remove a primary weapon upgrade: <code>UPGRADE_INCENDIARY_AMMO, UPGRADE_EXPLOSIVE_AMMO, UPGRADE_LASER_SIGHT</code>
|-
| <code>ReviveByDefib</code>
| <code>void ReviveByDefib()</code>
| Revive a dead player by defib.
|-
| <code>ReviveFromIncap</code>
| <code>void ReviveFromIncap()</code>
| Revive an incapacitated player.
|-
| <code>ReviveFromIncap</code>
| <code>void ReviveFromIncap()</code>
| Revive an incapacitated player.
|-
| <code>SetFriction</code>
| <code>void SetFriction(int ''friction'')</code>
| Set player friction.
|-
| <code>SetGravity</code>
| <code>void SetGravity(int ''gravity'')</code>
| Set player gravity.
|-
| <code>SetHealthBuffer</code>
| <code>void SetHealthBuffer(float ''health'')</code>
| Sets the temporary health of a survivor. Does not incapacitate or kill when set to zero.
|-
| <code>SetReviveCount</code>
| <code>void SetReviveCount(int ''count'')</code>
| Sets the number of times a survivor has been revived, and updates third-strike state and effects.
|-
| <code>SetSenseFlags</code>
| <code>void SetSenseFlags(int ''flags'')</code>
| Set the current bits for the bot sense flags: <code>BOT_CANT_SEE, BOT_CANT_HEAR, BOT_CANT_FEEL</code>
|-
| <code>Stagger</code>
| <code>void Stagger(Vector ''position'')</code>
| Stagger a player away from a position. Use Vector(0,0,0) to just stagger forward.
|-
| <code>TryGetPathableLocationWithin</code>
| <code>Vector TryGetPathableLocationWithin(int ''radius'')</code>
| Get a location on the nav the player can path to within the desired radius.
|-
| <code>UseAdrenaline</code>
| <code>void UseAdrenaline(int ''duration'')</code>
| Causes Adrenaline's speed and visual effect, no change to health.
|}
=== CCallChainer ===
=== CCallChainer ===


=== CDirector ===
=== CDirector ===
Game Instance: <code>Director</code>
Provides methods for reading information from the AI Director. To influence the Director, the <code>[[DirectorScript]]</code> table is used instead.
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 277: Line 413:
|-
|-
| <code>GetAveragedSurvivorSpan</code>
| <code>GetAveragedSurvivorSpan</code>
| <code>float CDirector::GetAveragedSurvivorSpan()</code>
| <code>float GetAveragedSurvivorSpan()</code>
| Get the distance between the lead and trailing survivors, smoothed over time
| Get the distance between the lead and trailing survivors, smoothed over time.
|-
|-
| <code>GetAveragedSurvivorSpeed</code>
| <code>GetAveragedSurvivorSpeed</code>
| <code>float CDirector::GetAveragedSurvivorSpeed()</code>
| <code>float GetAveragedSurvivorSpeed()</code>
| Get the rate at which the lead survivor is moving along the flow, smoothed over time
| Get the rate at which the lead survivor is moving along the flow, smoothed over time.
|-
|-
| <code>GetCommonInfectedCount</code>
| <code>GetCommonInfectedCount</code>
| <code>int CDirector::GetCommonInfectedCount()</code>
| <code>int GetCommonInfectedCount()</code>
| Returns number fo infected currently spawned
| Returns number for infected currently spawned.
|-
|-
| <code>GetFurthestSurvivorFlow</code>
| <code>GetFurthestSurvivorFlow</code>
| <code>float CDirector::GetFurthestSurvivorFlow()</code>
| <code>float GetFurthestSurvivorFlow()</code>
| Get the maximum distance along the flow that the survivors have reached
| Get the maximum distance along the flow that the survivors have reached
|-
|-
| <code>GetGameMode</code>
| <code>GetGameMode</code>
| <code>string CDirector::GetGameMode()</code>
| <code>string GetGameMode()</code>
| Get the current game mode
| Get the current game mode.
|-
|-
| <code>GetPendingMobCount</code>
| <code>GetPendingMobCount</code>
| <code>int CDirector::GetPendingMobCount()</code>
| <code>int GetPendingMobCount()</code>
| Returns tnumber of infected waiting to spawn
| Returns the number of infected waiting to spawn.
|-
|-
| <code>HasAnySurvivorLeftSafeArea</code>
| <code>HasAnySurvivorLeftSafeArea</code>
| <code>bool CDirector::HasAnySurvivorLeftSafeArea()</code>
| <code>bool HasAnySurvivorLeftSafeArea()</code>
| True when one or more survivors have left the starting safe area
| True when one or more survivors have left the starting safe area.
|-
|-
| <code>IsAnySurvivorInCombat</code>
| <code>IsAnySurvivorInCombat</code>
| <code>bool CDirector::IsAnySurvivorInCombat()</code>
| <code>bool IsAnySurvivorInCombat()</code>
| Returns true if any survivor recently dealt or took damage
| Returns true if any survivor recently dealt or took damage.
|-
|-
| <code>IsPlayingOnConsole</code>
| <code>IsPlayingOnConsole</code>
| <code>bool CDirector::IsPlayingOnConsole()</code>
| <code>bool IsPlayingOnConsole()</code>
| Return true if game is running on a console (such as Xbox 360)
| Return true if game is running on a console (such as Xbox 360).
|-
|-
| <code>IsSinglePlayerGame</code>
| <code>IsSinglePlayerGame</code>
| <code>bool CDirector::IsSinglePlayerGame()</code>
| <code>bool IsSinglePlayerGame()</code>
| Return true if game is in single player
| Return true if game is in single player.
|-
|-
| <code>IsTankInPlay</code>
| <code>IsTankInPlay</code>
| <code>bool CDirector::IsTankInPlay()</code>
| <code>bool IsTankInPlay()</code>
| Returns true if any tanks are aggro on survivors
| Returns true if any tanks are aggro on survivors.
|-
|-
| <code>L4D1SurvivorGiveItem</code>
| <code>L4D1SurvivorGiveItem</code>
| <code>void CDirector::L4D1SurvivorGiveItem()</code>
| <code>void L4D1SurvivorGiveItem()</code>
| Let the L4D1 survivors know that now is a good time to give the players an item
| Let the L4D1 survivors know that now is a good time to give the players an item.
|-
|-
| <code>PlayMegaMobWarningSounds</code>
| <code>PlayMegaMobWarningSounds</code>
| <code>void CDirector::PlayMegaMobWarningSounds()</code>
| <code>void PlayMegaMobWarningSounds()</code>
| Plays a horde scream sound and asks survivors to speak 'incoming horde' lines
| Plays a horde scream sound and asks survivors to speak 'incoming horde' lines.
|-
|-
| <code>ResetMobTimer</code>
| <code>ResetMobTimer</code>
| <code>void CDirector::ResetMobTimer()</code>
| <code>void ResetMobTimer()</code>
| Trigger a mob as soon as possible when in BUILD_UP
| Trigger a mob as soon as possible when in <code>BUILD_UP</code>.
|-
|-
| <code>UserDefinedEvent1</code>
| <code>UserDefinedEvent1</code>
| <code>void CDirector::UserDefinedEvent1()</code>
| <code>void UserDefinedEvent1()</code>
| generic user defined event fired from a squirrel script
| These trigger the appropriate output from the [[info_director]] entity when called.
|-
|-
| <code>UserDefinedEvent2</code>
| <code>UserDefinedEvent2</code>
| <code>void CDirector::UserDefinedEvent2()</code>
| <code>void UserDefinedEvent2()</code>
| generic user defined event fired from a squirrel script
|  
|-
|-
| <code>UserDefinedEvent3</code>
| <code>UserDefinedEvent3</code>
| <code>void CDirector::UserDefinedEvent3()</code>
| <code>void UserDefinedEvent3()</code>
| generic user defined event fired from a squirrel script
|  
|-
|-
| <code>UserDefinedEvent4</code>
| <code>UserDefinedEvent4</code>
| <code>void CDirector::UserDefinedEvent4()</code>
| <code>void UserDefinedEvent4()</code>
| generic user defined event fired from a squirrel script
|  
|}
|}


=== CEntities ===
=== CEntities ===
Game Instance: <code>Entities</code>
An interface to find and iterate over 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.
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 356: Line 498:
|-
|-
| <code>FindByClassname</code>
| <code>FindByClassname</code>
| <code>handle CEntities::FindByClassname(handle, string)</code>
| <code>handle FindByClassname(handle ''previous'', string ''class'')</code>
| Find entities by class name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
| Find entities by class name.  
|-
|-
| <code>FindByClassnameNearest</code>
| <code>FindByClassnameNearest</code>
| <code>handle CEntities::FindByClassnameNearest(string, Vector, float)</code>
| <code>handle FindByClassnameNearest(string ''class'', Vector ''origin'', float ''radius'')</code>
| Find entities by class name nearest to a point.
| Find the entity with the given class name nearest to the specified point.
|-
|-
| <code>FindByClassnameWithin</code>
| <code>FindByClassnameWithin</code>
| <code>handle CEntities::FindByClassnameWithin(handle, string, Vector, float)</code>
| <code>handle FindByClassnameWithin(handle ''previous'', string ''class'', Vector ''origin'', float ''radius'')</code>
| 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
| Find entities by class name within a radius.  
|-
|-
| <code>FindByModel</code>
| <code>FindByModel</code>
| <code>handle CEntities::FindByModel(handle, string)</code>
| <code>handle FindByModel(handle ''previous'', string ''filename'')</code>
| Find entities by model name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
| Find entities by model name.  
|-
|-
| <code>FindByName</code>
| <code>FindByName</code>
| <code>handle CEntities::FindByName(handle, string)</code>
| <code>handle FindByName(handle ''previous'', string ''name'')</code>
| Find entities by name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
| Find entities by name.  
|-
|-
| <code>FindByNameNearest</code>
| <code>FindByNameNearest</code>
| <code>handle CEntities::FindByNameNearest(string, Vector, float)</code>
| <code>handle FindByNameNearest(string ''name'', Vector ''origin'', float ''radius'')</code>
| Find entities by name nearest to a point.
| Find entities by name nearest to a point.
|-
|-
| <code>FindByNameWithin</code>
| <code>FindByNameWithin</code>
| <code>handle CEntities::FindByNameWithin(handle, string, Vector, float)</code>
| <code>handle FindByNameWithin(handle ''previous'', string ''name'', Vector ''origin'', float ''radius'')</code>
| Find entities by name within a radius. Pass 'null' to start an iteration, or reference to a previously found continue a search
| Find entities by name within a radius.
|-
|-
| <code>FindByTarget</code>
| <code>FindByTarget</code>
| <code>handle CEntities::FindByTarget(handle, string)</code>
| <code>handle FindByTarget(handle ''previous'', string ''targetname'')</code>
| Find entities by targetname. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
| Find entities by its target.
|-
|-
| <code>FindInSphere</code>
| <code>FindInSphere</code>
| <code>handle CEntities::FindInSphere(handle, Vector, float)</code>
| <code>handle FindInSphere(handle ''previous'', Vector ''origin'', float ''radius'')</code>
| Find entities within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
| Find entities within a radius.
|-
|-
| <code>First</code>
| <code>First</code>
| <code>handle CEntities::First()</code>
| <code>handle First()</code>
| Begin an iteration over the list of entities
| Begin an iteration over the list of entities
|-
|-
| <code>Next</code>
| <code>Next</code>
| <code>handle CEntities::Next(handle)</code>
| <code>handle Next(handle ''previous'')</code>
| Continue an iteration over the list of entities, providing reference to a previously found entity
| Continue an iteration over the list of entities, providing reference to a previously found entity.
|}
|}


Line 405: Line 547:


=== CNavMesh ===
=== CNavMesh ===
Game Instance: <code>NavMesh</code>
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 411: Line 555:
|-
|-
| <code>UnblockRescueVehicleNav</code>
| <code>UnblockRescueVehicleNav</code>
| <code>void CNavMesh::UnblockRescueVehicleNav()</code>
| <code>void UnblockRescueVehicleNav()</code>
| Unblock the rescue vehicle nav areas so bots can path through them
| Unblock the rescue vehicle nav areas so bots can path through them.
|}
|}



Revision as of 03:14, 6 April 2014

Squirrel This list contains all engine-related Squirrel variables, functions, and constants available for VScript in Left 4 Dead 2 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 [Todo]) Adds an I/O connection that will call the named function when the specified output fires.
DisconnectOutput void DisconnectOutput(string, string [Todo]) 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) Sets the entity velocity.
ValidateScriptScope bool ValidateScriptScope() Ensure that an entity's script scope has been created.

Player Class Methods

The following methods only work on player entities. Player entities belong to the CBaseEntity class, but return player from the GetClassname() method. Trying to use these methods on other entities will cause an exception.

Function Signature Description
Extinguish void Extinguish() Extinguish a burning player.
EyePosition Vector? EyePosition() Try and get the current eye position.
EyePosition 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.
Todo: Does temp health work on SI?
GetPlayerUserId int GetPlayerUserId() Get the player's 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.
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 currently equipped weapon. Double the value set in amount is added.
GiveItem void GiveItem(string itemname) Give an item/weapon by name. (health, katana, rifle_ak47, etc.)
GiveUpgrade void GiveUpgrade(string upgrade) 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.
IsSurvivor bool IsSurvivor() On the survivor team (Otherwise, infected).
RemoveUpgrade void RemoveUpgrade(string upgrade) 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.
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
Stagger void Stagger(Vector position) Stagger a player away from a position. Use Vector(0,0,0) to just stagger forward.
TryGetPathableLocationWithin Vector TryGetPathableLocationWithin(int radius) Get a location on the nav the player can path to within the desired radius.
UseAdrenaline void UseAdrenaline(int duration) Causes Adrenaline's speed and visual effect, no change to health.

CCallChainer

CDirector

Game Instance: Director

Provides methods for reading information from the AI Director. To influence the Director, the DirectorScript table is used instead.

Function Signature Description
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.
GetPendingMobCount int GetPendingMobCount() Returns the number of infected waiting to spawn.
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.
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.
UserDefinedEvent1 void UserDefinedEvent1() These trigger the appropriate output from the info_director entity when called.
UserDefinedEvent2 void UserDefinedEvent2()
UserDefinedEvent3 void UserDefinedEvent3()
UserDefinedEvent4 void UserDefinedEvent4()

CEntities

Game Instance: Entities

An interface to find and iterate over 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.

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.


CEnvEntityMaker

CNavMesh

Game Instance: NavMesh

Function Signature Description
UnblockRescueVehicleNav void 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

See also