Mappers - VScripts

sneaK

Owner
Owner
Administrator
Operations Team
Server Moderator
Joined
Aug 23, 2016
Messages
4,716
Reaction score
1,714
Points
296
Saw this really great post over @ KZ-Climb, figured some of you guys who do mapping might find this interesting. I was asked about vscripts the other day on stream (forgot who asked tbh, sorry!) so I figured there'd be some interest.

DanZay said:
Goal
Initially, I wanted to learn how to write VScripts to make mechanics for my planned map. But now I figured I would introduce mappers to the power of VScripts, and also provide mappers with reliable, more customisable implementations of frequently used KZ mechanics (e.g. b-hop blocks) . This is hopefully done whilst also reducing the complexity and impact on the entity count of putting the mechanics into a map. Also, people can tell me if I'm doing anything wrong.
DanZay said:
Disclaimer
I am not quite an experienced progammer but I tried. :)
These scripts aren't yet proven to work perfectly on a populated public server, but they work in testing.

Brief Explanation of How I Used VScripts
Entities can be given an "Entity Script" in their properties. This makes them run a script when it spawns. A script can connect entity outputs, such as a trigger_multiple's OnStartTouch, to execute code. That code can be written to have the entity do almost anything. In my case, they run functions from the player's scope. Used VScript files are placed into /csgo/scripts/vscripts/ and need to be packed into the map. Recommended resources: VScript, Vscript Fundamentals.

The VScripts
GitHub/Download Link - Example VMFs are provided!
To play the examples, place all .nut files into /csgo/scripts/vscripts/danzay/.

Due to the way these scripts are written, certain scripts need to be run by the player (RunScriptFile) when they spawn into the map (example of how to do this). This puts the required functions and variables into the player's scope, allowing my entity scripts to work. I took this idea from Olaahhh george. 's Onehop VScript.

I'm happy to try to address any issues or help anyone implement the VScripts.

More documentation can be found in the .nut files themselves.


misc.nut

All functions that weren't directly related to a certain mechanic. Is generally required to be in the player's scope. Includes teleport, printing to the center info panel, execute client commands.

One of the challenges was to disable the speed panel temporarily before sending a message to the center info panel. This is only done if a flag is set to true, so you should provide a way for the player to choose if they want to use the speed panel by using misc_setspeedflag.nut (specify what you want to set the flag to by naming the entity "true" or "false").

You must have the player run misc.nut when they join.

Use misc_setlanguage.nut to set the player's language as specified by the entity's name (this is mostly there for fun, but you could theoretically provide message localisation).

bhop.nut
Implementation of b-hop block mechanic.

You must have the player run bhop.nut and misc.nut when they join.

Use bhop_block.nut for bhop block triggers. You can specify how many jumps on other blocks you want to require by setting the name of the bhop_block entity e.g. 0 means it doesn't matter (multi-touch), 1 means you have to jump on different blocks 1 time before going back etc. You can use -1 to specify a strictly single-touch b-hop.

Use bhop_safe.nut for safe area triggers. Failing a b-hop will teleport you to the origin of the last touched safe area trigger. This is notably useful for non-linear maps where you would usually not know where you want to teleport the player to.

Use bhop_miss.nut for other triggers that should teleport the player back to the last touched safe area (e.g. the pit below the blocks).

nonlinear.nut
Implements, for lack of a better name, a non-linear system.

This has the players touch objectives to increase their objective count. You can then create a 'gate' that will block the player if they don't have a certain number of objectives (specified by setting the name of the gate entity).

You must have the player run nonlinear.nut and misc.nut when they join.

Use nonlinear_objective.nut for objective triggers.

Use nonlinear_gate_rebound.nut and/or nonlinear_gate_teleport.nut for objective gate triggers.

Use nonlinear_reset.nut for objective count reset triggers.

Look at editing nonlinear_resource.nut if you would like to change the messages displayed and the sound played.

Planned
antibhop.nut
booster.nut

However, note:

DanZay said:
I recently discovered that these scripts are incompatible with KZTimer.

When the player disconnects, the loaded files are cleared. If they reconnect, KZTimer puts the player back at the position they disconnected from. This means the player will be in the map without having loaded the files required, so the entity scripts will not work. Reloading the files again will reset all variables i.e. settings and things like the objectives collected.

I'm likely going to have to rethink some things. Please wait before implementing my VScripts.

Cheers.
 

Login or Register

Forgot your password?
or Log in using
Don't have an account? Register now

Members online

Latest posts

Upcoming Events

Today's birthdays

Discord

Login or Register

Forgot your password?
or Log in using
Don't have an account? Register now
Top