The RPG Maker Resource Kit

RMRK RPG Maker Creation => XP => XP Scripts Database => Topic started by: Synthesize on August 15, 2007, 10:00:57 PM

Title: Maximum Item Limits
Post by: Synthesize on August 15, 2007, 10:00:57 PM
Script Name: Maximum item Limits
Written by: Synthesize
Current Version: V.1.00
Release Date: August 15, 2007

What is it?
This script rewrites the gain_ methods in Game_Party allowing the designer to define maximum item, weapon and armor limits. Also, item IDs, weapon IDs, and Armor IDs can be defined allowing one to define custom item limits for specific items.

Screenshots
Look at the item screen, instead of '99' the value is x.

The Script
Place above Main
[spoiler]

#============================================================================
# *Syn's Maximum Item Limits*
#----------------------------------------------------------------------------
# Written by Synthesize
# Version 1.00
# August 15, 2007
#============================================================================
#----------------------------------------------------------------------------
# Compatability
# Rewrites:
#   Game_Party::gain_item
#   Game_Party::gain_weapon
#   Game_Party::gain_armor
#----------------------------------------------------------------------------
# Begin Customization Section
#----------------------------------------------------------------------------
module SynItemMax
  # Format = {item_id => maximum amount}
  Max_item = {32 => 100}
  # Default Max Item Storage
  Max_item.default = 100
  # Format = {weapon_id => maximum amount}
  Max_weapon = {}
  # Maximum Weapon storage
  Max_weapon.default = 99
  # Format = {armor_id => maximum amount}
  Max_armor = {}
  # Maximum storage space
  Max_armor.default = 99
end
#----------------------------------------------------------------------------
# Begin Game_Party rewrite
#----------------------------------------------------------------------------
class  Game_Party
  #--------------------------------------------------------------------------
  # Rewrite gain_item
  #--------------------------------------------------------------------------
  def gain_item(item_id,n)
if item_id > 0
  @items[item_id] = [[item_number(item_id) + n, 0].max, SynItemMax::Max_item[item_id]].min
end
  end
  #--------------------------------------------------------------------------
  # Rewrite gain_weapon
  #--------------------------------------------------------------------------
  def gain_weapon(weapon_id,n)
if weapon_id > 0
  @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, SynItemMax::Max_weapon[weapon_id]].min
end
  end
  #--------------------------------------------------------------------------
  # Rewrite gain_armor
  #--------------------------------------------------------------------------
  def gain_armor(armor_id,n)
if armor_id > 0
  @armor[armor_id] = [[armor_number(armor_id) + n, 0].max, SynItemMax::Max_armor[armor_id]].min
end
  end
end
#============================================================================
# Written by Synthesize
# Version 1.00
# August 15, 2007
#----------------------------------------------------------------------------
#    *Syns Maximum Item Limits*
#============================================================================

[/spoiler]


Usage:
This script may be used in either a commercial project or a free ware project free of charge. However, credit must be present somewhere in the project.

Editing/Distribution:
Feel free to redistribute this post to other boards/websites. Just keep the wording the same. As for editing the script to suite your tastes feel free. Just keep the original header/footer in tact.

If you have any questions or you found a bug, please PM me or make a post with the following:
1.) SDK Version
2.) Other Scripts
3.) Factors of the bug (What did you do to make it happen?)
4.) version
5.) Error Line

Cheers,

Syn
Title: Re: Maximum Item Limits
Post by: Irock on August 15, 2007, 10:03:07 PM
Sounds awesome. People could really get some use out of this.
Title: Re: Maximum Item Limits
Post by: :) on August 15, 2007, 10:22:12 PM
looks very cook :D
can't wait to see more scripts.
Title: Re: Maximum Item Limits
Post by: modern algebra on August 16, 2007, 03:59:43 AM
Another nice script. I hope to see you around the forums a little more. It's nice to see more scripters.
Title: Re: Maximum Item Limits
Post by: Demonic Blade on December 22, 2007, 05:49:52 PM
So by changing the numbers in the script you change how many of that item you can have in your inventory at one time?  :-\ Ah, well cool anyways, and I like that it's so short- really makes it easier when you just have one simple script like that!  ;D
Title: Re: Maximum Item Limits
Post by: Djeff on September 29, 2009, 06:33:03 PM
Can it also make your player only have a maximum of 20 items in the game.
Title: Re: Maximum Item Limits
Post by: Miss Nile on September 29, 2009, 06:53:46 PM
Was it really worth necroposting when you can just look at the script here,

#============================================================================
#                     *Syn's Maximum Item Limits*
#----------------------------------------------------------------------------
# Written by Synthesize
# Version 1.00
# August 15, 2007
#============================================================================
#----------------------------------------------------------------------------
# Compatability
# Rewrites:
#   Game_Party::gain_item
#   Game_Party::gain_weapon
#   Game_Party::gain_armor
#----------------------------------------------------------------------------
# Begin Customization Section
#----------------------------------------------------------------------------
module SynItemMax
  # Format = {item_id => maximum amount}
  Max_item = {32 => 100}
  # Default Max Item Storage
  Max_item.default = 100
  # Format = {weapon_id => maximum amount}
  Max_weapon = {}
  # Maximum Weapon storage
  Max_weapon.default = 99
  # Format = {armor_id => maximum amount}
  Max_armor = {}
  # Maximum storage space
  Max_armor.default = 99
end
#----------------------------------------------------------------------------
# Begin Game_Party rewrite
#----------------------------------------------------------------------------
class  Game_Party
  #--------------------------------------------------------------------------
  # Rewrite gain_item
  #--------------------------------------------------------------------------
  def gain_item(item_id,n)
   if item_id > 0
     @items[item_id] = [[item_number(item_id) + n, 0].max, SynItemMax::Max_item[item_id]].min
   end
  end
  #--------------------------------------------------------------------------
  # Rewrite gain_weapon
  #--------------------------------------------------------------------------
  def gain_weapon(weapon_id,n)
   if weapon_id > 0
     @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, SynItemMax::Max_weapon[weapon_id]].min
   end
  end
  #--------------------------------------------------------------------------
  # Rewrite gain_armor
  #--------------------------------------------------------------------------
  def gain_armor(armor_id,n)
   if armor_id > 0
     @armor[armor_id] = [[armor_number(armor_id) + n, 0].max, SynItemMax::Max_armor[armor_id]].min
   end
  end
end
#============================================================================
# Written by Synthesize
# Version 1.00
# August 15, 2007
#----------------------------------------------------------------------------
#               *Syns Maximum Item Limits*
#============================================================================
Title: Re: Maximum Item Limits
Post by: Djeff on September 30, 2009, 11:26:04 AM
I already tried doing that but no work
Title: Re: Maximum Item Limits
Post by: Mr_Wiggles on December 01, 2009, 08:08:36 AM
i find interst in your script because of the game im makeing you carry ammo and 99 bulets in a machine gun dont go very far... however it doesn't seem to work
i edit it but still the limits are 99