Skip to content
Permalink
master
Go to file
 
 
Cannot retrieve contributors at this time
123 lines (123 sloc) 3.45 KB
################################################################################
##### Max Item
##########################################################
# Author : Biward
# Date : 27/04/2014
# Version : 1.0 VX
#
# With this script, you can modify the maximum amount you can have of an object (items, weapons, armors)
#
# How it works :
# You just have to put <Max = N> in the object's note
# N = maximum amount
#
##########################################################
##### Script
##################################
##################################
# ** RPG::BaseItem
##################
module RPG
class BaseItem
attr_reader :max
def init_max
note =~ /<Max = (.*)>/
@max = 99
@max = $1.to_i if $1
end
end
end
##################################
# ** Scene Title
############
class Scene_Title
alias biload load_database
def load_database
biload
load_max
end
alias biload_bt load_bt_database
def load_bt_database
biload_bt
load_max
end
def load_max
$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
#--------------------------------------------------------------------------
# * Update Buy Item Selection
# >> Overwrite
#--------------------------------------------------------------------------
def update_buy_selection
@status_window.item = @buy_window.item
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = false
@status_window.item = nil
@help_window.set_text("")
return
end
if Input.trigger?(Input::C)
@item = @buy_window.item
number = $game_party.item_number(@item)
if @item == nil or @item.price > $game_party.gold or number == @item.max
Sound.play_buzzer
else
Sound.play_decision
max = @item.price == 0 ? @item.max : $game_party.gold / @item.price
max = [max, @item.max - number].min
@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
end
##################################
# ** Game Party
#############
class Game_Party
#--------------------------------------------------------------------------
# * Gain Items (or lose)
# item : Item
# n : Number
# include_equip : Include equipped items
# >> Overwrite
#--------------------------------------------------------------------------
def gain_item(item, n, include_equip = false)
number = item_number(item)
case item
when RPG::Item
@items[item.id] = [[number + n, 0].max, item.max].min
when RPG::Weapon
@weapons[item.id] = [[number + n, 0].max, item.max].min
when RPG::Armor
@armors[item.id] = [[number + n, 0].max, item.max].min
end
n += number
if include_equip and n < 0
for actor in members
while n < 0 and actor.equips.include?(item)
actor.discard_equip(item)
n += 1
end
end
end
end
end
##################################
##### End of the Script
##########################################################
You can’t perform that action at this time.