Updated VScript in Mapbase (markdown)

Blixibon 2020-11-26 11:47:18 -06:00
parent 080733e555
commit 4d6a94474b

@ -62,16 +62,20 @@ Players and NPCs share a single class called `CBaseCombatCharacter`, which is on
In spite of the overlap, players and NPCs have been given their own exclusive functions as well. Not all of them are listed here, but here's a basic overview of what can now be done:
### Players
### Players (`CBasePlayer`)
* There are now functions for monitoring and controlling the player's "button mask", or which binds the player is holding down. This is used by `game_ui` to detect what the player is pressing and `player_speedmod` suppresses abilities by selectively preventing certain buttons from being added to the button mask. *(Both features can also be used through these new VScript functions)*
* There are now functions for detecting HEV suit properties, like the amount of armor, aux power, flashlight battery, etc. are available and whether certain suit features are being used.
* In HL2's HEV suit, support for custom suit devices has been added. (TODO: proper tutorial?)
* A `PlayerRunCommand` hook has been added for controlling the player's movement and button commands as an alternative to the `game_ui` entity.
### NPCs
### NPCs (`CAI_BaseNPC`)
* TODO
* Functions and classes exist for enemy-related operations, including getting a handle for the current enemy, getting the enemy's last known position, etc. *(you can even get a struct for enemy memory information)*
* Functions exist for NPC squads and a `GetSquad()` function can return a `CAI_Squad` instance which exposes squad information. Squads can also be accessed through a new `Squads` (`CAI_SquadManager`) singleton.
* There are functions for reading, detecting, and controlling a NPC's schedules, conditions, and tasks. A `NPC_TranslateSchedule` hook exists for translating a NPC's current schedule.
* There are functions for reading, setting, and translating a NPC's activities. A `NPC_TranslateActivity` hook exists for translating a NPC's activity from one animation to another under certain conditions.
* A `CAI_Expresser` instance can be accessed with `GetExpresser()` and `CAI_BaseActor` is exposed with a few actor-related functions. These are mostly useful for NPC speech and choreography.
# VScript VBSP
@ -79,3 +83,27 @@ As of Mapbase v6.0, VBSP is capable of supporting a VScript VM which can read fr
VScript in VBSP can be enabled with the `-scripting` launch parameter. When this is enabled, VBSP will seek out a "<mapname>_vbsp.nut" file in the same directory as the VMF. To print documentation for VScript in VBSP, the `-doc` launch parameter could also be used.
```lua
Msg("Helloooo!! VScript calling!\n")
vecTest <- Vector(5,23,41)
Msg("Here's a vector for your troubles: " + vecTest + "\n")
randTool <- "something"
switch (RandomInt(1,3))
{
case 1:
randTool = "carve";
break;
case 2:
randTool = "Hammer";
break;
case 3:
randTool = "Source";
break;
}
Warning("Don't use " + randTool + "\n")
```
![VScript in VBSP](https://media.moddb.com/images/articles/1/289/288351/auto/21616unknown.png)