Need a simple change in Galv's Random loot script

Hi
I'm using a script from Galv to generate random loot, however, this script gives the generated loot to the player. Could please someone change it a little bit to just write the ID of the generated loot to a variable and not giving anything to the player? Possibly by extending the script call with the possibility of setting to which variable I want to write the generated loots ID. Something like this:

random_item(type, rarity_min, rarity_max, subtype=0, monster_id=0, family=0, variable_number)

I want to handle the way of giving the generated loot to the player differently, and I need the ID of the generated item to work with it.


Link to script
Change line 274 to this:
Code:
$game_variables[10] = @loot[i].id

I've used variable 10, but just change that to what you want.
Thank you A-Moonless-Night, it works like a charm 🙂

The only issue I found is when it generates an empty, it still writes to the variable a 1, which means that it generates an item anyways. Could it be changed so that when its empty, it writes a 0 to the variable ?
Okay, I did a bit more tinkering and I've made it so you set a default variable in the script, so if you don't specify one in the script call in the event, it automatically goes to that. I've also changed it so that monster attacks and empty chests write 0 to the variable.

So, your new script call would be (for example)
Code:
random_item(0, 1, 10, 50, 1, 1, 10)
type (0),
rarity_min (1),
rarity_max (10),
subtype (50),
monster_id (1),
family (1),
variable (10)

If you leave off the variable (e.g. the old script call: random_item(0, 1, 10, 50, 1, 1) ), it automatically goes to the default variable in the editable region in the script.

Hope this helps; let me know if there's any confusion or bugs.

Spoiler: code here
Code:
#===============================================================================
#                          +++ GALV'S RANDOM LOOT +++
#===============================================================================
# + Original Script by Galv
# + Extended by Fhizban (also known as Malagar)
# + Version 1.4
# + Updated August 2015
# + For RPGMaker VX Ace
# + Free for Non-Commercial and Commercial use
# + Requires no other scripts
#===============================================================================
#                                DESCRIPTION
#===============================================================================
#  This script allows you to have a script call to gain random loot from chests.
#  Add notetags to items to specify level requirements and rarity values.
#  A notetag can also be added to items that you want to increase the chance to
#  find rarer loot. Random loot can be limited to certain types of items too.
#===============================================================================
#                                INSTALLATION
#===============================================================================
# + Put this script after Material but before main.
# + Add some of the notetags (described below) to the items in the database.
# + Add a new event that represents a chest or other container to your map.
# + Add a script call to the event that will generate random loot (see below).
#===============================================================================
#                                DOCUMENTATION
#===============================================================================
# You are required to setup two different parts to make this script work:
#   1) Add Notetags to your items in the database.
#   2) Add the script call to your events (chests).
#   3) Optionally you can change the configuration below to your taste.
#
# 1) Editing Notetags:
#    You must specify the following notetags for all ITEMS, WEAPONS and ARMOR that
#    you want to randomly appear in your events (chests). If any items do not have
#    these tags, they will just not appear in a random chest at all.
#
#    <family: x>                    # The group or family the item belongs to
#                                   # You define these families yourself (1-99)
#    <rarity: x>                    # The rarity value (1+ higher is rarer)
#    <level-min: x>                 # Min level of player for item to show (1-99)
#    <level-max: x>                 # Max level of player for item to show (1-99)
#
#    Optional notetag for ARMORS and WEAPONS only:
#
#    <lucky: x>                     # All equipped lucky items of the party are added to
#                                   # calculate the total chance to get rarer items.
#
# 2) Using the script call:
#    By using this script call, you can randomly obtain an item. Go to your event and add
#    a new command to it, choose script from the very last command tab and insert the
#    following line.
# 
#    EXAMPLE:
#
#            random_item(0, 1, 10, 50, 1, 1, 10)
#
#    SYNTAX:
#
#            random_item(type, rarity_min, rarity_max, subtype=0, monster_id=0, family=0, var=10)
#
#    type                           # The type of item to be found:
#                                   # 0 = Random/any type (you can also use numbers 4+)
#                                   # 1 = Item
#                                   # 2 = Armor
#                                   # 3 = Weapon
#
#    rarity_min                     # Min and Max Rareness determine the item rarity that
#    rarity_max                     # the script call will obtain when successful. You can
#                                   # state any number that you also use on the notetags
#                                   # of your items. Example:
#                                   # rarity_min=10, rarity_max=50
#                                   # The script call will generate a random number 1-50.
#                                   # An item can only be obtained if it has a rarity
#                                   # EQUAL or LESS than the generated number.
#
#    subtype                        # OPTIONAL. This only applies to WEAPONS or ARMOR and
#                                   # will be ignored otherwise. Filters the random loot
#                                   # to drop only items of the stated type.
#                                   # (e.g. 1 = General Armour)
#
#    monster_id                     # OPTIONAL. This ID is used to decide what TROPP id
#                                   # will be used when a monster-in-a-box is encountered.
#                                   # Otherwise the standard troop will be used. Ignored
#                                   # if encounter chance is set to zero.
#
#    family                         # OPTIONAL. Family can be any number or 0.
#                                   # 0 = drops any item of the stated type/subtype
#                                   # x = drops only items of the stated type/subtype that
#                                   # share the family.
#
#---------------------ADDITION BY A-MOONLESS-NIGHT-------------------------------
#
#    variable                       # This is the variable where the ID of the item
#                                   # is stored. If the chest is empty, its value
#                                   # is set to zero.
#                                   # If no variable is set, the ID will go to the
#                                   # default variable (set below).
#
#--------------------------------------------------------------------------------
#
# Using a clever combination of type, subtype and families - you can tailor the random
# loot spawn to create only items of a very specific type. Like only Armors of the Small
# Shield type, or just Weapons of the Sword type and so on.
#===============================================================================
 
$imported = {} if $imported.nil?
$imported["Random_Loot"] = true
 
module Random_Loot
#===============================================================================
#  CONFIGURATION
#===============================================================================
  GET_MESSAGE = "Found "                    # Text before item name.
  GET_MESSAGE_AFTER = "!"                   # Text after item name.
 
  FAIL_MESSAGE = "It's empty!"              # Text when random item comes up nothing.
  
  SOUND_EFFECT = ["Coin", 90, 100]          # Sound effect of gaining an item.
                                            # ["SE Name", volume, pitch]
                                            # Make "SE Name" = "" for no sound.
                                    
  DEFAULT_MONSTER = 1                       # Default Monster ID if none stated.
 
  MONSTER_CHANCE = 10                       # % Chance that if no item is found, a
                                            # battle will happen instead.
  ESCAPE_MONSTER = true                     # Can you escape it? true or false
  
  MONSTER_MESSAGE = "Monster in a box!"     # Message when a monster appears.
                                            # Make it "" to disable.

#---------------------ADDITION BY A-MOONLESS-NIGHT------------------------------
 
  DEFAULT_VAR = 1                           # Default variable to put the item ID
                                            # to if none specified in script call.
#===============================================================================
#  END CONFIGURATION
#===============================================================================
end
 
#===============================================================================
module Random_Loot_Notetags
  def loot_rarity
    if @loot_rarity.nil?
      if @note =~ /<rarity: (.*)>/i
        @loot_rarity = $1.to_i
      else
        @loot_rarity = 0
      end
    end
    @loot_rarity
  end
  def loot_level_min
    if @loot_level_min.nil?
      if @note =~ /<level-min: (.*)>/i
        @loot_level_min = $1.to_i
      else
        @loot_level_min = 0
      end
    end
    @loot_level_min
  end
  def loot_level_max
    if @loot_level_max.nil?
      if @note =~ /<level-max: (.*)>/i
        @loot_level_max = $1.to_i
      else
        @loot_level_max = 0
      end
    end
    @loot_level_max
  end
  def loot_lucky
    if @loot_lucky.nil?
      if @note =~ /<lucky: (.*)>/i
        @loot_lucky = $1.to_i
      else
        @loot_lucky = 0
      end
    end
    @loot_lucky
  end
  def loot_family
    if @loot_family.nil?
      if @note =~ /<family: (.*)>/i
        @loot_family = $1.to_i
      else
        @loot_family = 0
      end
    end
    @loot_family
  end
  end # Random_Loot_Notetags
#===============================================================================
 
class RPG::Item
  include Random_Loot_Notetags
end
class RPG::Armor
  include Random_Loot_Notetags
end
class RPG::Weapon
  include Random_Loot_Notetags
end
 
#===============================================================================
class Game_Interpreter
 
  def random_item(type, rarity_min, rarity_max, subtype=0, monster_id=0, family=0, var)
   var = Random_Loot::DEFAULT_VAR if var == 0 # ADDITION BY A-MOONLESS-NIGHT
    #--- Determine Type
    if type == 1
      @loot = $data_items
      subtype = 0
    elsif type == 2
      @loot = $data_armors
    elsif type == 3
      @loot = $data_weapons
    else
      @loot = $data_items | $data_armors | $data_weapons
      subtype = 0
    end
 
    #--- Preperations
    @loot.shuffle
    if rarity_max < rarity_min
      rarity_max = rarity_min
    end
    if subtype < 0 || subtype > 99
      subtype = 0
    end
    if family < 0 || family > 99
      subtype = 0
    end
    if monster_id < 1
      monster_id = Random_Loot::DEFAULT_MONSTER
    end
    
    #--- Determine Party Luck Bonus
    mem = 0
    eqs = 0
    luck_bonus = 0
    i = 0
    no_equips = $game_party.members.count * $game_party.members[0].equips.count
    $game_party.members.each do |mem|
      mem.equips.each do |eq|
        next if eq.nil?
        luck_bonus += eq.loot_lucky
      end
    end
  
    #--- Determine Rarity Chance
    checked = 0
    restart = false
    continue = true
    no_items = @loot.count - 1
    rare_chance = rand(rarity_max - rarity_min) + rarity_min + luck_bonus + 1
    random_item = rand(no_items) + 1
    begin_count = rand(no_items) + 1
  
    #--- Determine Random Item
    no_items.times do |i|
      i = i + random_item
      begin_count += 1 if restart
      if i > no_items
        i = i - i + rand(no_items) + 1
        restart = true
      end
    
      #--- Get Random Item
      if family != 0 && @loot[i].loot_family != family
        continue = false
      end
      if subtype != 0 && type == 2
        if @loot[i].atype_id == subtype
          continue = false
        end
      end
      if subtype != 0 && type == 3
        if @loot[i].wtype_id == subtype
          continue = false
        end
      end

      if continue
        if @loot[i].loot_level_max >= $game_party.leader.level && @loot[i].loot_level_min <= $game_party.leader.level
          if @loot[i].loot_rarity <= rare_chance
            if rand(1) <= 0 #--- Dirty Hack to skip some items
              $game_variables[var] = @loot[i].id # edit by AMN to put item ID to variable
              RPG::SE.new(Random_Loot::SOUND_EFFECT[0], Random_Loot::SOUND_EFFECT[1], Random_Loot::SOUND_EFFECT[2]).play
              $game_message.add(Random_Loot::GET_MESSAGE + "\\I[" + @loot[i].icon_index.to_s + "]" + @loot[i].name.to_s + Random_Loot::GET_MESSAGE_AFTER)
              wait_for_message
              return
            end
          end
        end
      end
      checked += 1
    
      #--- Trigger Monster-in-a-Box Battle
      if checked == no_items
        monster_chance = rand(100) + 1
        if monster_chance <= Random_Loot::MONSTER_CHANCE
          if Random_Loot::MONSTER_MESSAGE != ""
            $game_message.add("\\>" + Random_Loot::MONSTER_MESSAGE + "\\.\\.\\.\\^")
            wait_for_message
          end
          $game_variables[var] = 0 # set value to zero if monster attack
          BattleManager.setup(monster_id, Random_Loot::ESCAPE_MONSTER, false)
          SceneManager.call(Scene_Battle)
        else
          $game_variables[var] = 0 # set value to zero if no items
          $game_message.add(Random_Loot::FAIL_MESSAGE)
          wait_for_message
        end
      end
    end
  end
  
end # Game_Interpreter
 
#===============================================================================
# END OF SCRIPT
#===============================================================================
Thank you A-Moonless-Night, I will be sure to credit you in my game 🙂

Aside from that, I found a little incompatibility or bug with Vlue's equipment randomization script. Sometimes, when I use Galv's Random Loot script to generate an equipment with affixes, it generates an item with 2 prefixes or suffixes, or sometimes 2 prefixes and suffixes, and sometimes even more. But that not occurs always. Can someone write a fix for that, please? It is not by the changes written by A-Moonless-Night, this bug occurs even in the version without the variable changes provided by her.

Link to Vlue randomization

I made a quick demo to see the bug in action if it is needed:

Link to demo

Just open that chest multiple times (ignore the "you gained item" text, as it is inaccurate), then look up the items it generated in your inventory. You will see some of them have multiple prefixes and/or suffixes on them.
Bump
Anyone?
Is anyone please able to fix the bug?
Hey there,

You could try this modified version of the edited script above (not a separate script this time as I would have to copy a good amount of the script anyway to do the edits):
Spoiler
Code:
#===============================================================================
#                          +++ GALV'S RANDOM LOOT +++
#===============================================================================
# + Original Script by Galv
# + Extended by Fhizban (also known as Malagar)
# + Version 1.4
# + Updated August 2015
# + For RPGMaker VX Ace
# + Free for Non-Commercial and Commercial use
# + Requires no other scripts
#
# + Modified by Another Fen (for compatibility with Vlue's Random Equipment)
#===============================================================================
#                                DESCRIPTION
#===============================================================================
#  This script allows you to have a script call to gain random loot from chests.
#  Add notetags to items to specify level requirements and rarity values.
#  A notetag can also be added to items that you want to increase the chance to
#  find rarer loot. Random loot can be limited to certain types of items too.
#===============================================================================
#                                INSTALLATION
#===============================================================================
# + Put this script after Material but before main.
# + Add some of the notetags (described below) to the items in the database.
# + Add a new event that represents a chest or other container to your map.
# + Add a script call to the event that will generate random loot (see below).
#===============================================================================
#                                DOCUMENTATION
#===============================================================================
# You are required to setup two different parts to make this script work:
#   1) Add Notetags to your items in the database.
#   2) Add the script call to your events (chests).
#   3) Optionally you can change the configuration below to your taste.
#
# 1) Editing Notetags:
#    You must specify the following notetags for all ITEMS, WEAPONS and ARMOR that
#    you want to randomly appear in your events (chests). If any items do not have
#    these tags, they will just not appear in a random chest at all.
#
#    <family: x>                    # The group or family the item belongs to
#                                   # You define these families yourself (1-99)
#    <rarity: x>                    # The rarity value (1+ higher is rarer)
#    <level-min: x>                 # Min level of player for item to show (1-99)
#    <level-max: x>                 # Max level of player for item to show (1-99)
#
#    Optional notetag for ARMORS and WEAPONS only:
#
#    <lucky: x>                     # All equipped lucky items of the party are added to
#                                   # calculate the total chance to get rarer items.
#
# 2) Using the script call:
#    By using this script call, you can randomly obtain an item. Go to your event and add
#    a new command to it, choose script from the very last command tab and insert the
#    following line.
#
#    EXAMPLE:
#
#            random_item(0, 1, 10, 50, 1, 1, 10)
#
#    SYNTAX:
#
#            random_item(type, rarity_min, rarity_max, subtype=0, monster_id=0, family=0, var=10)
#
#    type                           # The type of item to be found:
#                                   # 0 = Random/any type (you can also use numbers 4+)
#                                   # 1 = Item
#                                   # 2 = Armor
#                                   # 3 = Weapon
#
#    rarity_min                     # Min and Max Rareness determine the item rarity that
#    rarity_max                     # the script call will obtain when successful. You can
#                                   # state any number that you also use on the notetags
#                                   # of your items. Example:
#                                   # rarity_min=10, rarity_max=50
#                                   # The script call will generate a random number 1-50.
#                                   # An item can only be obtained if it has a rarity
#                                   # EQUAL or LESS than the generated number.
#
#    subtype                        # OPTIONAL. This only applies to WEAPONS or ARMOR and
#                                   # will be ignored otherwise. Filters the random loot
#                                   # to drop only items of the stated type.
#                                   # (e.g. 1 = General Armour)
#
#    monster_id                     # OPTIONAL. This ID is used to decide what TROPP id
#                                   # will be used when a monster-in-a-box is encountered.
#                                   # Otherwise the standard troop will be used. Ignored
#                                   # if encounter chance is set to zero.
#
#    family                         # OPTIONAL. Family can be any number or 0.
#                                   # 0 = drops any item of the stated type/subtype
#                                   # x = drops only items of the stated type/subtype that
#                                   # share the family.
#
#---------------------ADDITION BY A-MOONLESS-NIGHT-------------------------------
#
#    variable                       # This is the variable where the ID of the item
#                                   # is stored. If the chest is empty, its value
#                                   # is set to zero.
#                                   # If no variable is set, the ID will go to the
#                                   # default variable (set below).
#
#--------------------------------------------------------------------------------
#
# Using a clever combination of type, subtype and families - you can tailor the random
# loot spawn to create only items of a very specific type. Like only Armors of the Small
# Shield type, or just Weapons of the Sword type and so on.
#===============================================================================
$imported = {} if $imported.nil?
$imported["Random_Loot"] = true
module Random_Loot
#===============================================================================
#  CONFIGURATION
#===============================================================================
  GET_MESSAGE = "Found "                    # Text before item name.
  GET_MESSAGE_AFTER = "!"                   # Text after item name.
  FAIL_MESSAGE = "It's empty!"              # Text when random item comes up nothing.
 
  SOUND_EFFECT = ["Coin", 90, 100]          # Sound effect of gaining an item.
                                            # ["SE Name", volume, pitch]
                                            # Make "SE Name" = "" for no sound.
                               
  DEFAULT_MONSTER = 1                       # Default Monster ID if none stated.
  MONSTER_CHANCE = 10                       # % Chance that if no item is found, a
                                            # battle will happen instead.
  ESCAPE_MONSTER = true                     # Can you escape it? true or false
 
  MONSTER_MESSAGE = "Monster in a box!"     # Message when a monster appears.
                                            # Make it "" to disable.

#---------------------ADDITION BY A-MOONLESS-NIGHT------------------------------
  DEFAULT_VAR = 1                           # Default variable to put the item ID
                                            # to if none specified in script call.
#===============================================================================
#  END CONFIGURATION
#===============================================================================
end
#===============================================================================
module Random_Loot_Notetags
  def loot_rarity
    if @loot_rarity.nil?
      if @note =~ /<rarity: (.*)>/i
        @loot_rarity = $1.to_i
      else
        @loot_rarity = 0
      end
    end
    @loot_rarity
  end
  def loot_level_min
    if @loot_level_min.nil?
      if @note =~ /<level-min: (.*)>/i
        @loot_level_min = $1.to_i
      else
        @loot_level_min = 0
      end
    end
    @loot_level_min
  end
  def loot_level_max
    if @loot_level_max.nil?
      if @note =~ /<level-max: (.*)>/i
        @loot_level_max = $1.to_i
      else
        @loot_level_max = 0
      end
    end
    @loot_level_max
  end
  def loot_lucky
    if @loot_lucky.nil?
      if @note =~ /<lucky: (.*)>/i
        @loot_lucky = $1.to_i
      else
        @loot_lucky = 0
      end
    end
    @loot_lucky
  end
  def loot_family
    if @loot_family.nil?
      if @note =~ /<family: (.*)>/i
        @loot_family = $1.to_i
      else
        @loot_family = 0
      end
    end
    @loot_family
  end
  end # Random_Loot_Notetags
#===============================================================================
class RPG::Item
  include Random_Loot_Notetags
end
class RPG::Armor
  include Random_Loot_Notetags
end
class RPG::Weapon
  include Random_Loot_Notetags
end
#===============================================================================
# Addition by Another Fen: Access original database items:
class << DataManager
 
  alias_method(:load_database_ILC_originalItemsLength, :load_database)
  def load_database
    load_database_ILC_originalItemsLength
    remember_database_item_limits
  end
 
  def remember_database_item_limits
    @original_items_length = $data_items.length
    @original_armors_length = $data_armors.length
    @original_weapons_length = $data_weapons.length
  end
 
  def original_items(type)
    case type
    when :items   then return $data_items.take(@original_items_length)
    when :armors  then return $data_armors.take(@original_armors_length)
    when :weapons then return $data_weapons.take(@original_weapons_length)
    end
  end
end

#===============================================================================
class Game_Interpreter
 
  # Added Method by Another Fen
  def loot_item_list(type)
    case type
    when 1 then return DataManager.original_items(:items)
    when 2 then return DataManager.original_items(:armors)
    when 3 then return DataManager.original_items(:weapons)
    else return loot_item_list(1) | loot_item_list(2) | loot_item_list(3)
    end
  end
 
  def random_item(type, rarity_min, rarity_max, subtype=0, monster_id=0, family=0, var)
    var = Random_Loot::DEFAULT_VAR if var == 0 # ADDITION BY A-MOONLESS-NIGHT
    #--- Determine Type
    # Edit by Another Fen: Replaced loot assignment
#~     if type == 1
#~       @loot = $data_items
#~       subtype = 0
#~     elsif type == 2
#~       @loot = $data_armors
#~     elsif type == 3
#~       @loot = $data_weapons
#~     else
#~       @loot = $data_items | $data_armors | $data_weapons
#~       subtype = 0
#~     end
    @loot = loot_item_list(type)
    subtype = 0  unless type == 2 || type == 3
    #--- Preperations
    @loot.shuffle
    if rarity_max < rarity_min
      rarity_max = rarity_min
    end
    if subtype < 0 || subtype > 99
      subtype = 0
    end
    if family < 0 || family > 99
      subtype = 0
    end
    if monster_id < 1
      monster_id = Random_Loot::DEFAULT_MONSTER
    end
 
    #--- Determine Party Luck Bonus
    mem = 0
    eqs = 0
    luck_bonus = 0
    i = 0
    no_equips = $game_party.members.count * $game_party.members[0].equips.count
    $game_party.members.each do |mem|
      mem.equips.each do |eq|
        next if eq.nil?
        luck_bonus += eq.loot_lucky
      end
    end
 
    #--- Determine Rarity Chance
    checked = 0
    restart = false
    continue = true
    no_items = @loot.count - 1
    rare_chance = rand(rarity_max - rarity_min) + rarity_min + luck_bonus + 1
    random_item = rand(no_items) + 1
    begin_count = rand(no_items) + 1
 
    #--- Determine Random Item
    no_items.times do |i|
      i = i + random_item
      begin_count += 1 if restart
      if i > no_items
        i = i - i + rand(no_items) + 1
        restart = true
      end
 
      #--- Get Random Item
      if family != 0 && @loot[i].loot_family != family
        continue = false
      end
      if subtype != 0 && type == 2
        if @loot[i].atype_id == subtype
          continue = false
        end
      end
      if subtype != 0 && type == 3
        if @loot[i].wtype_id == subtype
          continue = false
        end
      end

      if continue
        if @loot[i].loot_level_max >= $game_party.leader.level && @loot[i].loot_level_min <= $game_party.leader.level
          if @loot[i].loot_rarity <= rare_chance
            if rand(1) <= 0 #--- Dirty Hack to skip some items
              $game_variables[var] = @loot[i].id # edit by AMN to put item ID to variable
              RPG::SE.new(Random_Loot::SOUND_EFFECT[0], Random_Loot::SOUND_EFFECT[1], Random_Loot::SOUND_EFFECT[2]).play
              $game_message.add(Random_Loot::GET_MESSAGE + "\\I[" + @loot[i].icon_index.to_s + "]" + @loot[i].name.to_s + Random_Loot::GET_MESSAGE_AFTER)
              wait_for_message
              return
            end
          end
        end
      end
      checked += 1
 
      #--- Trigger Monster-in-a-Box Battle
      if checked == no_items
        monster_chance = rand(100) + 1
        if monster_chance <= Random_Loot::MONSTER_CHANCE
          if Random_Loot::MONSTER_MESSAGE != ""
            $game_message.add("\\>" + Random_Loot::MONSTER_MESSAGE + "\\.\\.\\.\\^")
            wait_for_message
          end
          $game_variables[var] = 0 # set value to zero if monster attack
          BattleManager.setup(monster_id, Random_Loot::ESCAPE_MONSTER, false)
          SceneManager.call(Scene_Battle)
        else
          $game_variables[var] = 0 # set value to zero if no items
          $game_message.add(Random_Loot::FAIL_MESSAGE)
          wait_for_message
        end
      end
    end
  end
 
end # Game_Interpreter


#===============================================================================
# END OF SCRIPT
#===============================================================================

Apart from that a few things I noticed (probably nothing too severe, but probably worth keeping in mind when working with the script...):

- The variable ID is not an optional parameter right now, so you have to provide it when using random_item (as you did in the demo). However, you can substitute it with 0 to use the default variable ID set up in the script instead.
- If you use a "subtype", the method will only result in weapons/armors not of that subtype.
- Using a "subtype" or "family" may greatly reduce the chance of looting an item at all.
- Low rarity items are always eligible loot. "rarity_min" and "rarity_max" only determine the rarity ceiling of the looted item, they will not exclude low rarity items.

Apart from that, the drop rates of each item depend on their position in the database. The script will first pick a random item in your database and search from there for the next eligible item. Only when it reaches the end of the database it will start to pick arbitrary items.
For example, in your demo that means if you add a low-rarity-weapon to the end of your weapon list it will almost always drop from your example chest (since it would be preceded by 55 non-eligible weapons).
Thank you again Another Fen, you're a savior to my game 🙂 I will be sure to give you credits 🙂

I'm using that variable in all my events, which drops some kind of loot (chests, quest rewards, drops from defeated enemies...), so it's not a problem to always include.

I've made very small changes to the script, commented out 3 lines, which were giving messages about items dropped and a sound it makes, cuz I don't need that feature if I'm using the Storage Box script. I'm not using the monster in a box feature too, I don't need it and it's not compatible with the battle system I'm using anyway (its the Tankentai), but that's not a problem.

The fix you provided here works, I've tested it in both the demo and in the main game by opening 100 chests, so thanks for the fix 🙂

As you mentioned, the drops depend on the position in the database... I've noticed it greatly while testing, especially in one low rarity item (which is a reagent, a Paper) which has the highest database ID, just always drops in the chests, at least for me, without fail. If there isn't an easy fix for that, I will probably just allow that item to drop to the chests occasionally by randomizing again that ID, till it doesn't give me a different one via events.
Is your game setup like you did in the demo?

If it is then the issue is the values used in the notetags.
you have lines like <SUFFIX11 100>
the 100 is the percentage chance that it will occur. 100 = 100%

If this is not what you have then I'm not sure.
That was setup just for the demo, and its not for the randomized weapons and armors, its for the items with the lowest quality, ehichin my case, are reagents(items). As Another Fen said, the item with the highest database ID will get picked constantly, and that is the case, that one Paper for me has the highest database ID, so it just drops constantly. However, with events, I should be able to randomize it again, to force drop an another item with a different ID, like in the demo (if the dropped weapon's ID was 0, then it just didnt generated nothing. But in my case, It will just generate new item ID's until I get a different one). I will have to build around this small issue in the game, but its not a huge issue.

Original thread: https://forums.rpgmakerweb.com/threads/need-a-simple-change-in-galvs-random-loot-script.89820/