Shop w/Random Leveled Items

I want a specific shop in my game to sell random items based on player level (in other words, every time you leave and re-enter the shop there will be new stuff being sold). The only script I could find for Ace that did this was in a post by Reedo from several years ago, and the forums unfortunately screwed up that post so the script is 100% unusable now, and sadly Reedo has been gone for over a year (so probably never coming back).

Is there any other script out there that can do this?
Fixed the script for ya
Code:
################################################################################
#  RRSBL - Reedo's Random Shop-by-Level
#  Version 0.2
#  September 30, 2013
#  By Reedo
###############################################################################
#  REFERENCES
#  None.  This is an original script by Reedo.
###############################################################################
#  FEATURES#
#  + Allows shop processing to use a random selection of items determined
#    by the player's current level.
#  + Individual items-per-level also have their own chance of appearing.
#  + Simple event command script calls control shop processing options.
#  + Possible to control "random" selection based on some other value.
#  + Selection can be limited by "shop type".
################################################################################
#  COMPATIBILITY
#  Should be compatible with most other scripts.
################################################################################
#  REQUIREMENTS
#  Script commands in events to activate/control random shop processing.
################################################################################
#  INSTALLATION
#  Plug-and-play
#  Insert below Materials, above other add-on scripts.
################################################################################
#  RIGHTS & RESTRICTIONS
#  As with most Reedo scripts, this script is free to re-use, as-is,
#  in personal, educational, and commercial RPGVX Ace development projects,
#  providing that:  this script is credited in writing displayed readily
#  to the user of the final compiled code assembly.
#  Reedo retains all rights of intellect and ownership.
#  You forego all rights of warranty by utilizing this script.
################################################################################
################################################################################
#  USER OPTIONS
################################################################################
# The following variables have been added to the Game_Interpreter to support
# using this script:
# @reedo_random_shop   <- Set to True to enable random shopping, Nil/False to
# disable.
#
# @reedo_item_min      <- Set minimum number of items to show in shop.
# @reedo_item_max      <- Set maximum number of items to show in shop.
# @reedo_random_seed   <- Control the "random" selection by setting this value;
#                         set Nil for new random selection ever time.
# @reedo_shop_type     <- Set to a single shop type keyword, or array of shop
#                         type keywords.
#
# In any event that will show a shop scene where you want to use the random
# shopping, be sure to set @reedo_random_shop = true in a script command before
# you begin the shop scene processing. You can set the @reedo_item_min/max
# variables before shop scene processing to set the number of items for sale
# in each shop. If you do not set these values for each event, then the defaults
# defined in RSSBL are used instead. You can set the @reedo_random_seed to
# specific value to force the "random" selection to be the same every time.
# If you had another script such as a calendar that could give you a unique
# value every "day", then you could set the random seed to this value to force
# the same selection for an entire day, and create a new random selection on the
# next day. All other options are configured below:
################################################################################

module RRSBL
  SHOP_ITEMS = {} # Do not modify; configured below.  
 
  # Min number of items to show in shop
  ITEM_COUNT_MIN = 1
 
  # Max number of items to show in shop; set min = max to always show the same
  #amount
  ITEM_COUNT_MAX = 3
 
  # Auto-reset the random shop after use if true.
  AUTO_RESET_RANDOM = true  
 
  # ITEM CONFIGURATION
  #  Enter items as array of sales-item, percent chance to be sold, and optional
  #  shop type name used to filter selection with @reedo_shop_type.
  #  Sales-item array consists of:
  #  [type, id, defaultPrice, price]
  #  Where type = 0 for items, 1 for weapons, and 2 for armor
  #         id = the item id from the database
  #         defaultPrice = 0 to use item price, or 1 to use custom price
  #         price = the custom price, or nil when defaultprice = 0
  #  Percent chance is a float between 0.0 (0% chance) and 1.0 (100% chance)
  #  Shop type name is a single string or array of strings used to further
  #    restrict the possible random item selection.  
  # Configure possible items when level is equal or greater than 1
  LEVEL_1_ITEMS = []
  LEVEL_1_ITEMS.push([[0, 1, 0, nil], 1.0, "items"])
  LEVEL_1_ITEMS.push([[1, 1, 0, nil], 1.0, "weapons"])
  LEVEL_1_ITEMS.push([[2, 1, 0, nil], 1.0, "armor"])  
  # Configure possible items when level is equal or greater than 3
  LEVEL_3_ITEMS = []
  LEVEL_3_ITEMS.push([[0, 2, 0, nil], 1.0])
  LEVEL_3_ITEMS.push([[1, 2, 0, nil], 1.0])
  LEVEL_3_ITEMS.push([[2, 2, 0, nil], 1.0])  
  # Create and configure more items as needed...  
  # Add all configured items-per-level to the SHOP_ITEMS hash
  SHOP_ITEMS[1] = LEVEL_1_ITEMS
  SHOP_ITEMS[3] = LEVEL_3_ITEMS  end
################################################################################
# MAIN SCRIPT
################################################################################
#  EDITS BEYOND THIS POINT ARE AT YOUR OWN RISK!!!
###############################################################################
class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Shop Processing
  #--------------------------------------------------------------------------
  alias reedo_rrsbl_gi_command_302 command_302
  def command_302  
    return if $game_party.in_battle  
    if !@reedo_random_shop    
      reedo_rrsbl_gi_command_302  
    else    
      @reedo_random_shop = nil
      if RRSBL::AUTO_RESET_RANDOM    
        index = 1    
        level = $game_player.actor.level    
        RRSBL::SHOP_ITEMS.keys.each do |key|      
          if (key > index - 1) || (key > level) then        
            break      
          else        
            index += 1      
          end    
        end    
        goods = []          
        min = @reedo_item_min    
        min = RRSBL::ITEM_COUNT_MIN if !min    
        max = @reedo_item_max    
        max = RRSBL::ITEM_COUNT_MAX if !max    
        oldseed = nil    
        oldseed = srand(@reedo_random_seed) if @reedo_random_seed          
        possible = []    
        RRSBL::SHOP_ITEMS[index].each do |item|      
          if item.size > 2 && @reedo_shop_type && @reedo_shop_type.size > 0        
            next if !@reedo_shop_type.include?(item[2])      
          end      
          if rand <= item[1]        
            possible.push(item[0])      
          end    
        end                
        count = [min, rand(max + 1)].max    
        count.times do |cnt|      
          selectedindex = rand(possible.size)      
          goods.push(possible[selectedindex])      
          possible.delete_at(selectedindex)      
          break if possible.size == 0    
        end          
        srand(oldseed) if oldseed    
        SceneManager.call(Scene_Shop)    
        SceneManager.scene.prepare(goods, @params[4])    
        Fiber.yield  
      end
    end
  end
Disclaimer, don't ask me how to use the script
There are some errors in that almost fixed code.
Spoiler
Code:
################################################################################
#  RRSBL - Reedo's Random Shop-by-Level
#  Version 0.2
#  September 30, 2013
#  By Reedo
###############################################################################
#  REFERENCES
#  None.  This is an original script by Reedo.
###############################################################################
#  FEATURES#
#  + Allows shop processing to use a random selection of items determined
#    by the player's current level.
#  + Individual items-per-level also have their own chance of appearing.
#  + Simple event command script calls control shop processing options.
#  + Possible to control "random" selection based on some other value.
#  + Selection can be limited by "shop type".
################################################################################
#  COMPATIBILITY
#  Should be compatible with most other scripts.
################################################################################
#  REQUIREMENTS
#  Script commands in events to activate/control random shop processing.
################################################################################
#  INSTALLATION
#  Plug-and-play
#  Insert below Materials, above other add-on scripts.
################################################################################
#  RIGHTS & RESTRICTIONS
#  As with most Reedo scripts, this script is free to re-use, as-is,
#  in personal, educational, and commercial RPGVX Ace development projects,
#  providing that:  this script is credited in writing displayed readily
#  to the user of the final compiled code assembly.
#  Reedo retains all rights of intellect and ownership.
#  You forego all rights of warranty by utilizing this script.
################################################################################
################################################################################
#  USER OPTIONS
################################################################################
# The following variables have been added to the Game_Interpreter to support
# using this script:
# @reedo_random_shop   <- Set to True to enable random shopping, Nil/False to
# disable.
#
# @reedo_item_min      <- Set minimum number of items to show in shop.
# @reedo_item_max      <- Set maximum number of items to show in shop.
# @reedo_random_seed   <- Control the "random" selection by setting this value;
#                         set Nil for new random selection ever time.
# @reedo_shop_type     <- Set to a single shop type keyword, or array of shop
#                         type keywords.
#
# In any event that will show a shop scene where you want to use the random
# shopping, be sure to set @reedo_random_shop = true in a script command before
# you begin the shop scene processing. You can set the @reedo_item_min/max
# variables before shop scene processing to set the number of items for sale
# in each shop. If you do not set these values for each event, then the defaults
# defined in RSSBL are used instead. You can set the @reedo_random_seed to
# specific value to force the "random" selection to be the same every time.
# If you had another script such as a calendar that could give you a unique
# value every "day", then you could set the random seed to this value to force
# the same selection for an entire day, and create a new random selection on the
# next day. All other options are configured below:
################################################################################

module RRSBL
 
  SHOP_ITEMS = {} # Do not modify; configured below.
 
  # Min number of items to show in shop
  ITEM_COUNT_MIN = 1
 
  # Max number of items to show in shop; set min = max to always show the same
  #amount
  ITEM_COUNT_MAX = 3
 
  # Auto-reset the random shop after use if true.
  AUTO_RESET_RANDOM = true
 
  # ITEM CONFIGURATION
  #  Enter items as array of sales-item, percent chance to be sold, and optional
  #  shop type name used to filter selection with @reedo_shop_type.
  #  Sales-item array consists of:
  #  [type, id, defaultPrice, price]
  #  Where type = 0 for items, 1 for weapons, and 2 for armor
  #         id = the item id from the database
  #         defaultPrice = 0 to use item price, or 1 to use custom price
  #         price = the custom price, or nil when defaultprice = 0
  #  Percent chance is a float between 0.0 (0% chance) and 1.0 (100% chance)
  #  Shop type name is a single string or array of strings used to further
  #    restrict the possible random item selection.
  # Configure possible items when level is equal or greater than 1
  LEVEL_1_ITEMS = []
  LEVEL_1_ITEMS.push([[0, 1, 0, nil], 1.0, "items"])
  LEVEL_1_ITEMS.push([[1, 1, 0, nil], 1.0, "weapons"])
  LEVEL_1_ITEMS.push([[2, 1, 0, nil], 1.0, "armor"])
 
  # Configure possible items when level is equal or greater than 3
  LEVEL_3_ITEMS = []
  LEVEL_3_ITEMS.push([[0, 2, 0, nil], 1.0])
  LEVEL_3_ITEMS.push([[1, 2, 0, nil], 1.0])
  LEVEL_3_ITEMS.push([[2, 2, 0, nil], 1.0])
 
  # Create and configure more items as needed...
  # Add all configured items-per-level to the SHOP_ITEMS hash
  SHOP_ITEMS[1] = LEVEL_1_ITEMS
  SHOP_ITEMS[3] = LEVEL_3_ITEMS
 
end

################################################################################
# MAIN SCRIPT
################################################################################
#  EDITS BEYOND THIS POINT ARE AT YOUR OWN RISK!!!
###############################################################################

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Shop Processing
  #--------------------------------------------------------------------------
  alias reedo_rrsbl_gi_command_302 command_302
  def command_302
    return if $game_party.in_battle
    if !@reedo_random_shop
      reedo_rrsbl_gi_command_302
    else
      @reedo_random_shop = nil if RRSBL::AUTO_RESET_RANDOM
      index = 1
      level = $game_player.actor.level
      RRSBL::SHOP_ITEMS.keys.each do |key|  
        if (key > index - 1) || (key > level)
          break  
        else    
          index += 1  
        end
      end
      goods = []      
      min = @reedo_item_min
      min = RRSBL::ITEM_COUNT_MIN if !min
      max = @reedo_item_max
      max = RRSBL::ITEM_COUNT_MAX if !max
      oldseed = nil
      oldseed = srand(@reedo_random_seed) if @reedo_random_seed      
      possible = []
      RRSBL::SHOP_ITEMS[index].each do |item|  
        if item.size > 2
          if @reedo_shop_type.is_a?(Array) && @reedo_shop_type.size > 0
            next if !@reedo_shop_type.include?(item[2])
          elsif @reedo_shop_type
            next if @reedo_shop_type != item[2]
          end
        end  
        if rand <= item[1]    
          possible.push(item[0])  
        end
      end            
      count = [min, rand(max + 1)].max
      count.times do |cnt|  
        selectedindex = rand(possible.size)  
        goods.push(possible[selectedindex])  
        possible.delete_at(selectedindex)  
        break if possible.size == 0
      end      
      srand(oldseed) if oldseed
      SceneManager.call(Scene_Shop)
      SceneManager.scene.prepare(goods, @params[4])
      Fiber.yield
    end
  end
 
end
This one should be fully fixed.
I'm getting a CTD error whenever shop processing starts.

Script 'Reedo's Random Shop-by-Level' line 138:
NoMethodError occurred.

undefined method 'size' for 1.0:Float

Here's the line in question:

if item.size > 2 && @reedo_shop_type && @reedo_shop_type.size > 0
I have no idea how did that get to be a Float for you, but there was an error in the script related to that, so I fixed it.
Try it now.
Hmm, actually, looking now, I think the problem is that I don't know how to list the items in the script. It just says to use the "[type, id, default price, price], percent chance float" formula but doesn't say how to put more than one item in there (do I just put it on the next line? Do I put it on the next line, then tab until it's aligned directly under the previous line? No clue).
You create your items in one specific shop like this:
Code:
  LEVEL_1_ITEMS = []
  LEVEL_1_ITEMS.push([[0, 1, 0, nil], 1.0, "items"])
  LEVEL_1_ITEMS.push([[1, 1, 0, nil], 1.0, "weapons"])
  LEVEL_1_ITEMS.push([[2, 1, 0, nil], 1.0, "armor"])
Those are the items in one shop.
In this specific example, all 3 items added will show up for sure, unless you setup a specific shop type with the @reedo_shop_type variable.
For example, if you set that variable (with a script call) to "weapons", only the 2nd item on this list will show up in the shop, since only that one is labeled as "weapon" in the settings. You can also set that variable to ["weapons","armors"] to show items labeled as "weapons" OR "armors". You must do this before a shop processing event command, and you should reset it to nil after the shop processing event command to ensure that you don't forget to reset it.
So, basically, these settings are setting up entire shops with their item list.

Once you setup your shops, you can add it into the SHOP_ITEMS hash, like shown here:
Code:
  SHOP_ITEMS[1] = LEVEL_1_ITEMS
Use the same setting name you used for the item list you created above (which is LEVEL_1_ITEMS in this case).
See that number 1 between the [ ] signs? That will be the shop's level requirement. If the current party leader's level is equal or higher than that number, the items from the assigned list can show up, otherwise they can't.

When you are done with your settings, you can set the shop to use your item lists from the settings with the @reedo_random_shop variable.
Set that to true in a script call, like this:
Code:
@reedo_random_shop = true
You do this just before a shop processing event. It doesn't matter what your default shop processing event looks like if you used that script call before, since the items will be taken from this script, and not from the list you added in your event command.

At least this is how I understood it, but I didn't test it, so I might be wrong.
But what if I wanted MORE than just those three things in my shop? That's my question.
Just add another line below those examples. Use the same format.

Code:
LEVEL_1_ITEMS.push([[2, 1, 0, nil], 1.0, "armor"])
Use the same variable name (that is LEVEL_1_ITEMS here) and add the .push part after it with your settings.
Add as many as you want. Just change the settings in it and that's that.

Ohh, and if you want to add new settings, just create another one with whatever name you want like this:
Code:
Some_Name = []
Some_Name.push([[2,1,0,nil],1.0])
# And so on...
And add them into the SHOP_ITEMS settings like the others.

Original thread: https://forums.rpgmakerweb.com/threads/shop-w-random-leveled-items.92619/