FANDOM


In the previous chapter we covered how to create a simple cutscene. However, the cutscene that we created will never launch unless we add some more options that make it playable. To do this, we’ll add a trigger and a script, launching the cutscene when Geralt (i.e. the player) steps onto the trigger area. Additionally, since we only want the cutscene to play once, the script will also have to disable the trigger.

First, we need to add the trigger. If you need a refresher on how to add triggers, go back and take a look at the relevant section of the manual. When you’re ready, place the trigger in such a way as to have the start point within the trigger area:

Launching cutscene1

If you remember, the start point we previously placed can be found in the first area we created, i.e. g31_cave. Place the trigger in that location and double-click on it. The best way to do this is through the Module Explorer window:

Launching cutscene2

A window containing the trigger’s properties will appear on the right side of the screen:

Launching cutscene3

Type trigg_movie in the General section in the right-hand column opposite the Tag attribute:

Launching cutscene4

Make sure that the Enabled attribute in the Attributes section is set to True:

Launching cutscene5

This means that the trigger is switched on. Now look at the Scripts section. An attribute called On Enter should be displayed there. The script assigned to this attribute will be triggered by the passage of a character (Geralt or an NPC). This is precisely the attribute to which the script that triggers the cutscene should be assigned. Since the start point is within the trigger’s active area, the cutscene will be played immediately after the module launches. This will happen because Geralt will walk into the trigger.

Now we’ll discuss how to launch the Script Editor without using the File menu. Now add the file name launch_film. To do so, click the right-hand column opposite the On Enter attribute, type the text in, and hit ENTER:

Launching cutscene6

Then click on the small red icon located in the right-hand column:

Launching cutscene7

The Script Editor window will now appear:

Launching cutscene8

Note that the script will automatically be named after what you’ve typed in the On Enter attribute. This method of launching the Script Editor is actually better than through the File method, since the script is already named and assigned to an attribute.

Time to write our first script. As you can see, each script starts with a void main() function. The content of the script should be entered in the body of this function, i.e. between the parentheses ‘( )’.

Let’s start by writing a comment so that anyone viewing this script will immediately know what it’s all about. Type in the following:

Launching cutscene9

Everything written between ‘/*’ and ‘*/’ is treated as a comment and is thus skipped by the compiler. The comment is an additional piece of information that serves to tell the reader what the script is for. As you can see, this type of comment can be written over a couple of lines. Another type of comment is when the ‘//’ signs are used. Type this below the first comment:

Launching cutscene10

This type of comment is called a one-liner. As its name suggests, it’s only supposed to take up one line. If you wanted to add an additional comment of this type, you’d need to start a new row with //.

Let’s add the first function. Below the second comment, type in the following:

Launching cutscene11

Note that a window appears after the word Play is added. The window contains the list of functions that can be used in this context. There are 6 functions that start with the word Play – move up and down the list using the ↑↓ cursor buttons. After selecting the function, press either the TAB or ENTER button. Of course, the function can also be written in manually.

Since we want to launch a cutscene, type in PlayCutscene. Then open a ‘(‘.

Launching cutscene12

Note that a new window has appeared. This time it’s a tip regarding function syntax. Following the suggestion, we’ll add the name of the cutscene. This is naturally a file name, but without the .cut extension.

The next argument of the PlayCutscene function is the name of the script which will be launched at the end of the cutscene. We don’t need this type of script, so just leave the “” quotation marks empty.

The 3rd argument is more important for our purposes, however. This argument is the film display mode. If it’s set to 1 (True), then game characters will not be displayed. If it’s set to 0 (False), then game characters will be displayed, and that’s exactly what we want. During the movement of the two cameras, we’ll be able to see Jethro, Siegfried, and Geralt (provided that you’ve set the camera views near the characters’ spawn points). The whole line should now look like this:

Launching cutscene13

Remember to place a semi-colon ‘;’ after each line of script. The PlayCutscene function will now launch the specified cutscene. All that’s left to do is to switch the trigger off at the end of the cutscene.

Before doing that, though, let’s add another comment:

Launching cutscene14

This indicates that the next function will turn off the trigger. Now add the next function. Enter the following:

Launching cutscene15

As you can see, there are a number of functions that begin with the word Enable. But wait – if we’re trying to switch the script off, why use an Enable function instead of a Disable function? We’ll get to that in a moment.

The function that is necessary for now is called EnableTrigger. Type this in and open a ‘(‘:

Launching cutscene16

As you can see from the tip, the first argument of the EnableTrigger function is the trigger object. First, however, it’s important to draw the trigger. This can be done in one of two ways. The first way is to add a line with the following script:

object oTrigger = GetObjectByTag(“trigg_movie”);

Object is the keyword that means that we’ll be drawing on an object. oTrigger is just an arbitrary name, to which the object will be assigned. The GetObjectByTag function will draw on the object using the object’s tag. In our case, we want to draw on the trigger object, which, if you remember, we gave the tag trigg_movie. All we need to do now is write the following:

EnableTrigger(oTrigger

There’s an easier way, though – the keyword OBJECT_SELF. Keywords are marked in blue in the script editor. OBJECT_SELF refers to the object which owns the script. Since the script is assigned to the trigg_movie trigger, the usage of the OBJECT_SELF keyword will automatically indicate the trigg_movie trigger. Thus there’s no need to write the object oTrigger line.

The script should now look like this:

Launching cutscene17

The EnableTrigger function switches the trigger on/off. The second argument of the function can take the value TRUE (on) or FALSE (off). Type in FALSE after the comma and close the ‘)’:

Launching cutscene18

Remember to add the semi-colon ‘;’ at the end.

That’s it. Our script is ready and working. Now we need to save the script. In the File menu, choose Save launch_film.nss:

Launching cutscene19

If Save launch_film.nss does not appear in the drop down menu, or if there is another file name instead, it means that the launch_film.nss window is not active at the moment. In order to activate it, just click the title bar of the launch_film.nss window and then choose Save launch_film.nss from the File menu. A Save File window will appear:

Launching cutscene20

In saving the file, you will have the choice of saving it globally (meaning it will be available in other modules, as well) or just in the present module. Click the Global button this time but remember that it’s always possible to save the file just to a specific module. The latter is a good choice if you want to publish your work on the internet to share with friends or the community, since the whole one file is then saved within the module (in the .adv format). This has already been covered earlier in the manual.

Clicking the Global button opens the standard Windows window used for saving. Go to the Data\Scripts folder (where all scripts are saved), type in the file name and click Save. Naturally, a file saved this way can be later added to a module, but we’ll go ahead and do it now. Click the Module button. An Enter name window will appear. Type in the name of the script file, launch_film, in the Enter name window:

Launching cutscene21

Click OK. The script will now be compiled and will also appear in the Module Explorer window in the Neverwinter scripts sources subtree:

Launching cutscene22

Since the script has been compiled, let’s look at the event registry window, i.e. the Aurora log:

Launching cutscene23

If any errors arise during the compilation process, they will be signaled in purple. As you can see, the compilation shown here ended with such an error:

NWNScript Compiler: \..\ launch_film.nss did not Compile successfully

This means that the launch_film.nss script has not been properly compiled. The error is described in the next line:

NWNScript Compiler: launch_film.nss(10): ERROR: UNDEFINED IDENTIFER (PlayCuscene)

The line number is given in parentheses ‘()’, following the name of the script. The type of error is then given – UNDEFINED IDENTIFIER. The name of the identifier is given further in the parentheses. And the computer is right – there is no function called PlayCuscene, only PlayCutscene. Naturally, the typo needs to be corrected and the script recompiled:

NWNScript Compiler: \..\launch_film compiled successfully

This means that the script has now been compiled correctly, but we still need to save the whole module. To do this, choose Save Module in the Module menu:

Launching cutscene24

That’s it. We’ve created our first script. Granted, it’s not terribly complicated but it will suffice, at least for now.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.