Monday, September 12, 2011

Adding "Things"


With the “outdoors” areas completed and connected via transitions, it was time to start working on the items that could be found and used in the game.  Most of these items “do” something so will need some scripts to make them behave as they were in the text version of the game.

The first four items are found in the building.  They are a lantern (needed to light the caverns and avoid a deadly fall); a set of keys (used to open various locks discovered later); a water bottle (initially full of water, but could carry other fluids as well); and some food.  Creating the items was an interesting exercise …

Initially, I wanted the objects to “look” somewhat like what they were when the player discovered them lying (or dropped them) on the ground.  The challenge was that in NWN and Project Q, many items (things that Players can pick up and put into their inventories) lack true models and use the default “loot bag” model.  I thought I could work around this by using “placeables” that have models but can’t be added to a Players inventory and then by some clever scripting, “swap” between the placeable and the item as the Player picked up or dropped the object.  This actually worked fairly well; but seemed sort of “clunky” with a lot of tracking of tags (the way the toolset identifies an object) and resrefs (blueprints used for creating an object).  After messing around with the bottle (empty, full of water, and full of oil); I could see that as the number of items increased this would become less appealing to me – and eventually I would encounter an object that just did not have a model (the ring of keys was already pushing the limits of my  imagination).

So, I settled on a much easier solution.  By placing the objects in containers, they would be easily recognized by their portraits.  If at a later time the Player dropped the item it would have its default loot bag model, but the Player would at least know what it was.  I am a big believer in “less is often more” when it comes to NWN mods; I prefer to add just enough details to suggest the image I am trying to create, and let the Player's imagination fill in the rest.  It keeps the game clean and simple; something that I like.

It was at this point, that my imagination was beginning to take over.  Why was there a package of food just sitting in building?  I thought it seemed rather artificial, so removed it; with the idea of substituting something else – say apples collected from a tree outside?  Yes, I liked that, gave a reason to do a bit of exploring outside as well.  I had also considered adding a fishing pole inside the building, with the idea being that it could be used to catch fish to serve the same purpose – but that seemed to be too much deviation from the original for my taste (perhaps in a later expansion …).  Another change I made was removing the water from the bottle.  You now find an empty bottle, which you can fill at the spring … again, I liked that and felt it was a nice, if subtle improvement.  And finally, just for fun (and perhaps offer a bit of a wake-up to those who are very familiar with the text version of the game), I decided to lock the door to the building and place the keys (the same ones found inside the building in the text game) under a rock near the doorstep – I thought this was in keeping with the spirit of the original game and would offer an early clue that things might be a bit different ….

One of the really neat things that was added to the NWN toolset coding, is the concept of “tag-based scripting”.  This allows a builder to easily attach scripts to objects by simply giving the script the same name as the object’s tag.  So, when an object is used or activated or even picked up or put down, the engine checks to see if a script has been attached to that object’s event and runs it if found.

To make the bottle work, I created three items that looked alike (a bottle, duh!) but had different names (and tags): Empty Bottle, Bottle of Water, and Bottle of Oil.  I also created an invisible object, making it usable, calling it a “Spring” and placing it inside the fountain.  The Player finds the empty bottle.  If the Player  “clicks” on the “Spring”, the mod checks to see if they have an Empty Bottle in their inventory; if so, it replaces it with a Bottle of Water.  The Bottle of Water is “usable” – it can be used on anything including the Player or even the ground (there are some puzzles in the caverns that require the use of water to solve).  When used, the Bottle of Water is replaced by an Empty Bottle.  For fun, if the Player uses the Bottle of Water on themselves they take a drink (including the animation).  The thought of using a bottle of oil on themselves called up images of Gladiators or “Grease Devils” who used oil/grease to make it more difficult for an opponent to grab them – this might find a use later in the caverns ….

I decided to give the apples a special property as well … you know the saying, “An apple a day, keeps the doctor away.”  I decided to give the apples a bit of healing power as the Player may take small amounts of damage from time to time and really, I don’t want to make resting “easy” while in the caverns.  The concern here is that the apples are needed to complete at least one of the puzzles, so I need to make sure they are always available; however the game has a built in mitigation – the Player can only have seven items in their inventory at any given time so it will require some traveling and doubtful that it will be exploitable to any degree.

The grate required a bit of scripting as well.  It is initially locked, and the keys found near the building open it using the normal Bioware script.  I had to create a simple script to see if the Player had unlocked it, and then move them from outside the grate to inside the caverns when they clicked on it.

Coming up: adding the descriptive text to the areas and handling some “housekeeping” routines to keep track of things …

No comments:

Post a Comment