MV A Highly Specific Shop for a Roguelike Game

Hi everyone!

I currently have a pretty hacked together version of what I need, but I just know this could be handled more cleanly with a plugin. I am wondering if such a plugin exists, if someone would make it for me, or if someone would teach me how to make it myself!

Here's what the shop needs to be able to do:
  • Carry a randomized limited selection of items that can be rerolled. For example, the Armor Shop would have 3 random armors for sale, and each time you leave and enter town, it would have 3 different random armors.
  • Limited stock - a player should only be able to buy each offered item once per visit. Optionally, if weapons and armor the player owns could not show up again in the shop, that would be nice.
  • The ability to add to the potential selection of items. For example, in the beginning of the game the Armor Shop can potentially sell any Armors from the "Common" category. During the game the player will give gifts to the vendors to expand their inventory, so after giving 1 gift to the Armor vendor, it can now potentially sell any armors from the Common or Uncommon category.
  • Additionally, because armors are also where accessories are stored, there should be a way to have the armor vendor only roll armors and the accessory vendor to only roll accessories. I am currently using dingk's Loot Pools plugin, so if it could be compatible with that, that would be amazing.
I know this is a long shot but I figured I'd ask here before starting to work on this myself, as I am a very novice coder but I do think it's within the realm of things I could learn to do. Help of ANY kind is appreciated - from fully scripting the thing yourself to pointing me towards some tutorials that you think will set me down the right path. Right now my plan is to open up some shop plugins and try to reverse engineer them so anything better than that is a big improvement!
I mean this sounds very eventable with just show choices, but best of luck finding someone.
I mean this sounds very eventable with just show choices, but best of luck finding someone.

I currently have all the functionality except limited stock by using Yuyu's Randomized Shop Inventory but it requires having all the of the weapons/armors/items in the order you want them to appear in the shop in the database, so if I want to go back and add a new Common item, I have to shift all of the higher rarity items up, and it's just a big pain when I know there should be a way to set up the shop using the Loot Tables instead.

Started looking at javascript tutorials last night lol
The plugin I linked above says it has limited stock.
And if you put the item ids in an array, you can choose random from there with just like array[Math.randomInt(array.length)]
The plugin I linked above says it has limited stock.
And if you put the item ids in an array, you can choose random from there with just like array[Math.randomInt(array.length)]

I did see this shop plugin and it looks like it could work as it allows for full javascript for the stock, but I don't know how to add the item ids to the array or when to call it, etc. Like I'm familiar with the concepts but don't know how to actually implement them. If you've got any suggestions there I'd be very grateful!
When you select what items to put in the shop, it has the availability condition JS code. So you can put whatever you want there. It can just be that $gameVariables.value(X) If you've set that value to a number (like 1), the item appears, if it's at 0, the item doesn't show. If you don't want to use too many variables, you can make one an array with like $gameVariables.setValue(X, [0,0,0,0,etc]) Each index represents an item, and you can reference and change them with $gameVariables.value(X)[index]
Then you just affect 3 random variables or indexes there. You can google how to come up with 3 random numbers in a range.

EDIT: You can also make more conditions when deciding what randoms to pick, like checking what items the player has and if they've given items to the shopkeepers (with variables/switches) and remove stuff from the potential pool of randoms (like splice them out of a pool of random numbers for example).
This sounds exactly like my limited stock shop plugin for MZ. I am thinking of doing an MV version, I just need to think about how to best do the setup functionality with MV-style plugin commands.
When you select what items to put in the shop, it has the availability condition JS code. So you can put whatever you want there. It can just be that $gameVariables.value(X) If you've set that value to a number (like 1), the item appears, if it's at 0, the item doesn't show. If you don't want to use too many variables, you can make one an array with like $gameVariables.setValue(X, [0,0,0,0,etc]) Each index represents an item, and you can reference and change them with $gameVariables.value(X)[index]
Then you just affect 3 random variables or indexes there. You can google how to come up with 3 random numbers in a range.

EDIT: You can also make more conditions when deciding what randoms to pick, like checking what items the player has and if they've given items to the shopkeepers (with variables/switches) and remove stuff from the potential pool of randoms (like splice them out of a pool of random numbers for example).

This is a big help, thank you! I'm at this weird place with coding where I understand a lot of the logic when I'm looking at plugins but I feel fully lost when I try to work on something from scratch, but this is all making sense.

This sounds exactly like my limited stock shop plugin for MZ. I am thinking of doing an MV version, I just need to think about how to best do the setup functionality with MV-style plugin commands.

If you do get it made I would be the most grateful guy on the planet lol. Taking a look at it, it does sound like it does everything I need. I would gladly pay for it as well!
This is a big help, thank you! I'm at this weird place with coding where I understand a lot of the logic when I'm looking at plugins but I feel fully lost when I try to work on something from scratch, but this is all making sense.



If you do get it made I would be the most grateful guy on the planet lol. Taking a look at it, it does sound like it does everything I need. I would gladly pay for it as well!
Do you have any suggestions on a way to implement the setup commands that you'd find easy to use as a user of it?
Do you have any suggestions on a way to implement the setup commands that you'd find easy to use as a user of it?

Ideally if it could pull it's random selection from loot tables (as defined in this script), and have that selection be expandable by reaching a threshold with a variable, that would be amazing. So, if "giftsGiven" is 0 then it only pulls from the Common pool, but if it is 1 then it pulls from the Common and Uncommon pool, etc scaling up to 4 or 5 gifts. Also, if the number of items carried could be expanded in the same way.

I just want to make what I'm asking for extra clear so here's an example of how the game works:

You start, the Item, Armor, Accessory and Weapon vendors each sell 3 things a piece, randomized from a pool of things marked as Common.

You give the Armor vendor a gift to expand their selection. They now sell 3 random armors pulled from the Common and/or Uncommon pools.

You give the Weapon vendor a gift to expand their inventory. They now sell 4 random weapons pulled from the Common pool.


Let me know if this is answering your question, I think I am understanding what you mean by "setup commands" but I could be wrong.
Do you have any suggestions on a way to implement the setup commands that you'd find easy to use as a user of it?
why not easy to use scriptcalls?

depending how it used and where, plugin commands/scriptcalls target the
same is faster too like:

limitStock([{itemId:4, stock:2},{weaponId: 1, stock:1}])
etc, or simply array of id's or the likes (something to the point 🙂 )
Hmmm, I think that unless you get a very special made plugin, you'll have to use some code if you want to put random stuff in there.

I tried writing some code and this seemed to work for me, but I only tested it with the base 4 items (you check availability conditions with
$gameVariables.value(20)[item id], change them to 0 after shopping)

$gameVariables.setValue(12, []);
for (let i = 1; i < $dataItems.length+1; i++) {
if ($dataItems[i].meta["Common"]){
$gameVariables.value(12).push($dataItems[i]);
}
if ($gameSwitches.value(10) && $dataItems[i].meta["Uncommon"]){
$gameVariables.value(12).push($dataItems[i]);
}
if ($gameSwitches.value(11) && $dataItems[i].meta["Rare"]){
$gameVariables.value(12).push($dataItems[i]);
}
}

let random = Math.randomInt($gameVariables.value(12).length);
const item1 = $gameVariables.value(12)[random];
$gameVariables.value(12).splice(random, 1);
random = Math.randomInt($gameVariables.value(12).length);
const item2 = $gameVariables.value(12)[random];
$gameVariables.value(12).splice(random, 1);
random = Math.randomInt($gameVariables.value(12).length);
const item3 = $gameVariables.value(12)[random];
$gameVariables.value(12).splice(random, 1);
$gameVariables.value(20)[item1.id] = 1;
$gameVariables.value(20)[item2.id] = 1;
$gameVariables.value(20)[item3.id] = 1;

Plugin Command:OpenShop BaseShop

Original thread: https://forums.rpgmakerweb.com/threads/a-highly-specific-shop-for-a-roguelike-game.177506/