Script Generator

From Neverwinter Pedia

Jump to: navigation, search

Now that you have understood how Conditions and Outcomes worked as "gates" in game, let's try to create some scripts, which served as the "brain" of these gates (think of them as the gatekeepers).

NWN2 is a conversation-based game (as opposed to shoot 'em ups), this means, most of the storyline and NPC responses were conversation driven. Hence, all the conditional checkpoints must be placed inside a conversation thread in order to work.


Contents

Script Generator

Way back when it was still NWN1 (2002-2006), many modders complained about how hard it was to learn to script, because most of the early tutorials were created by computer science students, and they smelled like computer science lecture notes! Because many modders were non-programmers, they find it extremely frustrating to have to learn "C" before they can script. Wasn't the toolset's purpose to allow non-developers and non-programmers to create stories? The need to learn scripts as a programming language was so counter-productive!

Thankfully, some kind soul (actually, his moniker is LilacSoul) decided to help the non-programmers out and created a Script Generator to make script writing a much easier task. Without Script Generator, NWN/NWN2 modding probably would never be as popular as it is today! In fact, the Script Generator was so useful, that many non-programmers actually learned to write simple programs by just observing how the finished scripts were written. But that's another story.


Getting the Software

Now, do yourself a great favor, and download LilacSoul's Script Generator (version 2.3) using the following links: Script Generator's Page at NWVault at IGN.com | Zipped file of Script Generator | Manual of Script Generator.

Once you have downloaded the zipped file, unzip it (using 7-zip) into a directory of your choice. The zipped file will yield 4 files, as shown below.


The Script Generator does not need to be installed, it runs AS IS (and works with Windows 7 also). To use the program, double click on it and it should start. You may want to create a shortcut to the program and drag it onto your Desktop or Start Bar for easy access.

[I will leave you to read the Manual of Script Generator yourself. Besides, there is really no need to duplicate LilacSoul's effort by creating yet another tutorial to teach you how to use the Script Generator!]


Speaking to Frans

Using the scenario given above, speaking to Frans before speaking to Bennay is one condition player must fulfill. To do this,

  1. Select Normal Script.
  2. Select From a Conversation.
  3. Choose Set Local Variable(s) from the Event/Action Chooser dialog box that pops up.
  4. Click on the large "SCRIPT" button at the bottom of the dialog box.



  5. Check "Set the Local String", fill in the blanks as follows:




  6. OR, Check "Set the Local Integer", and fill in the blanks as follows: [Very Important: Choose only ONE!]



  7. Click the "Okay and Exit!" button towards the bottom of the dialog box.
  8. Click "CLOSE" on the Event/Action Chooser dialog box, to close that dialog box and return to the main Script Generator screen.
  9. Highlight and copy the lines of scripts from the Script Window to Clipboard, by click on the Copy/Other script actions button, or by pressing CTRL+C.





Deciphering the NWN2 Scripts

Actually, all that is required are the following section:

void main () 
{
    object oPC = GetPCSpeaker();
    SetLocalInt(oPC, "spoken2Frans", 1);
}

Do you think you can decipher what is going on in these 5 lines of code? You should have met voidmain() { } in the last tutorial. So let's examine the command inside the angle brackets ({ }) for a moment. Whatever falls within these two brackets are the actual commands (or computations/instructions) to be carried out by the program/game.

1. Declare a variable (like x in Algebra), in this case oPC, which stands for "object Player Character". (Note the convention used here, small letter for the first word, and CAPS for the following words). Set the variable oPC to the value of GetPCSpeaker(). The function GetPCSpeaker will identify which avatar is the Player Character, and then assign a variable oPC to it.

object oPC = GetPCSpeaker();

2. Terminate the instruction by semicolon (;). The semicolon is very important, you must terminate each line of command with a semicolon!

3. The following line creates a Local Integer: spoken2Frans, and assign the value 1 to it. It then attached (glued) this variable to oPC (the Player Character).

SetLocalInt(oPC, "spoken2Frans", 1);


Summary:

Basically, we have performed the following tasks:

  1. The game need to remember if a player has already "spoken to Frans", so that "spoken2Frans = TRUE" (if it is a string variable), or "spoken2Frans = 1" (if it is a numeric/integer variable).
  2. Identify which avatar is the Player Character (PC). (It may sound strange to you, but the game really doesn't know.)
  3. Tell the game to attach the variable to the PC avatar. (i.e., putting the variable into the PC INVENTORY).
  4. This will facilitate NPCs to check for the value of the Conditional variable(s) and "act" accordingly. Thus, we must ensure these Conditional variable(s) are not attached accidentally to NPCs, like Bennay or Frans.


Now that the variable is in the PC's INVENTORY, Bennay will "see" it, and tell the player about the Basement quest. (See next tutorial for instructions on how to do this).



Continue to ยป spoken2Frans | Return to Basic Skills