Quote from: game_guy on July 14, 2009, 12:14:58 pm
Too late WcW here you go grh oh and you can use this in your commercial game too ^_^
#===============================================================================
# Party Item Limit
# Author: game_guy
# Date: June 6th, 2009
#-------------------------------------------------------------------------------
# Intro
# What this script does is set the party's item limit. For instance say the
# party item limit is 10. You can only hold 10 different items/weapons/armors.
# For example you have 6 potions and 4 high potions. You won't be able to
# Carry anything else.
#
# Features
# * Limits how many items the party can carry
#
# Instructions
# Go down to the BEGIN CONFIG and you'll see this line
# @max_items = 20
# @max_weapons = 20
# @max_armors = 20
# Change that 20 to whatever you like.
# You can also change that number in game using this in a script call
# $game_system.max_items = x
# $game_system.max_weapons = x
# $game_system.max_armor = x
# x = number
#
# Credits
# game_guy ~ for making it
# Xuroth ~ inspiring me with the idea of a post
# link to post
# http://forum.chaos-project.com/index.php?topic=3444.msg74388#msg74388
#===============================================================================
#===============================================================================
# Game_System
#-------------------------------------------------------------------------------
# *Changed one method
#===============================================================================
class Game_System
attr_accessor :max_items
attr_accessor :max_weapons
attr_accessor :max_armor
alias add_max_items initialize
def initialize
#===========================================================================
# BEGIN CONFIG
@max_items = 20 # Change this to the max items you want the party to carry
@max_weapons = 20 # Change this to the max weapons you want the party to carry
@max_armor = 20 # Change this to the max armor you want the party to carry
# END CONFIG
#===========================================================================
add_max_items
end
end
#===============================================================================
# Game_Party
#-------------------------------------------------------------------------------
# *Added one method
# *changed three methods
#===============================================================================
class Game_Party
#=============================================================================
# Get Item Total
#=============================================================================
def get_item_total
amount = 0
for i in 1...$data_items.size
if item_number(i) > 0
amount += item_number(i)
end
end
return amount
end
#=============================================================================
# Get Armor Total
#=============================================================================
def get_armor_total
amount = 0
for i in 1...$data_armors.size
if armor_number(i) > 0
amount += armor_number(i)
end
end
return amount
end
#=============================================================================
# Get Weapon Total
#=============================================================================
def get_weapon_total
amount = 0
for i in 1...$data_weapons.size
if weapon_number(i) > 0
amount += weapon_number(i)
end
end
return amount
end
#=============================================================================
# Gain Item
#=============================================================================
def gain_item(item_id, n)
if item_id > 0
itemamount = get_item_total
unless itemamount >= $game_system.max_items
number = $game_system.max_items - itemamount
if n > number
n = number
end
@items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
end
end
end
#=============================================================================
# Gain Weapon
#=============================================================================
def gain_weapon(weapon_id, n)
if weapon_id > 0
itemamount = get_weapon_total
unless itemamount >= $game_system.max_weapons
number = $game_system.max_weapons - itemamount
if n > number
n = number
end
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
end
end
end
#=============================================================================
# Gain Armor
#=============================================================================
def gain_armor(armor_id, n)
if armor_id > 0
itemamount = get_armor_total
unless itemamount >= $game_system.max_armor
number = $game_system.max_armor - itemamount
if n > number
n = number
end
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
end
end
end
end
Dear god, that's waaaaay too long...
=begin
Item/Armor/Weapon Limits, v 1.00
by Collin Wright, aka WcW, aka WcWofEleven, aka Longfellow
Introduction:
This script allows for you to set a limit on the number of items, armors, or
weapons the player may have in his/her inventory at any given moment.
Instructions:
To set the initial values:
- Hit Ctrl+F, and type "INV_LIMIT CONFIG"
- Change the values within the section; they're fairly self-explanatory (-1 disables the limit for that type of item)
To change in game:
- Add a "Call Script" command to your event
- Use this code for items:
$game_system.wcw_max_items = <x>
And replace <x> with the desired limit
- To change the same for weapons and armor, replace "items" with "weapons" and "armor", respectively
Notes:
To all you scripters who look over this and say, "ZOMG! HE USED [a, b].min! THAT'S SO
SLOW!", note that the methods I used this in are used so rarely that the loss will
be negligible, and is worth it for the increase in readibility and brevity.
=end
#============================================================================================
# * Game_System
# Modified to allow savable configuration
#============================================================================================
class Game_System
attr_accessor :wcw_max_items, :wcw_max_armor, :wcw_max_weapons
#-----------------------------------------------------------------------------------------
# initialize
#-----------------------------------------------------------------------------------------
alias initialize_inventory_limit_wcw_later initialize
def initialize
#//////////////////////////////////////////////////////////////////////////////////////
#INV_LIMIT CONFIG
@wcw_max_items = -1
@wcw_max_weapons = -1
@wcw_max_armor = -1
#//////////////////////////////////////////////////////////////////////////////////////
initialize_inventory_limit_wcw_later
end
end
#============================================================================================
# * Game_Party
# gain_item, gain_weapon, and gain_armor all modified to ensure that items are limited
# properly
#============================================================================================
class Game_Party
#-----------------------------------------------------------------------------------------
# gain_item(item_id, n)
#-----------------------------------------------------------------------------------------
alias gain_item_inventory_limit_wcw_later gain_item
def gain_item(item_id, n)
return gain_item_inventory_limit_wcw_later(item_id, ($game_system.wcw_max_items == -1) ? n : [$game_system.wcw_max_items, item_number(item_id) + n].min)
end
#-----------------------------------------------------------------------------------------
# gain_weapon(weapon_id, n)
#-----------------------------------------------------------------------------------------
alias gain_weapon_inventory_limit_wcw_later gain_weapon
def gain_weapon(weapon_id, n)
return gain_weapon_inventory_limit_wcw_later(weapon_id, ($game_system.wcw_max_weapons == -1) ? n : [$game_system.wcw_max_weapons, weapon_number(weapon_id) + n].min)
end
#-----------------------------------------------------------------------------------------
# gain_armor(armor_id, n)
#-----------------------------------------------------------------------------------------
alias gain_armor_inventory_limit_wcw_later gain_armor
def gain_armor(armor_id, n)
return gain_armor_inventory_limit_wcw_later(armor_id, ($game_system.wcw_max_armor == -1) ? n : [$game_system.wcw_max_armor, armor_number(armor_id) + n].min)
end
end
My version. Public domain, have fun. However, I'm unable to test it since I don't have RMXP anymore >_<