Page 1 of 1

Merchant Scripting

Posted: Fri Oct 29, 2004 2:40 pm
by 4x4_Ender
From the Subcontractor Forum:
Krator wrote:
4x4_Ender wrote:One more question:

Is it possible for the store to identify a PC's plot guild item and, if that PC posesses one, open a different store inventory for them??
That will be quite easy to include in the conversation that opens the store.
I dont know where to begin to do this. Im guessing you use the GetItemPossesedby() command to determine if the PCis carrying the necessary item. But, do you have to create two different stores? Or, does the store need to be created from the script itself and have one of two scripted inventories based on if the PC has the item or not?

Im a horrible coder, but i think this should be pretty basic so some help here would be appreciated. 8) [/quote]

Posted: Fri Oct 29, 2004 2:48 pm
by Krator
Your conversation needs to look like this: (And yes, you need two stores)

Code: Select all

NPC Hello!
    PC Open Store
         NPC You have the item so you get 1337 items (Text Appears When Script, see below, and Actions Taken Script from scriptwizard to open store 1)
         NPC Ok. (Actions Taken Script from scriptwizard to open store 2!)

For the script: Use this (Not the best way, but it works :P)
This goes into the Text Appears When of the conversation part that opens the store for PCs that have the item. Place the appropiate script in Actions Taken.
Tip: Use Lilac Soul script generator, it sucks, but you can learn much from it. It was my first scripting too.
(This is a part of a script I had somewhere, some things might be useless)

Code: Select all

int StartingConditional()
{
object oPC = GetPCSpeaker();
object oItem = GetFirstItemInInventory(oPC);
int nObjectCount;
while (GetIsObjectValid(oItem))
{
  if(GetTag(oItem)=="/*tag of item goes here*/")
        nObjectCount++;

  oItem = GetNextItemInInventory(oPC);
}
if (nObjectCount==1)
return TRUE;
else
return FALSE;
}

Posted: Fri Oct 29, 2004 2:58 pm
by Mistcaller
I have done the same before with the Scholar's innkeeper in deglos. Here is some generic script to use in the ActionTaken tab when the PC asks to see the store (you should have already created 2 store objects):

Code: Select all

void main()
{ 
object oPC = GetPCSpeaker(); 
object oItem = GetItemPossessedBy(oPC, "YourItemTag");
object oStore1 = GetNearestObjectByTag("INV_YourStoreA");
object oStore2 = GetNearestObjectByTag("INV_YourStoreB");

if (GetIsObjectValid(oItem)) 
   OpenStore(oStore1, oPC);
else
   OpenStore(oStore2, oPC);
}
You'd like perhaps to take a look in the OpenStore command description for more details.

Posted: Fri Oct 29, 2004 3:00 pm
by Krator
Mistcaller pwns me. Use his thing.

Posted: Fri Oct 29, 2004 3:24 pm
by 4x4_Ender
Krator wrote:Mistcaller pwns me. Use his thing.
LOL, he pwns eveyone, so dont feel bad. Thans for the help both of you.

Posted: Fri Oct 29, 2004 3:31 pm
by Mistcaller
4x4_Ender wrote:
Krator wrote:Mistcaller pwns me. Use his thing.
LOL, he pwns eveyone, so dont feel bad. Thans for the help both of you.
Hehe.. Bah.. I'm still a "whiney peasant" in scripting.. :)

Posted: Sun Oct 31, 2004 11:12 pm
by 4x4_Ender
Ok, i got midnight's method to work. But, i want to change how this works slightly. Under the current method, the script activates all at once after a single PC quote in the conversation is clicked on, causing the appropriate store to open immediatly after the script checks for the item tag.

But, what i want to have happen is for the script to check for the item tag, and have the conversation move to 1 of 2 different lines of NPC quote based on the result of checking for the item. After the NPC finishes this line of conversation, THEN the appropriate store opens.

What i think needs to be done for this modification is to move the script to the "Text appears when..." tabs for each of the two different lines of conversation, and move the OpenStore() lines in the script to the "Actions Taken" tab as a seperate script.

The problem is the "Text appears when..." script needs to be in this form apparently, which is what is in the blank script rather than void main:

Code: Select all

int StartingConditional()
{
    int iResult;

    iResult = <<PLACE THE CONDITIONAL HERE>>;
    return iResult;
}
So, how do i use this to activate the text based on whether the object the original script got is valid or not?

Posted: Mon Nov 01, 2004 12:08 am
by 4x4_Ender
Nevermind, i figured it out. :oops:

Posted: Mon Nov 01, 2004 1:07 am
by Drakuul
Bunny with a pancake on his head! I love you 4x4!

Posted: Mon Nov 01, 2004 1:26 am
by 4x4_Ender
Drakuul wrote:Bunny with a pancake on his head! I love you 4x4!
:P