Project1
标题: 脚本问题~~~~~ [打印本页]
作者: lj1983nian 时间: 2011-2-14 13:19
标题: 脚本问题~~~~~
本帖最后由 IamI 于 2011-2-14 19:00 编辑
仓库.rar
(874.2 KB, 下载次数: 18)
脚本在游戏里面
我新建了个~
希望大家帮我看看啊~~~
脚本是:出现错误是:168行发生了 TypeError undefined superclass 'Scene_Base'
请大家帮忙看看
- #==============================================================================
- #
- # 仓库ver1.1
- #
- # 汉化 by 约束
- #
- # RPG中存放多余物品的仓库。
- # 本脚本与黑狮子的脚本相似
- # 参考于MQ0_PartyReserve所做。
- #
- # 使用方法
- # 事件中的「脚本」里填入reserve_system即可启动此脚本。
- #
- # 不可存放物品
- # ・不想可以存放事件/剧情所需物品时
- # 在物品的备注栏中填入 非存放 即可
- # 如此即可使物品不可存入仓库。
- #
- # 另外、为能使用TYPE74RX-T様的「限定特定物平的所持数上限」脚本
- # 而写了专门应对的方法
- # 如果有用到以上所述脚本、请使RX_T_ITEM为true状态
- #
- #==============================================================================
- module BBL_RESERVE_SYSTEM
- #==============================================================================
- # 设定项目开始
- #==============================================================================
- # 如果不希望保管物品根据以下范畴区分的情况时 请填入false
- ITEM_DISCRETION = true
- # ITEM_DISCRETION在true的状态时 请在以下填入范畴名
- # 从左开始依次为物品、武器、防具、金钱(顺序不可改变)
- # ※如果不希望有金钱保管功能时 将金钱从范畴内消去
- # 例) ["物品", "武器", "防具"]
- DISCRETION_NAME = ["物品", "武器", "防具", "金钱"]
- # 操作说明文
- # 如果不需要时、消除""内文字即可
- COMMAND_EXPLANATION = "空格:分别存入 D:全部存入"
- # 使用仓库时的按键
- RESERVE_KEY = Input::C # 分别存入
- RESERVE_ALL_KEY = Input::Z # 全部存入
- # 金钱选项窗口的用语
- # 从左开始依次为保存和提取
- GOLD_COMMAND_NAME = ["保存", "提取"]
- # 所持金钱的用语
- GOLD_NAME = "持有金额"
- # 保存金钱的用语
- RESERVE_GOLD_NAME = "保管金额"
- # 使用了TYPE74RX-T様的「限定特定物平的所持数上限」脚本
- # 请在以下改为true即可
- RX_T_ITEM = false
- #==============================================================================
- # 设定项目完毕
- #==============================================================================
- 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
- #==============================================================================
- # ■ Window_Reserve
- #------------------------------------------------------------------------------
- # 显示仓库中物品一览
- #==============================================================================
- class Window_Reserve < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :mode # 模式
- #--------------------------------------------------------------------------
- # ● 初期化对象
- # x : 窗口的 X 坐标
- # y : 窗口的 Y 坐标
- # width : 窗口的宽度
- # height : 窗口的高度
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x, y, width, height)
- @column_max = 1
- self.index = -1
- @mode = 0
- @total = 0
- @value = 0
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 获取物品
- #--------------------------------------------------------------------------
- def item
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- @data = []
- for item in $game_party.keeping_items
- next unless include?(item)
- @data.push(item)
- if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
- self.index = @data.size - 1
- end
- end
- @data.push(nil) if include?(nil)
- @item_max = @data.size
- create_contents
- for i in 0...@item_max
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # ● 项目的描画
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- item = @data[index]
- if item != nil
- number = $game_party.keeping_item_number(item)
- enabled = enable?(item)
- rect.width -= 4
- draw_item_name(item, rect.x, rect.y, enabled)
- self.contents.draw_text(rect, sprintf("%2d", number), 2)
- self.contents.font.size = 14
- rect.width -= 20
- self.contents.draw_text(rect, "×", 2)
- self.contents.font.size = 20
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(item == nil ? "" : item.description)
- end
- #--------------------------------------------------------------------------
- # ● 模式的设定
- # mode : 新模式
- #--------------------------------------------------------------------------
- def mode=(mode)
- if @mode != mode
- @mode = mode
- refresh
- end
- end
- #--------------------------------------------------------------------------
- # ● 物品在许可状态时是否显示
- #--------------------------------------------------------------------------
- def enable?(item)
- if BBL_RESERVE_SYSTEM::RX_T_ITEM
- rx_limit = RX_T.get_numeric_of_system_word_in_sys_str(item, "所持可能数")
- if rx_limit > 0
- if $game_party.item_number(item) == rx_limit
- return false
- end
- end
- end
- if $game_party.item_number(item) == 99
- return false
- else
- return true
- end
- end
- #--------------------------------------------------------------------------
- # ● 物品是否存在于名单
- # item : 物品
- #--------------------------------------------------------------------------
- def include?(item)
- if BBL_RESERVE_SYSTEM::ITEM_DISCRETION
- case @mode
- when 1 # 物品
- return false unless item.is_a?(RPG::Item)
- when 2 # 武器
- return false unless item.is_a?(RPG::Weapon)
- when 3 # 防具
- return false unless item.is_a?(RPG::Armor)
- when 4 # 金钱
- return false
- end
- return true
- else
- return false if item == nil
- if $game_temp.in_battle
- return false unless item.is_a?(RPG::Item)
- end
- return true
- end
- end
- #--------------------------------------------------------------------------
- # ● 取出保管中物品
- #--------------------------------------------------------------------------
- def reserve_item
- return if item == nil
- if BBL_RESERVE_SYSTEM::RX_T_ITEM
- rx_limit = RX_T.get_numeric_of_system_word_in_sys_str(item, "所持可能数")
- end
- return Sound.play_buzzer if $game_party.item_number(item) == 99
- if rx_limit == 0
- rx_limit = nil
- end
- if $game_party.item_number(item) == rx_limit
- Sound.play_buzzer
- else
- Sound.play_use_item
- $game_party.lose_keeping_item(item, 1)
- $game_party.gain_item(item, 1)
- end
- end
- #--------------------------------------------------------------------------
- # ● 将保管中物品全部取出
- #--------------------------------------------------------------------------
- def reserve_item_all
- return if item == nil
- if BBL_RESERVE_SYSTEM::RX_T_ITEM
- rx_limit = RX_T.get_numeric_of_system_word_in_sys_str(item, "所持可能数")
- end
- return Sound.play_buzzer if $game_party.item_number(item) == 99
- if rx_limit == 0
- rx_limit = nil
- end
- if $game_party.item_number(item) == rx_limit
- Sound.play_buzzer
- else
- Sound.play_use_item
- @total = $game_party.keeping_item_number(item) + $game_party.item_number(item)
- if rx_limit != nil
- if rx_limit > 0
- if @total > rx_limit
- @value = @total - rx_limit
- end
- end
- else
- if @total > 99
- @value = @total - 99
- end
- end
- $game_party.gain_item(item, $game_party.keeping_item_number(item))
- $game_party.lose_keeping_item(item, $game_party.keeping_item_number(item))
- $game_party.gain_keeping_item(item, @value)
- @total = 0
- @value = 0
- end
- end
- end
- #==============================================================================
- # ■ Window_Reserve
- #------------------------------------------------------------------------------
- # 显示仓库中所持物品一览
- #==============================================================================
- class Window_Reserve_main < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :mode # 模式
- #--------------------------------------------------------------------------
- # ● 初期化对象
- # x : 窗口的 X 坐标
- # y : 窗口的 Y 坐标
- # width : 窗口的宽度
- # height : 窗口的高度
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x, y, width, height)
- @column_max = 1
- self.index = -1
- @mode = 0
- @total = 0
- @value = 0
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 物品的获取
- #--------------------------------------------------------------------------
- def item
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- @data = []
- for item in $game_party.items
- next unless include?(item)
- @data.push(item)
- if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
- self.index = @data.size - 1
- end
- end
- @data.push(nil) if include?(nil)
- @item_max = @data.size
- create_contents
- for i in 0...@item_max
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # ● 项目的描画
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- item = @data[index]
- if item != nil
- number = $game_party.item_number(item)
- enabled = enable?(item)
- rect.width -= 4
- draw_item_name(item, rect.x, rect.y, enabled)
- self.contents.draw_text(rect, sprintf("%2d", number), 2)
- self.contents.font.size = 14
- rect.width -= 20
- self.contents.draw_text(rect, "×", 2)
- self.contents.font.size = 20
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(item == nil ? "" : item.description)
- end
- #--------------------------------------------------------------------------
- # ● 模式的设定
- # mode : 新模式
- #--------------------------------------------------------------------------
- def mode=(mode)
- if @mode != mode
- @mode = mode
- refresh
- end
- end
- #--------------------------------------------------------------------------
- # ● 物品在许可状态时是否显示
- #--------------------------------------------------------------------------
- def enable?(item)
- if $game_party.keeping_item_number(item) == 99
- return false
- else
- return true
- end
- end
- #--------------------------------------------------------------------------
- # ○ 物品是否存在于名单
- # item : 物品
- #--------------------------------------------------------------------------
- def include?(item)
- if BBL_RESERVE_SYSTEM::ITEM_DISCRETION
- case @mode
- when 1 # 物品
- return false unless item.is_a?(RPG::Item)
- return false if item.note.include?("非存放")
- when 2 # 武器
- return false unless item.is_a?(RPG::Weapon)
- return false if item.note.include?("非存放")
- when 3 # 防具
- return false unless item.is_a?(RPG::Armor)
- return false if item.note.include?("非存放")
- when 4 # 金钱
- return false
- end
- return true
- else
- return false if item == nil
- if $game_temp.in_battle
- return false unless item.is_a?(RPG::Item)
- end
- return false if item.note.include?("非存放")
- return true
- end
- end
- #--------------------------------------------------------------------------
- # ● 所持有物品的保存
- #--------------------------------------------------------------------------
- def gain_item
- return if item == nil
- if $game_party.keeping_item_number(item) == 99
- Sound.play_buzzer
- else
- Sound.play_use_item
- $game_party.gain_keeping_item(item, 1)
- $game_party.lose_item(item, 1)
- end
- end
- #--------------------------------------------------------------------------
- # ● 所持有物品全部保存
- #--------------------------------------------------------------------------
- def gain_item_all
- return if item == nil
- if $game_party.keeping_item_number(item) == 99
- Sound.play_buzzer
- else
- Sound.play_use_item
- @total = $game_party.keeping_item_number(item) + $game_party.item_number(item)
- if @total > 99
- @value = @total - 99
- end
- $game_party.gain_keeping_item(item, $game_party.item_number(item))
- $game_party.lose_item(item, $game_party.item_number(item))
- $game_party.gain_item(item, @value)
- @total = 0
- @value = 0
- end
- end
- end
- #==============================================================================
- # ■ Window_GoldInput
- #------------------------------------------------------------------------------
- # 用于填写所持金钱的窗口。
- #==============================================================================
- class Window_GoldInput < Window_Base
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :mode # 模式
- attr_accessor :index # 索引
- #--------------------------------------------------------------------------
- # ● 初期化对象
- # digits_max : 行数
- #--------------------------------------------------------------------------
- def initialize
- super(32, 208, 544, 64)
- @number = 0
- @digits_max = 7
- @index = @digits_max - 1
- @mode = 0
- self.opacity = 0
- self.active = false
- self.z += 9999
- refresh
- update_cursor
- end
- #--------------------------------------------------------------------------
- # ● 数值的获取
- #--------------------------------------------------------------------------
- def number
- return @number
- end
- #--------------------------------------------------------------------------
- # ● 模式的获取
- # 0:保存 1:提取
- #--------------------------------------------------------------------------
- def mode=(mode)
- @mode = mode
- return @mode
- end
- #--------------------------------------------------------------------------
- # ● 数值的设定
- # number : 新数值
- #--------------------------------------------------------------------------
- def number=(number)
- @number = [[number, 0].max, 10 ** @digits_max - 1].min
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 行数的获取
- #--------------------------------------------------------------------------
- def digits_max
- return @digits_max
- end
- #--------------------------------------------------------------------------
- # ● 行数的设定
- # digits_max : 新行数
- #--------------------------------------------------------------------------
- def digits_max=(digits_max)
- @digits_max = digits_max
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 光标向右移动
- # wrap : 可以往复循环移动
- #--------------------------------------------------------------------------
- def cursor_right(wrap)
- if @index < @digits_max - 1 or wrap
- @index = (@index + 1) % @digits_max
- end
- end
- #--------------------------------------------------------------------------
- # ● 光标向左移动
- # wrap : 可以往复循环移动
- #--------------------------------------------------------------------------
- def cursor_left(wrap)
- if @index > 0 or wrap
- @index = (@index + @digits_max - 1) % @digits_max
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- super
- if self.active
- if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)
- Sound.play_cursor
- place = 10 ** (@digits_max - 1 - @index)
- n = @number / place % 10
- @number -= n * place
- n = (n + 1) % 10 if Input.repeat?(Input::UP)
- n = (n + 9) % 10 if Input.repeat?(Input::DOWN)
- @number += n * place
- refresh
- end
- last_index = @index
- if Input.repeat?(Input::RIGHT)
- if @index == @digits_max - 1
- Sound.play_cursor
- if @mode == 0
- if @number == $game_party.gold
- @number = 0
- else
- @number = $game_party.gold
- end
- elsif @mode == 1
- if @number == $game_party.keep_gold
- @number = 0
- else
- @number = $game_party.keep_gold
- end
- end
- refresh
- else
- cursor_right(Input.trigger?(Input::RIGHT))
- end
- end
- if Input.repeat?(Input::LEFT)
- if @index == 0
- Sound.play_cursor
- if @mode == 0
- if @number == $game_party.gold
- @number = 0
- else
- @number = $game_party.gold
- end
- elsif @mode == 1
- if @number == $game_party.keep_gold
- @number = 0
- else
- @number = $game_party.keep_gold
- end
- end
- refresh
- else
- cursor_left(Input.trigger?(Input::LEFT))
- end
- end
- if @index != last_index
- Sound.play_cursor
- end
- update_cursor
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- self.contents.font.color = normal_color
- s = sprintf("%0*d", @digits_max, @number)
- for i in 0...@digits_max
- self.contents.draw_text(24 + i * 16, 0, 16, WLH, s[i,1], 1)
- end
- self.contents.font.color = system_color
- self.contents.draw_text(24 + (i + 1) * 16, 0, 16, WLH, Vocab::gold)
- end
- #--------------------------------------------------------------------------
- # ● 光标的刷新
- #--------------------------------------------------------------------------
- def update_cursor
- self.cursor_rect.set(24 + @index * 16, 0, 16, WLH)
- end
- end
- #==============================================================================
- # ■ Window_ReserveGold
- #------------------------------------------------------------------------------
- # 显示保存金额的窗口。
- #==============================================================================
- class Window_ReserveGold < Window_Base
- #--------------------------------------------------------------------------
- # ● 初期化对象
- # x : 窗口的 X 坐标
- # y : 窗口的 Y 坐标
- #--------------------------------------------------------------------------
- def initialize(x, y)
- super(x, y, 272, WLH + 32)
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- draw_currency_value($game_party.keep_gold, 104, 0, 120)
- self.contents.font.color = system_color
- self.contents.draw_text(16, 0, 120, WLH, BBL_RESERVE_SYSTEM::RESERVE_GOLD_NAME)
- end
- end
- #==============================================================================
- # ■ Window_HandGold
- #------------------------------------------------------------------------------
- # 显示所持金额的窗口。
- #==============================================================================
- class Window_HandGold < Window_Base
- #--------------------------------------------------------------------------
- # ● 初期化对象
- # x : 窗口的 X 坐标
- # y : 窗口的 Y 坐标
- #--------------------------------------------------------------------------
- def initialize(x, y)
- super(x, y, 272, WLH + 32)
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- draw_currency_value($game_party.gold, 104, 0, 120)
- self.contents.font.color = system_color
- self.contents.draw_text(16, 0, 120, WLH, BBL_RESERVE_SYSTEM::GOLD_NAME)
- end
- end
- #==============================================================================
- # ■ Window_ReserveCommand
- #------------------------------------------------------------------------------
- # 进行仓库指令选择的窗口。
- #==============================================================================
- class Window_ReserveCommand < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :commands # 指令
- #--------------------------------------------------------------------------
- # ● 初期化对象
- # width : 窗口的宽度
- # commands : 指令字符串的排序
- # column_max : 行数 (在2 以上时,横向选项)
- # row_max : 列数 (0:切合指令个数)
- # spacing : 项目横向排列时 空白的部分
- #--------------------------------------------------------------------------
- def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
- if row_max == 0
- row_max = (commands.size + column_max - 1) / column_max
- end
- super(0, 0, width, row_max * WLH + 32, spacing)
- @commands = commands
- @item_max = commands.size
- @column_max = column_max
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- for i in 0...@item_max
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # ● 项目的描画
- # index : 项目编号
- # enabled : 有效标志。false 时会描绘为半透明状
- #--------------------------------------------------------------------------
- def draw_item(index, enabled = true)
- rect = item_rect(index)
- rect.x += 4
- rect.width -= 8
- self.contents.clear_rect(rect)
- self.contents.font.color = normal_color
- self.contents.font.color.alpha = enabled ? 255 : 128
- self.contents.draw_text(rect, @commands[index], 1)
- end
- end
复制代码