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


Variables

I won't spend time going over basic programming concepts. I'm thinking that by this time you have a fair grasp of basic programming concepts, so you know what a variable is and what it's used for. (If I'm wrong, let me know and we'll have a mini-crash-course sometime.)

Type Casting and the Types

NWN variables are strictly type-cast. That means you can just say "x = 10" and get away with it. NWN has to know what type of variable will x be holding. So the first time you reference a variable, you have to tell the engine what type the variable will be. Some of the variable types are:

  • object An npc, PC, placeable, trigger, item, door...essentially anything that the place can interact with is in some way an object.
  • int (integer) A whole number. No decimal places.
  • float A number with decimal places. Even if your number is 3.0, that .0 makes it a float.
  • string A collection of keyboard characters. Names, tags, resrefs, etc.
  • effect A visual effect
  • location Data about a location on the map. Although you don't have to manage all the data, it's nice to know that this tends to include the area, the x / y / z coordinates, and the facing direction.

So, if we were going to use the x=10 example in our script, we'd have to do it something like this:

int x = 10;

The first time x shows up--in that particular script--we have to tell NWN what type of variable it is. After that we can use x all we want and we don't have to put int in front of it again.

You cannot (to my knowledge) recast on the fly! If you tell the editor that x is an int you cannot turn around a few lines later and try to put a string in there!

Conventions

Because the scripting is typecast, NWN scripters have adopted the following convention. We tend to use "camelBack" style with our variables. However, we also prefix the variable with the first letter of the variable type.

object oCreature;
int nMonsterCount;
string sBlueprint;

That way, deeper in the code, when we see "oCreature," we know that the variable is referring to some sort of object.

Furthermore, folks tend to do all their declarations at the "top" of the script rather than doing the declarations "on the fly" down in the actual code. But lately, I've seen more of the "on the fly" style, so I guess it's up to you.

Constants

A constant is a sort of "built-in" variable with a value that never changes. For instance, consider the value of pi. It never changes. It's always 3.1415 (and so on). So rather than try to remember that, NWN has made it into a constant. If you ever need to use pi, you just use the variable PI and NWN knows what you mean.

There are a large number of constants in NWN for you to use. The one thing to be aware of is that they're all in upper-case.

OBJECT_TYPE_CREATURE
INVENTORY_SLOT_LEFTHAND
VFX_IMP_DAZED_S

TRUE
FALSE

OBJECT_SELF

OBJECT_SELF is a good one to know because it defaults to "the object that is running the script."