Main Menu

Site Home Page

Glossary of Terms

Current Class Mod Package

Divider

Help! My mod is corrupted!

Divider

Week of June 15th, 2009

Topics:

  • Getting Help
    • The "Assistance" windows
    • The Lexicon
    • The Forums
  • Variables
    • Type-casting and the types
    • Conventions
    • Constants
  • Who Dun' It?
    • Who Spoke?
    • Who Used the Placeable?
    • Who Activated the Item?
    • Who Crossed the Trigger? Who Entered the Area?
    • Was it a Player? a DM?
  • Creating Objects
    • Preparing the Object
      • The Resref
      • The Object Type
    • At a Waypoint
      • Find the Waypoint
      • Find the Location
    • Where the player is
      • Find the Location
    • Create the Object
      • Deciding on a Tag
      • Spawning in the Object
      • Doing Things to the Object after Creation
  • Tracking Variables
    • Local Variables
    • Persistent Variables
  • Some Useful Scripts
    • Making Changes to the Avatar When It Enters the Game
    • Fiddling with the Avatar's Inventory
    • Destroying the Inventory Items
    • Destroying "Non-Destroyable" Items
    • Taking Gold From the Player
    • Giving Gold To the Player
    • Giving General Inventory Items to the Player
    • Giving Equipable Items and Forcing an Equip Action
    • Random Walk

Homework: Dungeon and Quest

Divider

Week of June 7th, 2009

Topics:

  • Items
    • Properties
    • Building your own items
    • How to make an item have a conversation.
  • Creatures
    • Properties
    • Building your own
  • Triggers
    • Choosing the right one
    • Drawing a trigger
    • Trigger Properties
    • Trigger Events and Scripting Preview
    • Examples of Trigger Use
  • Waypoints
    • Waypoint Properties
    • Waypoint Directions
    • Uses for Waypoints
    • Scripting Preview
    • How to Set Up a Patrol Route
  • Conversations
    • How they're used
    • The basic tree.
    • Branching
    • Links (or "Loop backs")
    • Tokens: Built-in and Custom
    • Colorizing the Text
    • Including Other Speakers
    • "Actions Taken" and other events
    • Conditional Nodes
  • The Journal
    • Categories
    • Entries
    • Updating the Journal through Conversations
    • Updating the Journal through Scripting
  • How to Test Your Mod
    • The Build Module Option.
    • The Real Way
    • The Test Module Option

Homework:


Divider

Week of June 1st, 2009

Topics:

  • Areas
    • Area Properties
    • Module Properties
  • Tiles
    • Tile Properties
  • Names
    • Blueprint / Resref
    • Tag
    • Display Name
  • Doors
    • Door Properties
    • Transitions between doors
    • How to make a door close itself
    • How to have a transition without a door
  • Placeables
    • Placeable properties
    • Spawning placeables.
    • How to stack placeables
    • How to have a placeable hold a conversation

Homework:

Divider

May 27, 2009

Topics

Homework

 

 

GAME CONCEPT AND DESIGN
COSC 320.101_SU09
SUMMER 2009


Conversations

Conversation writing is one of the key aspects of creating a NWN module. Most of your plot, instructions, and information will be delivered to your players through conversations. As you've seen in some examples, you can use conversations to offer choices to players and have the game react based on their answer, as in the following by-now-familiar mini example:

You stand before an altar. Do you make a sacrifice?

Yes.
No.

When you start a new conversation file, a new window pops open with a startling array of buttons, boxes, fields, and tabs. Yes...it can be that scary. But for the sort of conversations you'll be writing, you won't have to deal with a lot of these guys. I'll point out the ones that are important.

The easiest way to really get a handle on how this bad-boy works is to write a simple conversation. Fire up NWN, quickly whip up an empty module, and then follow along. I'll walk us through a few steps, and you can do it as we go.

  1. In the left-hand asset pane, right-click on the word Conversations, and select New.
  2. Right-click on the word Root and select Add
  3. A box pops up that says Enter the NPC greeting. Type Hello there.
  4. Click OK.
  5. Notice that there's a new line that says [OWNER] - Hello there.
  6. Let's edit that. Click the line once to select it. Look down below in the big field labeled Text. There's your text line.
  7. Click there and add Are you a good witch or a bad witch?
  8. This is the line that the NPC will say when the conversation starts. Now let's add the player's response.
  9. In the top pane, right-click on the NPC's text line.
  10. Notice in the pop-up menu that the choices on the menu have the same icons as some of the buttons along the left side. We're going to click Add, but we could just as easily have clicked the duplicate button on the left button bar.
  11. Go ahead and click Add.
  12. Once more the window opens, but this time is says Enter what the player says next.
  13. Type I'm not a witch at all. Then click OK.
  14. Notice that the line up top is beneath the first line and indented. And it reads I'm not a witch at all. [END DIALOG]
  15. That's the option that's displayed to the player to click on. If he clicks on it, his character will "recite" that line and the conversation will end.
  16. Let's add to it (and mix in a new movie). Click the player's line and add a new line.
  17. Here's the NPC box again. Type: But you are dressed like a witch. then click OK.
  18. Add another new line and type: They dressed me like this. and click OK.
  19. Look at the upper window to see how the lines are stacked up below each other. It's building a conversation "tree" for you.

If this conversation were to run in the game, the NPC would start the conversation and the conversation window would open and it would show (roughly)

Glenda: Hello there. Are you a good witch or a bad witch?

1. I'm not a witch at all.

The player then clicks on 1 and the box changes to:

Glenda: But you are dressed like a witch.

1. They dressed me like this.

The player clicks on 1 again and the box is dismissed.

Ok...now delete all those lines and let's start a new one.

  1. Add the first line and type: Guess how many fingers I'm holding up behind my back.
  2. Click the NPC's line and add a new line: I'll guess 3.
  3. Now this time, right-click on the NPC's line again and add a new line: I think it's 5.
  4. Notice that this new line appeared below the I'll guess 3 line, but not indented. That's because now we're giving the player an option between those two choices.
  5. Let's add another reponse. Once again, right-click on the NPC line and add: Um, 312?
  6. Notice it's been added to the list.

If the conversation were to run now, it'd look like this:

Gruntbelly: Guess how many fingers I'm holding up behind my back..

1. I'll guess 3.
2. I think it's 5.
3. Um, 312?

And the player can click on the response he wants to have his avatar speak.

That's nifty, but it's not a very good conversation. Let's add to it.

  1. Right-click on the player's line that reads I'll guess 3 and add a new line.
  2. Type Nope.
  3. Right-click on that line and add a new player line: Drat.
  4. Right-click on I think it's 5 and add a new NPC line: You're not very good at this.
  5. Right-click on that line and add a new player line: You noticed.
  6. Right-click on Um, 312 and add a new NPC line: Haha! And now I'm adding yours to my collection!
  7. Right-click on this line and add a new player line: Eeek!
  8. Your conversation tree should look something like this graphic:

Conversation_01

Notice that each of the closing player lines has an [END DIALOG] meaning that it'll close the box and end the conversation. Now the when the player choose one of the three options and the conversation travels down that branch of the tree.

Links or "Loop Backs"

Let's suppose you want your player to learn about all sorts of things. So you want the NPC to offer a list of several options. The player chooses one, reads through it, and when he's done you want the NPC to offer the list again so the player can choose a different branch to go down and learn about the next topic. We do this with what I call a "loop back". Create a new conversation and make it look like this:

conversation_02

Now, before we do a loop back, let's take a side-trip. Click the bottom button on the left-hand button panel. It looks like a bunch of arrows all pointing inward. When you do this, the entire tree collapes down. Now click the next button up, which looks like four arrows pointing outward. Bam! The conversation tree expands.

Now back to the looping....

We can see that the NPC says "Let's learn about shapes!" and the player says "Whee! Sound fun!" Then the NPC asks "What shape do you want to learn about?" Next the player has 5 choices: Triangle, Square, Circle, Pentagon, or Nothing. When the player choose a shape, we travel down that branch of the tree, right? Here's the kink: When the player says the last line of the branch, we want the NPC to re-offer the line: "What shape do you want to learn about?" But adding those lines to the end of the branch would be ugly and cumbersome. So we're going to do this:

  1. Right-click on the NPC line that reads What type of shape would you like to learn about?
  2. In the pop-up menu, choose Copy.
  3. Now right click on the player line: I see.
  4. In the pop-up menu choose Paste As Link.
  5. A + appears next to the player's line. Click the + and you'll see the NPC line again, but it's in grey.
  6. This means that the NPC's next line is the original line up above. The conversation loops back to that position.
  7. Right-click on the player's line: Interesting.
  8. Select Paste As Link.
  9. Right-click on the players line: Fascinating, and select Paste As Link.
  10. Repeat for the line: I never knew that.
  11. Don't do it for the line Nothing. I'm bored now. So there's a way out of the conversation.

If you'd like to test the conversation, right-click on the Root node and select Test. It doesn't run exactly like the conversation does in the game, but it'll give you a fair idea of how it'll work.

Tokens : Built-in

It's always a nice touch if the conversation reflects the speakers or the circumstances around the speakers. You can make this work through the use of built-in tokens. Start a new conversation and type in the NPC line that reads: Hello there, don't click OK yet. Now, after the comma, right-click and select Insert Token. A window pops up showing a bunch of variables that you can choose from. Depending on which you choose, the conversation will "look around" and select the right option. For instance, select Brother/Sister, and click OK.

The text now reads Hello there, <Brother/Sister> so let's finish it up. Add in a . How are you? And click OK.

When the conversation runs, the game will check the sex of the avatar and put in the appropriate word.

Tokens : Custom

Creating custom tokens is a little tricky as it involves some scripting and we're not there just yet. Nonetheless, here's an example lifted (more-or-less) from the .pdf file.

Suppose the player is supposed to chop down 80 trees. So you put some "choppable" trees in your map and when the player chops one, you have a script that looks something like this (for you programmers, this is pseudo-code! It won't work!):

nTreesCut++;
SetCustomToken(200, nTreesCut);

So, we've created our own token with an ID of 200 and set it equal to the number of trees that have been cut.

Now let us suppose that the player has chopped down 45 trees, then goes to talk to the NPC, the conversation tree looks like this:

conversation_03

And where it says <CUSTOM200> the conversation will display the current value of the token--in our case 45. Working with custom tokens can be a bit tricky but is a nice touch when you can do it.

Colorizing the Text

You can do a limited about of colorizing the text in the conversation. When you want to change the color right-click in the text window as if you were going to insert a built-in token. You'll notice that there are four tokens that seem odd: StartAction, StartCheck, StartHighlight, and /Start. These do not actually start any actions, checks, or such but served other purposes in the NWN compaigns.

Sometimes in a conversation, one of the player options would not be a line of "spoken" text but would instead be an opportunity to use a skill...say Pickpocket. So the option to attempt to pickpocket would display to the player in red text, indicating that it wasn't a spoken line.

Although these tokens don't actually perform the actions, you can still include them in your conversation to colorize the text.

  • StartAction will turn the text to green.
  • StartCheck will change it to red.
  • StartHighlight will change it to blue (which is usually nearly unreadable)
  • Start turns it back to white.

Including Other Speakers

Suppose you want your conversation to appear to come from more than one NPC. For instance, he's talking to the captain of the guard, and then a lieutenant pipes in with some text, then the captain, then the player, then the lieutenant...and so on.

Build your conversation. When you see [OWNER] that refers to the NPC that starts and "owns" the conversation. If you want another NPC to have a line, click the [OWNER] line in question, then click the drop down box that is labeled Speaker Tag. This will show you the tags of all the NPCs in the area. Select the tag of the NPC who gets to speak the line. If the third-party NPC is too far away from the conversation, the player will see the "generic" portrait in the conversation window and will be told that it comes from an "unknown speaker."

If you plan to add your third-party speaker through scripting, then its name won't show up in the Speaker Tag dropdown box. Instead, you can click the Add button and you'll see a list of all the blueprints of any custom creatures, doors, or placeables in your palette, and you can select the one that's going to get to speak the line. (I've never done this, so I'm not aware of any tricks.)

"Actions Taken" and other Events

One of the key parts of figuring out NWN is realizing that scripts can start conversations and that conversations can start scripts. Now, we're going to look at how to do that.

Actions Taken

At the bottom right of the window is a series of tabs. Click on the one that reads Actions Taken. This is where you have a line of conversation start up a script. Select the line you want to have fire the script, then enter the name of the script that should be run when this line of text is spoken.

  • Clicking the ... button will bring up a list of all the scripts in your module and you can pick the one you want.
  • You can type in the name of a script that doesn't exist and click the Edit button and the script window will appear so you can create the script.
  • You can click the hat to start a script Wizard that will help you build some very basic scripts.

It's important to note that the script will only run if the node to which it is attached is spoken. So if you attach it to a blue player line and the player doesn't click that line of conversation, then the script won't run!

Other Actions

Here you can inject some more life into the conversation by having the speaker of the line perform an animation or play a sound. You also have access to the Journal funtions which let you change the contents of the player's game journal. (More on that later.)

Comments

Go on...guess.

Current File

You may have to click the > arrow to scroll more tabs into view. There you will find Current File. This tab actually applies to the entire conversation, not any particular selected line.

  • Stop Camera Zoom In. Does exactly that. It prevents the camera from moving in close to the speakers of the conversation.
  • Normal. If the conversation ends normally, by reaching a node that says [END DIALOG], then this script will run. Typically, the script is nw_walk_wp which is the default "walk waypoints" script. So the NPC will resume his patrol.
  • Aborted. This is the script that is run if the player presses ESC to end the coversation, walks away from the conversation, or starts a fight. This is fun for instances where you want the NPC to be angry with the player for not finishing their chat. Typically, this is also set to nw_walk_wp but can be changed if you want.

Conditional Nodes

Conditional Nodes are nodes that appear in the conversation only when certain circumstances are met. For instance, suppose the player has to go find the golden apple and bring it back to the NPC.

Create a conversation tree that looks like the one below.

conversation_04

As you can see, all the options for the conversation are present. However, if the player doesn't have the apple, it wouldn't make much sense for him to have the option of saying "Yes." And if he did have the apple, we don't really want him to say "Not yet." (Unless fibbing is part of our game.) So we'll put conditionals on those lines.

  1. Click the player's line: Yes, it's right here.
  2. Down below, click the tab labeled Text Appears When.
  3. Click the wizard hat to start up the script wizard.
  4. In this window, we can make the choices we want to check for. There's a few, but in our case we want Item In Inventory, so click that box.
  5. Select Next> .
  6. Now we enter the tag of the item that the player must have. Let's suppose our apple is conveniently tagged golden_apple. So type in that tag in the top field.
  7. Click Add.
  8. The item appeared in the field below. This allows us to require several things in inventory if we wanted.
  9. Once again, click Next>.
  10. Give the script a name. I like to name them obvious, so I'll use ck_ as a prefix to mean "check", then what I'm checking for. So ck_goldenapple is a good name. (There is a character limit to script names, so you may have to be creative.)
  11. Click Finish.
  12. The window will disappear and you'll see a preview of your script in the window below.

Now, when the conversation runs, if the apple is not in the player's inventory, the "It's right here" line won't show up at all.

Ok, programmers, let's get rid of the Not Yet line if the person does have the apple. This one is a bit tricky because you want it to appear if the item is not present.

  1. Click the Not Yet line.
  2. Click the wizard hat.
  3. Set up the file as if it were going to look for the apple again.
  4. Save the file as, oh, ck_noapple.
  5. Once it shows up down below, click the Edit button to edit the file.
  6. Now you have to make changes to the script to flip the logic a bit.

It's been a while since I've done this, but I think you can just take away the ! in front of HasItem and that'll do the trick. You might have to experiment with it a bit, but that's the idea. Once it's been flipped, then if the player doesn't have the apple, he'll only see the "Not Yet" line. If he does have the apple, he'll only see the "Yes, right here." line.

Then, of course, on the "Yes, right here" line, you put in an Actions Taken script that removes the apple from his inventory, gives him a reward of some sort, and so on.

NOTE: In case I haven't said it elsewhere, in order to use HasItem( ) as well as a bunch of other specialized commands, you need to put #include "nw_i0_tool" at the top of your script before anything else.