Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
| ################################################################################ | |
| ##### Max Item | |
| ########################################################## | |
| # Author : Biward | |
| # Date : 27/04/2014 | |
| # Version : 1.0 XP | |
| # | |
| # With this script, you can modify the maximum amount you can have of an object (items, weapons, armors) | |
| # | |
| # How it works : | |
| # You have to add the number max you can have of an object in the config. module | |
| # just like this example : | |
| # | |
| # MAX_ITEMS = { | |
| # ID_ITEM => MAX, | |
| # ID_ITEM2 => MAX2, | |
| # } | |
| # | |
| # Do not forget the , ! | |
| # | |
| # Same for Weapons & | |
| ######### | |
| # Module | |
| ######### | |
| module BIMAX | |
| MAX_ITEMS = { | |
| 1 => 5 | |
| } | |
| MAX_WEAPONS = { | |
| 1 => 5 | |
| } | |
| MAX_ARMORS = { | |
| 1 => 5 | |
| } | |
| end | |
| ########################################################## | |
| ##### Script | |
| ################################## | |
| ################################## | |
| # ** RPG::BaseItem | |
| ################## | |
| module RPG | |
| class Item | |
| attr_reader :max | |
| def init_max | |
| @max = 99 | |
| @max = BIMAX::MAX_ITEMS[self.id] if BIMAX::MAX_ITEMS.keys.include?(self.id) | |
| end | |
| end | |
| class Weapon | |
| attr_reader :max | |
| def init_max | |
| @max = 99 | |
| @max = BIMAX::MAX_WEAPONS[self.id] if BIMAX::MAX_WEAPONS.keys.include?(self.id) | |
| end | |
| end | |
| class Armor | |
| attr_reader :max | |
| def init_max | |
| @max = 99 | |
| @max = BIMAX::MAX_ARMORS[self.id] if BIMAX::MAX_ARMORS.keys.include?(self.id) | |
| end | |
| end | |
| end | |
| ################################## | |
| # ** Scene Title | |
| ############ | |
| class Scene_Title | |
| alias biload update | |
| def update | |
| load_max if ! @load | |
| biload | |
| end | |
| def load_max | |
| @load = true | |
| $data_items.each { |obj| obj.init_max if obj } | |
| $data_weapons.each { |obj| obj.init_max if obj } | |
| $data_armors.each { |obj| obj.init_max if obj } | |
| end | |
| end | |
| ################################## | |
| # ** Scene Shop | |
| ############# | |
| class Scene_Shop | |
| #-------------------------------------------------------------------------- | |
| # * Frame Update (when buy window is active) | |
| #-------------------------------------------------------------------------- | |
| def update_buy | |
| # Set status window item | |
| @status_window.item = @buy_window.item | |
| # If B button was pressed | |
| if Input.trigger?(Input::B) | |
| # Play cancel SE | |
| $game_system.se_play($data_system.cancel_se) | |
| # Change windows to initial mode | |
| @command_window.active = true | |
| @dummy_window.visible = true | |
| @buy_window.active = false | |
| @buy_window.visible = false | |
| @status_window.visible = false | |
| @status_window.item = nil | |
| # Erase help text | |
| @help_window.set_text("") | |
| return | |
| end | |
| # If C button was pressed | |
| if Input.trigger?(Input::C) | |
| # Get item | |
| @item = @buy_window.item | |
| # If item is invalid, or price is higher than money possessed | |
| if @item == nil or @item.price > $game_party.gold | |
| # Play buzzer SE | |
| $game_system.se_play($data_system.buzzer_se) | |
| return | |
| end | |
| # Get items in possession count | |
| case @item | |
| when RPG::Item | |
| number = $game_party.item_number(@item.id) | |
| when RPG::Weapon | |
| number = $game_party.weapon_number(@item.id) | |
| when RPG::Armor | |
| number = $game_party.armor_number(@item.id) | |
| end | |
| # If 99 items are already in possession | |
| if number == @item.max | |
| # Play buzzer SE | |
| $game_system.se_play($data_system.buzzer_se) | |
| return | |
| end | |
| # Play decision SE | |
| $game_system.se_play($data_system.decision_se) | |
| # Calculate maximum amount possible to buy | |
| max = @item.price == 0 ? @item.max : $game_party.gold / @item.price | |
| max = [max, @item.max - number].min | |
| # Change windows to quantity input mode | |
| @buy_window.active = false | |
| @buy_window.visible = false | |
| @number_window.set(@item, max, @item.price) | |
| @number_window.active = true | |
| @number_window.visible = true | |
| end | |
| end | |
| end | |
| ################################## | |
| # ** Game Party | |
| ############# | |
| class Game_Party | |
| #-------------------------------------------------------------------------- | |
| # * 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, $data_items[item_id].max].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, $data_weapons[weapon_id].max].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, $data_armors[armor_id].max].min | |
| end | |
| end | |
| end | |
| ################################## | |
| ##### End of the Script | |
| ########################################################## |