** Generic Merchant Conversation with personalizations **
This collection of scripts and conversation will allow you to quickly add a
conversation to each of your merchants. Each
merchant will remember meeting the NPC, be able to open their own store, and a
conversation node will tell the player
what the store sells.
Each merchant's store must be called "<NPC Tag>_store". For example, a merchant
named "Nilin Menris" has a default tag
of "Nilin". Assuming you leave that as is, the store must have a tag of "Nilin_store".
Use:
1) Create your NPC and get his tag. I always leave it to the default of their
first name.
2) Create a conversation that is generic, but includes a custom token where the
description of the store will go. For
example, a barebones conversation tree goes like this:
[OWNER] Back again, eh? Would you like to see what I've got for sale today?
- Yes please. Let me see what you have.
- What sort of items do you sell?
- Why, I sell <CUSTOM101>
[OWNER] Greetings <sir/madam>. Can I interest you in some of my fine wares?
- I would certainly like to see what you've got.
- What sort of items do you sell?
- Why, I sell <CUSTOM101>
3) Add these scripts to the conversation:
// Put this in the "Text Appears when" of the first response
// It checks to see if they've already met
int StartingConditional()
{
string sNPC = GetTag(OBJECT_SELF);
string sVarName = "nMet_" + sNPC;
if(!(GetLocalInt(GetPCSpeaker(), sVarName) == 1))
return FALSE;
return TRUE;
}
// Put this in the "Actions Taken" of any root response that
// could result in the store being opened.
// This sets the local met variable on the Player, plus gets
// the store type for the merchant off their own local variable
// It's a bit redundant, but it was easier this way
void main()
{
string sNPC = GetTag(OBJECT_SELF);
string sVarName = "nMet_" + sNPC;
string sStoreDesc = GetLocalString(OBJECT_SELF, sStoreDesc);
// Set the variables
SetLocalInt(GetPCSpeaker(), sVarName, 1);
SetCustomToken(101, sStoreDesc);
}
// Put this in the "Actions Taken" of any response you want to
// have open the NPC's store
void main()
{
string sNPC = GetTag(OBJECT_SELF);
object oStore = GetNearestObjectByTag(sNPC + "_store");
// Either open the store with that tag or let the user know that no store
exists.
if(GetObjectType(oStore) == OBJECT_TYPE_STORE)
OpenStore(oStore, GetPCSpeaker());
else
ActionSpeakStringByStrRef(53090, TALKVOLUME_TALK);
}
4) Create the store, giving it a tag according to the instructions above (i.e. "Nilin_store").
5) Edit the NPC's OnSpawn script to add these lines:
// Store Description is stored on the NPC this way.
string sStoreDesc;
SetLocalString(OBJECT_SELF, sStoreDesc, "things for nature lovers.");
The text string is how the NPC will describe the store.
THe only potential disadvantage I've seen so far is if you want multiple
merchants to use the same store object. Then you
have to have merchants with the same tag. If all they do is stand around waiting
for players to talk to them, this
shouldn't be a problem though.