Author Topic: store  (Read 314 times)

Legacy_Builder__Anthony

  • Full Member
  • ***
  • Posts: 180
  • Karma: +0/-0
store
« on: June 15, 2012, 04:43:14 am »


               if oc has object 1 open store 1 if pc has item 2 open store 2
Spawn in npc merchant with random item that opens store



Basicly spawn in a npc with a random item and this way the merchant has a random store.Just aidea i threw out there if anyone codes it please post
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
store
« Reply #1 on: June 15, 2012, 09:43:00 am »


               If I understand correctly it sounds like you want to activate an item to spawn in an npc merchant and the merchant would depend on the item that you activated?

The way I would do it would be to use 1 tag based script for mutlitple items. So lets say for example you have 6 of these items. Give them all the same tag. When activated they will all fire the same script. But the script will check a string variable on the item and spawn in an NPC which has that res ref. So you would need 6 merchant blue prints and give each item a string variable that has a matching merchant res ref.

The script would just be something like so:

#include "x2_inc_switches"
void main()
{
    if (GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE) return;

    object oItem   = GetItemActivated();
    object oPC     = GetItemActivator();
    location lLoc  = GetLocation(oPC);
    string sResRef = GetLocalString(oItem, "MY_MERCHANT");

    //if you want just a store but no NPC then use these lines.
    //object oStore  = CreateObject(OBJECT_TYPE_STORE, sResRef, lLoc);
    //OpenStore(oStore, oPC);

    //if you want to spawn an NPC merchant who has a store then use this.
    object oNPC = CreateObject(OBJECT_TYPE_CREATURE, sResRef, lLoc);
}

You of course would still need to set up your merchants and what not. But with the script above you could also just bypass the NPC all together and just open a store right there. And you would just do that the same way you'd do with the merchant NPCs above.

Hope that makes sense.
               
               

               
            

Legacy_Builder__Anthony

  • Full Member
  • ***
  • Posts: 180
  • Karma: +0/-0
store
« Reply #2 on: June 15, 2012, 06:56:56 pm »


               actualy what i was saying was have 1 npc spawn in and check the random item he has spawned in with and get the resref from that to open a store.The item he spawns with controls which store opens.But i like your idea as well.I dont need this script but thought id throw the idea out there.