Trying to make a Player-Made shop for my game, but I am a novice.

So I am trying to make a shop run by the player in my game, but I am a novice in coding.
I was told it would be possible to make the shop in vanilla RPG Maker, but my knowledge on how to make it possible is lacking.

What I want to have happen is
1: Player Goes up to a spot and selects an item or equipment to sell in that spot and for how much, removing the item from the inventory.

2: When the shop opens, A customer will come in and run a check to see if they want the item at that price.

3: If the NPC wants the item, they will buy, removing the item from the store and giving the player that much gold in their inventory.

So far, I have some variables set for items, and their prices, and some very basic understanding of RPG Maker Order of operations. and the spots where the item being sold will display the item, but I haven't figured out how to make it display the name of the item in the text box.

Another issue I am trying to overcome is that the game only lets me select items from the "Select Items" command and no armor, weapons, or accessories.

1731784698902.png
1731784711371.png
1731784734047.png
1731784795011.png
1731784823788.png
1: Player Goes up to a spot and selects an item or equipment to sell in that spot and for how much, removing the item from the inventory.
Use an event spawner like Galv's one to spawn an event in the tile in front of the player. I wrote the scripts for how to do this here
2: When the shop opens, A customer will come in and run a check to see if they want the item at that price.
Not enough information. How is the customer's move route determined? Is the customer randomized?
3: If the NPC wants the item, they will buy, removing the item from the store and giving the player that much gold in their inventory.
Unspawn the item and increase the player's gold. You may want to put a notetag <value:300> in each item's notebox and use a script to grab that value.
Use an event spawner like Galv's one to spawn an event in the tile in front of the player. I wrote the scripts for how to do this here
Unspawn the item and increase the player's gold. You may want to put a notetag <value:300> in each item's notebox and use a script to grab that value.
I will try something like that out.
Not enough information. How is the customer's move route determined? Is the customer randomized?
What I intended to do would be to create a rng system where it spawns a random npc to come it, choose one of 10 different routes, It would preform a check to see if the price for the item is good or not Where if Item price is Equal to actual buy price It would be a 75% chance to buy, but going as low as 70% of the buy value will make it a 100% chance and making the item be priced at 200% will always refuse to buy it.

I haven't made the actual coding for that yet, wanting to start on the first step.
What I intended to do would be to create a rng system where it spawns a random npc to come it, choose one of 10 different routes, It would preform a check to see if the price for the item is good or not Where if Item price is Equal to actual buy price It would be a 75% chance to buy, but going as low as 70% of the buy value will make it a 100% chance and making the item be priced at 200% will always refuse to buy it.
Just so you know this is going to be a fair amount of coding so you'll have to break it down step by step. Here is the code to "spawn a random customer"
Code:
var customerPool = [10, 30];//the event IDs of the possible customers on the spawn map
var randomIndex = Math.floor(Math.random() * customerPool.length);
Galv.SPAWN.event(SpawnMapNumberHere, customerPool[randomIndex], StoreEntranceXHere, StoreEntranceYHere, false);

You could also do something like:
1. Spawn a random customer.
2. Randomly pick one of the displayed items
3. Make the customer pathfind to that displayed item.
4. When the customer is in a tile next to that item, trigger the buying process.
The default Select Item command only works with items (not armour, weapons, or accessories). It can only work with Regular Items, Key Items, or Hidden Items. There are a couple of ways I can think of to get around this and do what you want.

You could create Hidden Items that match the armour, weapons, and accessories you want available and use those instead for the input. Whenever the player finds one of those items, just make sure to also give them the hidden version at the same time as the normal version, and make sure to remove both as well later.

The other way would be to use a plugin that allows you to create select windows for equipment, such as Yanfly's Map Select Equip.

Personally I think you'd be better off with the first option, and make not just the equipment have hidden item duplicates, but every item you want to be able to sell work that way. That will allow you to have all the options in one select window, whereas if you did the second option there would have to be separate selections for items vs equipment. However that could be fine if you put a choice in before the item select window pops up (Place item vs Place equipment).

My game features heavy shop mechanics so I'm happy to help further if you need.
A general advice, more about the "being a novice" part rather than your shop ideas.
Try to split up your game idea into smaller tasks. The smaller the better.

Right now you seem to be thinking: "How do I put various items into shelves that get bought by NPCs that make individual decisions based on several conditions?"
That can be overwhelming and tough to figure out.

Better approach might be to tackle these issues one after another, as they are simple to solve if you look at them separated.

The way an NPC will come to a decision isn't relevant while you figure out how to spawn events for your shop items. The way an NPC will walk to an item isn't relevant while you create a logic on figuring out good offers. Etc.

And while you complete task by task, they'll get easier to connect.
The default Select Item command only works with items (not armour, weapons, or accessories). It can only work with Regular Items, Key Items, or Hidden Items. There are a couple of ways I can think of to get around this and do what you want.

You could create Hidden Items that match the armour, weapons, and accessories you want available and use those instead for the input. Whenever the player finds one of those items, just make sure to also give them the hidden version at the same time as the normal version, and make sure to remove both as well later.

The other way would be to use a plugin that allows you to create select windows for equipment, such as Yanfly's Map Select Equip.

Personally I think you'd be better off with the first option, and make not just the equipment have hidden item duplicates, but every item you want to be able to sell work that way. That will allow you to have all the options in one select window, whereas if you did the second option there would have to be separate selections for items vs equipment. However that could be fine if you put a choice in before the item select window pops up (Place item vs Place equipment).

My game features heavy shop mechanics so I'm happy to help further if you need.
Thank you kindly,
So I am able to create a 3 window choice between Weapons, Consumables, and Armor, and with the VisuStella Text Plug-in allows me to select armor and weapons, and also display their names in the Text Windows. Thank you. ^v^

A general advice, more about the "being a novice" part rather than your shop ideas.
Try to split up your game idea into smaller tasks. The smaller the better.

Right now you seem to be thinking: "How do I put various items into shelves that get bought by NPCs that make individual decisions based on several conditions?"
That can be overwhelming and tough to figure out.

Better approach might be to tackle these issues one after another, as they are simple to solve if you look at them separated.

The way an NPC will come to a decision isn't relevant while you figure out how to spawn events for your shop items. The way an NPC will walk to an item isn't relevant while you create a logic on figuring out good offers. Etc.

And while you complete task by task, they'll get easier to connect.
That is what I am doing, starting with The Setup phase as I put it, when you put items on the shelves and price them.

So I found some code I should be able to use. to withdraw the item from your inventory.


$gameParty.loseItem($dataItems[$gameVariable.value(1)], 1);

I tried it out but it doesn't seem to be working.
What I am trying to do is have it pull on the game variable which holds the stored item number placement (Like potion being 7 or Hi potion being 8)

Is there something I am doing wrong?


Edit:
Okay I found out what was wrong.

With that being said, The set up phase seems to be complete.

So I found some code I should be able to use. to withdraw the item from your inventory.


$gameParty.loseItem($dataItems[$gameVariable.value(1)], 1);

I tried it out but it doesn't seem to be working.
What I am trying to do is have it pull on the game variable which holds the stored item number placement (Like potion being 7 or Hi potion being 8)

Is there something I am doing wrong?
Okay I found out what was wrong.

With that being said, The set up phase seems to be complete.
This thread is closed due to being reported as solved. If you need it reopened, report it to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-make-a-player-made-shop-for-my-game-but-i-am-a-novice.173264/