Edit Page
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
+ | == What it does == |
||
− | '''Animatronic store''' is a [[script]] that causes a [[non-player character|NPC]] to approach a [[player character|PC]], say something, then open a [[store]] whenever the PC uses (clicks on) a special [[placeable]]. The contents of the store are randomly generated and replenished over time. |
||
+ | '''Animatronic Store''': You click the [[placeable]] "[[container]]", the [[NPC]] comes over, says whatever [[conversation|speil]] you like and opens the store. |
||
+ | The script also randomly generates the contents (5 types) and replenishes over time, if needed. It is compatible with regular merchants. |
||
− | == Configuration == |
||
+ | |||
− | The elements a [[module]] needs in order to make use of this script are |
||
+ | == Setting up the script == |
||
⚫ | |||
+ | Scripts needed: 2 |
||
− | * an NPC to initiate the dialog, |
||
+ | |||
− | * a placeable for PCs to click, and |
||
+ | Items needed: |
||
⚫ | |||
+ | * You need an NPC with the word "seller" in its [[tag]] and the second [[script]] in it's conversation. |
||
− | To make the script work, some guidelines must be followed. The NPC must have the word "seller" in its [[tag]], and the placeable should have one of six keywords in its tag ("CLASS", "ARCANE", "DIVINE", "AMMO", "POTION", or "KIT"). In addition, the placeable must be useable with no inventory, and probably should be flagged as [[plot]]. The dialog does not need to be assigned to the NPC in the [[Toolset]], but should end with a line like "Do you want to see these?", for which the second script below is the "Actions Taken" script. Finally, the merchant object needs to be placed near the placeable. |
||
+ | * You need a placeable set to plot and useable with no [[inventory]], that should have one of 5 words in its tag (see script). |
||
⚫ | |||
+ | * a merchant placed near the placeable. |
||
== How it works == |
== How it works == |
||
+ | Basically, the script uses the tag of the placeable to determine how to stock the nearest store. Since it uses the standard [[NWN]] treasure charts the [[class]] and [[level]] of the seller also affect stocking. |
||
− | The script stocks the nearest store using the standard (non-expansion) treasure system included in NWN, based on the keyword in the placeable's tag. This treasure system often factors a character's [[class]] and [[character level|level]] into which items are created; for this script, it is the NPC's class and level that affect the items. Next, the NPC moves to the PC and starts the "basic_merchant" conversation, which ends with the newly-stocked store being opened. |
||
+ | Once the placeable is properly stocked, the nearest designated salesman is called over and his conversation starts. |
||
⚫ | |||
+ | I found that I had to add an option in his conversation to ask him to back up, otherwise s/he tends to trap characters in corners. |
||
− | This script is to be the container's [[OnUsed event]] [[event handler|handler]]. |
||
+ | |||
⚫ | |||
+ | This goes in the container's on_use (note the container will not have an inventory!) |
||
<pre> |
<pre> |
||
#include "nw_o2_coninclude" |
#include "nw_o2_coninclude" |
||
− | |||
// Generate treasure routine modified from guess where |
// Generate treasure routine modified from guess where |
||
void GenerateStock(int nNumberItems, object oSeller, object oStore) |
void GenerateStock(int nNumberItems, object oSeller, object oStore) |
||
{ |
{ |
||
− | + | // there are 5 basic types of store. The tag should include one of the 5 words below |
|
⚫ | |||
− | // The tag should include one of the 6 words below. |
||
⚫ | |||
⚫ | |||
− | + | else if (FindSubString( GetTag(oStore),"ARCANE")>=0) {nType=1;} |
|
+ | else if (FindSubString(GetTag(oStore),"DIVINE")>=0) {nType=2;} |
||
⚫ | |||
− | + | else if (FindSubString(GetTag(oStore),"AMMO")>=0) {nType=3;} |
|
+ | else if (FindSubString(GetTag(oStore),"POTION")>=0) {nType=4;} |
||
− | nType=1; |
||
− | + | else if (FindSubString(GetTag(oStore),"KIT")>=0) {nType=5;} |
|
⚫ | |||
− | nType=2; |
||
⚫ | |||
⚫ | |||
⚫ | |||
− | nType=3; |
||
− | + | case 0: {CreateTable2Item(oStore, oSeller, 0); break; } |
|
⚫ | |||
− | nType=4; |
||
− | + | case 2: {CreateDivineScroll(oStore, oSeller); break; } |
|
⚫ | |||
− | nType=5; |
||
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | { |
||
− | switch(nType) |
||
− | { |
||
− | case 0: CreateTable2Item(oStore, oSeller, 0); break; |
||
⚫ | |||
− | case 2: CreateDivineScroll(oStore, oSeller); break; |
||
⚫ | |||
⚫ | |||
⚫ | |||
} |
} |
||
} |
} |
||
+ | //dbSpeak("Generate Treasure nSpecific = 0"); |
||
} |
} |
||
− | |||
− | |||
void main() |
void main() |
||
{ |
{ |
||
− | + | object oPC; |
|
+ | oPC = GetLastUsedBy(); |
||
⚫ | |||
− | + | if (!GetIsObjectValid(oPC)) { oPC = GetLastOpenedBy(); } |
|
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | while ( GetIsObjectValid(oSeller) ) |
||
⚫ | |||
− | { |
||
⚫ | |||
− | break; |
||
⚫ | |||
⚫ | |||
} |
} |
||
⚫ | |||
− | |||
⚫ | |||
− | // Store the merchant object. |
||
⚫ | |||
⚫ | |||
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | while ( GetIsObjectValid(oItem) ) |
||
⚫ | |||
− | { |
||
⚫ | |||
− | nNth++; |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
} |
} |
||
+ | // END RESTOCKING * |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | { |
||
⚫ | |||
⚫ | |||
− | } |
||
− | // END Restocking. |
||
− | |||
⚫ | |||
⚫ | |||
⚫ | |||
} |
} |
||
</pre> |
</pre> |
||
− | == Script 2 == |
+ | == The Script, Part 2 == |
− | This script |
+ | This goes in the conversation script. Note that the previous script will start the conversation. It is set up for a resref "basic_merchant" for the conversation. |
<pre> |
<pre> |
||
void main() |
void main() |
||
{ |
{ |
||
− | + | object oPC = GetPCSpeaker(); |
|
− | + | object oStore = GetLocalObject( oPC, "Store_at" ); |
|
⚫ | |||
− | |||
⚫ | |||
− | OpenStore(oStore, oPC); |
||
} |
} |
||
+ | |||
</pre> |
</pre> |
||
== Notes == |
== Notes == |
||
+ | *I should also mention that the merchant conversation this script uses isn't necessarily (and probably isn't) the conversation the Seller uses when you click on it. It's simply a script that says something like "Do you want to see these?" or some such generic store opening question. After using it awhile I'm sonsidering have it be a one-liner and use OpenStore immediately. |
||
− | * It is possible to merge the two scripts, eliminating the "basic_merchat" conversation. (Instead of a full-fledged conversation, the NPC would be made to speak a one-liner.) |
||
− | * The original version of this script is by WyrmSoul, and was posted in the BioWare fourms [http://nwn.bioware.com/forums/viewpost.html?topic=116828&post=1194053&forum=63 here]. |
||
− | [[category: |
+ | [[category:Script_directory:Merchants]] |