Dispatches From Neverwinter

A journal of my progress as I (attempt to) learn how to build modules for Neverwinter Nights.

Name:
Location: United States

Started playing Neverwinter Nights back in November '05 and got hooked. Tried to write my own module, but I just didn't have the time. Maybe I'll try again someday.

Monday, August 28, 2006

Lots of little things learned, and a new area almost finished

Been over a week since I was able to update here, as real world stuff didn't leave much time for working on the module. I managed to do a little work on it here and there, and was able to get in a lot more time on it than I expected this weekend (since I expected to have little to no time at all).

I've done as much as I can on cutscene area and the first area until CEP 2.0 comes out. I think I finally got the camera problem solved: I used SetCameraFacing instead of SetCameraMode to set the camera angle where I wanted it to be. Why the former worked and not the latter I don't know. Everything is pretty much done in the first scene except one of the transititions (since I haven't yet made the area it's transitioning too). I wasn't able to 100% resolve the disappearing peasants problem. I tried a suggestion from someone in the forum, but it produced a weird effect wherein half the peasants would disappear when they were supposed to, but the other half would sort of jump into the center of the trigger and then just stay there. So I went back to the old method, and that's that. I also set down two map pins and learned how make them appear during a conversation.

The player can go into two directions - north or northwest - from the first area, and I decided to work on the latter first. In this scene, the player comes upon two hobgoblins arguing over the body of a soldier. After dispatching the hobgoblins, the player can talk to the solider, who is on the verge of death. The soldier gives him his wedding ring and asks it to return it to his wife, then dies. The player can take his armor and weapons and stuff afterwards. In putting the area together, I learned how to make NPCs talk to each other and how to trigger their conversation. I learned how to do alignment shifts in a conversation, and how to use an invisible object to simulate the player talking to the nearly dead soldier. In short: a script "kills" the soldier as soon as it spawns, and since a PC can't interact with a corpse, I put an invisible object in front of the soldier, so that when it falls it lands under it. PC's can interact with an invisible object, and so that's where the conversation takes place (Ghostdreamer spelled this all out, so I can't take credit for figuring it out myself).

For the most part everything worked, but there were a few glitches. The dumbest one had to do with the conversation: in order to make two NPC's talk, you have to put blank lines for the PC between their lines. However, I forgot that when you add a line it says "," so when I tested it the first time, that kept popping up in the conversation. Some of the other problems are more difficult. For one, I can't get through the whole conversation because the hobgoblins keep spotting the PC and attacking it. Also, I noticed that they keep talking a little longer even while rushing the PC, which looks odd. Also, there are some problems with the soldier. The invisible object should destroy itself at the end of the conversation, but it doesn't, so when the PC tries to loot the body, they get the invisible object's inventory instead, which means they get a second copy of the ring. Meanwhile, the PC can't get at the soldier's inventory at all.

Nonetheless, whereas it seemed like it took forever to put the first area together, I got through this one very quickly (though the first one was more complex). I feel like I'm making progress here. Of course, these are very simple areas, and I've been skipping over the placeables for now, but still, I think my skills are improving.

Saturday, August 19, 2006

New Things Learned; Problems Still Unsolved

Got in about six hours straight working on the module today. In terms of getting it done I actually made very little progress, but in terms of learning it was very productive.

The big thing today was working on getting the non-combatant peasants to not fight back and also on getting them to walk away and disappear on cue. I had more success with the latter than the former. First I had to figure out how to make something happening in one NPC's conversation affect all the others. The first part of the solution was realizing that it's easy to call a variable from any object. I'm not sure why this didn't click to begin with, since it's pretty obvious. The second part was discovering that you use the AssignCommand function when you want a script on one object to make another object do something. In this case, I set a variable on the PC during a conversation with an NPC. At the end of that conversation, I used a bunch of AssignCommands to make the other NPCs walk away. If the PC tries to talk to them, the variable tells them to say one line and keep walking, rather than stopping. It took a while to iron all the bugs out though, and I got a very good lesson in the importance of making sure that a tag in a script exactly matches the tag on the object I'm calling, and that just because you think you spelled it right, it doesn't mean you did. Also, although I got everything to work the way I wanted it to, I wasn't exactly able to get it to work how I wanted it to. For some reason I couldn't get DestroyObject to work with AssignCommand. I solved the problem by doing things the way I originally intended, i.e., by having a trigger destroy the NPCs when they walked over it, but I'm left wondering why it didn't work.

Getting the non-combantants to be non-combatants was a stickier problem. I went into the OC and found a peasant who cowers and calls for help when attacked and exported her to my module. It turns out she had no scripts in her event slots except for one in the OnAttackedEvent. So after tinkering with it for a bit, I tried it out. It worked in the sense that the peasants didn't fight back. Unfortunately, they don't do anything else either unless directly attacked, and even when that happens, only the one being attacked will respond. What's more, the goblins pretty much ignore them and only attack the NPCs with weapons. The rest just stand around. I tried to fix this by calling the script in the OnPercieved event, but all that did was fire the script once at the beginning (and since they all act in unison, it looks more like a group prayer session). So I read up on loops and tried to put on in that would make the animation fire repeatedly until all the goblins were dead, but I didn't do it correctly, and so it caused a lot of errors. Ironically, I accidentally put the OnPhysicallyAttacked script in the OnPercieved event for one of the peasants, and it did create the kind of loop I wanted - except that it didn't stop firing after the battle was over.

I also went through my scripts, deleted ones I wasn't using, backed up ones I was using, and then ended up making more that I ended up not needing. I also did a lot with conversations; specifically, setting and calling variables and having scripts fire in them. I'm looking forward to getting past this area, as I don't think there's any unusual or complex scripting coming up for a while.

Oh, and script to set the camera mode in the trigger doesn't work after all.

Friday, August 18, 2006

A Valuable Lesson

Last night I learned that when I'm trying to get a script that's supposed to fire in the OnEnter event of the area to work, it helps if I actually put the script in the OnEnter event.

Just did a bit of clean-up last night: deleted all the unnecessary NPCs from the palette and then repopulated the area using copies from one blueprint. Added a script for the journal entry, and edited that entry to make it more concise. I may have solved the SetCameraMode issue by using a trigger, but I can't be sure without more testing, since beforehand it was only sometimes dropping into chasecam mode. I was about to change the peasant conversations from a one-liner to a random selection of one-liners, when I realized that the changes I made to the story means they probably aren't necessary. Well, strictly speaking I should have them say one line after the battle and a different line once they start walking, but that's too much work for something that probably won't come up.

I couldn't get a script using OBJECT_SELF to compile last night, but it turns out that may just be a quirk, since the script is working for other people who tested it. Also, I broke down and asked for a script that would count the NPCs left alive and then award XP based on that number. Someone responded, and now having seen the script, there's no way I would have figured it out on my own.

Thursday, August 17, 2006

Learning About Custom NPCs, Journal Writing

Finally got to do a little more work on the module last night. I'm starting to get the feeling that I may just have confine work to the weekends and days off. Revised the OnClientEnter script using part of Sir Elric's script, so now the PC loses, gains, and equips his gear all at the start of the module, and all in one script. Went on to do a lot of twiddling and tweaking of the NPCs in the next scene, and began to learn about the vagaries of "update all instances" and "edit copy." I changed the voiceset of my soldier from "Aasimar, Male" (the first on the list) to a more appropriate voice, and then did an update all instances. When I tested it, I discovered that not only did the voice not change, but the cutscene wasn't working again! I realized that changes I had made on the soldier I had painted down were not changes on the soldier in the palette, so when I updated, it changed the former to match up with the latter. As a result, the tag, faction, and voiceset all changed, which is why things weren't working.

After spending a long time fiddling with the various peasants and goblins in the second area, I realized I was doing it all wrong: instead of creating one model, painting it down several times, and then tweaking each model, I was making a new copy of each model on the palette and then painting it down. As such, I've got a bunch of unnecessary NPCs cluttering up my palette. I'm going to go back and fix that tonight, but that means I'll have to be careful about updating all instances in the future, so that I don't reset everyone again. Still can't get the peasant women and children to stop fighting the goblins though. Someone noted that there's a scene in the OC where peasants who are under attack don't fight back. I'll have to check that out.

Also wrote my first journal entry. That took a long time, because I suck at coming up with names for things on the fly. I got the first entry down, but didn't have the time to write the script that calls it when the PC enters the first area. I also accidentally deleted the script that sets the camera mode, and my attempt to recreate it didn't work. Someone suggested this may be a flaw in the game, and suggested I use a trigger instead of putting it in the OnEnter event. Another peson suggested putting a short delay on the command. I'll have to see if either works.

Saturday, August 12, 2006

Frustration, Then a Partial Rebound

Of the things I hate, one of them is not knowing how to do something I need to do, and another is not being able to figure out why something isn't working, especially when it looks like it should. That pretty much defined the first part of working on the module today. I wanted to write a single script that would destroy some of the items on the starting PC, then give him new items, and then finally equip those items. I didn't think it would be two hard; I already had one script to handle the item creation and another to handle the equiping of said items (albeit in seperate places), and they both worked, and the DestroyObject command looked pretty simple. Plus, the module I'm currently playing does the same thing, so I went in and copied the script the author used.

It turned out to be not easy ast all. The script from the module destroyed all the items, and I didn't want to destroy the PC's healing potions, so I added some code to create them along with the other items, but it didn't work. Also, I couldn't figure out how to combine the scripts - no matter what I tried, the PC wouldn't equip the items. So I had to split them again, and this time, since all the items were being destroyed in the first area, and the PC doesn't equip until the next area, there's a moment where he appears in his underwear, which was not what I wanted. And I still couldn't create the potions either. This put me in a very bad mood.

After taking a break for a while, I decided to try Lilac Soul's script generator. It couldn't write the full script, but I did have it write me a script to destroy a specific item. Then I replaced the destroy everything code with those lines, and it worked. In one stroke that solved both the potion and the nudity problem. I still have two scripts instead of one, and there's also a weird fluke where it looks like the PC hasn't equiped his armor even though he has, but at least it all works.

The next step was to put in a command to return to camera to top-down mode after the cutscene, since sometimes it would start the next scene in chase mode, with the camera right up against the PC's back. I don't know for sure if it worked, but so far, the camera has started in top-down mode every time, so I consider it a success. Next, I started tinkering with the first area (after the cutscene), in which a band of goblins and orcs attacks a group of peasants. I figured out how to make the peasants randomly say things when they're hit only 25% of the time (though in retrospect that's unnecessary, since they generally die after one hit). I also figured out how to fire a specific animation when they fall under attack. In the process I learned how to set multiple user-defined events and something about how the switch command works, though I ended up not needing it, since I decided to have both the speaking and the animation happen when the PC gets attacked. However, I couldn't figure out how to make some of the peasants not fight back. They're supposed to cower, but instead, I've got children and old people beating up goblins. I already asked about this on the forums, and I don't know why this won't work.

Finally, I did a lot of tweaking and fine tuning, and generally put in all the peasants and bad guys that I want in the scene. It's tough balancing it out though: presuming the PC acts, I want most of the peasants to survive. However, with too few monsters, they win too easily, and the PC doesn't have to help. Too many monsters, and most of the villagers get slaugtered, even when the PC does help. Also, while the peasant leader should die if the PC doesn't intervene, I do want to keep him alive as much as possible, since he gives a reward to the PC, and, in theory, other stuff will trigger off of him. Come to think of it, I should probably just make him unkillable, since I also need him to have a conversation that will trigger a journal update.

I checked the forum when I was done, and SirElric had written up a script that handled my problem. Unfortunately, although I'm sure it works, the scripting is too advanced for me to understand, which bums me out. However, I saw how he combined item creation with item equiping, so I can probably use that to turn my two scripts into one. Also, he explained why the potions weren't being created, although again, I don't entirely get it.

Looks like CEP 2.0 won't be out for a few more weeks. That's a bummer, because I basically have to use placeholder creatures until it does. I can't change the appearance of the Uruk-Hai, and I don't want to use the regular orcs, and there's no point trying to merge the hobgoblins hak now, since it might not work with CEP 2.0 (or the CEP might have something I can use, which would make importing something else a waste of time).

Thursday, August 10, 2006

Custom Content, Hakpak merging

Got started late again last night - weekdays are just not really ideal for getting any work done. By the time I get home and eat dinner, it's already late, and I'm usually kind of worn out by then. I really didn't do any work on the module. Instead, I just messed around with various haks. My original intention was to try to keep the custom content in my first module down to a minimum, but I started rethinking that yesterday. Partly that's because I'm playing two modules - Almraiven and Blackwall Keep - which both make effective use of a lot of custom content. Blackwall Keep uses a custom tileset to create a swamp that's better looking than any other I've seen. It also has custom items and custom rules for eating, drinking, resting, climbing, and fishing. Almraiven uses colored spell icons and custom rules for spell components, potion brewing, and money. It's also the most visually stunning module I've ever played (not that I've played a lot, but still). The use of custom placeables and the incredible attention to detail are just amazing, and it makes the game incredibly immersive - I just want to stand around and look at everything. My own efforts seem crude and feeble in comparison.

Playing these modules, and reading the comments on them (as well as from other things I've picked up) made me realize that players - especially veteran players - like custom content and are willing to download large haks. Aside from this, there are a number of haks that I'd like to use in this module. For instance, this ogre, and these fantastic dynamic goblins, which I had a lot of fun playing with last night (in fact, now that I've discovered dynamic creatures, I want to use them as much as possible) - they're definitely going in, as the Bioware models don't even come close. I'm also unhappy with the orcs in the game. The CEP does have a bunch of custom orcs, but most of them are modifications to the standard model, while the really cool ones are basically Uruk-Hai (right down to the white handprints), and I don't want something that obviously comes from LOTR, since the module isn't set in Middle-Earth. I tried using a custom orc hakpak, but I couldn't get it to work. So I might just go with these hobgoblins instead.

So in order to try and make this work, I decided to try to learn how to merge haks last night. Specifically, I tried to merge the DLA Ogre with the CEP, because I knew that they had conflicting 2da's, and I knew I'd have to learn it eventually. I read two tutorials on the subject, but they were somewhat confusing, and I didn't feel like I knew what I was doing. I found the non-matching lines, but I was sure what to copy into what and then what to do with it and so on. Ghostdreamer sent me a link to this utility, which makes 2da merging easier, but I'm still kind of shaky about the whole process.

As it turns out, I might be able to put much of this off for now anyway: it looks like CEP 2.0 is going to be coming out any day now, and it looks like they're going to be including a lot of the content that I either wanted to use in this module or in the future, including the DLA Ogre, so I won't have to worry about merging it. Not that this gets me off the hook entirely - the dynamic goblins work fine with the current CEP, but it's possible they might conflict with 2.0, and the Hobgoblins don't work with this version. So for now, I think I'm going to put off working on the module for the most part, until CEP 2.0 comes out. Then I'll see what new models are included, and from there I'll be able to decide what else I might want to use. Until then, there's still plenty I can do: I have a lot of scripting to do - specifically, I need to see if I can figure out how to make certain things work. My module is getting cluttered with scripts, many of which aren't currently in use, so I need to clean that up. I need to see if the custom tilesets I want to use are going to conflict, and if so, I have to merge them, and I still need to learn how to merge haks in general. And finally, I have plenty of reading to do as well.

Tuesday, August 08, 2006

Cutscene Perspective; Discipline

Wanted to get the cutscene done last night, but I got home late and, thus, got started late. Worked on the layout and physical features of the cutscene. I decided that I wanted a tower in the background because A) it would look dramatic and B) it made sense to me that the two armies would fight at some key area. As I sort of knew, the rural tileset didn't have much to offer, so I ended up using the Wizard's Tower placeable - which just looks like a tower, and not particularly wizardly - from the CEP. Then I decided that I wanted it on a hill, so I added the Hills of Wayland hakpak to the module, because I wanted the tower to sit on a gently sloping hill, rather than the chunky, squarish, built-in variety. Then I decided that the scene would look better if there was a forest behind the tower, so I started throwing in a bunch of tree placeables. I also wanted the battlefield to have a bleak, smoky, Excalibur-esque feel, so I spent a long time adding and removing various fire, smoke, and scorch mark placeables.

One of the things I quickly learned is that what you see in the toolset isn't necessarily what you're going to see in the cutscene. Because of the way I have the camera movements scripted, you don't even see the trees or tower or first. It's only as the camera swoops forward that they emerge out of the mist, along with the sky. It's a very nice, dramatic effect, but it also made me realize that a lot of the background stuff I was futzing with isn't going to be visible anyway. For instance, I wasn't happy with the fact that I couldn't place a pathway on the slope of the hill. There's actually a hak that would let me do this, but it looks like you have to have another hak to make it work, and the player probably wouldn't end up seeing it anyway.

When it comes to custom content, I'm finding that I need to have a lot of self-discipline. Although some modules use a lot of haks, I'm trying to keep this one relatively simple. Also, the more haks I include, the more likely I am to end up having them in conflict, which means I'd then have to go in and merge them. I'll have to learn how to do that anyway, but it's still something I want to avoid if possible. So whenever I see some cool piece of custom content, I ask myself if my module really needs it. Sure, the module will look cooler if, say, I use nothing but custom tilesets and placeables and so on, but for the first time out, I'm thinking it's better not to go overboard until I know exactly what I'm doing.

As it is, I might end up undoing all my work from last night. I don't know if I want a tower after all; the original vision was for an open battlefield, and the tower might be superfluous. If I dump that, I'll probably drop the Hills hakpak too. Yeah, they look good, but I don't really need them anywhere else. The landscape is supposed to be flat plains, and in the places where I do want hills, I actually want the rougher default style, rather than the gently sloping variety. However, I'm also going to try increasing the size of the area and moving the trees behind the keep. I'm hoping that'll make it look more like a distant forest. However, it's also possible that they simply won't be visible at all.

Sunday, August 06, 2006

The first post: A breakthrough

Started work on my module - currently entitled "Behind the Lines" - a few weeks ago, with only a rudimentary knowledge of the toolset and no idea how to do scripting. So of course, I decided to start with a cutscene. This is like trying to learn how to use Microsoft Office without knowing how to use Windows. Needless to say, I got frustrated very quickly, and realized that A) I needed to learn more about module building and B) Needed to learn scripting. There's no lack of resources for either, it was just a matter of picking the right one. I ended up going with The Hermit's Chalice, a tutorial that walked me through every step of building a fairly simple module, covering almost all of the basic stuff.

Once I was done, I went back to my module, and back to work on the cutscene, using the Gestalt Cutscene Scripting System. However, I couldn't quite get the cutscene to work right. The cutscene was supposed to show an army of humans and an army of orcs fighting with each other (I started with one of each). After 30 seconds, the human soldier was supposed to sound a retreat, and then run off with the orc hot on his heels. At first the problem was that the soldier and orc wouldn't do anything except fight. I fixed that with the help of John "Gestalt" Bye, the guy who wrote the system, but then the next problem was that he'd say his line, but not run off. I fixed that, but then hit a new problem: the two would fight, and then the soldier would say his line and then... sometimes he'd run off, sometimes he'd just stand there, and sometimes he'd run partway but then stop and turn around. Same thing with the orc. This left me baffled.

My three biggest obstacles when it comes to learning how to build are impatience, frustration, and inundation. When I want to know something, I want to know it now - I hate having to sift through tons of stuff to find out what I need to know. When something doesn't work, I get easily frustrated. The more I learn, the less this is a problem, but there were times this weekend when I just wanted to quit. And finally, just trying to find the right information can be overwhelming; not because there's too little, but because there's too much. There are dozens of tutorials, guides, FAQ's, and resources online. Trying to dig through them all is a pain. I spent much of Saturday looking at this stuff, only to discover at the end of the day that someone had compiled most of it into one document.

On the other hand, when I get the info I need to do what I want to do - or better yet, when I figure it out myself - I feel elated. For instance, I spent a lot of Saturday trying to figure out how to make NPC's randomly say something (from a list of possible sayings) without having anyone initiate a conversation. Someone in the forum posted a script which handled it, but by then, I had changed my plans: now I wanted the NPCs to randomly say something when they were hit by an enemy. I did some research, learned how to create user-defined events, adapted the script, and was able to figure out how to make this happen. I also found out how to put certain items in a PC's inventory when the game starts, and I figured out how to make him equip those items in the first area. Relatively minor stuff, but considering I didn't know a thing about scripting a week or two ago, it felt like a triumph. I've been slowly reading Celowin's Scripting Tutorial, and while I don't quite have a good handle yet on how to write my own scripts, at least I can now look at simpler scripts and understand what's going on in them. Sometimes.

And tonight, I made a breakthrough on the cutscene: after appealing to the community for help, Roybos, the author of Red Moon Rising - a great module that makes fantastic use of cutscenes - looked at my script and fixed it up. However, although it worked for him, when I tried it, my two combatants would simply stare at each other for 30 seconds before running off. I finally figured out the problem: my game was set on normal difficulty, and the two combatants were set to be part of the same faction. Normal rules don't allow player vs. player, so even though the script was telling them to fight, the game's restrictions were overriding it. Once I set my difficult to hardcore, the script worked the way it was supposed to. It feels really good to finally get past this.

Next up: populating the cutscene with my armies, and amending the script to handle all the NPCs. Also: figuring out how to destroy items on a PC, figuring out how to set the camera, figuring out how to have a PC receive an XP award based on the number of NPCs left alive in a scene, and figuring out how to make most of them leave the area once the award has been given.