Tuesday, 23 October 2012

Show Me The Way (Misbehaving Waypoints)

Before discussing this post's topic, I just wanted to let people know that The Althéa Weather System is now on version 1.03. The latest version fixes things such as cloud height and splash heights, and also has other effects added such as fog and dust storms. All these settings are easily adjustable for those with even basic scripting knowledge - and if used in conjunction with a module, can add some great atmosphere to an area.

The Wayward Patrol

I have started to work on creatures that players can encounter. This includes creatures that can be spawned via an encounter trigger and those already placed within an area at build time. As soon as I tested my first patrol of goblins, I encountered two problems:

1) The goblins did not drop what I expected them to drop according to their templates.
2) The goblins had their own ideas of where they wanted to patrol, even after I added waypoints!

Talk about creatures having a mind of their own! Unfortunately, this meant what little time I normally spend trying to build was spent sorting out more official campaign script. After some experimenting, I soon discovered that "spawned" creatures act differently to "placed" creatures when it came to identifying items in their loot drops. Eventually, I managed to update my own creature spawn and death scripts to ensure they only dropped what I wanted them to drop and identify (or not) the items accordingly. There is also a trick I learned from the forums that said to place items you want the creature to drop in their inventory (and mark as droppable) and to make sure all equipped items (like weapons and armour they use) are always marked non-drop. (If you want the creature to drop equipped items, you needed to give the creature a droppabel non-equipped version in their equipment as well.) Now, I just need to add a routine that differentiates between which items I may want the creature to be able to use in their inventory, like potions!

The second problem was more annoying, as I could nto see any reason why my goblins would not follow their waypoint path. And neither could I find out anybody else who had the same problems. So, it meant I had to write the script myself to make sure they stuck to their patrol path. This meant also having to change some of the minor functions that WalkWayPoints (the main function) uses, and so also change the way scripted waypoints worked for some of my other creatures. Thankfully, it is a simple enough task when done over a few days, but it is frustrating that it robs me of being able to do more plot writing. I hope to have the amended scripts finished soon.

Toolset Plugins

The funny thing about both of these issues I had, is that I was pointed to NWN2 Legends and the great work of Marshall as an alternative means to solve these issues. And if my own code had not already been written the way it has been, I think I would have delighted in using some of his systems designed as plugins to the toolset. However, as much as I would have liked to do so, I do not believe I can due to the fundamental differences between how our two games work. That said, however, I was so impressed by Marshall's plugins and what they could do, it did spur my own interest to look at plugins for the toolset again. Not just in implementing them, but maybe (if I ever get the time) actually designing some of my own to help me build the module more easily - and make tasks simpler. The problem is, my health limits me as to how much I can do, and if I do spend some time designing a plugin, I have to weigh up if the time spent making it will be rewarded in the time it helps save me in further module development. Thankfully, MS C# is a free downloadable program nowadays, and so the tools are there ... it now depends on its overall benefit.

The Opening Screen of MS C#
I have enjoyed programming for as long as I have had a computer and still have copies of The Pawn and Adlan (Adventure Language) for my old Amstrad. I even recall a database program I wrote in BASIC once (many years ago when I was fit and healthy in body and mind) that handled monster combat for my D&D pen and paper game. As C# seems very similar to NWN Script, I thought I might be able to try to combine a hobby of old with that of what I can still do now ... but, as I say, I am yet to convince myself that the time spent making a plugin will be worth it. Still, I like the idea, and if I ever have an extra burst of inspiration and enthusiasm, I may have a play and see where it takes me.

Monday, 8 October 2012

What's The Weather Like Outside?

As I was doing a test run on the module, I noticed it started to rain in the area. This was expected (as I had set it to rain), except that I felt it lacked the atmosphere I had hoped it would achieve. So I started to think about how I could improve on the basic rain settings and (thinking to save some time), I decided to check the Vault to see if anybody else had put together a weather system for NWN2.

After a quick search, I was pleased to find a few systems and briefly looked at each of them to see which would suit my needs. I found four systems that I may have been able to use, and thought the Abyssya Weather System seemed to be the best of the lot. However, once I looked at it more closely, I found a few bugs in the scripts and felt it was rather too cumbersome to implement easily. Don't get me wrong, I liked it and gave it a vote score of 7.00 (Very good. Deserves a look.) However, I hope the system I now offer to builders will be more useful from the point of view of being much easier to implement by being less cumbersome in code and more flexible in what it can do with just a little know how. You don't need to mess with the default settings, but if you have just a basic scripting knowledge, it offers a great deal of flexibility.

A stormy day at New Edgeton
The Althéa Weather System

After working out what I wanted the system to do, I managed to write the script as a single include file, called by one line from an area's ON CLIENT ENTER hook. From this call, the weather system is activated for the area in question, and the frequency of the weather checking can be modified from the default of every minute. A GLOBAL variable can be set at any time to change the weather to (currently) one of 12 weather conditions (if you include 0, which means SUNNY and no precipitation). Note, however, the system is flexible enough to allow a competent scriptor to add as many weather conditions as they want. Kamal even suggested a possibility of it raining frogs, which is possible with this system ... if you can design the "frog" VFX.

Furthermore, there are currently two area LOCAL variable settings available to allow the builder to set the weather for "desert" or "snow" regions, which limits the weather types to sun (no precipitation) and "downpour" (for the desert region) or "snow" instead of rain (for the snow region). Although, once again, a competent builder can alter their needs for an area and add it to the script easily enough. The system uses three types of snow: light, heavy and blizzard.

The system also manages seasonal changes. For instance, it is more likely to snow than rain in the winter months. The system also tries to keep weather directional flow as logical as possible. e.g. If it starts to rain lightly, it is more likely to continue to get worse before getting better, and vice-versa. The addition of "rain sounds" and "rain splashes", as well as the sound of distant thunder and nearby thunder claps (with lightning) all add to the immersive feel of the weather, adding atmosphere to any module that makes good use of it.

Note also that the script is very versatile and the VFX's used can all be altered if the builder prefers different settings. For example, the cloud effects (of which there is currently grey, dark grey and black) are all set to a height of 20 by default, which may be too low if you have many tall buildings in the area. It is easy enough to make these float higher, but bear in mind the higher you make them, the less the player will see on their display (unless looking upwards).

I will add this custom content to the pane on the left, under "My NWN2 Material", and for those who want a direct link to the Vault now, here is The Althéa Weather System. Below you can see a couple of video's as I was designing the system. The first shows how simple the weather can be changed, and the second shows the system with its clouds.

Recommendation: Switch to the HD video quality settings and allow buffer to fill before watching. Lower video settings you do not see the rain very well, or such things like the "splashes".

The Althéa Weather System - Showing Easy Switching

The Althéa Weather System - Showing Cloud Cover