Alien Swarm: Reactive Drop/Scripting/Script Functions
This list contains the engine-related Squirrel classes, functions and variables available for VScript in
Alien Swarm: Reactive Drop .
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. |
Entities
|
CEntities
|
Provides access to currently spawned entities. |
NetProps
|
CNetPropManager
|
Allows reading and updating the network properties of an entity. |
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 |
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
|
void __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
|
void __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
|
void __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
|
void __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. |
Activate
|
void Activate()
|
Activates the spawned entity. |
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. |
Destroy
|
void Destroy()
|
Deletes the entity. |
EmitSound
|
void EmitSound(string soundScript)
|
Plays a sound from this entity. |
entindex
|
int entindex()
|
Returns the entity index. |
EyePosition
|
Vector EyePosition()
|
Get vector to the eye position - absolute coordinates. |
FirstMoveChild
|
handle FirstMoveChild()
|
[Todo] |
GetAngles
|
Vector GetAngles()
|
Get the entity pitch, yaw, roll as a Vector object. |
GetAngularVelocity
|
Vector GetAngularVelocity()
|
Get the local angular velocity - returns a Vector of pitch, yaw, roll. |
GetBoundingMaxs
|
Vector GetBoundingMaxs()
|
Returns the maximum extent of the entity bounding box as a local vector. |
GetBoundingMins
|
Vector GetBoundingMins()
|
Returns the maximum extent of the entity bounding box as a local vector. |
GetCenter
|
Vector GetCenter()
|
Returns a local vector of the bounding box center. |
GetClassname
|
string GetClassname()
|
Returns the entity class. This includes player .
|
GetContext
|
string GetContext()
|
Looks up a response context and returns it if available. May return string or null (if the context isn't found). |
GetForwardVector
|
Vector GetForwardVector()
|
Get the forward vector of the entity. |
GetHealth
|
int GetHealth()
|
Returns the current health. |
GetKeyValue
|
variable GetKeyValue(string key)
|
Returns the entity's Keyvalue. |
GetLeftVector
|
Vector GetLeftVector()
|
Get the left vector of the entity. |
GetMaxHealth
|
int GetMaxHealth()
|
Returns the maximum health. |
GetModelKeyValues
|
Keyvalues GetModelKeyValues()
|
Returns the [$keyvalues] block of the entitys model as a #Keyvalues object. Note that this is not the keyvalues of the entity itself. |
GetModelName
|
string GetModelName()
|
Returns the file name of the entitys model. |
GetMoveParent
|
CBaseEntity GetMoveParent()
|
If in hierarchy, retrieves the entitys parent. |
GetName
|
string GetName()
|
Returns the targetname of the entity. |
GetOrigin
|
Vector GetOrigin()
|
Returns the Entity position in the world. |
GetOwner
|
handle GetOwner()
|
Gets this entity's owner. (seems to only be useful if you have used SetOwner() previously on this entity, could be wrong) |
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 data associated with this entity. |
GetSoundDuration
|
float GetSoundDuration(string soundName, string actorModelName = "")
|
Returns float duration of the sound. Takes soundname and optional actormodelname. |
GetTeam
|
int GetTeam()
|
Returns the team number of a player. Terrorists = 2, CTs = 3. |
GetUpVector
|
Vector GetUpVector()
|
Get the up vector of the entity. |
GetVelocity
|
Vector GetVelocity()
|
Returns a local velocity Vector. |
IsAlien
|
bool IsAlien()
|
Whether the handle belongs to an alien class. |
IsValid
|
bool IsValid()
|
Whether the handle belongs to a valid entity. |
NextMovePeer
|
handle NextMovePeer()
|
|
PrecacheModel
|
void PrecacheModel(string modelPath)
|
Precache a model after the map has loaded. |
PrecacheSoundScript
|
void PrecacheSoundScript(string soundScript)
|
Precache a sound for later playing. |
SetAbsOrigin
|
void SetAbsOrigin(Vector position)
|
Same as SetOrigin(). |
SetAngles
|
void SetAngles(float pitch, float yaw, float roll)
|
Set entity pitch, yaw, roll. Note that it doesn't take a Vector object. |
SetAnglesVector
|
void SetAnglesVector(Vector angles)
|
Set entity pitch, yaw, roll from a vector. |
SetAngularVelocity
|
void SetAngularVelocity(float pitch, float yaw, float roll)
|
Set the local angular velocity - takes float pitch, yaw, roll velocities. |
SetCollisionGroup
|
void SetCollisionGroup(int collisionGroup)
|
Sets the entity's collision group. |
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'). |
SetForwardVector
|
void SetForwardVector(Vector forwardVector)
|
Set the orientation of the entity to have this forward vector. |
SetHealth
|
void SetHealth(int newHealth)
|
Sets the current health. |
SetMaxHealth
|
void SetMaxHealth(int maxHealth)
|
Sets a new maximum health. |
SetModel
|
void SetModel(string modelName)
|
Changes the model of the entity. Does not Precache the model. Todo: Check for side effects
|
SetName
|
void SetName()
|
Sets the targetname of the entity. |
SetOrigin
|
void SetOrigin(Vector position)
|
Moves the entity to this global position vector. |
SetOwner
|
void SetOwner(handle owner)
|
Sets this entity's owner. |
SetSize
|
void SetSize(Vector, Vector)
|
[Todo] |
SetTeam
|
void SetTeam(int teamNumber)
|
Instantly switches a players team. Terrorists = 2, CTs = 3. |
SetVelocity
|
void SetVelocity(Vector velocity)
|
Gives the entity a new local velocity. |
Spawn
|
void Spawn()
|
Spawns the entity into the game. |
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.
|
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 |
---|---|---|
GetAttachmentAngles
|
Vector GetAttachmentAngles(int id)
|
Get the attachment ID's angles as a pitch, yaw, roll vector. |
GetAttachmentOrigin
|
Vector GetAttachmentOrigin(int id)
|
Get the attachment ID's origin vector. |
IsSequenceFinished
|
bool IsSequenceFinished()
|
Ask whether the main sequence is done playing. |
LookupAttachment
|
int LookupAttachment(string attachmentName)
|
Get the named attachment ID. |
SetBodygroup
|
void SetBodygroup(int groupIndex, int value)
|
Sets the models bodygroup value by index. Todo: How do you find the index?
|
CBaseFlex
Extends CBaseAnimating
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. |
CBasePlayer
Extends CBaseAnimating
Methods
Function | Signature | Description |
---|---|---|
GetNetworkIDString
|
string GetNetworkIDString()
|
Get the player's network (i.e. Steam) ID. |
GetPlayerName
|
string GetPlayerName()
|
Get the players name. |
GetPlayerUserID
|
string GetPlayerUserID()
|
Get the players userID. |
IsNoclipping
|
bool IsNoclipping()
|
Returns true if the player is in noclip mode. |
CASW_Marine
Extends CBaseAnimating
Methods
Function | Signature | Description |
---|---|---|
BecomeInfested
|
void BecomeInfested()
|
Infests the marine. |
CureInfestation
|
void CureInfestation()
|
Cures an infestation. |
DropWeapon
|
void DropWeapon(int slot)
|
Makes the marine drop a weapon. |
Extinguish
|
void Extinguish()
|
Extinguish a burning marine. |
GetCommander
|
CBasePlayer GetCommander()
|
Get the player that owns the marine. |
GetInvTable
|
table GetInvTable()
|
Returns a table of the marine's inventory data. |
GetMarineName
|
string GetMarineName()
|
Returns the marine's name. |
GiveAmmo
|
void GiveAmmo(int amount, int ammoIndex)
|
Gives the marine ammo for the specified ammo index. |
GiveWeapon
|
void GiveWeapon(string weaponName, int slot)
|
Gives the marine a weapon. |
Ignite
|
void Ignite(float duration)
|
Ignites the marine into flames. |
IsInhabited
|
bool IsInhabited()
|
True if the marine is a player, false if the marine is a bot. |
Knockdown
|
void Knockdown(Vector velocity)
|
Knocks down the marine with desired velocity. |
RemoveWeapon
|
void RemoveWeapon(int slot)
|
Removes a weapon from the marine. |
SetKnockedOut
|
void SetKnockedOut(bool knockedOut)
|
Used to knock out and incapacitate a marine, or revive them. |
Speak
|
void Speak(string concept, float delay, string criteria)
|
Makes the marine speak a response rules concept. |
CASW_Alien
Extends CBaseAnimating
Methods
Function | Signature | Description |
---|---|---|
ChaseNearestMarine
|
void ChaseNearestMarine()
|
Order the alien to chase the nearest marine. |
ClearOrders
|
void ClearOrders()
|
Clear the alien's orders. |
Extinguish
|
void Extinguish()
|
Extinguish a burning alien. |
Ignite
|
void Ignite(float duration)
|
Ignites the alien into flames. |
OrderMoveTo
|
bool OrderMoveTo(handle entity, bool ignoreMarines)
|
Order the alien to move to an entity handle, second parameter ignore marines. |
CASW_Buzzer
Extends CBaseAnimating
Methods
Function | Signature | Description |
---|---|---|
ChaseNearestMarine
|
void ChaseNearestMarine()
|
Order the buzzer to chase the nearest marine. |
ClearOrders
|
void ClearOrders()
|
Clear the buzzer's orders. |
Extinguish
|
void Extinguish()
|
Extinguish a burning buzzer. |
Ignite
|
void Ignite(float duration)
|
Ignites the buzzer into flames. |
OrderMoveTo
|
bool OrderMoveTo(handle entity, bool ignoreMarines)
|
Order the buzzer to move to an entity handle, second parameter ignore marines. |
CASW_Colonist
Extends CBaseAnimating
Methods
Function | Signature | Description |
---|---|---|
BecomeInfested
|
void BecomeInfested()
|
Infests the colonist. |
CureInfestation
|
void CureInfestation()
|
Cures an infestation. |
DropWeapon
|
void DropWeapon()
|
Makes the colonist drop a weapon. |
Extinguish
|
void Extinguish()
|
Extinguish a burning colonist. |
GiveWeapon
|
void GiveWeapon(string weaponName)
|
Gives the colonist a weapon. |
Ignite
|
void Ignite(float duration)
|
Ignites the colonist into flames. |
RemoveWeapon
|
void RemoveWeapon()
|
Removes a weapon from the colonist. |
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, Vector orientation)
|
Create an entity at a specified location and orientation, orientation is Euler angle in degrees (pitch, yaw, roll). |
SpawnEntityAtNamedEntityOrigin
|
void SpawnEntityAtNamedEntityOrigin(string targetName)
|
Create an entity at the location of a named entity. |
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.
function PreSpawnInstance( entityClass, entityName )
{
local keyvalues =
{
rendercolor = "0 255 0"
targetname = "mySpawnedEntity"
}
return keyvalues
}
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 )
}
}
CSceneEntity
Extends CBaseEntity
Methods
Function | Signature | Description |
---|---|---|
AddBroadcastTeamTarget
|
void AddBroadcastTeamTarget(int index)
|
Adds a team (by index) to the broadcast list. |
EstimateLength
|
float EstimateLength()
|
Returns length of this scene in seconds. |
FindNamedEntity
|
handle FindNamedEntity(string reference)
|
given an entity reference, such as !target, get actual entity from scene object. |
IsPaused
|
bool IsPaused()
|
If this scene is currently paused. |
IsPlayingBack
|
bool IsPlayingBack()
|
If this scene is currently playing. |
LoadSceneFromString
|
bool LoadSceneFromString(string sceneName, string scene)
|
Given a dummy scene name and a vcd string, load the scene. |
RemoveBroadcastTeamTarget
|
void RemoveBroadcastTeamTarget(int index)
|
Removes a team (by index) from the broadcast list. |
CTriggerCamera
Extends CBaseEntity
Methods
Function | Signature | Description |
---|---|---|
GetFov
|
int GetFov()
|
Get cameras current Field Of View setting as integer. |
SetFov
|
void SetFov(int fov, float rate)
|
Set cameras current FOV in integer degrees and FOV change rate as float. |
Hooks
void ScriptStartCameraShot(string shotType, handle sceneEntity, handle actor1, handle actor2, float duration)
- Called from SceneEntity in response to a CChoreoEvent::CAMERA sent from a VCD. [Todo]
CCallChainer
[Todo]
Methods
Function | Signature | Description |
---|---|---|
constructor
|
[Todo] constructor()
|
|
PostScriptExecute
|
[Todo] PostScriptExecute()
|
|
Call
|
[Todo] 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.
Methods
Function | Signature | Description |
---|---|---|
GetAlienCount
|
int GetAlienCount()
|
Returns number of aliens currently spawned. |
GetIntensity
|
float GetIntensity(CBaseEntity marine)
|
Get the intensity value for a marine. |
GetMaxIntensity
|
float GetMaxIntensity()
|
Get the maximum intensity value for all living marines. |
IsOfflineGame
|
bool IsOfflineGame()
|
Return true if game is in single player. |
MissionComplete
|
void MissionComplete(bool completed)
|
Completes the mission if true. |
ResetIntensity
|
void ResetIntensity(CBaseEntity marine)
|
Reset the intensity value for a marine to zero. |
ResetIntensityForAllMarines
|
void ResetIntensityForAllMarines()
|
Reset the intensity value for all marines to zero. |
RestartMission
|
void RestartMission()
|
Restarts the mission. |
SpawnAlienAt
|
handle SpawnAlienAt(string alienClass, Vector position, Vector angles)
|
Spawn an alien by class name. |
SpawnAlienBatch
|
int SpawnAlienBatch(string alienClass, int aliens, Vector position, Vector angles)
|
Spawn a group of aliens by class name. |
SpawnAlienAuto
|
bool SpawnAlienAuto(string alienClass)
|
Spawn an alien automatically near the marines. |
StartFinale
|
void StartFinale()
|
Spawn a horde every few seconds for the rest of the level. |
StartHoldout
|
void StartHoldout()
|
Starts spawning a horde every few seconds until stopped. |
StopHoldout
|
void StopHoldout()
|
Stops spawning hordes. |
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 |
---|---|---|
CreateByClassname
|
handle CreateByClassname(string class)
|
Creates an entity by class name. |
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. |
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_Collision.m_nSolidType").

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. Todo: 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. |
Convars
Game Instance: Convars
Provides an interface for getting and setting convars on the server.
Methods
Function | Signature | Description |
---|---|---|
ExecuteConCommand
|
void ExecuteConCommand(string cmd)
|
Executes the convar command. |
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 to a numeric value. |
SetValueString
|
void SetValueString(string name, string value)
|
Sets the value of the convar to a string. |
CScriptResponseCriteria
Game Instance: ResponseCriteria
Allows reading the response rules of an entity.
Methods
Function | Signature | Description |
---|---|---|
GetTable
|
table GetTable(CBaseEntity entity)
|
Returns a table of 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. |
CPlayerVoiceListener
Methods
Function | Signature | Description |
---|---|---|
GetPlayerSpeechDuration
|
float GetPlayerSpeechDuration(int playerIndex)
|
Returns the number of seconds the player has been continuously speaking. |
IsPlayerSpeaking
|
bool IsPlayerSpeaking(int playerIndex)
|
Returns whether the player specified is speaking. |
IsValid
|
bool IsValid()
|
Whether the handle belongs to a valid entity. |
CScriptKeyValues
Script handle representation of a models $keyvalues block. Sub keys are instances of the same class.
Methods
Function | Signature | Description |
---|---|---|
constructor
| ||
FindKey
|
CScriptKeyValues FindKey(string keyName)
|
Find a sub key by the key name. |
GetFirstSubKey
|
CScriptKeyValues GetFirstSubKey()
|
Return the first sub key object. |
GetKeyBool
|
bool GetKeyBool(string keyName)
|
Return the key value as a bool. |
GetKeyFloat
|
float GetKeyFloat(string keyName)
|
Return the key value as a float. |
GetKeyInt
|
int GetKeyInt(string keyName)
|
Return the key value as an integer. |
GetKeyString
|
string GetKeyString(string keyName)
|
Return the key value as a string. |
GetNextKey
|
handle GetNextKey()
|
Return the next neighbor key object to the one the method is called on. |
IsKeyEmpty
|
bool IsKeyEmpty(string keyName)
|
Returns true if the named key has no value. |
IsValid
|
bool IsValid()
|
Whether the handle belongs to a valid entity. |
ReleaseKeyValues
|
void ReleaseKeyValues()
|
Releases the contents of the instance. |
CSimpleCallChainer
Seems to have the same members as CCallChainer. [Todo]
LateBinder
Late binding: allows a table to refer to parts of itself, it's children, it's owner, and then have the references fixed up after it's fully parsed.
// Usage:
lateBinder <- LateBinder();
lateBinder.Begin( this );
Test1 <-
{
Foo=1
}
Test2 <-
{
FooFoo = "I'm foo foo"
BarBar="@Test1.Foo"
SubTable = { boo=[bah, "@Test2.FooFoo", "@Test1.Foo"], booboo2={one=bah, two="@Test2.FooFoo", three="@Test1.Foo"} }
booboo=[bah, "@Test2.FooFoo", "@Test1.Foo"]
booboo2={one=bah, two="@Test2.FooFoo", three="@Test1.Foo"}
bah=wha
}
lateBinder.End();
delete lateBinder;
When End() is called, all of the unresolved symbols in the tables and arrays will be resolved, any left unresolved will become a string prepended with '~', which later code can deal with.
Methods
Function | Signature | Description |
---|---|---|
Begin
| ||
End
| ||
EstablishDelegation
| ||
HookRootMetamethod
| ||
Log
| ||
m_bindNamesStack
| ||
m_fixupSet
| ||
m_log
| ||
m_logIndent
| ||
m_targetTable
| ||
RemoveDelegation
| ||
Resolve
| ||
UnhookRootMetamethod
|
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
|
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(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()
|
Will return the vector length as a float. This function will also NORMALIZE the vector, the X, Y, and Z values will each be set to a number between -1 and 1. You can then multiply these values by, for example, 3000 to use the vector to set the velocity of something in game. |
ToKVString
|
string ToKVString()
|
Returns a string without separations commas. |
Members
Instance | Type | Description |
---|---|---|
x
|
float
|
Cartesian X axis. |
y
|
float
|
Cartesian Y axis. |
z
|
float
|
Cartesian Z axis. |
Hooks
These hook functions 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.
OnTakeDamage_Alive_Any
float OnTakeDamage_Alive_Any(CBaseEntity victim, CBaseEntity inflictor, CBaseEntity attacker, CBaseEntity weapon, float damage, int damageType, string ammoName)
: Adding a function with this name in the script causes C++ to call it on all OnTakeDamage_Alive events.
Returning "false" causes the damage to be stopped and nothing will be done to the target (though animation/bloodstains/decals will probably still happen, sorry about that).
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.
Global functions
Printing and Drawing
Function | Signature | Description |
---|---|---|
ClientPrint
|
void ClientPrint(CBasePlayer player, int destination, string message)
|
Print a client message. |
DebugDrawBox
|
void DebugDrawBox(vector origin, vector min, vector max, int r, int g, int b, int alpha, float duration)
|
Draw a debug overlay box. |
DebugDrawLine
|
void DebugDrawLine(Vector start, Vector end, int red, int green, int blue, bool zTest, float time)
|
Draw a debug line between two points. |
Msg
|
void Msg(string message)
|
Equivalent to print
|
print
|
void print(string message)
|
Prints the given message to the developer console. |
printl
|
void printl(string message)
|
Prints the given message to the developer console just like print but also appends a newline. |
Say
|
void Say(CBasePlayer player, string message)
|
Calling this will have the specified player send the message to chat. |
ShowMessage
|
void ShowMessage(string)
|
Print a hud message on all clients. ![]() |
__DumpScope
|
void __DumpScope(int indentation, handle scope)
|
Dumps contents of everything in the scope. |
Other
Function | Signature | Description |
---|---|---|
Assert
|
void Assert(bool value, string optional message)
|
Test value and if not true, throws exception, optionally with message. |
CreateGrenadeCluster
|
handle CreateGrenadeCluster(float damage, float radius, int clusters, Vector position, Vector angles, Vector velocity, Vector angVelocity)
|
Create grenade cluster. |
CreateProp
|
handle CreateProp(string class, Vector origin, string model, int animation)
|
Create a prop with the specified class and model. Both prop_physics, prop_dynamic as well as some other entity classes with models work. Does not precache the model. ![]() |
CreateSceneEntity
|
CSceneEntity CreateSceneEntity(string scene)
|
Create a scene entity to play the specified scene .vcd file. |
DoIncludeScript
|
bool DoIncludeScript(string filename, table scope)
|
Execute a script with the script scope set to the specified table. |
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. |
DropFreezeGrenade
|
handle DropFreezeGrenade(float damage, float freezeAmount, float grenadeRadius, Vector origin)
|
Drops a freeze grenade. |
EntFire
|
function EntFire(string target, string action, string value, float delay = 0.0, handle activator = null)
|
Generate an entity I/O event. |
EntFireByHandle
|
void EntFireByHandle(handle target, string action, string value, float delay, handle activator, handle caller)
|
Generate an entity I/O event. The first parameter is an entity instance, so the handles of nameless or script generated entities can be passed easily. |
EntIndexToHScript
|
CBaseEntity EntIndexToHScript(int entIndex)
|
Returns the script handle for the given entity index. |
FileToString
|
string FileToString(string string)
|
Reads a string from file. Returns the string from the file, null if no file or file is too big. |
FrameTime
|
float FrameTime()
|
Get the time spent on the server in the last frame |
GetFrameCount
|
int GetFrameCount()
|
Returns the engine's current frame count. |
GetMapName
|
string GetMapName()
|
Get the name of the map. |
GetPlayerFromUserID
|
handle GetPlayerFromUserID(int ID)
|
Given a user id, return the entity, or null. |
PlaceDamageAmplifier
|
handle PlaceDamageAmplifier(float duration, float grenadeRadius, Vector origin)
|
Places a damage amplifier. |
PlaceHealBeacon
|
handle PlaceHealBeacon(float healAmount, float healthPerSecond, float infestationCureAmount, float duration, float grenadeRadius, Vector origin)
|
Places a heal beacon. |
PlantIncendiaryMine
|
handle PlantIncendiaryMine(Vector origin, Vector angles)
|
Plants an incendiary mine. |
PlantLaserMine
|
handle PlantLaserMine(bool friendly, Vector origin, Vector angles)
|
Plants a laser mine. |
PlayerInstanceFromIndex
|
CBasePlayer PlayerInstanceFromIndex(int index)
|
Get a script handle of a player using the player index. |
PrintHelp
|
[Todo] | |
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 |
RetrieveNativeSignature
|
void RetrieveNativeSignature(string or func)
|
Name suggests it would print the calling format for a native function, but I can't get it to output anything other than <unnamed>
|
SendToConsole
|
void SendToConsole(string command)
|
Send a string to the console as a command. |
SendToConsoleServer
|
void SendToConsoleServer(string)
|
Send a string that gets executed on the server as a ServerCommand |
StartStim
|
void StartStim(float duration)
|
Activates a stim pack for desired duration. |
StopStim
|
void StopStim()
|
Stops any active stim pack. |
StringToFile
|
void StringToFile(string file, string string)
|
Stores the string into the file. |
Time
|
float Time()
|
Get the current server time |
TraceLine
|
float TraceLine(Vector, Vector, handle)
|
given 2 points & ent to ignore, return fraction along line that hits world or models |
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. |
__ReplaceClosures
|