=begin #=============================================================================== Title: Dynamic Stack Sizes Author: Hime Date: Feb 4, 2014 -------------------------------------------------------------------------------- ** Change log May 4, 2014 - Fixed bug where increasing stack size failed Feb 16, 2014 - fixed saving issue Nov 1, 2013 - initial release -------------------------------------------------------------------------------- ** Terms of Use * Free to use in non-commercial projects * Contact me for commercial use * No real support. The script is provided as-is * Will do bug fixes, but no compatibility patches * Features may be requested but no guarantees, especially if it is non-trivial * Preserve this header -------------------------------------------------------------------------------- ** Description This script allows you to adjust an item's stack size during the game. If you decrease the party's stack size below the current number of items for that stack, the items are not deleted. Instead, you won't be able to obtain more. For example, maybe initially you can't carry any hi-potions, which means you can't buy any either. Then at some point, you can carry hi-potions. -------------------------------------------------------------------------------- ** Required Item Stack Size (http://himeworks.com/2013/10/27/item-stack-sizes/) -------------------------------------------------------------------------------- ** Installation In the script editor, place this script below Item Stack Size and above Main -------------------------------------------------------------------------------- ** Usage Make the following script calls to change an item's stack size: increase_item_stack(item_id, count) increase_weapon_stack(weapon_id, count) increase_armor_stack(armor_id, count) decrease_item_stack(item_id, count) decrease_weapon_stack(weapon_id, count) decrease_armor_stack(armor_id, count) Where you pass in the appropriate database ID and the amount you want to increase or decrease it by. #=============================================================================== =end $imported = {} if $imported.nil? $imported["TH_DynamicStackSize"] = true #============================================================================== # ** Configuration #============================================================================== module TH module Dynamic_Stack_Size def initialize_item_stacks @item_stacks = {} @weapon_stacks = {} @armor_stacks = {} end def increase_stack_size(item, count) container = get_stack_container(item) container[item.id] ||= item.stack_size container[item.id] = container[item.id] + count end def decrease_stack_size(item, count) container = get_stack_container(item) container[item.id] ||= item.stack_size container[item.id] = [container[item.id] - count, 0].max end def get_stack_container(item) return @item_stacks if item.is_a?(RPG::Item) return @weapon_stacks if item.is_a?(RPG::Weapon) return @armor_stacks if item.is_a?(RPG::Armor) return nil end end end #============================================================================== # ** Rest of the script #============================================================================== class Game_Interpreter def get_party(party_id) return $game_party end def increase_item_stack(id, count, party_id=0) get_party(party_id).increase_stack_size($data_items[id], count) end def increase_weapon_stack(id, count, party_id=0) get_party(party_id).increase_stack_size($data_weapons[id], count) end def increase_armor_stack(id, count, party_id=0) get_party(party_id).increase_stack_size($data_armors[id], count) end def decrease_item_stack(id, count, party_id=0) get_party(party_id).decrease_stack_size($data_items[id], count) end def decrease_weapon_stack(id, count, party_id=0) get_party(party_id).decrease_stack_size($data_weapons[id], count) end def decrease_armor_stack(id, count, party_id=0) get_party(party_id).decrease_stack_size($data_armors[id], count) end end class Game_Party < Game_Unit include TH::Dynamic_Stack_Size alias :th_dynamic_stack_size_initialize :initialize def initialize initialize_item_stacks th_dynamic_stack_size_initialize end #----------------------------------------------------------------------------- # Replaced. #----------------------------------------------------------------------------- def item_stack_size(item) return get_stack_container(item)[item.id] ||= item.stack_size end end if $imported["TH_CoreInventory"] class Game_Inventory include TH::Dynamic_Stack_Size alias :th_dynamic_stack_size_initialize :initialize def initialize initialize_item_stacks th_dynamic_stack_size_initialize end def item_stack_size(item) return get_stack_container(item)[item.id] end end class Game_Party def increase_stack_size(item, count) @inventory.increase_stack_size(item, count) end def decrease_stack_size(item, count) @inventory.decrease_stack_size(item, count) end end end