You are here

Template Design (Advance Building)

Author: 
Genisys / Guile
Old Vault Category: 
other

In this tutorial, I'll be talking about designing template things, whether it's items, placeables, NPCs, or what have you.  Every great Template system requires you to use variables, as I explained in my Variables Preferred tutorial (For those who don't have a lot of scripting / building knowledge), and the reason variables are so powerful is, it allows us to create copies of something and use it in different ways.

Variables are accessible in different ways, under the "Description" tab for items or under the "Advanced Tab" for creatures, placeables, or waypoints, you'll find a little button with a bunch of periods [.....]  <<< like so or a [Variables] button, and this is the button you press to access the variables window for an object.  You can also right click on anything painted into the module and select "Variables" from the context menu that pops up.  But for the sake of simplicity, let's just refer to the picture that I uploaded for this tutorial to referrence what a variable's window looks like in the toolset.

The picture in this tutorial shows you how I setup the "Template Quiver"'s variables, it's a tagbased scripted item that I tend to put "tbsi_" in it's name because I build scripts that match it's name, which fires when the item is used, equipped, unequipped, acquired, unacquired, a spell is cast at it, or other similar tag based script events that fire for items with the same tagname as the script you create.  e.g. I created an item tagnamed "tbsi_quiver" then created a script with the same name that matches the tagname of the item. (e.g. "tbsi_quiver")

Tagbased scripting is the default x2 module event scripting system for items now, in the old days we had to create one script for ALL tagbased scripted item, and we are all very glad we can now create template scripts that help us build things faster. (Template Scripts go in your "template scripts" folder, located in your "nwn" folder.)  When designing templates, whether it's a script, a tagbased scripted item, or whatever, please be kind enough to thoroughly comment the script / item / placeable to help those using them understand how the variables / system works....

Here are the comments for the "tbsi_quiver" / Template Quiver...
Set the variable's  AMMO_RESREF  string   EnterResRefHere

to the ResRef of the ammunition you wish to create on the PC...

Set AMMO_STACK_SIZE  int  99   to the exact stack size count of the item...

NOTE: 2 Stacks are given to them with this quiver!
I'd use 99 for Arrows / Bolts / Bullets  & 50 for Shurikens / Throwing Axes / & Darts

 

As you can see from that comment example, it really helps the builder see how it works, without having to go back and referrence material (like a PDF or a module you had it in) in order to understand how the template system (placeable / item / etc)  works.   Here is the scripting I used for the template quiver, as you can see from the coding, it eliminates the need for redundant script making for each quiver / item creator, we want to create on the PC, in fact you can use this very same template quiver to be a host of other types of template items, like a Candy Dispenser for example, or whatever. :D

Template system are so awesome, I'd recommend the entire community jumping on the bandwagon to create as many templates as possible, because we can never have too much of these awesome creations!  Indeed, when I looked at my friend's module (Lord Lestat), I learned instantly about the critical importance of using variables & template system to handle a whole host of different things, like creature spawning,  handling doors, portal teleporting, or whatever!

There are so many things we can do with templates, like controlling systems through variables specifically tied to objects, areas, items, or whatever, this gives us better control, less scripting, and a way to replicate such objects as much as we want.  When I created my 1.69 Persistent Treasure System, I used waypoints as templates to spawn in treasure, the area's OnEnter event was used to cycle through all of the object in an area, and if it was a treasure chest it killed it, then looked at all of the waypoints in the area, and spawned in the treasure chest that was referrence in a variable on the waypoint, this allowed me to simply paint waypoints instead of treasure chest, it also allows me to use custom chest from the very same system. (Changing variable on a waypoint I paint is all that is needed other than creating the chest)

I wish I could explore this topic for hours, because it's very indepth, but on a final note, I'd encourage you all to discuss the topic more in the Scripting Section of the forums, I'd be happy to help anyone (Other scripters may be as well) who has questions on how to create a template script.  (Scripters / Builders love challenges)  Thanks for reading, hope you enjoyed it.

Genisys / Guile

Migrate Wizard: 
First Release: 
  • up
    100%
  • down
    0%
Genisys

Any Questions/Comments?

  • up
    50%
  • down
    50%