| Author |
Sticky:
Post Working Scripts Here |
|
oddbod
|
Posted: Monday, 29 July 04:49AM
|
** 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:
NWScript: [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:
NWScript:
int StartingConditional()
{
string sNPC = GetTag(OBJECT_SELF);
string sVarName = "nMet_" + sNPC;
if(!(GetLocalInt(GetPCSpeaker(), sVarName) == 1))
return FALSE;
return TRUE;
}
NWScript:
void main()
{
string sNPC = GetTag(OBJECT_SELF);
string sVarName = "nMet_" + sNPC;
string sStoreDesc = GetLocalString(OBJECT_SELF, sStoreDesc);
SetLocalInt(GetPCSpeaker(), sVarName, 1);
SetCustomToken(101, sStoreDesc);
}
NWScript:
void main()
{
string sNPC = GetTag(OBJECT_SELF);
object oStore = GetNearestObjectByTag(sNPC + "_store");
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:
NWScript:
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. |
|