Alien Swarm: Reactive Drop/Scripting/Script Functions: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(new OnSentTextMessage hook)
m (AlterDeathMessage)
 
(31 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{toc-right}}
{{toc-right}}


{{sq}} This list contains the engine-related Squirrel classes, functions and variables available for [[VScript]] in {{game link|Alien Swarm: Reactive Drop}}.
{{sq}} This list contains the engine-related Squirrel classes, functions and variables available for [[VScript]] in {{asrd|4}}.


== Variables ==
== Variables ==
Line 37: Line 37:
|<code>[[#CASW_Mission_Chooser_VScript|CASW_Mission_Chooser_VScript]]</code>
|<code>[[#CASW_Mission_Chooser_VScript|CASW_Mission_Chooser_VScript]]</code>
|Provides an interface for querying campaigns, missions, and challenges on the server.
|Provides an interface for querying campaigns, missions, and challenges on the server.
|-
|<code>Deathmatch</code>
|<code>[[#CASW_Deathmatch_VScript|CASW_Deathmatch_VScript]]</code>
|Allows challenge modes to modify deathmatch scores.
|-
|-
|<code>NetProps</code>
|<code>NetProps</code>
Line 132: Line 136:
| <code>void Destroy()</code>
| <code>void Destroy()</code>
| Deletes the entity.
| Deletes the entity.
|-
| <code>DispatchParticleEffect</code>
| <code>void DispatchParticleEffect(string ''name'')</code>
| Spawns a particle effect that follows the origin of this entity.
|-
| <code>DispatchParticleEffectLink</code>
| <code>void DispatchParticleEffectLink(string ''name'', handle ''otherEntity'')</code>
| Spawns a particle effect that follows the origin of this entity and has another entity's origin as control point 1.
|-
| <code>DispatchParticleEffectCP1</code>
| <code>void DispatchParticleEffectCP1(string ''name'', Vector ''cp1'')</code>
| Spawns a particle effect at the origin of this entity with a specific offset for control point 1.
|-
| <code>StopParticleEffect</code>
| <code>void StopParticleEffect(string ''name'')</code>
| Removes a particle effect from this entity by name.
|-
| <code>StopParticleEffects</code>
| <code>void StopParticleEffects()</code>
| Removes all particle effects from this entity.
|-
|-
| <code>EmitSound</code>
| <code>EmitSound</code>
| <code>void EmitSound(string ''soundScript'')</code>
| <code>void EmitSound(string ''soundScript'')</code>
| Plays a sound from this entity.
| Plays a sound from this entity.
|-
| <code>EmitSoundTable</code>
| <code>void EmitSoundTable(string ''soundScript'', table ''options'')</code>
| Plays a sound from this entity. Options that can be specified: ''caption'' (true or false), ''channel'' (one of the CHAN_ constants such as CHAN_AUTO), ''delay'' (number), ''origin'' (Vector), ''pitch'' (one of the PITCH_ constants such as PITCH_NORM or a number from 1 to 255), ''recipient'' (a player or character entity handle), ''soundlevel'' (one of the SNDLVL_ constants such as SNDLVL_GUNFIRE or a number of decibels - affects distance the sound can be heard from, not volume), ''volume'' (number from 0 to 1)
|-
|-
| <code>entindex</code>
| <code>entindex</code>
Line 410: Line 438:
! Signature
! Signature
! Description
! Description
|-
| <code>DispatchParticleEffectAttachment</code>
| <code>void DispatchParticleEffectAttachment(string ''name'', string ''attachment'')</code>
| Spawn a particle effect that follows an attachment point of this entity.
|-
| <code>DispatchParticleEffectAttachmentLink</code>
| <code>void DispatchParticleEffectAttachmentLink(string ''name'', string ''attachment'', handle ''otherEntity'')</code>
| Spawns a particle effect that follows an attachment point of this entity and has another entity's origin as control point 1.
|-
|-
| <code>GetAttachmentAngles</code>
| <code>GetAttachmentAngles</code>
Line 572: Line 608:
| Returns the world location directly beneath the player's crosshair.
| Returns the world location directly beneath the player's crosshair.
|-
|-
| <code>GetMarine</code>
| <code>GetMarine</code> (Shared)
| <code>CASW_Marine GetMarine()</code>
| <code>CASW_Marine GetMarine()</code>
| Returns the marine the player is commanding.
| Returns the marine the player is commanding.
|-
|-
| <code>GetNPC</code>
| <code>GetNPC</code> (Shared)
| <code>CBaseEntity GetNPC()</code>
| <code>CBaseEntity GetNPC()</code>
| Returns entity the player is inhabiting.
| Returns entity the player is inhabiting.
Line 584: Line 620:
| Sets the player's inhabiting entity.
| Sets the player's inhabiting entity.
|-
|-
| <code>GetSpectatingNPC</code>
| <code>GetSpectatingNPC</code> (Shared)
| <code>CBaseEntity GetSpectatingNPC()</code>
| <code>CBaseEntity GetSpectatingNPC()</code>
| Returns entity the player is spectating.
| Returns entity the player is spectating.
Line 592: Line 628:
| Sets the player's spectating entity.
| Sets the player's spectating entity.
|-
|-
| <code>GetViewNPC</code>
| <code>GetViewNPC</code> (Shared)
| <code>CBaseEntity GetViewNPC()</code>
| <code>CBaseEntity GetViewNPC()</code>
| Returns entity the player is spectating, else will return inhabiting entity.
| Returns entity the player is spectating, else will return inhabiting entity.
Line 616: Line 652:
|}
|}


 
=== CASW_Inhabitable_NPC ===
=== CBaseTrigger ===
Extends [[#CBaseEntity|CBaseEntity]]
 
Entity class for triggers.
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
| <code>Disable</code>
| <code>void Disable() </code>
| Disable the trigger
|-
| <code>Enable</code>
| <code>void Enable() </code>
| Enable the trigger
|-
| <code>IsTouching</code>
| <code>bool IsTouching(handle ''entity'') </code>
| Checks whether the passed entity is touching the trigger.
|}
 
 
=== CASW_Marine ===
Extends [[#CBaseCombatCharacter|CBaseCombatCharacter]]
Extends [[#CBaseCombatCharacter|CBaseCombatCharacter]]


Line 651: Line 661:
! Description
! Description
|-
|-
| <code>BecomeInfested</code>
| <code>IsInhabited</code>
| <code>void BecomeInfested()</code>
| <code>bool IsInhabited()</code>
| Infests the marine.
| Removes true if this character is being controlled by a player.
|-
|-
| <code>CureInfestation</code>
| <code>GetCommander</code>
| <code>void CureInfestation()</code>
| <code>CASW_Player GetCommander()</code>
| Cures an infestation.
| Returns the player who "owns" this character, for example the player who is playing as a marine or who added a marine bot to the lobby.
|-
|-
| <code>DropWeapon</code>
| <code>SetControls</code>
| <code>void DropWeapon(int ''slot'')</code>
| <code>void SetControls(int ''controls'')</code>
| Makes the marine drop a weapon.
| Sets this character to use a specific control scheme. -1 = use asw_controls convar, 0 = first person, 1 = top-down, 2 = third person
|-
|-
| <code>Extinguish</code>
| <code>SetFogController</code>
| <code>void Extinguish()</code>
| <code>void SetFogController(entity)</code>
| Extinguish a burning marine.
| Force this character to use a specific env_fog_controller entity.
|-
|-
| <code>GetCommander</code>
| <code>SetPostProcessController</code>
| <code>CBasePlayer GetCommander()</code>
| <code>void SetPostProcessController(entity)</code>
| Get the player that owns the marine.
| Force this character to use a specific postprocess_controller entity.
|-
|-
| <code>GetInventoryTable</code>
| <code>SetColorCorrection</code>
| <code>void GetInventoryTable(table)</code>
| <code>void SetColorCorrection(entity)</code>
| Fills the passed table with the marine's inventory.
| Force this character to use a specific color_correction entity.
|-
|-
| <code>GetInvTable</code>
| <code>SetTonemapController</code>
| <code>table GetInvTable()</code>
| <code>void SetTonemapController(entity)</code>
| -DEPRECATED- Returns a table of the marine's inventory data.
| Force this character to use a specific env_tonemap_controller entity.
|-
|-
| <code>GetMarineName</code>
| <code>SetGlow</code>
| <code>string GetMarineName()</code>
| <code>void SetGlow(Vector ''color'', float ''alpha'', bool ''glowWhenOccluded'', bool ''glowWhenUnoccluded'', bool ''fullBloom'')</code>
| Returns the marine's name.
| Make this character glow when occluded or when unoccluded. Does not affect cases where the character would glow due to built-in game logic.
|-
|-
| <code>GiveAmmo</code>
| <code>ClearOrders</code>
| <code>void GiveAmmo(int ''amount'', int ''ammoIndex'')</code>
| <code>void ClearOrders()</code>
| Gives the marine ammo for the specified ammo index.
| Clear the alien's orders.
|-
|-
| <code>GiveWeapon</code>
| <code>OrderMoveTo</code>
| <code>void GiveWeapon(string ''weaponName'', int ''slot'')</code>
| <code>void OrderMoveTo(entity ''orderObject'', bool ''ignoreMarines'')</code>
| Gives the marine a weapon.
| Order the alien to chase an entity.
|-
| <code>ChaseNearestMarine</code>
| <code>void ChaseNearestMarine()</code>
| Order the alien to chase the nearest marine.
|-
| <code>Extinguish</code>
| <code>void Extinguish()</code>
| Put out a fire.
|-
|-
| <code>Ignite</code>
| <code>Ignite</code>
| <code>void Ignite(float ''duration'')</code>
| <code>void Ignite(float ''duration'')</code>
| Ignites the marine into flames.
| Set a character on fire.
|-
| <code>Thaw</code>
| <code>void Thaw(float ''amount'')</code>
| Unfreeze this character.
|-
|-
| <code>IsInhabited</code>
| <code>Freeze</code>
| <code>bool IsInhabited()</code>
| <code>void Freeze(float ''amount'')</code>
| True if the marine is a player, false if the marine is a bot.
| Freeze this character.
|-
|-
| <code>Knockdown</code>
| <code>ElectroStun</code>
| <code>void Knockdown(Vector ''velocity'')</code>
| <code>void ElectroStun(float ''duration'')</code>
| Knocks down the marine with desired velocity.
| Electrocute this character.
|-
|-
| <code>RemoveWeapon</code>
| <code>Wake</code>
| <code>void RemoveWeapon(int ''slot'')</code>
| <code>void Wake()</code>
| Removes a weapon from the marine.
| Wake up this character's AI.
|-
|-
| <code>SetKnockedOut</code>
| <code>Die</code>
| <code>void SetKnockedOut(bool ''knockedOut'')</code>
| <code>void Die()</code>
| Used to knock out and incapacitate a marine, or revive them.
| Kills this character with damage (shortcut, alternative to using SetHealth followed by TakeDamage).
|-
|-
| <code>Speak</code>
| <code>SetSpawnZombineOnMarineKill</code>
| <code>void Speak(string ''concept'', float ''delay'', string ''criteria'')</code>
| <code>void SetSpawnZombineOnMarineKill(bool ''spawnZombine'')</code>
| Makes the marine speak a response rules concept.
| Sets this character to spawn a zombie marine if it kills a marine.
|-
|-
| <code>SwitchWeapon</code>
| <code>SetHealthBarColor</code>
| <code>bool SwitchWeapon(int ''slot'')</code>
| <code>void SetHealthBarColor(int ''r'', int ''g'', int ''b'', int ''a'')</code>
| Make the marine switch to a weapon.
| Sets the health bar color. Cheaper than spawning an asw_health_bar. Set alpha to 0 to disable the health bar.
|-
|-
| <code>SetMarineRolls</code>
| <code>SetHealthBarScale</code>
| <code>void SetMarineRolls(bool ''bRolls'')</code>
| <code>void SetHealthBarScale(float ''scale'')</code>
| Send true to make a marine roll when the player presses the roll button, send false to make a marine jump (Changing asw_marine_rolls ConVar overrides all marines' roll/jump behavior).
| Sets the health bar scale. Negative scales hide the health bar if the alien's health is full.
|-
| <code>SetSpawnZombineOnDeath</code>
| <code>void SetSpawnZombineOnDeath(bool ''bSpawn'')</code>
| Makes a zombine spawn when the marine dies.
|-
| <code>SetColorCorrection</code>
| <code>void SetColorCorrection(handle ''entity'')</code>
| Force this character to use a specific color_correction.
|-
| <code>SetFogController</code>
| <code>void SetFogController(handle ''entity'')</code>
| Force this character to use a specific env_fog_controller.
|-
| <code>SetPostProcessController</code>
| <code>void SetPostProcessController(handle ''entity'')</code>
| Force this character to use a specific postprocess_controller.
|-
|-
| <code>SetTonemapController</code>
| <code>SetHealthBarOffset</code>
| <code>void SetTonemapController(handle ''entity'')</code>
| <code>void SetHealthBarOffset(Vector ''offset'')</code>
| Force this character to use a specific env_tonemap_controller.
| Sets the health bar offset in local space.
|}
|}


Example of how a script writer might set up the handles, with a table ''g_fx_t'' (For SetColorCorrection, SetFogController, SetPostProcessController, SetTonemapController functions usage).
=== CBaseTrigger ===
Extends [[#CBaseEntity|CBaseEntity]]


<source lang="cpp">
Entity class for triggers.
function OnMissionStart()
{
InitFXTable();
}


g_fx_t <- {};
==== Methods ====
 
{| class="standard-table" style="width: 100%;"
function InitFXTable()
! Function
{
! Signature
// color corrections
! Description
local cc_kvs_t =
|-
{
| <code>Disable</code>
// shouldnt be edited
| <code>void Disable() </code>
maxfalloff = -1
| Disable the trigger
spawnflags = 2
|-
| <code>Enable</code>
// can be edited
| <code>void Enable() </code>
fadeOutDuration = 0.5
| Enable the trigger
filename = "scripts/colorcorrection/cc_std_sepia.raw"
|-
};
| <code>IsTouching</code>
g_fx_t[ "cc_sepia" ] <- SpawnEntityFromTable( "color_correction", cc_kvs_t );
| <code>bool IsTouching(handle ''entity'') </code>
| Checks whether the passed entity is touching the trigger.
cc_kvs_t[ "filename" ] = "scripts/colorcorrection/infested_green.raw";
|-
g_fx_t[ "cc_red" ] <- SpawnEntityFromTable( "color_correction", cc_kvs_t );
| <code>GetNumTouching</code>
| <code>int GetNumTouching()</code>
// fog controllers
| Returns the number of entities currently touching the trigger.
local fog_kvs_t =
|-
{
| <code>GetTouching</code>
// shouldnt be edited
| <code>handle GetTouching(int ''index'')</code>
fogenable = 1
| Returns an entity currently touching the trigger. If index is not from 0 to GetNumTouching() - 1, returns null.
|}
// can be edited
 
foglerptime = 0
=== CASW_Marine ===
fogstart = 500
Extends [[#CASW_Inhabitable_NPC|CASW_Inhabitable_NPC]]
fogend = 2000
fogcolor = "192 70 70"
fogmaxdensity = 0.4
};
g_fx_t[ "fog_red" ] <- SpawnEntityFromTable( "env_fog_controller", fog_kvs_t );
fog_kvs_t[ "fogcolor" ] = "50 255 50";
fog_kvs_t[ "fogstart" ] = 0;
g_fx_t[ "fog_green" ] <- SpawnEntityFromTable( "env_fog_controller", fog_kvs_t );


// postprocess controllers
==== Methods ====
local pp_kvs_t =
{| class="standard-table" style="width: 100%;"
{
! Function
// can be edited
! Signature
fadetime = 0.25
! Description
localcontrastedgestrength = 3
|-
localcontraststrength = 3
| <code>AddSlowHeal</code>
fadetoblackstrength = 0
| <code>void AddSlowHeal(int ''health'', float ''healratescale'', handle ''healer'', handle ''weapon'')</code>
screenblurstrength = 0
| Heals the marine. Medic and weapon can be null, those are used for stats.
depthblurstrength = 0
|-
depthblurfocaldistance = 0
| <code>BecomeInfested</code>
};
| <code>void BecomeInfested()</code>
g_fx_t[ "pp_contrast_high" ] <- SpawnEntityFromTable( "postprocess_controller", pp_kvs_t );
| Infests the marine.
|-
pp_kvs_t[ "localcontrastedgestrength" ] = 0;
| <code>CureInfestation</code>
pp_kvs_t[ "localcontraststrength" ] = 0;
| <code>void CureInfestation()</code>
pp_kvs_t[ "fadetoblackstrength" ] = 0.5;
| Cures an infestation.
pp_kvs_t[ "screenblurstrength" ] = 0.55;
|-
pp_kvs_t[ "depthblurstrength" ] = 0.2;
| <code>DropWeapon</code>
pp_kvs_t[ "depthblurfocaldistance" ] = 0.9;
| <code>void DropWeapon(int ''slot'')</code>
g_fx_t[ "pp_blurry" ] <- SpawnEntityFromTable( "postprocess_controller", pp_kvs_t );
| Makes the marine drop a weapon.
 
|-
// tonemap controllers a little more tricky, have no keyvalues so we are playing with netprops
| <code>Extinguish</code>
local hTNMP = Entities.CreateByClassname( "env_tonemap_controller" );
| <code>void Extinguish()</code>
NetProps.SetPropBool( hTNMP, "m_bUseCustomAutoExposureMin", true );
| Extinguish a burning marine.
NetProps.SetPropBool( hTNMP, "m_bUseCustomAutoExposureMax", true );
|-
NetProps.SetPropBool( hTNMP, "m_bUseCustomManualTonemapRate", true );
| <code>GetCommander</code>
NetProps.SetPropFloat( hTNMP, "m_flCustomManualTonemapRate", 0.0 );
| <code>CBasePlayer GetCommander()</code>
| Get the player that owns the marine.
NetProps.SetPropFloat( hTNMP, "m_flCustomAutoExposureMin", 0.0 );
|-
NetProps.SetPropFloat( hTNMP, "m_flCustomAutoExposureMax", 0.0 );
| <code>GetInventoryTable</code>
g_fx_t[ "tnmp_dark" ] <- hTNMP;
| <code>void GetInventoryTable(table)</code>
}
| Fills the passed table with the marine's inventory.
</source>
|-
 
| <code>GetInvTable</code>
Accessing the handles example:
| <code>table GetInvTable()</code>
 
| -DEPRECATED- Returns a table of the marine's inventory data.
<source lang="cpp">
|-
function OnGameEvent_marine_infested( params )
| <code>GetMarineName</code>
{
| <code>string GetMarineName()</code>
local hMarine = EntIndexToHScript( params[ "entindex" ] );
| -DEPRECATED- Returns the ''translated'' marine name. This changes based on the host's game language.
|-
hMarine.SetFogController( g_fx_t[ "fog_green" ] );
| <code>GetMarineProfile</code>
hMarine.SetPostProcessController( g_fx_t[ "pp_blurry" ] );
| <code>int GetMarineProfile()</code>
hMarine.SetTonemapController( g_fx_t[ "tnmp_dark" ] );
| Returns an integer representing which marine profile is in use. Constants are available: <code>ASW_MARINE_PROFILE_SARGE</code>, <code>ASW_MARINE_PROFILE_WILDCAT</code>, <code>ASW_MARINE_PROFILE_FAITH</code>, etc.
}
|-
 
| <code>GiveAmmo</code>
function OnGameEvent_marine_infested_cured( params )
| <code>void GiveAmmo(int ''amount'', int ''ammoIndex'')</code>
{
| Gives the marine ammo for the specified ammo index.
local hMarine = EntIndexToHScript( params[ "entindex" ] );
|-
| <code>GiveWeapon</code>
hMarine.SetFogController( null );
| <code>void GiveWeapon(string ''weaponName'', int ''slot'')</code>
hMarine.SetPostProcessController( null );
| Gives the marine a weapon.
hMarine.SetTonemapController( null );
}
</source>
 
=== CASW_Alien ===
Extends [[#CBaseCombatCharacter|CBaseCombatCharacter]]
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>ChaseNearestMarine</code>
| <code>Ignite</code>
| <code>void ChaseNearestMarine()</code>
| <code>void Ignite(float ''duration'')</code>
| Order the alien to chase the nearest marine.
| Ignites the marine into flames.
|-
|-
| <code>ClearOrders</code>
| <code>IsInhabited</code>
| <code>void ClearOrders()</code>
| <code>bool IsInhabited()</code>
| Clear the alien's orders.
| True if the marine is a player, false if the marine is a bot.
|-
|-
| <code>ElectroStun</code>
| <code>Knockdown</code>
| <code>void ElectroStun(float ''duration'')</code>
| <code>void Knockdown(Vector ''velocity'')</code>
| Stuns the alien.
| Knocks down the marine with desired velocity.
|-
|-
| <code>Extinguish</code>
| <code>OrderMoveTo</code>
| <code>void Extinguish()</code>
| <code>void OrderMoveTo(float ''yaw'', Vector ''position'')</code>
| Extinguish a burning alien.
| Order an uninhabited marine to move to this position.
|-
|-
| <code>Freeze</code>
| <code>RemoveWeapon</code>
| <code>void Freeze(float ''freezeTime'')</code>
| <code>void RemoveWeapon(int ''slot'')</code>
| Freezes the alien.
| Removes a weapon from the marine.
|-
|-
| <code>Ignite</code>
| <code>SetKnockedOut</code>
| <code>void Ignite(float ''duration'')</code>
| <code>void SetKnockedOut(bool ''knockedOut'')</code>
| Ignites the alien into flames.
| Used to knock out and incapacitate a marine, or revive them.
|-
|-
| <code>OrderMoveTo</code>
| <code>Speak</code>
| <code>bool OrderMoveTo(handle ''entity'', bool ''ignoreMarines'')</code>
| <code>void Speak(string ''concept'', float ''delay'', string ''criteria'')</code>
| Order the alien to move to an entity handle, second parameter ignore marines.
| Makes the marine speak a response rules concept.
|-
|-
| <code>Wake</code>
| <code>SwitchWeapon</code>
| <code>void Wake(bool ''bFireOutput'')</code>
| <code>bool SwitchWeapon(int ''slot'')</code>
| Wake up the alien, with option to fire output.
| Make the marine switch to a weapon.
|-
|-
| <code>SetSpawnZombineOnMarineKill</code>
| <code>SetMarineRolls</code>
| <code>void SetSpawnZombineOnMarineKill(bool ''bSpawn'')</code>
| <code>void SetMarineRolls(bool ''bRolls'')</code>
| Makes a zombine spawn after killing a marine.
| Send true to make a marine roll when the player presses the roll button, send false to make a marine jump (Changing asw_marine_rolls ConVar overrides all marines' roll/jump behavior).
|-
| <code>SetSpawnZombineOnDeath</code>
| <code>void SetSpawnZombineOnDeath(bool ''bSpawn'')</code>
| Makes a zombine spawn when the marine dies.
|-
| <code>SetColorCorrection</code>
| <code>void SetColorCorrection(handle ''entity'')</code>
| Force this character to use a specific color_correction.
|-
| <code>SetFogController</code>
| <code>void SetFogController(handle ''entity'')</code>
| Force this character to use a specific env_fog_controller.
|-
| <code>SetPostProcessController</code>
| <code>void SetPostProcessController(handle ''entity'')</code>
| Force this character to use a specific postprocess_controller.
|-
| <code>SetTonemapController</code>
| <code>void SetTonemapController(handle ''entity'')</code>
| Force this character to use a specific env_tonemap_controller.
|}
|}


Example of how a script writer might set up the handles, with a table ''g_fx_t'' (For SetColorCorrection, SetFogController, SetPostProcessController, SetTonemapController functions usage).
<source lang="cpp">
function OnMissionStart()
{
InitFXTable();
}


=== CASW_Parasite ===
g_fx_t <- {};
Extends [[#CASW_Alien|CASW_Alien]]


==== Methods ====
function InitFXTable()
{| class="standard-table" style="width: 100%;"
{
! Function
// color corrections
! Signature
local cc_kvs_t =  
! Description
{
|-
// shouldnt be edited
| <code>JumpAttack</code>
maxfalloff = -1
| <code>void JumpAttack()</code>
spawnflags = 2
| Jump and attack something.
|}
// can be edited
 
fadeOutDuration = 0.5
 
filename = "scripts/colorcorrection/cc_std_sepia.raw"
=== CASW_Buzzer ===
};
Extends [[#CBaseAnimating|CBaseAnimating]]
g_fx_t[ "cc_sepia" ] <- SpawnEntityFromTable( "color_correction", cc_kvs_t );
 
==== Methods ====
cc_kvs_t[ "filename" ] = "scripts/colorcorrection/infested_green.raw";
{| class="standard-table" style="width: 100%;"
g_fx_t[ "cc_red" ] <- SpawnEntityFromTable( "color_correction", cc_kvs_t );
! Function
! Signature
// fog controllers
! Description
local fog_kvs_t =
|-
{
| <code>ChaseNearestMarine</code>
// shouldnt be edited
| <code>void ChaseNearestMarine()</code>
fogenable = 1
| Order the buzzer to chase the nearest marine.
|-
// can be edited
| <code>ClearOrders</code>
foglerptime = 0
| <code>void ClearOrders()</code>
fogstart = 500
| Clear the buzzer's orders.
fogend = 2000
|-
fogcolor = "192 70 70"
| <code>ElectroStun</code>
fogmaxdensity = 0.4
| <code>void ElectroStun(float ''duration'')</code>
};
| Stuns the buzzer.
g_fx_t[ "fog_red" ] <- SpawnEntityFromTable( "env_fog_controller", fog_kvs_t );
|-
| <code>Extinguish</code>
fog_kvs_t[ "fogcolor" ] = "50 255 50";
| <code>void Extinguish()</code>
fog_kvs_t[ "fogstart" ] = 0;
| Extinguish a burning buzzer.
g_fx_t[ "fog_green" ] <- SpawnEntityFromTable( "env_fog_controller", fog_kvs_t );
|-
 
| <code>Freeze</code>
// postprocess controllers
| <code>void Freeze(float ''freezeTime'')</code>
local pp_kvs_t =
| Freezes the buzzer.
{
|-
// can be edited
| <code>Ignite</code>
fadetime = 0.25
| <code>void Ignite(float ''duration'')</code>
localcontrastedgestrength = 3
| Ignites the buzzer into flames.
localcontraststrength = 3
|-
fadetoblackstrength = 0
| <code>OrderMoveTo</code>
screenblurstrength = 0
| <code>bool OrderMoveTo(handle ''entity'', bool ''ignoreMarines'')</code>
depthblurstrength = 0
| Order the buzzer to move to an entity handle, second parameter ignore marines.
depthblurfocaldistance = 0
|-
};
| <code>Wake</code>
g_fx_t[ "pp_contrast_high" ] <- SpawnEntityFromTable( "postprocess_controller", pp_kvs_t );
| <code>void Wake(bool ''bFireOutput'')</code>
| Wake up the buzzer, with option to fire output.
pp_kvs_t[ "localcontrastedgestrength" ] = 0;
|}
pp_kvs_t[ "localcontraststrength" ] = 0;
pp_kvs_t[ "fadetoblackstrength" ] = 0.5;
pp_kvs_t[ "screenblurstrength" ] = 0.55;
pp_kvs_t[ "depthblurstrength" ] = 0.2;
pp_kvs_t[ "depthblurfocaldistance" ] = 0.9;
g_fx_t[ "pp_blurry" ] <- SpawnEntityFromTable( "postprocess_controller", pp_kvs_t );


// tonemap controllers a little more tricky, have no keyvalues so we are playing with netprops
local hTNMP = Entities.CreateByClassname( "env_tonemap_controller" );
NetProps.SetPropBool( hTNMP, "m_bUseCustomAutoExposureMin", true );
NetProps.SetPropBool( hTNMP, "m_bUseCustomAutoExposureMax", true );
NetProps.SetPropBool( hTNMP, "m_bUseCustomManualTonemapRate", true );
NetProps.SetPropFloat( hTNMP, "m_flCustomManualTonemapRate", 0.0 );
NetProps.SetPropFloat( hTNMP, "m_flCustomAutoExposureMin", 0.0 );
NetProps.SetPropFloat( hTNMP, "m_flCustomAutoExposureMax", 0.0 );
g_fx_t[ "tnmp_dark" ] <- hTNMP;
}
</source>
Accessing the handles example:
<source lang="cpp">
function OnGameEvent_marine_infested( params )
{
local hMarine = EntIndexToHScript( params[ "entindex" ] );
hMarine.SetFogController( g_fx_t[ "fog_green" ] );
hMarine.SetPostProcessController( g_fx_t[ "pp_blurry" ] );
hMarine.SetTonemapController( g_fx_t[ "tnmp_dark" ] );
}
function OnGameEvent_marine_infested_cured( params )
{
local hMarine = EntIndexToHScript( params[ "entindex" ] );
hMarine.SetFogController( null );
hMarine.SetPostProcessController( null );
hMarine.SetTonemapController( null );
}
</source>


=== CASW_Colonist ===
=== CASW_Alien ===
Extends [[#CBaseCombatCharacter|CBaseCombatCharacter]]
Extends [[#CASW_Inhabitable_NPC|CASW_Inhabitable_NPC]]


==== Methods ====
==== Methods ====
Line 962: Line 1,009:
! Description
! Description
|-
|-
| <code>BecomeInfested</code>
| <code>ChaseNearestMarine</code>
| <code>void BecomeInfested()</code>
| <code>void ChaseNearestMarine()</code>
| Infests the colonist.
| Order the alien to chase the nearest marine.
|-
|-
| <code>CureInfestation</code>
| <code>ClearOrders</code>
| <code>void CureInfestation()</code>
| <code>void ClearOrders()</code>
| Cures an infestation.
| Clear the alien's orders.
|-
|-
| <code>DropWeapon</code>
| <code>ElectroStun</code>
| <code>void DropWeapon()</code>
| <code>void ElectroStun(float ''duration'')</code>
| Makes the colonist drop a weapon.
| Stuns the alien.
|-
|-
| <code>Extinguish</code>
| <code>Extinguish</code>
| <code>void Extinguish()</code>
| <code>void Extinguish()</code>
| Extinguish a burning colonist.
| Extinguish a burning alien.
|-
|-
| <code>GiveWeapon</code>
| <code>Freeze</code>
| <code>void GiveWeapon(string ''weaponName'')</code>
| <code>void Freeze(float ''freezeTime'')</code>
| Gives the colonist a weapon.
| Freezes the alien.
|-
|-
| <code>Ignite</code>
| <code>Ignite</code>
| <code>void Ignite(float ''duration'')</code>
| <code>void Ignite(float ''duration'')</code>
| Ignites the colonist into flames.
| Ignites the alien into flames.
|-
| <code>OrderMoveTo</code>
| <code>bool OrderMoveTo(handle ''entity'', bool ''ignoreMarines'')</code>
| Order the alien to move to an entity handle, second parameter ignore marines.
|-
|-
| <code>RemoveWeapon</code>
| <code>Wake</code>
| <code>void RemoveWeapon()</code>
| <code>void Wake(bool ''bFireOutput'')</code>
| Removes a weapon from the colonist.
| Wake up the alien, with option to fire output.
|}
|-
| <code>SetSpawnZombineOnMarineKill</code>
| <code>void SetSpawnZombineOnMarineKill(bool ''bSpawn'')</code>
| Makes a zombine spawn after killing a marine.
|}




=== CBaseCombatWeapon ===
=== CASW_Parasite ===
Extends [[#CBaseAnimating|CBaseAnimating]]
Extends [[#CASW_Alien|CASW_Alien]]


==== Methods ====
==== Methods ====
Line 1,001: Line 1,056:
! Description
! Description
|-
|-
| <code>Clip1</code>
| <code>JumpAttack</code>
| <code>int Clip1()</code>
| <code>void JumpAttack()</code>
| Get the weapon's current primary clip. Note: also used to get the offhand item's count.
| Jump and attack something.
|}
 
 
=== CASW_Buzzer ===
Extends [[#CASW_Inhabitable_NPC|CASW_Inhabitable_NPC]]
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>Clip2</code>
| <code>ChaseNearestMarine</code>
| <code>int Clip2()</code>
| <code>void ChaseNearestMarine()</code>
| Get the weapon's current secondary clip.
| Order the buzzer to chase the nearest marine.
|-
|-
| <code>GetClips</code>
| <code>ClearOrders</code>
| <code>int GetClips()</code>
| <code>void ClearOrders()</code>
| Get the amount of clips for weapon.
| Clear the buzzer's orders.
|-
|-
| <code>GetDefaultClip1</code>
| <code>ElectroStun</code>
| <code>int GetDefaultClip1()</code>
| <code>void ElectroStun(float ''duration'')</code>
| Get the weapon's default primary clip. Note: also used to get the offhand item's default count.
| Stuns the buzzer.
|-
|-
| <code>GetDefaultClip2</code>
| <code>Extinguish</code>
| <code>int GetDefaultClip2()</code>
| <code>void Extinguish()</code>
| Get the weapon's default secondary clip.
| Extinguish a burning buzzer.
|-
|-
| <code>GetMaxAmmo1</code>
| <code>Freeze</code>
| <code>int GetMaxAmmo1()</code>
| <code>void Freeze(float ''freezeTime'')</code>
| Get max primary ammo for weapon.
| Freezes the buzzer.
|-
|-
| <code>GetMaxAmmo2</code>
| <code>Ignite</code>
| <code>int GetMaxAmmo2()</code>
| <code>void Ignite(float ''duration'')</code>
| Get max secondary ammo for weapon.
| Ignites the buzzer into flames.
|-
|-
| <code>GetMaxClip1</code>
| <code>OrderMoveTo</code>
| <code>int GetMaxClip1()</code>
| <code>bool OrderMoveTo(handle ''entity'', bool ''ignoreMarines'')</code>
| Get max primary clip for weapon. Note: also used to get the offhand item's max count.
| Order the buzzer to move to an entity handle, second parameter ignore marines.
|-
|-
| <code>GetMaxClip2</code>
| <code>Wake</code>
| <code>int GetMaxClip2()</code>
| <code>void Wake(bool ''bFireOutput'')</code>
| Get max secondary clip for weapon.
| Wake up the buzzer, with option to fire output.
|-
| <code>GetMaxClips</code>
| <code>int GetMaxClips()</code>
| Get max total clips for weapon.
|-
| <code>SetClip1</code>
| <code>void SetClip1(int ''amount'')</code>
| Set weapon's primary clip. Note: also used to set the offhand item's count.
|-
| <code>SetClip2</code>
| <code>void SetClip2(int ''amount'')</code>
| Set weapon's secondary clip.
|-
| <code>SetClips</code>
| <code>void SetClips(int ''amount'')</code>
| Set weapon's total clips.
|}
|}


 
=== CASW_Colonist ===
=== CASW_Sentry_Base ===
Extends [[#CASW_Inhabitable_NPC|CASW_Inhabitable_NPC]]
Extends [[#CBaseAnimating|CBaseAnimating]]


==== Methods ====
==== Methods ====
Line 1,064: Line 1,113:
! Description
! Description
|-
|-
| <code>GetAmmo</code>
| <code>BecomeInfested</code>
| <code>int GetAmmo()</code>
| <code>void BecomeInfested()</code>
| Get the sentry's current ammo.
| Infests the colonist.
|-
|-
| <code>GetMaxAmmo</code>
| <code>CureInfestation</code>
| <code>int GetMaxAmmo()</code>
| <code>void CureInfestation()</code>
| Get the sentry's max allowed ammo.
| Cures an infestation.
|-
|-
| <code>GetSentryTop</code>
| <code>DropWeapon</code>
| <code>CASW_Sentry_Top GetSentryTop()</code>
| <code>void DropWeapon()</code>
| Get a handle of the sentry's top.
| Makes the colonist drop a weapon.
|-
| <code>Extinguish</code>
| <code>void Extinguish()</code>
| Extinguish a burning colonist.
|-
| <code>GiveWeapon</code>
| <code>void GiveWeapon(string ''weaponName'')</code>
| Gives the colonist a weapon.
|-
| <code>Ignite</code>
| <code>void Ignite(float ''duration'')</code>
| Ignites the colonist into flames.
|-
|-
| <code>SetAmmo</code>
| <code>RemoveWeapon</code>
| <code>void SetAmmo()</code>
| <code>void RemoveWeapon()</code>
| Set the sentry's current ammo.
| Removes a weapon from the colonist.
|}
|}


=== CASW_Sentry_Top ===
 
=== CBaseCombatWeapon ===
Extends [[#CBaseAnimating|CBaseAnimating]]
Extends [[#CBaseAnimating|CBaseAnimating]]


Line 1,090: Line 1,152:
! Description
! Description
|-
|-
| <code>PreventFiringUntil</code>
| <code>Clip1</code>
| <code>void PreventFiringUntil(float ''nextFireTime'')</code>
| <code>int Clip1()</code>
| Prevents sentry from firing until the time set.
| Get the weapon's current primary clip. Note: also used to get the offhand item's count.
|}
|-
 
| <code>Clip2</code>
=== CASW_Weapon_Sentry ===
| <code>int Clip2()</code>
Extends [[#CASW_Weapon|CASW_Weapon]]
| Get the weapon's current secondary clip.
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>GetSentryAmmo</code>
| <code>GetClips</code>
| <code>int GetSentryAmmo()</code>
| <code>int GetClips()</code>
| Returns the amount of ammo for the contained sentry.
| Get the amount of clips for weapon.
|-
|-
| <code>SetSentryAmmo</code>
| <code>GetDefaultClip1</code>
| <code>void SetSentryAmmo(int ''nAmmo'')</code>
| <code>int GetDefaultClip1()</code>
| Changes the amount of ammo for the contained sentry.
| Get the weapon's default primary clip. Note: also used to get the offhand item's default count.
|}
 
 
=== CAI_DynamicLink ===
Extends [[#CBaseEntity|CBaseEntity]]
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>FindLink</code>
| <code>GetDefaultClip2</code>
| <code>CAI_Link FindLink()</code>
| <code>int GetDefaultClip2()</code>
| Returns the node link or null if not found.
| Get the weapon's default secondary clip.
|-
| <code>GetMaxAmmo1</code>
| <code>int GetMaxAmmo1()</code>
| Get max primary ammo for weapon.
|-
|-
| <code>GetDestNode</code>
| <code>GetMaxAmmo2</code>
| <code>CAI_Node GetDestNode()</code>
| <code>int GetMaxAmmo2()</code>
| Returns the node on the other end of the link.
| Get max secondary ammo for weapon.
|-
|-
| <code>GetSrcNode</code>
| <code>GetMaxClip1</code>
| <code>CAI_Node GetSrcNode()</code>
| <code>int GetMaxClip1()</code>
| Returns the node that 'owns' this link.
| Get max primary clip for weapon. Note: also used to get the offhand item's max count.
|-
|-
| <code>IsLinkValid</code>
| <code>GetMaxClip2</code>
| <code>bool IsLinkValid()</code>
| <code>int GetMaxClip2()</code>
| Returns true if the dynamic link has a corresponding node link.
| Get max secondary clip for weapon.
|-
|-
| <code>TurnOff</code>
| <code>GetMaxClips</code>
| <code>void TurnOff()</code>
| <code>int GetMaxClips()</code>
| Disables node link connections.
| Get max total clips for weapon.
|-
|-
| <code>TurnOn</code>
| <code>SetClip1</code>
| <code>void TurnOn()</code>
| <code>void SetClip1(int ''amount'')</code>
| Enables node link connections.
| Set weapon's primary clip. Note: also used to set the offhand item's count.
|}
|-
| <code>SetClip2</code>
| <code>void SetClip2(int ''amount'')</code>
| Set weapon's secondary clip.
|-
| <code>SetClips</code>
| <code>void SetClips(int ''amount'')</code>
| Set weapon's total clips.
|}




=== CAI_Link ===
=== CASW_Sentry_Base ===
This is a script handle class for node links.
Extends [[#CBaseAnimating|CBaseAnimating]]


==== Methods ====
==== Methods ====
Line 1,158: Line 1,215:
! Description
! Description
|-
|-
| <code>GetAcceptedMoveTypes</code>
| <code>GetAmmo</code>
| <code>int GetAcceptedMoveTypes(int ''hullType'')</code>
| <code>int GetAmmo()</code>
| Get the Capability_T of motions acceptable for passed hull type.
| Get the sentry's current ammo.
|-
|-
| <code>GetDangerCount</code>
| <code>GetMaxAmmo</code>
| <code>int GetDangerCount()</code>
| <code>int GetMaxAmmo()</code>
| Returns how many dangerous things are near this link.
| Get the sentry's max allowed ammo.
|-
|-
| <code>GetDestNodeID</code>
| <code>GetSentryTop</code>
| <code>int GetDestNodeID()</code>
| <code>CASW_Sentry_Top GetSentryTop()</code>
| Get the ID of the node on the other end of the link.
| Get a handle of the sentry's top.
|-
|-
| <code>GetDynamicLink</code>
| <code>SetAmmo</code>
| <code>CAI_DynamicLink GetDynamicLink()</code>
| <code>void SetAmmo()</code>
| Returns the info_node_link entity for this link or null if it doesn't exist.
| Set the sentry's current ammo.
|-
| <code>GetLinkInfo</code>
| <code>int GetLinkInfo()</code>
| Get other information about this link.
|-
| <code>GetSrcNodeID</code>
| <code>int GetSrcNodeID()</code>
| Get the ID of the node that 'owns' this link.
|-
| <code>GetTimeStaleExpires</code>
| <code>float GetTimeStaleExpires()</code>
| Returns the amount of time until this link is available again.
|-
| <code>SetAcceptedMoveTypes</code>
| <code>void SetAcceptedMoveTypes(int ''hullType'', int ''moveType'')</code>
| Set the Capability_T of motions acceptable for passed hull type.
|-
| <code>SetDangerCount</code>
| <code>void SetDangerCount(int ''count'')</code>
| Sets how many dangerous things are near this link.
|-
| <code>SetLinkInfo</code>
| <code>void SetLinkInfo(int ''info'')</code>
| Sets information about this link.
|-
| <code>SetTimeStaleExpires</code>
| <code>void SetTimeStaleExpires(float ''duration'')</code>
| Sets the amount of time until this link is available again.
|}
|}


=== CASW_Sentry_Top ===
Extends [[#CBaseAnimating|CBaseAnimating]]


=== CAI_Node ===
==== Methods ====
This is a script handle class for nodes.
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
| <code>PreventFiringUntil</code>
| <code>void PreventFiringUntil(float ''nextFireTime'')</code>
| Prevents sentry from firing until the time set.
|}
 
=== CASW_Weapon_Sentry ===
Extends [[#CASW_Weapon|CASW_Weapon]]


==== Methods ====
==== Methods ====
Line 1,213: Line 1,255:
! Description
! Description
|-
|-
| <code>AddLink</code>
| <code>GetSentryAmmo</code>
| <code>void AddLink(CAI_Link ''link'')</code>
| <code>int GetSentryAmmo()</code>
| Adds a link to this node.
| Returns the amount of ammo for the contained sentry.
|-
|-
| <code>ClearLinks</code>
| <code>SetSentryAmmo</code>
| <code>void ClearLinks()</code>
| <code>void SetSentryAmmo(int ''nAmmo'')</code>
| Clears all links from node.
| Changes the amount of ammo for the contained sentry.
|}
 
 
=== CAI_DynamicLink ===
Extends [[#CBaseEntity|CBaseEntity]]
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>DebugDrawNode</code>
| <code>FindLink</code>
| <code>void DebugDrawNode(int ''r'', int ''g'', int ''b'', float ''duration'')</code>
| <code>CAI_Link FindLink()</code>
| Draw node as a box of the given color for x seconds.
| Returns the node link or null if not found.
|-
|-
| <code>GetId</code>
| <code>GetDestNode</code>
| <code>int GetId()</code>
| <code>CAI_Node GetDestNode()</code>
| Get node ID.
| Returns the node on the other end of the link.
|-
|-
| <code>GetInfo</code>
| <code>GetSrcNode</code>
| <code>int GetInfo()</code>
| <code>CAI_Node GetSrcNode()</code>
| Get node info.
| Returns the node that 'owns' this link.
|-
|-
| <code>GetLink</code>
| <code>IsLinkValid</code>
| <code>CAI_Link GetLink(int ''nodeID'')</code>
| <code>bool IsLinkValid()</code>
| Get link to dest node ID.
| Returns true if the dynamic link has a corresponding node link.
|-
|-
| <code>GetLinkByIndex</code>
| <code>TurnOff</code>
| <code>CAI_Link GetLinkByIndex(int ''index'')</code>
| <code>void TurnOff()</code>
| Get link by index.
| Disables node link connections.
|-
|-
| <code>GetOrigin</code>
| <code>TurnOn</code>
| <code>Vector GetOrigin()</code>
| <code>void TurnOn()</code>
| Get node origin.
| Enables node link connections.
|}
 
 
=== CAI_Link ===
This is a script handle class for node links.
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>GetPosition</code>
| <code>GetAcceptedMoveTypes</code>
| <code>Vector GetPosition(int ''hullType'')</code>
| <code>int GetAcceptedMoveTypes(int ''hullType'')</code>
| Get hull specific position for a node.
| Get the Capability_T of motions acceptable for passed hull type.
|-
|-
| <code>GetType</code>
| <code>GetDangerCount</code>
| <code>int GetType()</code>
| <code>int GetDangerCount()</code>
| Get node type.
| Returns how many dangerous things are near this link.
|-
|-
| <code>GetYaw</code>
| <code>GetDestNodeID</code>
| <code>float GetYaw()</code>
| <code>int GetDestNodeID()</code>
| Get node Yaw.
| Get the ID of the node on the other end of the link.
|-
|-
| <code>GetZone</code>
| <code>GetDynamicLink</code>
| <code>int GetZone()</code>
| <code>CAI_DynamicLink GetDynamicLink()</code>
| Get node zone.
| Returns the info_node_link entity for this link or null if it doesn't exist.
|-
|-
| <code>IsLocked</code>
| <code>GetLinkInfo</code>
| <code>bool IsLocked()</code>
| <code>int GetLinkInfo()</code>
| Returns true if node is locked.
| Get other information about this link.
|-
|-
| <code>Lock</code>
| <code>GetSrcNodeID</code>
| <code>void Lock(float ''duration'')</code>
| <code>int GetSrcNodeID()</code>
| Locks the node for x seconds.
| Get the ID of the node that 'owns' this link.
|-
|-
| <code>NumLinks</code>
| <code>GetTimeStaleExpires</code>
| <code>int NumLinks()</code>
| <code>float GetTimeStaleExpires()</code>
| Number of links for node.
| Returns the amount of time until this link is available again.
|-
|-
| <code>RemoveLink</code>
| <code>SetAcceptedMoveTypes</code>
| <code>void RemoveLink(CAI_Link ''link'')</code>
| <code>void SetAcceptedMoveTypes(int ''hullType'', int ''moveType'')</code>
| Removes a link from this node.
| Set the Capability_T of motions acceptable for passed hull type.
|-
|-
| <code>SetInfo</code>
| <code>SetDangerCount</code>
| <code>void SetInfo(int ''info'')</code>
| <code>void SetDangerCount(int ''count'')</code>
| Set node info.
| Sets how many dangerous things are near this link.
|-
|-
| <code>SetType</code>
| <code>SetLinkInfo</code>
| <code>void SetType(int ''type'')</code>
| <code>void SetLinkInfo(int ''info'')</code>
| Set node type.
| Sets information about this link.
|-
|-
| <code>SetZone</code>
| <code>SetTimeStaleExpires</code>
| <code>void SetZone(int ''zone'')</code>
| <code>void SetTimeStaleExpires(float ''duration'')</code>
| Set node zone.
| Sets the amount of time until this link is available again.
|-
| <code>Unlock</code>
| <code>void Unlock()</code>
| Unlocks the node.
|}
|}




=== CEnvEntityMaker ===
=== CAI_Node ===
Extends [[#CBaseEntity|CBaseEntity]]
This is a script handle class for nodes.
 
Script handle class for [[env_entity_maker]].  


==== Methods ====
==== Methods ====
Line 1,306: Line 1,364:
! Description
! Description
|-
|-
| <code>SpawnEntity</code>
| <code>AddLink</code>
| <code>void SpawnEntity()</code>
| <code>void AddLink(CAI_Link ''link'')</code>
| Create an entity at the location of the maker
| Adds a link to this node.
|-
|-
| <code>SpawnEntityAtEntityOrigin</code>
| <code>ClearLinks</code>
| <code>void SpawnEntityAtEntityOrigin(CBaseEntity ''entity'')</code>
| <code>void ClearLinks()</code>
| Create an entity at the location of a specified entity instance.
| Clears all links from node.
|-
|-
| <code>SpawnEntityAtLocation</code>
| <code>DebugDrawNode</code>
| <code>void SpawnEntityAtLocation(Vector ''origin'', Vector ''orientation'')</code>
| <code>void DebugDrawNode(int ''r'', int ''g'', int ''b'', float ''duration'')</code>
| Create an entity at a specified location and orientation, orientation is Euler angle in degrees (pitch, yaw, roll).
| Draw node as a box of the given color for x seconds.
|-
|-
| <code>SpawnEntityAtNamedEntityOrigin</code>
| <code>GetId</code>
| <code>void SpawnEntityAtNamedEntityOrigin(string ''targetName'')</code>
| <code>int GetId()</code>
| Create an entity at the location of a named entity.
| Get node ID.
|}
|-
 
| <code>GetInfo</code>
 
| <code>int GetInfo()</code>
=== CPointTemplate ===
| Get node info.
Extends [[#CBaseEntity|CBaseEntity]]
|-
 
| <code>GetLink</code>
Script handle class for [[point_template]].
| <code>CAI_Link GetLink(int ''nodeID'')</code>
 
| Get link to dest node ID.
==== Hooks ====
|-
 
| <code>GetLinkByIndex</code>
;<code>table PreSpawnInstance(string ''entityClass'', string ''entityName'')</code>
| <code>CAI_Link GetLinkByIndex(int ''index'')</code>
:If this is defined, it will be called right before the entity is created, and any KeyValues returned will be assigned to the entity.
| Get link by index.
 
|-
<source lang="cpp">function PreSpawnInstance( entityClass, entityName )
| <code>GetOrigin</code>
{
| <code>Vector GetOrigin()</code>
local keyvalues =
| Get node origin.
{
|-
  rendercolor = "0 255 0"
| <code>GetPosition</code>
  targetname = "mySpawnedEntity"
| <code>Vector GetPosition(int ''hullType'')</code>
}
| Get hull specific position for a node.
return keyvalues
}
</source>
 
;<code>void PostSpawn(table ''entities'')</code>
: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.  
 
<source lang="cpp">function PostSpawn( entities )
{
foreach( name, handle in entities )
{
printl( name + ": " + handle )
}
}
</source>
 
 
=== CSceneEntity ===
Extends [[#CBaseEntity|CBaseEntity]]
 
==== Methods ====
 
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>AddBroadcastTeamTarget</code>
| <code>GetType</code>
| <code>void AddBroadcastTeamTarget(int ''index'')</code>
| <code>int GetType()</code>
| Adds a team (by index) to the broadcast list.
| Get node type.
|-
|-
| <code>EstimateLength</code>
| <code>GetYaw</code>
| <code>float EstimateLength()</code>
| <code>float GetYaw()</code>
| Returns length of this scene in seconds.
| Get node Yaw.
|-
|-
| <code>FindNamedEntity</code>
| <code>GetZone</code>
| <code>handle FindNamedEntity(string ''reference'')</code>
| <code>int GetZone()</code>
| given an entity reference, such as !target, get actual entity from scene object.
| Get node zone.
|-
|-
| <code>IsPaused</code>
| <code>IsLocked</code>
| <code>bool IsPaused()</code>
| <code>bool IsLocked()</code>
| If this scene is currently paused.
| Returns true if node is locked.
|-
|-
| <code>IsPlayingBack</code>
| <code>Lock</code>
| <code>bool IsPlayingBack()</code>
| <code>void Lock(float ''duration'')</code>
| If this scene is currently playing.
| Locks the node for x seconds.
|-
|-
| <code>LoadSceneFromString</code>
| <code>NumLinks</code>
| <code>bool LoadSceneFromString(string ''sceneName'', string ''scene'')</code>
| <code>int NumLinks()</code>
| Given a dummy scene name and a vcd string, load the scene.
| Number of links for node.
|-
|-
| <code>RemoveBroadcastTeamTarget</code>
| <code>RemoveLink</code>
| <code>void RemoveBroadcastTeamTarget(int ''index'')</code>
| <code>void RemoveLink(CAI_Link ''link'')</code>
| Removes a team (by index) from the broadcast list.
| Removes a link from this node.
|-
| <code>SetInfo</code>
| <code>void SetInfo(int ''info'')</code>
| Set node info.
|-
| <code>SetType</code>
| <code>void SetType(int ''type'')</code>
| Set node type.
|-
| <code>SetZone</code>
| <code>void SetZone(int ''zone'')</code>
| Set node zone.
|-
| <code>Unlock</code>
| <code>void Unlock()</code>
| Unlocks the node.
|}
|}




=== CTriggerCamera ===
=== CEnvEntityMaker ===
Extends [[#CBaseEntity|CBaseEntity]]
Extends [[#CBaseEntity|CBaseEntity]]
Script handle class for [[env_entity_maker]].


==== Methods ====
==== Methods ====
Line 1,408: Line 1,457:
! Description
! Description
|-
|-
| <code>GetFov</code>
| <code>SpawnEntity</code>
| <code>int GetFov()</code>
| <code>void SpawnEntity()</code>
| Get cameras current Field Of View setting as integer.
| Create an entity at the location of the maker
|-
|-
| <code>SetFov</code>
| <code>SpawnEntityAtEntityOrigin</code>
| <code>void SetFov(int ''fov'', float ''rate'')</code>
| <code>void SpawnEntityAtEntityOrigin(CBaseEntity ''entity'')</code>
| Set cameras current FOV in integer degrees and FOV change rate as float.
| Create an entity at the location of a specified entity instance.
|-
| <code>SpawnEntityAtLocation</code>
| <code>void SpawnEntityAtLocation(Vector ''origin'', Vector ''orientation'')</code>
| Create an entity at a specified location and orientation, orientation is Euler angle in degrees (pitch, yaw, roll).
|-
| <code>SpawnEntityAtNamedEntityOrigin</code>
| <code>void SpawnEntityAtNamedEntityOrigin(string ''targetName'')</code>
| Create an entity at the location of a named entity.
|}
|}




=== CASW_Grenade_Cluster ===
=== CPointTemplate ===
Extends [[#CBaseCombatCharacter|CBaseCombatCharacter]]
Extends [[#CBaseEntity|CBaseEntity]]
 
Script handle class for [[point_template]].
 
==== Hooks ====
 
;<code>table PreSpawnInstance(string ''entityClass'', string ''entityName'')</code>
:If this is defined, it will be called right before the entity is created, and any KeyValues returned will be assigned to the entity.


==== Methods ====
<source lang="cpp">function PreSpawnInstance( entityClass, entityName )
{| class="standard-table" style="width: 100%;"
{
! Function
local keyvalues =
! Signature
{
! Description
  rendercolor = "0 255 0"
|-
  targetname = "mySpawnedEntity"
| <code>Disable</code>
}
| <code>void Disable()</code>
return keyvalues
| Disable the grenade.
|-
}
| <code>Enable</code>
</source>
| <code>void Enable()</code>
| Enable the grenade, different time setting like explosion time correctly adjusted after disable state.
|-
| <code>EnableWithReset</code>
| <code>void EnableWithReset()</code>
| Enable the grenade, different time setting like explosion time reset like grenade is newly created.
|-
| <code>ReflectBack</code>
| <code>void ReflectBack()</code>
| Reflect grenade preciselly to firer marine position if marine is alive, ReflectBackSimple used otherwise.
|-
| <code>ReflectBackSimple</code>
| <code>void ReflectBackSimple()</code>
| Reflect grenade near to initial fire position.
|-
| <code>ReflectRandomly</code>
| <code>void ReflectRandomly()</code>
| Reflect grenade to random porition.
|}


==== Hooks ====
;<code>void PostSpawn(table ''entities'')</code>
: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.
 
<source lang="cpp">function PostSpawn( entities )
{
foreach( name, handle in entities )
{
printl( name + ": " + handle )
}
}
</source>


;<code>void ScriptStartCameraShot(string ''shotType'', handle ''sceneEntity'', handle ''actor1'', handle ''actor2'', float ''duration'')</code>
: ''Called from SceneEntity in response to a CChoreoEvent::CAMERA sent from a VCD.'' {{todo}}
=== CDirector ===
Game Instance: <code>Director</code>


Provides methods for reading information and forcing events in the AI Director.
=== CSceneEntity ===
Extends [[#CBaseEntity|CBaseEntity]]


==== Methods ====
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 1,469: Line 1,520:
! Description
! Description
|-
|-
| <code>FindHordePosition</code>
| <code>AddBroadcastTeamTarget</code>
| <code>Vector FindHordePosition(bool ''north'')</code>
| <code>void AddBroadcastTeamTarget(int ''index'')</code>
| Get a random position where a horde can spawn (returns null on fail).
| Adds a team (by index) to the broadcast list.
|-
|-
| <code>GetAlienCount</code>
| <code>EstimateLength</code>
| <code>int GetAlienCount()</code>
| <code>float EstimateLength()</code>
| Returns number of aliens currently spawned.
| Returns length of this scene in seconds.
|-
|-
| <code>GetIntensity</code>
| <code>FindNamedEntity</code>
| <code>float GetIntensity(CBaseEntity ''marine'')</code>
| <code>handle FindNamedEntity(string ''reference'')</code>
| Get the intensity value for a marine.
| given an entity reference, such as !target, get actual entity from scene object.
|-
|-
| <code>GetMaxIntensity</code>
| <code>IsPaused</code>
| <code>float GetMaxIntensity()</code>
| <code>bool IsPaused()</code>
| Get the maximum intensity value for all living marines.
| If this scene is currently paused.
|-
|-
| <code>GetTimeToNextHorde</code>
| <code>IsPlayingBack</code>
| <code>float GetTimeToNextHorde()</code>
| <code>bool IsPlayingBack()</code>
| Get the current number of seconds until the director will try to spawn a horde.
| If this scene is currently playing.
|-
|-
| <code>IsOfflineGame</code>
| <code>LoadSceneFromString</code>
| <code>bool IsOfflineGame()</code>
| <code>bool LoadSceneFromString(string ''sceneName'', string ''scene'')</code>
| Return true if game is in single player.
| Given a dummy scene name and a vcd string, load the scene.
|-
|-
| <code>IsSpawningHorde</code>
| <code>RemoveBroadcastTeamTarget</code>
| <code>int IsSpawningHorde()</code>
| <code>void RemoveBroadcastTeamTarget(int ''index'')</code>
| Get the number of aliens remaining to spawn in the current horde.
| Removes a team (by index) from the broadcast list.
|}
 
 
=== CTriggerCamera ===
Extends [[#CBaseEntity|CBaseEntity]]
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>MissionComplete</code>
| <code>GetFov</code>
| <code>void MissionComplete(bool ''completed'')</code>
| <code>int GetFov()</code>
| Completes the mission if true.
| Get cameras current Field Of View setting as integer.
|-
|-
| <code>ResetIntensity</code>
| <code>SetFov</code>
| <code>void ResetIntensity(CBaseEntity ''marine'')</code>
| <code>void SetFov(int ''fov'', float ''rate'')</code>
| Reset the intensity value for a marine to zero.
| Set cameras current FOV in integer degrees and FOV change rate as float.
|}
 
 
=== CASW_Grenade_Cluster ===
Extends [[#CBaseCombatCharacter|CBaseCombatCharacter]]
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>ResetIntensityForAllMarines</code>
| <code>Disable</code>
| <code>void ResetIntensityForAllMarines()</code>
| <code>void Disable()</code>
| Reset the intensity value for all marines to zero.
| Disable the grenade.
|-
|-
| <code>RestartMission</code>
| <code>Enable</code>
| <code>void RestartMission()</code>
| <code>void Enable()</code>
| Restarts the mission.
| Enable the grenade, different time setting like explosion time correctly adjusted after disable state.
|-
|-
| <code>SetTimeToNextHorde</code>
| <code>EnableWithReset</code>
| <code>void SetTimeToNextHorde(float ''seconds'')</code>
| <code>void EnableWithReset()</code>
| Force the horde countdown timer to be set to this number of seconds.
| Enable the grenade, different time setting like explosion time reset like grenade is newly created.
|-
|-
| <code>SpawnAlienAt</code>
| <code>ReflectBack</code>
| <code>handle SpawnAlienAt(string ''alienClass'', Vector ''position'', Vector ''angles'')</code>
| <code>void ReflectBack()</code>
| Spawn an alien by class name.
| Reflect grenade preciselly to firer marine position if marine is alive, ReflectBackSimple used otherwise.
|-
|-
| <code>SpawnAlienBatch</code>
| <code>ReflectBackSimple</code>
| <code>int SpawnAlienBatch(string ''alienClass'', int ''aliens'', Vector ''position'', Vector ''angles'')</code>
| <code>void ReflectBackSimple()</code>
| Spawn a group of aliens by class name.
| Reflect grenade near to initial fire position.
|-
|-
| <code>SpawnAlienAuto</code>
| <code>ReflectRandomly</code>
| <code>bool SpawnAlienAuto(string ''alienClass'')</code>
| <code>void ReflectRandomly()</code>
| Spawn an alien automatically near the marines.
| Reflect grenade to random porition.
|-
| <code>SpawnHordeSoon</code>
| <code>void SpawnHordeSoon()</code>
| Queue a horde to spawn soon (the same logic as when a hack starts).
|-
| <code>StartFinale</code>
| <code>void StartFinale()</code>
| Spawn a horde every few seconds for the rest of the level.
|-
| <code>StartHoldout</code>
| <code>void StartHoldout()</code>
| Starts spawning a horde every few seconds until stopped.
|-
| <code>StopHoldout</code>
| <code>void StopHoldout()</code>
| Stops spawning hordes.
|-
| <code>ValidSpawnPoint</code>
| <code>bool ValidSpawnPoint(Vector ''position'', Vector ''mins'', Vector ''maxs'')</code>
| Return true if the position is a valid spawn point.
|}
|}


=== CEntities ===
==== Hooks ====
Game Instance: <code>Entities</code>
 
;<code>void ScriptStartCameraShot(string ''shotType'', handle ''sceneEntity'', handle ''actor1'', handle ''actor2'', float ''duration'')</code>
: ''Called from SceneEntity in response to a CChoreoEvent::CAMERA sent from a VCD.'' {{todo}}
 


An interface to find and iterate over the script handles for the entities in play.
=== CDirector ===
Game Instance: <code>Director</code>


To iterate over a set of entities, pass <code>null</code> to the ''previous'' argument in the appropriate method to start an iteration, or reference to a previously found entity to continue a search.
Provides methods for reading information and forcing events in the AI Director.


==== Methods ====
==== Methods ====
Line 1,563: Line 1,620:
! Description
! Description
|-
|-
| <code>CreateByClassname</code>
| <code>FindHordePosition</code>
| <code>handle CreateByClassname(string ''class'')</code>
| <code>Vector FindHordePosition(bool ''north'')</code>
| Creates an entity by class name.
| Get a random position where a horde can spawn (returns null on fail).
|-
|-
| <code>FindByClassname</code>
| <code>GetAlienCount</code>
| <code>handle FindByClassname(handle ''previous'', string ''class'')</code>
| <code>int GetAlienCount()</code>
| Find entities by class name.  
| Returns number of aliens currently spawned.
|-
|-
| <code>FindByClassnameNearest</code>
| <code>GetIntensity</code>
| <code>handle FindByClassnameNearest(string ''class'', Vector ''origin'', float ''radius'')</code>
| <code>float GetIntensity(CBaseEntity ''marine'')</code>
| Find the entity with the given class name nearest to the specified point.
| Get the intensity value for a marine.
|-
|-
| <code>FindByClassnameWithin</code>
| <code>GetMaxIntensity</code>
| <code>handle FindByClassnameWithin(handle ''previous'', string ''class'', Vector ''origin'', float ''radius'')</code>
| <code>float GetMaxIntensity()</code>
| Find entities by class name within a radius.  
| Get the maximum intensity value for all living marines.
|-
|-
| <code>FindByModel</code>
| <code>GetTimeToNextHorde</code>
| <code>handle FindByModel(handle ''previous'', string ''filename'')</code>
| <code>float GetTimeToNextHorde()</code>
| Find entities by model name.  
| Get the current number of seconds until the director will try to spawn a horde.
|-
|-
| <code>FindByName</code>
| <code>IsOfflineGame</code>
| <code>handle FindByName(handle ''previous'', string ''name'')</code>
| <code>bool IsOfflineGame()</code>
| Find entities by name.  
| Return true if game is in single player.
|-
|-
| <code>FindByNameNearest</code>
| <code>IsSpawningHorde</code>
| <code>handle FindByNameNearest(string ''name'', Vector ''origin'', float ''radius'')</code>
| <code>int IsSpawningHorde()</code>
| Find entities by name nearest to a point.
| Get the number of aliens remaining to spawn in the current horde.
|-
|-
| <code>FindByNameWithin</code>
| <code>MissionComplete</code>
| <code>handle FindByNameWithin(handle ''previous'', string ''name'', Vector ''origin'', float ''radius'')</code>
| <code>void MissionComplete(bool ''completed'')</code>
| Find entities by name within a radius.
| Completes the mission if true.
|-
|-
| <code>FindByTarget</code>
| <code>ResetIntensity</code>
| <code>handle FindByTarget(handle ''previous'', string ''targetname'')</code>
| <code>void ResetIntensity(CBaseEntity ''marine'')</code>
| Find entities by its target.
| Reset the intensity value for a marine to zero.
|-
|-
| <code>FindInSphere</code>
| <code>ResetIntensityForAllMarines</code>
| <code>handle FindInSphere(handle ''previous'', Vector ''origin'', float ''radius'')</code>
| <code>void ResetIntensityForAllMarines()</code>
| Find entities within a radius.
| Reset the intensity value for all marines to zero.
|-
|-
| <code>First</code>
| <code>RestartMission</code>
| <code>handle First()</code>
| <code>void RestartMission()</code>
| Begin an iteration over the list of entities.
| Restarts the mission.
|-
|-
| <code>Next</code>
| <code>SetTimeToNextHorde</code>
| <code>handle Next(handle ''previous'')</code>
| <code>void SetTimeToNextHorde(float ''seconds'')</code>
| Continue an iteration over the list of entities, providing reference to a previously found entity.
| Force the horde countdown timer to be set to this number of seconds.
|-
|-
| <code>IsValid</code>
| <code>SpawnAlienAt</code>
| <code>bool IsValid()</code>
| <code>handle SpawnAlienAt(string ''alienClass'', Vector ''position'', Vector ''angles'')</code>
| Whether the handle belongs to a valid entity.
| Spawn an alien by class name.
|}
 
 
=== CNetPropManager ===
 
Game Instance: <code>NetProps</code>
 
Allows reading and updating the [[Networking_Entities#Network_Variables|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").
 
{{warning|Each netprop has a set size in bits, exceeding the size may desync the clients from the server causing unpredictable behavior.}}
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>GetPropArraySize</code>
| <code>SpawnAlienBatch</code>
| <code>int GetPropArraySize(CBaseEntity ''entity'', string ''propertyName'')</code>
| <code>int SpawnAlienBatch(string ''alienClass'', int ''aliens'', Vector ''position'', Vector ''angles'')</code>
| Returns the size of an netprop array, or -1.
| Spawn a group of aliens by class name.
|-
|-
| <code>GetPropBool</code>
| <code>SpawnAlienAuto</code>
| <code>bool GetPropBool(CBaseEntity ''entity'', string ''propertyName'')</code>
| <code>bool SpawnAlienAuto(string ''alienClass'')</code>
| Reads a boolean valued netprop.
| Spawn an alien automatically near the marines.
|-
|-
| <code>GetPropBoolArray</code>
| <code>SpawnHordeSoon</code>
| <code>bool GetPropBoolArray(CBaseEntity ''entity'', string ''propertyName'', int ''arrayElement'')</code>
| <code>void SpawnHordeSoon()</code>
| Reads a boolean valued netprop from an array.
| Queue a horde to spawn soon (the same logic as when a hack starts).
|-
|-
| <code>GetPropEntity</code>
| <code>StartFinale</code>
| <code>CBaseEntity GetPropEntity(CBaseEntity ''entity'', string ''propertyName'')</code>
| <code>void StartFinale()</code>
| Reads an EHANDLE valued netprop (21 bit integer). Returns the script handle of the entity.
| Spawn a horde every few seconds for the rest of the level.
|-
|-
| <code>GetPropEntityArray</code>
| <code>StartHoldout</code>
| <code>CBaseEntity GetPropEntityArray(CBaseEntity ''entity'', string ''propertyName'', int ''arrayElement'')</code>
| <code>void StartHoldout()</code>
| Reads an EHANDLE valued netprop (21 bit integer) from an array. Returns the script handle of the entity.
| Starts spawning a horde every few seconds until stopped.
|-
|-
| <code>GetPropFloat</code>
| <code>StopHoldout</code>
| <code>float GetPropFloat(CBaseEntity ''entity'', string ''propertyName'')</code>
| <code>void StopHoldout()</code>
| Reads a float valued netprop.
| Stops spawning hordes.
|-
|-
| <code>GetPropFloatArray</code>
| <code>ValidSpawnPoint</code>
| <code>float GetPropFloatArray(CBaseEntity ''entity'', string ''propertyName'', int ''arrayElement'')</code>
| <code>bool ValidSpawnPoint(Vector ''position'', Vector ''mins'', Vector ''maxs'')</code>
| Reads a float valued netprop from an array.
| Return true if the position is a valid spawn point.
|-
|-
| <code>GetPropInfo</code>
| <code>GetMinNPCClassIndex</code>
| <code>void GetPropInfo(CBaseEntity ''entity'', string ''propertyName'', int ''arrayElement'', table)</code>
| <code>int GetMinNPCClassIndex()</code>
| Fills in a passed table with property info for the provided entity.
| Returns the minimum NPC class index. Class indexes that are negative cannot be used in spawners. -1 is reserved for "no class".
|-
| <code>GetPropInt</code>
| <code>int GetPropInt(CBaseEntity ''entity'', string ''propertyName'')</code>
| Reads an integer valued netprop.
|-
|-
| <code>GetPropIntArray</code>
| <code>GetMaxNPCClassIndex</code>
| <code>int GetPropIntArray(CBaseEntity ''entity'', string ''propertyName'', int ''arrayElement'')</code>
| <code>int GetMaxNPCClassIndex()</code>
| Reads an integer valued netprop from an array.
| Returns the maximum NPC class index.
|-
|-
| <code>GetPropString</code>
| <code>GetNPCClassName</code>
| <code>string GetPropString(CBaseEntity ''entity'', string ''propertyName'')</code>
| <code>string GetNPCClassName(int ''index'')</code>
| Reads an string valued netprop.
| Returns the NPC classname associated with a given index.
|-
|-
| <code>GetPropStringArray</code>
| <code>GetNPCClassIndex</code>
| <code>string GetPropStringArray(CBaseEntity ''entity'', string ''propertyName'', int ''arrayElement'')</code>
| <code>int GetNPCClassIndex(string ''classname'')</code>
| Reads an string valued netprop from an array.
| Returns the NPC class index associated with a given classname, or -1 if there is none.
|-
|-
| <code>GetPropType</code>
| <code>GetNPCHordeSound</code>
| <code>string GetPropType(CBaseEntity ''entity'', string ''propertyName'')</code>
| <code>string GetNPCHordeSound(int ''index'')</code>
| Returns the name of the netprop type as a string.
| Returns the horde sound name for a given NPC class index. This can be used to roughly categorize enemies into factions.
|-
|-
| <code>GetPropVector</code>
| <code>GetNPCHullType</code>
| <code>Vector GetPropVector(CBaseEntity ''entity'', string ''propertyName'')</code>
| <code>int GetNPCHullType(int ''index'')</code>
| Reads a 3D vector valued netprop. {{todo | Does it work for other dimensions too?}}
| Returns the hull type (for example, HULL_MEDIUMBIG) of an NPC class.
|-
|-
| <code>GetPropVectorArray</code>
| <code>GetNPCMins</code>
| <code>Vector GetPropVectorArray(CBaseEntity ''entity'', string ''propertyName'', int ''arrayElement'')</code>
| <code>Vector GetNPCMins(int ''index'')</code>
| Reads a 3D vector valued netprop from an array.
| Returns the component-wise minimum coordinate on the given NPC class's hull. (For hull traces)
|-
|-
| <code>GetTable</code>
| <code>GetNPCMaxs</code>
| <code>void GetTable(CBaseEntity ''entity'', int ''propType'', table)</code>
| <code>Vector GetNPCMaxs(int ''index'')</code>
| Fills in a passed table with all props of a specified type for the provided entity (set ''propType'' to 0 for '''SendTable''' or 1 for '''DataMap''').
| Returns the component-wise maximum coordinate on the given NPC class's hull. (For hull traces)
|}
 
=== CEntities ===
Game Instance: <code>Entities</code>
 
An interface to find and iterate over the script handles for the entities in play.
 
To iterate over a set of entities, pass <code>null</code> to the ''previous'' argument in the appropriate method to start an iteration, or reference to a previously found entity to continue a search.
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>HasProp</code>
| <code>CreateByClassname</code>
| <code>bool HasProp(CBaseEntity ''entity'', string ''propertyName'')</code>
| <code>handle CreateByClassname(string ''class'')</code>
| Checks if a netprop exists.
| Creates an entity by class name.
|-
|-
| <code>SetPropBool</code>
| <code>FindByClassname</code>
| <code>void SetPropBool(CBaseEntity ''entity'', string ''propertyName'', bool ''value'')</code>
| <code>handle FindByClassname(handle ''previous'', string ''class'')</code>
| Sets a netprop to the specified boolean.
| Find entities by class name.  
|-
|-
| <code>SetPropBoolArray</code>
| <code>FindByClassnameNearest</code>
| <code>void SetPropBoolArray(CBaseEntity ''entity'', string ''propertyName'', bool ''value'', int ''arrayElement'')</code>
| <code>handle FindByClassnameNearest(string ''class'', Vector ''origin'', float ''radius'')</code>
| Sets a netprop from an array to the specified boolean.
| Find the entity with the given class name nearest to the specified point.
|-
|-
| <code>SetPropEntity</code>
| <code>FindByClassnameWithin</code>
| <code>void SetPropEntity(CBaseEntity ''entity'', string ''propertyName'', CBaseEntity ''value'')</code>
| <code>handle FindByClassnameWithin(handle ''previous'', string ''class'', Vector ''origin'', float ''radius'')</code>
| Sets an EHANDLE valued netprop (21 bit integer) to reference the specified entity.
| Find entities by class name within a radius.  
|-
|-
| <code>SetPropEntityArray</code>
| <code>FindByModel</code>
| <code>void SetPropEntityArray(CBaseEntity ''entity'', string ''propertyName'', CBaseEntity ''value'', int ''arrayElement'')</code>
| <code>handle FindByModel(handle ''previous'', string ''filename'')</code>
| Sets an EHANDLE valued netprop (21 bit integer) from an array to reference the specified entity.
| Find entities by model name.  
|-
|-
| <code>SetPropFloat</code>
| <code>FindByName</code>
| <code>void SetPropFloat(CBaseEntity ''entity'', string ''propertyName'', float ''value'')</code>
| <code>handle FindByName(handle ''previous'', string ''name'')</code>
| Sets a netprop to the specified float.
| Find entities by name.  
|-
|-
| <code>SetPropFloatArray</code>
| <code>FindByNameNearest</code>
| <code>void SetPropFloatArray(CBaseEntity ''entity'', string ''propertyName'', float ''value'', int ''arrayElement'')</code>
| <code>handle FindByNameNearest(string ''name'', Vector ''origin'', float ''radius'')</code>
| Sets a netprop from an array to the specified float.
| Find entities by name nearest to a point.
|-
|-
| <code>SetPropInt</code>
| <code>FindByNameWithin</code>
| <code>void SetPropInt(CBaseEntity ''entity'', string ''propertyName'', int ''value'')</code>
| <code>handle FindByNameWithin(handle ''previous'', string ''name'', Vector ''origin'', float ''radius'')</code>
| Sets a netprop to the specified integer.
| Find entities by name within a radius.
|-
|-
| <code>SetPropIntArray</code>
| <code>FindByTarget</code>
| <code>void SetPropInt(CBaseEntity ''entity'', string ''propertyName'', int ''value'', int ''arrayElement'')</code>
| <code>handle FindByTarget(handle ''previous'', string ''targetname'')</code>
| Sets a netprop from an array to the specified integer.
| Find entities by its target.
|-
|-
| <code>SetPropString</code>
| <code>FindInSphere</code>
| <code>void SetPropString(CBaseEntity ''entity'', string ''propertyName'', string ''value'')</code>
| <code>handle FindInSphere(handle ''previous'', Vector ''origin'', float ''radius'')</code>
| Sets a netprop to the specified string.
| Find entities within a radius.
|-
|-
| <code>SetPropStringArray</code>
| <code>First</code>
| <code>void SetPropStringArray(CBaseEntity ''entity'', string ''propertyName'', string ''value'', int ''arrayElement'')</code>
| <code>handle First()</code>
| Sets a netprop from an array to the specified string.
| Begin an iteration over the list of entities.
|-
|-
| <code>SetPropVector</code>
| <code>Next</code>
| <code>void SetPropVector(CBaseEntity ''entity'', string ''propertyName'', Vector ''value'')</code>
| <code>handle Next(handle ''previous'')</code>
| Sets a netprop to the specified vector.
| Continue an iteration over the list of entities, providing reference to a previously found entity.
|-
|-
| <code>SetPropVectorArray</code>
| <code>IsValid</code>
| <code>void SetPropVectorArray(CBaseEntity ''entity'', string ''propertyName'', Vector ''value'', int ''arrayElement'')</code>
| <code>bool IsValid()</code>
| Sets a netprop from an array to the specified vector.
| Whether the handle belongs to a valid entity.
|}
|}


=== CScriptInfoNodes ===


Game Instance: <code>InfoNodes</code>
=== CNetPropManager ===
 
Game Instance: <code>NetProps</code>
 
Allows reading and updating the [[Networking_Entities#Network_Variables|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").


Allows reading info_node data.
{{warning|Each netprop has a set size in bits, exceeding the size may desync the clients from the server causing unpredictable behavior.}}


==== Methods ====
==== Methods ====
Line 1,762: Line 1,816:
! Description
! Description
|-
|-
| <code>CreateLink</code>
| <code>GetPropArraySize</code>
| <code>CAI_Link CreateLink(int ''srcID'', int ''destID'')</code>
| <code>int GetPropArraySize(CBaseEntity ''entity'', string ''propertyName'')</code>
| Creates a new link from srcID to destID and returns the link.
| Returns the size of an netprop array, or -1.
|-
|-
| <code>GetAllNearestNodes</code>
| <code>GetPropBool</code>
| <code>int GetAllNearestNodes(CBaseEntity ''npc'', Vector ''position'', int ''maxNodes'', table)</code>
| <code>bool GetPropBool(CBaseEntity ''entity'', string ''propertyName'')</code>
| Fills a passed in table of x nearest nodes to origin with optional npc parameter, and returns number of nodes found.
| Reads a boolean valued netprop.
|-
|-
| <code>GetAllNodes</code>
| <code>GetPropBoolArray</code>
| <code>void GetAllNodes(table)</code>
| <code>bool GetPropBoolArray(CBaseEntity ''entity'', string ''propertyName'', int ''arrayElement'')</code>
| Fills a passed in table of all nodes.
| Reads a boolean valued netprop from an array.
|-
|-
| <code>GetNearestNodeToPoint</code>
| <code>GetPropEntity</code>
| <code>CAI_Node GetNearestNodeToPoint(CBaseEntity ''npc'', Vector ''position'')</code>
| <code>CBaseEntity GetPropEntity(CBaseEntity ''entity'', string ''propertyName'')</code>
| Returns the node nearest to origin with optional npc parameter.
| Reads an EHANDLE valued netprop (21 bit integer). Returns the script handle of the entity.
|-
|-
| <code>GetNumNodes</code>
| <code>GetPropEntityArray</code>
| <code>int GetNumNodes()</code>
| <code>CBaseEntity GetPropEntityArray(CBaseEntity ''entity'', string ''propertyName'', int ''arrayElement'')</code>
| Returns the amount of info_nodes in the network array.
| Reads an EHANDLE valued netprop (21 bit integer) from an array. Returns the script handle of the entity.
|-
|-
| <code>GetNodeOrigin</code>
| <code>GetPropFloat</code>
| <code>Vector GetNodeOrigin(int ''nodeID'')</code>
| <code>float GetPropFloat(CBaseEntity ''entity'', string ''propertyName'')</code>
| Returns the origin of the node.
| Reads a float valued netprop.
|-
|-
| <code>GetNodePosition</code>
| <code>GetPropFloatArray</code>
| <code>Vector GetNodePosition(int ''nodeID'', int ''hull'')</code>
| <code>float GetPropFloatArray(CBaseEntity ''entity'', string ''propertyName'', int ''arrayElement'')</code>
| Returns the hull specific origin of the node.
| Reads a float valued netprop from an array.
|-
|-
| <code>GetNodeType</code>
| <code>GetPropInfo</code>
| <code>int GetNodeType(int ''nodeID'')</code>
| <code>void GetPropInfo(CBaseEntity ''entity'', string ''propertyName'', int ''arrayElement'', table)</code>
| Returns the type of node.
| Fills in a passed table with property info for the provided entity.
|}
 
Example of spawning stuff at random info_node origins.
 
<source lang="cpp">for( local i = 0; i < 5; i++ )
{
local node_id = RandomInt( 0, InfoNodes.GetNumNodes() - 1 );
local node_type = InfoNodes.GetNodeType( node_id );
if ( node_type != NODE_GROUND )
continue;
local ammo = Entities.CreateByClassname( "asw_ammo_drop" );
ammo.SetOrigin( InfoNodes.GetNodeOrigin( node_id ) );
ammo.SetName( "info_node_ammospawn_" + i );
ammo.Spawn();
//Director.SpawnAlienAt( "asw_shieldbug", InfoNodes.GetNodePosition( node_id, HULL_WIDE_SHORT ), Vector( 0, 0, 0 ) );
}
</source>
 
=== CScriptEntityOutputs ===
 
Game Instance: <code>EntityOutputs</code>
 
Allows reading entity output data.
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>AddOutput</code>
| <code>GetPropInt</code>
| <code>void AddOutput(handle ''entity'', string ''outputName'', string ''targetName'', string ''inputName'', string ''parameter'', float ''delay'', int ''timesToFire'')</code>
| <code>int GetPropInt(CBaseEntity ''entity'', string ''propertyName'')</code>
| Adds a new output to the entity.
| Reads an integer valued netprop.
|-
|-
| <code>GetNumElements</code>
| <code>GetPropIntArray</code>
| <code>int GetNumElements(handle ''entity'', string ''outputName'')</code>
| <code>int GetPropIntArray(CBaseEntity ''entity'', string ''propertyName'', int ''arrayElement'')</code>
| Returns the number of array elements.
| Reads an integer valued netprop from an array.
|-
|-
| <code>GetOutputTable</code>
| <code>GetPropString</code>
| <code>void GetOutputTable(handle ''entity'', string ''outputName'', table, int ''arrayElement'')</code>
| <code>string GetPropString(CBaseEntity ''entity'', string ''propertyName'')</code>
| Returns a table of output information.
| Reads an string valued netprop.
|-
|-
| <code>GetValue</code>
| <code>GetPropStringArray</code>
| <code>variable GetValue(handle ''entity'', string ''outputName'')</code>
| <code>string GetPropStringArray(CBaseEntity ''entity'', string ''propertyName'', int ''arrayElement'')</code>
| Returns the value of the output if it has one. (can be used to read math_counter OutValue)
| Reads an string valued netprop from an array.
|-
|-
| <code>HasAction</code>
| <code>GetPropType</code>
| <code>bool HasAction(handle ''entity'', string ''outputName'')</code>
| <code>string GetPropType(CBaseEntity ''entity'', string ''propertyName'')</code>
| Returns true if an action exists for the output.
| Returns the name of the netprop type as a string.
|-
|-
| <code>HasOutput</code>
| <code>GetPropVector</code>
| <code>bool HasOutput(handle ''entity'', string ''outputName'')</code>
| <code>Vector GetPropVector(CBaseEntity ''entity'', string ''propertyName'')</code>
| Returns true if the output exists.
| Reads a 3D vector valued netprop. {{todo | Does it work for other dimensions too?}}
|-
|-
| <code>RemoveOutput</code>
| <code>GetPropVectorArray</code>
| <code>void RemoveOutput(handle ''entity'', string ''outputName'', string ''targetName'', string ''inputName'', string ''parameter'')</code>
| <code>Vector GetPropVectorArray(CBaseEntity ''entity'', string ''propertyName'', int ''arrayElement'')</code>
| Removes an output from the entity.
| Reads a 3D vector valued netprop from an array.
|}
 
Example of looping through entity outputs.
 
<source lang="cpp">ent <- null;
while( ent = Entities.FindByClassname(ent, "trigger_once") )
{
if ( EntityOutputs.HasAction( ent, "OnTrigger" ) )
{
local numElements = EntityOutputs.GetNumElements( ent, "OnTrigger" );
for ( local i = 0; i < numElements; i++ )
{
local tbl = {};
EntityOutputs.GetOutputTable( ent, "OnTrigger", tbl, i );
DeepPrintTable( tbl );
}
}
}
</source>
 
=== CScriptTempEnts ===
 
Game Instance: <code>TempEnts</code>
 
Allows creating Temporary Entities on clients.
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>Create</code>
| <code>GetTable</code>
| <code>void Create(handle ''player'', string ''name'', float ''delay'', table)</code>
| <code>void GetTable(CBaseEntity ''entity'', int ''propType'', table)</code>
| Queue a temp entity for transmission on a client from a passed table of SendProp data. Passing null for a player will playback Temp Entity on all clients.
| Fills in a passed table with all props of a specified type for the provided entity (set ''propType'' to 0 for '''SendTable''' or 1 for '''DataMap''').
|-
|-
| <code>GetNames</code>
| <code>HasProp</code>
| <code>void GetNames(string ''name'', table)</code>
| <code>bool HasProp(CBaseEntity ''entity'', string ''propertyName'')</code>
| Fills in a passed table with the names of all temp entities
| Checks if a netprop exists.
|-
|-
| <code>GetPropTypes</code>
| <code>SetPropBool</code>
| <code>void GetPropTypes(table)</code>
| <code>void SetPropBool(CBaseEntity ''entity'', string ''propertyName'', bool ''value'')</code>
| Fills in a passed table with all SendProps and their types for the temp entity.
| Sets a netprop to the specified boolean.
|}
 
=== Convars ===
Game Instance: <code>Convars</code>
 
Provides an interface for getting and setting [[Convar|convars]] on the server.
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>ExecuteConCommand</code>
| <code>SetPropBoolArray</code>
| <code>void ExecuteConCommand(string ''cmd'')</code>
| <code>void SetPropBoolArray(CBaseEntity ''entity'', string ''propertyName'', bool ''value'', int ''arrayElement'')</code>
| Executes the convar command.
| Sets a netprop from an array to the specified boolean.
|-
|-
| <code>GetClientConvarValue</code>
| <code>SetPropEntity</code>
| <code>string GetClientConvarValue(int ''entindex'', string ''name'')</code>
| <code>void SetPropEntity(CBaseEntity ''entity'', string ''propertyName'', CBaseEntity ''value'')</code>
| Returns the convar value for the entindex as a string. Only works with client convars with the FCVAR_USERINFO flag.
| Sets an EHANDLE valued netprop (21 bit integer) to reference the specified entity.
|-
| <code>SetPropEntityArray</code>
| <code>void SetPropEntityArray(CBaseEntity ''entity'', string ''propertyName'', CBaseEntity ''value'', int ''arrayElement'')</code>
| Sets an EHANDLE valued netprop (21 bit integer) from an array to reference the specified entity.
|-
|-
| <code>GetStr</code>
| <code>SetPropFloat</code>
| <code>string GetStr(string ''name'')</code>
| <code>void SetPropFloat(CBaseEntity ''entity'', string ''propertyName'', float ''value'')</code>
| Returns the convar as a string. May return null if no such convar.
| Sets a netprop to the specified float.
|-
|-
| <code>GetFloat</code>
| <code>SetPropFloatArray</code>
| <code>float GetFloat(string ''name'')</code>
| <code>void SetPropFloatArray(CBaseEntity ''entity'', string ''propertyName'', float ''value'', int ''arrayElement'')</code>
| Returns the convar as a float. May return null if no such convar.
| Sets a netprop from an array to the specified float.
|-
|-
| <code>SetValue</code>
| <code>SetPropInt</code>
| <code>void SetValue(string ''name'', ''value'')</code>
| <code>void SetPropInt(CBaseEntity ''entity'', string ''propertyName'', int ''value'')</code>
| Sets the value of the convar to a numeric value.
| Sets a netprop to the specified integer.
|-
|-
| <code>SetValueString</code>
| <code>SetPropIntArray</code>
| <code>void SetValueString(string ''name'', string ''value'')</code>
| <code>void SetPropInt(CBaseEntity ''entity'', string ''propertyName'', int ''value'', int ''arrayElement'')</code>
| Sets the value of the convar to a string.
| Sets a netprop from an array to the specified integer.
|}
|-
 
| <code>SetPropString</code>
 
| <code>void SetPropString(CBaseEntity ''entity'', string ''propertyName'', string ''value'')</code>
=== CScriptResponseCriteria ===
| Sets a netprop to the specified string.
|-
| <code>SetPropStringArray</code>
| <code>void SetPropStringArray(CBaseEntity ''entity'', string ''propertyName'', string ''value'', int ''arrayElement'')</code>
| Sets a netprop from an array to the specified string.
|-
| <code>SetPropVector</code>
| <code>void SetPropVector(CBaseEntity ''entity'', string ''propertyName'', Vector ''value'')</code>
| Sets a netprop to the specified vector.
|-
| <code>SetPropVectorArray</code>
| <code>void SetPropVectorArray(CBaseEntity ''entity'', string ''propertyName'', Vector ''value'', int ''arrayElement'')</code>
| Sets a netprop from an array to the specified vector.
|}
 
=== CScriptInfoNodes ===


Game Instance: <code>ResponseCriteria</code>
Game Instance: <code>InfoNodes</code>


Allows reading the response rules of an entity.  
Allows reading info_node data.


==== Methods ====
==== Methods ====
Line 1,947: Line 1,945:
! Description
! Description
|-
|-
| <code>GetTable</code>
| <code>CreateLink</code>
| <code>void GetTable(CBaseEntity ''entity'', table)</code>
| <code>CAI_Link CreateLink(int ''srcID'', int ''destID'')</code>
| Returns a table of all criteria.
| Creates a new link from srcID to destID and returns the link.
|-
|-
| <code>GetValue</code>
| <code>GetAllNearestNodes</code>
| <code>string GetValue(CBaseEntity ''entity'', string ''criteriaName'')</code>
| <code>int GetAllNearestNodes(CBaseEntity ''npc'', Vector ''position'', int ''maxNodes'', table)</code>
| Returns a string.
| Fills a passed in table of x nearest nodes to origin with optional npc parameter, and returns number of nodes found.
|-
| <code>GetAllNodes</code>
| <code>void GetAllNodes(table)</code>
| Fills a passed in table of all nodes.
|-
| <code>GetNearestNodeToPoint</code>
| <code>CAI_Node GetNearestNodeToPoint(CBaseEntity ''npc'', Vector ''position'')</code>
| Returns the node nearest to origin with optional npc parameter.
|-
| <code>GetNumNodes</code>
| <code>int GetNumNodes()</code>
| Returns the amount of info_nodes in the network array.
|-
| <code>GetNodeOrigin</code>
| <code>Vector GetNodeOrigin(int ''nodeID'')</code>
| Returns the origin of the node.
|-
| <code>GetNodePosition</code>
| <code>Vector GetNodePosition(int ''nodeID'', int ''hull'')</code>
| Returns the hull specific origin of the node.
|-
|-
| <code>HasCriterion</code>
| <code>GetNodeType</code>
| <code>bool HasCriterion(CBaseEntity ''entity'', string ''criteriaName'')</code>
| <code>int GetNodeType(int ''nodeID'')</code>
| Returns true if the criterion exists.
| Returns the type of node.
|}
|}


Example of spawning stuff at random info_node origins.
<source lang="cpp">for( local i = 0; i < 5; i++ )
{
local node_id = RandomInt( 0, InfoNodes.GetNumNodes() - 1 );
local node_type = InfoNodes.GetNodeType( node_id );
if ( node_type != NODE_GROUND )
continue;
local ammo = Entities.CreateByClassname( "asw_ammo_drop" );
ammo.SetOrigin( InfoNodes.GetNodeOrigin( node_id ) );
ammo.SetName( "info_node_ammospawn_" + i );
ammo.Spawn();
//Director.SpawnAlienAt( "asw_shieldbug", InfoNodes.GetNodePosition( node_id, HULL_WIDE_SHORT ), Vector( 0, 0, 0 ) );
}
</source>
=== CScriptEntityOutputs ===
Game Instance: <code>EntityOutputs</code>
Allows reading entity output data.


=== CASW_Mission_Chooser_VScript ===
Game Instance: <code>MissionChooser</code>
Provides an interface for querying campaigns, missions, and challenges on the server.
==== Methods ====
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
Line 1,973: Line 2,009:
! Description
! Description
|-
|-
| <code>CountCampaigns</code>
| <code>AddOutput</code>
| <code>int CountCampaigns()</code>
| <code>void AddOutput(handle ''entity'', string ''outputName'', string ''targetName'', string ''inputName'', string ''parameter'', float ''delay'', int ''timesToFire'')</code>
| Returns the number of installed campaigns.
| Adds a new output to the entity.
|-
|-
| <code>CountChallenges</code>
| <code>GetNumElements</code>
| <code>int CountChallenges()</code>
| <code>int GetNumElements(handle ''entity'', string ''outputName'')</code>
| Returns the number of installed challenges.
| Returns the number of array elements.
|-
|-
| <code>CountMissions</code>
| <code>GetOutputTable</code>
| <code>int CountMissions()</code>
| <code>void GetOutputTable(handle ''entity'', string ''outputName'', table, int ''arrayElement'')</code>
| Returns the number of installed missions.
| Returns a table of output information.
|-
|-
| <code>GetCampaign</code>
| <code>GetValue</code>
| <code>table GetCampaign(int ''index'')</code>
| <code>variable GetValue(handle ''entity'', string ''outputName'')</code>
| Creates a table containing campaign data for a campaign by index.
| Returns the value of the output if it has one. (can be used to read math_counter OutValue)
|-
|-
| <code>GetCampaignByName</code>
| <code>HasAction</code>
| <code>table GetCampaignByName(string ''name'')</code>
| <code>bool HasAction(handle ''entity'', string ''outputName'')</code>
| Creates a table containing campaign data for a campaign by name.
| Returns true if an action exists for the output.
|-
|-
| <code>GetChallenge</code>
| <code>HasOutput</code>
| <code>table GetChallenge(int ''index'')</code>
| <code>bool HasOutput(handle ''entity'', string ''outputName'')</code>
| Creates a table containing challenge data for a challenge by index.
| Returns true if the output exists.
|-
|-
| <code>GetChallengeByName</code>
| <code>RemoveOutput</code>
| <code>table GetChallengeByName(string ''name'')</code>
| <code>void RemoveOutput(handle ''entity'', string ''outputName'', string ''targetName'', string ''inputName'', string ''parameter'')</code>
| Creates a table containing challenge data for a challenge by name.
| Removes an output from the entity.
|-
|}
| <code>GetCurrentCampaign</code>
 
| <code>table GetCurrentCampaign()</code>
Example of looping through entity outputs.
| Creates a table containing campaign data for the current campaign.
 
|-
<source lang="cpp">ent <- null;
| <code>GetCurrentChallenge</code>
while( ent = Entities.FindByClassname(ent, "trigger_once") )
| <code>table GetCurrentChallenge()</code>
{
| Creates a table containing challenge data for the current challenge.
if ( EntityOutputs.HasAction( ent, "OnTrigger" ) )
|-
{
| <code>GetCurrentMission</code>
local numElements = EntityOutputs.GetNumElements( ent, "OnTrigger" );
| <code>table GetCurrentMission()</code>
for ( local i = 0; i < numElements; i++ )
| Creates a table containing mission overview data for the current mission.
{
|-
local tbl = {};
| <code>GetMission</code>
EntityOutputs.GetOutputTable( ent, "OnTrigger", tbl, i );
| <code>table GetMission(int ''index'')</code>
DeepPrintTable( tbl );
| Creates a table containing mission overview data for a mission by index.
}
|-
}
| <code>GetMissionByName</code>
}
| <code>table GetMissionByName(string ''name'')</code>
</source>
| Creates a table containing mission overview data for a mission by name.
|}


=== CScriptTempEnts ===


=== CPlayerVoiceListener ===
Game Instance: <code>TempEnts</code>


Allows creating Temporary Entities on clients.


==== Methods ====
==== Methods ====
Line 2,032: Line 2,068:
! Description
! Description
|-
|-
| <code>GetPlayerSpeechDuration</code>
| <code>Create</code>
| <code>float GetPlayerSpeechDuration(int ''playerIndex'')</code>
| <code>void Create(handle ''player'', string ''name'', float ''delay'', table)</code>
| Returns the number of seconds the player has been continuously speaking.
| Queue a temp entity for transmission on a client from a passed table of SendProp data. Passing null for a player will playback Temp Entity on all clients.
|-
|-
| <code>IsPlayerSpeaking</code>
| <code>GetNames</code>
| <code>bool IsPlayerSpeaking(int ''playerIndex'')</code>
| <code>void GetNames(string ''name'', table)</code>
| Returns whether the player specified is speaking.
| Fills in a passed table with the names of all temp entities
|-
|-
| <code>IsValid</code>
| <code>GetPropTypes</code>
| <code>bool IsValid()</code>
| <code>void GetPropTypes(table)</code>
| Whether the handle belongs to a valid entity.
| Fills in a passed table with all SendProps and their types for the temp entity.
|}
|}


=== Convars ===
Game Instance: <code>Convars</code>


=== CScriptKeyValues ===
Provides an interface for getting and setting [[Convar|convars]] on the server.
Script handle representation of a models [[$keyvalues]] block.
Sub keys are instances of the same class.


==== Methods ====
==== Methods ====
Line 2,056: Line 2,092:
! Description
! Description
|-
|-
| <code>constructor</code>
| <code>ExecuteConCommand</code>
| <code>void ExecuteConCommand(string ''cmd'')</code>
| Executes the convar command.
|-
|-
| <code>FindKey</code>
| <code>GetClientConvarValue</code>
| <code>CScriptKeyValues FindKey(string ''keyName'')</code>
| <code>string GetClientConvarValue(int ''entindex'', string ''name'')</code>
| Find a sub key by the key name.
| Returns the convar value for the entindex as a string. Only works with client convars with the FCVAR_USERINFO flag.
|-
|-
| <code>GetFirstSubKey</code>
| <code>GetStr</code>
| <code>CScriptKeyValues GetFirstSubKey()</code>
| <code>string GetStr(string ''name'')</code>
| Return the first sub key object.
| Returns the convar as a string. May return null if no such convar.
|-
|-
| <code>GetKeyBool</code>
| <code>GetFloat</code>
| <code>bool GetKeyBool(string ''keyName'')</code>
| <code>float GetFloat(string ''name'')</code>
| Return the key value as a bool.
| Returns the convar as a float. May return null if no such convar.
|-
|-
| <code>GetKeyFloat</code>
| <code>SetValue</code>
| <code>float GetKeyFloat(string ''keyName'')</code>
| <code>void SetValue(string ''name'', ''value'')</code>
| Return the key value as a float.
| Sets the value of the convar to a numeric value.
|-
|-
| <code>GetKeyInt</code>
| <code>SetValueString</code>
| <code>int GetKeyInt(string ''keyName'')</code>
| <code>void SetValueString(string ''name'', string ''value'')</code>
| Return the key value as an integer.
| Sets the value of the convar to a string.
|}
 
 
=== CScriptResponseCriteria ===
 
Game Instance: <code>ResponseCriteria</code>
 
Allows reading the response rules of an entity.  
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>GetKeyString</code>
| <code>GetTable</code>
| <code>string GetKeyString(string ''keyName'')</code>
| <code>void GetTable(CBaseEntity ''entity'', table)</code>
| Return the key value as a string.
| Returns a table of all criteria.
|-
|-
| <code>GetNextKey</code>
| <code>GetValue</code>
| <code>handle GetNextKey()</code>
| <code>string GetValue(CBaseEntity ''entity'', string ''criteriaName'')</code>
| Return the next neighbor key object to the one the method is called on.
| Returns a string.
|-
|-
| <code>IsKeyEmpty</code>
| <code>HasCriterion</code>
| <code>bool IsKeyEmpty(string ''keyName'')</code>
| <code>bool HasCriterion(CBaseEntity ''entity'', string ''criteriaName'')</code>
| Returns true if the named key has no value.
| Returns true if the criterion exists.
|-
| <code>IsValid</code>
| <code>bool IsValid()</code>
| Whether the handle belongs to a valid entity.
|-
| <code>ReleaseKeyValues</code>
| <code>void ReleaseKeyValues()</code>
| Releases the contents of the instance.
|}
|}




=== CCallChainer ===
=== CASW_Mission_Chooser_VScript ===
'''CCallChainer''' objects collect all functions with a matching prefix in a given scope, then inserts it all into the <code>chains</code> table with the prefix removed. All collected unprefixed functions can then be called in a chain using the class's <code>Call()</code> method, given the method's ''event'' argument matches the functions' name.
 
Game Instance: <code>MissionChooser</code>


Whenever a '''CCallChainer''' object is created, a function named <code>Dispatch</code> followed by its given prefix will also be created, which  the class binds the environment of its <code>Call()</code> method to.
Provides an interface for querying campaigns, missions, and challenges on the server.


==== Methods ====
==== Methods ====
Line 2,111: Line 2,156:
! Description
! Description
|-
|-
| <code>constructor</code>
| <code>CountCampaigns</code>
| <code>CCallChainer(string ''functionPrefix'', table ''scope'' = null)</code>
| <code>int CountCampaigns()</code>
| Creates a CCallChainer object that'll collect functions that have a matching prefix in the given scope.
| Returns the number of installed campaigns.
|-
|-
| <code>PostScriptExecute</code>
| <code>CountChallenges</code>
| <code>void PostScriptExecute()</code>
| <code>int CountChallenges()</code>
| Search for all non-native functions with matching prefixes, then push them into the <code>chains</code> table.
| Returns the number of installed challenges.
|-
|-
| <code>Call</code>
| <code>CountMissions</code>
| <code>bool Call(string ''event'', any ...)</code>
| <code>int CountMissions()</code>
| Find an unprefixed function name in the <code>chains</code> table and call it with the given arguments.
| Returns the number of installed missions.
|}
 
==== Members ====
{| class="standard-table" style="width: 100%;"
! Instance
! Type
! Description
|-
|-
| <code>chains</code>
| <code>GetCampaign</code>
| <code>table</code>
| <code>table GetCampaign(int ''index'')</code>
| Contains names of unprefixed functions, each with an array of functions to call.
| Creates a table containing campaign data for a campaign by index.
|-
|-
| <code>prefix</code>
| <code>GetCampaignByName</code>
| <code>string</code>
| <code>table GetCampaignByName(string ''name'')</code>
| Prefix that functions should have to be added into the <code>chains</code> table. Set by the constructor.
| Creates a table containing campaign data for a campaign by name.
|-
|-
| <code>scope</code>
| <code>GetChallenge</code>
| <code>table</code>
| <code>table GetChallenge(int ''index'')</code>
| If set, seek functions in this scope instead. Set by the constructor.
| Creates a table containing challenge data for a challenge by index.
|-
| <code>GetChallengeByName</code>
| <code>table GetChallengeByName(string ''name'')</code>
| Creates a table containing challenge data for a challenge by name.
|-
| <code>GetCurrentCampaign</code>
| <code>table GetCurrentCampaign()</code>
| Creates a table containing campaign data for the current campaign.
|-
| <code>GetCurrentChallenge</code>
| <code>table GetCurrentChallenge()</code>
| Creates a table containing challenge data for the current challenge.
|-
| <code>GetCurrentMission</code>
| <code>table GetCurrentMission()</code>
| Creates a table containing mission overview data for the current mission.
|-
| <code>GetMission</code>
| <code>table GetMission(int ''index'')</code>
| Creates a table containing mission overview data for a mission by index.
|-
| <code>GetMissionByName</code>
| <code>table GetMissionByName(string ''name'')</code>
| Creates a table containing mission overview data for a mission by name.
|}
|}




=== CSimpleCallChainer ===
=== CASW_Deathmatch_VScript ===
Intended to be simpler to use than [[#CCallChainer|CCallChainer]], the class '''CSimpleCallChainer''' holds only a single chain of functions inside an array instead of multiple inside a table. As such, its <code>Call()</code> method does not need a function's name.
 
Game Instance: <code>Deathmatch</code>


This class is also used internally by these [[#CBaseEntity|CBaseEntity]] hooks: <code>Precache()</code> and <code>OnPostSpawn()</code>.
Allows challenge modes to modify deathmatch scores.


==== Methods ====
==== Methods ====
Line 2,155: Line 2,218:
! Description
! Description
|-
|-
| <code>constructor</code>
| <code>ResetScores</code>
| <code>CSimpleCallChainer(string ''functionPrefix'', table ''scope'' = null, exactMatch = false)</code>
| <code>void ResetScores()</code>
| Creates a CSimpleCallChainer object that'll collect functions that have a matching prefix in the given scope, unless it seek for an exact name match.
| Clears all scores.
|-
| <code>GetKills</code>
| <code>int GetKills(handle ''marineOrResource'')</code>
| Returns a marine's kill count.
|-
|-
| <code>PostScriptExecute</code>
| <code>SetKills</code>
| <code>void PostScriptExecute()</code>
| <code>void SetKills(handle ''marineOrResource'', int ''kills'')</code>
| Begin searching for all non-native functions with matching prefixes, then push them into the <code>chain</code> array.
| Overrides a marine's kill count.
|-
| <code>GetDeaths</code>
| <code>int GetKills(handle ''marineOrResource'')</code>
| Returns a marine's death count.
|-
| <code>SetDeaths</code>
| <code>void SetDeaths(handle ''marineOrResource'', int ''deaths'')</code>
| Overrides a marine's death count.
|-
| <code>GetTeamScore</code>
| <code>int GetKills(int ''teamNumber'')</code>
| Returns a team's score. Team numbers are TEAM_ALPHA (2) for the yellow team and TEAM_BETA (3) for the blue team.
|-
|-
| <code>Call</code>
| <code>SetTeamScore</code>
| <code>bool Call(any ...)</code>
| <code>void SetTeamScore(int ''teamNumber'', int ''score'')</code>
| Call all functions inside the <code>chain</code> array with the given arguments.
| Overrides a team's score. Team numbers are TEAM_ALPHA (2) for the yellow team and TEAM_BETA (3) for the blue team.
|}
 
==== Members ====
{| class="standard-table" style="width: 100%;"
! Instance
! Type
! Description
|-
|-
| <code>chain</code>
| <code>CheckFragLimit</code>
| <code>array</code>
| <code>bool CheckFragLimit(handle ''marineOrResource'')</code>
| All functions to be called by the <code>Call()</code> method.
| Checks if a player or their team should win the match. Call this after modifying a team's score or a marine's kill count.
|-
|-
| <code>exactMatch</code>
| <code>ResetKillingSpree</code>
| <code>bool</code>
| <code>void ResetKillingSpree(handle ''marineOrResource'')</code>
| If set, names of non-native functions and <code>prefix</code> must be an exact match.  Set by the constructor.
| Reset a marine's killing spree counter.
|-
|-
| <code>prefix</code>
| <code>IncreaseKillingSpree</code>
| <code>string</code>
| <code>void IncreaseKillingSpree(handle ''marineOrResource'')</code>
| Prefix that functions should have to be added into the <code>chain</code> array. Set by the constructor.
| Record a kill for a marine's killing spree counter.
|-
|-
| <code>scope</code>
| <code>GetKillingSpree</code>
| <code>table</code>
| <code>int GetKillingSpree(handle ''marineOrResource'')</code>
| If set, seek functions in this scope instead. Set by the constructor.
| Get a marine's current killing spree counter. This is always 0 if rd_quake_sounds is 0.
|}
|}




=== LateBinder ===
=== CPlayerVoiceListener ===
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.
 
<source lang=cpp>
// Usage:
lateBinder <- LateBinder();
lateBinder.Begin( this );


Test1 <-
==== Methods ====
{| class="standard-table" style="width: 100%;"
  Foo=1
! Function
}  
! Signature
! Description
|-
| <code>GetPlayerSpeechDuration</code>
| <code>float GetPlayerSpeechDuration(int ''playerIndex'')</code>
| Returns the number of seconds the player has been continuously speaking.
|-
| <code>IsPlayerSpeaking</code>
| <code>bool IsPlayerSpeaking(int ''playerIndex'')</code>
| Returns whether the player specified is speaking.
|-
| <code>IsValid</code>
| <code>bool IsValid()</code>
| Whether the handle belongs to a valid entity.
|}


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();
=== CRD_HUD_VScript ===
delete lateBinder;
</source>


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.
Classname of the entity: rd_hud_vscript.


==== Methods ====
==== Methods ====
Line 2,226: Line 2,297:
! Description
! Description
|-
|-
| <code>Begin</code>
| <code>LookupTexture</code> (Client)
| <code>int LookupTexture(string ''filename'')</code>
| Loads a vmt file for use in Paint. Should not be called while the Paint function is running. Instead, store the texture number and reuse it.
|-
|-
| <code>End</code>
| <code>LookupFont</code> (Client)
| <code>int LookupFont(string ''name'')</code>
| Gets the ID of a font defined in SwarmSchemeNew.res. Examples of font names include Default, DefaultExtraLarge, DefaultVerySmall, DefaultBlur. Should not be called while the Paint function is running. Instead, store the font ID and reuse it.
|-
|-
| <code>EstablishDelegation</code>
| <code>GetFontTall</code> (Client)
| <code>int GetFontTall(int ''font'')</code>
| Returns the height in pixels of a font. Fast and safe to call from anywhere.
|-
|-
| <code>HookRootMetamethod</code>
| <code>GetTextWide</code> (Client)
| <code>int GetTextWide(int ''font'', string ''text'')</code>
| Returns the width in pixels of a string in a given font. Fast and safe to call from anywhere.
|-
|-
| <code>Log</code>
| <code>PaintText</code> (Client)
| <code>void PaintText(int ''x'', int ''y'', int ''r'', int ''g'', int ''b'', int ''a'', int ''font'', string ''text'')</code>
| Draws a string to the screen in a given color and font, with the top-left corner x pixels from the left edge of the screen and y pixels from the top of the screen. Can only be called during Paint.
|-
|-
| <code>m_bindNamesStack</code>
| <code>PaintRectangle</code> (Client)
| <code>void PaintRectangle(int ''x0'', int ''y0'', int ''x1'', int ''y1'', int ''r'', int ''g'', int ''b'', int ''a'')</code>
| Draws a solid-color rectangle to the screen. Can only be called during Paint.
|-
|-
| <code>m_fixupSet</code>
| <code>PaintRectangleFade</code> (Client)
| <code>void PaintRectangleFade(int ''x0'', int ''y0'', int ''x1'', int ''y1'', int ''r'', int ''g'', int ''b'', int ''a0'', int ''a1'', int ''fadeStart'', int ''fadeEnd'', bool ''horizontal'')</code>
| Draws a solid-color rectangle with a gradient alpha channel. Can only be called during paint.
|-
|-
| <code>m_log</code>
| <code>PaintTexturedRectangle</code> (Client)
| <code>void PaintTexturedRectangle(int ''x0'', int ''y0'', int ''x1'', int ''y1'', int ''r'', int ''g'', int ''b'', int ''a'', int ''texture'')</code>
| Draws a textured rectangle to the screen, multiplied by a color. Can only be called during paint.
|-
|-
| <code>m_logIndent</code>
| <code>PaintTexturedRectangleAdvanced</code> (Client)
| <code>void PaintTexturedRectangleAdvanced({int ''x0'', int ''y0'', int ''x1'', int ''y1'', int ''r'', int ''g'', int ''b'', int ''a0'', int ''a1'', int ''a2'', int ''a3'', float ''s0'', float ''t0'', float ''s1'', float ''t1'', float ''angle'', int ''texture''})</code>
| Takes a table and draws a rectangle to the screen. You can leave out fields from the table if you don't need them. Can only be called during paint.
|-
|-
| <code>m_targetTable</code>
| <code>PaintPolygon</code> (Client)
| <code>void PaintPolygon([{float ''x'', float ''y'', float ''s'', float ''t''}, ...], int ''r'', int ''g'', int ''b'', int ''a'', int ''texture'')</code>
| Draws an arbitrary convex polygon made up of at least three vertices defined by x,y (position) and s,t (texture) coordinates.
|-
|-
| <code>RemoveDelegation</code>
| <code>GetEntity</code> (Shared)
| <code>handle GetEntity(int ''index'')</code>
| Returns an entity stored in the data. Index must be 0.
|-
|-
| <code>Resolve</code>
| <code>GetInt</code> (Shared)
| <code>int GetInt(int ''index'')</code>
| Returns an integer stored in the data. Index can be from 0 to 63.
|-
|-
| <code>UnhookRootMetamethod</code>
| <code>GetFloat</code> (Shared)
|}
| <code>float GetFloat(int ''index'')</code>
 
| Returns a float stored in the data. Index can be from 0 to 31.
=== regexp ===
The built-in [http://squirrel-lang.org/doc/sqstdlib3.html#d0e2591 Squirrel class] for regular expressions.
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>constructor</code>
| <code>GetString</code> (Shared)
| <code>regexp()</code>
| <code>string GetString(int ''index'')</code>
|  
| Returns a string stored in the data. Index must be 0.
|-
|-
| <code>capture</code>
| <code>SetEntity</code> (Server)
| <code> [table] capture(''str'', [''start''])</code>
| <code>void SetEntity(int ''index'', handle ''entity'')</code>
| 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.  
| Stores an entity handle in the data. Index must be 0.
|-
|-
| <code>match</code>
| <code>SetInt</code> (Server)
| <code> bool match(''str'')</code>
| <code>void SetInt(int ''index'', int ''value'')</code>
| Returns a true if the regular expression matches the string str, otherwise returns false.  
| Stores an integer in the data. Index can be from 0 to 63.
|-
|-
| <code>search</code>
| <code>SetFloat</code> (Server)
| <code>table search(''str'', [''start''])</code>
| <code>void SetFloat(int ''index'', float ''value'')</code>
| 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.  
| Stores a float in the data. Index can be from 0 to 31.
|-
|-
| <code>subexpcount</code>
| <code>SetString</code> (Server)
|  
| <code>void SetString(int ''index'', string ''text'')</code>
|  
| Stores a string of up to 255 bytes in the data. Index must be 0.
|}
|}


Set up the entity:
<source lang=cpp>
local hHud = Entities.CreateByClassname( "rd_hud_vscript" );
hHud.__KeyValueFromString( "client_vscript", "your_nut_file.nut" );
hHud.Spawn();
hHud.Activate();
</source>


=== Vector ===
The client script should define two functions: OnUpdate and Paint.
Squirrel equivalent of the C++ [[Vector]] class.
 
OnUpdate is called on every client whenever the server changes the entity data, including immediately after the entity spawns on the client.
 
Paint is called on every client on every frame while the HUD is being drawn.


Three-dimensional vector.
This entity can hold up to 64 integers, 32 floats, 1 string and 1 entity of data.


Has overloaded arithmetic operations with both Vectors and scalar values.
An example below on how to display marine's kill count when they kill an alien, for 2 seconds.


{{note|[http://www.leeland.net/hochsuch.html Example] declaration and manipulation of Vector}}
Your challenge's .nut file:
<source lang=cpp>
function OnGameplayStart()
{
local hMarine = null;
while ( hMarine = Entities.FindByClassname( hMarine, "asw_marine" ) )
{
local hHud = Entities.CreateByClassname( "rd_hud_vscript" );
hHud.__KeyValueFromString( "client_vscript", "your_nut_file.nut" );
hHud.Spawn();
hHud.Activate();
hHud.SetEntity( 0, hMarine );
hHud.SetName( hMarine.GetName() + "_hud" );
hMarine.ValidateScriptScope();
hMarine.GetScriptScope().nKillCount <- 0;
}
}


==== Methods ====
function OnGameEvent_alien_died( params )
{| class="standard-table" style="width: 100%;"
{
! Function
if ( !( "marine" in params ) )
! Signature
return;
! Description
|-
local hMarine = EntIndexToHScript( params["marine"] );
| <code>constructor</code>
if ( !hMarine || !hMarine.IsValid() )
| <code>Vector(float ''x'', float ''y'', float ''z'')</code>
return;
| Creates a new vector with the specified Cartesian coordiantes.
|-
hMarine.GetScriptScope().nKillCount += 1;
| <code>Cross</code>
| <code>float Cross(Vector ''factor'')</code>
local hHud = Entities.FindByName( null, hMarine.GetName() + "_hud" );
| The vector product of two vectors. Returns a vector orthogonal to the input vectors.
hHud.SetInt( 0, hMarine.GetScriptScope().nKillCount );
|-
hHud.SetFloat( 0, Time() );
| <code>Dot</code>
}
| <code>float Dot(Vector ''factor'')</code>
</source>
| The scalar product of two vectors.  
Client script file for hud, in this case your_nut_file.nut:
<source lang=cpp>
/*
float 0 - time when last kill was performed
 
int 0 - kill count
entity 0 - marine
*/
 
FONT_DEFAULTLARGE <- self.LookupFont( "DefaultLarge" );
 
function Paint()
{
// if we are not playing or not spectating this marine, dont show his kill count
if ( self.GetEntity(0) != GetLocalPlayer().GetViewNPC() )
return;
// if more than 2 seconds have passed since last kill, dont show the kill count
if ( Time() - self.GetFloat(0) > 2.0 )
return;
self.PaintText( ScreenPosX( 0.5 ), ScreenPosY( 0.2 ), 200, 200, 200, 200, FONT_DEFAULTLARGE, self.GetInt(0).tostring() );
}
 
// pass in a value from 0.0 to 1.0, 0.0 means the left side of the screen, 1.0 means the right, 0.5 in the middle
function ScreenPosX( fFraction )
{
return ScreenWidth() * fFraction;
}
 
// pass in a value from 0.0 to 1.0, 0.0 means the up side of the screen, 1.0 means the down, 0.5 in the middle
function ScreenPosY( fFraction )
{
return ScreenHeight() * fFraction;
}
</source>
 
Some fonts (use LookupFont to get their IDs as they can change with game updates or Workshop mods):
*DefaultVerySmall
*DefaultVerySmallBlur
*DefaultSmall
*DefaultSmallBlur
*DefaultSmallOutline
*Default
*DefaultBlur
*DefaultShadowed
*DefaultUnderline
*DefaultMedium
*DefaultMediumBlur
*DefaultLarge
*DefaultLargeBlur
*DefaultBold
*DefaultBoldBlur
*DefaultExtraLarge
*DefaultExtraLargeBlur
*Countdown
*CountdownBlur
 
=== CRD_VGui_VScript ===
 
Classname of the entity: rd_vgui_vscript. '''Supports all methods that rd_hud_vscript does, plus:'''<br>
'''Note''': The client uses a prediction system to anticipate server responses and provide a smoother user experience. Therefore, the client side functions will not sync with server side variables automatically when you call Set***() functions from serverside. You can use the '''ForceSync()''' function to trigger a force sync with server side variables after you have called the Set***() functions from.
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
| <code>GetEntity</code> (Server)<br><code>GetInt</code> (Server)<br><code>GetFloat</code> (Server)<br><code>GetString</code> (Server)<br><code>SetEntity</code> (Server)<br><code>SetInt</code> (Server)<br><code>SetFloat</code> (Server)<br><code>SetString</code> (Server)
| <code>handle GetEntity(int ''index'')</code><br><code>int GetInt(int ''index'')</code><br><code>float GetFloat(int ''index'')</code><br><code>string GetString(int ''index'')</code><br><code>handle SetEntity(int ''index'')</code><br><code>int SetInt(int ''index'')</code><br><code>float SetFloat(int ''index'')</code><br><code>string SetString(int ''index'')</code>
| These functions allow you to get and set values from '''server side'''. Be aware that the corresponding values being manipulated in these server functions are stored in the '''server side''' variables.<br><code>CRD_VGui_VScript.m_hDataEntity</code><br><code>CRD_VGui_VScript.m_szDataInt</code><br><code>CRD_VGui_VScript.m_szDataFloat</code><br><code>CRD_VGui_VScript.m_szDataString</code><br>Therefore, each time you call these functions, the values will sync with the '''client side''' corresponding variables:<br><code>CRD_VGui_VScript.m_hDataEntity</code><br><code>CRD_VGui_VScript.m_szDataInt</code><br><code>CRD_VGui_VScript.m_szDataFloat</code><br><code>CRD_VGui_VScript.m_szDataString</code><br>
|-
|-
| <code>Length</code>
| <code>GetEntity</code> (Client)<br><code>GetInt</code> (Client)<br><code>GetFloat</code> (Client)<br><code>GetString</code> (Client)<br><code>SetInt</code> (Client)<br><code>SetFloat</code> (Client)<br><code>SetString</code> (Client)
| <code>float Length()</code>
| <code>handle GetEntity(int ''index'')</code><br><code>int GetInt(int ''index'')</code><br><code>float GetFloat(int ''index'')</code><br><code>string GetString(int ''index'')</code><br><code>int SetInt(int ''index'')</code><br><code>float SetFloat(int ''index'')</code><br><code>string SetString(int ''index'')</code>
| Magnitude of the vector.
| These functions allow you to get and set values from '''client side'''. Be aware that the corresponding values being manipulated in these client functions are stored in the '''client side''' variables.<br><code>CRD_VGui_VScript.m_hPredictedEntity</code><br><code>CRD_VGui_VScript.m_szPredictedInt</code><br><code>CRD_VGui_VScript.m_szPredictedFloat</code><br><code>CRD_VGui_VScript.m_szPredictedString</code><br>Therefore, each time you call these functions, the values '''will not''' sync with the '''server side''' corresponding variables automatically, since data from server are stored in different variables. If you want a force sync, you can call the '''ForceSync()''' function, this function will discard all client predictions and force syncing with server.
|-
|-
| <code>LengthSqr</code>
| <code>ForceSync</code> (Client)
| <code>float LengthSqr()</code>
| <code>void ForceSync()</code>
| The magnitude of the vector squared. Faster than the above method.
| This function simply calls an internal client side function:<br><code>void CRD_VGui_VScript::ResetPrediction()</code><br><code>{</code><br><code>    m_hPredictedEntity = m_hDataEntity;</code><br><code>    V_memcpy( &m_szPredictedString, &m_szDataString, sizeof( m_szPredictedString ) );</code><br><code>    V_memcpy( &m_flPredictedFloat, &m_flDataFloat, sizeof( m_flPredictedFloat ) );</code><br><code>    V_memcpy( &m_iPredictedInt, &m_iDataInt, sizeof( m_iPredictedInt ) );</code><br><code>    //Other stuff...</code><br><code>}</code><br><br>Call this function after you have changed some variables from server side and then you can use Get****() to retrive the latest values.
|-
|-
| <code>Length2D</code>
| <code>SendInput</code> (Client)
| <code>float Length2D()</code>
| <code>void SendInput(int ''value'')</code>
| Returns the magnitude of the vector on the x-y plane.
| Sends an input to the server. Inputs can be integers between ±16,777,215; larger values may result in floating point precision loss. Inputs will arrive on the server in order. Can only be called during the Control function.
|-
|-
| <code>Length2DSqr</code>
| <code>CreateButton</code> (Client)
| <code>float Length2DSqr()</code>
| <code>CRD_VGui_VScript_Button CreateButton()</code>
| Returns the square of the magnitude of the vector on the x-y plane. Faster than the above method.
| Creates a button that can be targeted by both mice and controllers. Do not create new buttons every frame; buttons exist for the lifetime of the rd_vgui_vscript entity. Instead, move or enable/disable buttons as needed.
|-
|-
| <code>Norm</code>
| <code>GetInteracter</code> (Shared)
| <code>float Norm()</code>
| <code>CASW_Inhabitable_NPC GetInteracter()</code>
| 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.  
| Returns the character (usually marine) that is allowed to interact with this screen.
|-
|-
| <code>ToKVString</code>
| <code>SetInteracter</code> (Server)
| <code>string ToKVString()</code>
| <code>void SetInteracter(CASW_Inhabitable_NPC interacter)</code>
| Returns a string without separations commas.
| Sets which character (usually marine) is allowed to interact with this screen.
|}
|}


==== Members ====
In addition to the callback functions for rd_hud_vscript, rd_vgui_vscript has the following callback functions:
 
Control(table) (Client)
 
The table contains:
*bool ''mouse'' (is the player using the mouse to aim? otherwise controller)
*bool ''keyboard'' (is the player using the keyboard to act/move? otherwise controller)
*int ''button'' (the button code that was pressed)
*bool ''mouse_left'', ''mouse_right'', ''key_left'', ''key_right'', ''key_up'', ''key_down'', ''key_space'', ''key_enter'', ''controller_left'', ''controller_right'', ''controller_up'', ''controller_down'', ''controller_a'', ''controller_b'' (whether each button is held)
*int ''mouse_x'', ''mouse_y'' (mouse position on screen)
*float ''move_x'', ''move_y'', ''look_x'', ''look_y'' (controller stick positions)
*CRD_VGui_VScript_Button ''focus'' (currently focused button on controller)
 
Input(integer) (Shared)
 
Called on both the client and the server when the client calls self.SendInput. The client can call SetInt, SetFloat, SetString, and SetEntity during this callback. Should only change data stored in the slots of the rd_vgui_vscript entity on the client as this function will be called repeatedly and only those values will be rolled back for prediction. When called on the client, it is followed by a call to the Update callback.
 
=== CRD_VGui_VScript_Button ===
 
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Instance
! Function
! Type
! Signature
! Description
! Description
|-
|-
| <code>x</code>
| <code>GetX</code>
| <code>float</code>
| <code>int GetX()</code>
| Cartesian X axis.
| Returns the x coordinate of the left edge of the button, previously set by SetX, SetPos, or SetBounds.
|-
| <code>GetY</code>
| <code>int GetY()</code>
| Returns the y coordinate of the top edge of the button, previously set by SetY, SetPos, or SetBounds.
|-
|-
| <code>y</code>
| <code>GetWide</code>
| <code>float</code>
| <code>int GetWide()</code>
| Cartesian Y axis.
| Returns the width of the button, previously set by SetWide, SetSize, or SetBounds.
|-
|-
| <code>z</code>
| <code>GetTall</code>
| <code>float</code>
| <code>int GetTall()</code>
| Cartesian Z axis.
| Returns the height of the button, previously set by SetTall, SetSize, or SetBounds.
|-
| <code>SetX</code>
| <code>void SetX(int ''x'')</code>
| Moves the button.
|-
| <code>SetY</code>
| <code>void SetY(int ''y'')</code>
| Moves the button.
|-
| <code>SetWide</code>
| <code>void SetWide(int ''wide'')</code>
| Resizes the button.
|-
| <code>SetTall</code>
| <code>void SetTall(int ''tall'')</code>
| Resizes the button.
|-
| <code>SetPos</code>
| <code>void SetPos(int ''x'', int ''y'')</code>
| Shortcut for calling SetX and SetY.
|-
| <code>SetSize</code>
| <code>void SetSize(int ''wide'', int ''tall'')</code>
| Shortcut for calling SetWide and SetTall.
|-
| <code>SetBounds</code>
| <code>void SetBounds(int ''x'', int ''y'', int ''wide'', int ''tall'')</code>
| Shortcut for calling SetPos and SetSize.
|-
| <code>SetEnabled</code>
| <code>void SetEnabled(bool ''enabled'')</code>
| Enables or disables the button. Disabled buttons cannot be focused by the controller and do not run callbacks.
|-
| <code>SetOnClicked</code>
| <code>void SetOnClicked(function() ''callback'')</code>
| Sets a function to be called when the button is clicked with the mouse or activated with the controller. This callback counts as part of the Control function, meaning you can call self.SendInput during the callback.
|-
| <code>SetOnCursorMoved</code>
| <code>void SetOnCursorMoved(function(int ''x'', int ''y'') ''callback'')</code>
| Sets a function to be called when the mouse is moved over the button. This callback counts as part of the Control function, meaning you can call self.SendInput during the callback.
|-
| <code>SetOnCursorEntered</code>
| <code>void SetOnCursorEntered(function() ''callback'')</code>
| Sets a function to be called when the mouse is moved onto the button. This callback counts as part of the Control function, meaning you can call self.SendInput during the callback.
|-
| <code>SetOnCursorExited</code>
| <code>void SetOnCursorExited(function() ''callback'')</code>
| Sets a function to be called when the mouse is moved off of the button. This callback counts as part of the Control function, meaning you can call self.SendInput during the callback.
|-
| <code>SetOnMousePressed</code>
| <code>void SetOnMousePressed(function(bool ''right'') ''callback'')</code>
| Sets a function to be called when a mouse button is pressed over the button. This callback counts as part of the Control function, meaning you can call self.SendInput during the callback.
|-
| <code>SetOnMouseReleased</code>
| <code>void SetOnMouseReleased(function(bool ''right'') ''callback'')</code>
| Sets a function to be called when a mouse button is released over the button. This callback counts as part of the Control function, meaning you can call self.SendInput during the callback.
|}
|}


=== CRD_Computer_VScript ===


=== Hooks ===
Classname of the entity: rd_computer_vscript. '''Supports all methods that rd_vgui_vscript does, plus:'''
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 ====
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
| <code>HackCompleted</code> (Server)
| <code>void HackCompleted()</code>
| Call this function to complete the hack. No effect if this entity is not being used as the hack.
|-
| <code>SetFastHackEndTime</code> (Server)
| <code>void SetFastHackEndTime(float ''time'')</code>
| Sets the deadline for the fast hack. In order for the fast hack to award stat progress and play the failed sound, the computer area must be set to have at least 6 tumblers. The hack must have been initialized, so the earliest this can be called is in the first call to OnOpened.
|-
| <code>GetFastHackEndTime</code> (Shared)
| <code>float GetFastHackEndTime()</code>
| Returns the deadline for the fast hack. The current time can be determined by calling Time().
|-
| <code>GetHackStartTime</code> (Shared)
| <code>float GetHackStartTime()</code>
| Returns the value of Time() when the hack started.
|-
| <code>Back</code> (Shared)
| <code>void Back()</code>
| Closes the screen, returning to the menu or exiting the computer.
|-
| <code>SetHackProgress</code> (Shared)
| <code>void SetHackProgress(float ''progress'')</code>
| Sets the hack progress between 0 (just started) and 1 (ready to call HackCompleted). Can only be called during the Input callback.
|}


<code>float OnTakeDamage_Alive_Any(CBaseEntity ''victim'', CBaseEntity ''inflictor'', CBaseEntity ''attacker'', CBaseEntity ''weapon'', float ''damage'', int ''damageType'', string ''ammoName'')</code>: Adding a function with this name in the script causes C++ to call it on all OnTakeDamage_Alive events.
In addition to the callback functions for rd_vgui_vscript, rd_computer_vscript has OnOpened and OnClosed callback functions on both the client and the server. The screen resolution is YRes(416) by YRes(312) rather than the usual XRes(640) by YRes(480).


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).
=== CScriptKeyValues ===
Script handle representation of a models [[$keyvalues]] block.
Sub keys are instances of the same class.


==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
| <code>constructor</code>
|-
| <code>FindKey</code>
| <code>CScriptKeyValues FindKey(string ''keyName'')</code>
| Find a sub key by the key name.
|-
| <code>GetFirstSubKey</code>
| <code>CScriptKeyValues GetFirstSubKey()</code>
| Return the first sub key object.
|-
| <code>GetKeyBool</code>
| <code>bool GetKeyBool(string ''keyName'')</code>
| Return the key value as a bool.
|-
| <code>GetKeyFloat</code>
| <code>float GetKeyFloat(string ''keyName'')</code>
| Return the key value as a float.
|-
| <code>GetKeyInt</code>
| <code>int GetKeyInt(string ''keyName'')</code>
| Return the key value as an integer.
|-
| <code>GetKeyString</code>
| <code>string GetKeyString(string ''keyName'')</code>
| Return the key value as a string.
|-
| <code>GetNextKey</code>
| <code>handle GetNextKey()</code>
| Return the next neighbor key object to the one the method is called on.
|-
| <code>IsKeyEmpty</code>
| <code>bool IsKeyEmpty(string ''keyName'')</code>
| Returns true if the named key has no value.
|-
| <code>IsValid</code>
| <code>bool IsValid()</code>
| Whether the handle belongs to a valid entity.
|-
| <code>ReleaseKeyValues</code>
| <code>void ReleaseKeyValues()</code>
| Releases the contents of the instance.
|}




==== UserConsoleCommand ====
=== CCallChainer ===
 
'''CCallChainer''' objects collect all functions with a matching prefix in a given scope, then inserts it all into the <code>chains</code> table with the prefix removed. All collected unprefixed functions can then be called in a chain using the class's <code>Call()</code> method, given the method's ''event'' argument matches the functions' name.
<code>void UserConsoleCommand(handle ''playerScript'', arg)</code>: when a user does a &lt;scripted_user_func argument&gt; 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 &lt;arg&gt; to give players special controls, etc.
 
 
 
==== OnGameEvent_''x'' ====
 
<code>void OnGameEvent_''x''(table ''params'')</code>: A callback that is called when the game event ''x'' is fired. See <code>scripts\gameevents.res</code> and <code>scripts\modeevents.res</code> for valid events. The [https://github.com/ReactiveDrop/reactivedrop_public_src/blob/a56e858f6ab76ff511f44cbe7bee550e2d2f66b8/src/game/server/ScriptGameEventListener.cpp#L385-L540 list of game events a script can listen for] is available in the game's source code.
 
 
 
==== OnMissionStart ====
 
<code>void OnMissionStart()</code>: A callback that is called when MissionStart occurs.
 
 


==== OnGameplayStart ====
Whenever a '''CCallChainer''' object is created, a function named <code>Dispatch</code> followed by its given prefix will also be created, which  the class binds the environment of its <code>Call()</code> method to.
 
<code>void OnGameplayStart()</code>: A callback that is called when all marines have spawned and players start to play.
 
 
 
==== Update ====
 
<code>void Update()</code>: Update gets called much like a Think() function. If you return a float value the function will get called again in x seconds.
 
 
 
==== OnSentTextMessage ====
 
<code>string OnSentTextMessage(CBaseEntity ''recipient'', CBaseEntity ''sender'', string ''message'')</code>: Called when a player sends a text message into chat.
 
Sent message will be replaced by the returned string. If the return type is not a string, message is not sent. Note, the message parameter contains an end of line character. If you want to get rid of it, do message = message.slice(
0, message.len() - 1 )
 
== Global functions ==
 
=== Printing and Drawing ===


==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 2,413: Line 2,723:
! Description
! Description
|-
|-
| <code>ClientPrint</code>
| <code>constructor</code>
| <code>void ClientPrint(CBasePlayer ''player'', int ''destination'', string ''message'', ...)</code>
| <code>CCallChainer(string ''functionPrefix'', table ''scope'' = null)</code>
| Print a client message. If you pass null instead of a valid player, the message will be sent to all clients. ''destination'' should be HUD_PRINTNOTIFY, HUD_PRINTCONSOLE, HUD_PRINTTALK, HUD_PRINTCENTER, or ASW_HUD_PRINTTALKANDCONSOLE. ''message'' will be looked up as a translation string and can contain %s1 through %s4 to reference extra string arguments passed after ''message''.
| Creates a CCallChainer object that'll collect functions that have a matching prefix in the given scope.
|-
|-
| <code>TextColor</code>
| <code>PostScriptExecute</code>
| <code>string TextColor(int ''r'', int ''g'', int ''b'')</code>
| <code>void PostScriptExecute()</code>
| Returns a string which is reinterpreted into a color internally in the ClientPrint ''message'' string. Turns all the characters that come after the returned string into respective RGB color.
| Search for all non-native functions with matching prefixes, then push them into the <code>chains</code> table.
|-
|-
| <code>TextColorBlend</code>
| <code>Call</code>
| <code>string TextColorBlend(int ''r1'', int ''g1'', int ''b1'', int ''r2'', int ''g2'', int ''b2'')</code>
| <code>bool Call(string ''event'', any ...)</code>
| Returns a string which is reinterpreted into a color blend internally in the ClientPrint ''message'' string. Turns all the characters that come after the returned string into respective RGB color blend.
| Find an unprefixed function name in the <code>chains</code> table and call it with the given arguments.
|}
 
==== Members ====
{| class="standard-table" style="width: 100%;"
! Instance
! Type
! Description
|-
|-
| <code>TextColorBlendInvert</code>
| <code>chains</code>
| <code>string TextColorBlendInvert(int ''r'', int ''g'', int ''b'')</code>
| <code>table</code>
| Returns a string which is reinterpreted into a inverted color blend internally in the ClientPrint ''message'' string. Turns all the characters that come after the returned string into respective inverted RGB color blend.
| Contains names of unprefixed functions, each with an array of functions to call.
|-
|-
| <code>TextColorBlend3</code>
| <code>prefix</code>
| <code>string TextColorBlend3(int ''r1'', int ''g1'', int ''b1'', int ''r2'', int ''g2'', int ''b2'', int ''r3'', int ''g3'', int ''b3'')</code>
| <code>string</code>
| Returns a string which is reinterpreted into a triple color blend internally in the ClientPrint ''message'' string. Turns all the characters that come after the returned string into respective triple RGB color blend.
| Prefix that functions should have to be added into the <code>chains</code> table. Set by the constructor.
|-
|-
| <code>TextColorBlendCycle</code>
| <code>scope</code>
| <code>string TextColorBlendCycle(int ''transition_length'', int ''r1'', int ''g1'', int ''b1'', int ''r2'', int ''g2'', int ''b2'')</code>
| <code>table</code>
| Returns a string which is reinterpreted into a color blend cycle internally in the ClientPrint ''message'' string. Turns all the characters that come after the returned string into respective RGB color blend cycle.
| If set, seek functions in this scope instead. Set by the constructor.
|-
|}
| <code>TextColorBlendSmoothCycle</code>
 
| <code>string TextColorBlendSmoothCycle(int ''transition_length'', int ''r1'', int ''g1'', int ''b1'', int ''r2'', int ''g2'', int ''b2'')</code>
 
| Returns a string which is reinterpreted into a smooth color blend cycle internally in the ClientPrint ''message'' string. Turns all the characters that come after the returned string into respective smooth RGB color blend cycle.
=== CSimpleCallChainer ===
|-
Intended to be simpler to use than [[#CCallChainer|CCallChainer]], the class '''CSimpleCallChainer''' holds only a single chain of functions inside an array instead of multiple inside a table. As such, its <code>Call()</code> method does not need a function's name.
| <code>DebugDrawBox</code>
 
| <code>void DebugDrawBox(vector ''origin'', vector ''min'', vector ''max'', int ''r'', int ''g'', int ''b'', int ''alpha'', float ''duration'')</code>
This class is also used internally by these [[#CBaseEntity|CBaseEntity]] hooks: <code>Precache()</code> and <code>OnPostSpawn()</code>.
| Draw a debug overlay box.
|-
| <code>DebugDrawLine</code>
| <code>void DebugDrawLine(Vector ''start'', Vector ''end'', int ''red'', int ''green'', int ''blue'', bool ''zTest'', float ''time'')</code>
| Draw a debug line between two points.
|-
| <code>Msg</code>
| <code>void Msg(string ''message'')</code>
| Equivalent to <code>print</code>
|-
| <code>print</code>
| <code>void print(string ''message'')</code>
| Prints the given message to the developer console.
|-
| <code>printl</code>
| <code>void printl(string ''message'')</code>
| Prints the given message to the developer console just like print but also appends a newline.
|-
| <code>Say</code>
| <code>void Say(CBasePlayer ''player'', string ''message'')</code>
| Calling this will have the specified player send the message to chat.
|-
| <code>ShowMessage</code>
| <code>void ShowMessage(string)</code>
| Print a hud message on all clients. {{Bug|Non-functional}}
|-
| <code>__DumpScope</code>
| <code>void __DumpScope(int ''indentation'', handle ''scope'')</code>
| Dumps contents of everything in the scope.
|-
|}


=== Other ===
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 2,481: Line 2,767:
! Description
! Description
|-
|-
| <code>AddThinkToEnt</code>
| <code>constructor</code>
| <code>void AddThinkToEnt(handle ''entity'', string ''funcName'')</code>
| <code>CSimpleCallChainer(string ''functionPrefix'', table ''scope'' = null, exactMatch = false)</code>
| Adds a late bound think function to the C++ think tables for the obj.
| Creates a CSimpleCallChainer object that'll collect functions that have a matching prefix in the given scope, unless it seek for an exact name match.
|-
|-
| <code>Assert</code>
| <code>PostScriptExecute</code>
| <code>void Assert(bool ''value'', string ''optional message'')</code>
| <code>void PostScriptExecute()</code>
| Test value and if not true, throws exception, optionally with message.
| Begin searching for all non-native functions with matching prefixes, then push them into the <code>chain</code> array.
|-
|-
| <code>ChangeLevel</code>
| <code>Call</code>
| <code>void ChangeLevel(string ''mapname'')</code>
| <code>bool Call(any ...)</code>
| Tell engine to change level.
| Call all functions inside the <code>chain</code> array with the given arguments.
|}
 
==== Members ====
{| class="standard-table" style="width: 100%;"
! Instance
! Type
! Description
|-
|-
| <code>CreateGrenadeCluster</code>
| <code>chain</code>
| <code>handle CreateGrenadeCluster(float ''damage'', float ''radius'', int ''clusters'', Vector ''position'', Vector ''angles'', Vector ''velocity'', Vector ''angVelocity'')</code>
| <code>array</code>
| Create grenade cluster.
| All functions to be called by the <code>Call()</code> method.
|-
|-
| <code>CreateProp</code>
| <code>exactMatch</code>
| <code>handle CreateProp(string ''class'', Vector ''origin'', string ''model'', int ''animation'')</code>
| <code>bool</code>
| 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. {{bug|Does not initialize the physics of the prop.}}
| If set, names of non-native functions and <code>prefix</code> must be an exact match. Set by the constructor.
|-
|-
| <code>CreateSceneEntity</code>
| <code>prefix</code>
| <code>CSceneEntity CreateSceneEntity(string ''scene'')</code>
| <code>string</code>
| Create a scene entity to play the specified scene .vcd file.
| Prefix that functions should have to be added into the <code>chain</code> array. Set by the constructor.
|-
|-
| <code>DoIncludeScript</code>
| <code>scope</code>
| <code>bool DoIncludeScript(string ''filename'', table ''scope'')</code>
| <code>table</code>
| Execute a script with the script scope set to the specified table.
| If set, seek functions in this scope instead. Set by the constructor.
|-
|}
| <code>DoEntFire</code>
 
| <code>void DoEntFire(string ''target'', string ''action'', string ''value'', float ''delay'', handle ''activator'', handle ''caller'')</code>
 
| 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.
=== 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.
| <code>DropFragGrenade</code>
<source lang=cpp>
| <code>handle DropFragGrenade(float ''damage'', float ''grenadeRadius'', Vector ''origin'')</code>
// Usage:
| Drops a frag grenade.
lateBinder <- LateBinder();
|-
lateBinder.Begin( this );
| <code>DropFreezeGrenade</code>
 
| <code>handle DropFreezeGrenade(float ''damage'', float ''freezeAmount'', float ''grenadeRadius'', Vector ''origin'')</code>
Test1 <-
| Drops a freeze grenade.
  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;
</source>
 
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 ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>DropGasGrenade</code>
| <code>Begin</code>
| <code>handle DropGasGrenade(float ''damage'', float dmgInterval, float duration, float fuse, Vector ''origin'')</code>
| Drops a gas grenade. // new edit default: damge = 20 , damage per seconds = 0.3, duration = 30, fuse = 1 # radius being fix to 100 using covar asw_gas_grenade_cloud_width
|-
|-
| <code>DropIncendiaryGrenade</code>
| <code>End</code>
| <code>handle DropIncendiaryGrenade(float ''damage'', float ''grenadeRadius'', Vector ''origin'')</code>
| Drops an incendiary grenade.
|-
|-
| <code>DropStunGrenade</code>
| <code>EstablishDelegation</code>
| <code>handle DropStunGrenade(float ''damage'', float ''grenadeRadius'', Vector ''origin'')</code>
| Drops a stun grenade.
|-
|-
| <code>EntFire</code>
| <code>HookRootMetamethod</code>
| <code>function EntFire(string ''target'', string ''action'', string ''value'', float ''delay'' = 0.0, handle ''activator'' = null)</code>
| Generate an entity I/O event.
|-
|-
| <code>EntFireByHandle</code>
| <code>Log</code>
| <code>void EntFireByHandle(handle ''target'', string ''action'', string ''value'', float ''delay'', handle ''activator'', handle ''caller'')</code>
| 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.
|-
|-
| <code>EntIndexToHScript</code>
| <code>m_bindNamesStack</code>
| <code>CBaseEntity EntIndexToHScript(int ''entIndex'')</code>
| Returns the script handle for the given entity index.
|-
|-
| <code>FadeClientVolume</code>
| <code>m_fixupSet</code>
| <code>void FadeClientVolume(handle ''player'', float ''fadePercent'', float ''fadeOutSeconds'', float ''holdTime'', float ''fadeInSeconds'')</code>
| Fade out the client's volume level toward silence (or fadePercent).
|-
|-
| <code>FileToString</code>
| <code>m_log</code>
| <code>string FileToString(string ''file'')</code>
| Reads a string from file. Returns the string from the file, empty string if no file or file is too big.
|-
|-
| <code>FindNearestNPC</code>
| <code>m_logIndent</code>
| <code>handle FindNearestNPC(Vector ''position'', bool ''checkZCoordinate'', float ''radius'')</code>
| Returns the nearest character (Marine, Colonist, or Alien) to the given coordinate.
|-
|-
| <code>FrameTime</code>
| <code>m_targetTable</code>
| <code>float FrameTime()</code>
| Get the time spent on the server in the last frame
|-
|-
| <code>GamePause</code>
| <code>RemoveDelegation</code>
| <code>void GamePause(bool ''bPause'')</code>
| Pause or unpause the game.
|-
|-
| <code>GetClientXUID</code>
| <code>Resolve</code>
| <code>string GetClientXUID(handle ''player'')</code>
| Get the player's xuid (i.e. SteamID64).
|-
|-
| <code>GetDecalIndexForName</code>
| <code>UnhookRootMetamethod</code>
| <code>int GetDecalIndexForName(string ''name'')</code>
|}
| Get decal index from a string.
 
=== regexp ===
The built-in [http://squirrel-lang.org/doc/sqstdlib3.html#d0e2591 Squirrel class] for regular expressions.
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>GetEffectIndex</code>
| <code>constructor</code>
| <code>int GetEffectIndex(string ''name'')</code>
| <code>regexp()</code>
| Converts a previously precached effect into an index.
|  
|-
|-
| <code>GetEffectNameFromIndex</code>
| <code>capture</code>
| <code>string GetEffectNameFromIndex(int ''index'')</code>
| <code> [table] capture(''str'', [''start''])</code>
| Converts a previously precached effect index into a string.
| 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.  
|-
|-
| <code>GetFrameCount</code>
| <code>match</code>
| <code>int GetFrameCount()</code>
| <code> bool match(''str'')</code>
| Returns the engine's current frame count.
| Returns a true if the regular expression matches the string str, otherwise returns false.  
|-
|-
| <code>GetHullMaxs</code>
| <code>search</code>
| <code>Vector GetHullMaxs(int ''hullType'')</code>
| <code>table search(''str'', [''start''])</code>
| Returns a Vector for the hull maxs.
| 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.  
|-
|-
| <code>GetHullMins</code>
| <code>subexpcount</code>
| <code>Vector GetHullMins(int ''hullType'')</code>
|  
| Returns a Vector for the hull mins.
|  
|}
 
 
=== Vector ===
Squirrel equivalent of the C++ [[Vector]] class.
 
Three-dimensional vector.
 
Has overloaded arithmetic operations with both Vectors and scalar values.
 
{{note|[http://www.leeland.net/hochsuch.html Example] declaration and manipulation of Vector}}
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>GetListenServerHost</code>
| <code>constructor</code>
| <code>handle GetListenServerHost()</code>
| <code>Vector(float ''x'', float ''y'', float ''z'')</code>
| Get the host player on a listen server.
| Creates a new vector with the specified Cartesian coordiantes.
|-
|-
| <code>GetMapName</code>
| <code>Cross</code>
| <code>string GetMapName()</code>
| <code>float Cross(Vector ''factor'')</code>
| Get the name of the map.
| The vector product of two vectors. Returns a vector orthogonal to the input vectors.
|-
|-
| <code>GetModelIndex</code>
| <code>Dot</code>
| <code>int GetModelIndex(string ''filename'')</code>
| <code>float Dot(Vector ''factor'')</code>
| Returns index of model by name.
| The scalar product of two vectors.  
|-
|-
| <code>GetParticleSystemIndex</code>
| <code>Length</code>
| <code>int GetParticleSystemIndex(string ''name'')</code>
| <code>float Length()</code>
| Converts a previously precached material into an index.
| Magnitude of the vector.
|-
|-
| <code>GetParticleSystemNameFromIndex</code>
| <code>LengthSqr</code>
| <code>string GetParticleSystemNameFromIndex(int ''index'')</code>
| <code>float LengthSqr()</code>
| Converts a previously precached material index into a string.
| The magnitude of the vector squared. Faster than the above method.
|-
|-
| <code>GetPlayerConnectionInfo</code>
| <code>Length2D</code>
| <code>void GetPlayerConnectionInfo(handle ''player'', table)</code>
| <code>float Length2D()</code>
| Returns a table containing the player's connection info.
| Returns the magnitude of the vector on the x-y plane.
|-
|-
| <code>GetPlayerFromUserID</code>
| <code>Length2DSqr</code>
| <code>handle GetPlayerFromUserID(int ''ID'')</code>
| <code>float Length2DSqr()</code>
| Given a user id, return the entity, or null.
| Returns the square of the magnitude of the vector on the x-y plane. Faster than the above method.
|-
|-
| <code>IsAnniversaryWeek</code>
| <code>Norm</code>
| <code>bool IsAnniversaryWeek()</code>
| <code>float Norm()</code>
| Returns true if it is the anniversary week of Alien Swarm: Reactive Drop.
| 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.  
|-
|-
| <code>IsDedicatedServer</code>
| <code>ToKVString</code>
| <code>bool IsDedicatedServer()</code>
| <code>string ToKVString()</code>
| Returns true if this is a dedicated server.
| Returns a string without separations commas.
|}
 
==== Members ====
{| class="standard-table" style="width: 100%;"
! Instance
! Type
! Description
|-
|-
| <code>IsModelPrecached</code>
| <code>x</code>
| <code>bool IsModelPrecached(string ''modelname'')</code>
| <code>float</code>
| Checks if the modelname is precached.
| Cartesian X axis.
|-
|-
| <code>LocalTime</code>
| <code>y</code>
| <code>void LocalTime(table)</code>
| <code>float</code>
| Fills in the passed table with the local system time.
| Cartesian Y axis.
|-
|-
| <code>PlaceDamageAmplifier</code>
| <code>z</code>
| <code>handle PlaceDamageAmplifier(float ''duration'', float ''grenadeRadius'', Vector ''origin'')</code>
| <code>float</code>
| Places a damage amplifier.
| Cartesian Z axis.
|-
|}
| <code>PlaceHealBeacon</code>
 
| <code>handle PlaceHealBeacon(float ''healAmount'', float ''healthPerSecond'', float ''infestationCureAmount'', float ''duration'', float ''grenadeRadius'', Vector ''origin'')</code>
 
| Places a heal beacon. Default values for Faith / Bastille are : healAmount = 100 / 90, healthPerSecond = 3, infestationCureAmount = 0.75 / 0.25, duration = 20, grenadeRadius = 100
=== 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 ====
 
<code>float OnTakeDamage_Alive_Any(CBaseEntity ''victim'', CBaseEntity ''inflictor'', CBaseEntity ''attacker'', CBaseEntity ''weapon'', float ''damage'', int ''damageType'', string ''ammoName'')</code>: 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).
 
 
 
==== AlterDeathMessage ====
 
<code>string AlterDeathMessage(CBaseEntity ''victim'', CBaseEntity ''inflictor'', CBaseEntity ''attacker'', CBaseEntity ''weapon'', float ''damage'', int ''damageType'', string ''ammoName'')</code>:
 
Called when a chat death message is about to be printed. Return a string which will be printed instead, %s1 in the string being the victim's display name (optional to have it). No return value or non-string return value results in default death message.
 
Example:
<source lang=cpp>
function AlterDeathMessage( victim, inflictor, attacker, weapon, damage, damageType, ammoName )
{
if ( attacker.IsAlien() )
return "%s1 was killed by an alien!";
if ( damageType & 64 )
return "%s1 was killed by an explosion!";
}
</source>
 
==== UserConsoleCommand ====
 
<code>void UserConsoleCommand(handle ''playerScript'', arg)</code>: when a user does a &lt;scripted_user_func argument&gt; 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 &lt;arg&gt; to give players special controls, etc.
 
 
 
==== OnGameEvent_''x'' ====
 
<code>void OnGameEvent_''x''(table ''params'')</code>: A callback that is called when the game event ''x'' is fired. See <code>scripts\gameevents.res</code> and <code>scripts\modeevents.res</code> for valid events. The [https://github.com/ReactiveDrop/reactivedrop_public_src/blob/a56e858f6ab76ff511f44cbe7bee550e2d2f66b8/src/game/server/ScriptGameEventListener.cpp#L385-L540 list of game events a script can listen for] is available in the game's source code.
 
 
 
==== OnMissionStart ====
 
<code>void OnMissionStart()</code>: A callback that is called when MissionStart occurs.
 
 
 
==== OnGameplayStart ====
 
<code>void OnGameplayStart()</code>: A callback that is called when all marines have spawned and players start to play.
 
 
 
==== Update ====
 
<code>void Update()</code>: Update gets called much like a Think() function. If you return a float value the function will get called again in x seconds.
 
 
 
==== OnReceivedTextMessage ====
 
<code>string OnReceivedTextMessage(CBaseEntity ''recipient'', CBaseEntity ''sender'', string ''message'')</code>: Called when a player sends a text message into chat.
 
Sent message will be replaced by the returned string. If the return type is not a string, message is not sent. Note, the message parameter contains an end of line character. If you want to get rid of it, do message = message.slice(
0, message.len() - 1 )
 
== Global functions ==
 
=== Printing and Drawing ===
 
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
|-
| <code>PlantIncendiaryMine</code>
| <code>ClientPrint</code>
| <code>void ClientPrint(CBasePlayer ''player'', int ''destination'', string ''message'', ...)</code>
| Print a client message. If you pass null instead of a valid player, the message will be sent to all clients. ''destination'' should be HUD_PRINTNOTIFY, HUD_PRINTCONSOLE, HUD_PRINTTALK, HUD_PRINTCENTER, or ASW_HUD_PRINTTALKANDCONSOLE. ''message'' will be looked up as a translation string and can contain %s1 through %s4 to reference extra string arguments passed after ''message''.
|-
| <code>TextColor</code>
| <code>string TextColor(int ''r'', int ''g'', int ''b'')</code>
| Returns a string which is reinterpreted into a color internally in the ClientPrint ''message'' string. Turns all the characters that come after the returned string into respective RGB color.
|-
| <code>TextColorBlend</code>
| <code>string TextColorBlend(int ''r1'', int ''g1'', int ''b1'', int ''r2'', int ''g2'', int ''b2'')</code>
| Returns a string which is reinterpreted into a color blend internally in the ClientPrint ''message'' string. Turns all the characters that come after the returned string into respective RGB color blend.
|-
| <code>TextColorBlendInvert</code>
| <code>string TextColorBlendInvert(int ''r'', int ''g'', int ''b'')</code>
| Returns a string which is reinterpreted into a inverted color blend internally in the ClientPrint ''message'' string. Turns all the characters that come after the returned string into respective inverted RGB color blend.
|-
| <code>TextColorBlend3</code>
| <code>string TextColorBlend3(int ''r1'', int ''g1'', int ''b1'', int ''r2'', int ''g2'', int ''b2'', int ''r3'', int ''g3'', int ''b3'')</code>
| Returns a string which is reinterpreted into a triple color blend internally in the ClientPrint ''message'' string. Turns all the characters that come after the returned string into respective triple RGB color blend.
|-
| <code>TextColorBlendCycle</code>
| <code>string TextColorBlendCycle(int ''transition_length'', int ''r1'', int ''g1'', int ''b1'', int ''r2'', int ''g2'', int ''b2'')</code>
| Returns a string which is reinterpreted into a color blend cycle internally in the ClientPrint ''message'' string. Turns all the characters that come after the returned string into respective RGB color blend cycle.
|-
| <code>TextColorBlendSmoothCycle</code>
| <code>string TextColorBlendSmoothCycle(int ''transition_length'', int ''r1'', int ''g1'', int ''b1'', int ''r2'', int ''g2'', int ''b2'')</code>
| Returns a string which is reinterpreted into a smooth color blend cycle internally in the ClientPrint ''message'' string. Turns all the characters that come after the returned string into respective smooth RGB color blend cycle.
|-
| <code>DebugDrawBox</code>
| <code>void DebugDrawBox(vector ''origin'', vector ''min'', vector ''max'', int ''r'', int ''g'', int ''b'', int ''alpha'', float ''duration'')</code>
| Draw a debug overlay box.
|-
| <code>DebugDrawLine</code>
| <code>void DebugDrawLine(Vector ''start'', Vector ''end'', int ''red'', int ''green'', int ''blue'', bool ''zTest'', float ''time'')</code>
| Draw a debug line between two points.
|-
| <code>Msg</code>
| <code>void Msg(string ''message'')</code>
| Equivalent to <code>print</code>
|-
| <code>print</code>
| <code>void print(string ''message'')</code>
| Prints the given message to the developer console.
|-
| <code>printl</code>
| <code>void printl(string ''message'')</code>
| Prints the given message to the developer console just like print but also appends a newline.
|-
| <code>Say</code>
| <code>void Say(CBasePlayer ''player'', string ''message'')</code>
| Calling this will have the specified player send the message to chat.
|-
| <code>ScreenHeight</code> (Client)
| <code>int ScreenHeight()</code>
| Returns the height of the screen in pixels.
|-
| <code>ScreenWidth</code> (Client)
| <code>int ScreenWidth()</code>
| Returns the width of the screen in pixels.
|-
| <code>ShowMessage</code>
| <code>void ShowMessage(string)</code>
| Print a hud message on all clients. {{Bug|Non-functional}}
|-
| <code>TryLocalize</code> (Client)
| <code>string TryLocalize(string ''text'')</code>
| If text is a valid translation key starting with #, returns the translated string. Otherwise, returns text as-is.
|-
| <code>XRes</code> (Client)
| <code>float XRes(float ''x'')</code>
| Scales an X coordinate based on a 640 pixel wide screen.
|-
| <code>YRes</code> (Client)
| <code>float YRes(float ''y'')</code>
| Scales a Y coordinate based on a 480 pixel tall screen.
|-
| <code>__DumpScope</code>
| <code>void __DumpScope(int ''indentation'', handle ''scope'')</code>
| Dumps contents of everything in the scope.
|-
|}
 
=== Other ===
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
| <code>AddThinkToEnt</code>
| <code>void AddThinkToEnt(handle ''entity'', string ''funcName'')</code>
| Adds a late bound think function to the C++ think tables for the obj.
|-
| <code>Assert</code>
| <code>void Assert(bool ''value'', string ''optional message'')</code>
| Test value and if not true, throws exception, optionally with message.
|-
| <code>ChangeLevel</code>
| <code>void ChangeLevel(string ''mapname'')</code>
| Tell engine to change level.
|-
| <code>CreateGrenadeCluster</code>
| <code>handle CreateGrenadeCluster(float ''damage'', float ''radius'', int ''clusters'', Vector ''position'', Vector ''angles'', Vector ''velocity'', Vector ''angVelocity'')</code>
| Create grenade cluster.
|-
| <code>CreateProp</code>
| <code>handle CreateProp(string ''class'', Vector ''origin'', string ''model'', int ''animation'')</code>
| 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. {{bug|hidetested=1|Does not initialize the physics of the prop.}}
|-
| <code>CreateSceneEntity</code>
| <code>CSceneEntity CreateSceneEntity(string ''scene'')</code>
| Create a scene entity to play the specified scene .vcd file.
|-
| <code>DisptchParticleEffect</code>
| <code>void DispatchParticleEffect(string ''name'', Vector ''origin'', Vector ''angles'')</code>
| Spawns a particle effect in the world.
|-
| <code>DisptchParticleEffectCP1</code>
| <code>void DispatchParticleEffectCP1(string ''name'', Vector ''origin'', Vector ''angles'', Vector ''cp1'')</code>
| Spawns a particle effect in the world with a specific offset for control point 1.
|-
| <code>DoIncludeScript</code>
| <code>bool DoIncludeScript(string ''filename'', table ''scope'')</code>
| Execute a script with the script scope set to the specified table.
|-
| <code>DoEntFire</code>
| <code>void DoEntFire(string ''target'', string ''action'', string ''value'', float ''delay'', handle ''activator'', handle ''caller'')</code>
| 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.
|-
| <code>DropFragGrenade</code>
| <code>handle DropFragGrenade(float ''damage'', float ''grenadeRadius'', Vector ''origin'')</code>
| Drops a frag grenade.
|-
| <code>DropFreezeGrenade</code>
| <code>handle DropFreezeGrenade(float ''damage'', float ''freezeAmount'', float ''grenadeRadius'', Vector ''origin'')</code>
| Drops a freeze grenade.
|-
| <code>DropGasGrenade</code>
| <code>handle DropGasGrenade(float ''damage'', float dmgInterval, float duration, float fuse, Vector ''origin'')</code>
| Drops a gas grenade. // new edit default: damge = 20 , damage per seconds = 0.3, duration = 30, fuse = 1 # radius being fix to 100 using covar asw_gas_grenade_cloud_width
|-
| <code>DropIncendiaryGrenade</code>
| <code>handle DropIncendiaryGrenade(float ''damage'', float ''grenadeRadius'', Vector ''origin'')</code>
| Drops an incendiary grenade.
|-
| <code>DropStunGrenade</code>
| <code>handle DropStunGrenade(float ''damage'', float ''grenadeRadius'', Vector ''origin'')</code>
| Drops a stun grenade.
|-
| <code>EntFire</code>
| <code>function EntFire(string ''target'', string ''action'', string ''value'', float ''delay'' = 0.0, handle ''activator'' = null)</code>
| Generate an entity I/O event.
|-
| <code>EntFireByHandle</code>
| <code>void EntFireByHandle(handle ''target'', string ''action'', string ''value'', float ''delay'', handle ''activator'', handle ''caller'')</code>
| 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.
|-
| <code>EntIndexToHScript</code>
| <code>CBaseEntity EntIndexToHScript(int ''entIndex'')</code>
| Returns the script handle for the given entity index.
|-
| <code>FadeClientVolume</code>
| <code>void FadeClientVolume(handle ''player'', float ''fadePercent'', float ''fadeOutSeconds'', float ''holdTime'', float ''fadeInSeconds'')</code>
| Fade out the client's volume level toward silence (or fadePercent).
|-
| <code>FileToString</code>
| <code>string FileToString(string ''file'')</code>
| Reads a string from file. Returns the string from the file, empty string if no file or file is too big.
|-
| <code>FindNearestNPC</code>
| <code>handle FindNearestNPC(Vector ''position'', bool ''checkZCoordinate'', float ''radius'')</code>
| Returns the nearest character (Marine, Colonist, or Alien) to the given coordinate.
|-
| <code>FrameTime</code>
| <code>float FrameTime()</code>
| Get the time spent on the server in the last frame
|-
| <code>GamePause</code>
| <code>void GamePause(bool ''bPause'')</code>
| Pause or unpause the game.
|-
| <code>GetClientXUID</code>
| <code>string GetClientXUID(handle ''player'')</code>
| Get the player's xuid (i.e. SteamID64).
|-
| <code>GetDecalIndexForName</code>
| <code>int GetDecalIndexForName(string ''name'')</code>
| Get decal index from a string.
|-
| <code>GetEffectIndex</code>
| <code>int GetEffectIndex(string ''name'')</code>
| Converts a previously precached effect into an index.
|-
| <code>GetEffectNameFromIndex</code>
| <code>string GetEffectNameFromIndex(int ''index'')</code>
| Converts a previously precached effect index into a string.
|-
| <code>GetFrameCount</code>
| <code>int GetFrameCount()</code>
| Returns the engine's current frame count.
|-
| <code>GetHullMaxs</code>
| <code>Vector GetHullMaxs(int ''hullType'')</code>
| Returns a Vector for the hull maxs.
|-
| <code>GetHullMins</code>
| <code>Vector GetHullMins(int ''hullType'')</code>
| Returns a Vector for the hull mins.
|-
| <code>GetLocalPlayer</code> (Client)
| <code>handle GetLocalPlayer()</code>
| Returns the local C_ASW_Player.
|-
| <code>GetListenServerHost</code>
| <code>handle GetListenServerHost()</code>
| Get the host player on a listen server.
|-
| <code>GetMapName</code>
| <code>string GetMapName()</code>
| Get the name of the map.
|-
| <code>GetModelIndex</code>
| <code>int GetModelIndex(string ''filename'')</code>
| Returns index of model by name.
|-
| <code>GetParticleSystemIndex</code>
| <code>int GetParticleSystemIndex(string ''name'')</code>
| Converts a previously precached material into an index.
|-
| <code>GetParticleSystemNameFromIndex</code>
| <code>string GetParticleSystemNameFromIndex(int ''index'')</code>
| Converts a previously precached material index into a string.
|-
| <code>GetPlayerConnectionInfo</code>
| <code>void GetPlayerConnectionInfo(handle ''player'', table)</code>
| Returns a table containing the player's connection info.
|-
| <code>GetPlayerFromUserID</code>
| <code>handle GetPlayerFromUserID(int ''ID'')</code>
| Given a user id, return the entity, or null.
|-
| <code>IsAnniversaryWeek</code>
| <code>bool IsAnniversaryWeek()</code>
| Returns true if it is the anniversary week of Alien Swarm: Reactive Drop.
|-
| <code>IsDedicatedServer</code>
| <code>bool IsDedicatedServer()</code>
| Returns true if this is a dedicated server.
|-
| <code>IsModelPrecached</code>
| <code>bool IsModelPrecached(string ''modelname'')</code>
| Checks if the modelname is precached.
|-
| <code>LocalTime</code>
| <code>void LocalTime(table)</code>
| Fills in the passed table with the local system time.
|-
| <code>PlaceDamageAmplifier</code>
| <code>handle PlaceDamageAmplifier(float ''duration'', float ''grenadeRadius'', Vector ''origin'')</code>
| Places a damage amplifier.
|-
| <code>PlaceHealBeacon</code>
| <code>handle PlaceHealBeacon(float ''healAmount'', float ''healthPerSecond'', float ''infestationCureAmount'', float ''duration'', float ''grenadeRadius'', Vector ''origin'')</code>
| Places a heal beacon. Default values for Faith / Bastille are : healAmount = 100 / 90, healthPerSecond = 3, infestationCureAmount = 0.75 / 0.25, duration = 20, grenadeRadius = 100
|-
| <code>PlantIncendiaryMine</code>
| <code>handle PlantIncendiaryMine(Vector ''origin'', Vector ''angles'')</code>
| <code>handle PlantIncendiaryMine(Vector ''origin'', Vector ''angles'')</code>
| Plants an incendiary mine.
| Plants an incendiary mine.
|-
|-
| <code>PlantLaserMine</code>
| <code>PlantLaserMine</code>
| <code>handle PlantLaserMine(bool ''friendly'', Vector ''origin'', Vector ''angles'')</code>
| <code>handle PlantLaserMine(bool ''friendly'', Vector ''origin'', Vector ''angles'')</code>
| Plants a laser mine.
| Plants a laser mine.
|-
|-
| <code>PlayerInstanceFromIndex</code>
| <code>PlayerInstanceFromIndex</code>
| <code>CBasePlayer PlayerInstanceFromIndex(int ''index'')</code>
| <code>CBasePlayer PlayerInstanceFromIndex(int ''index'')</code>
| Get a script handle of a player using the player index.
| Get a script handle of a player using the player index.
|-
|-
| <code>PrecacheEffect</code>
| <code>PrecacheEffect</code>
| <code>void PrecacheEffect(string ''name'')</code>
| <code>void PrecacheEffect(string ''name'')</code>
| Precaches an effect.
| Precaches an effect.
|-
|-
| <code>PrecacheModel</code>
| <code>PrecacheModel</code>
| <code>int PrecacheModel(string ''filename'')</code>
| <code>int PrecacheModel(string ''filename'')</code>
| Precache a model and return index of the model.
| Precache a model and return index of the model.
|-
|-
| <code>PrecacheParticleSystem</code>
| <code>PrecacheParticleSystem</code>
| <code>int PrecacheParticleSystem(string ''name'')</code>
| <code>int PrecacheParticleSystem(string ''name'')</code>
| Precaches a particle material.
| Precaches a particle material.
|-
| <code>PrintHelp</code>
|
| {{todo}}
|-
| <code>RandomFloat</code>
| <code>float RandomFloat()</code>
| Generate a random floating point number.
|-
| <code>RandomFloat</code>
| <code>float RandomFloat(float ''min'', float ''max'')</code>
| Generate a random floating point number within a range, inclusive
|-
| <code>RandomInt</code>
| <code>int RandomInt()</code>
| Generate a random integer.
|-
| <code>RandomInt</code>
| <code>int RandomInt(int ''min'', int ''max'')</code>
| Generate a random integer within a range, inclusive
|-
|-
| <code>PrintHelp</code>
| <code>RandomHQSetSeed</code>
|
| <code>void RandomHQSetSeed(unsigned int seed)</code>
| {{todo}}
| Set a specific seed value for reproducibility. RandomHQ*() is a set of functions to access C++ Native MT19937 Random Number Generator. MT19937 is very fast and provides very High Quality random numbers. By default, you don't need to call this function, as it will automatically seed the generator to a non-deterministic state upon game initialization.
|-
|-
| <code>RandomFloat</code>
| <code>RandomHQSetRandomDevice</code>
| <code>float RandomFloat()</code>
| <code>void RandomHQSetRandomDevice()</code>
| Generate a random floating point number.
| Reset the generator to a non-deterministic state. By default, you don't need to call this function, as it will automatically seed the generator to a non-deterministic state upon game initialization.
|-
|-
| <code>RandomFloat</code>
| <code>RandomHQUniformIntDistribution</code>
| <code>float RandomFloat(float ''min'', float ''max'')</code>
| <code>int RandomHQUniformIntDistribution(int min, int max)</code>
| Generate a random floating point number within a range, inclusive
| Generate a uniformly distributed random integer in the range [min, max]. If min > max, the values are swapped.
|-
|-
| <code>RandomInt</code>
| <code>RandomHQUniformFloatDistribution</code>
| <code>int RandomInt()</code>
| <code>float RandomHQUniformFloatDistribution(float min, float max)</code>
| Generate a random integer.
| Generate a uniformly distributed random float in the range [min, max]. If min > max, the values are swapped.
|-
|-
| <code>RandomInt</code>
| <code>RandomHQNormalDistribution</code>
| <code>int RandomInt(int ''min'', int ''max'')</code>
| <code>float RandomHQNormalDistribution(float mean, float std_dev)</code>
| Generate a random integer within a range, inclusive
| Generate a normally(Gaussian) distributed random float with the specified mean and standard deviation. If std_dev <= 0.0f, it sets std_dev to 1.0f.
|-
|-
| <code>RetrieveNativeSignature</code>
| <code>RetrieveNativeSignature</code>
Line 2,810: Line 3,492:
* {{portal2}} [[List of Portal 2 Script Functions]]
* {{portal2}} [[List of Portal 2 Script Functions]]
* {{csgo}} [[List of Counter-Strike: Global Offensive Script Functions]]
* {{csgo}} [[List of Counter-Strike: Global Offensive Script Functions]]
* {{tf2}} [[List of TF2 Script Functions]]
* {{tf2}} [[Team Fortress 2/Scripting/Script Functions|List of Team Fortress 2 Script Functions]]


[[Category:Alien Swarm: Reactive Drop]]
[[Category:Alien Swarm: Reactive Drop]]
[[Category:Scripting]]
[[Category:Scripting]]

Latest revision as of 11:20, 24 August 2025

Squirrel This list contains the engine-related Squirrel classes, functions and variables available for VScript in Alien Swarm: Reactive Drop 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.
EntityOutputs CScriptEntityOutputs Allows reading entity output data.
g_ModeScript table Script scope for mode specific vscripts. Only available in Challenges.
InfoNodes CScriptInfoNodes Allows reading info_node data.
MissionChooser CASW_Mission_Chooser_VScript Provides an interface for querying campaigns, missions, and challenges on the server.
Deathmatch CASW_Deathmatch_VScript Allows challenge modes to modify deathmatch scores.
NetProps CNetPropManager Allows reading and updating the network properties of an entity.
ResponseCriteria CScriptResponseCriteria Allows reading the response criteria of an entity.
TempEnts CScriptTempEnts Allows creating Temporary Entities on clients.

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 bool __KeyValueFromInt(string key, int value) Sets an entity Keyvalue from an integer. This simply changes the value without executing any code that may be needed for the entity to process the KeyValue, so there may be unintended side effects.
__KeyValueFromFloat bool __KeyValueFromFloat(string key, float value) Sets an entity Keyvalue from a float. This simply changes the value without executing any code that may be needed for the entity to process the KeyValue, so there may be unintended side effects.
__KeyValueFromString bool __KeyValueFromString(string key, string value) Sets an entity Keyvalue from a string. This simply changes the value without executing any code that may be needed for the entity to process the KeyValue, so there may be unintended side effects.
__KeyValueFromVector bool __KeyValueFromVector(string key, Vector value) Sets an entity Keyvalue from a Vector. This simply changes the value without executing any code that may be needed for the entity to process the KeyValue, so there may be unintended side effects.
Activate void Activate() Activates the spawned entity.
ClearParent void ClearParent() Clears the entity's move parent.
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.
DispatchParticleEffect void DispatchParticleEffect(string name) Spawns a particle effect that follows the origin of this entity.
DispatchParticleEffectLink void DispatchParticleEffectLink(string name, handle otherEntity) Spawns a particle effect that follows the origin of this entity and has another entity's origin as control point 1.
DispatchParticleEffectCP1 void DispatchParticleEffectCP1(string name, Vector cp1) Spawns a particle effect at the origin of this entity with a specific offset for control point 1.
StopParticleEffect void StopParticleEffect(string name) Removes a particle effect from this entity by name.
StopParticleEffects void StopParticleEffects() Removes all particle effects from this entity.
EmitSound void EmitSound(string soundScript) Plays a sound from this entity.
EmitSoundTable void EmitSoundTable(string soundScript, table options) Plays a sound from this entity. Options that can be specified: caption (true or false), channel (one of the CHAN_ constants such as CHAN_AUTO), delay (number), origin (Vector), pitch (one of the PITCH_ constants such as PITCH_NORM or a number from 1 to 255), recipient (a player or character entity handle), soundlevel (one of the SNDLVL_ constants such as SNDLVL_GUNFIRE or a number of decibels - affects distance the sound can be heard from, not volume), volume (number from 0 to 1)
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.
GetLocalAngles Vector GetLocalAngles() Get entity pitch, yaw, roll relative to the parent as a vector.
GetLocalOrigin Vector GetLocalOrigin() Returns the Entity position in the world relative to the parent as a vector.
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 an entity.
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 int PrecacheModel(string modelPath) Precache a model after the map has loaded and return index of the model.
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.
SetLocalAngles void SetLocalAngles(float pitch, float yaw, float roll) Set entity pitch, yaw, roll relative to the parent. Note that it doesn't take a Vector object.
SetLocalOrigin void SetLocalOrigin(Vector position) Moves the entity to this global position vector relative to the parent.
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.
SetParent void SetParent(CBaseEntity entity) Sets an entity as another entity's move parent.
SetSize void SetSize(Vector, Vector) [Todo]
SetTeam void SetTeam(int teamNumber) Instantly switches an entity's team.
SetVelocity void SetVelocity(Vector velocity) Gives the entity a new local velocity.
Spawn void Spawn() Spawns the entity into the game.
StopSound void StopSound(string soundName) Stop sound from entity.
TakeDamage void TakeDamage(float damage, int damageType, CBaseEntity attacker) Damages the entity.
TakeDamageParams void TakeDamageParams(handle inflictor, handle attacker, handle weapon, Vector vecDmgForce, Vector vecDmgPosition, float damage, int dmgType) Damages the entity, with additional parameters.
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
DispatchParticleEffectAttachment void DispatchParticleEffectAttachment(string name, string attachment) Spawn a particle effect that follows an attachment point of this entity.
DispatchParticleEffectAttachmentLink void DispatchParticleEffectAttachmentLink(string name, string attachment, handle otherEntity) Spawns a particle effect that follows an attachment point of this entity and has another entity's origin as control point 1.
GetAttachmentAngles Vector GetAttachmentAngles(int id) Get the attachment ID's angles as a pitch, yaw, roll vector.
GetAttachmentBone int GetAttachmentBone(int id) Gets the bone for an attachment.
GetAttachmentOrigin Vector GetAttachmentOrigin(int id) Get the attachment ID's origin vector.
GetBodygroup int GetBodygroup(int group) Get the bodygroup.
GetBodygroupName string GetBodygroupName(int group) Get the name of the bodygroup.
GetBodygroupPartName string GetBodygroupPartName(int group, int part) Get the part name of the bodygroup.
GetBoneAngles Vector GetBoneAngles(int bone_id) Get the bone id's angles.
GetBoneOrigin Vector GetBoneOrigin(int bone_id) Get the bone id's origin vector.
GetModelScale float GetModelScale() Get scale of entity's model.
GetSequence int GetSequence() Get the active sequence.
GetSequenceActivityName string GetSequenceActivityName(int sequence_id) Get the activity name of the sequence.
GetSequenceDuration float GetSequenceDuration(int sequence_id) Returns the duration in seconds of the passed sequence.
GetSequenceName string GetSequenceName(int sequence_id) Returns the name of the sequence.
IsSequenceFinished bool IsSequenceFinished() Ask whether the main sequence is done playing.
LookupActivity int LookupActivity(string activityName) Get the named activity ID.
LookupAttachment int LookupAttachment(string attachmentName) Get the named attachment ID.
LookupBone int LookupBone(string boneName) Get the named bone ID.
LookupSequence int LookupSequence(string sequenceName) Get the named sequence ID.
ResetSequence void ResetSequence(int sequence_id) Sets the active sequence, resetting the current cycle.
SetBodygroup void SetBodygroup(int groupIndex, int value) Sets the models bodygroup value by index.
Todo: How do you find the index?
SetModelScale void SetModelScale(float scale, float changeDuration) Sets the model's scale with change duration.
SetPoseParameter float SetPoseParameter(string name, float value) Set the specified pose parameter to the specified value.
SetSequence void SetSequence(int sequence_id) Sets the active sequence, keeping the current cycle.
StopAnimation void StopAnimation() Stop the current animation by setting playback rate to 0.0.


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_Player

Extends CBasePlayer

Methods

Function Signature Description
FindPickerEntity CBaseEntity FindPickerEntity() Finds the nearest entity in front of the player.
GetCrosshairTracePos Vector GetCrosshairTracePos() Returns the world location directly beneath the player's crosshair.
GetMarine (Shared) CASW_Marine GetMarine() Returns the marine the player is commanding.
GetNPC (Shared) CBaseEntity GetNPC() Returns entity the player is inhabiting.
SetNPC void SetNPC(handle entity) Sets the player's inhabiting entity.
GetSpectatingNPC (Shared) CBaseEntity GetSpectatingNPC() Returns entity the player is spectating.
SetSpectatingNPC void SetSpectatingNPC(handle entity) Sets the player's spectating entity.
GetViewNPC (Shared) CBaseEntity GetViewNPC() Returns entity the player is spectating, else will return inhabiting entity.
ResurrectMarine CASW_Marine ResurrectMarine(Vector position, bool bEffect) Resurrect the marine.


CBaseCombatCharacter

Extends CBaseAnimating

Methods

Function Signature Description
RemoveAllAmmo void RemoveAllAmmo() Removes all ammo for the character.

CASW_Inhabitable_NPC

Extends CBaseCombatCharacter

Methods

Function Signature Description
IsInhabited bool IsInhabited() Removes true if this character is being controlled by a player.
GetCommander CASW_Player GetCommander() Returns the player who "owns" this character, for example the player who is playing as a marine or who added a marine bot to the lobby.
SetControls void SetControls(int controls) Sets this character to use a specific control scheme. -1 = use asw_controls convar, 0 = first person, 1 = top-down, 2 = third person
SetFogController void SetFogController(entity) Force this character to use a specific env_fog_controller entity.
SetPostProcessController void SetPostProcessController(entity) Force this character to use a specific postprocess_controller entity.
SetColorCorrection void SetColorCorrection(entity) Force this character to use a specific color_correction entity.
SetTonemapController void SetTonemapController(entity) Force this character to use a specific env_tonemap_controller entity.
SetGlow void SetGlow(Vector color, float alpha, bool glowWhenOccluded, bool glowWhenUnoccluded, bool fullBloom) Make this character glow when occluded or when unoccluded. Does not affect cases where the character would glow due to built-in game logic.
ClearOrders void ClearOrders() Clear the alien's orders.
OrderMoveTo void OrderMoveTo(entity orderObject, bool ignoreMarines) Order the alien to chase an entity.
ChaseNearestMarine void ChaseNearestMarine() Order the alien to chase the nearest marine.
Extinguish void Extinguish() Put out a fire.
Ignite void Ignite(float duration) Set a character on fire.
Thaw void Thaw(float amount) Unfreeze this character.
Freeze void Freeze(float amount) Freeze this character.
ElectroStun void ElectroStun(float duration) Electrocute this character.
Wake void Wake() Wake up this character's AI.
Die void Die() Kills this character with damage (shortcut, alternative to using SetHealth followed by TakeDamage).
SetSpawnZombineOnMarineKill void SetSpawnZombineOnMarineKill(bool spawnZombine) Sets this character to spawn a zombie marine if it kills a marine.
SetHealthBarColor void SetHealthBarColor(int r, int g, int b, int a) Sets the health bar color. Cheaper than spawning an asw_health_bar. Set alpha to 0 to disable the health bar.
SetHealthBarScale void SetHealthBarScale(float scale) Sets the health bar scale. Negative scales hide the health bar if the alien's health is full.
SetHealthBarOffset void SetHealthBarOffset(Vector offset) Sets the health bar offset in local space.

CBaseTrigger

Extends CBaseEntity

Entity class for triggers.

Methods

Function Signature Description
Disable void Disable() Disable the trigger
Enable void Enable() Enable the trigger
IsTouching bool IsTouching(handle entity) Checks whether the passed entity is touching the trigger.
GetNumTouching int GetNumTouching() Returns the number of entities currently touching the trigger.
GetTouching handle GetTouching(int index) Returns an entity currently touching the trigger. If index is not from 0 to GetNumTouching() - 1, returns null.

CASW_Marine

Extends CASW_Inhabitable_NPC

Methods

Function Signature Description
AddSlowHeal void AddSlowHeal(int health, float healratescale, handle healer, handle weapon) Heals the marine. Medic and weapon can be null, those are used for stats.
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.
GetInventoryTable void GetInventoryTable(table) Fills the passed table with the marine's inventory.
GetInvTable table GetInvTable() -DEPRECATED- Returns a table of the marine's inventory data.
GetMarineName string GetMarineName() -DEPRECATED- Returns the translated marine name. This changes based on the host's game language.
GetMarineProfile int GetMarineProfile() Returns an integer representing which marine profile is in use. Constants are available: ASW_MARINE_PROFILE_SARGE, ASW_MARINE_PROFILE_WILDCAT, ASW_MARINE_PROFILE_FAITH, etc.
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.
OrderMoveTo void OrderMoveTo(float yaw, Vector position) Order an uninhabited marine to move to this position.
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.
SwitchWeapon bool SwitchWeapon(int slot) Make the marine switch to a weapon.
SetMarineRolls void SetMarineRolls(bool bRolls) Send true to make a marine roll when the player presses the roll button, send false to make a marine jump (Changing asw_marine_rolls ConVar overrides all marines' roll/jump behavior).
SetSpawnZombineOnDeath void SetSpawnZombineOnDeath(bool bSpawn) Makes a zombine spawn when the marine dies.
SetColorCorrection void SetColorCorrection(handle entity) Force this character to use a specific color_correction.
SetFogController void SetFogController(handle entity) Force this character to use a specific env_fog_controller.
SetPostProcessController void SetPostProcessController(handle entity) Force this character to use a specific postprocess_controller.
SetTonemapController void SetTonemapController(handle entity) Force this character to use a specific env_tonemap_controller.

Example of how a script writer might set up the handles, with a table g_fx_t (For SetColorCorrection, SetFogController, SetPostProcessController, SetTonemapController functions usage).

function OnMissionStart()
{	
	InitFXTable();
}

g_fx_t <- {};

function InitFXTable()
{
// color corrections
	local cc_kvs_t = 
	{ 
		// shouldnt be edited
		maxfalloff = -1
		spawnflags = 2
		
		// can be edited
		fadeOutDuration = 0.5
		filename = "scripts/colorcorrection/cc_std_sepia.raw"
	};
	g_fx_t[ "cc_sepia" ] <- SpawnEntityFromTable( "color_correction", cc_kvs_t );
	
	cc_kvs_t[ "filename" ] = "scripts/colorcorrection/infested_green.raw";
	g_fx_t[ "cc_red" ] <- SpawnEntityFromTable( "color_correction", cc_kvs_t );
	
// fog controllers
	local fog_kvs_t =
	{
		// shouldnt be edited
		fogenable = 1
		
		// can be edited
		foglerptime = 0
		fogstart = 500
		fogend = 2000
		fogcolor = "192 70 70"
		fogmaxdensity = 0.4
	};
	g_fx_t[ "fog_red" ] <- SpawnEntityFromTable( "env_fog_controller", fog_kvs_t );
	
	fog_kvs_t[ "fogcolor" ] = "50 255 50";
	fog_kvs_t[ "fogstart" ] = 0;
	g_fx_t[ "fog_green" ] <- SpawnEntityFromTable( "env_fog_controller", fog_kvs_t );

// postprocess controllers
	local pp_kvs_t =
	{
		// can be edited
		fadetime = 0.25
		localcontrastedgestrength = 3
		localcontraststrength = 3
		fadetoblackstrength = 0
		screenblurstrength = 0
		depthblurstrength = 0
		depthblurfocaldistance = 0
	};
	g_fx_t[ "pp_contrast_high" ] <- SpawnEntityFromTable( "postprocess_controller", pp_kvs_t );
	
	pp_kvs_t[ "localcontrastedgestrength" ] = 0;
	pp_kvs_t[ "localcontraststrength" ] = 0;
	pp_kvs_t[ "fadetoblackstrength" ] = 0.5;
	pp_kvs_t[ "screenblurstrength" ] = 0.55;
	pp_kvs_t[ "depthblurstrength" ] = 0.2;
	pp_kvs_t[ "depthblurfocaldistance" ] = 0.9;
	g_fx_t[ "pp_blurry" ] <- SpawnEntityFromTable( "postprocess_controller", pp_kvs_t );

// tonemap controllers a little more tricky, have no keyvalues so we are playing with netprops
	local hTNMP = Entities.CreateByClassname( "env_tonemap_controller" );
	NetProps.SetPropBool( hTNMP, "m_bUseCustomAutoExposureMin", true );
	NetProps.SetPropBool( hTNMP, "m_bUseCustomAutoExposureMax", true );
	NetProps.SetPropBool( hTNMP, "m_bUseCustomManualTonemapRate", true );
	NetProps.SetPropFloat( hTNMP, "m_flCustomManualTonemapRate", 0.0 );
	
	NetProps.SetPropFloat( hTNMP, "m_flCustomAutoExposureMin", 0.0 );
	NetProps.SetPropFloat( hTNMP, "m_flCustomAutoExposureMax", 0.0 );
	g_fx_t[ "tnmp_dark" ] <- hTNMP;
}

Accessing the handles example:

function OnGameEvent_marine_infested( params )
{	
	local hMarine = EntIndexToHScript( params[ "entindex" ] );
	
	hMarine.SetFogController( g_fx_t[ "fog_green" ] );
	hMarine.SetPostProcessController( g_fx_t[ "pp_blurry" ] );
	hMarine.SetTonemapController( g_fx_t[ "tnmp_dark" ] );
}

function OnGameEvent_marine_infested_cured( params )
{
	local hMarine = EntIndexToHScript( params[ "entindex" ] );
	
	hMarine.SetFogController( null );
	hMarine.SetPostProcessController( null );
	hMarine.SetTonemapController( null );
}

CASW_Alien

Extends CASW_Inhabitable_NPC

Methods

Function Signature Description
ChaseNearestMarine void ChaseNearestMarine() Order the alien to chase the nearest marine.
ClearOrders void ClearOrders() Clear the alien's orders.
ElectroStun void ElectroStun(float duration) Stuns the alien.
Extinguish void Extinguish() Extinguish a burning alien.
Freeze void Freeze(float freezeTime) Freezes the 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.
Wake void Wake(bool bFireOutput) Wake up the alien, with option to fire output.
SetSpawnZombineOnMarineKill void SetSpawnZombineOnMarineKill(bool bSpawn) Makes a zombine spawn after killing a marine.


CASW_Parasite

Extends CASW_Alien

Methods

Function Signature Description
JumpAttack void JumpAttack() Jump and attack something.


CASW_Buzzer

Extends CASW_Inhabitable_NPC

Methods

Function Signature Description
ChaseNearestMarine void ChaseNearestMarine() Order the buzzer to chase the nearest marine.
ClearOrders void ClearOrders() Clear the buzzer's orders.
ElectroStun void ElectroStun(float duration) Stuns the buzzer.
Extinguish void Extinguish() Extinguish a burning buzzer.
Freeze void Freeze(float freezeTime) Freezes the 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.
Wake void Wake(bool bFireOutput) Wake up the buzzer, with option to fire output.

CASW_Colonist

Extends CASW_Inhabitable_NPC

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.


CBaseCombatWeapon

Extends CBaseAnimating

Methods

Function Signature Description
Clip1 int Clip1() Get the weapon's current primary clip. Note: also used to get the offhand item's count.
Clip2 int Clip2() Get the weapon's current secondary clip.
GetClips int GetClips() Get the amount of clips for weapon.
GetDefaultClip1 int GetDefaultClip1() Get the weapon's default primary clip. Note: also used to get the offhand item's default count.
GetDefaultClip2 int GetDefaultClip2() Get the weapon's default secondary clip.
GetMaxAmmo1 int GetMaxAmmo1() Get max primary ammo for weapon.
GetMaxAmmo2 int GetMaxAmmo2() Get max secondary ammo for weapon.
GetMaxClip1 int GetMaxClip1() Get max primary clip for weapon. Note: also used to get the offhand item's max count.
GetMaxClip2 int GetMaxClip2() Get max secondary clip for weapon.
GetMaxClips int GetMaxClips() Get max total clips for weapon.
SetClip1 void SetClip1(int amount) Set weapon's primary clip. Note: also used to set the offhand item's count.
SetClip2 void SetClip2(int amount) Set weapon's secondary clip.
SetClips void SetClips(int amount) Set weapon's total clips.


CASW_Sentry_Base

Extends CBaseAnimating

Methods

Function Signature Description
GetAmmo int GetAmmo() Get the sentry's current ammo.
GetMaxAmmo int GetMaxAmmo() Get the sentry's max allowed ammo.
GetSentryTop CASW_Sentry_Top GetSentryTop() Get a handle of the sentry's top.
SetAmmo void SetAmmo() Set the sentry's current ammo.

CASW_Sentry_Top

Extends CBaseAnimating

Methods

Function Signature Description
PreventFiringUntil void PreventFiringUntil(float nextFireTime) Prevents sentry from firing until the time set.

CASW_Weapon_Sentry

Extends CASW_Weapon

Methods

Function Signature Description
GetSentryAmmo int GetSentryAmmo() Returns the amount of ammo for the contained sentry.
SetSentryAmmo void SetSentryAmmo(int nAmmo) Changes the amount of ammo for the contained sentry.


CAI_DynamicLink

Extends CBaseEntity

Methods

Function Signature Description
FindLink CAI_Link FindLink() Returns the node link or null if not found.
GetDestNode CAI_Node GetDestNode() Returns the node on the other end of the link.
GetSrcNode CAI_Node GetSrcNode() Returns the node that 'owns' this link.
IsLinkValid bool IsLinkValid() Returns true if the dynamic link has a corresponding node link.
TurnOff void TurnOff() Disables node link connections.
TurnOn void TurnOn() Enables node link connections.


CAI_Link

This is a script handle class for node links.

Methods

Function Signature Description
GetAcceptedMoveTypes int GetAcceptedMoveTypes(int hullType) Get the Capability_T of motions acceptable for passed hull type.
GetDangerCount int GetDangerCount() Returns how many dangerous things are near this link.
GetDestNodeID int GetDestNodeID() Get the ID of the node on the other end of the link.
GetDynamicLink CAI_DynamicLink GetDynamicLink() Returns the info_node_link entity for this link or null if it doesn't exist.
GetLinkInfo int GetLinkInfo() Get other information about this link.
GetSrcNodeID int GetSrcNodeID() Get the ID of the node that 'owns' this link.
GetTimeStaleExpires float GetTimeStaleExpires() Returns the amount of time until this link is available again.
SetAcceptedMoveTypes void SetAcceptedMoveTypes(int hullType, int moveType) Set the Capability_T of motions acceptable for passed hull type.
SetDangerCount void SetDangerCount(int count) Sets how many dangerous things are near this link.
SetLinkInfo void SetLinkInfo(int info) Sets information about this link.
SetTimeStaleExpires void SetTimeStaleExpires(float duration) Sets the amount of time until this link is available again.


CAI_Node

This is a script handle class for nodes.

Methods

Function Signature Description
AddLink void AddLink(CAI_Link link) Adds a link to this node.
ClearLinks void ClearLinks() Clears all links from node.
DebugDrawNode void DebugDrawNode(int r, int g, int b, float duration) Draw node as a box of the given color for x seconds.
GetId int GetId() Get node ID.
GetInfo int GetInfo() Get node info.
GetLink CAI_Link GetLink(int nodeID) Get link to dest node ID.
GetLinkByIndex CAI_Link GetLinkByIndex(int index) Get link by index.
GetOrigin Vector GetOrigin() Get node origin.
GetPosition Vector GetPosition(int hullType) Get hull specific position for a node.
GetType int GetType() Get node type.
GetYaw float GetYaw() Get node Yaw.
GetZone int GetZone() Get node zone.
IsLocked bool IsLocked() Returns true if node is locked.
Lock void Lock(float duration) Locks the node for x seconds.
NumLinks int NumLinks() Number of links for node.
RemoveLink void RemoveLink(CAI_Link link) Removes a link from this node.
SetInfo void SetInfo(int info) Set node info.
SetType void SetType(int type) Set node type.
SetZone void SetZone(int zone) Set node zone.
Unlock void Unlock() Unlocks the node.


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.


CASW_Grenade_Cluster

Extends CBaseCombatCharacter

Methods

Function Signature Description
Disable void Disable() Disable the grenade.
Enable void Enable() Enable the grenade, different time setting like explosion time correctly adjusted after disable state.
EnableWithReset void EnableWithReset() Enable the grenade, different time setting like explosion time reset like grenade is newly created.
ReflectBack void ReflectBack() Reflect grenade preciselly to firer marine position if marine is alive, ReflectBackSimple used otherwise.
ReflectBackSimple void ReflectBackSimple() Reflect grenade near to initial fire position.
ReflectRandomly void ReflectRandomly() Reflect grenade to random porition.

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]


CDirector

Game Instance: Director

Provides methods for reading information and forcing events in the AI Director.

Methods

Function Signature Description
FindHordePosition Vector FindHordePosition(bool north) Get a random position where a horde can spawn (returns null on fail).
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.
GetTimeToNextHorde float GetTimeToNextHorde() Get the current number of seconds until the director will try to spawn a horde.
IsOfflineGame bool IsOfflineGame() Return true if game is in single player.
IsSpawningHorde int IsSpawningHorde() Get the number of aliens remaining to spawn in the current horde.
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.
SetTimeToNextHorde void SetTimeToNextHorde(float seconds) Force the horde countdown timer to be set to this number of seconds.
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.
SpawnHordeSoon void SpawnHordeSoon() Queue a horde to spawn soon (the same logic as when a hack starts).
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.
ValidSpawnPoint bool ValidSpawnPoint(Vector position, Vector mins, Vector maxs) Return true if the position is a valid spawn point.
GetMinNPCClassIndex int GetMinNPCClassIndex() Returns the minimum NPC class index. Class indexes that are negative cannot be used in spawners. -1 is reserved for "no class".
GetMaxNPCClassIndex int GetMaxNPCClassIndex() Returns the maximum NPC class index.
GetNPCClassName string GetNPCClassName(int index) Returns the NPC classname associated with a given index.
GetNPCClassIndex int GetNPCClassIndex(string classname) Returns the NPC class index associated with a given classname, or -1 if there is none.
GetNPCHordeSound string GetNPCHordeSound(int index) Returns the horde sound name for a given NPC class index. This can be used to roughly categorize enemies into factions.
GetNPCHullType int GetNPCHullType(int index) Returns the hull type (for example, HULL_MEDIUMBIG) of an NPC class.
GetNPCMins Vector GetNPCMins(int index) Returns the component-wise minimum coordinate on the given NPC class's hull. (For hull traces)
GetNPCMaxs Vector GetNPCMaxs(int index) Returns the component-wise maximum coordinate on the given NPC class's hull. (For hull traces)

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").

Warning.pngWarning:Each netprop has a set size in bits, exceeding the size may desync the clients from the server causing unpredictable behavior.

Methods

Function Signature Description
GetPropArraySize int GetPropArraySize(CBaseEntity entity, string propertyName) Returns the size of an netprop array, or -1.
GetPropBool bool GetPropBool(CBaseEntity entity, string propertyName) Reads a boolean valued netprop.
GetPropBoolArray bool GetPropBoolArray(CBaseEntity entity, string propertyName, int arrayElement) Reads a boolean valued netprop from an array.
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.
GetPropInfo void GetPropInfo(CBaseEntity entity, string propertyName, int arrayElement, table) Fills in a passed table with property info for the provided entity.
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.
GetTable void GetTable(CBaseEntity entity, int propType, table) Fills in a passed table with all props of a specified type for the provided entity (set propType to 0 for SendTable or 1 for DataMap).
HasProp bool HasProp(CBaseEntity entity, string propertyName) Checks if a netprop exists.
SetPropBool void SetPropBool(CBaseEntity entity, string propertyName, bool value) Sets a netprop to the specified boolean.
SetPropBoolArray void SetPropBoolArray(CBaseEntity entity, string propertyName, bool value, int arrayElement) Sets a netprop from an array to the specified boolean.
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.

CScriptInfoNodes

Game Instance: InfoNodes

Allows reading info_node data.

Methods

Function Signature Description
CreateLink CAI_Link CreateLink(int srcID, int destID) Creates a new link from srcID to destID and returns the link.
GetAllNearestNodes int GetAllNearestNodes(CBaseEntity npc, Vector position, int maxNodes, table) Fills a passed in table of x nearest nodes to origin with optional npc parameter, and returns number of nodes found.
GetAllNodes void GetAllNodes(table) Fills a passed in table of all nodes.
GetNearestNodeToPoint CAI_Node GetNearestNodeToPoint(CBaseEntity npc, Vector position) Returns the node nearest to origin with optional npc parameter.
GetNumNodes int GetNumNodes() Returns the amount of info_nodes in the network array.
GetNodeOrigin Vector GetNodeOrigin(int nodeID) Returns the origin of the node.
GetNodePosition Vector GetNodePosition(int nodeID, int hull) Returns the hull specific origin of the node.
GetNodeType int GetNodeType(int nodeID) Returns the type of node.

Example of spawning stuff at random info_node origins.

for( local i = 0; i < 5; i++ )
{
	local node_id = RandomInt( 0, InfoNodes.GetNumNodes() - 1 );
	local node_type = InfoNodes.GetNodeType( node_id );
	
	if ( node_type != NODE_GROUND )
		continue;
	
	local ammo = Entities.CreateByClassname( "asw_ammo_drop" );
	ammo.SetOrigin( InfoNodes.GetNodeOrigin( node_id ) );
	ammo.SetName( "info_node_ammospawn_" + i );
	ammo.Spawn();
	
	//Director.SpawnAlienAt( "asw_shieldbug", InfoNodes.GetNodePosition( node_id, HULL_WIDE_SHORT ), Vector( 0, 0, 0 ) );
}

CScriptEntityOutputs

Game Instance: EntityOutputs

Allows reading entity output data.

Methods

Function Signature Description
AddOutput void AddOutput(handle entity, string outputName, string targetName, string inputName, string parameter, float delay, int timesToFire) Adds a new output to the entity.
GetNumElements int GetNumElements(handle entity, string outputName) Returns the number of array elements.
GetOutputTable void GetOutputTable(handle entity, string outputName, table, int arrayElement) Returns a table of output information.
GetValue variable GetValue(handle entity, string outputName) Returns the value of the output if it has one. (can be used to read math_counter OutValue)
HasAction bool HasAction(handle entity, string outputName) Returns true if an action exists for the output.
HasOutput bool HasOutput(handle entity, string outputName) Returns true if the output exists.
RemoveOutput void RemoveOutput(handle entity, string outputName, string targetName, string inputName, string parameter) Removes an output from the entity.

Example of looping through entity outputs.

ent <- null;
while( ent = Entities.FindByClassname(ent, "trigger_once") )
{
	if ( EntityOutputs.HasAction( ent, "OnTrigger" ) )
	{
		local numElements = EntityOutputs.GetNumElements( ent, "OnTrigger" );
		for ( local i = 0; i < numElements; i++ )
		{
			local tbl = {};
			EntityOutputs.GetOutputTable( ent, "OnTrigger", tbl, i );
			DeepPrintTable( tbl );
		}
	}
}

CScriptTempEnts

Game Instance: TempEnts

Allows creating Temporary Entities on clients.

Methods

Function Signature Description
Create void Create(handle player, string name, float delay, table) Queue a temp entity for transmission on a client from a passed table of SendProp data. Passing null for a player will playback Temp Entity on all clients.
GetNames void GetNames(string name, table) Fills in a passed table with the names of all temp entities
GetPropTypes void GetPropTypes(table) Fills in a passed table with all SendProps and their types for the temp entity.

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(int entindex, string name) 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 void GetTable(CBaseEntity entity, table) 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.


CASW_Mission_Chooser_VScript

Game Instance: MissionChooser

Provides an interface for querying campaigns, missions, and challenges on the server.

Methods

Function Signature Description
CountCampaigns int CountCampaigns() Returns the number of installed campaigns.
CountChallenges int CountChallenges() Returns the number of installed challenges.
CountMissions int CountMissions() Returns the number of installed missions.
GetCampaign table GetCampaign(int index) Creates a table containing campaign data for a campaign by index.
GetCampaignByName table GetCampaignByName(string name) Creates a table containing campaign data for a campaign by name.
GetChallenge table GetChallenge(int index) Creates a table containing challenge data for a challenge by index.
GetChallengeByName table GetChallengeByName(string name) Creates a table containing challenge data for a challenge by name.
GetCurrentCampaign table GetCurrentCampaign() Creates a table containing campaign data for the current campaign.
GetCurrentChallenge table GetCurrentChallenge() Creates a table containing challenge data for the current challenge.
GetCurrentMission table GetCurrentMission() Creates a table containing mission overview data for the current mission.
GetMission table GetMission(int index) Creates a table containing mission overview data for a mission by index.
GetMissionByName table GetMissionByName(string name) Creates a table containing mission overview data for a mission by name.


CASW_Deathmatch_VScript

Game Instance: Deathmatch

Allows challenge modes to modify deathmatch scores.

Methods

Function Signature Description
ResetScores void ResetScores() Clears all scores.
GetKills int GetKills(handle marineOrResource) Returns a marine's kill count.
SetKills void SetKills(handle marineOrResource, int kills) Overrides a marine's kill count.
GetDeaths int GetKills(handle marineOrResource) Returns a marine's death count.
SetDeaths void SetDeaths(handle marineOrResource, int deaths) Overrides a marine's death count.
GetTeamScore int GetKills(int teamNumber) Returns a team's score. Team numbers are TEAM_ALPHA (2) for the yellow team and TEAM_BETA (3) for the blue team.
SetTeamScore void SetTeamScore(int teamNumber, int score) Overrides a team's score. Team numbers are TEAM_ALPHA (2) for the yellow team and TEAM_BETA (3) for the blue team.
CheckFragLimit bool CheckFragLimit(handle marineOrResource) Checks if a player or their team should win the match. Call this after modifying a team's score or a marine's kill count.
ResetKillingSpree void ResetKillingSpree(handle marineOrResource) Reset a marine's killing spree counter.
IncreaseKillingSpree void IncreaseKillingSpree(handle marineOrResource) Record a kill for a marine's killing spree counter.
GetKillingSpree int GetKillingSpree(handle marineOrResource) Get a marine's current killing spree counter. This is always 0 if rd_quake_sounds is 0.


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.


CRD_HUD_VScript

Classname of the entity: rd_hud_vscript.

Methods

Function Signature Description
LookupTexture (Client) int LookupTexture(string filename) Loads a vmt file for use in Paint. Should not be called while the Paint function is running. Instead, store the texture number and reuse it.
LookupFont (Client) int LookupFont(string name) Gets the ID of a font defined in SwarmSchemeNew.res. Examples of font names include Default, DefaultExtraLarge, DefaultVerySmall, DefaultBlur. Should not be called while the Paint function is running. Instead, store the font ID and reuse it.
GetFontTall (Client) int GetFontTall(int font) Returns the height in pixels of a font. Fast and safe to call from anywhere.
GetTextWide (Client) int GetTextWide(int font, string text) Returns the width in pixels of a string in a given font. Fast and safe to call from anywhere.
PaintText (Client) void PaintText(int x, int y, int r, int g, int b, int a, int font, string text) Draws a string to the screen in a given color and font, with the top-left corner x pixels from the left edge of the screen and y pixels from the top of the screen. Can only be called during Paint.
PaintRectangle (Client) void PaintRectangle(int x0, int y0, int x1, int y1, int r, int g, int b, int a) Draws a solid-color rectangle to the screen. Can only be called during Paint.
PaintRectangleFade (Client) void PaintRectangleFade(int x0, int y0, int x1, int y1, int r, int g, int b, int a0, int a1, int fadeStart, int fadeEnd, bool horizontal) Draws a solid-color rectangle with a gradient alpha channel. Can only be called during paint.
PaintTexturedRectangle (Client) void PaintTexturedRectangle(int x0, int y0, int x1, int y1, int r, int g, int b, int a, int texture) Draws a textured rectangle to the screen, multiplied by a color. Can only be called during paint.
PaintTexturedRectangleAdvanced (Client) void PaintTexturedRectangleAdvanced({int x0, int y0, int x1, int y1, int r, int g, int b, int a0, int a1, int a2, int a3, float s0, float t0, float s1, float t1, float angle, int texture}) Takes a table and draws a rectangle to the screen. You can leave out fields from the table if you don't need them. Can only be called during paint.
PaintPolygon (Client) void PaintPolygon([{float x, float y, float s, float t}, ...], int r, int g, int b, int a, int texture) Draws an arbitrary convex polygon made up of at least three vertices defined by x,y (position) and s,t (texture) coordinates.
GetEntity (Shared) handle GetEntity(int index) Returns an entity stored in the data. Index must be 0.
GetInt (Shared) int GetInt(int index) Returns an integer stored in the data. Index can be from 0 to 63.
GetFloat (Shared) float GetFloat(int index) Returns a float stored in the data. Index can be from 0 to 31.
GetString (Shared) string GetString(int index) Returns a string stored in the data. Index must be 0.
SetEntity (Server) void SetEntity(int index, handle entity) Stores an entity handle in the data. Index must be 0.
SetInt (Server) void SetInt(int index, int value) Stores an integer in the data. Index can be from 0 to 63.
SetFloat (Server) void SetFloat(int index, float value) Stores a float in the data. Index can be from 0 to 31.
SetString (Server) void SetString(int index, string text) Stores a string of up to 255 bytes in the data. Index must be 0.

Set up the entity:

local hHud = Entities.CreateByClassname( "rd_hud_vscript" );
hHud.__KeyValueFromString( "client_vscript", "your_nut_file.nut" );
hHud.Spawn();
hHud.Activate();

The client script should define two functions: OnUpdate and Paint.

OnUpdate is called on every client whenever the server changes the entity data, including immediately after the entity spawns on the client.

Paint is called on every client on every frame while the HUD is being drawn.

This entity can hold up to 64 integers, 32 floats, 1 string and 1 entity of data.

An example below on how to display marine's kill count when they kill an alien, for 2 seconds.

Your challenge's .nut file:

function OnGameplayStart()
{
	local hMarine = null;
	while ( hMarine = Entities.FindByClassname( hMarine, "asw_marine" ) )
	{
		local hHud = Entities.CreateByClassname( "rd_hud_vscript" );
		hHud.__KeyValueFromString( "client_vscript", "your_nut_file.nut" );
		hHud.Spawn();
		hHud.Activate();
		hHud.SetEntity( 0, hMarine );
		hHud.SetName( hMarine.GetName() + "_hud" );
		
		hMarine.ValidateScriptScope();
		hMarine.GetScriptScope().nKillCount <- 0;
	}
}

function OnGameEvent_alien_died( params )
{
	if ( !( "marine" in params ) )
		return;
	
	local hMarine = EntIndexToHScript( params["marine"] );
	if ( !hMarine || !hMarine.IsValid() )
		return;
		
	hMarine.GetScriptScope().nKillCount += 1;
		
	local hHud = Entities.FindByName( null, hMarine.GetName() + "_hud" );
	hHud.SetInt( 0, hMarine.GetScriptScope().nKillCount );
	hHud.SetFloat( 0, Time() );
}

Client script file for hud, in this case your_nut_file.nut:

/*
	float 0 - time when last kill was performed

	int 0 - kill count
	
	entity 0 - marine
*/

FONT_DEFAULTLARGE <- self.LookupFont( "DefaultLarge" );

function Paint()
{
	// if we are not playing or not spectating this marine, dont show his kill count
	if ( self.GetEntity(0) != GetLocalPlayer().GetViewNPC() )
		return;
		
	// if more than 2 seconds have passed since last kill, dont show the kill count
	if ( Time() - self.GetFloat(0) > 2.0 )
		return;
		
	self.PaintText( ScreenPosX( 0.5 ), ScreenPosY( 0.2 ), 200, 200, 200, 200, FONT_DEFAULTLARGE, self.GetInt(0).tostring() );
}

// pass in a value from 0.0 to 1.0, 0.0 means the left side of the screen, 1.0 means the right, 0.5 in the middle
function ScreenPosX( fFraction )
{
	return ScreenWidth() * fFraction;
}

// pass in a value from 0.0 to 1.0, 0.0 means the up side of the screen, 1.0 means the down, 0.5 in the middle
function ScreenPosY( fFraction )
{
	return ScreenHeight() * fFraction;
}

Some fonts (use LookupFont to get their IDs as they can change with game updates or Workshop mods):

  • DefaultVerySmall
  • DefaultVerySmallBlur
  • DefaultSmall
  • DefaultSmallBlur
  • DefaultSmallOutline
  • Default
  • DefaultBlur
  • DefaultShadowed
  • DefaultUnderline
  • DefaultMedium
  • DefaultMediumBlur
  • DefaultLarge
  • DefaultLargeBlur
  • DefaultBold
  • DefaultBoldBlur
  • DefaultExtraLarge
  • DefaultExtraLargeBlur
  • Countdown
  • CountdownBlur

CRD_VGui_VScript

Classname of the entity: rd_vgui_vscript. Supports all methods that rd_hud_vscript does, plus:
Note: The client uses a prediction system to anticipate server responses and provide a smoother user experience. Therefore, the client side functions will not sync with server side variables automatically when you call Set***() functions from serverside. You can use the ForceSync() function to trigger a force sync with server side variables after you have called the Set***() functions from.

Methods

Function Signature Description
GetEntity (Server)
GetInt (Server)
GetFloat (Server)
GetString (Server)
SetEntity (Server)
SetInt (Server)
SetFloat (Server)
SetString (Server)
handle GetEntity(int index)
int GetInt(int index)
float GetFloat(int index)
string GetString(int index)
handle SetEntity(int index)
int SetInt(int index)
float SetFloat(int index)
string SetString(int index)
These functions allow you to get and set values from server side. Be aware that the corresponding values being manipulated in these server functions are stored in the server side variables.
CRD_VGui_VScript.m_hDataEntity
CRD_VGui_VScript.m_szDataInt
CRD_VGui_VScript.m_szDataFloat
CRD_VGui_VScript.m_szDataString
Therefore, each time you call these functions, the values will sync with the client side corresponding variables:
CRD_VGui_VScript.m_hDataEntity
CRD_VGui_VScript.m_szDataInt
CRD_VGui_VScript.m_szDataFloat
CRD_VGui_VScript.m_szDataString
GetEntity (Client)
GetInt (Client)
GetFloat (Client)
GetString (Client)
SetInt (Client)
SetFloat (Client)
SetString (Client)
handle GetEntity(int index)
int GetInt(int index)
float GetFloat(int index)
string GetString(int index)
int SetInt(int index)
float SetFloat(int index)
string SetString(int index)
These functions allow you to get and set values from client side. Be aware that the corresponding values being manipulated in these client functions are stored in the client side variables.
CRD_VGui_VScript.m_hPredictedEntity
CRD_VGui_VScript.m_szPredictedInt
CRD_VGui_VScript.m_szPredictedFloat
CRD_VGui_VScript.m_szPredictedString
Therefore, each time you call these functions, the values will not sync with the server side corresponding variables automatically, since data from server are stored in different variables. If you want a force sync, you can call the ForceSync() function, this function will discard all client predictions and force syncing with server.
ForceSync (Client) void ForceSync() This function simply calls an internal client side function:
void CRD_VGui_VScript::ResetPrediction()
{
m_hPredictedEntity = m_hDataEntity;
V_memcpy( &m_szPredictedString, &m_szDataString, sizeof( m_szPredictedString ) );
V_memcpy( &m_flPredictedFloat, &m_flDataFloat, sizeof( m_flPredictedFloat ) );
V_memcpy( &m_iPredictedInt, &m_iDataInt, sizeof( m_iPredictedInt ) );
//Other stuff...
}

Call this function after you have changed some variables from server side and then you can use Get****() to retrive the latest values.
SendInput (Client) void SendInput(int value) Sends an input to the server. Inputs can be integers between ±16,777,215; larger values may result in floating point precision loss. Inputs will arrive on the server in order. Can only be called during the Control function.
CreateButton (Client) CRD_VGui_VScript_Button CreateButton() Creates a button that can be targeted by both mice and controllers. Do not create new buttons every frame; buttons exist for the lifetime of the rd_vgui_vscript entity. Instead, move or enable/disable buttons as needed.
GetInteracter (Shared) CASW_Inhabitable_NPC GetInteracter() Returns the character (usually marine) that is allowed to interact with this screen.
SetInteracter (Server) void SetInteracter(CASW_Inhabitable_NPC interacter) Sets which character (usually marine) is allowed to interact with this screen.

In addition to the callback functions for rd_hud_vscript, rd_vgui_vscript has the following callback functions:

Control(table) (Client)

The table contains:

  • bool mouse (is the player using the mouse to aim? otherwise controller)
  • bool keyboard (is the player using the keyboard to act/move? otherwise controller)
  • int button (the button code that was pressed)
  • bool mouse_left, mouse_right, key_left, key_right, key_up, key_down, key_space, key_enter, controller_left, controller_right, controller_up, controller_down, controller_a, controller_b (whether each button is held)
  • int mouse_x, mouse_y (mouse position on screen)
  • float move_x, move_y, look_x, look_y (controller stick positions)
  • CRD_VGui_VScript_Button focus (currently focused button on controller)

Input(integer) (Shared)

Called on both the client and the server when the client calls self.SendInput. The client can call SetInt, SetFloat, SetString, and SetEntity during this callback. Should only change data stored in the slots of the rd_vgui_vscript entity on the client as this function will be called repeatedly and only those values will be rolled back for prediction. When called on the client, it is followed by a call to the Update callback.

CRD_VGui_VScript_Button

Methods

Function Signature Description
GetX int GetX() Returns the x coordinate of the left edge of the button, previously set by SetX, SetPos, or SetBounds.
GetY int GetY() Returns the y coordinate of the top edge of the button, previously set by SetY, SetPos, or SetBounds.
GetWide int GetWide() Returns the width of the button, previously set by SetWide, SetSize, or SetBounds.
GetTall int GetTall() Returns the height of the button, previously set by SetTall, SetSize, or SetBounds.
SetX void SetX(int x) Moves the button.
SetY void SetY(int y) Moves the button.
SetWide void SetWide(int wide) Resizes the button.
SetTall void SetTall(int tall) Resizes the button.
SetPos void SetPos(int x, int y) Shortcut for calling SetX and SetY.
SetSize void SetSize(int wide, int tall) Shortcut for calling SetWide and SetTall.
SetBounds void SetBounds(int x, int y, int wide, int tall) Shortcut for calling SetPos and SetSize.
SetEnabled void SetEnabled(bool enabled) Enables or disables the button. Disabled buttons cannot be focused by the controller and do not run callbacks.
SetOnClicked void SetOnClicked(function() callback) Sets a function to be called when the button is clicked with the mouse or activated with the controller. This callback counts as part of the Control function, meaning you can call self.SendInput during the callback.
SetOnCursorMoved void SetOnCursorMoved(function(int x, int y) callback) Sets a function to be called when the mouse is moved over the button. This callback counts as part of the Control function, meaning you can call self.SendInput during the callback.
SetOnCursorEntered void SetOnCursorEntered(function() callback) Sets a function to be called when the mouse is moved onto the button. This callback counts as part of the Control function, meaning you can call self.SendInput during the callback.
SetOnCursorExited void SetOnCursorExited(function() callback) Sets a function to be called when the mouse is moved off of the button. This callback counts as part of the Control function, meaning you can call self.SendInput during the callback.
SetOnMousePressed void SetOnMousePressed(function(bool right) callback) Sets a function to be called when a mouse button is pressed over the button. This callback counts as part of the Control function, meaning you can call self.SendInput during the callback.
SetOnMouseReleased void SetOnMouseReleased(function(bool right) callback) Sets a function to be called when a mouse button is released over the button. This callback counts as part of the Control function, meaning you can call self.SendInput during the callback.

CRD_Computer_VScript

Classname of the entity: rd_computer_vscript. Supports all methods that rd_vgui_vscript does, plus:

Methods

Function Signature Description
HackCompleted (Server) void HackCompleted() Call this function to complete the hack. No effect if this entity is not being used as the hack.
SetFastHackEndTime (Server) void SetFastHackEndTime(float time) Sets the deadline for the fast hack. In order for the fast hack to award stat progress and play the failed sound, the computer area must be set to have at least 6 tumblers. The hack must have been initialized, so the earliest this can be called is in the first call to OnOpened.
GetFastHackEndTime (Shared) float GetFastHackEndTime() Returns the deadline for the fast hack. The current time can be determined by calling Time().
GetHackStartTime (Shared) float GetHackStartTime() Returns the value of Time() when the hack started.
Back (Shared) void Back() Closes the screen, returning to the menu or exiting the computer.
SetHackProgress (Shared) void SetHackProgress(float progress) Sets the hack progress between 0 (just started) and 1 (ready to call HackCompleted). Can only be called during the Input callback.

In addition to the callback functions for rd_vgui_vscript, rd_computer_vscript has OnOpened and OnClosed callback functions on both the client and the server. The screen resolution is YRes(416) by YRes(312) rather than the usual XRes(640) by YRes(480).

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.


CCallChainer

CCallChainer objects collect all functions with a matching prefix in a given scope, then inserts it all into the chains table with the prefix removed. All collected unprefixed functions can then be called in a chain using the class's Call() method, given the method's event argument matches the functions' name.

Whenever a CCallChainer object is created, a function named Dispatch followed by its given prefix will also be created, which the class binds the environment of its Call() method to.

Methods

Function Signature Description
constructor CCallChainer(string functionPrefix, table scope = null) Creates a CCallChainer object that'll collect functions that have a matching prefix in the given scope.
PostScriptExecute void PostScriptExecute() Search for all non-native functions with matching prefixes, then push them into the chains table.
Call bool Call(string event, any ...) Find an unprefixed function name in the chains table and call it with the given arguments.

Members

Instance Type Description
chains table Contains names of unprefixed functions, each with an array of functions to call.
prefix string Prefix that functions should have to be added into the chains table. Set by the constructor.
scope table If set, seek functions in this scope instead. Set by the constructor.


CSimpleCallChainer

Intended to be simpler to use than CCallChainer, the class CSimpleCallChainer holds only a single chain of functions inside an array instead of multiple inside a table. As such, its Call() method does not need a function's name.

This class is also used internally by these CBaseEntity hooks: Precache() and OnPostSpawn().

Methods

Function Signature Description
constructor CSimpleCallChainer(string functionPrefix, table scope = null, exactMatch = false) Creates a CSimpleCallChainer object that'll collect functions that have a matching prefix in the given scope, unless it seek for an exact name match.
PostScriptExecute void PostScriptExecute() Begin searching for all non-native functions with matching prefixes, then push them into the chain array.
Call bool Call(any ...) Call all functions inside the chain array with the given arguments.

Members

Instance Type Description
chain array All functions to be called by the Call() method.
exactMatch bool If set, names of non-native functions and prefix must be an exact match. Set by the constructor.
prefix string Prefix that functions should have to be added into the chain array. Set by the constructor.
scope table If set, seek functions in this scope instead. Set by the constructor.


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.

Note.pngNote:Example declaration and manipulation of Vector

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).


AlterDeathMessage

string AlterDeathMessage(CBaseEntity victim, CBaseEntity inflictor, CBaseEntity attacker, CBaseEntity weapon, float damage, int damageType, string ammoName):

Called when a chat death message is about to be printed. Return a string which will be printed instead, %s1 in the string being the victim's display name (optional to have it). No return value or non-string return value results in default death message.

Example:

function AlterDeathMessage( victim, inflictor, attacker, weapon, damage, damageType, ammoName )
{
	if ( attacker.IsAlien() )
		return "%s1 was killed by an alien!";
		
	if ( damageType & 64 )
		return "%s1 was killed by an explosion!";
}

UserConsoleCommand

void UserConsoleCommand(handle playerScript, arg): when a user does a <scripted_user_func argument> at console (or bound to a key) this function is called (if it exists). The playerscript is which players console it came from. You can pass strings or whatever, of course. So could do a switch statement off <arg> to give players special controls, etc.


OnGameEvent_x

void OnGameEvent_x(table params): A callback that is called when the game event x is fired. See scripts\gameevents.res and scripts\modeevents.res for valid events. The list of game events a script can listen for is available in the game's source code.


OnMissionStart

void OnMissionStart(): A callback that is called when MissionStart occurs.


OnGameplayStart

void OnGameplayStart(): A callback that is called when all marines have spawned and players start to play.


Update

void Update(): Update gets called much like a Think() function. If you return a float value the function will get called again in x seconds.


OnReceivedTextMessage

string OnReceivedTextMessage(CBaseEntity recipient, CBaseEntity sender, string message): Called when a player sends a text message into chat.

Sent message will be replaced by the returned string. If the return type is not a string, message is not sent. Note, the message parameter contains an end of line character. If you want to get rid of it, do message = message.slice( 0, message.len() - 1 )

Global functions

Printing and Drawing

Function Signature Description
ClientPrint void ClientPrint(CBasePlayer player, int destination, string message, ...) Print a client message. If you pass null instead of a valid player, the message will be sent to all clients. destination should be HUD_PRINTNOTIFY, HUD_PRINTCONSOLE, HUD_PRINTTALK, HUD_PRINTCENTER, or ASW_HUD_PRINTTALKANDCONSOLE. message will be looked up as a translation string and can contain %s1 through %s4 to reference extra string arguments passed after message.
TextColor string TextColor(int r, int g, int b) Returns a string which is reinterpreted into a color internally in the ClientPrint message string. Turns all the characters that come after the returned string into respective RGB color.
TextColorBlend string TextColorBlend(int r1, int g1, int b1, int r2, int g2, int b2) Returns a string which is reinterpreted into a color blend internally in the ClientPrint message string. Turns all the characters that come after the returned string into respective RGB color blend.
TextColorBlendInvert string TextColorBlendInvert(int r, int g, int b) Returns a string which is reinterpreted into a inverted color blend internally in the ClientPrint message string. Turns all the characters that come after the returned string into respective inverted RGB color blend.
TextColorBlend3 string TextColorBlend3(int r1, int g1, int b1, int r2, int g2, int b2, int r3, int g3, int b3) Returns a string which is reinterpreted into a triple color blend internally in the ClientPrint message string. Turns all the characters that come after the returned string into respective triple RGB color blend.
TextColorBlendCycle string TextColorBlendCycle(int transition_length, int r1, int g1, int b1, int r2, int g2, int b2) Returns a string which is reinterpreted into a color blend cycle internally in the ClientPrint message string. Turns all the characters that come after the returned string into respective RGB color blend cycle.
TextColorBlendSmoothCycle string TextColorBlendSmoothCycle(int transition_length, int r1, int g1, int b1, int r2, int g2, int b2) Returns a string which is reinterpreted into a smooth color blend cycle internally in the ClientPrint message string. Turns all the characters that come after the returned string into respective smooth RGB color blend cycle.
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.
ScreenHeight (Client) int ScreenHeight() Returns the height of the screen in pixels.
ScreenWidth (Client) int ScreenWidth() Returns the width of the screen in pixels.
ShowMessage void ShowMessage(string) Print a hud message on all clients.
Icon-Bug.pngBug:Non-functional  [todo tested in ?]
TryLocalize (Client) string TryLocalize(string text) If text is a valid translation key starting with #, returns the translated string. Otherwise, returns text as-is.
XRes (Client) float XRes(float x) Scales an X coordinate based on a 640 pixel wide screen.
YRes (Client) float YRes(float y) Scales a Y coordinate based on a 480 pixel tall screen.
__DumpScope void __DumpScope(int indentation, handle scope) Dumps contents of everything in the scope.

Other

Function Signature Description
AddThinkToEnt void AddThinkToEnt(handle entity, string funcName) Adds a late bound think function to the C++ think tables for the obj.
Assert void Assert(bool value, string optional message) Test value and if not true, throws exception, optionally with message.
ChangeLevel void ChangeLevel(string mapname) Tell engine to change level.
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.
Icon-Bug.pngBug:Does not initialize the physics of the prop.
CreateSceneEntity CSceneEntity CreateSceneEntity(string scene) Create a scene entity to play the specified scene .vcd file.
DisptchParticleEffect void DispatchParticleEffect(string name, Vector origin, Vector angles) Spawns a particle effect in the world.
DisptchParticleEffectCP1 void DispatchParticleEffectCP1(string name, Vector origin, Vector angles, Vector cp1) Spawns a particle effect in the world with a specific offset for control point 1.
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.
DropFragGrenade handle DropFragGrenade(float damage, float grenadeRadius, Vector origin) Drops a frag grenade.
DropFreezeGrenade handle DropFreezeGrenade(float damage, float freezeAmount, float grenadeRadius, Vector origin) Drops a freeze grenade.
DropGasGrenade handle DropGasGrenade(float damage, float dmgInterval, float duration, float fuse, Vector origin) Drops a gas grenade. // new edit default: damge = 20 , damage per seconds = 0.3, duration = 30, fuse = 1 # radius being fix to 100 using covar asw_gas_grenade_cloud_width
DropIncendiaryGrenade handle DropIncendiaryGrenade(float damage, float grenadeRadius, Vector origin) Drops an incendiary grenade.
DropStunGrenade handle DropStunGrenade(float damage, float grenadeRadius, Vector origin) Drops a stun 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.
FadeClientVolume void FadeClientVolume(handle player, float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds) Fade out the client's volume level toward silence (or fadePercent).
FileToString string FileToString(string file) Reads a string from file. Returns the string from the file, empty string if no file or file is too big.
FindNearestNPC handle FindNearestNPC(Vector position, bool checkZCoordinate, float radius) Returns the nearest character (Marine, Colonist, or Alien) to the given coordinate.
FrameTime float FrameTime() Get the time spent on the server in the last frame
GamePause void GamePause(bool bPause) Pause or unpause the game.
GetClientXUID string GetClientXUID(handle player) Get the player's xuid (i.e. SteamID64).
GetDecalIndexForName int GetDecalIndexForName(string name) Get decal index from a string.
GetEffectIndex int GetEffectIndex(string name) Converts a previously precached effect into an index.
GetEffectNameFromIndex string GetEffectNameFromIndex(int index) Converts a previously precached effect index into a string.
GetFrameCount int GetFrameCount() Returns the engine's current frame count.
GetHullMaxs Vector GetHullMaxs(int hullType) Returns a Vector for the hull maxs.
GetHullMins Vector GetHullMins(int hullType) Returns a Vector for the hull mins.
GetLocalPlayer (Client) handle GetLocalPlayer() Returns the local C_ASW_Player.
GetListenServerHost handle GetListenServerHost() Get the host player on a listen server.
GetMapName string GetMapName() Get the name of the map.
GetModelIndex int GetModelIndex(string filename) Returns index of model by name.
GetParticleSystemIndex int GetParticleSystemIndex(string name) Converts a previously precached material into an index.
GetParticleSystemNameFromIndex string GetParticleSystemNameFromIndex(int index) Converts a previously precached material index into a string.
GetPlayerConnectionInfo void GetPlayerConnectionInfo(handle player, table) Returns a table containing the player's connection info.
GetPlayerFromUserID handle GetPlayerFromUserID(int ID) Given a user id, return the entity, or null.
IsAnniversaryWeek bool IsAnniversaryWeek() Returns true if it is the anniversary week of Alien Swarm: Reactive Drop.
IsDedicatedServer bool IsDedicatedServer() Returns true if this is a dedicated server.
IsModelPrecached bool IsModelPrecached(string modelname) Checks if the modelname is precached.
LocalTime void LocalTime(table) Fills in the passed table with the local system time.
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. Default values for Faith / Bastille are : healAmount = 100 / 90, healthPerSecond = 3, infestationCureAmount = 0.75 / 0.25, duration = 20, grenadeRadius = 100
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.
PrecacheEffect void PrecacheEffect(string name) Precaches an effect.
PrecacheModel int PrecacheModel(string filename) Precache a model and return index of the model.
PrecacheParticleSystem int PrecacheParticleSystem(string name) Precaches a particle material.
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
RandomHQSetSeed void RandomHQSetSeed(unsigned int seed) Set a specific seed value for reproducibility. RandomHQ*() is a set of functions to access C++ Native MT19937 Random Number Generator. MT19937 is very fast and provides very High Quality random numbers. By default, you don't need to call this function, as it will automatically seed the generator to a non-deterministic state upon game initialization.
RandomHQSetRandomDevice void RandomHQSetRandomDevice() Reset the generator to a non-deterministic state. By default, you don't need to call this function, as it will automatically seed the generator to a non-deterministic state upon game initialization.
RandomHQUniformIntDistribution int RandomHQUniformIntDistribution(int min, int max) Generate a uniformly distributed random integer in the range [min, max]. If min > max, the values are swapped.
RandomHQUniformFloatDistribution float RandomHQUniformFloatDistribution(float min, float max) Generate a uniformly distributed random float in the range [min, max]. If min > max, the values are swapped.
RandomHQNormalDistribution float RandomHQNormalDistribution(float mean, float std_dev) Generate a normally(Gaussian) distributed random float with the specified mean and standard deviation. If std_dev <= 0.0f, it sets std_dev to 1.0f.
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>
ScreenFade void ScreenFade(handle player, int red, int green, int blue, int alpha, float fadeTime, float fadeHold, int flags) Start a screenfade with the following parameters.
ScreenShake void ScreenShake(Vector vecCenter, float flAmplitude, float flFrequency, float flDuration, float flRadius, int eCommand, bool bAirShake) Start a screenshake with the following parameters.
SendToConsole void SendToConsole(string command) Send a string to the console as a command.
SendToServerConsole void SendToServerConsole(string) Send a string that gets executed on the server as a ServerCommand
SpawnEntityFromTable handle SpawnEntityFromTable(string name, handle keyvalues) Spawn entity from KeyValues in table - 'name' is entity name, rest are KeyValues for spawn.
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
TraceLineTable void TraceLineTable(table traceTable) Uses a configuration table to do a raytrace, puts return information into the table for return usage.
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

Useful Code

Delaying Code Execution

function DelayCodeExecution( string_code, delay )
{
	DoEntFire( "worldspawn", "RunScriptCode", string_code, delay, null, null );
}

Usage example, this code below prints each marine's health into console 5 seconds after they have spawned:

function OnGameplayStart()
{		
	DelayCodeExecution( 
	"local handle_marine = null; while ( ( handle_marine = Entities.FindByClassname( handle_marine, \"asw_marine\" ) ) != null ) { printl( handle_marine.GetMarineName() + \" health is \" + handle_marine.GetHealth() ); }",
	5.0 );
}

Note that if the code that you want to delay uses quotation marks, you have to add a '\' symbol before those quotation marks so that they would get parsed into the string.

Delaying a Function Call

Delays a function call, the function that gets delayed has to be in the same script scope.

function DelayFunctionCall( function_name, function_params, delay )
{
	if ( !this["self"] )
		return;
	
	// this[ function_name ]( function_params );
	EntFireByHandle( this["self"], "RunScriptCode", "this[\"" + function_name + "\"](" + function_params + ");", delay, null, null );
}

Usage examples:

function OnGameplayStart()
{		
	DelayFunctionCall( "PrintToChat", "\"Hello, I was printed with a 3 second delay.\"", 3.0 );
}

function PrintToChat( message )
{
	ClientPrint( null, 3, message );
}
function OnGameplayStart()
{		
	DelayFunctionCall( "SetMarineHealth", "50", 3.0 );
}

function SetMarineHealth( health )
{
	local handle_marine = null;
	
	while ( ( handle_marine = Entities.FindByClassname( handle_marine, "asw_marine" ) ) != null )
	{
		handle_marine.SetHealth( health );
	}
}

Note that the parameters have to be constants or indexes which are global to the scope.

See also