Merchant sells items based on your level
#1
Posté 27 avril 2011 - 03:41
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.
#2
Posté 27 avril 2011 - 03:59
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 .
#3
Posté 27 avril 2011 - 04:45
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 .
#4
Posté 27 avril 2011 - 05:12
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 .
#5
Posté 27 avril 2011 - 09:18
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!
Modifié par AmbrosiaPW, 27 avril 2011 - 09:21 .
#6
Posté 27 avril 2011 - 10:12
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.
#7
Posté 28 avril 2011 - 03:39
GhostOfGod wrote...
If you do create the shop in this manner you will probably want to use the stores OnClosed event to destroy itself.
#8
Posté 28 avril 2011 - 04:45
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.
#9
Posté 29 avril 2011 - 05:24
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?
#10
Posté 29 avril 2011 - 08:44
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 .
#11
Posté 29 avril 2011 - 09:13
Thanks for your input.
#12
Posté 29 avril 2011 - 09:33
#13
Posté 30 avril 2011 - 12:21





Retour en haut






