View Full Version : Neverwinter Nights, technical stuff

Inigo Montoya
12-08-2006, 10:52 AM
Anyone know of a good reference for explaining the creation of scripts in NWN? I haven't gotten up the guts to sneak NWN2 into the house yet and all the info I can find online is for NWN2 and I don't know if they're using the same toolset version. And why would they?

Ana-hoo, What I need is a sort of "NWN scripts for dummies" to walk me through the mechanics because it's not as self-explanatory as I would like. Stuff like making an area transition without using a door (you know, where you draw the trigger square that activates the transition to another area when you step on it?) took hours of frustration before I realized all you have to do is draw the square and then double click it to bring up the Area Transition wiz. And the only reason I figured that out was because I did some rapid mouse clicking to vent some momentary frustration and my cursor just happened to be inside my trigger drawing. :mad:

Needless to say, the odds of an accidental eureka moment while banging my head on the keyboard as I try to work out the coding language and methodology for a simple script are pretty small.

12-08-2006, 11:07 AM
Neverwinter Nights: For Builders (http://nwn.bioware.com/builders/)

12-08-2006, 11:07 AM
Hi Inigo,

You may find the NWN Lexicon (http://s94022747.onlinehome.us/lexicon/index) to be of some use. It basically defines & explains all the scripting terms available in the script editor. If you would prefer to download a version to your computer rather than rely upon the kindness of the internet, you can find a downloadable version on the NWN Vault (http://nwvault.ign.com/View.php?view=Other.Detail&id=736).

If you would like some assistance in crafting simple scripts (I found it easier to learn how to script from looking at other scripts, personally), try LilacSoul's Script Generator (http://nwvault.ign.com/View.php?view=Other.Detail&id=625) - this guy lived in my launch bar the entire time I was dabbling with the toolset, and I found it invaluable. Of course, I eventually got to the point where I didn't need it anymore, but it looks like it's had some recent additions which make it even more useful than it was when I started!

I don't know how helpful David Gaider's Scripting Tutorials (http://nwn.bioware.com/builders/sctutorial.html) will be because I don't know whether they've been updated for recent patches, but the simple things in scripting haven't really changed, so you might find them useful for your entry-level type stuff.

Finally, there's still a thriving online community posting to the Bioware site, and there's a whole forum for NWN1 scripting help (http://nwn.bioware.com/forums/viewforum.html?forum=47) on the boards there. Specific questions with descriptive titles usually garner a few informative answers, each with different styles of solving your problem, within 48 hours. Consider it the GQ of NWN :)

Good luck with your mod-building excursion, I hope it goes better than mine did! :smack:

Inigo Montoya
12-10-2006, 10:39 PM
Script Generator is one of the coolest things ever. Bioware really should have included something ike this in the toolset--It's absolutely spiffy.

Still, I can't figure out 2 things: 1) how do you strip a new character's equipment? I can take all the gold and exp, but none of their stuff. 2) Been trying but can't seem to figure out how to make a conversation happen once or loop until the player ends it. I know it has something to do with referencing an integer variable, which I understand in concept, but I can't think the code well enough to figure out what I'm doing wrong.

12-11-2006, 04:53 AM
Item stripping is kind of annoying because you have to build a loop - you basically say, "Show me the first item of the inventory. If the item exists, destroy it. Now show me the first item of the inventory. If the item exists, destroy it. If it doesn't exist because the inventory is empty, stop." There is a simple script to achieve this goal in the "Newbe FAQ #2 (http://nwn.bioware.com/forums/viewtopic.html?topic=207626&forum=47)" thread on the NWN 1 Scripting forum; I can't figure out how to link directly to the post, but it is the 11th post on the page and the code for it is in a little box-like window.

You will need to decide whether you should run it from "OnClientEnter" (which can be found in the module properties menu) or as a trigger that the player will spawn into upon entering the game the first time. I think if you run it from "OnClientEnter" you will need to add a variable so that it doesn't run each time they load up your module. So for example, once the equipment has been stripped once, you set a variable called "vItemStrip" to 1; at the beginning of the script you should check to make sure that vItemStrip isn't already set to 1. I really can't remember how OnClientEnter works though, so you should test this out.

I would like to warn you that many players will whinge terribly if their items are stripped & they cannot get them back at the end of the game. While you may be designing your game for a 1st level, new character, many players will prefer to bring higher-level favourite characters into the module & will get quite pissed if they no longer have all their uber l00t. You may want to store a copy of all their equipment in a chest they can access at the end of the module to accommodate this; or you can say "Suck it, whingers" - whichever is your style :)

For conversation looping, I'm not quite sure what you want to happen - do you want the PC to have options to ask a bunch of questions, then after they ask one, the others are still available for asking? This can be quite frustrating to do - I think the conversation editor is pretty clunky - but basically you need to have all the dialogue nodes you want available to be conditional. The condition would be, "Has the player already asked this question?" - if so, then it shouldn't appear; if not, then it should appear. Say you had the four questions:

1: "Why?"
2: "Where?"
3: "When?"
4: "How?"

In the conditional (TextAppearsWhen) script attached to the "Why" option, you would put a script like

int StartingConditional();

object oPC = GetPCSpeaker;

"if (GetLocalVarInt("qWhy", oPC) == 0) return TRUE;

return FALSE"
In the ActionsTaken script for the "Why" option, you would put a script like

#include "nw_i0_plot"

void main()

object oPC = GetPCSpeaker;

SetLocalInt(oPC, "qWhy", 1);
What this means is, when your PC first approaches the NPC, his "qWhy" variable does not yet exist - so it is by default 0. Thus, because his qWhy variable is 0, the text appears and he is allowed to ask why. After he is done asking why, the qWhy variable is set to 1, and the next time he clicks on the NPC, the text does not appear and he is not allowed to ask why. He can still ask where, when, and how, though.

To make the PC have all the options available all the time you will need to make "links" to each of the questions for each point in the dialogue that you want him to have more questions available. I would do it by having a PC dialogue option at the end of each explanation that says, "May I ask another question?" This is only available if at least one of the qWhy, qWhere, qWhen, or qHow variables is not yet set (that is, if he has not asked at least one of the questions). The NPC's response to this might be, "Feel free." Then under 'feel free', you would make a link back to the PC's "Why", "Where", "When", and "How" nodes.

I hope this helps - it's been about a year since I wrote a script for NWN so I'm pretty rusty. That Newbe FAQ is a pretty good resource, and after a bit of experience it should get a little easier.

Send questions for Cecil Adams to: cecil@straightdope.com

Send comments about this website to: webmaster@straightdope.com

Terms of Use / Privacy Policy

Advertise on the Straight Dope!
(Your direct line to thousands of the smartest, hippest people on the planet, plus a few total dipsticks.)

Publishers - interested in subscribing to the Straight Dope?
Write to: sdsubscriptions@chicagoreader.com.

Copyright 2018 STM Reader, LLC.