Author Topic: Merchant sells items based on your level  (Read 495 times)

Legacy_AmbrosiaPW

  • Jr. Member
  • **
  • Posts: 70
  • Karma: +0/-0
Merchant sells items based on your level
« on: April 27, 2011, 04:41:43 pm »


               Hello, I am modifying an existing module that is heavily scripted. Merchants have way points. One for moderate faction, one for good faction. When you speak to the merchant, they do a faction check.

Normal Faction: Hi, buy my stuff. :Open Store1_tag
Good Faction: Hi, buy my stuff. :Open Store2_tag

Then in the inventory of the merchant there are the items the merchant sells.

I don't need to use this system. I don't have to check for factions. I can just create my own merchants for this, but I want a level 1 PC to see normal items and then around level 6 the merchant should show +1 items. Level 12ish +2 etc.

Can you guys point me in the right dfirection please? Do I have more than one inventory for one merchant? Do I make copies of the merchant and point to the one whose inventory has the correct items for the PC's level?

I've searched and searched and am having trouble finding the logic to accomplish this with.

Thank you for your help. 
               
               

               
            

Legacy_Ryuhi2000

  • Full Member
  • ***
  • Posts: 159
  • Karma: +0/-0
Merchant sells items based on your level
« Reply #1 on: April 27, 2011, 04:59:21 pm »


               im pretty sure youd want to make a additonal shop for each level  and to have them launch from  the same npc you would need to do a text appears when script based on the players level.

you might want to say Open Level X Shop
X being the level of the character

edit: you would need to place the additonal shops in the area
               
               

               


                     Modifié par Ryuhi2000, 27 avril 2011 - 04:02 .
                     
                  


            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
Merchant sells items based on your level
« Reply #2 on: April 27, 2011, 05:45:04 pm »


               You could use a single store opening script to be called from the conversation (and the same line of the conversation).  In the script itself, have it check the PC's character level with GetHitDice(), then check the merchant NPC for the tag of the level-dependent store (stored as string integers) and open that one.

Example:
NPC: Sam the Sword Seller
- on Sam, you set a variable for each PC level (or range of levels)
- - PC_SHOP_LVL_1  string   samswordsellerlvl1
- - PC_SHOP_LVL_2  string   samswordsellerlvl1
- - PC_SHOP_LVL_3  string   samswordsellerlvl1
- - PC_SHOP_LVL_4  string   samswordsellerlvl1
- - PC_SHOP_LVL_5  string   samswordsellerlvl1
- - PC_SHOP_LVL_6  string   samswordsellerlvl6
- - PC_SHOP_LVL_7  string   samswordsellerlvl6
- - PC_SHOP_LVL_8  string   samswordsellerlvl6
- in Sam's converstion, on the line that says something like "Yes, I want to buy something."
- - script that opens the store:
- - - checks PC Speaker's level
- - - checks OBJECT_SELF for level-dependent string variable (the store's tag)
- - - opens appropriate store for the PC

Notes:

By moving this all into the shop opening script, you save module resource space (with that whole 16k limit thing).  Using this method, you're only adding three resources (1 conversation file, 1 script source file, and 1 compiled script file).  If you want to go the generic route, you can use the script and conversation for multiple merchants (which is why I recommend using variables on the NPC shopkeeper, rather than storing the shop tags within the script itself).

I recommend making an "empty" merchant blueprint in the custom palette, then using that to make Sam's 1st store.  Change the store name and tag, fill in inventory that won't change.  Then copy that store for the next level, changing inventory and tag.  Then copy again for the next one, and so on.  Stores in the palette generally just uselessly take up valuable module resource space unless you've got a scripted event somewhere that "creates" a store in any location (such as various "shop genies").

Good luck!
               
               

               


                     Modifié par The Amethyst Dragon, 27 avril 2011 - 04:45 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Merchant sells items based on your level
« Reply #3 on: April 27, 2011, 06:12:15 pm »


               It also depends on whether you will be opening the stores through a conversation or if you just want the player to click on the npc and the store just opens without a conversation.

If you want to bypass the conversation then you would just add a script like so to the NPCs OnConversation event.

void main()
{
    object oClicker = GetLastSpeaker();
    int iLevel = GetHitDice(oClicker);
    location lLoc = GetLocation(OBJECT_SELF);
    object oStore;

    if (iLevel > 0 && iLevel < 6)
    oStore = CreateObject(OBJECT_TYPE_STORE, "store_level_1to5", lLoc);
    if (iLevel > 5 && iLevel < 12)
    oStore = CreateObject(OBJECT_TYPE_STORE, "store_level_6to11", lLoc);
    //etc...

    OpenStore(oStore, oClicker, 0, 0);
}


And you do not have to place all the stores in the area either. You just have to have made a blue print for each one. Then you can just create the store at the location of the NPC, exampled in the script above. If you do create the shop in this manner you will probably want to use the stores OnClosed event to destroy itself.

There are a few different ways to go about it. Just depends on how you want it to work really. If you are doing this via a conversation you can also use a script similar to the one above to create a store based on the level. Just need to replace GetLastSpeaker with GetPCSpeaker.

Good luck.
               
               

               


                     Modifié par GhostOfGod, 27 avril 2011 - 05:16 .
                     
                  


            

Legacy_AmbrosiaPW

  • Jr. Member
  • **
  • Posts: 70
  • Karma: +0/-0
Merchant sells items based on your level
« Reply #4 on: April 27, 2011, 10:18:45 pm »


               Yeah I just looked again and see that each store has it's own inventory. I must have been either too tired or too stoned to put two and two together. lol

Thanks for the help. Yeah my idea was to check int he existing conversations. After faction is true check the level. The issue I see is with 2 factions and lets just say 3 levels of stores, thats 6 stores sitting there and then multiply that by at least 12 merchants. Is that ok?

I'm also wondering how I can change the item level restrictions. For instance I'd like to make it so you can't wear +1 until level 6. +2 at level 10 and +3 at level 16 or something. Do I have to edit a .2da for this? I'm not asking you to give me step by step directions, but if you could point me in the right direction I would really appreciate it.

Thank you! ':wizard:'
               
               

               


                     Modifié par AmbrosiaPW, 27 avril 2011 - 09:21 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Merchant sells items based on your level
« Reply #5 on: April 27, 2011, 11:12:44 pm »


               @GhostOfGod

The only problem I see with your system is that it creates a store every time it is opened.  
you may want to either add something in the Onclosed of the store to destroy it or Check to see if the store for that level has already been created then just reopen it instead of creating a new one,

The module could bog down pretty fast if some PC just kept opening and closeing the store.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Merchant sells items based on your level
« Reply #6 on: April 28, 2011, 04:39:22 pm »


               

GhostOfGod wrote...

If you do create the shop in this manner you will probably want to use the stores OnClosed event to destroy itself.


'<img'>
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Merchant sells items based on your level
« Reply #7 on: April 28, 2011, 05:45:26 pm »


               

GhostOfGod wrote...

GhostOfGod wrote...

If you do create the shop in this manner you will probably want to use the stores OnClosed event to destroy itself.


'<img'>


':crying:'  oops.
               
               

               
            

Legacy_AmbrosiaPW

  • Jr. Member
  • **
  • Posts: 70
  • Karma: +0/-0
Merchant sells items based on your level
« Reply #8 on: April 29, 2011, 06:24:18 pm »


               

AmbrosiaPW wrote...


Thanks for the help. Yeah my idea was to check in the existing conversations. After faction is true check the level. The issue I see is with 2 factions and lets just say 3 levels of stores, thats 6 stores sitting there and then multiply that by at least 12 merchants. Is that ok?


Is this a big deal having 6 or more possibles stores for each merchant?
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Merchant sells items based on your level
« Reply #9 on: April 29, 2011, 09:44:41 pm »


               So you're looking at possibly 72 shops with items getting piled up in them. Yes it can cause problems. If you are constantly keeping the items in the stores that the players sell down to a minimum you will probably be ok. And of course the more objects you have in game the more resources you will be using.

But then using the method i suggested has it's own set of draw backs as well. If you have 72 players on, all with their own store open at the same time(highly unlikely), you will have the same scenario as described above. But the other big one that you may or may not want is that when the shop destroys itself all the objects that the player sold will also be gone so no other players will be able to buy items that other players sold.
               
               

               


                     Modifié par GhostOfGod, 29 avril 2011 - 08:47 .
                     
                  


            

Legacy_AmbrosiaPW

  • Jr. Member
  • **
  • Posts: 70
  • Karma: +0/-0
Merchant sells items based on your level
« Reply #10 on: April 29, 2011, 10:13:00 pm »


               Ok thanks. It sounds like the big deal is whether player sold items build up in the stores. I think I will only have a few stores operate like this. I'll just make some new merchants.

Thanks for your input.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Merchant sells items based on your level
« Reply #11 on: April 29, 2011, 10:33:09 pm »


               Also note, That the NPC's can share a merchant.   So if you have two NPC that have the same goods in there store, you can just have both of them open the same merchant.  The merchant does not have to be in the same area as the NPC shop keeper.
               
               

               
            

Legacy_AmbrosiaPW

  • Jr. Member
  • **
  • Posts: 70
  • Karma: +0/-0
Merchant sells items based on your level
« Reply #12 on: April 30, 2011, 01:21:57 am »


               Oh cool, thanks!