Skip to content

Creating Your First Script#

Notice

This page is still work in progress and may contain inaccurate information.

To familiarize yourself with scripting, let's go over creating your first script: a scenario script. Before you begin, you'll need to have:

  • Created a Project
  • Created C++ Script Project(s) for your Project
  • Created a Scenario tag within your Project
  • Familiarity with C++

Once you've got these, continue reading!

Creating a Script Class#

To start, create a new class within your C++ project. It should inherit from the BlamScenarioScript class. You can achieve this either using the New Class wizard, or by creating it manually with headers and source files - whichever you like.

Next, you'll need to

TBA: FILL THIS IN ONCE THE PROCESS IS IRONED OUT

Attaching your Script#

Once your script is created, open your Scenario tag in Guerilla. At the top of the window, click the 'Attach Script' button. A dialog box will open, displaying a list of all compatible scripts. Search for your new script name, and when you find it, select it and choose the 'Attach' button. If you cannot find your script, ensure that you have built your project in Visual Studio, then restart Guerilla and try again. If it still fails to appear, you can use the following tool command to manually update the script database:

tool process-scripts

Once you've attached your script, navigate to the script events section within the tag, where you will find several event functions you can connect to. For this example, locate the scenario loaded event, and in the function dropdown, locate and select your ScenarioLoaded method. If it does not appear within the list, ensure the signature of your script method exactly matches that shown in Guerilla, and that the method is marked as public.

Once attached, save your scenario tag, then run your game from Visual Studio. If you have not set the scenario to load on startup, load it manually by opening the in-game console (~) and running:

level_name /path/to/your/level.scenario

When it has finished loading, you should see "Hello world!" printed in green in the bottom left of the screen. If so, congratulations - you've created your first script! If you don't see it, ensure that you're running either a debug build, or a build with debug tools enabled (note that Release builds do not allow debug tools to be enabled by default, though you can choose to have them enabled or allow them to be enabled using command-line arguments).