Variable shop prices

Soulnet

Veteran
Veteran
Joined
Mar 10, 2014
Messages
198
Reaction score
97
First Language
English
Primarily Uses
So I'm looking to have shops in say three different locations. Each location will have some items that over lap. We'll just call it Item A.


So Scenario 1;

  • location 1, Item A costs 100 to buy and sold to a vendor for 60.
  • location 2, Item A costs 80 to buy and sold to a vendor for 70.
  • location 3, Item A costs 120 to buy and sold to a vendor for 85.



On top of this i'd love the prices to be able to fluctuate randomly say between -50% to +50% to give the items a way to be traded without spamming one location. The price fluctuation to be controlled by say every 24 hours of time. So lets say the above has had 24 hours, the results could now look like this;


Scenario 2;

  • location 1, Item A costs 80 to buy and sold to a vendor for 50.
  • location 2, Item A costs 120 to buy and sold to a vendor for 95.
  • location 3, Item A costs 110 to buy and sold to a vendor for 65.



So in scenario 1 it was best to buy at location 2 and sold at location 3 where as after the day has moved on scenario 2 it was best to buy at location 1 and sell at location 2.


Couple of additional rules;

  • I'd like to limit the number of items that can be bought / sold. So location 1 might be 5 then location 1 in the next scenario could be only 2.
  • The prices have a set benchmark to calculate the value from. I.e. Item A is set to 100 for buying and say 75 for selling, then the random fluctuation is always based of this number. This is more to ensure the game doesn't do 3 days of minus 50% to get to very low (or very high) numbers. So 100 to 50 to 25 to 12.5. So formula always starts with 100 (to be set by me) as the base.
  • Certain locations might have a different 'base' price so for example it might be a seaside shop so it specialises in fish. So using the above scenario it's base number might be 75.
  • If there was a location 4, i'd also like to control if it actually had the item for sale or not. So location 4 you can sell item A but you cannot buy it from there.
  • Three locations is just an example but lets say we had to expand that to 10 locations as well.



Is there a way to set this up?
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,567
Reaction score
6,892
First Language
German
Primarily Uses
RMMV
I've moved this thread to Plugin Request. Please be sure to post your threads in the correct forum next time. Thank you.



Some of your ideas can only be solved by plugins, not by default eventing (shop stock as one example) - so even if part of it might be doable by events, it's better to handle the entire idea as a plugin.
 

Soulnet

Veteran
Veteran
Joined
Mar 10, 2014
Messages
198
Reaction score
97
First Language
English
Primarily Uses
Ok, thanks for the advice.
 

Soulnet

Veteran
Veteran
Joined
Mar 10, 2014
Messages
198
Reaction score
97
First Language
English
Primarily Uses
Bump.


The rules said 72 hours, but i'm double posting so I don't know if that's allowed (didn't say in the rules with regards to bumping).
 

Soulnet

Veteran
Veteran
Joined
Mar 10, 2014
Messages
198
Reaction score
97
First Language
English
Primarily Uses
No one thinks this might be handy for their game? 
 

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,676
Reaction score
2,122
First Language
English
Primarily Uses
RMMV
I see the use for this but the game I'm making at the moment doesn't have a need for it.
 

Maliki79

Veteran
Veteran
Joined
Mar 13, 2012
Messages
660
Reaction score
251
First Language
English
Primarily Uses
N/A
I'm willing to give this a try. 


I will be setting it up so that item prices can be set as groups as opposed to setting prices by location.


So, if group 1 were fish, you could have them be sold (to the player) at 75% price and bought (from the player) for 125%.


Then group 2 could be wood, which would sold at 105% and bought at 100%.


You'll be able to have as many groups as you want.


The intention will be to set the group rates via a script call sometime before beginning shop processing.


Since the dev can set the prices at will, I will not have prices auto reset/flux.  I will have a script call to reset prices to normal, so will leave the flux pricing to be done in common events set up on your end.


Also, I can make it so the dev can set a base number, but to keep the plugin relatively simple to use, I will omit this.  Since you can set group prices whenever, if you keep the amount of flux in mind when setting up the event, it should be simple to do


Does this sound like something that would work for you?
 

Soulnet

Veteran
Veteran
Joined
Mar 10, 2014
Messages
198
Reaction score
97
First Language
English
Primarily Uses
Thanks for the reply!


So in other words to keep the prices a bit 'random' i could set up group 1.1, 1.2, 1.3, 1.4 for wood etc... so 1.4 could be reserved for location A and 1.2 for location B? Then for say Fish it's 2.1, 2.2, 2.3 and 2.4. so 2.4 could be for location A and 2.1 for location B? You'll notice the 1.X is changed depending on the location. I'm using this as 1.1 might be a certain % and 1.2 as another. So to mix up the shop you could call 2.1 and 1.4 as examples.


I suppose most important is that there is enough 'randomness' (in buy and sell price, not in the item available) that it doesn't become a cash exploit. I.e. you can't keep spamming location A to sell at location B, so you'll find a 'good' chance not a 'definite'. 


Will it be able to be worked this way?
 
Last edited by a moderator:

Maliki79

Veteran
Veteran
Joined
Mar 13, 2012
Messages
660
Reaction score
251
First Language
English
Primarily Uses
N/A
As of right now,  the script call is like this:


$gameParty.setShopRates(x, y, z);


x is the group number,


y is the buy % as a number,


and z is the sell % as a number.


So if you wanted some variability to the numbers, you could use conditional branches in events to set slightly different sets for each group.


So you can have a variable check:  if the var is 0 call:


$gameParty.setShopRates(1, 100, 50); //normal buy/sell structure


If 1:


$gameParty.setShopRates(1, 120, 75);


if 2:


$gameParty.setShopRates(1, 90, 40);


And so on.


If you need true flux you can use variables in the script calls as well.


$gameParty.setShopRates(1, $gameVariables.value(w), $gameVariables.value(p));


Just make sure you set those variables before the shop call itself.


Does that work ok?
 

Soulnet

Veteran
Veteran
Joined
Mar 10, 2014
Messages
198
Reaction score
97
First Language
English
Primarily Uses
Think it will be great! 


I'll give it a go tomorrow if you have it ready as it's bedtime for me. 


Look forward to trying it! 


Thanks muchly :D
 

Kino

EIS Game Dev
Veteran
Joined
Nov 27, 2015
Messages
515
Reaction score
678
First Language
English
Primarily Uses
RMMV
This is a pretty extensive script.
Hopefully, this helps you with some of the needs that you wanted provided in your game.
This script does feature items with stock attached to them. Furthermore, selling the item back to the shop, restocks that item.


Shop System
It also saves the stock when you save the game, so you won't have the stock reset every time you exit the game.
 
Last edited by a moderator:

Soulnet

Veteran
Veteran
Joined
Mar 10, 2014
Messages
198
Reaction score
97
First Language
English
Primarily Uses
This works!  :D


I'll have to read up on how to use the variables (so as to put in a range) but so far it's working great but if you can provide an example perhaps then i'll play with it till I find my magic formula.*


* $gameParty.setShopRates(2, Math.floor(Math.random()*50)+88, Math.floor(Math.random()*50)+34)


* So it brings up a random number between 0 and 49 then adds 88. So the range is between 88% and 137%. Changing the +88 will make the % bigger or smaller. Changing the *50 will increase the % range. So if the base price above was 100, the first formula the buy price can be between 88 and 137 while the sell price is between 34 and 83.


I had to turn off HIME_ShopManager plugin though. Game would crash when opening a shop if this plugin was used at the same time.


I'll try to set this up extensively now and let you know if I come across any other issues (if any).


Thanks again!!! :D


** Think i've run into an issue when selling. The formula (or even just a base number) doesn't want to work.


$gameParty.setShopRates(1, Math.floor(Math.random()*50)+64, Math.floor(Math.random()*50)+14)


or


$gameParty.setShopRates(1, Math.floor(Math.random()*50)+64, 400)


Both end up with same sell results. Am I doing something wrong? Screenshots attached.


database.png


HK Buy.png


HK Sell.png


Lastly,  within the shop as well, I don't want the prices to reset everything time the shop event is triggered. It'd like to use another trigger before the prices change (say time of day, or lock for 10 minutes with a timer), so you can still repeatedly use the shop but the prices change when other conditions are met. Is this possible with your script or is it an event i'd need to setup? Without it you could spam the shop until you get the price you wanted!
 
Last edited by a moderator:

Maliki79

Veteran
Veteran
Joined
Mar 13, 2012
Messages
660
Reaction score
251
First Language
English
Primarily Uses
N/A
I'll look into the selling part of the plugin.  I'll also see what I can do about compatibility with Hime's plugin. (No guarantees there, tho!)


As for the variables, you can set them via events normally.  You can then add them to the call via:


$gameVariables.value(x)


Finally, you don't have to make the Rate call each time you open the shop.


You can set the event to make the call any time you like and it save the info for whenever it's used.


(I personally envisioned you using a call when you enter a town or use an inn.)


But at any rate, I'm glad you're enjoying the plugin.


I'll get to fixing the issues with it asap!


Edit: I tried using your formula listed above, and everything worked as it should.  Just bear in mind that when selling, the change is based on the original value of the item as listed in the database, not the buying price.  Even saying that, the buying and selling prices changed properly each time I made the script call, so I'm not quite sure what you might've done to make the sell results not change.
 
Last edited by a moderator:

Soulnet

Veteran
Veteran
Joined
Mar 10, 2014
Messages
198
Reaction score
97
First Language
English
Primarily Uses
Hmmm, that's interesting. Maybe there is another plugin that's affecting the formula. If you go by the formula used there would be no way known the number could be less than the number added (i.e. random number between 0 - 49 + 14 can't mathematically get the screenshot result!). That's just maths! My base price was set to 100.


I'll report back if I find which it is.


** Figured it out. In pic 3 how it says Dyes : 5. It's actually the quantity I have, not the sell price in the shop! Must find plug in to fix this now :)
 
Last edited by a moderator:

Maliki79

Veteran
Veteran
Joined
Mar 13, 2012
Messages
660
Reaction score
251
First Language
English
Primarily Uses
N/A
Okay.  I'll be here.


2 suggestions that may assist you:


1: Consider not using a formula for testing.  Simpler numbers are easier to test.


2: Use $gameVariables calls.  You can set a variable vie an event to equal the Math formula first, then input the variable into the script call.


Doing it this way will allow you to track the value easier.  (You can hit F9 during a test play to see switches and variable values while on the map screen.  You can also change the values if they are integers.)


But again, let me know if there's anything I can do to improve or fix my plugin.
 

Soulnet

Veteran
Veteran
Joined
Mar 10, 2014
Messages
198
Reaction score
97
First Language
English
Primarily Uses
Sorry, to rephrase my edit, it all actually worked fine! I was reading it as Dyes for sale at 5 each when it was simply stating I had 5 dyes on hand. So it was all working, cause when you press enter to sell it, it then shows the sell cost.


Sorry to confuse!


To keep the fixed cost i've used a conditional entry and simply used a control switch to determine whether the values reset or not. I use time to reset the switch thus resetting the shop to vary the price again :)
 

Maliki79

Veteran
Veteran
Joined
Mar 13, 2012
Messages
660
Reaction score
251
First Language
English
Primarily Uses
N/A
Awesome!  Glad everything's working as intended.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Had no time to work more on my Redwood tiles yesterday and no time yet still today--But! Somehow found time to make sit health potion props.
Today I learned that George Washington was not the first president of my country, and that there were technically over a dozen presidents before him. My own ignorance astounds me, I mean it always does but the sheer scope of this revelation astounds me. I guess George Santayana really was quite astute when he said:
Currently enjoying FF7 Remake :biggrin:
Day 753: I think im just about ready to finish the planning stage of my game creation and actually start to make it :0
I usually don't enjoy survival games, but I absolutely love Conan Exiles.

Forum statistics

Threads
95,774
Messages
931,813
Members
126,183
Latest member
MonchosMan
Top