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.

Party Max Item Quantities

Party Max Item QuantitiesVersion: 2.5
By: Kain Nobel

Introduction

This is a simple script allows you to set a limit to how many Items, Armors and/or Weapons the player can gain.

Features
  • Ability to limit any item individually
  • Can break the 99 max of gaining items
  • Easy to setup

Script

Code:
#===============================================================================

# ** Party : Maximum Item Quantities

#===============================================================================

 

#-------------------------------------------------------------------------------

# * SDK Log

#-------------------------------------------------------------------------------

if Object.const_defined?(:SDK)

  SDK.log('Party.MaxItemQuants', 'Kain Nobel ©', 2.5, '12.10.2008')

  SDK.log_overwrite(:Game_Party, :gain_item)

  SDK.log_overwrite(:Game_Party, :gain_weapon)

  SDK.log_overwrite(:Game_Party, :gain_armor)

end

 

#===============================================================================

# ** Game_Party

#===============================================================================

 

class Game_Party

  #-----------------------------------------------------------------------------

  # * Cant Gain Items   (Used for Dummy Items)

  #-----------------------------------------------------------------------------

  Cant_Gain_Items   = []

  #-----------------------------------------------------------------------------

  # * Cant Gain Weapons (Used for Dummy Weapons)

  #-----------------------------------------------------------------------------

  Cant_Gain_Weapons = []

  #-----------------------------------------------------------------------------

  # * Cant Gain Armors  (Used for Dummy Armors)

  #-----------------------------------------------------------------------------

  Cant_Gain_Armors  = []

  #-----------------------------------------------------------------------------

  # * Maximum Items   = {item_id => max_quantity}

  #-----------------------------------------------------------------------------

  Max_Items = {}

  Max_Items.default = 99

  #-----------------------------------------------------------------------------

  # * Maximum Weapons = {item_id => max_quantity}

  #-----------------------------------------------------------------------------

  Max_Weapons = {}

  Max_Weapons.default = 99

  #-----------------------------------------------------------------------------

  # * Maximum Armors  = {item_id => max_quantity

  #-----------------------------------------------------------------------------

  Max_Armors = {}

  Max_Armors.default = 99

  #-----------------------------------------------------------------------------

  # * Gain Item

  #-----------------------------------------------------------------------------

  def gain_item(id, n)

    if id > 0

      @items[id] = [[item_number(id) + n, 0].max, Max_Items[id]].min

    end

    @items[id] = 0 if Cant_Gain_Items.include?(id)

  end

  #-----------------------------------------------------------------------------

  # * Gain Armor

  #-----------------------------------------------------------------------------

  def gain_armor(id, n)

    if id > 0

      @armors[id] = [[armor_number(id) + n, 0].max, Max_Armors[id]].min

    end

    @armors[id] = 0 if Cant_Gain_Armors.include?(id)

  end

  #-----------------------------------------------------------------------------

  # * Gain Weapon

  #-----------------------------------------------------------------------------

  def gain_weapon(id, n)

    if id > 0

      @weapons[id] = [[weapon_number(id) + n, 0].max, Max_Weapons[id]].min

    end

    @weapons[id] = 0 if Cant_Gain_Weapons.include?(id)

  end

end

Instructions

Paste below 'Scene_Debug' (and 'SDK', if using), so long as it is above 'main'

Setting a max limit to an item/armor/weapon is as easy as...

{1 => 5} # (Meaning that Item ID 1 has a max limit of 5 can be gained)

FAQ

Q.) I set it so that the player can gain 100 Potions but it doesn't display correctly in my Items menu.
A.) Its up to you to edit your menus to display more than 99 items :P

Compatibility

This script overwrites the following methods of Game_Party

  • gain_item
  • gain_weapon
  • gain_armor

So place above anything that aliases these methods

Terms and Conditions

Free to use in any commercial or non-commercial game, please put my name in your credits if you use.
 

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