#==============================================================================
# 设定项目完毕
#==============================================================================
end
$imported = {} if $imported == nil
class Game_Party
alias bbl_initialize initialize
#--------------------------------------------------------------------------
# ○ 定义实例变量 (追加定义)
#--------------------------------------------------------------------------
attr_reader :keep_gold # 保存金钱
#--------------------------------------------------------------------------
# ● 初期化对象
#--------------------------------------------------------------------------
def initialize
bbl_initialize
@keep_items = {} # 保管品 hash (物品 ID)
@keep_weapons = {} # 保管品 hash (武器 ID)
@keep_armors = {} # 保管品 hash (防具 ID)
@keep_gold = 0 # 保管金钱
end
#--------------------------------------------------------------------------
# ○ 获取保存物品的排序
#--------------------------------------------------------------------------
def keeping_items
result = []
for i in @keep_items.keys.sort
result.push($data_items[i]) if @keep_items[i] > 0
end
for i in @keep_weapons.keys.sort
result.push($data_weapons[i]) if @keep_weapons[i] > 0
end
for i in @keep_armors.keys.sort
result.push($data_armors[i]) if @keep_armors[i] > 0
end
return result
end
#--------------------------------------------------------------------------
# ○ 获取保存物品的所持数量
#--------------------------------------------------------------------------
def keeping_item_number(item)
case item
when RPG::Item
number = @keep_items[item.id]
when RPG::Weapon
number = @keep_weapons[item.id]
when RPG::Armor
number = @keep_armors[item.id]
end
return number == nil ? 0 : number
end
#--------------------------------------------------------------------------
# ○ 保存物品的增加 (减少)
# item : 物品
# n : 个数
#--------------------------------------------------------------------------
def gain_keeping_item(item, n)
number = keeping_item_number(item)
case item
when RPG::Item
@keep_items[item.id] = [[number + n, 0].max, 99].min
when RPG::Weapon
@keep_weapons[item.id] = [[number + n, 0].max, 99].min
when RPG::Armor
@keep_armors[item.id] = [[number + n, 0].max, 99].min
end
end
#--------------------------------------------------------------------------
# ○ 保存物品的减少
# item : 物品
# n : 个数
#--------------------------------------------------------------------------
def lose_keeping_item(item, n)
gain_keeping_item(item, -n)
end
#--------------------------------------------------------------------------
# ● 保管金额的增加 (减少)
# n : 金额
#--------------------------------------------------------------------------
def gain_keeping_gold(n)
@keep_gold = [[@keep_gold + n, 0].max, 9999999].min
end
#--------------------------------------------------------------------------
# ● 保管金额的减少
# n : 金额
#--------------------------------------------------------------------------
def lose_keeping_gold(n)
gain_keeping_gold(-n)
end
end
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● 呼出仓库
#--------------------------------------------------------------------------
def reserve_system
$scene = Scene_Reserve.new
return true
end
end
class Scene_Reserve < Scene_Base
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
create_menu_background
@not_gold = true if BBL_RESERVE_SYSTEM::DISCRETION_NAME.size < 4
if BBL_RESERVE_SYSTEM::ITEM_DISCRETION
@item_window = Window_Reserve_main.new(0, 112, 272, 248)
@reserve_window = Window_Reserve.new(272, 112, 272, 248)
else
@item_window = Window_Reserve_main.new(0, 56, 272, 304)
@reserve_window = Window_Reserve.new(272, 56, 272, 304)
end
@help_window = Window_Help.new
@item_window.help_window = @help_window
@reserve_window.help_window = @help_window
@command_window = Window_ReserveCommand.new(544, BBL_RESERVE_SYSTEM::DISCRETION_NAME,
BBL_RESERVE_SYSTEM::DISCRETION_NAME.size, 1, 4)
@command_window.y = 56
@command_window.active = true
@gold_command_window = Window_ReserveCommand.new(192, BBL_RESERVE_SYSTEM::GOLD_COMMAND_NAME, 1, 0)
@gold_command_window.opacity = 0
@gold_command_window.x = 32
@gold_command_window.y = @item_window.y + 64
@gold_command_window.visible = false
@item_window.active = false
@reserve_window.active = false
@item_window.index = -1
@reserve_window.index = -1
@item_cursor = 0
@reserve_cursor = 0
@item_window.mode = 1
@reserve_window.mode = 1
@number_window = Window_GoldInput.new
@number_window.visible = false
@number_window.y = @gold_command_window.y + @gold_command_window.height
@gold_window = Window_HandGold.new(0, 416 - 56)
@gold_reserve_window = Window_ReserveGold.new(272, 416 - 56)
unless BBL_RESERVE_SYSTEM::ITEM_DISCRETION
@command_window.active = false
@command_window.visible = false
@item_window.index = 0
@item_window.active
end
if $imported["HelpExtension"]
adjust_window_size
else
adjust_gold_window_size
end
end
#--------------------------------------------------------------------------
# ● 完毕处理
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
@item_window.dispose
@reserve_window.dispose
@command_window.dispose
@help_window.dispose
@gold_command_window.dispose
@gold_window.dispose
@gold_reserve_window.dispose
@number_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
update_menu_background
@command_window.update if BBL_RESERVE_SYSTEM::ITEM_DISCRETION
if @item_window.index >= 0
@item_window.active = true
@reserve_window.active = false
elsif @reserve_window.index >= 0
@item_window.active = false
@reserve_window.active = true
end
if @command_window.active == true
command_selection
elsif @item_window.active == true
select_item
elsif @reserve_window.active == true
select_keeping_item
elsif @gold_command_window.active == true
select_gold_command
elsif @number_window.active == true
select_number
end
item_mode = @command_window.index + 1
if item_mode != @item_window.mode
@item_window.mode = item_mode
end
if item_mode != @reserve_window.mode
@reserve_window.mode = item_mode
end
end
#--------------------------------------------------------------------------
# ● 指令窗口选项的刷新
#--------------------------------------------------------------------------
def command_selection
@help_window.set_text(BBL_RESERVE_SYSTEM::COMMAND_EXPLANATION)
if Input.trigger?(Input::C)
if @command_window.index == 3
Sound.play_decision
@command_window.active = false
@gold_command_window.visible = true
@gold_command_window.active = true
@gold_command_window.index = 0
else
Sound.play_decision
@command_window.active = false
@item_window.active = true
@item_window.index = 0
end
elsif Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
end
end
#--------------------------------------------------------------------------
# ● 所持物品选项的刷新
#--------------------------------------------------------------------------
def select_item
@item_window.update
@reserve_window.update
if Input.repeat?(BBL_RESERVE_SYSTEM::RESERVE_KEY)
@item_window.gain_item
@item_window.refresh
@reserve_window.refresh
if @item_window.item == nil
@item_window.index -= 1 if @item_window.index > 0
end
elsif Input.repeat?(BBL_RESERVE_SYSTEM::RESERVE_ALL_KEY)
@item_window.gain_item_all
@item_window.refresh
@reserve_window.refresh
if @item_window.item == nil
@item_window.index -= 1 if @item_window.index > 0
end
elsif Input.trigger?(Input::B)
if BBL_RESERVE_SYSTEM::ITEM_DISCRETION
Sound.play_cancel
@item_window.active = false
@item_window.index = -1
@command_window.active = true
else
Sound.play_cancel
$scene = Scene_Map.new
end
elsif Input.trigger?(Input::RIGHT) or Input.trigger?(Input::LEFT)
Sound.play_cursor
@item_cursor = @item_window.index
@item_window.active = false
@reserve_window.active
@item_window.index = -1
@reserve_window.index = @reserve_cursor
end
end
#--------------------------------------------------------------------------
# ● 保管物品选项的刷新
#--------------------------------------------------------------------------
def select_keeping_item
@item_window.update
@reserve_window.update
if Input.repeat?(BBL_RESERVE_SYSTEM::RESERVE_KEY)
@reserve_window.reserve_item
@item_window.refresh
@reserve_window.refresh
if @reserve_window.item == nil
@reserve_window.index -= 1 if @reserve_window.index > 0
end
elsif Input.repeat?(BBL_RESERVE_SYSTEM::RESERVE_ALL_KEY)
@reserve_window.reserve_item_all
@item_window.refresh
@reserve_window.refresh
if @reserve_window.item == nil
@reserve_window.index -= 1 if @reserve_window.index > 0
end
elsif Input.trigger?(Input::B)
if BBL_RESERVE_SYSTEM::ITEM_DISCRETION
Sound.play_cancel
@reserve_window.active = false
@reserve_window.index = -1
@command_window.active = true
else
Sound.play_cancel
$scene = Scene_Map.new
end
elsif Input.trigger?(Input::RIGHT) or Input.trigger?(Input::LEFT)
Sound.play_cursor
@reserve_cursor = @reserve_window.index
@reserve_window.active = false
@item_window.active
@reserve_window.index = -1
@item_window.index = @item_cursor
end
end
#--------------------------------------------------------------------------
# ● 金钱指令窗口选项的刷新
#--------------------------------------------------------------------------
def select_gold_command
@gold_command_window.update
if Input.trigger?(Input::C)
Sound.play_decision
@gold_command_window.active = false
@gold_command_window.visible = false
@number_window.visible = true
@number_window.active = true
if @gold_command_window.index == 0
@number_window.mode = 0 # 存入
@number_window.x = 32
else
@number_window.mode = 1 # 提取
@number_window.x = 304
end
elsif Input.trigger?(Input::B)
Sound.play_cancel
@gold_command_window.active = false
@gold_command_window.visible = false
@command_window.active = true
end
end
#--------------------------------------------------------------------------
# ● 填写金额的刷新
#--------------------------------------------------------------------------
def select_number
@number_window.update
if Input.trigger?(Input::C)
if @number_window.mode == 0
if @number_window.number > $game_party.gold
Sound.play_buzzer
@number_window.number = $game_party.gold
else
Sound.play_decision
gold = @number_window.number
$game_party.lose_gold(gold)
$game_party.gain_keeping_gold(gold)
@number_window.number = 0
@gold_window.refresh
@gold_reserve_window.refresh
end
elsif @number_window.mode == 1
if @number_window.number > $game_party.keep_gold
Sound.play_buzzer
@number_window.number = $game_party.keep_gold
else
Sound.play_decision
gold = @number_window.number
$game_party.gain_gold(gold)
$game_party.lose_keeping_gold(gold)
@number_window.number = 0
@gold_window.refresh
@gold_reserve_window.refresh
end
end
elsif Input.trigger?(Input::B)
Sound.play_cancel
@number_window.visible = false
@number_window.active = false
@number_window.number = 0
@number_window.index = 6
@gold_command_window.visible = true
@gold_command_window.active = true
end
end
if $imported["HelpExtension"]
#--------------------------------------------------------------------------
# ● 调整窗口大小 用于KGC的扩张帮助窗口
#--------------------------------------------------------------------------
def adjust_window_size
@help_window.row_max = KGC::HelpExtension::ROW_MAX
@command_window.y = @help_window.height
@item_window.y = @command_window.height + @help_window.height
@reserve_window.y = @command_window.height + @help_window.height
sy = @help_window.height + @command_window.height + @gold_window.height
sy = @help_window.height + @command_window.height if @not_gold
@item_window.height = 416 - sy
@reserve_window.height = 416 - sy
@gold_command_window.y = @item_window.y
if @not_gold
@gold_window.visible = false
@gold_reserve_window.visible = false
end
end
end
#--------------------------------------------------------------------------
# ● 调整窗口大小
#--------------------------------------------------------------------------
def adjust_gold_window_size
sy = @help_window.height + @command_window.height + @gold_window.height
sy = @help_window.height + @command_window.height if @not_gold
@item_window.height = 416 - sy
@reserve_window.height = 416 - sy
if @not_gold
@gold_window.visible = false
@gold_reserve_window.visible = false
end
end
end