diff --git a/VScript-in-Mapbase.md b/VScript-in-Mapbase.md index cb3d074..7525b78 100644 --- a/VScript-in-Mapbase.md +++ b/VScript-in-Mapbase.md @@ -25,6 +25,7 @@ Mapbase's implementation of VScript does **not** use any leaked code whatsoever. * [New VScript Classes](VScript-in-Mapbase#New-VScript-Classes) * [CBaseCombatCharacter](VScript-in-Mapbase#CBaseCombatCharacter) * [CAI_BaseNPC](VScript-in-Mapbase#CAI_BaseNPC) + * [Hooks](VScript-in-Mapbase#Hooks) * [CAI_BaseActor](VScript-in-Mapbase#CAI_BaseActor) * [CAI_Network](VScript-in-Mapbase#CAI_Network) * [CAI_Expresser](VScript-in-Mapbase#CAI_Expresser) @@ -39,17 +40,23 @@ Mapbase's implementation of VScript does **not** use any leaked code whatsoever. Some features are not available in Mapbase's implementation of VScript, although some may be available in the future. -* Most of the global functions (e.g. `SpawnEntityFromTable`) are not yet available because many of them are game-speciic. +* Most of the global functions (e.g. `SpawnEntityFromTable`) are not yet available because many of them are game-specific and are not included in the Alien Swarm SDK. * Some singletons like `Convars` or `NetProps` are not available. (`Entities` *is* available) * It is currently not possible to use in-game documentation methods, such as `script_help`. # Documentation -A lot of the documentation for VScript on the VDC applies to Mapbase, but Mapbase also extends the VScript support in various ways, mostly to make it able to operate upon NPCs and other Source 2013/Half-Life 2 conventions. Those changes are documented below. +A lot of the documentation for VScript on the VDC applies to Mapbase, but Mapbase also extends the VScript support in various ways, mostly to make it able to operate upon NPCs and other Source 2013/Half-Life 2 conventions. + +In addition to the original VScript inputs, Mapbase introduces a new `RunScriptCodeQuotable` input. This operates the same way as `RunScriptCode`, but double apostrophes ('') are converted to quotation marks ("), allowing code with strings to be run from Hammer and in-game `ent_fire`. + +Other changes are documented below. ## New VScript Classes These are classes Mapbase exposes to VScript. +*** + ### CBaseCombatCharacter The base class shared by players and NPCs. @@ -78,6 +85,8 @@ The base class shared by players and NPCs. | *Vector* EyeDirection2D()| Get the eyes' 2D direction. | | *Vector* EyeDirection3D()| Get the eyes' 3D direction. | +*** + ### CAI_BaseNPC The base class shared all NPCs derive from. @@ -109,6 +118,16 @@ The base class shared all NPCs derive from. | *bool* IsCommandable()| Check if the NPC is commandable. | | *bool* IsInPlayerSquad()| Check if the NPC is in the player's squad. | +*** + +**Hooks** + +| Signature | Description | +|:------------- | :-----| +| *variable* NPC_TranslateActivity()| Translates a requested NPC activity to another activity. The requested activity is stored as a string in `activity` and as an integer in `activity_id`. Either an activity string or an activity ID can be returned. If either -1 or "ACT_INVALID" are returned, the activity will not be translated to anything different. | + +*** + ### CAI_BaseActor The base class for NPCs which act in complex choreo scenes. @@ -117,6 +136,7 @@ The base class for NPCs which act in complex choreo scenes. | *void* AddLookTarget(handle *target*, float *importance*, float *duration*, float *ramp*)| Add a potential look target for this actor. | | *void* AddLookTargetPos(Vector *target*, float *importance*, float *duration*, float *ramp*)| Add a potential look target position for this actor. | +*** *** ### CAI_Network @@ -133,6 +153,8 @@ The global list of AI nodes. Can be accessed through a global `AINetwork` instan | *int* GetNodeType()| Get a node's type | | *handle* GetNodeHint()| Get a node's hint | +*** + ### CAI_Expresser Expresser class for complex speech. Typically accessed through `GetExpresser()`. Not all NPCs/players have an expresser. @@ -145,6 +167,7 @@ Expresser class for complex speech. Typically accessed through `GetExpresser()`. | *void* SpeakRawScene(string *scene*, float *delay*)| Speak a raw, instanced VCD scene as though it were played through the Response System. Return whether the scene successfully plays. | | *void* ScriptSpeakAutoGeneratedScene(string *soundname*, float *delay*)| Speak an automatically generated, instanced VCD scene for this sound as though it were played through the Response System. Return whether the scene successfully plays. | +*** *** ### CLogicExternalData @@ -184,23 +207,16 @@ Wrapper class over KeyValues instance. | Signature | Description | |:------------- | :-----| -| *handle* ()| . | - -TODO - - DEFINE_SCRIPTFUNC_NAMED( ScriptGetName, "GetName", "Given a KeyValues object, return its name" ); - DEFINE_SCRIPTFUNC_NAMED( ScriptGetInt, "GetInt", "Given a KeyValues object, return its own associated integer value" ); - DEFINE_SCRIPTFUNC_NAMED( ScriptGetFloat, "GetFloat", "Given a KeyValues object, return its own associated float value" ); - DEFINE_SCRIPTFUNC_NAMED( ScriptGetString, "GetString", "Given a KeyValues object, return its own associated string value" ); - DEFINE_SCRIPTFUNC_NAMED( ScriptGetBool, "GetBool", "Given a KeyValues object, return its own associated bool value" ); - - DEFINE_SCRIPTFUNC_NAMED( ScriptSetKeyValueInt, "SetKeyInt", "Given a KeyValues object and a key name, set associated integer value" ); - DEFINE_SCRIPTFUNC_NAMED( ScriptSetKeyValueFloat, "SetKeyFloat", "Given a KeyValues object and a key name, set associated float value" ); - DEFINE_SCRIPTFUNC_NAMED( ScriptSetKeyValueBool, "SetKeyBool", "Given a KeyValues object and a key name, set associated bool value" ); - DEFINE_SCRIPTFUNC_NAMED( ScriptSetKeyValueString, "SetKeyString", "Given a KeyValues object and a key name, set associated string value" ); - - DEFINE_SCRIPTFUNC_NAMED( ScriptSetName, "SetName", "Given a KeyValues object, set its name" ); - DEFINE_SCRIPTFUNC_NAMED( ScriptSetInt, "SetInt", "Given a KeyValues object, set its own associated integer value" ); - DEFINE_SCRIPTFUNC_NAMED( ScriptSetFloat, "SetFloat", "Given a KeyValues object, set its own associated float value" ); - DEFINE_SCRIPTFUNC_NAMED( ScriptSetBool, "SetBool", "Given a KeyValues object, set its own associated bool value" ); - DEFINE_SCRIPTFUNC_NAMED( ScriptSetString, "SetString", "Given a KeyValues object, set its own associated string value" ); +| *string* GetName()| Given a KeyValues object, return its name. | +| *int* GetInt()| Given a KeyValues object, return its own associated integer value. | +| *float* GetFloat()| Given a KeyValues object, return its own associated float value. | +| *string* GetString()| Given a KeyValues object, return its own associated string value. | +| *bool* GetBool()| Given a KeyValues object, return its own associated bool value. | +| *void* SetKeyInt(int *value*)| Given a KeyValues object and a key name, set associated integer value. | +| *void* SetKeyFloat(float *value*)| Given a KeyValues object and a key name, set associated float value. | +| *void* SetKeyBool(bool *value*)| Given a KeyValues object and a key name, set associated bool value. | +| *void* SetKeyString(string *value*)| Given a KeyValues object and a key name, set associated string value. | +| *void* SetName(string *name*)| Given a KeyValues object, set its name. | +| *void* SetFloat(float *value*)| Given a KeyValues object, set its own associated float value. | +| *void* SetBool(bool *value*)| Given a KeyValues object, set its own associated bool value. | +| *void* SetString(string *value*)| Given a KeyValues object, set its own associated string value. |