Quasi 54 Posted March 8, 2014 (edited) [Quasi] Shops Version 1.1 by Quasi What it does: Creates shops that are filled with random items. All shops are created at the start of a new game to prevent "cheating". By cheating I mean, if shops were randomly generated when they're first opened, a player could save before opening the shop, and keep restarting until the shop has the item he/she wants. All items can have separate probability rates and factors with note tags! (Have potions have a 90% chance to be included and Hi-Potion have a 10% chance!) Factors include: Level, Parameters, Switches and Variables. Level and Parameters are an exponential growth. Switches adds X amount, and Variables add their value into the probability. ** This does not change the current shop script, or make a new shop script! It just makes a new way to open a shop! Instructions: To set up a shop: Shops must be made inside the script, starting at line 51. All you have to do to add more shows is add an extra lines in between the { }'s: shop number => [type, [probability factors]], shop number = shop number/id ( we use this number to open the shop ) type = What type of items will the shop sell, items,weapons, armor or mixed? (Detailed info on lines 21-29) [probability factors] = Needs to be wrapped in brackets and is optional. (Detailed info on lines 30-49) Example of 4 shops: SHOPS = { 0 => [:items], 1 => [:wep,[:level]], 2 => [:arm,[":param7"]], 3 => [:all, [":switch1"]] # <= Last one on the list shouldn't have a comma!!! } Shop 0 will have only items, with no outside probability factors. (Would only use it's rate or DEFAULT_RATE) Shop 1 is a weapon shop which uses the Level factors. (Probability rates increase as you get closer to the items rate level) Shop 2 is an armor shop which uses param7 (LUK). (Probability rates increase as avg party luk gets closer to items rate param(7th value)) Shop 3 is a shop that has items,weapons and armor with the probability factor switch1. (If switch 1 is true all items probability increase by SWITCH_RATE) more info between lines 16-50. (Each item can have their own probability rates and factors if you set notes!~) To open a shop: With a simple call script: open_shop(shop id, purchase only?) Where shop is = to the shop id that you create inside the script. and where purchase is set to true or false. Example: script call: open_shop(1, true) would open shop 1 and would be purchase only. To reset/(Re-Randomize if that's even a word) all shops stock: Use the following call script: script call: reset_shops ~It is possible for someone to "cheat" if they know when the resets happen. *Note~ If a shop has any probability factors, you should reset shops every once in awhile or the probability factors would be pretty useless. * I'm going to work on changing the reset method a bit. I'll add in the ability to reset only certain shops, and reset any shops whenever their factor changes (example: A shop with Switch factor will reset whenever a switch is changed.) *New* To reset shops items. (Re-Randomize their stock) Run a script call: reset_shops(mode, x) Mode can be set to :all => resets all shops (doesn't use x) *DEFAULT* :level => resets all shops with :level factor (doesn't use x) :param => resets all shops with ":paramX" factor (x = param) :variable => resets all shops with ":variableX" factor (x = variable) :switch => resets all shops with ":switchX" factor (x = switch) :selected => resets ONLY x shop Examples: reset_shops or reset_shops(:all) => resets all reset_shops(:level) => resets all shops with :level factor reset_shops(:switch,5) => resets all shops with ":switch5" factor reset_shops(:selected,1) => resets shop 1 Note Tags: rate=X Where X = the items Probability Rate ratelvl=X Where X = the items Target Level rateparam=x0,x1,x2,x3,x4,x5,x6,x7 (mhp,mmp,str,def,matk,mdef,agi,luk) Where x0-7 = Param value (Thinking of changing param rate into separate tags per param to make it easier) *0 = MHP, 1 = MMP, 2 = Str, 3 = Def, 4 = MATK, 5 = MDEF, 6 = AGI, 7 = LUK* Links: Shop Script <- Some more info on the level/param growth Quasi Core <- NEEDED Change Logs: 1.1 => New Reset method 1.0 => Released * If anyone needs help setting it up, feel free to ask because I'm not the best at explaining. * Future ideas: - Add a tag so certain items can only appear in certain shop id - Stock Amount - Different growth formulas which option to choose which Example Level growth: X-axis = player level, y-axis = probability chance. Item lvl rate is 50. (Graph is not the overall rate! Just the amount that level factors to it.) Edited March 8, 2014 by Quasi 4 Share this post Link to post Share on other sites
magic2345 252 Posted March 8, 2014 That's an interesting script you've got there, reminds me a bit of disgaea's random shops in random dungeons. Very nice! Share this post Link to post Share on other sites
Quasi 54 Posted March 8, 2014 Thanks! I also forgot to add in the fact that there's no auto resets. So if you make a shop with any probability factors you will want to do resets every once in awhile. I actually forgot about that, so I'll change the reset method a bit so you can get reset certain shops, and certain shops reset when their factor changes. Example if a shop with a switch factor will reset if that switch is changed. 1 Share this post Link to post Share on other sites
Skysagi 219 Posted March 8, 2014 Really nice script! If I need it in my game, I'll try using it. Share this post Link to post Share on other sites
+ TBWCS 953 Posted March 8, 2014 Amazing script, shops are very important and I think scripts like these deserves a go to be used. Hope one day I'd be using it in my games 1 Share this post Link to post Share on other sites
LordSquirrel 150 Posted March 8, 2014 Sees like a good script. I may use it if I make a heavily randomized game at some point. Share this post Link to post Share on other sites
Quasi 54 Posted March 8, 2014 (edited) Thanks guys. Most of my scripts are built around tactical rpg systems, so I don't expect them to be used much. But they're still handy and I shouldn't hog all the good scripts I've made to myself! Still debating if I should release my over world script (Like the FFT games or Super Mario) but I'm not sure if it'd be of use to anyone cause it could also be made with events. Back on topic: Updated to 1.1! Just changed the reset method and added in some auto resets. There's 2 auto resets, 1 is for variables and switches and the other is for params/levels. Variables and switches auto reset whenever you change an variable/switch through an event (doesn't call when you change them through scripts.) Level and param auto reset on level up (Didn't really like this which is why I made them 2 different auto resets and set this off by default.) New reset method is now: Run a script call: reset_shops(mode, x) Mode can be set to :all => resets all shops (doesn't use x) *DEFAULT* :level => resets all shops with :level factor (doesn't use x) :param => resets all shops with ":paramX" factor (x = param) :variable => resets all shops with ":variableX" factor (x = variable) :switch => resets all shops with ":switchX" factor (x = switch) :selected => resets ONLY x shop Examples: reset_shops or reset_shops(:all) => resets all reset_shops(:level) => resets all shops with :level factor reset_shops(:switch,5) => resets all shops with ":switch5" factor reset_shops(:selected,1) => resets shop 1 Edited March 8, 2014 by Quasi 1 Share this post Link to post Share on other sites
_Rift_ 0 Posted June 11, 2014 Brilliant - Exactly what I was looking for. Thanks very much, Quasi! Share this post Link to post Share on other sites
ashes999 13 Posted July 26, 2014 (edited) Precisely what I need for my roguelike. Thanks man. I do note, however, that the level shops are a bit ... odd. If I start a new game, I get weapons/armour that cost several thousand (like 3000-15000) while on level one. Not a great result, considering how little gold you get for early encounters using the default troops. Still, resetting is easy enough, and you will eventually get reasonable goods. (This is using a default setup, like so:) SHOPS = { 0 => [:items, [:level]], 1 => [:wep, [:level]], 2 => [:arm, [:level]] } Edited July 26, 2014 by ashes999 Share this post Link to post Share on other sites