### 1. Introduction

NWN Treasure Editor (NWN Treasure) provides the content creator with the ability to easily customize and augment the existing treasure tables provided by Bioware. It is a standalone application that produces NSS (NWN script source) files that are compiled by the existing NWN toolset.

If desired by the content provider, NWN Treasure editor will produce what is called "Shroudworld" style treasure tables. These advanced treasure tables provide automatic respawning of treasure chests, NPCs, and a few more advanced features.

Click here to download NWN Treasure

### 2. About Tables

#### What are Treasure/Encounter/Placeable Tables?

There are 3 types of tables in the NWN treasure editor program. Each type is used to spawn a specific item. All act exactly the same.

Tables are a road map to the creation of content. They tell what content to create. For example, a treasure table for a lowly goblin might include 1-6 gold pieces and a twenty percent chance of dropping a loaf of bread. Simple, right? Well, in reality, it is a bit more complicated.

Supplied with this program is a file called "nwn_default.xml". It contains treasure tables that emulate the treasure tables contained within NWN. It contains exactly 511 different treasure tables. Most of these treasure tables are only used internally. But it still underscores how complex treasure tables can be. Also supplied with this program is "nwtreas_demo.xml". It is a copy of "nwn_default.xml" with the addition of a new treasure table used by the "nwtreas_demo" module. Finally, there is "respawn_demo.xml" that contains sample placeable and encounter tables.

To understand exactly what a table is, let us compare it to a real life game that two friends might play. We will call these two friends Moe and Larry. Moe takes a deck of 3x5 index cards. On the top of each index card, he writes something for Larry to do or to look for (we will call this the "decision"). This could be flip a coin or see if there is a red car close by. The rest of the card is filled with commands that Larry will have to do depending on the results from what was written at the top of the card (we will call these the actions). These could be things such as "go home, game over" or "buy some gum". Now to make this game a little bit more interesting, the card could also tell Larry to go in search of another card that will give his more tasks to do.

So after a day of preparation, Moe calls Larry up and tells him, "I have placed 50 index cards at different location in the city. I want you to start by going to the General Store at the corner of Lexington and Main and ask the manager for the card." So Larry gets in his car and drives to the store and asks the manager for the card.

On the top of the card is written "Decision: Look at the people in the checkout lines and depending what you see, perform only one of the following actions." The actions are as follow:

1. If you see a woman with a child, then head over to the drug store on 10th street and ask the manager for your next card.

2. If you see a shopping cart with a broken wheel, then head over to the playground on Washington Ave. There you will find a card taped to the bottom of the slide.

3. If you didn't see either of those, get the dollar I gave to the manager, buy yourself a candy bar and go home. The game is over.

Even though Larry didn't see a woman with a child, he did see a shopping cart with a broken wheel. So he jumps into his car and heads to the playground. There he finds another card in a zip lock bag with a 6 sided die. Written on the card is "Decision: Roll the die and perform only one of the following actions." The actions are as follow:

1. If you roll a 1 or a 2, then head on over to the Mazda dealership 3 blocks down the road.

2. If you roll a 3, 4, or 5 then look under the 3rd swing seat and you will find 10 dollars. Take it and go home. Game over.

3. If you roll a 6, you lose, go home.

Luckily for Larry, he rolls a 4 and ends the game 10 dollars richer.

So how does this compare with tables?

Tables work the exact same way. Instead of an index card, we have a table. Instead of Moe, the content creator makes the tables. Instead of Larry, we have the script file executing the tables and creating the content.

#### Decisions and Actions

With tables, everything is based on decisions and actions. Every table has exactly one decision and zero or more actions.

The types of decisions are as follows:

1. Pick One Of - Given a list of actions, randomly pick one

2. Pick Multiple From - Given a list of actions, pick an action based on a percentage chance.

3. Pick By Racial Type - Pick an action based on the race of a creature, NPC, or PC

4. Pick By Level Range - Pick an action based on the level of the creature, NPC, or PC

5. Pick By Class - Pick an action based on if the creature, NPC, or PC is of a given class

6. Pick By Random Class - Pick an action based on a random choice between all 3 classes the creature, NPC or PC might possess.

7. Pick By Armor Proficiency - Pick an action based on if the creature, NPC, or PC is proficient in a weight of armor.

8. Pick By Weapon Focus - Pick an action based on if the creature, NPC, or PC is focused on a given weapon class.

9. Pick By Specific - Picks an action based on if a previous entry in the table requested that class specific treasure be generated. Otherwise, class generic treasure is generated. This is primarily used by the boss creature spawns.

The types of decisions supported by NWN Treasure was primarily dictated by what was required to emulate Bioware's existing tables.

The types of actions are as follows:

1. Drop nothing, stop creating treasure

2. Drop Gold

3. Drop an Item

4. Move to Table

With each type of action, the content creator must specify specifics about the treasure to be created. For example, in the case of an item, the blueprint name, and the number of items to create must be specified. For gold, the dice used to generate the amount of gold has to be specified. However, common to all actions, a single parameter that is specific to the decision being used must be specified. This tells the treasure generator under what circumstances this action is to be executed. For example, in the case of "Pick By Racial Type", the specific parameter might be "Human" or "Gnome".

#### Decisions in Depth

##### "Pick One Of"

(Valid with: treasure tables, encounter tables, and placeable tables)

When using the "Pick One Of" decision, a single random number is generated. That random number is used to decide which action is to be taken. It is important to remember, that with this decision, only one action will be taken. To provide more flexibility than each action having an equal chance of being chosen, each action is allowed to specify a "chance". This is a number between 0 and 9999. Prior to the random number being generated, the sum of all the chances for every action in the table is computed. Then the random number is generated and an action is chosen.

Example:

1. Chance 5: Create Gold

2. Chance 1: Create "Uber" Item

3. Chance 4: Do nothing

In this example, we have 3 actions. Each action has a chance assigned to it. The total of all the chances is 10. So, then a random number between 0 and 9 would be generated. If the number is 0-4, then gold is created. If the number is 5, then the "Uber" item is created. If the number is 6-9, then nothing is created.

Note: You are allowed to assign a chance of 0 to an action. You can see an example of this in the Bioware treasure tables. Initially, Bioware would generate random animal parts. In either March or May, it was decided that animal parts were just "too silly" and their chance was set to zero. In strange homage to Bioware and the old "that's just plain silly" Month Python sketch, I have left in the animal parts treasure table with the chance set to 0.

##### "Pick Multiple From"

(Valid with: treasure tables, encounter tables, and placeable tables)

The "Pick One Of" decision can be though of "Pick this or that". In the case of "Pick Multiple From", we have "Pick this, maybe. Oh and that too, maybe. Oh yes, and one of those, sort of." For each action, a random number is generated between 0 and 99. If the random number is less than the percent chance assigned to each action then that action is done. Each action is allowed to set a percent chance from 0 to 100. If the action has a percent chance of 0, then the action will never get taken. If the action has a percent chance of 100, it will always be taken.

Example:

1. Percent Chance 100: Create Gold

2. Percent Chance 30: Create "Uber" Item

3. Percent Chance 0: Create Animal Parts

In this example, we have 3 actions. The first action has a percentage chance of 100. It will always create gold. Then the next action is checked. If the random number generated is 0-29, then the "Uber" item is created. If the random number is 30-99, then the "Uber" item isn't created. Finally, since the "Animal Parts" has a 0 percent chance, then it will never get tested. A new random number is generated for each action.

Note: It is important to remember that EACH action will be checked. Thus each action has a chance of being taken.

##### "Pick By Racial Type"

(Valid with: treasure tables)

In Bioware's tables, the racial type was used to weed out treasure from certain creatures such as animals or undead. The create who's race is being tested can vary greatly depending on what situation the treasure is being generated. See the later section on the relatives of treasure generation. When the actions for a racial type decision are configured, a race must be specified for each action. You can also select the race of "Any" as a catch all for the final action. It is important to remember than any action listed after an action using "Any" will never get executed.

Example:

1. Undead: Do nothing

2. Animal: Do nothing

3. Orc: Go to the special orc treasure tables.

4. Any: Go to the standard treasure tables.

In this example, if our NPC is "Undead" or "Animal" (we can't be silly now), then no treasure is generated. If the race is "Orc" then we continue with treasure generation using a treasure table specific for orcs. Otherwise, our "Any" catches all other races and executes the standard treasure tables.

If you don't use "Any" at the end of your table, then if you NPC isn't one of the races listed, then no treasure will be generated.

##### "Pick By Level Range"

(Valid with: treasure tables)

"Pick By Level Range" allows the content provider to scale treasure based on the range of the NPC or characters. Currently, NWN Treasure uses the same level ranges as used by Bioware. However, a future enhancement might allow this to be configurable. The level ranges are as follows 0-5, 6-8, 9-10,11-13,14-16,17-100. Each of these level ranges are given numbers between 1-6 with 1 being levels 0-5 while 6 is levels 17-100. Each action must specify which level range it applies. Multiple actions can not be assigned the same level range. Well, they can be assigned the same range, but only the first one will be utilized.

Example:

1. Level Range 1: Give them a rock

2. Level Range 2: Give them a rusty dagger

3. Level Range 3: Give them a clean rusty dagger

4. Level Range 4: Give them a rusty dagger that has had the mileage rolled back in an attempt to sell it as new.

5. Level Range 5: Give them a new dagger

6. Level Range 6: Give them a new dagger, but one that doesn't fall apart on first use.

In this example, if the PC was level 12, that would equate to a level range of 4 and result in a "rusty dagger that has had...".

##### "Pick By Class/Random Class"

(Valid with: treasure tables)

"Pick By Class" and "Pick By Random Class" allows the content developer to chose treasure based on the class of the NPC or PC. The way that "Class" and "Random Class" differ is that with "Class" a character is tested to see if he has that class. With "Random Class" a random class based on levels from the 3 available classes of the character is chosen. Then based on that class, the different actions are selected. Like "Pick By Racial Type", this decision has available the catch-all of "any" to send the NPC or PC to default tables if they don't have the classes being tested.

Example:

1. Class FIGHTER: Give them a really big sword

2. Class THIEF: Give them a small sword

3. Class MONK: Give them a thank-you card and send them on their way

4. Class Any: Give all other classes 50 gold

First, let us take the case of a wizard and this is a "Pick By Class". The treasure generator would say, "Is he a fighter? No. Is he a thief? No. Is he a monk? No. Then give him 50 gold. Now, what if the take the case of a thief with a "Pick By Class". In this case, a short sword would be generated. What if the thief was a level 10 thief and a level 1 fighter and this was a pick by class? Then a really big sword would be created. A HAH!!! THAT SUCKS!!! Yes it does. That is why "Pick By Random Class" exists. Lets take the case of our level 10 thief and level 1 warrior, but this time, our decision is "Pick By Random Class". The treasure generator would look at the PC and see that he is a level 10 thief and a level 1 fighter. Then it would randomize a number between 0 and 10 (total of 11 which is the total number of hit dice for the character) and depending on the roll, it picks a class. 10 out of 11 times it will pick thief and 1 out of 11 times it will pick fighter. Then that randomly chosen class is used to search the action table. If we randomly chose a thief, the short sword would be created. Otherwise, the really big sword would be created.

Aside: It is interesting looking at Bioware's tables. They have a table called "table2". This table generates special class specific loot. It uses the random class to generate which class specific loot to create. However, if you look at the feat tables, it uses just the existence of a class on the character to make a decision. Admittedly, due to the way the feat tables are made, few characters will ever have their class used to generate feat treasure.

Note: Only the first action that matches the decision test will be executed.

##### "Pick By Armor Proficiency"

(Valid with: treasure tables)

"Pick By Armor Proficiency" allows to content provider to pick treasure based on the type of armor the character will probably ware. It is important that action are listed from heavy to light with the catch-all of "Any" listed last. This decision was included primarily for one treasure table in Bioware's treasure tables that needed to test to see if the ranger could use heavy armor. Rangers that have heavy armor proficiency use the fighter tables while rangers without use the barbarian tables.

Note: Only the first action that matches the decision test will be executed.

##### "Pick By Weapon Focus"

(Valid with: treasure tables)

"Pick By Weapon Focus" allows the content provider to pick treasure based on which weapon the PC has decided to focus on. "Any" is available as a catch-all.

##### "Pick By Specific"

(Valid with: treasure tables)

"Pick By Specific" is only used in Bioware's class specific treasure tables. Boss mobs use the specific tables to generate a better quality of class specific loot. The only two options for the actions are "Specific" and "Generic".

#### Actions in Depth

##### "Drop Nothing/Spawn Nothing"

(Valid with: treasure tables, encounter tables, and placeable tables)

When a "Drop Nothing/Spawn Nothing" action is reached then content generation is stopped for that part of the process. The only exception is cases where an action has it specified that a table is used multiple times to generate content. In that case, only that instance of content generation is stopped. Any remaining iterations will continue normally.

##### "Drop Gold"

(Valid with: treasure tables)

"Drop Gold" instructs the treasure generator to create some gold. Gold creation has 3 parameters, the number of dice, the die itself and a final multiplier. For example, a "Drop Gold" action might request 5d20*1.5. This translates into roll a d20 5 times and sum up all the values. Then multiply the final value by 1.5.

##### "Drop Item"

(Valid with: treasure tables)

"Drop Item" instructs the treasure generator to create an item. The blueprint of the item must be specified and MUST match a blueprint name in NWN or you module. Failure to specify a valid blueprint name will result in unpredictable results (i.e. the badgers of death). The number of items to create can also be defined using a range. If a range of "1-30" is specified, then between 1 and 30 copies of the item will be generated. The specific value will be randomized. If you specify a closed range such as "2-2", then 2 items will always be generated. At this point, if you specify more than one copy of non-stackable items, I don't know what will happen.

##### "Spawn Creature/NPC"

(Valid with: encounter tables)

"Spawn Creature/NPC" will spawn the given creature or NPC. The blueprint of the creature must be specified and MUST match a blueprint name in NWN or you module. Failure to specify a valid blueprint name will result in unpredictable results (i.e. the badgers of death). The number of creatures to spawn can also be defined using a range. If a range of "1-30" is specified, then between 1 and 30 copies of the creature will be generated. The specific value will be randomized. If you specify a closed range such as "2-2", then 2 items will always be generated.

##### "Spawn Placeable"

(Valid with: placeable tables)

"Spawn Placeable" will spawn the given placeable. The blueprint of the creature must be specified and MUST match a blueprint name in NWN or you module. Failure to specify a valid blueprint name will result in unpredictable results (i.e. the badgers of death).

##### "Move to Table"

(Valid with: treasure tables, encounter tables, and placeable tables)

"Move to Table" allows the content provider to chain together multiple decisions into one large table. For example, if you wanted a special table for rangers with heavy armor, then you would first have to have a table that "Pick By Class" to select all the rangers, and then a table that "Pick By Armor Proficiency" to select rangers with heavy armor.

Like "Drop Item", this action allows you to run the given table 1 or more times. If one run of the treasure table runs yields a "Drop Nothing/Spawn Nothing", then only that iteration will be stopped. All remaining iterations will continue.

Two other options for this action are available. The first is "Modifier". This option allows you to temporarily boost the level of the character for which treasure is being generated. Thus, any later decisions using "Pick By Level Range" will use the adjusted range. Modifiers are not cumulative. If you specify a zero, the modifier will be reset to zero. Most all actions of this type leave "Modifier" set to "Inherit". This option tells the treasure generator to leave the current modifier unadjusted.

The second option is "Specific". This option temporarily tells the treasure generator that any decisions using "Pick By Specific" should select the value specified. Most all actions of this type leave "Specific" set to "Inherit".

#### The Relatives of Treasure Generation

One very important concept to the treasure generation is for whom is the treasure being generated. In the case of NPC's, when they spawn, their treasure is generated relative to themselves. If they are a rogue, then any special class treasure will be generated for a rogue. In the case of treasure chests, the player who opened the chest or destroyed the chest is used to generate the treasure.

For multiplayer games, this is a very important thing to keep in mind. As is, treasure for chests will be generated primarily for the "lewt whores" who have to be the first who open the chest. (Yours truly included. Just ask Amberyll and Deeva.) This problem will be resolves in a future version of NWN Treasure.

### 3. Editing Tables

#### Creating New Tables

When you create a new table, you need to specify three things, the name of the table, the decision to be used, and if the table is global.

I STRONGLY suggest that all new table names are prefixed with something other than "nw_". For example, if Segal creates a few treasure tables for everyone to use in Shroudworld, he will prefix the treasure tables with "sw_". The ones he won't share might be prefixed with "swa_", which is the prefix for his module. For my module, my treasure tables are prefixed with "mk_".

The global flag is very important. If a table is marked as global, then it appears directly below the "XXXX Tables" entry in the tree. The icon has a small blue circle in the lower right hand corner. Global tables are always included in the exported script and have callable routines created for them. If you wish to invoke a table directly from a script, then you MUST mark that table as global.

In some cases you will see tables in root of the "XXXX Tables" along with your global tables. However, these tables have a small yellow question mark in the lower right hand corner of the icon. These are tables that have been created but are not marked as global and have not been referenced by any other tables. Non-global, unreferenced tables will not be included in the exported script.

#### Creating New Actions

One you have created a new table, you can start to add actions to the table. Selected the table and then use the "Insert In..." option to add a new action inside of the selected table. After the first action has been added, you can select the newly added action and then use "Insert After.." to create a new action after the selected action.

If your new action is "Move To Table", you can selected from an existing table or type the name of a new table. If you do type in the name of a new table you will be prompted to make sure that you wish to create a new table. If you do create a new table, the decision for the table will default to "Pick One Of". To change this, select the action you just added and select "Table Properties".

Note: Once an action has been created, you can not change the type of action.

#### Modifying Tables

Modifying table properties can be confusing. Tables in the root of the tree are easy to modify. However, tables that exist deep within the tree are more or less hidden. There isn't anything you can select that says "this is table nw_item_fighter_weapon_s_1". However, all "Move To Table" actions have a table associated with them. So if you want to change the properties of the table and not the action, select the "Move To Table" action in question and then press "Table Properties". This will allow you to change the decision and global flag settings for that table.

#### Moving Actions

Actions can not be moved from table to table. However, their order within a table can be changed. For some decisions, the order is very important. Any decision that has an "Any" option should always have the "Any" listed at the end. If you get your actions out of order, you can select the action you wish to move an then use the Up/Down commands to move them.

### 4. Using NWN Treasure

NWN Treasure is really two programs in one. The first program allows content providers to edit the default NWN treasure tables and then export a script file that is compatible with Bioware's "nw_o2_coninclude". The second part of NWN Treasure is by far much more powerful. It provides the core scripts for a complete NPC/Placeable respawn system that will also utilize the treasure tables.

So, before you can continue on, you have to ask yourself, do you want the full Shroudworld respawn system or do you just want to be able to edit your treasure tables.

### 4.1 Using NWN Treasure Just to Edit Treasure Tables

So, you have decided that all you want to do is create new treasure tables. Well, you still have one question to answer, do you want to use these new treasure tables for ALL your NPCs and treasure chests or just to new NPCs and treasure chests.

WARNING: Under NO circumstances should you EVER overwrite the scripts contained in NWN's override directory. Don't do it. JUST DON'T DO IT.

WARNING: When exporting scripts, you should not have that script open in the script editor.

WARNING: You can not just export files into your modules temp directory and expect the Bioware tools to know about them. The easiest thing to do is inside of the Bioware tools, create a blank script with the exact same name, save and then close the script. Then export to that file using NWN Treasure.

#### Exporting Your Treasure Tables

In order to be able to use your new treasure tables in your module, the first must be exported. If you haven't exported the treasure script to your module before, you must first create a new script in the NWN toolkit with the name of the file you wish to export. Close the script editor but keep the NWN toolkit loaded with your module open. Then in the NWN Treasure program, select the export option. Locate the newly created script in your "C:NeverwinterNights\NWN\Modules\tempxxx\" directory and save. (Note: The exact directory name will vary depending on where NWN was installed.)

#### Using Your Treasure Tables With NPCs

In order to have your NPCs use your new treasure table, you must create a new OnSpawn NPC script and assign that script to your NPC. Using the default NPC OnSpawn script as a starting point, the following changes must be made. (Remember, save to a different file name)

1. Locate the line "#include "nw_o2_coninclude"" and replace "nw_o2_coninclude" with the name of the script you exported.

2. Locate the line "GenerateNPCTreasure ()" and replace it with a call to the treasure table of your choice.

For example:

> Let us assume you have created a treasure table called "my_phatlewt". In order to generate treasure on a NPC using that table, you would make the following call.

> CT_my_phatlewt (OBJECT_SELF, OBJECT_SELF);

#### Using Your Treasure Tables With Placeables

In order to have your placeables use your new treasure table, you must create a new OnOpen and OnClose placeables script and assign this script to your placeable. In almost all cases, both the OnOpen and OnClose scripts can be the exact same script. Using on of the default NWN OnOpen scripts such as "nw_o2_classmed" as a starting point, make the following changes. (Remember, save to a different file name)

1. Locate the line "#include "nw_o2_coninclude"" and replace "nw_o2_coninclude" with the name of the script you exported.

2. Locate the line "GenerateXXXTreasure ()" and replace it with a call to the treasure table of your choice.

For example:

> Let us assume you have created a treasure table called "my_phatlewt". In order to generate treasure on a placeable using that table, you would make the following call.

> CT_my_phatlewt (GetLastOpener (), OBJECT_SELF);

### 4.2 Using NWN Treasure With Shroudworld Style Respawn

So, you have decided use all the features available in NWN Treasure.

WARNING: Under NO circumstances should you EVER overwrite the scripts contained in NWN's override directory. Don't do it. JUST DON'T DO IT.

WARNING: When exporting scripts, you should not have that script open in the script editor.

WARNING: You can not just export files into your modules temp directory and expect the Bioware tools to know about them. The easiest thing to do is inside of the Bioware tools, create a blank script with the exact same name, save and then close the script. Then export to that file using NWN Treasure.

#### Exporting Your Treasure Tables

In order to be able to use your new treasure tables in your module, the first must be exported. If you haven't exported the treasure script to your module before, you must first create a new script in the NWN toolkit with the name of the file you wish to export. Close the script editor but keep the NWN toolkit loaded with your module open. Then in the NWN Treasure program, select the export option. Locate the newly created script in your "C:NeverwinterNights\NWN\Modules\tempxxx\" directory and save. (Note: The exact directory name will vary depending on where NWN was installed.)

When exporting for Shroudworld, make sure you select the "Shroudworld" mode in the export dialog box.

#### Using the Shroudworld Respawn System

At the time of this writing, all content for Shroudworld will be combined into a single module. However, since not all content will be using all the features of the respawner, content providers who use the respawner won't be able to depend on the NWN default scripts being modified for use with the respawner. Thus, NPCs and placeables that wish to use the respawner MUST make new blueprints that use specialized scripts.

The good news is that only three scripts need to be created; NPC OnSpawn, NPC OnDeath, and placeable OnOpen/OnClose.

#### Creating a new NPC OnSpawn

In order to have your NPCs use the respawner, you must create a new OnSpawn NPC script and assign that script to your NPC blueprints. Using the default NPC OnSpawn script as a starting point, the following changes must be made. (Remember, save to a different file name)

1. Locate the line "#include "nw_o2_coninclude"" and replace "nw_o2_coninclude" with "sw_i0_treasure".

2. Locate the line "GenerateNPCTreasure ()" and replace it with a call to "DoNPCSpawn ();".

#### Creating a new NPC OnDeath

In order to have your NPCs use the respawner, you must create a new OnDeath NPC script and assign that script to your NPC blueprints. Using the default NPC OnDeath script as a starting point, the following changes must be made. (Remember, save to a different file name)

1. Add a new include, "#include "sw_i0_treasure"".

2. Prior to the "NW_I_AM_DEAD" shout line, add a call to "DoNPCDeath ();"

#### Creating a new Placeable OnOpen/OnClose

In order to have your placeables use the respawner, you must create a new OnOpen/OnClose placeable script and assign that script to your placeable blueprints. Using the default placeable OnOpen/OnClose script as a starting point, the following changes must be made. (Remember, save to a different file name)

1. Locate the line "#include "nw_o2_coninclude"" and replace "nw_o2_coninclude" with "sw_i0_treasure".

2. Replace ALL of the code in the main routine, but leave the main and surrounding "{}", with a call to "DoOpenDeath ();"

If you wish for all your placeables to have a default treasure, the add the following line prior to the call to "DoOpenDeath".

SetLocalString (OBJECT_SELF, "SW_RS_DEFAULT_PROFILE", "mytablename");

#### Using Your Treasure Tables With Placeables

In order to have your placeables use your new treasure table, you must create a new OnOpen and OnClose placeables script and assign this script to your placeable. In almost all cases, both the OnOpen and OnClose scripts can be the exact same script. Using on of the default NWN OnOpen scripts such as "nw_o2_classmed" as a starting point, make the following changes. (Remember, save to a different file name)

1. Locate the line "#include "nw_o2_coninclude"" and replace "nw_o2_coninclude" with the name of the script you exported.

2. Locate the line "GenerateXXXTreasure ()" and replace it with a call to the treasure table of your choice.

For example:

> Let us assume you have created a treasure table called "my_phatlewt". In order to generate treasure on a placeable using that table, you would make the following call.

> CT_my_phatlewt (GetLastOpener (), OBJECT_SELF);

#### Telling NWN Treasure what script to execute

In order for NWN Treasure to know what script to execute, you must assign a local string to each of your areas. Inside the OnModuleLoad, use the following example to set the treasure script for an area:

> object oArea = GetObjectByTag ("MY_AREA_NAME");
> SetLocalString (oArea, "SW_RS_SCRIPT", "my_treasure");

#### Telling NWN Treasure a default respawn time

Be default, NWN Treasure will default to a respawn time of 30 seconds. If you wish to change this for an area, then the local integer "SW_RS_RESPAWN_DEFTIME" must be set to the number of seconds. This value must be non-zero.

> object oArea = GetObjectByTag ("MY_AREA_NAME");
> SetLocalInt (oArea, "SW_RS_RESPAWN_DEFTIME", 10);

#### Setting Up Respawn and Treasure on Your NPCs and chests

By default, treasure will be created the same way that the original treasure tables make treasure for NPCs and chests. (Unless you have modified the treasure tables). Containers that use "nw_o2_classmed" will still generate medium level treasure. NPCs will still generate low level NPC treasure.

However, respawning the NPCs and containers is a big issue. All respawned content MUST come from existing blueprints. If you place an NPC in your module, customize it heavily but do not create a new blueprint with all the modifications, that NPC will not respawn properly.

Instead of going into great detail about how everything works, let us look at examples on how to set things up.

### 5. How to do Different Things with the Shroudworld Respawn

#### 5.1. I want this NPC/Container I got from the NWN palette to respawn automatically

One of the nice things is that for NPCs, all the tag names are the same as the blueprint names. So, unless the tag name is different than the blueprint name, you are done. However, this is not the case for containers.

If the tag name is different, then modify the tag name on the NPC/Container placed in your module. Set the tag to be the same as the blueprint name found on the advanced tab. You will NOT need to add this modified creature/container to your palette. The respawn system will remember the tag name for future respawns.

#### 5.2. I want this NPC/Container I got from the NWN palette to respawn automatically, but I want to customize it.

If you want to customize the look of your NPC/Container or add such things as traps and have them respawn, then you MUST add the new NPC/Container to the palette.

Place the NPC/Container in your module. Make all the customizations required. Change the tag to make the name that you will use for the blueprint name in the palette. Add the NPC/Container to the palette. Make SURE you set the blueprint name (advanced tab) to match the name used for the tag.

#### 5.3. I want this NPC/Container, but I think the loot sucks. Can I change it to use a different treasure name?

Yes. Place the NPC/Container in your module. Edit the tag name and add at the beginning the name of the treasure table followed by two underscores.

For example, let us say this is an NPC with the tag and blueprint of "PHATGUARD". By default, all NPCs use the "nw_npc_low" treasure table. If you want this NPC to drop high level loot, then you can change his tag to "nw_high__PHATGUARD". The respawn system is smart enough to see the loot table name at the start and then use the second part as the blue print name.

#### 5.4. I have a blueprint called "MYGUARD" that I use for my waypoints and posts. I have modified their tag so they use the waypoints or posts that I want them to. But the respawn system always gives me badgers.

The problem is that if you have a blueprint called "MYGUARD" but have modified all instances of that blueprint with tags such as "GUARDWPSET1" and "GUARDPOSTA", the respawn engine doesn't have a clue what to spawn. Thus the game creates badgers. Why badgers? I don't know. But that is only half the problem. The respawn system does have a method of telling it that when it sees a specific tag to then use what is called a "profile" to determine how to respawn the NPC. But if this was used in this case, all respawned guards would lose their specific tags (they would be spawned with the tag from the blueprint). They would fail to work.

The only way to get around this problem is that for every waypoint set and every post, a new blueprint must be made with the tag set to the name of the waypoint set or post and the blueprint name matching that tag. It really isn't a good solution, but at the moment there is little that can be done short of replacing the waypoint system.

#### 5.5. How do I use a specific treasure table for my NWN encounters?

Now we are starting to get into a feature in NWN Treasure called profiles. This allows the content developer to define treasure tables and other respawn information for a mob with a given name.

For example, let us assume your encounter spawned mobs with a tag of "NW_DEER". Inside of NWN Treasure, create a new profile and call it "nw_deer". Leave all fields as default except the treasure table. Change that setting to what you wish it to be and save. Export and recompile the script and you are done.

#### 5.6. How do I create my own treasure table

Go into the treasure editor, select "Treasure Tables" and click on "Insert Table". Give the table a name such as "sw_sewer". Check the global checkbox and give the table a number. Export and recompile the script.

See #3 for more information on changing the loot table for an NPC/Container. Or if you need to use a profile, then change the treasure table setting for the profile to your new treasure table.

#### 5.7. How do I have a creature spawn when a treasure chest is open

This is another example of where you have to use the profiles in NWN Treasure. Create a new profile give it a name. If you use the same name as the tag name used by the container's blueprint, then ALL containers using that blueprint will use this profile. If you just want it for a few chests, then give the profile a unique name that doesn't match any tag name in your module.

Next, set the "Death/Open Spawn" setting to the blueprint of the mod you wish to spawn or the name of an encounter table. If you want a sound to play, set the name of the sound without the ".wav". If you want damage to be dealt, then set a value larger than 0.

Next, if you will have to change the container's tag to match the profile name, then you will need to set the respawn blueprint name to the name of the blueprint used to respawn the container. Export and recompile the script.

Place the container in your module. If your profile name doesn't match the tag of the container, then change the tag to the name of the profile. The respawn system will remember this even after the container has been respawned and the tag lost.

#### 5.8. Can I have a creature spawn when my NPC is killed?

Yes, follow the exact same steps for question 7.

#### 5.9. Can I create a default treasure for the whole area?

Currently, if you want to create a default treasure for the whole area, then you MUST use area specific treasure tables (see the instructions from when you added Shroudworld respawning to your module.)

Next, you will need to create a new profile in NWN Treasure. Call this profile "*". That tells the respawn system that this profile is to be used for all objects that don't have a profile defined. IT IS VERY IMPORTANT THAT THIS IS THE LAST PROFILE IN THE LIST. Use the move down button to move it to the bottom.

In the profile, set the treasure table to the name of the table you want to use. If you want no treasure to drop, set it to "nw_none". Now, this will apply to all NPCs and containers unless they have their own profile or unless they have a treasure table encoded in their tag such as "nw_high__NW_DEER".