Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[request]Customizable item max, can be changed in event[resolved,thanks to khmp]

Can anyone write a script that:
- allows you to change the maximum amount of items you can have for each item
- have maximum items exceed 99
?

Thanks,
OZ

By the way it's for vx
 

khmp

Sponsor

XP Version:

Code:
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold 
#  and items. Refer to "$game_party" for the instance of this class.
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  MAX_ITEMS = 255
  MAX_ARMORS = 255
  MAX_WEAPONS = 255
  #--------------------------------------------------------------------------
  # * Gain Items (or lose)
  #     item_id : item ID
  #     n       : quantity
  #--------------------------------------------------------------------------
  def gain_item(item_id, n)
    # Update quantity data in the hash.
    if item_id > 0
      @items[item_id] = [[item_number(item_id) + n, 0].max, MAX_ITEMS].min
    end
  end
  #--------------------------------------------------------------------------
  # * Gain Weapons (or lose)
  #     weapon_id : weapon ID
  #     n         : quantity
  #--------------------------------------------------------------------------
  def gain_weapon(weapon_id, n)
    # Update quantity data in the hash.
    if weapon_id > 0
      @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, MAX_ARMORS].min
    end
  end
  #--------------------------------------------------------------------------
  # * Gain Armor (or lose)
  #     armor_id : armor ID
  #     n        : quantity
  #--------------------------------------------------------------------------
  def gain_armor(armor_id, n)
    # Update quantity data in the hash.
    if armor_id > 0
      @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, MAX_WEAPONS].min
    end
  end
end

I think that should do it.
 

khmp

Sponsor

VX Version:

Code:
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold 
# and items. The instance of this class is referenced by $game_party.
#==============================================================================

class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  MAX_ITEMS = 255
  MAX_ARMORS = 255
  MAX_WEAPONS = 255
  #--------------------------------------------------------------------------
  # * Gain Items (or lose)
  #     item          : Item
  #     n             : Number
  #     include_equip : Include equipped items
  #--------------------------------------------------------------------------
  def gain_item(item, n, include_equip = false)
    number = item_number(item)
    case item
    when RPG::Item
      @items[item.id] = [[number + n, 0].max, MAX_ITEMS].min
    when RPG::Weapon
      @weapons[item.id] = [[number + n, 0].max, MAX_WEAPONS].min
    when RPG::Armor
      @armors[item.id] = [[number + n, 0].max, MAX_ARMORS].min
    end
    n += number
    if include_equip and n < 0
      for actor in members
        while n < 0 and actor.equips.include?(item)
          actor.discard_equip(item)
          n += 1
        end
      end
    end
  end
end
 

khmp

Sponsor

VX Code:

omegazion has requested a change be made to have the ability to adjust these values in game.

Code:
#==============================================================================
# ** Inventory_Limits
#------------------------------------------------------------------------------
#  This class holds the values that dictate the maximum values of that the 
#  inventory can hold.
#==============================================================================

module Inventory_Limits
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  @max_items = 99
  @max_armors = 99
  @max_weapons = 99
  #--------------------------------------------------------------------------
  # * Max Items =
  #     max_items : the new maximum amount of items you can have.
  #--------------------------------------------------------------------------
  def self.max_items=(max_items)
    return unless max_items.is_a?(Integer) || max_items < 0
    @max_items = max_items
    return if $game_party.nil?
    $game_party.get_items.each do |id, amount|
      $game_party.change_item(id, [amount, @max_items].min)
    end
  end
  #--------------------------------------------------------------------------
  # * Max Items
  #--------------------------------------------------------------------------
  def self.max_items
    return @max_items
  end
  #--------------------------------------------------------------------------
  # * Max Weapons =
  #     max_weapons : the new maximum amount of weapons you can have.
  #--------------------------------------------------------------------------
  def self.max_weapons=(max_weapons)
    return unless max_weapons.is_a?(Integer) || max_weapons < 0
    @max_weapons = max_weapons
    return if $game_party.nil?
    $game_party.weapons.each do |id, amount|
      $game_party.weapons[id] = [amount, @max_weapons].min
    end
  end
  #--------------------------------------------------------------------------
  # * Max Weapons
  #--------------------------------------------------------------------------
  def self.max_weapons
    return @max_weapons
  end
  #--------------------------------------------------------------------------
  # * Max Armors =
  #     max_items : the new maximum amount of armors you can have.
  #--------------------------------------------------------------------------
  def self.max_armors=(max_armors)
    return unless max_armors.is_a?(Integer) || max_armors < 0
    @max_armors = max_armors
    return if $game_party.nil?
    $game_party.armors.each do |id, amount|
      $game_party.armors[id] = [amount, @max_armors].min
    end
  end
  #--------------------------------------------------------------------------
  # * Max Armors
  #--------------------------------------------------------------------------
  def self.max_armors
    return @max_armors
  end
  #--------------------------------------------------------------------------
  # * Max All =
  #     max_all : the new max of items, weapons, and armors you can have.
  #--------------------------------------------------------------------------
  def self.max_all(max_all)
    return unless max_all.is_a?(Integer) || max_all < 0
    self.max_items = max_all
    self.max_weapons = max_all
    self.max_armors = max_all
  end
end

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold 
# and items. The instance of this class is referenced by $game_party.
#==============================================================================

class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :armors, :weapons
  #--------------------------------------------------------------------------
  # * Gain Items (or lose) !OVERRIDE!
  #     item          : Item
  #     n             : Number
  #     include_equip : Include equipped items
  #--------------------------------------------------------------------------
  def gain_item(item, n, include_equip = false)
    number = item_number(item)
    case item
    when RPG::Item
      @items[item.id] = [[number + n, 0].max, Inventory_Limits.max_items].min
    when RPG::Weapon
      @weapons[item.id] = [[number + n, 0].max, Inventory_Limits.max_weapons].min
    when RPG::Armor
      @armors[item.id] = [[number + n, 0].max, Inventory_Limits.max_armors].min
    end
    n += number
    if include_equip and n < 0
      for actor in members
        while n < 0 and actor.equips.include?(item)
          actor.discard_equip(item)
          n += 1
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Get The Items
  #--------------------------------------------------------------------------
  def get_items
    return @items
  end
  #--------------------------------------------------------------------------
  # * Change Item
  #     id     : the id of the item you want to change the amount of.
  #     amount : the amount of the item.
  #--------------------------------------------------------------------------
  def change_item(id, amount)
    return unless @items.has_key?(id)
    @items[id] = amount
  end
end

A quick "Why that design?" tidbit. I'm using a module for the sake of avoiding a saving loading error by adding extras to Game_Party. Anyway from within a "Script..." event command call you can now use the following lines to limit inventory.
Code:
Inventory_Limits.max_items = n
Inventory_Limits.max_armors = n
Inventory_Limits.max_weapons = n
Inventory_Limits.max_all = n
Where n is the new limit to the particular inventory type. "max_all" adjusts every maximum value for convenience.

If the amount of inventory exceeds the maximum when the change is made the max inventory currently in your party will be capped to the new maximum. Meaning if at some point you want to limit the number of items to 50 and you have 75 potions. 15 Potions will be lost and will not be recoverable.

@strager: If you set the maximum to something less than 99 will it create and take up multiple slots? No it will not. If you set the max to 9 you can carry 9 of that particular inventory type.
 
thank you very much. although i haven't tested... does the new limit script change the limit for a specific item, or for a general inventory type? because i would want the earlier.
 

khmp

Sponsor

... :dead: You should mention that clearly for the sake of my sanity. Right now its set for inventory overall, not item specific. *drags feet back to uncomfortable swivel chair* Let me get back to work.

[edit]
Ok. There are three more constants to be aware of at the top of Inventory_Limits. Change these numbers to the indexes of the $game_variables you will use to have the inventory limits too. Just because I didn't want to destroy any previous saves. To specify a item maximum now:
Code:
Inventory_Limits.item_max(item_id, new_max)
Inventory_Limits.weapon_max(weapon_id, new_max)
Inventory_Limits.armor_max(armor_id, new_max)

I recommend saving a game first and not loading an existing save as it will reset the inventory limits to a default of 99.

Code:
#==============================================================================
# ** Inventory_Limits
#------------------------------------------------------------------------------
#  This class holds the values that dictate the maximum values of that the 
#  inventory can hold.
#==============================================================================

module Inventory_Limits
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  #------------------------------------------------------------------------
  # - Items_Hash_Index
  #     The index in $game_variables where the items hash is stored.
  #------------------------------------------------------------------------
  Items_Hash_Index = 1
  #------------------------------------------------------------------------
  # - Weapons_Hash_Index
  #     The index in $game_variables where the weapons hash is stored.
  #------------------------------------------------------------------------
  Weapons_Hash_Index = 2
  #------------------------------------------------------------------------
  # - Armors_Hash_Index
  #     The index in $game_variables where the armors hash is stored.
  #------------------------------------------------------------------------
  Armors_Hash_Index = 3
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  @max_items = {
    0 => 60,
    1 => 100,
    4 => 50,
  }
  # If the item is not mentioned in the max items hash.
  @max_items.default = 99
  
  @max_armors = {
    0 => 255,
    1 => 100,
    4 => 70,
  }
  # If the item is not mentioned in the max armors hash.
  @max_armors.default = 99
  
  @max_weapons = {
    0 => 2,
    1 => 67,
    4 => 123,
  }
  @max_weapons.default = 99
  #--------------------------------------------------------------------------
  # * Max Items =
  #     item_id   : the id of the item you want to set the max for.
  #     max_items : the new maximum amount of items you can have.
  #--------------------------------------------------------------------------
  def self.max_items=(item_id, max_items)
    return unless max_items.is_a?(Integer) || max_items < 0 
    @max_items[item_id] = max_items
    
    return if $game_party.nil?
    if $game_party.get_items.has_key?(item_id)
      $game_party.change_item(item_id, [amount, @max_items[item_id]].min)
    end
  end
  #--------------------------------------------------------------------------
  # * Max Items
  #     item_id : the id of the item you are trying to retrieve the max for.
  #--------------------------------------------------------------------------
  def self.max_items(item_id = nil)
    return @max_items[item_id]
  end
  #--------------------------------------------------------------------------
  # * Max Weapons =
  #     weapon_id   : the id of the weapon you are trying to set the max for.
  #     max_weapons : the new maximum amount of weapons you can have.
  #--------------------------------------------------------------------------
  def self.max_weapons=(weapon_id, max_weapons)
    return unless max_weapons.is_a?(Integer) || max_weapons < 0
    @max_weapons[weapon_id] = max_weapons
    
    return if $game_party.nil?
    if $game_party.weapons.has_key?(weapon_id)
      $game_party.weapons[weapon_id] = [amount, @max_weapons[weapon_id]].min
    end
  end
  #--------------------------------------------------------------------------
  # * Max Weapons
  #     weapon_id : the id of the weapon  you are trying to retrieve the max 
  #                 for.
  #--------------------------------------------------------------------------
  def self.max_weapons(weapon_id = nil)
    return @max_weapons[weapon_id]
  end
  #--------------------------------------------------------------------------
  # * Max Armors =
  #     armor_id  : the id of the armor you are trying to set the max for.
  #     max_items : the new maximum amount of armors you can have.
  #--------------------------------------------------------------------------
  def self.max_armors=(armor_id, max_armors)
    return unless max_armors.is_a?(Integer) || max_armors < 0
    @max_armors[armor_id] = max_armors
    
    return if $game_party.nil?
    if $game_party.armors.has_key?(armor_id)
      $game_party.armors[armor_id] = [amount, @max_armors[armor_id]].min
    end
  end
  #--------------------------------------------------------------------------
  # * Max Armors
  #     armor_id : the id of the armor you are trying to retrieve the max 
  #                for.
  #--------------------------------------------------------------------------
  def self.max_armors(armor_id = nil)
    return @max_armors[armor_id]
  end
  
  def self.get_items
    return @max_items
  end
  
  def self.get_weapons
    return @max_weapons
  end
  
  def self.get_armors
    return @max_armors
  end
  
  def self.set_items=(items)
    @max_items = items
  end
  
  def self.set_weapons=(weapons)
    @max_weapons = weapons
  end
  
  def self.set_armors=(armors)
    @max_armors = armors
  end
end

#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
#  This class performs the save and load screen processing.
#==============================================================================

class Scene_File < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias_method :omon_item_max_scene_file_do_save, :do_save
  alias_method :omon_item_max_scene_file_do_load, :do_load
  #--------------------------------------------------------------------------
  # * Execute Save
  #--------------------------------------------------------------------------
  def do_save
    # Save the current items to the $game_variables.
    $game_variables[Inventory_Limits::Items_Hash_Index] = 
      Inventory_Limits.get_items
      
    $game_variables[Inventory_Limits::Weapons_Hash_Index] = 
      Inventory_Limits.get_weapons
      
    $game_variables[Inventory_Limits::Armors_Hash_Index] = 
      Inventory_Limits.get_armors
    
    omon_item_max_scene_file_do_save
  end
  #--------------------------------------------------------------------------
  # * Execute Load
  #--------------------------------------------------------------------------
  def do_load
    omon_item_max_scene_file_do_load
    
    if $game_variables[Inventory_Limits::Items_Hash_Index].is_a?(Hash)
      Inventory_Limits.set_items = 
        $game_variables[Inventory_Limits::Items_Hash_Index]
    else
      items = Hash.new
      items.default = 99
      Inventory_Limits.set_items = items
    end
    
    if $game_variables[Inventory_Limits::Weapons_Hash_Index].is_a?(Hash)
      # Load the loaded items.
      Inventory_Limits.set_weapons = 
        $game_variables[Inventory_Limits::Weapons_Hash_Index]
    else
      weapons = Hash.new
      weapons.default = 99
      Inventory_Limits.set_items = weapons
    end
    
    if $game_variables[Inventory_Limits::Armors_Hash_Index].is_a?(Hash)
      # Load the loaded items.
      Inventory_Limits.set_armors = 
        $game_variables[Inventory_Limits::Armors_Hash_Index]
    else
      armors = Hash.new
      armors.default = 99
      Inventory_Limits.set_items = armors
    end
  end
end

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold 
# and items. The instance of this class is referenced by $game_party.
#==============================================================================

class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :armors, :weapons
  #--------------------------------------------------------------------------
  # * Gain Items (or lose) !OVERRIDE!
  #     item          : Item
  #     n             : Number
  #     include_equip : Include equipped items
  #--------------------------------------------------------------------------
  def gain_item(item, n, include_equip = false)
    number = item_number(item)
    case item
    when RPG::Item
      @items[item.id] = 
        [[number + n, 0].max, Inventory_Limits.max_items(item.id)].min
    when RPG::Weapon
      @weapons[item.id] = 
        [[number + n, 0].max, Inventory_Limits.max_weapons(item.id)].min
    when RPG::Armor
      @armors[item.id] = 
        [[number + n, 0].max, Inventory_Limits.max_armors(item.id)].min
    end
    n += number
    if include_equip and n < 0
      for actor in members
        while n < 0 and actor.equips.include?(item)
          actor.discard_equip(item)
          n += 1
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Get The Items
  #--------------------------------------------------------------------------
  def get_items
    return @items
  end
  #--------------------------------------------------------------------------
  # * Change Item
  #     id     : the id of the item you want to change the amount of.
  #     amount : the amount of the item.
  #--------------------------------------------------------------------------
  def change_item(id, amount)
    return unless @items.has_key?(id)
    @items[id] = amount
  end
end
 
question about your last script...

khmp":2a3m4tfd said:
... :dead: You should mention that clearly for the sake of my sanity. Right now its set for inventory overall, not item specific. *drags feet back to uncomfortable swivel chair* Let me get back to work.

[edit]
Ok. There are three more constants to be aware of at the top of Inventory_Limits. Change these numbers to the indexes of the $game_variables you will use to have the inventory limits too. Just because I didn't want to destroy any previous saves. To specify a item maximum now:
Code:
Inventory_Limits.item_max(item_id, new_max)
Inventory_Limits.weapon_max(weapon_id, new_max)
Inventory_Limits.armor_max(armor_id, new_max)

I recommend saving a game first and not loading an existing save as it will reset the inventory limits to a default of 99.

Code:
#==============================================================================
# ** Inventory_Limits
#------------------------------------------------------------------------------
#  This class holds the values that dictate the maximum values of that the 
#  inventory can hold.
#==============================================================================

module Inventory_Limits
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  #------------------------------------------------------------------------
  # - Items_Hash_Index
  #     The index in $game_variables where the items hash is stored.
  #------------------------------------------------------------------------
  Items_Hash_Index = 1
  #------------------------------------------------------------------------
  # - Weapons_Hash_Index
  #     The index in $game_variables where the weapons hash is stored.
  #------------------------------------------------------------------------
  Weapons_Hash_Index = 2
  #------------------------------------------------------------------------
  # - Armors_Hash_Index
  #     The index in $game_variables where the armors hash is stored.
  #------------------------------------------------------------------------
  Armors_Hash_Index = 3
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  @max_items = {
    0 => 60,
    1 => 100,
    4 => 50,
  }
  # If the item is not mentioned in the max items hash.
  @max_items.default = 99
  
  @max_armors = {
    0 => 255,
    1 => 100,
    4 => 70,
  }
  # If the item is not mentioned in the max armors hash.
  @max_armors.default = 99
  
  @max_weapons = {
    0 => 2,
    1 => 67,
    4 => 123,
  }
  @max_weapons.default = 99
  #--------------------------------------------------------------------------
  # * Max Items =
  #     item_id   : the id of the item you want to set the max for.
  #     max_items : the new maximum amount of items you can have.
  #--------------------------------------------------------------------------
  def self.max_items=(item_id, max_items)
    return unless max_items.is_a?(Integer) || max_items < 0 
    @max_items[item_id] = max_items
    
    return if $game_party.nil?
    if $game_party.get_items.has_key?(item_id)
      $game_party.change_item(item_id, [amount, @max_items[item_id]].min)
    end
  end
  #--------------------------------------------------------------------------
  # * Max Items
  #     item_id : the id of the item you are trying to retrieve the max for.
  #--------------------------------------------------------------------------
  def self.max_items(item_id = nil)
    return @max_items[item_id]
  end
  #--------------------------------------------------------------------------
  # * Max Weapons =
  #     weapon_id   : the id of the weapon you are trying to set the max for.
  #     max_weapons : the new maximum amount of weapons you can have.
  #--------------------------------------------------------------------------
  def self.max_weapons=(weapon_id, max_weapons)
    return unless max_weapons.is_a?(Integer) || max_weapons < 0
    @max_weapons[weapon_id] = max_weapons
    
    return if $game_party.nil?
    if $game_party.weapons.has_key?(weapon_id)
      $game_party.weapons[weapon_id] = [amount, @max_weapons[weapon_id]].min
    end
  end
  #--------------------------------------------------------------------------
  # * Max Weapons
  #     weapon_id : the id of the weapon  you are trying to retrieve the max 
  #                 for.
  #--------------------------------------------------------------------------
  def self.max_weapons(weapon_id = nil)
    return @max_weapons[weapon_id]
  end
  #--------------------------------------------------------------------------
  # * Max Armors =
  #     armor_id  : the id of the armor you are trying to set the max for.
  #     max_items : the new maximum amount of armors you can have.
  #--------------------------------------------------------------------------
  def self.max_armors=(armor_id, max_armors)
    return unless max_armors.is_a?(Integer) || max_armors < 0
    @max_armors[armor_id] = max_armors
    
    return if $game_party.nil?
    if $game_party.armors.has_key?(armor_id)
      $game_party.armors[armor_id] = [amount, @max_armors[armor_id]].min
    end
  end
  #--------------------------------------------------------------------------
  # * Max Armors
  #     armor_id : the id of the armor you are trying to retrieve the max 
  #                for.
  #--------------------------------------------------------------------------
  def self.max_armors(armor_id = nil)
    return @max_armors[armor_id]
  end
  
  def self.get_items
    return @max_items
  end
  
  def self.get_weapons
    return @max_weapons
  end
  
  def self.get_armors
    return @max_armors
  end
  
  def self.set_items=(items)
    @max_items = items
  end
  
  def self.set_weapons=(weapons)
    @max_weapons = weapons
  end
  
  def self.set_armors=(armors)
    @max_armors = armors
  end
end

#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
#  This class performs the save and load screen processing.
#==============================================================================

class Scene_File < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias_method :omon_item_max_scene_file_do_save, :do_save
  alias_method :omon_item_max_scene_file_do_load, :do_load
  #--------------------------------------------------------------------------
  # * Execute Save
  #--------------------------------------------------------------------------
  def do_save
    # Save the current items to the $game_variables.
    $game_variables[Inventory_Limits::Items_Hash_Index] = 
      Inventory_Limits.get_items
      
    $game_variables[Inventory_Limits::Weapons_Hash_Index] = 
      Inventory_Limits.get_weapons
      
    $game_variables[Inventory_Limits::Armors_Hash_Index] = 
      Inventory_Limits.get_armors
    
    omon_item_max_scene_file_do_save
  end
  #--------------------------------------------------------------------------
  # * Execute Load
  #--------------------------------------------------------------------------
  def do_load
    omon_item_max_scene_file_do_load
    
    if $game_variables[Inventory_Limits::Items_Hash_Index].is_a?(Hash)
      Inventory_Limits.set_items = 
        $game_variables[Inventory_Limits::Items_Hash_Index]
    else
      items = Hash.new
      items.default = 99
      Inventory_Limits.set_items = items
    end
    
    if $game_variables[Inventory_Limits::Weapons_Hash_Index].is_a?(Hash)
      # Load the loaded items.
      Inventory_Limits.set_weapons = 
        $game_variables[Inventory_Limits::Weapons_Hash_Index]
    else
      weapons = Hash.new
      weapons.default = 99
      Inventory_Limits.set_items = weapons
    end
    
    if $game_variables[Inventory_Limits::Armors_Hash_Index].is_a?(Hash)
      # Load the loaded items.
      Inventory_Limits.set_armors = 
        $game_variables[Inventory_Limits::Armors_Hash_Index]
    else
      armors = Hash.new
      armors.default = 99
      Inventory_Limits.set_items = armors
    end
  end
end

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold 
# and items. The instance of this class is referenced by $game_party.
#==============================================================================

class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :armors, :weapons
  #--------------------------------------------------------------------------
  # * Gain Items (or lose) !OVERRIDE!
  #     item          : Item
  #     n             : Number
  #     include_equip : Include equipped items
  #--------------------------------------------------------------------------
  def gain_item(item, n, include_equip = false)
    number = item_number(item)
    case item
    when RPG::Item
      @items[item.id] = 
        [[number + n, 0].max, Inventory_Limits.max_items(item.id)].min
    when RPG::Weapon
      @weapons[item.id] = 
        [[number + n, 0].max, Inventory_Limits.max_weapons(item.id)].min
    when RPG::Armor
      @armors[item.id] = 
        [[number + n, 0].max, Inventory_Limits.max_armors(item.id)].min
    end
    n += number
    if include_equip and n < 0
      for actor in members
        while n < 0 and actor.equips.include?(item)
          actor.discard_equip(item)
          n += 1
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Get The Items
  #--------------------------------------------------------------------------
  def get_items
    return @items
  end
  #--------------------------------------------------------------------------
  # * Change Item
  #     id     : the id of the item you want to change the amount of.
  #     amount : the amount of the item.
  #--------------------------------------------------------------------------
  def change_item(id, amount)
    return unless @items.has_key?(id)
    @items[id] = amount
  end
end

is this used without the one above it? or do you need both

hmm now to find a weight script XD
 

khmp

Sponsor

It depends on what you want but only one script will suffice. The latest one, which you have quoted and is for VX. It has limits for specific items. Like if you only ever wanted to carry 6 potions and 10 tents and really your item maximums are all over the place you would use that one.

Further up the thread there are different versions depending upon your taste. The one that I think you are referring to above will set the item limit to 99 by default for an entire item type. But allows for change during play. Now the one above that which is also the first one I made for VX hard codes a constant to be a specific value not meant to changed while playing. And lastly my first post is for XP and is the equivalent of the last VX code I just described.

Well for a hunger script as I know there are plenty around use the search function at the top of this page. Limit it to Submitted Scripts. If the search fails create a request here and be thorough as possible. Make sure to follow the rules when you do so though.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top