L4D2 - VScript Documentation and FAQ

A work in progress

[B]Overview[/b]
*TODO

[B]Variables[/B]
*TODO


[B]Classes[/B]
  • [B]CDirector[/B] [B]Game Instance: [/B] Director [B]Class Methods:[/B]
    • GetAveragedSurvivorSpan() - Get the distance between the lead and trailing survivors, smoothed over time
    • GetAveragedSurvivorSpeed() - Get the rate at which the lead survivor is moving along the flow, smoothed over tim
    • GetFurthestSurvivorFlow() - Get the maximum distance along the flow that the survivors have reache
    • GetGameMode() - Get the current game mode "versus", etc
    • HasAnySurvivorLeftSafeArea()
    • IsPlayingOnConsole() - Returns true if player on xbox
    • IsSinglePlayerGame() - Return true if game is in single player
    • IsValid()
    • L4D1SurvivorGiveItem()
    • PlayMegaMobWarningSounds() - Plays a horde scream sound and asks survivors to speak 'incoming horde' lines
    • ResetMobTimer() - Trigger a mob as soon as possible when in BUILD_UP
    [b]Director Enumerations[/b] [COLOR="Red"][B]These are (or some are) SCRIPT SPECIFIC[/B][/COLOR]. Hence the duplicate values
    • FINALE_CUSTOM_DELAY = 10
    • FINALE_CUSTOM_PANIC = 7
    • FINALE_CUSTOM_SCRIPTED = 9
    • FINALE_CUSTOM_TANK = 8
    • FINALE_FINAL_BOSS = 5
    • FINALE_GAUNTLET_1 = 0
    • FINALE_GAUNTLET_2 = 3
    • FINALE_GAUNTLET_BOSS = 15
    • FINALE_GAUNTLET_BOSS_INCOMING = 14
    • FINALE_GAUNTLET_ESCAPE = 16
    • FINALE_GAUNTLET_HORDE = 12
    • FINALE_GAUNTLET_HORDE_BONUSTIME = 13
    • FINALE_GAUNTLET_START = 11
    • FINALE_HALFTIME_BOSS = 2
    • FINALE_HORDE_ATTACK_1 = 1
    • FINALE_HORDE_ATTACK_2 = 4
    • FINALE_HORDE_ESCAPE = 6
    • SPAWN_ABOVE_SURVIVORS = 6
    • SPAWN_ANYWHERE = 0
    • SPAWN_BEHIND_SURVIVORS = 1
    • SPAWN_FAR_AWAY_FROM_SURVIVORS = 5
    • SPAWN_IN_FRONT_OF_SURVIVORS = 7
    • SPAWN_LARGE_VOLUME = 9
    • SPAWN_NEAR_IT_VICTIM = 2
    • SPAWN_NO_PREFERENCE = -1
    • SPAWN_SPECIALS_ANYWHERE = 4
    • SPAWN_SPECIALS_IN_FRONT_OF_SURVIVORS = 3
    • SPAWN_VERSUS_FINALE_DISTANCE = 8
    • ZOMBIE_TANK = 8
    • ZOMBIE_WITCH = 7
    -----------------------------------------------
  • [B]CEntities[/B] [B]Game Instance: [/B] Entities [B]Class Methods:[/B]
    • .FindByClassname (null|prev,classname) - Find entities by class name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search Continue an iteration over the list of entities, providing reference to a previously found entity
    • .FindByClassnameNearest (classname, vector) - Find entities by class name nearest to a point
    • .FindByClassnameWithin (null|prev,classname) - Find entities by class name within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
    • .FindByModel (null|prev, modename) - Find entities by model name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
    • .FindByName (null|prev, name) - Find entities by name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
    • .FindByNameNearest (name, vector) ??? - Find entities by name nearest to a point
    • .FindByNameWithin (null|prev, name, radius)??? - Find entities by name within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
    • .FindByTarget (null|prev, targetname) - Find entities by targetname. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
    • .FindInSphere (null|prev, vector,radius) ??? - Find entities within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
    • .IsValid() - whether entity is valid
    • .First() - Begin an iteration over the list of entities
    • .Next() - Returns the next entity in the Entities list
    -----------------------------------------------
  • [B]CBaseEntity[/B] [B]Class Methods:[/B]
    • .__KeyValueFromInt(key,int) - Sets a keyvalue from an integer, the keys avaiable for all __KeyValue are from the DEFINE_KEYFIELD in baseentity.cpp (classname,rendermode, renderfx, etc)
    • .__KeyValueFromString(key,string) - Sets a keyvalue from a string, the keys avaiable for all __KeyValue are from the DEFINE_KEYFIELD in baseentity.cpp (classname,rendermode, renderfx, etc)
    • .__KeyValueFromVector(key,vector) - Sets a keyvalue from a vector, the keys avaiable for all __KeyValue are from the DEFINE_KEYFIELD in baseentity.cpp (classname,rendermode, renderfx, etc)
    • .ConnectOutput(outputname,functioname) - Adds an I/O connection that will call the named function when the specified output fires
    • .DisconnectOutput(event) - Removes a connected script function from an I/O event
    • .FirstMoveChild() - returns entity's first move child if exists
    • .GetClassname() - returns classname
    • .GetForwardVector() - returns Vector instance
    • .GetHealth() - returns entity health
    • .GetMoveParent() - If in hierarchy, retrieves the entity's parent
    • .GetName() - returns named (if entity is named)
    • .GetOrigin() - returns origin vector
    • .GetPreTemplateName - Get the entity name stripped of template unique decoration. ie myitem&0125 returns myitem
    • .GetRootMoveParent() - If in hierarchy, walks up the hierarchy to find the root parent
    • .GetScriptId() - Retrieve the unique identifier used to refer to the entity within the scripting system
    • .GetScriptScope() - Retrieve the script-side data associated with an entity
    • .GetVelocity() - returns velocity vector
    • .IsValid() - whether entity is valid
    • .NextMovePeer - returns next child entity
    • .SetForwardVector(vector)
    • .SetHealth(int) - sets entity health
    • .SetOrigin(vector) - sets entity position in world
    • .SetVelocity(vector) - sets entity velocity
    • .ValidateScriptScope - Ensure that an entity's script scope has been created
    -----------------------------------------------
  • [B]CBaseAnimating[/B] [B]EXTENDS[/B] CBaseEntity [B]Class Methods[/B]
    • .__KeyValueFromInt(key,int) - Sets a keyvalue from an integer, the keys avaiable for all __KeyValue are from the DEFINE_KEYFIELD in baseentity.cpp (classname,rendermode, renderfx, etc)
    • .__KeyValueFromString(key,string) - Sets a keyvalue from a string, the keys avaiable for all __KeyValue are from the DEFINE_KEYFIELD in baseentity.cpp (classname,rendermode, renderfx, etc)
    • .__KeyValueFromVector(key,vector) - Sets a keyvalue from a vector, the keys avaiable for all __KeyValue are from the DEFINE_KEYFIELD in baseentity.cpp (classname,rendermode, renderfx, etc)
    • .ConnectOutput(outputname,functioname) - Adds an I/O connection that will call the named function when the specified output fires
    • .DisconnectOutput(event) - Removes a connected script function from an I/O event
    • .FirstMoveChild() - returns entity's first move child if exists
    • .GetClassname() - returns classname
    • .GetForwardVector() - returns Vector instance
    • .GetHealth() - returns entity health
    • .GetMoveParent() - If in hierarchy, retrieves the entity's parent
    • .GetName() - returns named (if entity is named)
    • .GetOrigin() - returns origin vector
    • .GetPreTemplateName - Get the entity name stripped of template unique decoration. ie myitem&0125 returns myitem
    • .GetRootMoveParent() - If in hierarchy, walks up the hierarchy to find the root parent
    • .GetScriptId() - Retrieve the unique identifier used to refer to the entity within the scripting system
    • .GetScriptScope() - Retrieve the script-side data associated with an entity
    • .GetVelocity() - returns velocity vector
    • .IsValid() - whether entity is valid
    • .NextMovePeer - returns next child entity
    • .SetForwardVector(vector)
    • .SetHealth(int) - sets entity health
    • .SetOrigin(vector) - sets entity position in world
    • .SetVelocity(vector) - sets entity velocity
    • .ValidateScriptScope - Ensure that an entity's script scope has been created
    -----------------------------------------------
  • [B]CNavMesh[/B] [B]Game Instance: [/B] NavMesh [B]Class Methods:[/B]
  • .IsValid
  • .UnblockRescueVehicleNav -----------------------------------------------
  • [B]CCallChainer[/B] [B]Game Instance: [/B] N/A [B]Class Methods:[/B]
    • .PostScriptExecute
    • .chains
    • .constructor
    • .prefix
    • .scope
    -----------------------------------------------
  • [B]CSimpleCallChainer[/B] [B]Game Instance: [/B] [B]Class Methods:[/B]
    • .Call
    • .PostScriptExecute
    • .chain
    • .constructor
    • .exactMatch
    • .prefix
    • .scope
    -----------------------------------------------
  • [B]regexp[/B] [B]Game Instance: [/B] [B]Class Methods:[/B] -----------------------------------------------
  • [B]Vector[/B] [B]Game Instance: [/B] None [B]Class Methods:[/B]
    • .constructor
    • .Cross
    • .Dot
    • .Length
    • .Length2D
    • .Length2DSqr
    • .LengthSqr
    • .Norm
    • .ToKVString
----------------------------------------------- [B]Functions[/B]
  • Assert(value, "optional message") - test value and if not true, throws exception, optionally with messsage
  • ConnectOutputs(table) - sets output functions for entity by table TODO
  • DebugDrawBox
  • DebugDrawLine
  • DoEntFire( target.tostring(), action, value, delay, activator, caller ) - Fire an event
  • EntFire("ent_fire target event") - wrapper for DoEntFire() that sets activator and caller to null
  • DoIncludeScript
  • IncludeScript - Wrapper for DoIncludeScript
  • GetFunctionSignature
  • Msg("message here") - prints message to console
  • printl("message") - prints message with carriage return
  • RandomFloat() - Returns a random float
  • RandomInt() - Returns a random int between 0 and 32767
  • RetrieveNativeSignature
  • SendToConsole("string")- send a string to the console as a command
  • ShowMessage("message") - Print a hud message on all clients
  • Time() - Get the current server time
  • DoUniqueString - Called by UniqueString, prob want to call that instead
  • UniqueString() - Generate a string guaranteed to be unique across the life of the script VM, with an optional root string. Useful for adding data to tables when not sure what keys are already in use in that table.
Standard Squirrel library functions - consult https://squirrel-lang.org abs, acos, array, asin , assert, atan , atan2, ceil, collectgarbage, compilestring, cos, exp , fabs , floor, format, getconsttable, getroottable, getstackinfos, log, log10, lstrip, pow, print, rand, rstrip, setconsttable, seterrorhandler, setroottable, type, sin, split, sqrt, srand, strip, suspend, tan ----------------------------------------------- [B]Constants[/B] TODO ----------------------------------------------- [B]Example Scripts[/B] [B] Getting a handle on surviviors[/B] [quote] /*************************************** Get a handle on a specific survivor - This is pretty hackish, I can't just say Entities.FindByName(null, "playername"), (YET) because I don't know what it's expecting internally. And I can't "learn" it's name by saying survivior.GetName(), because what that returns is just some a function ref, it's probably the C++ side wrapped in a closure, OPAQUE, bummer. ***************************************/ //Get Nick Nick <- Entities.FindByModel(null,"models/survivors/survivor_gambler.mdl"); // Nick is class "player" (which must be related or superset of CBaseEntity) Nick.SetHealth(0); // Ouch but he won't incap until hit again, even below zero //or Super Nick! Nick.SetHealth(50000); // Tank gonna get slapped to death. [/quote] [B] Change Max Specials[/B] [quote] Msg("Preparing to own the Survivors"); local Dopts = DirectorScript.DirectorOptions; // get a reference to the options Dopts.MaxSpecials <- 20; Dopts.BoomerLimit <- 5; Dopts.SmokerLimit <- 5; Dopts.HunterLimit <- 5; Dopts.ChargerLimit <- 5; Dopts.SpitterLimit <- 5; Dopts.JockeyLimit <- 5; Dopts.CommonLimit <- 120; Dopts.SpecialRespawnInterval <- 1.0; [/quote]
Scroll to top