赞 | 1 |
VIP | 8 |
好人卡 | 6 |
积分 | 4 |
经验 | 49158 |
最后登录 | 2022-2-17 |
在线时间 | 602 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 380
- 在线时间
- 602 小时
- 注册时间
- 2014-5-8
- 帖子
- 699
|
9楼
楼主 |
发表于 2014-8-31 19:52:58
|
只看该作者
本帖最后由 布罗利 于 2014-8-31 20:15 编辑
芯☆淡茹水 发表于 2014-8-17 17:21
要改很多很多,,很多。
每个角色增加一个 包包 的属性。
改得到物品时判断每个角色包包是否都满?或者哪个 ...
闲得无聊
我就去翻百变宝典
没想到找到了这样的类似系统
稍微改一下就可以用.....
帮忙改改呗
我改了好几遍都不对
需要注意的是这个脚本那菜单写进去了
我所以我发两个脚本,第一个是原脚本,第二个是我改的差不多但是进不去物品的脚本
#单人负重系统 V 1.10 BY SLICK module RPG class Item attr_accessor :weight def name return @name.split(/,/)[0] end def weight rpgwt = @name.split(/,/)[1].to_i return rpgwt = nil ? 0 : rpgwt end def description return @description.split(/@/)[0] end def inc_weight rpgwt = @description.split(/@/)[1].to_i return rpgwt = nil ? 0 : rpgwt end end class Weapon attr_accessor :weight def name return @name.split(/,/)[0] end def weight rpgwt = @name.split(/,/)[1].to_i return rpgwt = nil ? 0 : rpgwt end end class Armor attr_accessor :weight def name return @name.split(/,/)[0] end def weight rpgwt = @name.split(/,/)[1].to_i return rpgwt = nil ? 0 : rpgwt end end end class Game_Actor < Game_Battler attr_accessor :weight # 单个人物目前所带负载 attr_accessor :indi_capacity attr_accessor :items attr_accessor :weapons attr_accessor :armors alias original_setup setup def setup(actor_id) original_setup(actor_id) @weight=0 @items = {} @weapons = {} @armors = {} case actor_id when 1 # SLICK @indi_capacity = 50000 when 2 # 玛塔赫 @indi_capacity = 18000 when 3 # 塞拉斯 @indi_capacity = 40000 when 4 # 特萝西 @indi_capacity = 14000 when 5 # 艾斯迪儿 @indi_capacity = 36000 when 6 # 菲力克斯 @indi_capacity = 25000 when 7 # 克萝莉亚 @indi_capacity = 14000 when 8 # 西露达 @indi_capacity = 10000 end end def total_weight totalwt = self.weight if self.weapon_id != 0 totalwt += $data_weapons[self.weapon_id].weight end if self.armor1_id != 0 totalwt += $data_armors[self.armor1_id].weight end if self.armor2_id != 0 totalwt += $data_armors[self.armor2_id].weight end if self.armor3_id != 0 totalwt += $data_armors[self.armor3_id].weight end if self.armor4_id != 0 totalwt += $data_armors[self.armor4_id].weight end return totalwt end def item_number(item_id) # 如果 hash 个数数值不存在就返回 0 return @items.include?(item_id) ? @items[item_id] : 0 end #-------------------------------------------------------------------------- # ● 获取武器所持数 # weapon_id : 武器 ID #-------------------------------------------------------------------------- def weapon_number(weapon_id) # 如果 hash 个数数值不存在就返回 0 return @weapons.include?(weapon_id) ? @weapons[weapon_id] : 0 end #-------------------------------------------------------------------------- # ● 获取防具所持数 # armor_id : 防具 ID #-------------------------------------------------------------------------- def armor_number(armor_id) # 如果 hash 个数数值不存在就返回 0 return @armors.include?(armor_id) ? @armors[armor_id] : 0 end #-------------------------------------------------------------------------- # ● 增加物品 (减少) # item_id : 物品 ID # n : 个数 #-------------------------------------------------------------------------- def gain_item(item_id, n) # 更新 hash 的个数数据 if item_id > 0 temp = @weight + $data_items[item_id].weight * n return if (n < 0 and @items[item_id] == nil) if temp > max_weight return end if temp < 0 a = @weight for i in 1..n.abs a -= $data_items[item_id].weight if a < 0 return else # 数量-1 @items[item_id] = [item_number(item_id) - i, 0].max # 负重-1 @weight -= $data_items[item_id].weight # p @weight end end # p @weight return end if @items[item_id] != nil b = @items[item_id] - n.abs if b < 0 and n < 0 c = @items[item_id] @items[item_id] = [item_number(item_id) + n, 0].max @weight -= $data_items[item_id].weight * c # p @weight return end end @items[item_id] = [item_number(item_id) + n, 0].max @weight = temp # p @weight end end #-------------------------------------------------------------------------- # ● 增加武器 (减少) # weapon_id : 武器 ID # n : 个数 #-------------------------------------------------------------------------- def gain_weapon(weapon_id, n) # 更新 hash 的个数数据 if weapon_id > 0 temp = @weight + $data_weapons[weapon_id].weight * n return if (n < 0 and @weapons[weapon_id] == nil) if temp > max_weight return end if temp < 0 a = @weight for i in 1..n.abs a -= $data_weapons[weapon_id].weight if a < 0 return else # 数量-1 @weapons[weapon_id] = [weapon_number(weapon_id) - i, 0].max # 负重-1 @weight -= $data_weapons[weapon_id].weight # p @weight end end # p @weight return end if @weapons[weapon_id] != nil b = @weapons[weapon_id] - n.abs if b < 0 and n < 0 c = @weapons[weapon_id] @weapons[weapon_id] = [weapon_number(weapon_id) + n, 0].max @weight -= $data_weapons[weapon_id].weight * c # p @weight return end end @weapons[weapon_id] = [weapon_number(weapon_id) + n, 0].max @weight = temp # p @weight end end #-------------------------------------------------------------------------- # ● 增加防具 (减少) # armor_id : 防具 ID # n : 个数 #-------------------------------------------------------------------------- def gain_armor(armor_id, n) # 更新 hash 的个数数据 if armor_id > 0 temp = @weight + $data_armors[armor_id].weight * n return if (n < 0 and @armors[armor_id] == nil) if temp > max_weight return end if temp < 0 a = @weight for i in 1..n.abs a -= $data_armors[armor_id].weight if a < 0 return else # 数量-1 @armors[armor_id] = [armor_number(armor_id) - i, 0].max # 负重-1 @weight -= $data_armors[armor_id].weight # p @weight end end # p @weight return end if @armors[armor_id] != nil b = @armors[armor_id] - n.abs if b < 0 and n < 0 c = @armors[armor_id] @armors[armor_id] = [armor_number(armor_id) + n, 0].max @weight -= $data_armors[armor_id].weight * c # p @weight return end end @armors[armor_id] = [armor_number(armor_id) + n, 0].max @weight = temp # p @weight end end def max_weight return @indi_capacity end def check_weight end #-------------------------------------------------------------------------- # ● 减少物品 # item_id : 物品 ID # n : 个数 #-------------------------------------------------------------------------- def lose_item(item_id, n) # 调用 gain_item 的数值逆转 gain_item(item_id, -n) end #-------------------------------------------------------------------------- # ● 减少武器 # weapon_id : 武器 ID # n : 个数 #-------------------------------------------------------------------------- def lose_weapon(weapon_id, n) # 调用 gain_weapon 的数值逆转 gain_weapon(weapon_id, -n) end #-------------------------------------------------------------------------- # ● 减少防具 # armor_id : 防具 ID # n : 个数 #-------------------------------------------------------------------------- def lose_armor(armor_id, n) # 调用 gain_armor 的数值逆转 gain_armor(armor_id, -n) end #-------------------------------------------------------------------------- # ● 判断物品可以使用 # item_id : 物品 ID #-------------------------------------------------------------------------- def item_can_use?(item_id) # 物品个数为 0 的情况 if item_number(item_id) == 0 # 不能使用 return false end # 获取可以使用的时候 occasion = $data_items[item_id].occasion # 战斗的情况 if $game_temp.in_battle # 可以使用时为 0 (平时) 或者是 1 (战斗时) 可以使用 return (occasion == 0 or occasion == 1) end # 可以使用时为 0 (平时) 或者是 2 (菜单时) 可以使用 return (occasion == 0 or occasion == 2) end #-------------------------------------------------------------------------- # ● 变更装备 # equip_type : 装备类型 # id : 武器 or 防具 ID (0 为解除装备) #-------------------------------------------------------------------------- def equip(equip_type, id) case equip_type when 0 # 武器 if id == 0 or self.weapon_number(id) > 0 self.gain_weapon(@weapon_id, 1) @weapon_id = id self.lose_weapon(id, 1) end when 1 # 盾 if id == 0 or self.armor_number(id) > 0 update_auto_state($data_armors[@armor1_id], $data_armors[id]) self.gain_armor(@armor1_id, 1) @armor1_id = id self.lose_armor(id, 1) end when 2 # 头 if id == 0 or self.armor_number(id) > 0 update_auto_state($data_armors[@armor2_id], $data_armors[id]) self.gain_armor(@armor2_id, 1) @armor2_id = id self.lose_armor(id, 1) end when 3 # 身体 if id == 0 or self.armor_number(id) > 0 update_auto_state($data_armors[@armor3_id], $data_armors[id]) self.gain_armor(@armor3_id, 1) @armor3_id = id self.lose_armor(id, 1) end when 4 # 装饰品 if id == 0 or self.armor_number(id) > 0 update_auto_state($data_armors[@armor4_id], $data_armors[id]) self.gain_armor(@armor4_id, 1) @armor4_id = id self.lose_armor(id, 1) end end end end #============================================================================== # ■ Scene_Menu #------------------------------------------------------------------------------ # 处理菜单画面的类。 #============================================================================== class Scene_Menu #-------------------------------------------------------------------------- # ● 初始化对像 # menu_index : 命令光标的初期位置 #-------------------------------------------------------------------------- def initialize(menu_index = 0) @menu_index = menu_index end #-------------------------------------------------------------------------- # ● 主处理 #-------------------------------------------------------------------------- def main # 生成命令窗口 s1 = $data_system.words.item s2 = $data_system.words.skill s3 = $data_system.words.equip s4 = "状态" s5 = "存档" s6 = "结束游戏" @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6]) @command_window.index = @menu_index # 同伴人数为 0 的情况下 if $game_party.actors.size == 0 # 物品、特技、装备、状态无效化 @command_window.disable_item(0) @command_window.disable_item(1) @command_window.disable_item(2) @command_window.disable_item(3) end # 禁止存档的情况下 if $game_system.save_disabled # 存档无效 @command_window.disable_item(4) end # 生成游戏时间窗口 @playtime_window = Window_PlayTime.new @playtime_window.x = 0 @playtime_window.y = 224 # 生成步数窗口 @steps_window = Window_Steps.new @steps_window.x = 0 @steps_window.y = 320 # 生成金钱窗口 @gold_window = Window_Gold.new @gold_window.x = 0 @gold_window.y = 416 # 生成状态窗口 @status_window = Window_MenuStatus.new @status_window.x = 160 @status_window.y = 0 # 执行过渡 Graphics.transition # 主循环 loop do # 刷新游戏画面 Graphics.update # 刷新输入信息 Input.update # 刷新画面 update # 如果切换画面就中断循环 if $scene != self break end end # 准备过渡 Graphics.freeze # 释放窗口 @command_window.dispose @playtime_window.dispose @steps_window.dispose @gold_window.dispose @status_window.dispose end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update # 刷新窗口 @command_window.update @playtime_window.update @steps_window.update @gold_window.update @status_window.update # 命令窗口被激活的情况下: 调用 update_command if @command_window.active update_command return end # 状态窗口被激活的情况下: 调用 update_status if @status_window.active update_status return end end #-------------------------------------------------------------------------- # ● 刷新画面 (命令窗口被激活的情况下) #-------------------------------------------------------------------------- def update_command # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 切换的地图画面 $scene = Scene_Map.new return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 同伴人数为 0、存档、游戏结束以外的场合 if $game_party.actors.size == 0 and @command_window.index < 4 # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 命令窗口的光标位置分支 case @command_window.index when 0 # 物品 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换到物品画面 @command_window.active = false @status_window.active = true @status_window.index = 0 when 1 # 特技 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 激活状态窗口 @command_window.active = false @status_window.active = true @status_window.index = 0 when 2 # 装备 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 激活状态窗口 @command_window.active = false @status_window.active = true @status_window.index = 0 when 3 # 状态 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 激活状态窗口 @command_window.active = false @status_window.active = true @status_window.index = 0 when 4 # 存档 # 禁止存档的情况下 if $game_system.save_disabled # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换到存档画面 $scene = Scene_Save.new when 5 # 游戏结束 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换到游戏结束画面 $scene = Scene_End.new end return end end #-------------------------------------------------------------------------- # ● 刷新画面 (状态窗口被激活的情况下) #-------------------------------------------------------------------------- def update_status # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 激活命令窗口 @command_window.active = true @status_window.active = false @status_window.index = -1 return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 命令窗口的光标位置分支 case @command_window.index when 0 # 单人物品选择 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换的装备画面 $scene = Scene_IndiItem.new(@status_window.index) when 1 # 特技 # 本角色的行动限制在 2 以上的情况下 if $game_party.actors[@status_window.index].restriction >= 2 # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换到特技画面 $scene = Scene_Skill.new(@status_window.index) when 2 # 装备 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换的装备画面 $scene = Scene_Equip.new(@status_window.index) when 3 # 状态 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换到状态画面 $scene = Scene_Status.new(@status_window.index) end return end end end #============================================================================== # ■ Scene_IndiItem #------------------------------------------------------------------------------ # 处理单人物品画面的类。 #============================================================================== class Scene_IndiItem #-------------------------------------------------------------------------- # ● 初始化对像 # actor_index : 角色索引 # equip_index : 装备索引 #-------------------------------------------------------------------------- def initialize(actor_index) @actor_index = actor_index @actor = $game_party.actors[@actor_index] $正在丢弃物品 = 0 $正在交付物品 = 0 $指定人物=0 $交付数量=0 end #-------------------------------------------------------------------------- # ● 主处理 #-------------------------------------------------------------------------- def main # 生成帮助窗口、物品窗口 @help_window = Window_Help.new @item_window = Window_IndiItem.new(@actor) # 关联帮助窗口 @item_window.help_window = @help_window # 生成目标窗口 (设置为不可见・不活动) @target_window = Window_Target.new @target_window.visible = false @target_window.active = false @num_window = Window_GiveNum.new(@actor, nil) @num_window.visible=false @num_window.active=false @give_window = Window_Give.new(@actor) @give_window.visible=false @give_window.active=false @dowi_window = Window_Dowi.new @dowi_window.visible=false @dowi_window.active=false # 执行过度 Graphics.transition # 主循环 loop do # 刷新游戏画面 Graphics.update # 刷新输入信息 Input.update # 刷新画面 update # 如果画面切换就中断循环 if $scene != self break end end # 装备过渡 Graphics.freeze # 释放窗口 @help_window.dispose @item_window.dispose @target_window.dispose @num_window.dispose @give_window.dispose @dowi_window.dispose end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update # 刷新窗口 @help_window.update @item_window.update @target_window.update # 物品窗口被激活的情况下: 调用 update_item if @item_window.active update_item return end # 目标窗口被激活的情况下: 调用 update_target if @target_window.active update_target return end if @num_window.active update_num return end if @give_window.active update_give return end if @dowi_window.active update_dowi return end end def update_num if Input.trigger?(Input::B) @num_window.active=false @num_window.visible=false @give_window.active=false @give_window.visible=false @item_window.active=true $game_system.se_play($data_system.cancel_se) return end if Input.trigger?(Input::C) @item = @item_window.item wwwt = @item.weight * $交付数量 if @dowi_window.index == 1 if wwwt > ($game_party.actors[$指定人物].indi_capacity-$game_party.actors[$指定人物].total_weight) $game_system.se_play($data_system.buzzer_se) return end case @item when RPG::Item $game_party.actors[$指定人物].gain_item(@item.id,$交付数量) when RPG::Weapon $game_party.actors[$指定人物].gain_weapon(@item.id,$交付数量) when RPG::Armor $game_party.actors[$指定人物].gain_armor(@item.id,$交付数量) end end case @item when RPG::Item @actor.lose_item(@item.id,$交付数量) when RPG::Weapon @actor.lose_weapon(@item.id,$交付数量) when RPG::Armor @actor.lose_armor(@item.id,$交付数量) end @num_window.active=false @num_window.visible=false @give_window.active=false @give_window.visible=false @item_window.active=true $game_system.se_play($data_system.decision_se) @item_window.refresh @weight_window.refresh(@item.weight) return end @num_window.update end def update_give if Input.trigger?(Input::B) @give_window.active=false @give_window.visible=false @item_window.active=true $game_system.se_play($data_system.cancel_se) return end if Input.trigger?(Input::C) @item = @item_window.item @give_window.active=false @num_window.dispose @num_window = Window_GiveNum.new(@actor, @item) @num_window.active=true @num_window.visible=true $game_system.se_play($data_system.decision_se) return end if Input.trigger?(Input::DOWN) @give_window.index+=1 if @give_window.index>=$give_max @give_window.index=0 end $game_system.se_play($data_system.cursor_se) return end if Input.trigger?(Input::UP) @give_window.index-=1 if @give_window.index<0 @give_window.index+=$give_max end $game_system.se_play($data_system.cursor_se) return end @give_window.update end def update_dowi if Input.trigger?(Input::B) @dowi_window.active=false @dowi_window.visible=false @item_window.active=true $game_system.se_play($data_system.cancel_se) return end if Input.trigger?(Input::C) @item = @item_window.item if @dowi_window.index == 0 #============================================================================== # 不使用物品的情况下 unless @item.is_a?(RPG::Item) # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 不能使用的情况下 unless @actor.item_can_use?(@item.id) # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 效果范围是我方的情况下 if @item.scope >= 3 # 激活目标窗口 @dowi_window.active=false @dowi_window.visible=false @target_window.x = (@item_window.index + 1) % 2 * 304 @target_window.visible = true @target_window.active = true # 设置效果范围 (单体/全体) 的对应光标位置 if @item.scope == 4 || @item.scope == 6 @target_window.index = -1 else @target_window.index = 0 end # 效果在我方以外的情况下 else # 公共事件 ID 有效的情况下 if @item.common_event_id > 0 # 预约调用公共事件 $game_temp.common_event_id = @item.common_event_id # 演奏物品使用时的 SE $game_system.se_play(@item.menu_se) # 消耗品的情况下 if @item.consumable # 使用的物品数减 1 @actor.lose_item(@item.id, 1) # 再描绘物品窗口的项目 @item_window.draw_item(@item_window.index) end # 切换到地图画面 $scene = Scene_Map.new return end return end #============================================================================== else if @dowi_window.index==1 if $game_party.actors.size<2 $game_system.se_play($data_system.buzzer_se) return end $正在交付物品=1 $正在丢弃物品=0 @dowi_window.active=false @dowi_window.visible=false @give_window.dispose @give_window=Window_Give.new(@actor) @give_window.active=true @give_window.visible=true else $正在交付物品=0 $正在丢弃物品=1 @dowi_window.active=false @dowi_window.visible=false @item = @item_window.item @num_window.dispose @num_window = Window_GiveNum.new(@actor, @item) @num_window.active=true @num_window.visible=true end $game_system.se_play($data_system.decision_se) return end end if Input.trigger?(Input::DOWN) @dowi_window.index+=1 if @dowi_window.index>2 @dowi_window.index=0 end $game_system.se_play($data_system.cursor_se) return end if Input.trigger?(Input::UP) @dowi_window.index-=1 if @dowi_window.index<0 @dowi_window.index=2 end $game_system.se_play($data_system.cursor_se) return end @dowi_window.update end #-------------------------------------------------------------------------- # ● 刷新画面 (物品窗口被激活的情况下) #-------------------------------------------------------------------------- def update_item # 按下 R 键的情况下 if Input.trigger?(Input::R) # 演奏光标 SE $game_system.se_play($data_system.cursor_se) # 移至下一位角色 @actor_index += 1 @actor_index %= $game_party.actors.size # 切换到别的装备画面 $scene = Scene_IndiItem.new(@actor_index) return end # 按下 L 键的情况下 if Input.trigger?(Input::L) # 演奏光标 SE $game_system.se_play($data_system.cursor_se) # 移至上一位角色 @actor_index += $game_party.actors.size - 1 @actor_index %= $game_party.actors.size # 切换到别的装备画面 $scene = Scene_IndiItem.new(@actor_index) return end # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 切换到菜单画面 $scene = Scene_Menu.new(0) return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 获取物品窗口当前选中的物品数据 @item = @item_window.item @item_window.active=false @dowi_window.dispose @dowi_window=Window_Dowi.new(@item) @dowi_window.visible=true @dowi_window.active=true $game_system.se_play($data_system.decision_se) return end end #-------------------------------------------------------------------------- # ● 刷新画面 (目标窗口被激活的情况下) #-------------------------------------------------------------------------- def update_target # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 由于物品用完而不能使用的场合 unless @actor.item_can_use?(@item.id) # 再次生成物品窗口的内容 @item_window.refresh end # 删除目标窗口 @item_window.active = true @target_window.visible = false @target_window.active = false return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 如果物品用完的情况下 if @actor.item_number(@item.id) == 0 # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 目标是全体的情况下 if @target_window.index == -1 # 对同伴全体应用物品使用效果 used = false for i in $game_party.actors used |= i.item_effect(@item) end end # 目标是单体的情况下 if @target_window.index >= 0 # 对目标角色应用物品的使用效果 target = $game_party.actors[@target_window.index] used = target.item_effect(@item) end # 使用物品的情况下 if used # 演奏物品使用时的 SE $game_system.se_play(@item.menu_se) # 消耗品的情况下 if @item.consumable # 使用的物品数减 1 @actor.lose_item(@item.id, 1) # 再描绘物品窗口的项目 @item_window.draw_item(@item_window.index) end # 再生成目标窗口的内容 @target_window.refresh # 全灭的情况下 if $game_party.all_dead? # 切换到游戏结束画面 $scene = Scene_Gameover.new return end # 公共事件 ID 有效的情况下 if @item.common_event_id > 0 # 预约调用公共事件 $game_temp.common_event_id = @item.common_event_id # 切换到地图画面 $scene = Scene_Map.new return end end # 无法使用物品的情况下 unless used # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) end return end end end class Scene_Battle def start_item_select # 生成物品窗口 @item_window = Window_IndiItem.new(@active_actor) # 关联帮助窗口 @item_window.help_window = @help_window # 无效化角色指令窗口 @actor_command_window.active = false @actor_command_window.visible = false end #-------------------------------------------------------------------------- # ● 刷新画面 (角色命令回合 : 选择物品) #-------------------------------------------------------------------------- def update_phase3_item_select # 设置物品窗口为可视状态 @item_window.visible = true # 刷新物品窗口 @item_window.update # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 选择物品结束 end_item_select return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 获取物品窗口现在选择的物品资料 @item = @item_window.item # 无法使用的情况下 unless @active_actor.item_can_use?(@item.id) # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 设置行动 @active_actor.current_action.item_id = @item.id # 设置物品窗口为不可见状态 @item_window.visible = false # 效果范围是敌单体的情况下 if @item.scope == 1 # 开始选择敌人 start_enemy_select # 效果范围是我方单体的情况下 elsif @item.scope == 3 or @item.scope == 5 # 开始选择角色 start_actor_select # 效果范围不是单体的情况下 else # 物品选择结束 end_item_select # 转到下一位角色的指令输入 phase3_next_actor end return end end def make_item_action_result(battler) # アイテムを取得 @item = $data_items[battler.current_action.item_id] # アイテム切れなどで使用できなくなった場合 unless battler.item_can_use?(@item.id) # ステップ 6 に移行 battler.phase = 6 return end # 消耗品の場合 if @item.consumable # 使用したアイテムを 1 減らす battler.lose_item(@item.id, 1) end # アニメーション ID を設定 battler.anime1 = @item.animation1_id battler.anime2 = @item.animation2_id # コモンイベント ID を設定 battler.event = @item.common_event_id # 対象を決定 index = battler.current_action.target_index target = $game_party.smooth_target_actor(index) # 対象側バトラーを設定 set_target_battlers(@item.scope, battler) # アイテムの効果を適用 for target in battler.target target.item_effect(@item, battler) end end end #============================================================================== # ■ Window_IndiItem #------------------------------------------------------------------------------ # 物品画面、战斗画面、显示浏览物品的窗口。 #============================================================================== class Window_IndiItem < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize(actor) @actor = actor super(0, 64, 640, 288) @column_max = 2 refresh self.index = 0 # 战斗中的情况下将窗口移至中央并将其半透明化 if $game_temp.in_battle self.y = 64 self.height = 256 self.back_opacity = 160 end end #-------------------------------------------------------------------------- # ● 获取物品 #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] # 添加报务 for i in 1...$data_items.size if @actor.item_number(i) > 0 @data.push($data_items[i]) end end # 在战斗中以外添加武器、防具 unless $game_temp.in_battle for i in 1...$data_weapons.size if @actor.weapon_number(i) > 0 @data.push($data_weapons[i]) end end for i in 1...$data_armors.size if @actor.armor_number(i) > 0 @data.push($data_armors[i]) end end end # 如果项目数不是 0 就生成位图、重新描绘全部项目 @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # ● 描绘项目 # index : 项目编号 #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] case item when RPG::Item number = @actor.item_number(item.id) when RPG::Weapon number = @actor.weapon_number(item.id) when RPG::Armor number = @actor.armor_number(item.id) end if item.is_a?(RPG::Item) and @actor.item_can_use?(item.id) self.contents.font.color = normal_color else self.contents.font.color = disabled_color end x = 4 + index % 2 * (288 + 32) y = index / 2 * 32 rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 192, 32, item.name, 0) self.contents.draw_text(x + 224, y, 16, 32, ":", 1) self.contents.draw_text(x + 240, y, 40, 32, number.to_s, 2) end #-------------------------------------------------------------------------- # ● 刷新帮助文本 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.item == nil ? "" : self.item.description) end end class Scene_IndiItem alias ori_main main def main @weight_window = Window_Weight.new(@actor) @weight_window.x = 0 @weight_window.y = 352 @weight_window.z = 0 ori_main @weight_window.dispose end alias ori_update update def update case @item_window.item when RPG::Item @weight_window.refresh($data_items[@item_window.item.id].weight) when RPG::Weapon @weight_window.refresh($data_weapons[@item_window.item.id].weight) when RPG::Armor @weight_window.refresh($data_armors[@item_window.item.id].weight) end ori_update end end class Window_Weight < Window_Base def initialize(actor) @actor=actor super(0,0,640,128) self.opacity = 255 self.contents = Bitmap.new(width-32,height-32) refresh(nil) end def refresh(weight) self.contents.clear self.contents.draw_text(0,0,160,32,@actor.name) if weight != nil self.contents.draw_text(128,0,160,32,"单件重量:#{weight}") end self.contents.draw_text(320,0,320,32,"背包重量:"+@actor.total_weight.to_s + "/" + @actor.indi_capacity.to_s , 0) ssstx=0 sssty=32 self.contents.draw_text(ssstx,sssty,160,32,"装备物品:") ssstx=128 if @actor.weapon_id != 0 self.contents.draw_text(ssstx,sssty,160,32,$data_weapons[@actor.weapon_id].name + "(" + $data_weapons[@actor.weapon_id].weight.to_s + ")") end ssstx=288 if @actor.armor1_id != 0 self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor1_id].name + "(" + $data_armors[@actor.armor1_id].weight.to_s + ")") end ssstx=448 if @actor.armor2_id != 0 self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor2_id].name + "(" + $data_armors[@actor.armor2_id].weight.to_s + ")") end ssstx=128 sssty=64 if @actor.armor3_id != 0 self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor3_id].name + "(" + $data_armors[@actor.armor3_id].weight.to_s + ")") end ssstx=288 if @actor.armor4_id != 0 self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor4_id].name + "(" + $data_armors[@actor.armor4_id].weight.to_s + ")") end end end class Window_Dowi < Window_Selectable def initialize(item = nil) super(256, 240, 128, 160) @item = item self.opacity = 255 self.contents = Bitmap.new(width-32,height-32) self.z=120 self.index=0 refresh end def refresh self.contents.draw_text(4, 0, 192, 32, "使用", 0) self.contents.draw_text(4, 32, 192, 32, "交给", 0) self.contents.draw_text(4, 64, 192, 32, "丢弃", 0) end end class Window_Give < Window_Selectable def initialize(actor) super(256, 240, 128, 160) @actor = actor @column_max = 1 self.active = false self.index = -1 self.contents = Bitmap.new(width - 32, height - 32) self.z=120 self.index=0 $指定人物=0 # 添加本人以外的角色 @data=[] @data_target=[] for iii in 0...$game_party.actors.size if @actor != $game_party.actors[iii] @data.push($game_party.actors[iii].name) @data_target.push(iii) end end @item_max=@data.size $give_max=@item_max refresh end def refresh self.contents.clear for i in 0...@item_max draw_item(i) end $指定人物=@data_target[self.index] end #-------------------------------------------------------------------------- # ● 项目的描绘 # index : 项目符号 #-------------------------------------------------------------------------- def draw_item(index) #print index item = @data[index] #print item x = 4 y = index * 32 self.contents.font.color = normal_color self.contents.draw_text(x, y, 192, 32, item, 0) end def update refresh end end class Window_GiveNum < Window_Base #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize(actor, item) super(160, 80, 320, 160) self.contents = Bitmap.new(width - 32, height - 32) @item = item @number = 1 if item != nil @max = actor.item_number(item.id) else @max = 0 end self.z=120 refresh end def refresh self.contents.clear self.contents.font.color = normal_color if @item != nil if $正在丢弃物品 != 0 self.contents.draw_text(4, 0, 192, 32, "丢掉几件", 0) self.contents.draw_text(200, 0, 192, 32, @number.to_s, 0) self.contents.draw_text(4, 32, 192, 32, "减轻重量", 0) self.contents.draw_text(200, 32, 192, 32, [@number * @item.weight].to_s, 0) self.contents.draw_text(4, 96, 240, 32, "请按方向键增减数量", 0) return end if $正在交付物品 != 1 self.contents.draw_text(4, 0, 192, 32, "要交给谁", 0) else self.contents.draw_text(4, 0, 192, 32, "交给几件", 0) self.contents.draw_text(200, 0, 192, 32, @number.to_s, 0) self.contents.draw_text(4, 32, 192, 32, "交换重量", 0) self.contents.draw_text(200, 32, 192, 32, [@number * @item.weight].to_s, 0) self.contents.draw_text(4, 64, 240, 32, "接收方剩余负荷", 0) lastweight=$game_party.actors[$指定人物].indi_capacity-$game_party.actors[$指定人物].total_weight self.contents.draw_text(200, 64, 192, 32, lastweight.to_s, 0) end self.contents.draw_text(4, 96, 240, 32, "请按方向键增减数量", 0) end end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update super if @item != nil if self.active # 光标右 (+10) if Input.repeat?(Input::RIGHT) and @number < @max $game_system.se_play($data_system.cursor_se) @number = [@number + 10, @max].min end # 光标左 (-10) if Input.repeat?(Input::LEFT) and @number > 1 $game_system.se_play($data_system.cursor_se) @number = [@number - 10, 1].max end # 光标上 (-1) if Input.repeat?(Input::UP) and @number > 1 $game_system.se_play($data_system.cursor_se) @number -= 1 end # 光标下 (+1) if Input.repeat?(Input::DOWN) and @number < @max $game_system.se_play($data_system.cursor_se) @number += 1 end end end $交付数量=@number refresh end end #============================================================================== # ■ Window_EquipItem #------------------------------------------------------------------------------ # 装备画面、显示浏览变更装备的候补物品的窗口。 #============================================================================== class Window_EquipItem < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 # actor : 角色 # equip_type : 装备部位 (0~3) #-------------------------------------------------------------------------- def initialize(actor, equip_type) super(0, 256, 640, 224) @actor = actor @equip_type = equip_type @column_max = 2 refresh self.active = false self.index = -1 end #-------------------------------------------------------------------------- # ● 获取物品 #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] # 添加可以装备的武器 if @equip_type == 0 weapon_set = $data_classes[@actor.class_id].weapon_set for i in 1...$data_weapons.size if @actor.weapon_number(i) > 0 and weapon_set.include?(i) @data.push($data_weapons[i]) end end end # 添加可以装备的防具 if @equip_type != 0 armor_set = $data_classes[@actor.class_id].armor_set for i in 1...$data_armors.size if @actor.armor_number(i) > 0 and armor_set.include?(i) if $data_armors[i].kind == @equip_type-1 @data.push($data_armors[i]) end end end end # 添加空白 @data.push(nil) # 生成位图、描绘全部项目 @item_max = @data.size self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max-1 draw_item(i) end end #-------------------------------------------------------------------------- # ● 项目的描绘 # index : 项目符号 #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] x = 4 + index % 2 * (288 + 32) y = index / 2 * 32 case item when RPG::Weapon number = @actor.weapon_number(item.id) when RPG::Armor number = @actor.armor_number(item.id) end bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) self.contents.font.color = normal_color self.contents.draw_text(x + 28, y, 192, 32, item.name, 0) self.contents.draw_text(x + 224, y, 16, 32, ":", 1) self.contents.draw_text(x + 240, y, 40, 32, number.to_s, 2) end #-------------------------------------------------------------------------- # ● 刷新帮助文本 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.item == nil ? "" : self.item.description) end end class Game_Party #-------------------------------------------------------------------------- # ● 增加物品 (减少) # item_id : 物品 ID # n : 个数 #-------------------------------------------------------------------------- def gain_item(item_id, n) # 更新 hash 的个数数据 if item_id > 0 wwwt = $data_items[item_id].weight straight = 0 #从领队开始依次拿取物品,当领队载重量不够时转至下一个队员获取 for iii in 0...n #检查物品n次 leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight while leftwt < wwwt straight += 1 if straight>=$game_party.actors.size return end leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight end $game_party.actors[straight].gain_item(item_id, 1) end end end #-------------------------------------------------------------------------- # ● 增加武器 (减少) # weapon_id : 武器 ID # n : 个数 #-------------------------------------------------------------------------- def gain_weapon(weapon_id, n) # 更新 hash 的个数数据 if item_id > 0 wwwt = $data_weapons[weapon_id].weight straight = 0 #从领队开始依次拿取物品,当领队载重量不够时转至下一个队员获取 for iii in 0...n #检查物品n次 leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight while leftwt < wwwt straight += 1 if straight>=$game_party.actors.size return end leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight end $game_party.actors[straight].gain_weapon(weapon_id, 1) end end end #-------------------------------------------------------------------------- # ● 增加防具 (减少) # armor_id : 防具 ID # n : 个数 #-------------------------------------------------------------------------- def gain_armor(armor_id, n) # 更新 hash 的个数数据 if item_id > 0 wwwt = $data_armors[armor_id].weight straight = 0 #从领队开始依次拿取物品,当领队载重量不够时转至下一个队员获取 for iii in 0...n #检查物品n次 leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight while leftwt < wwwt straight += 1 if straight>=$game_party.actors.size return end leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight end $game_party.actors[straight].gain_armor(armor_id, 1) end end end end
#单人负重系统 V 1.10 BY SLICK
module RPG
class Item
attr_accessor :weight
def name
return @name.split(/,/)[0]
end
def weight
rpgwt = @name.split(/,/)[1].to_i
return rpgwt = nil ? 0 : rpgwt
end
def description
return @description.split(/@/)[0]
end
def inc_weight
rpgwt = @description.split(/@/)[1].to_i
return rpgwt = nil ? 0 : rpgwt
end
end
class Weapon
attr_accessor :weight
def name
return @name.split(/,/)[0]
end
def weight
rpgwt = @name.split(/,/)[1].to_i
return rpgwt = nil ? 0 : rpgwt
end
end
class Armor
attr_accessor :weight
def name
return @name.split(/,/)[0]
end
def weight
rpgwt = @name.split(/,/)[1].to_i
return rpgwt = nil ? 0 : rpgwt
end
end
end
class Game_Actor < Game_Battler
attr_accessor :weight # 单个人物目前所带负载
attr_accessor :indi_capacity
attr_accessor :items
attr_accessor :weapons
attr_accessor :armors
alias original_setup setup
def setup(actor_id)
original_setup(actor_id)
@weight=0
@items = {}
@weapons = {}
@armors = {}
case actor_id
when 1 # SLICK
@indi_capacity = 50000
when 2 # 玛塔赫
@indi_capacity = 18000
when 3 # 塞拉斯
@indi_capacity = 40000
when 4 # 特萝西
@indi_capacity = 14000
when 5 # 艾斯迪儿
@indi_capacity = 36000
when 6 # 菲力克斯
@indi_capacity = 25000
when 7 # 克萝莉亚
@indi_capacity = 14000
when 8 # 西露达
@indi_capacity = 10000
end
end
def total_weight
totalwt = self.weight
if self.weapon_id != 0
totalwt += $data_weapons[self.weapon_id].weight
end
if self.armor1_id != 0
totalwt += $data_armors[self.armor1_id].weight
end
if self.armor2_id != 0
totalwt += $data_armors[self.armor2_id].weight
end
if self.armor3_id != 0
totalwt += $data_armors[self.armor3_id].weight
end
if self.armor4_id != 0
totalwt += $data_armors[self.armor4_id].weight
end
return totalwt
end
def item_number(item_id)
# 如果 hash 个数数值不存在就返回 0
return @items.include?(item_id) ? @items[item_id] : 0
end
#--------------------------------------------------------------------------
# ● 获取武器所持数
# weapon_id : 武器 ID
#--------------------------------------------------------------------------
def weapon_number(weapon_id)
# 如果 hash 个数数值不存在就返回 0
return @weapons.include?(weapon_id) ? @weapons[weapon_id] : 0
end
#--------------------------------------------------------------------------
# ● 获取防具所持数
# armor_id : 防具 ID
#--------------------------------------------------------------------------
def armor_number(armor_id)
# 如果 hash 个数数值不存在就返回 0
return @armors.include?(armor_id) ? @armors[armor_id] : 0
end
#--------------------------------------------------------------------------
# ● 增加物品 (减少)
# item_id : 物品 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_item(item_id, n)
# 更新 hash 的个数数据
if item_id > 0
temp = @weight + $data_items[item_id].weight * n
return if (n < 0 and @items[item_id] == nil)
if temp > max_weight
return
end
if temp < 0
a = @weight
for i in 1..n.abs
a -= $data_items[item_id].weight
if a < 0
return
else
# 数量-1
@items[item_id] = [item_number(item_id) - i, 0].max
# 负重-1
@weight -= $data_items[item_id].weight
# p @weight
end
end
# p @weight
return
end
if @items[item_id] != nil
b = @items[item_id] - n.abs
if b < 0 and n < 0
c = @items[item_id]
@items[item_id] = [item_number(item_id) + n, 0].max
@weight -= $data_items[item_id].weight * c
# p @weight
return
end
end
@items[item_id] = [item_number(item_id) + n, 0].max
@weight = temp
# p @weight
end
end
#--------------------------------------------------------------------------
# ● 增加武器 (减少)
# weapon_id : 武器 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_weapon(weapon_id, n)
# 更新 hash 的个数数据
if weapon_id > 0
temp = @weight + $data_weapons[weapon_id].weight * n
return if (n < 0 and @weapons[weapon_id] == nil)
if temp > max_weight
return
end
if temp < 0
a = @weight
for i in 1..n.abs
a -= $data_weapons[weapon_id].weight
if a < 0
return
else
# 数量-1
@weapons[weapon_id] = [weapon_number(weapon_id) - i, 0].max
# 负重-1
@weight -= $data_weapons[weapon_id].weight
# p @weight
end
end
# p @weight
return
end
if @weapons[weapon_id] != nil
b = @weapons[weapon_id] - n.abs
if b < 0 and n < 0
c = @weapons[weapon_id]
@weapons[weapon_id] = [weapon_number(weapon_id) + n, 0].max
@weight -= $data_weapons[weapon_id].weight * c
# p @weight
return
end
end
@weapons[weapon_id] = [weapon_number(weapon_id) + n, 0].max
@weight = temp
# p @weight
end
end
#--------------------------------------------------------------------------
# ● 增加防具 (减少)
# armor_id : 防具 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_armor(armor_id, n)
# 更新 hash 的个数数据
if armor_id > 0
temp = @weight + $data_armors[armor_id].weight * n
return if (n < 0 and @armors[armor_id] == nil)
if temp > max_weight
return
end
if temp < 0
a = @weight
for i in 1..n.abs
a -= $data_armors[armor_id].weight
if a < 0
return
else
# 数量-1
@armors[armor_id] = [armor_number(armor_id) - i, 0].max
# 负重-1
@weight -= $data_armors[armor_id].weight
# p @weight
end
end
# p @weight
return
end
if @armors[armor_id] != nil
b = @armors[armor_id] - n.abs
if b < 0 and n < 0
c = @armors[armor_id]
@armors[armor_id] = [armor_number(armor_id) + n, 0].max
@weight -= $data_armors[armor_id].weight * c
# p @weight
return
end
end
@armors[armor_id] = [armor_number(armor_id) + n, 0].max
@weight = temp
# p @weight
end
end
def max_weight
return @indi_capacity
end
def check_weight
end
#--------------------------------------------------------------------------
# ● 减少物品
# item_id : 物品 ID
# n : 个数
#--------------------------------------------------------------------------
def lose_item(item_id, n)
# 调用 gain_item 的数值逆转
gain_item(item_id, -n)
end
#--------------------------------------------------------------------------
# ● 减少武器
# weapon_id : 武器 ID
# n : 个数
#--------------------------------------------------------------------------
def lose_weapon(weapon_id, n)
# 调用 gain_weapon 的数值逆转
gain_weapon(weapon_id, -n)
end
#--------------------------------------------------------------------------
# ● 减少防具
# armor_id : 防具 ID
# n : 个数
#--------------------------------------------------------------------------
def lose_armor(armor_id, n)
# 调用 gain_armor 的数值逆转
gain_armor(armor_id, -n)
end
#--------------------------------------------------------------------------
# ● 判断物品可以使用
# item_id : 物品 ID
#--------------------------------------------------------------------------
def item_can_use?(item_id)
# 物品个数为 0 的情况
if item_number(item_id) == 0
# 不能使用
return false
end
# 获取可以使用的时候
occasion = $data_items[item_id].occasion
# 战斗的情况
if $game_temp.in_battle
# 可以使用时为 0 (平时) 或者是 1 (战斗时) 可以使用
return (occasion == 0 or occasion == 1)
end
# 可以使用时为 0 (平时) 或者是 2 (菜单时) 可以使用
return (occasion == 0 or occasion == 2)
end
#--------------------------------------------------------------------------
# ● 变更装备
# equip_type : 装备类型
# id : 武器 or 防具 ID (0 为解除装备)
#--------------------------------------------------------------------------
def equip(equip_type, id)
case equip_type
when 0 # 武器
if id == 0 or self.weapon_number(id) > 0
self.gain_weapon(@weapon_id, 1)
@weapon_id = id
self.lose_weapon(id, 1)
end
when 1 # 盾
if id == 0 or self.armor_number(id) > 0
update_auto_state($data_armors[@armor1_id], $data_armors[id])
self.gain_armor(@armor1_id, 1)
@armor1_id = id
self.lose_armor(id, 1)
end
when 2 # 头
if id == 0 or self.armor_number(id) > 0
update_auto_state($data_armors[@armor2_id], $data_armors[id])
self.gain_armor(@armor2_id, 1)
@armor2_id = id
self.lose_armor(id, 1)
end
when 3 # 身体
if id == 0 or self.armor_number(id) > 0
update_auto_state($data_armors[@armor3_id], $data_armors[id])
self.gain_armor(@armor3_id, 1)
@armor3_id = id
self.lose_armor(id, 1)
end
when 4 # 装饰品
if id == 0 or self.armor_number(id) > 0
update_auto_state($data_armors[@armor4_id], $data_armors[id])
self.gain_armor(@armor4_id, 1)
@armor4_id = id
self.lose_armor(id, 1)
end
end
end
end
#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
# 处理菜单画面的类。
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# ● 初始化对像
# menu_index : 命令光标的初期位置
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成命令窗口
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "状态"
s5 = "存档"
s6 = "结束游戏"
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
@command_window.index = @menu_index
# 同伴人数为 0 的情况下
if $game_party.actors.size == 0
# 物品、特技、装备、状态无效化
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# 禁止存档的情况下
if $game_system.save_disabled
# 存档无效
@command_window.disable_item(4)
end
# 生成游戏时间窗口
@playtime_window = Window_PlayTime.new
@playtime_window.x = 0
@playtime_window.y = 224
# 生成步数窗口
@steps_window = Window_Steps.new
@steps_window.x = 0
@steps_window.y = 320
# 生成金钱窗口
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 416
# 生成状态窗口
@status_window = Window_MenuStatus.new
@status_window.x = 160
@status_window.y = 0
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果切换画面就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@command_window.dispose
@playtime_window.dispose
@steps_window.dispose
@gold_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@command_window.update
@playtime_window.update
@steps_window.update
@gold_window.update
@status_window.update
# 命令窗口被激活的情况下: 调用 update_command
if @command_window.active
update_command
return
end
# 状态窗口被激活的情况下: 调用 update_status
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (命令窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_command
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换的地图画面
$scene = Scene_Map.new
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 同伴人数为 0、存档、游戏结束以外的场合
if $game_party.actors.size == 0 and @command_window.index < 4
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 命令窗口的光标位置分支
case @command_window.index
when 0 # 物品
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到物品画面
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 1 # 特技
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # 装备
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # 状态
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # 存档
# 禁止存档的情况下
if $game_system.save_disabled
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到存档画面
$scene = Scene_Save.new
when 5 # 游戏结束
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到游戏结束画面
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (状态窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_status
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 激活命令窗口
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 命令窗口的光标位置分支
case @command_window.index
when 0 # 单人物品选择
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换的装备画面
$scene = Scene_IndiItem.new(@status_window.index)
when 1 # 特技
# 本角色的行动限制在 2 以上的情况下
if $game_party.actors[@status_window.index].restriction >= 2
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到特技画面
$scene = Scene_Skill.new(@status_window.index)
when 2 # 装备
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换的装备画面
$scene = Scene_Equip.new(@status_window.index)
when 3 # 状态
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到状态画面
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end
#==============================================================================
# ■ Scene_IndiItem
#------------------------------------------------------------------------------
# 处理单人物品画面的类。
#==============================================================================
class Scene_IndiItem
#--------------------------------------------------------------------------
# ● 初始化对像
# actor_index : 角色索引
# equip_index : 装备索引
#--------------------------------------------------------------------------
def initialize(actor_index)
@actor_index = actor_index
@actor = $game_party.actors[@actor_index]
$正在丢弃物品 = 0
$正在交付物品 = 0
$指定人物=0
$交付数量=0
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成帮助窗口、物品窗口
@help_window = Window_Help.new
@item_window = Window_IndiItem.new(@actor)
# 关联帮助窗口
@item_window.help_window = @help_window
# 生成目标窗口 (设置为不可见・不活动)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
@num_window = Window_GiveNum.new(@actor, nil)
@num_window.visible=false
@num_window.active=false
@give_window = Window_Give.new(@actor)
@give_window.visible=false
@give_window.active=false
@dowi_window = Window_Dowi.new
@dowi_window.visible=false
@dowi_window.active=false
# 执行过度
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换就中断循环
if $scene != self
break
end
end
# 装备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
@item_window.dispose
@target_window.dispose
@num_window.dispose
@give_window.dispose
@dowi_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@item_window.update
@target_window.update
# 物品窗口被激活的情况下: 调用 update_item
if @item_window.active
update_item
return
end
# 目标窗口被激活的情况下: 调用 update_target
if @target_window.active
update_target
return
end
if @num_window.active
update_num
return
end
if @give_window.active
update_give
return
end
if @dowi_window.active
update_dowi
return
end
end
def update_num
if Input.trigger?(Input::B)
@num_window.active=false
@num_window.visible=false
@give_window.active=false
@give_window.visible=false
@item_window.active=true
$game_system.se_play($data_system.cancel_se)
return
end
if Input.trigger?(Input::C)
@item = @item_window.item
wwwt = @item.weight * $交付数量
if @dowi_window.index == 1
if wwwt > ($game_party.actors[$指定人物].indi_capacity-$game_party.actors[$指定人物].total_weight)
$game_system.se_play($data_system.buzzer_se)
return
end
case @item
when RPG::Item
$game_party.actors[$指定人物].gain_item(@item.id,$交付数量)
when RPG::Weapon
$game_party.actors[$指定人物].gain_weapon(@item.id,$交付数量)
when RPG::Armor
$game_party.actors[$指定人物].gain_armor(@item.id,$交付数量)
end
end
case @item
when RPG::Item
@actor.lose_item(@item.id,$交付数量)
when RPG::Weapon
@actor.lose_weapon(@item.id,$交付数量)
when RPG::Armor
@actor.lose_armor(@item.id,$交付数量)
end
@num_window.active=false
@num_window.visible=false
@give_window.active=false
@give_window.visible=false
@item_window.active=true
$game_system.se_play($data_system.decision_se)
@item_window.refresh
@weight_window.refresh(@item.weight)
return
end
@num_window.update
end
def update_give
if Input.trigger?(Input::B)
@give_window.active=false
@give_window.visible=false
@item_window.active=true
$game_system.se_play($data_system.cancel_se)
return
end
if Input.trigger?(Input::C)
@item = @item_window.item
@give_window.active=false
@num_window.dispose
@num_window = Window_GiveNum.new(@actor, @item)
@num_window.active=true
@num_window.visible=true
$game_system.se_play($data_system.decision_se)
return
end
if Input.trigger?(Input::DOWN)
@give_window.index+=1
if @give_window.index>=$give_max
@give_window.index=0
end
$game_system.se_play($data_system.cursor_se)
return
end
if Input.trigger?(Input::UP)
@give_window.index-=1
if @give_window.index<0
@give_window.index+=$give_max
end
$game_system.se_play($data_system.cursor_se)
return
end
@give_window.update
end
def update_dowi
if Input.trigger?(Input::B)
@dowi_window.active=false
@dowi_window.visible=false
@item_window.active=true
$game_system.se_play($data_system.cancel_se)
return
end
if Input.trigger?(Input::C)
@item = @item_window.item
if @dowi_window.index == 0
#==============================================================================
# 不使用物品的情况下
unless @item.is_a?(RPG::Item)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 不能使用的情况下
unless @actor.item_can_use?(@item.id)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 效果范围是我方的情况下
if @item.scope >= 3
# 激活目标窗口
@dowi_window.active=false
@dowi_window.visible=false
@target_window.x = (@item_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# 设置效果范围 (单体/全体) 的对应光标位置
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# 效果在我方以外的情况下
else
# 公共事件 ID 有效的情况下
if @item.common_event_id > 0
# 预约调用公共事件
$game_temp.common_event_id = @item.common_event_id
# 演奏物品使用时的 SE
$game_system.se_play(@item.menu_se)
# 消耗品的情况下
if @item.consumable
# 使用的物品数减 1
@actor.lose_item(@item.id, 1)
# 再描绘物品窗口的项目
@item_window.draw_item(@item_window.index)
end
# 切换到地图画面
$scene = Scene_Map.new
return
end
return
end
#==============================================================================
else
if @dowi_window.index==1
if $game_party.actors.size<2
$game_system.se_play($data_system.buzzer_se)
return
end
$正在交付物品=1
$正在丢弃物品=0
@dowi_window.active=false
@dowi_window.visible=false
@give_window.dispose
@give_window=Window_Give.new(@actor)
@give_window.active=true
@give_window.visible=true
else
$正在交付物品=0
$正在丢弃物品=1
@dowi_window.active=false
@dowi_window.visible=false
@item = @item_window.item
@num_window.dispose
@num_window = Window_GiveNum.new(@actor, @item)
@num_window.active=true
@num_window.visible=true
end
$game_system.se_play($data_system.decision_se)
return
end
end
if Input.trigger?(Input::DOWN)
@dowi_window.index+=1
if @dowi_window.index>2
@dowi_window.index=0
end
$game_system.se_play($data_system.cursor_se)
return
end
if Input.trigger?(Input::UP)
@dowi_window.index-=1
if @dowi_window.index<0
@dowi_window.index=2
end
$game_system.se_play($data_system.cursor_se)
return
end
@dowi_window.update
end
#--------------------------------------------------------------------------
# ● 刷新画面 (物品窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_item
# 按下 R 键的情况下
if Input.trigger?(Input::R)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至下一位角色
@actor_index += 1
@actor_index %= $game_party.actors.size
# 切换到别的装备画面
$scene = Scene_IndiItem.new(@actor_index)
return
end
# 按下 L 键的情况下
if Input.trigger?(Input::L)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至上一位角色
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# 切换到别的装备画面
$scene = Scene_IndiItem.new(@actor_index)
return
end
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(0)
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品窗口当前选中的物品数据
@item = @item_window.item
@item_window.active=false
@dowi_window.dispose
@dowi_window=Window_Dowi.new(@item)
@dowi_window.visible=true
@dowi_window.active=true
$game_system.se_play($data_system.decision_se)
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (目标窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_target
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 由于物品用完而不能使用的场合
unless @actor.item_can_use?(@item.id)
# 再次生成物品窗口的内容
@item_window.refresh
end
# 删除目标窗口
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 如果物品用完的情况下
if @actor.item_number(@item.id) == 0
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 目标是全体的情况下
if @target_window.index == -1
# 对同伴全体应用物品使用效果
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# 目标是单体的情况下
if @target_window.index >= 0
# 对目标角色应用物品的使用效果
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# 使用物品的情况下
if used
# 演奏物品使用时的 SE
$game_system.se_play(@item.menu_se)
# 消耗品的情况下
if @item.consumable
# 使用的物品数减 1
@actor.lose_item(@item.id, 1)
# 再描绘物品窗口的项目
@item_window.draw_item(@item_window.index)
end
# 再生成目标窗口的内容
@target_window.refresh
# 全灭的情况下
if $game_party.all_dead?
# 切换到游戏结束画面
$scene = Scene_Gameover.new
return
end
# 公共事件 ID 有效的情况下
if @item.common_event_id > 0
# 预约调用公共事件
$game_temp.common_event_id = @item.common_event_id
# 切换到地图画面
$scene = Scene_Map.new
return
end
end
# 无法使用物品的情况下
unless used
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
class Scene_Battle
def start_item_select
# 生成物品窗口
@item_window = Window_IndiItem.new(@active_actor)
# 关联帮助窗口
@item_window.help_window = @help_window
# 无效化角色指令窗口
@actor_command_window.active = false
@actor_command_window.visible = false
end
#--------------------------------------------------------------------------
# ● 刷新画面 (角色命令回合 : 选择物品)
#--------------------------------------------------------------------------
def update_phase3_item_select
# 设置物品窗口为可视状态
@item_window.visible = true
# 刷新物品窗口
@item_window.update
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 选择物品结束
end_item_select
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品窗口现在选择的物品资料
@item = @item_window.item
# 无法使用的情况下
unless @active_actor.item_can_use?(@item.id)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 设置行动
@active_actor.current_action.item_id = @item.id
# 设置物品窗口为不可见状态
@item_window.visible = false
# 效果范围是敌单体的情况下
if @item.scope == 1
# 开始选择敌人
start_enemy_select
# 效果范围是我方单体的情况下
elsif @item.scope == 3 or @item.scope == 5
# 开始选择角色
start_actor_select
# 效果范围不是单体的情况下
else
# 物品选择结束
end_item_select
# 转到下一位角色的指令输入
phase3_next_actor
end
return
end
end
def make_item_action_result(battler)
# アイテムを取得
@item = $data_items[battler.current_action.item_id]
# アイテム切れなどで使用できなくなった場合
unless battler.item_can_use?(@item.id)
# ステップ 6 に移行
battler.phase = 6
return
end
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
battler.lose_item(@item.id, 1)
end
# アニメーション ID を設定
battler.anime1 = @item.animation1_id
battler.anime2 = @item.animation2_id
# コモンイベント ID を設定
battler.event = @item.common_event_id
# 対象を決定
index = battler.current_action.target_index
target = $game_party.smooth_target_actor(index)
# 対象側バトラーを設定
set_target_battlers(@item.scope, battler)
# アイテムの効果を適用
for target in battler.target
target.item_effect(@item, battler)
end
end
end
#==============================================================================
# ■ Window_IndiItem
#------------------------------------------------------------------------------
# 物品画面、战斗画面、显示浏览物品的窗口。
#==============================================================================
class Window_IndiItem < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize(actor)
@actor = actor
super(0, 64, 640, 288)
@column_max = 2
refresh
self.index = 0
# 战斗中的情况下将窗口移至中央并将其半透明化
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# 添加报务
for i in 1...$data_items.size
if @actor.item_number(i) > 0
@data.push($data_items[i])
end
end
# 在战斗中以外添加武器、防具
unless $game_temp.in_battle
for i in 1...$data_weapons.size
if @actor.weapon_number(i) > 0
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if @actor.armor_number(i) > 0
@data.push($data_armors[i])
end
end
end
# 如果项目数不是 0 就生成位图、重新描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = @actor.item_number(item.id)
when RPG::Weapon
number = @actor.weapon_number(item.id)
when RPG::Armor
number = @actor.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
@actor.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 192, 32, item.name, 0)
self.contents.draw_text(x + 224, y, 16, 32, ":", 1)
self.contents.draw_text(x + 240, y, 40, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
class Scene_IndiItem
alias ori_main main
def main
@weight_window = Window_Weight.new(@actor)
@weight_window.x = 0
@weight_window.y = 352
@weight_window.z = 0
ori_main
@weight_window.dispose
end
alias ori_update update
def update
case @item_window.item
when RPG::Item
@weight_window.refresh($data_items[@item_window.item.id].weight)
when RPG::Weapon
@weight_window.refresh($data_weapons[@item_window.item.id].weight)
when RPG::Armor
@weight_window.refresh($data_armors[@item_window.item.id].weight)
end
ori_update
end
end
class Window_Weight < Window_Base
def initialize(actor)
@actor=actor
super(0,0,640,128)
self.opacity = 255
self.contents = Bitmap.new(width-32,height-32)
refresh(nil)
end
def refresh(weight)
self.contents.clear
self.contents.draw_text(0,0,160,32,@actor.name)
if weight != nil
self.contents.draw_text(128,0,160,32,"单件重量:#{weight}")
end
self.contents.draw_text(320,0,320,32,"背包重量:"+@actor.total_weight.to_s + "/" + @actor.indi_capacity.to_s , 0)
ssstx=0
sssty=32
self.contents.draw_text(ssstx,sssty,160,32,"装备物品:")
ssstx=128
if @actor.weapon_id != 0
self.contents.draw_text(ssstx,sssty,160,32,$data_weapons[@actor.weapon_id].name + "(" + $data_weapons[@actor.weapon_id].weight.to_s + ")")
end
ssstx=288
if @actor.armor1_id != 0
self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor1_id].name + "(" + $data_armors[@actor.armor1_id].weight.to_s + ")")
end
ssstx=448
if @actor.armor2_id != 0
self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor2_id].name + "(" + $data_armors[@actor.armor2_id].weight.to_s + ")")
end
ssstx=128
sssty=64
if @actor.armor3_id != 0
self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor3_id].name + "(" + $data_armors[@actor.armor3_id].weight.to_s + ")")
end
ssstx=288
if @actor.armor4_id != 0
self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor4_id].name + "(" + $data_armors[@actor.armor4_id].weight.to_s + ")")
end
end
end
class Window_Dowi < Window_Selectable
def initialize(item = nil)
super(256, 240, 128, 160)
@item = item
self.opacity = 255
self.contents = Bitmap.new(width-32,height-32)
self.z=120
self.index=0
refresh
end
def refresh
self.contents.draw_text(4, 0, 192, 32, "使用", 0)
self.contents.draw_text(4, 32, 192, 32, "交给", 0)
self.contents.draw_text(4, 64, 192, 32, "丢弃", 0)
end
end
class Window_Give < Window_Selectable
def initialize(actor)
super(256, 240, 128, 160)
@actor = actor
@column_max = 1
self.active = false
self.index = -1
self.contents = Bitmap.new(width - 32, height - 32)
self.z=120
self.index=0
$指定人物=0
# 添加本人以外的角色
@data=[]
@data_target=[]
for iii in 0...$game_party.actors.size
if @actor != $game_party.actors[iii]
@data.push($game_party.actors[iii].name)
@data_target.push(iii)
end
end
@item_max=@data.size
$give_max=@item_max
refresh
end
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
$指定人物=@data_target[self.index]
end
#--------------------------------------------------------------------------
# ● 项目的描绘
# index : 项目符号
#--------------------------------------------------------------------------
def draw_item(index)
#print index
item = @data[index]
#print item
x = 4
y = index * 32
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 192, 32, item, 0)
end
def update
refresh
end
end
class Window_GiveNum < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize(actor, item)
super(160, 80, 320, 160)
self.contents = Bitmap.new(width - 32, height - 32)
@item = item
@number = 1
if item != nil
@max = actor.item_number(item.id)
else
@max = 0
end
self.z=120
refresh
end
def refresh
self.contents.clear
self.contents.font.color = normal_color
if @item != nil
if $正在丢弃物品 != 0
self.contents.draw_text(4, 0, 192, 32, "丢掉几件", 0)
self.contents.draw_text(200, 0, 192, 32, @number.to_s, 0)
self.contents.draw_text(4, 32, 192, 32, "减轻重量", 0)
self.contents.draw_text(200, 32, 192, 32, [@number * @item.weight].to_s, 0)
self.contents.draw_text(4, 96, 240, 32, "请按方向键增减数量", 0)
return
end
if $正在交付物品 != 1
self.contents.draw_text(4, 0, 192, 32, "要交给谁", 0)
else
self.contents.draw_text(4, 0, 192, 32, "交给几件", 0)
self.contents.draw_text(200, 0, 192, 32, @number.to_s, 0)
self.contents.draw_text(4, 32, 192, 32, "交换重量", 0)
self.contents.draw_text(200, 32, 192, 32, [@number * @item.weight].to_s, 0)
self.contents.draw_text(4, 64, 240, 32, "接收方剩余负荷", 0)
lastweight=$game_party.actors[$指定人物].indi_capacity-$game_party.actors[$指定人物].total_weight
self.contents.draw_text(200, 64, 192, 32, lastweight.to_s, 0)
end
self.contents.draw_text(4, 96, 240, 32, "请按方向键增减数量", 0)
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
if @item != nil
if self.active
# 光标右 (+10)
if Input.repeat?(Input::RIGHT) and @number < @max
$game_system.se_play($data_system.cursor_se)
@number = [@number + 10, @max].min
end
# 光标左 (-10)
if Input.repeat?(Input::LEFT) and @number > 1
$game_system.se_play($data_system.cursor_se)
@number = [@number - 10, 1].max
end
# 光标上 (-1)
if Input.repeat?(Input::UP) and @number > 1
$game_system.se_play($data_system.cursor_se)
@number -= 1
end
# 光标下 (+1)
if Input.repeat?(Input::DOWN) and @number < @max
$game_system.se_play($data_system.cursor_se)
@number += 1
end
end
end
$交付数量=@number
refresh
end
end
#==============================================================================
# ■ Window_EquipItem
#------------------------------------------------------------------------------
# 装备画面、显示浏览变更装备的候补物品的窗口。
#==============================================================================
class Window_EquipItem < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
# equip_type : 装备部位 (0~3)
#--------------------------------------------------------------------------
def initialize(actor, equip_type)
super(0, 256, 640, 224)
@actor = actor
@equip_type = equip_type
@column_max = 2
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# 添加可以装备的武器
if @equip_type == 0
weapon_set = $data_classes[@actor.class_id].weapon_set
for i in 1...$data_weapons.size
if @actor.weapon_number(i) > 0 and weapon_set.include?(i)
@data.push($data_weapons[i])
end
end
end
# 添加可以装备的防具
if @equip_type != 0
armor_set = $data_classes[@actor.class_id].armor_set
for i in 1...$data_armors.size
if @actor.armor_number(i) > 0 and armor_set.include?(i)
if $data_armors[i].kind == @equip_type-1
@data.push($data_armors[i])
end
end
end
end
# 添加空白
@data.push(nil)
# 生成位图、描绘全部项目
@item_max = @data.size
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max-1
draw_item(i)
end
end
#--------------------------------------------------------------------------
# ● 项目的描绘
# index : 项目符号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
case item
when RPG::Weapon
number = @actor.weapon_number(item.id)
when RPG::Armor
number = @actor.armor_number(item.id)
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
self.contents.draw_text(x + 28, y, 192, 32, item.name, 0)
self.contents.draw_text(x + 224, y, 16, 32, ":", 1)
self.contents.draw_text(x + 240, y, 40, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
class Game_Party
#--------------------------------------------------------------------------
# ● 增加物品 (减少)
# item_id : 物品 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_item(item_id, n)
# 更新 hash 的个数数据
if item_id > 0
wwwt = $data_items[item_id].weight
straight = 0 #从领队开始依次拿取物品,当领队载重量不够时转至下一个队员获取
for iii in 0...n #检查物品n次
leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
while leftwt < wwwt
straight += 1
if straight>=$game_party.actors.size
return
end
leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
end
$game_party.actors[straight].gain_item(item_id, 1)
end
end
end
#--------------------------------------------------------------------------
# ● 增加武器 (减少)
# weapon_id : 武器 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_weapon(weapon_id, n)
# 更新 hash 的个数数据
if item_id > 0
wwwt = $data_weapons[weapon_id].weight
straight = 0 #从领队开始依次拿取物品,当领队载重量不够时转至下一个队员获取
for iii in 0...n #检查物品n次
leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
while leftwt < wwwt
straight += 1
if straight>=$game_party.actors.size
return
end
leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
end
$game_party.actors[straight].gain_weapon(weapon_id, 1)
end
end
end
#--------------------------------------------------------------------------
# ● 增加防具 (减少)
# armor_id : 防具 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_armor(armor_id, n)
# 更新 hash 的个数数据
if item_id > 0
wwwt = $data_armors[armor_id].weight
straight = 0 #从领队开始依次拿取物品,当领队载重量不够时转至下一个队员获取
for iii in 0...n #检查物品n次
leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
while leftwt < wwwt
straight += 1
if straight>=$game_party.actors.size
return
end
leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
end
$game_party.actors[straight].gain_armor(armor_id, 1)
end
end
end
end
#单人负重系统 V 1.10 BY SLICK module RPG class Item attr_accessor :weight def name return @name.split(/,/)[0] end def weight rpgwt = @name.split(/,/)[1].to_i return rpgwt = nil ? 0 : rpgwt end def description return @description.split(/@/)[0] end def inc_weight rpgwt = @description.split(/@/)[1].to_i return rpgwt = nil ? 0 : rpgwt end end class Weapon attr_accessor :weight def name return @name.split(/,/)[0] end def weight rpgwt = @name.split(/,/)[1].to_i return rpgwt = nil ? 0 : rpgwt end end class Armor attr_accessor :weight def name return @name.split(/,/)[0] end def weight rpgwt = @name.split(/,/)[1].to_i return rpgwt = nil ? 0 : rpgwt end end end class Game_Actor < Game_Battler attr_accessor :weight # 单个人物目前所带负载 attr_accessor :indi_capacity attr_accessor :items attr_accessor :weapons attr_accessor :armors alias original_setup setup def setup(actor_id) original_setup(actor_id) @weight=0 @items = {} @weapons = {} @armors = {} case actor_id when 1 # SLICK @indi_capacity = 50000 when 2 # 玛塔赫 @indi_capacity = 18000 when 3 # 塞拉斯 @indi_capacity = 40000 when 4 # 特萝西 @indi_capacity = 14000 when 5 # 艾斯迪儿 @indi_capacity = 36000 when 6 # 菲力克斯 @indi_capacity = 25000 when 7 # 克萝莉亚 @indi_capacity = 14000 when 8 # 西露达 @indi_capacity = 10000 end end def total_weight totalwt = self.weight if self.weapon_id != 0 totalwt += $data_weapons[self.weapon_id].weight end if self.armor1_id != 0 totalwt += $data_armors[self.armor1_id].weight end if self.armor2_id != 0 totalwt += $data_armors[self.armor2_id].weight end if self.armor3_id != 0 totalwt += $data_armors[self.armor3_id].weight end if self.armor4_id != 0 totalwt += $data_armors[self.armor4_id].weight end return totalwt end def item_number(item_id) # 如果 hash 个数数值不存在就返回 0 return @items.include?(item_id) ? @items[item_id] : 0 end #-------------------------------------------------------------------------- # ● 获取武器所持数 # weapon_id : 武器 ID #-------------------------------------------------------------------------- def weapon_number(weapon_id) # 如果 hash 个数数值不存在就返回 0 return @weapons.include?(weapon_id) ? @weapons[weapon_id] : 0 end #-------------------------------------------------------------------------- # ● 获取防具所持数 # armor_id : 防具 ID #-------------------------------------------------------------------------- def armor_number(armor_id) # 如果 hash 个数数值不存在就返回 0 return @armors.include?(armor_id) ? @armors[armor_id] : 0 end #-------------------------------------------------------------------------- # ● 增加物品 (减少) # item_id : 物品 ID # n : 个数 #-------------------------------------------------------------------------- def gain_item(item_id, n) # 更新 hash 的个数数据 if item_id > 0 temp = @weight + $data_items[item_id].weight * n return if (n < 0 and @items[item_id] == nil) if temp > max_weight return end if temp < 0 a = @weight for i in 1..n.abs a -= $data_items[item_id].weight if a < 0 return else # 数量-1 @items[item_id] = [item_number(item_id) - i, 0].max # 负重-1 @weight -= $data_items[item_id].weight # p @weight end end # p @weight return end if @items[item_id] != nil b = @items[item_id] - n.abs if b < 0 and n < 0 c = @items[item_id] @items[item_id] = [item_number(item_id) + n, 0].max @weight -= $data_items[item_id].weight * c # p @weight return end end @items[item_id] = [item_number(item_id) + n, 0].max @weight = temp # p @weight end end #-------------------------------------------------------------------------- # ● 增加武器 (减少) # weapon_id : 武器 ID # n : 个数 #-------------------------------------------------------------------------- def gain_weapon(weapon_id, n) # 更新 hash 的个数数据 if weapon_id > 0 temp = @weight + $data_weapons[weapon_id].weight * n return if (n < 0 and @weapons[weapon_id] == nil) if temp > max_weight return end if temp < 0 a = @weight for i in 1..n.abs a -= $data_weapons[weapon_id].weight if a < 0 return else # 数量-1 @weapons[weapon_id] = [weapon_number(weapon_id) - i, 0].max # 负重-1 @weight -= $data_weapons[weapon_id].weight # p @weight end end # p @weight return end if @weapons[weapon_id] != nil b = @weapons[weapon_id] - n.abs if b < 0 and n < 0 c = @weapons[weapon_id] @weapons[weapon_id] = [weapon_number(weapon_id) + n, 0].max @weight -= $data_weapons[weapon_id].weight * c # p @weight return end end @weapons[weapon_id] = [weapon_number(weapon_id) + n, 0].max @weight = temp # p @weight end end #-------------------------------------------------------------------------- # ● 增加防具 (减少) # armor_id : 防具 ID # n : 个数 #-------------------------------------------------------------------------- def gain_armor(armor_id, n) # 更新 hash 的个数数据 if armor_id > 0 temp = @weight + $data_armors[armor_id].weight * n return if (n < 0 and @armors[armor_id] == nil) if temp > max_weight return end if temp < 0 a = @weight for i in 1..n.abs a -= $data_armors[armor_id].weight if a < 0 return else # 数量-1 @armors[armor_id] = [armor_number(armor_id) - i, 0].max # 负重-1 @weight -= $data_armors[armor_id].weight # p @weight end end # p @weight return end if @armors[armor_id] != nil b = @armors[armor_id] - n.abs if b < 0 and n < 0 c = @armors[armor_id] @armors[armor_id] = [armor_number(armor_id) + n, 0].max @weight -= $data_armors[armor_id].weight * c # p @weight return end end @armors[armor_id] = [armor_number(armor_id) + n, 0].max @weight = temp # p @weight end end def max_weight return @indi_capacity end def check_weight end #-------------------------------------------------------------------------- # ● 减少物品 # item_id : 物品 ID # n : 个数 #-------------------------------------------------------------------------- def lose_item(item_id, n) # 调用 gain_item 的数值逆转 gain_item(item_id, -n) end #-------------------------------------------------------------------------- # ● 减少武器 # weapon_id : 武器 ID # n : 个数 #-------------------------------------------------------------------------- def lose_weapon(weapon_id, n) # 调用 gain_weapon 的数值逆转 gain_weapon(weapon_id, -n) end #-------------------------------------------------------------------------- # ● 减少防具 # armor_id : 防具 ID # n : 个数 #-------------------------------------------------------------------------- def lose_armor(armor_id, n) # 调用 gain_armor 的数值逆转 gain_armor(armor_id, -n) end #-------------------------------------------------------------------------- # ● 判断物品可以使用 # item_id : 物品 ID #-------------------------------------------------------------------------- def item_can_use?(item_id) # 物品个数为 0 的情况 if item_number(item_id) == 0 # 不能使用 return false end # 获取可以使用的时候 occasion = $data_items[item_id].occasion # 战斗的情况 if $game_temp.in_battle # 可以使用时为 0 (平时) 或者是 1 (战斗时) 可以使用 return (occasion == 0 or occasion == 1) end # 可以使用时为 0 (平时) 或者是 2 (菜单时) 可以使用 return (occasion == 0 or occasion == 2) end #-------------------------------------------------------------------------- # ● 变更装备 # equip_type : 装备类型 # id : 武器 or 防具 ID (0 为解除装备) #-------------------------------------------------------------------------- def equip(equip_type, id) case equip_type when 0 # 武器 if id == 0 or self.weapon_number(id) > 0 self.gain_weapon(@weapon_id, 1) @weapon_id = id self.lose_weapon(id, 1) end when 1 # 盾 if id == 0 or self.armor_number(id) > 0 update_auto_state($data_armors[@armor1_id], $data_armors[id]) self.gain_armor(@armor1_id, 1) @armor1_id = id self.lose_armor(id, 1) end when 2 # 头 if id == 0 or self.armor_number(id) > 0 update_auto_state($data_armors[@armor2_id], $data_armors[id]) self.gain_armor(@armor2_id, 1) @armor2_id = id self.lose_armor(id, 1) end when 3 # 身体 if id == 0 or self.armor_number(id) > 0 update_auto_state($data_armors[@armor3_id], $data_armors[id]) self.gain_armor(@armor3_id, 1) @armor3_id = id self.lose_armor(id, 1) end when 4 # 装饰品 if id == 0 or self.armor_number(id) > 0 update_auto_state($data_armors[@armor4_id], $data_armors[id]) self.gain_armor(@armor4_id, 1) @armor4_id = id self.lose_armor(id, 1) end end end end #============================================================================== # ■ Scene_Menu #------------------------------------------------------------------------------ # 处理菜单画面的类。 #============================================================================== class Scene_Menu #-------------------------------------------------------------------------- # ● 初始化对像 # menu_index : 命令光标的初期位置 #-------------------------------------------------------------------------- def initialize(menu_index = 0) @menu_index = menu_index end #-------------------------------------------------------------------------- # ● 主处理 #-------------------------------------------------------------------------- def main # 生成命令窗口 s1 = "对话" s2 = "乘降" s3 = "强度" s4 = "工具" s5 = "装备" s6 = "炮弹" s7 = "调查" s8 = "系统" @command_window = Window_Menu.new(200, [s1, s2, s3, s4, s5, s6, s7, s8],2) @command_window.index = @menu_index # 同伴人数为 0 的情况下 if $game_party.actors.size == 0 # 物品、特技、装备、状态无效化 @command_window.disable_item(0) @command_window.disable_item(1) @command_window.disable_item(2) @command_window.disable_item(3) end # 生成金钱窗口 @gold_window = Window_Gold.new @gold_window.x = 485 # 生成状态窗口 @status_window = Window_MenuStatus.new @status_window.x = 193 @status_window.y = 315 # 生成地图名窗口 @mapname_window = Window_Mapname.new @mapname_window.x = 0 # 执行过渡 Graphics.transition # 主循环 loop do # 刷新游戏画面 Graphics.update # 刷新输入信息 Input.update # 刷新画面 update # 如果切换画面就中断循环 if $scene != self break end end # 准备过渡 Graphics.freeze # 准备过渡 Graphics.freeze # 释放窗口 @command_window.dispose @gold_window.dispose @status_window.dispose @mapname_window.dispose end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update # 刷新窗口 @command_window.update @status_window.update # 命令窗口被激活的情况下: 调用 update_command if @command_window.active update_command return end # 状态窗口被激活的情况下: 调用 update_status if @status_window.active update_status return end end #-------------------------------------------------------------------------- # ● 刷新画面 (命令窗口被激活的情况下) #-------------------------------------------------------------------------- def update_command # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 切换的地图画面 $scene = Scene_Map.new return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 同伴人数为 0、存档、游戏结束以外的场合 if $game_party.actors.size == 0 and @command_window.index < 4 # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 命令窗口的光标位置分支 case @command_window.index when 5 # 特技 # 演奏确定 SE $game_system.se_play($data_system.decision_se) $game_temp.message_text = "只有对话和调查" $scene = Scene_Map.new when 3 # 物品 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换到物品画面 @command_window.active = false @status_window.active = true @status_window.index = 0 when 4 # 装备 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 激活状态窗口 @command_window.active = false @status_window.active = true @status_window.index = 0 when 2 # 状态 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 激活状态窗口 $game_temp.message_text = "只有对话和调查" $scene = Scene_Map.new when 6 # 调查 $game_system.se_play($data_system.decision_se) $game_temp.check_judge = true $scene = Scene_Map.new when 7 # 系统 # 演奏确定 SE $game_system.se_play($data_system.decision_se) $game_temp.common_event_id = 4 $scene = Scene_Map.new when 0 # 对话 $game_system.se_play($data_system.decision_se) $game_temp.conversation_judge = true $scene = Scene_Map.new when 1 # 乘降 $game_system.se_play($data_system.decision_se) $game_temp.common_event_id = 6 $scene = Scene_Map.new end return end end #-------------------------------------------------------------------------- # ● 刷新画面 (状态窗口被激活的情况下) #-------------------------------------------------------------------------- def update_status # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 激活命令窗口 @command_window.active = true @status_window.active = false @status_window.index = -1 return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 命令窗口的光标位置分支 case @command_window.index when 5 # 特技 # 本角色的行动限制在 2 以上的情况下 if $game_party.actors[@status_window.index].restriction >= 2 # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换到特技画面 $scene = Scene_Skill.new(@status_window.index) when 4 # 装备 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换的装备画面 $scene = Scene_Equip.new(@status_window.index) when 2 # 状态 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换到状态画面 $scene = Scene_Status.new(@status_window.index) end return end end end #============================================================================== # ■ Scene_IndiItem #------------------------------------------------------------------------------ # 处理单人物品画面的类。 #============================================================================== class Scene_IndiItem #-------------------------------------------------------------------------- # ● 初始化对像 # actor_index : 角色索引 # equip_index : 装备索引 #-------------------------------------------------------------------------- def initialize(actor_index) @actor_index = actor_index @actor = $game_party.actors[@actor_index] $正在丢弃物品 = 0 $正在交付物品 = 0 $指定人物=0 $交付数量=0 end #-------------------------------------------------------------------------- # ● 主处理 #-------------------------------------------------------------------------- def main # 生成帮助窗口、物品窗口 @help_window = Window_Help.new @item_window = Window_IndiItem.new(@actor) # 关联帮助窗口 @item_window.help_window = @help_window # 生成目标窗口 (设置为不可见・不活动) @target_window = Window_Target.new @target_window.visible = false @target_window.active = false @num_window = Window_GiveNum.new(@actor, nil) @num_window.visible=false @num_window.active=false @give_window = Window_Give.new(@actor) @give_window.visible=false @give_window.active=false @dowi_window = Window_Dowi.new @dowi_window.visible=false @dowi_window.active=false # 执行过度 Graphics.transition # 主循环 loop do # 刷新游戏画面 Graphics.update # 刷新输入信息 Input.update # 刷新画面 update # 如果画面切换就中断循环 if $scene != self break end end # 装备过渡 Graphics.freeze # 释放窗口 @help_window.dispose @item_window.dispose @target_window.dispose @num_window.dispose @give_window.dispose @dowi_window.dispose end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update # 刷新窗口 @help_window.update @item_window.update @target_window.update # 物品窗口被激活的情况下: 调用 update_item if @item_window.active update_item return end # 目标窗口被激活的情况下: 调用 update_target if @target_window.active update_target return end if @num_window.active update_num return end if @give_window.active update_give return end if @dowi_window.active update_dowi return end end def update_num if Input.trigger?(Input::B) @num_window.active=false @num_window.visible=false @give_window.active=false @give_window.visible=false @item_window.active=true $game_system.se_play($data_system.cancel_se) return end if Input.trigger?(Input::C) @item = @item_window.item wwwt = @item.weight * $交付数量 if @dowi_window.index == 1 if wwwt > ($game_party.actors[$指定人物].indi_capacity-$game_party.actors[$指定人物].total_weight) $game_system.se_play($data_system.buzzer_se) return end case @item when RPG::Item $game_party.actors[$指定人物].gain_item(@item.id,$交付数量) when RPG::Weapon $game_party.actors[$指定人物].gain_weapon(@item.id,$交付数量) when RPG::Armor $game_party.actors[$指定人物].gain_armor(@item.id,$交付数量) end end case @item when RPG::Item @actor.lose_item(@item.id,$交付数量) when RPG::Weapon @actor.lose_weapon(@item.id,$交付数量) when RPG::Armor @actor.lose_armor(@item.id,$交付数量) end @num_window.active=false @num_window.visible=false @give_window.active=false @give_window.visible=false @item_window.active=true $game_system.se_play($data_system.decision_se) @item_window.refresh @weight_window.refresh(@item.weight) return end @num_window.update end def update_give if Input.trigger?(Input::B) @give_window.active=false @give_window.visible=false @item_window.active=true $game_system.se_play($data_system.cancel_se) return end if Input.trigger?(Input::C) @item = @item_window.item @give_window.active=false @num_window.dispose @num_window = Window_GiveNum.new(@actor, @item) @num_window.active=true @num_window.visible=true $game_system.se_play($data_system.decision_se) return end if Input.trigger?(Input::DOWN) @give_window.index+=1 if @give_window.index>=$give_max @give_window.index=0 end $game_system.se_play($data_system.cursor_se) return end if Input.trigger?(Input::UP) @give_window.index-=1 if @give_window.index<0 @give_window.index+=$give_max end $game_system.se_play($data_system.cursor_se) return end @give_window.update end def update_dowi if Input.trigger?(Input::B) @dowi_window.active=false @dowi_window.visible=false @item_window.active=true $game_system.se_play($data_system.cancel_se) return end if Input.trigger?(Input::C) @item = @item_window.item if @dowi_window.index == 0 #============================================================================== # 不使用物品的情况下 unless @item.is_a?(RPG::Item) # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 不能使用的情况下 unless @actor.item_can_use?(@item.id) # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 效果范围是我方的情况下 if @item.scope >= 3 # 激活目标窗口 @dowi_window.active=false @dowi_window.visible=false @target_window.x = (@item_window.index + 1) % 2 * 304 @target_window.visible = true @target_window.active = true # 设置效果范围 (单体/全体) 的对应光标位置 if @item.scope == 4 || @item.scope == 6 @target_window.index = -1 else @target_window.index = 0 end # 效果在我方以外的情况下 else # 公共事件 ID 有效的情况下 if @item.common_event_id > 0 # 预约调用公共事件 $game_temp.common_event_id = @item.common_event_id # 演奏物品使用时的 SE $game_system.se_play(@item.menu_se) # 消耗品的情况下 if @item.consumable # 使用的物品数减 1 @actor.lose_item(@item.id, 1) # 再描绘物品窗口的项目 @item_window.draw_item(@item_window.index) end # 切换到地图画面 $scene = Scene_Map.new return end return end #============================================================================== else if @dowi_window.index==1 if $game_party.actors.size<2 $game_system.se_play($data_system.buzzer_se) return end $正在交付物品=1 $正在丢弃物品=0 @dowi_window.active=false @dowi_window.visible=false @give_window.dispose @give_window=Window_Give.new(@actor) @give_window.active=true @give_window.visible=true else $正在交付物品=0 $正在丢弃物品=1 @dowi_window.active=false @dowi_window.visible=false @item = @item_window.item @num_window.dispose @num_window = Window_GiveNum.new(@actor, @item) @num_window.active=true @num_window.visible=true end $game_system.se_play($data_system.decision_se) return end end if Input.trigger?(Input::DOWN) @dowi_window.index+=1 if @dowi_window.index>2 @dowi_window.index=0 end $game_system.se_play($data_system.cursor_se) return end if Input.trigger?(Input::UP) @dowi_window.index-=1 if @dowi_window.index<0 @dowi_window.index=2 end $game_system.se_play($data_system.cursor_se) return end @dowi_window.update end #-------------------------------------------------------------------------- # ● 刷新画面 (物品窗口被激活的情况下) #-------------------------------------------------------------------------- def update_item # 按下 R 键的情况下 if Input.trigger?(Input::R) # 演奏光标 SE $game_system.se_play($data_system.cursor_se) # 移至下一位角色 @actor_index += 1 @actor_index %= $game_party.actors.size # 切换到别的装备画面 $scene = Scene_IndiItem.new(@actor_index) return end # 按下 L 键的情况下 if Input.trigger?(Input::L) # 演奏光标 SE $game_system.se_play($data_system.cursor_se) # 移至上一位角色 @actor_index += $game_party.actors.size - 1 @actor_index %= $game_party.actors.size # 切换到别的装备画面 $scene = Scene_IndiItem.new(@actor_index) return end # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 切换到菜单画面 $scene = Scene_Menu.new(0) return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 获取物品窗口当前选中的物品数据 @item = @item_window.item @item_window.active=false @dowi_window.dispose @dowi_window=Window_Dowi.new(@item) @dowi_window.visible=true @dowi_window.active=true $game_system.se_play($data_system.decision_se) return end end #-------------------------------------------------------------------------- # ● 刷新画面 (目标窗口被激活的情况下) #-------------------------------------------------------------------------- def update_target # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 由于物品用完而不能使用的场合 unless @actor.item_can_use?(@item.id) # 再次生成物品窗口的内容 @item_window.refresh end # 删除目标窗口 @item_window.active = true @target_window.visible = false @target_window.active = false return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 如果物品用完的情况下 if @actor.item_number(@item.id) == 0 # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 目标是全体的情况下 if @target_window.index == -1 # 对同伴全体应用物品使用效果 used = false for i in $game_party.actors used |= i.item_effect(@item) end end # 目标是单体的情况下 if @target_window.index >= 0 # 对目标角色应用物品的使用效果 target = $game_party.actors[@target_window.index] used = target.item_effect(@item) end # 使用物品的情况下 if used # 演奏物品使用时的 SE $game_system.se_play(@item.menu_se) # 消耗品的情况下 if @item.consumable # 使用的物品数减 1 @actor.lose_item(@item.id, 1) # 再描绘物品窗口的项目 @item_window.draw_item(@item_window.index) end # 再生成目标窗口的内容 @target_window.refresh # 全灭的情况下 if $game_party.all_dead? # 切换到游戏结束画面 $scene = Scene_Gameover.new return end # 公共事件 ID 有效的情况下 if @item.common_event_id > 0 # 预约调用公共事件 $game_temp.common_event_id = @item.common_event_id # 切换到地图画面 $scene = Scene_Map.new return end end # 无法使用物品的情况下 unless used # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) end return end end end class Scene_Battle def start_item_select # 生成物品窗口 @item_window = Window_IndiItem.new(@active_actor) # 关联帮助窗口 @item_window.help_window = @help_window # 无效化角色指令窗口 @actor_command_window.active = false @actor_command_window.visible = false end #-------------------------------------------------------------------------- # ● 刷新画面 (角色命令回合 : 选择物品) #-------------------------------------------------------------------------- def update_phase3_item_select # 设置物品窗口为可视状态 @item_window.visible = true # 刷新物品窗口 @item_window.update # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 选择物品结束 end_item_select return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 获取物品窗口现在选择的物品资料 @item = @item_window.item # 无法使用的情况下 unless @active_actor.item_can_use?(@item.id) # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 设置行动 @active_actor.current_action.item_id = @item.id # 设置物品窗口为不可见状态 @item_window.visible = false # 效果范围是敌单体的情况下 if @item.scope == 1 # 开始选择敌人 start_enemy_select # 效果范围是我方单体的情况下 elsif @item.scope == 3 or @item.scope == 5 # 开始选择角色 start_actor_select # 效果范围不是单体的情况下 else # 物品选择结束 end_item_select # 转到下一位角色的指令输入 phase3_next_actor end return end end def make_item_action_result(battler) # アイテムを取得 @item = $data_items[battler.current_action.item_id] # アイテム切れなどで使用できなくなった場合 unless battler.item_can_use?(@item.id) # ステップ 6 に移行 battler.phase = 6 return end # 消耗品の場合 if @item.consumable # 使用したアイテムを 1 減らす battler.lose_item(@item.id, 1) end # アニメーション ID を設定 battler.anime1 = @item.animation1_id battler.anime2 = @item.animation2_id # コモンイベント ID を設定 battler.event = @item.common_event_id # 対象を決定 index = battler.current_action.target_index target = $game_party.smooth_target_actor(index) # 対象側バトラーを設定 set_target_battlers(@item.scope, battler) # アイテムの効果を適用 for target in battler.target target.item_effect(@item, battler) end end end #============================================================================== # ■ Window_IndiItem #------------------------------------------------------------------------------ # 物品画面、战斗画面、显示浏览物品的窗口。 #============================================================================== class Window_IndiItem < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize(actor) @actor = actor super(0, 64, 640, 288) @column_max = 2 refresh self.index = 0 # 战斗中的情况下将窗口移至中央并将其半透明化 if $game_temp.in_battle self.y = 64 self.height = 256 self.back_opacity = 160 end end #-------------------------------------------------------------------------- # ● 获取物品 #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] # 添加报务 for i in 1...$data_items.size if @actor.item_number(i) > 0 @data.push($data_items[i]) end end # 在战斗中以外添加武器、防具 unless $game_temp.in_battle for i in 1...$data_weapons.size if @actor.weapon_number(i) > 0 @data.push($data_weapons[i]) end end for i in 1...$data_armors.size if @actor.armor_number(i) > 0 @data.push($data_armors[i]) end end end # 如果项目数不是 0 就生成位图、重新描绘全部项目 @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # ● 描绘项目 # index : 项目编号 #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] case item when RPG::Item number = @actor.item_number(item.id) when RPG::Weapon number = @actor.weapon_number(item.id) when RPG::Armor number = @actor.armor_number(item.id) end if item.is_a?(RPG::Item) and @actor.item_can_use?(item.id) self.contents.font.color = normal_color else self.contents.font.color = disabled_color end x = 4 + index % 2 * (288 + 32) y = index / 2 * 32 rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 192, 32, item.name, 0) self.contents.draw_text(x + 224, y, 16, 32, ":", 1) self.contents.draw_text(x + 240, y, 40, 32, number.to_s, 2) end #-------------------------------------------------------------------------- # ● 刷新帮助文本 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.item == nil ? "" : self.item.description) end end class Scene_IndiItem alias ori_main main def main @weight_window = Window_Weight.new(@actor) @weight_window.x = 0 @weight_window.y = 352 @weight_window.z = 0 ori_main @weight_window.dispose end alias ori_update update def update case @item_window.item when RPG::Item @weight_window.refresh($data_items[@item_window.item.id].weight) when RPG::Weapon @weight_window.refresh($data_weapons[@item_window.item.id].weight) when RPG::Armor @weight_window.refresh($data_armors[@item_window.item.id].weight) end ori_update end end class Window_Weight < Window_Base def initialize(actor) @actor=actor super(0,0,640,128) self.opacity = 255 self.contents = Bitmap.new(width-32,height-32) refresh(nil) end def refresh(weight) self.contents.clear self.contents.draw_text(0,0,160,32,@actor.name) if weight != nil self.contents.draw_text(128,0,160,32,"单件重量:#{weight}") end self.contents.draw_text(320,0,320,32,"背包重量:"+@actor.total_weight.to_s + "/" + @actor.indi_capacity.to_s , 0) ssstx=0 sssty=32 self.contents.draw_text(ssstx,sssty,160,32,"装备物品:") ssstx=128 if @actor.weapon_id != 0 self.contents.draw_text(ssstx,sssty,160,32,$data_weapons[@actor.weapon_id].name + "(" + $data_weapons[@actor.weapon_id].weight.to_s + ")") end ssstx=288 if @actor.armor1_id != 0 self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor1_id].name + "(" + $data_armors[@actor.armor1_id].weight.to_s + ")") end ssstx=448 if @actor.armor2_id != 0 self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor2_id].name + "(" + $data_armors[@actor.armor2_id].weight.to_s + ")") end ssstx=128 sssty=64 if @actor.armor3_id != 0 self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor3_id].name + "(" + $data_armors[@actor.armor3_id].weight.to_s + ")") end ssstx=288 if @actor.armor4_id != 0 self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor4_id].name + "(" + $data_armors[@actor.armor4_id].weight.to_s + ")") end end end class Window_Dowi < Window_Selectable def initialize(item = nil) super(256, 240, 128, 160) @item = item self.opacity = 255 self.contents = Bitmap.new(width-32,height-32) self.z=120 self.index=0 refresh end def refresh self.contents.draw_text(4, 0, 192, 32, "使用", 0) self.contents.draw_text(4, 32, 192, 32, "交给", 0) self.contents.draw_text(4, 64, 192, 32, "丢弃", 0) end end class Window_Give < Window_Selectable def initialize(actor) super(256, 240, 128, 160) @actor = actor @column_max = 1 self.active = false self.index = -1 self.contents = Bitmap.new(width - 32, height - 32) self.z=120 self.index=0 $指定人物=0 # 添加本人以外的角色 @data=[] @data_target=[] for iii in 0...$game_party.actors.size if @actor != $game_party.actors[iii] @data.push($game_party.actors[iii].name) @data_target.push(iii) end end @item_max=@data.size $give_max=@item_max refresh end def refresh self.contents.clear for i in 0...@item_max draw_item(i) end $指定人物=@data_target[self.index] end #-------------------------------------------------------------------------- # ● 项目的描绘 # index : 项目符号 #-------------------------------------------------------------------------- def draw_item(index) #print index item = @data[index] #print item x = 4 y = index * 32 self.contents.font.color = normal_color self.contents.draw_text(x, y, 192, 32, item, 0) end def update refresh end end class Window_GiveNum < Window_Base #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize(actor, item) super(160, 80, 320, 160) self.contents = Bitmap.new(width - 32, height - 32) @item = item @number = 1 if item != nil @max = actor.item_number(item.id) else @max = 0 end self.z=120 refresh end def refresh self.contents.clear self.contents.font.color = normal_color if @item != nil if $正在丢弃物品 != 0 self.contents.draw_text(4, 0, 192, 32, "丢掉几件", 0) self.contents.draw_text(200, 0, 192, 32, @number.to_s, 0) self.contents.draw_text(4, 32, 192, 32, "减轻重量", 0) self.contents.draw_text(200, 32, 192, 32, [@number * @item.weight].to_s, 0) self.contents.draw_text(4, 96, 240, 32, "请按方向键增减数量", 0) return end if $正在交付物品 != 1 self.contents.draw_text(4, 0, 192, 32, "要交给谁", 0) else self.contents.draw_text(4, 0, 192, 32, "交给几件", 0) self.contents.draw_text(200, 0, 192, 32, @number.to_s, 0) self.contents.draw_text(4, 32, 192, 32, "交换重量", 0) self.contents.draw_text(200, 32, 192, 32, [@number * @item.weight].to_s, 0) self.contents.draw_text(4, 64, 240, 32, "接收方剩余负荷", 0) lastweight=$game_party.actors[$指定人物].indi_capacity-$game_party.actors[$指定人物].total_weight self.contents.draw_text(200, 64, 192, 32, lastweight.to_s, 0) end self.contents.draw_text(4, 96, 240, 32, "请按方向键增减数量", 0) end end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update super if @item != nil if self.active # 光标右 (+10) if Input.repeat?(Input::RIGHT) and @number < @max $game_system.se_play($data_system.cursor_se) @number = [@number + 10, @max].min end # 光标左 (-10) if Input.repeat?(Input::LEFT) and @number > 1 $game_system.se_play($data_system.cursor_se) @number = [@number - 10, 1].max end # 光标上 (-1) if Input.repeat?(Input::UP) and @number > 1 $game_system.se_play($data_system.cursor_se) @number -= 1 end # 光标下 (+1) if Input.repeat?(Input::DOWN) and @number < @max $game_system.se_play($data_system.cursor_se) @number += 1 end end end $交付数量=@number refresh end end #============================================================================== # ■ Window_EquipItem #------------------------------------------------------------------------------ # 装备画面、显示浏览变更装备的候补物品的窗口。 #============================================================================== class Window_EquipItem < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 # actor : 角色 # equip_type : 装备部位 (0~3) #-------------------------------------------------------------------------- def initialize(actor, equip_type) super(0, 256, 640, 224) @actor = actor @equip_type = equip_type @column_max = 2 refresh self.active = false self.index = -1 end #-------------------------------------------------------------------------- # ● 获取物品 #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] # 添加可以装备的武器 if @equip_type == 0 weapon_set = $data_classes[@actor.class_id].weapon_set for i in 1...$data_weapons.size if @actor.weapon_number(i) > 0 and weapon_set.include?(i) @data.push($data_weapons[i]) end end end # 添加可以装备的防具 if @equip_type != 0 armor_set = $data_classes[@actor.class_id].armor_set for i in 1...$data_armors.size if @actor.armor_number(i) > 0 and armor_set.include?(i) if $data_armors[i].kind == @equip_type-1 @data.push($data_armors[i]) end end end end # 添加空白 @data.push(nil) # 生成位图、描绘全部项目 @item_max = @data.size self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max-1 draw_item(i) end end #-------------------------------------------------------------------------- # ● 项目的描绘 # index : 项目符号 #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] x = 4 + index % 2 * (288 + 32) y = index / 2 * 32 case item when RPG::Weapon number = @actor.weapon_number(item.id) when RPG::Armor number = @actor.armor_number(item.id) end bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) self.contents.font.color = normal_color self.contents.draw_text(x + 28, y, 192, 32, item.name, 0) self.contents.draw_text(x + 224, y, 16, 32, ":", 1) self.contents.draw_text(x + 240, y, 40, 32, number.to_s, 2) end #-------------------------------------------------------------------------- # ● 刷新帮助文本 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.item == nil ? "" : self.item.description) end end class Game_Party #-------------------------------------------------------------------------- # ● 增加物品 (减少) # item_id : 物品 ID # n : 个数 #-------------------------------------------------------------------------- def gain_item(item_id, n) # 更新 hash 的个数数据 if item_id > 0 wwwt = $data_items[item_id].weight straight = 0 #从领队开始依次拿取物品,当领队载重量不够时转至下一个队员获取 for iii in 0...n #检查物品n次 leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight while leftwt < wwwt straight += 1 if straight>=$game_party.actors.size return end leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight end $game_party.actors[straight].gain_item(item_id, 1) end end end #-------------------------------------------------------------------------- # ● 增加武器 (减少) # weapon_id : 武器 ID # n : 个数 #-------------------------------------------------------------------------- def gain_weapon(weapon_id, n) # 更新 hash 的个数数据 if item_id > 0 wwwt = $data_weapons[weapon_id].weight straight = 0 #从领队开始依次拿取物品,当领队载重量不够时转至下一个队员获取 for iii in 0...n #检查物品n次 leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight while leftwt < wwwt straight += 1 if straight>=$game_party.actors.size return end leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight end $game_party.actors[straight].gain_weapon(weapon_id, 1) end end end #-------------------------------------------------------------------------- # ● 增加防具 (减少) # armor_id : 防具 ID # n : 个数 #-------------------------------------------------------------------------- def gain_armor(armor_id, n) # 更新 hash 的个数数据 if item_id > 0 wwwt = $data_armors[armor_id].weight straight = 0 #从领队开始依次拿取物品,当领队载重量不够时转至下一个队员获取 for iii in 0...n #检查物品n次 leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight while leftwt < wwwt straight += 1 if straight>=$game_party.actors.size return end leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight end $game_party.actors[straight].gain_armor(armor_id, 1) end end end end
#单人负重系统 V 1.10 BY SLICK
module RPG
class Item
attr_accessor :weight
def name
return @name.split(/,/)[0]
end
def weight
rpgwt = @name.split(/,/)[1].to_i
return rpgwt = nil ? 0 : rpgwt
end
def description
return @description.split(/@/)[0]
end
def inc_weight
rpgwt = @description.split(/@/)[1].to_i
return rpgwt = nil ? 0 : rpgwt
end
end
class Weapon
attr_accessor :weight
def name
return @name.split(/,/)[0]
end
def weight
rpgwt = @name.split(/,/)[1].to_i
return rpgwt = nil ? 0 : rpgwt
end
end
class Armor
attr_accessor :weight
def name
return @name.split(/,/)[0]
end
def weight
rpgwt = @name.split(/,/)[1].to_i
return rpgwt = nil ? 0 : rpgwt
end
end
end
class Game_Actor < Game_Battler
attr_accessor :weight # 单个人物目前所带负载
attr_accessor :indi_capacity
attr_accessor :items
attr_accessor :weapons
attr_accessor :armors
alias original_setup setup
def setup(actor_id)
original_setup(actor_id)
@weight=0
@items = {}
@weapons = {}
@armors = {}
case actor_id
when 1 # SLICK
@indi_capacity = 50000
when 2 # 玛塔赫
@indi_capacity = 18000
when 3 # 塞拉斯
@indi_capacity = 40000
when 4 # 特萝西
@indi_capacity = 14000
when 5 # 艾斯迪儿
@indi_capacity = 36000
when 6 # 菲力克斯
@indi_capacity = 25000
when 7 # 克萝莉亚
@indi_capacity = 14000
when 8 # 西露达
@indi_capacity = 10000
end
end
def total_weight
totalwt = self.weight
if self.weapon_id != 0
totalwt += $data_weapons[self.weapon_id].weight
end
if self.armor1_id != 0
totalwt += $data_armors[self.armor1_id].weight
end
if self.armor2_id != 0
totalwt += $data_armors[self.armor2_id].weight
end
if self.armor3_id != 0
totalwt += $data_armors[self.armor3_id].weight
end
if self.armor4_id != 0
totalwt += $data_armors[self.armor4_id].weight
end
return totalwt
end
def item_number(item_id)
# 如果 hash 个数数值不存在就返回 0
return @items.include?(item_id) ? @items[item_id] : 0
end
#--------------------------------------------------------------------------
# ● 获取武器所持数
# weapon_id : 武器 ID
#--------------------------------------------------------------------------
def weapon_number(weapon_id)
# 如果 hash 个数数值不存在就返回 0
return @weapons.include?(weapon_id) ? @weapons[weapon_id] : 0
end
#--------------------------------------------------------------------------
# ● 获取防具所持数
# armor_id : 防具 ID
#--------------------------------------------------------------------------
def armor_number(armor_id)
# 如果 hash 个数数值不存在就返回 0
return @armors.include?(armor_id) ? @armors[armor_id] : 0
end
#--------------------------------------------------------------------------
# ● 增加物品 (减少)
# item_id : 物品 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_item(item_id, n)
# 更新 hash 的个数数据
if item_id > 0
temp = @weight + $data_items[item_id].weight * n
return if (n < 0 and @items[item_id] == nil)
if temp > max_weight
return
end
if temp < 0
a = @weight
for i in 1..n.abs
a -= $data_items[item_id].weight
if a < 0
return
else
# 数量-1
@items[item_id] = [item_number(item_id) - i, 0].max
# 负重-1
@weight -= $data_items[item_id].weight
# p @weight
end
end
# p @weight
return
end
if @items[item_id] != nil
b = @items[item_id] - n.abs
if b < 0 and n < 0
c = @items[item_id]
@items[item_id] = [item_number(item_id) + n, 0].max
@weight -= $data_items[item_id].weight * c
# p @weight
return
end
end
@items[item_id] = [item_number(item_id) + n, 0].max
@weight = temp
# p @weight
end
end
#--------------------------------------------------------------------------
# ● 增加武器 (减少)
# weapon_id : 武器 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_weapon(weapon_id, n)
# 更新 hash 的个数数据
if weapon_id > 0
temp = @weight + $data_weapons[weapon_id].weight * n
return if (n < 0 and @weapons[weapon_id] == nil)
if temp > max_weight
return
end
if temp < 0
a = @weight
for i in 1..n.abs
a -= $data_weapons[weapon_id].weight
if a < 0
return
else
# 数量-1
@weapons[weapon_id] = [weapon_number(weapon_id) - i, 0].max
# 负重-1
@weight -= $data_weapons[weapon_id].weight
# p @weight
end
end
# p @weight
return
end
if @weapons[weapon_id] != nil
b = @weapons[weapon_id] - n.abs
if b < 0 and n < 0
c = @weapons[weapon_id]
@weapons[weapon_id] = [weapon_number(weapon_id) + n, 0].max
@weight -= $data_weapons[weapon_id].weight * c
# p @weight
return
end
end
@weapons[weapon_id] = [weapon_number(weapon_id) + n, 0].max
@weight = temp
# p @weight
end
end
#--------------------------------------------------------------------------
# ● 增加防具 (减少)
# armor_id : 防具 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_armor(armor_id, n)
# 更新 hash 的个数数据
if armor_id > 0
temp = @weight + $data_armors[armor_id].weight * n
return if (n < 0 and @armors[armor_id] == nil)
if temp > max_weight
return
end
if temp < 0
a = @weight
for i in 1..n.abs
a -= $data_armors[armor_id].weight
if a < 0
return
else
# 数量-1
@armors[armor_id] = [armor_number(armor_id) - i, 0].max
# 负重-1
@weight -= $data_armors[armor_id].weight
# p @weight
end
end
# p @weight
return
end
if @armors[armor_id] != nil
b = @armors[armor_id] - n.abs
if b < 0 and n < 0
c = @armors[armor_id]
@armors[armor_id] = [armor_number(armor_id) + n, 0].max
@weight -= $data_armors[armor_id].weight * c
# p @weight
return
end
end
@armors[armor_id] = [armor_number(armor_id) + n, 0].max
@weight = temp
# p @weight
end
end
def max_weight
return @indi_capacity
end
def check_weight
end
#--------------------------------------------------------------------------
# ● 减少物品
# item_id : 物品 ID
# n : 个数
#--------------------------------------------------------------------------
def lose_item(item_id, n)
# 调用 gain_item 的数值逆转
gain_item(item_id, -n)
end
#--------------------------------------------------------------------------
# ● 减少武器
# weapon_id : 武器 ID
# n : 个数
#--------------------------------------------------------------------------
def lose_weapon(weapon_id, n)
# 调用 gain_weapon 的数值逆转
gain_weapon(weapon_id, -n)
end
#--------------------------------------------------------------------------
# ● 减少防具
# armor_id : 防具 ID
# n : 个数
#--------------------------------------------------------------------------
def lose_armor(armor_id, n)
# 调用 gain_armor 的数值逆转
gain_armor(armor_id, -n)
end
#--------------------------------------------------------------------------
# ● 判断物品可以使用
# item_id : 物品 ID
#--------------------------------------------------------------------------
def item_can_use?(item_id)
# 物品个数为 0 的情况
if item_number(item_id) == 0
# 不能使用
return false
end
# 获取可以使用的时候
occasion = $data_items[item_id].occasion
# 战斗的情况
if $game_temp.in_battle
# 可以使用时为 0 (平时) 或者是 1 (战斗时) 可以使用
return (occasion == 0 or occasion == 1)
end
# 可以使用时为 0 (平时) 或者是 2 (菜单时) 可以使用
return (occasion == 0 or occasion == 2)
end
#--------------------------------------------------------------------------
# ● 变更装备
# equip_type : 装备类型
# id : 武器 or 防具 ID (0 为解除装备)
#--------------------------------------------------------------------------
def equip(equip_type, id)
case equip_type
when 0 # 武器
if id == 0 or self.weapon_number(id) > 0
self.gain_weapon(@weapon_id, 1)
@weapon_id = id
self.lose_weapon(id, 1)
end
when 1 # 盾
if id == 0 or self.armor_number(id) > 0
update_auto_state($data_armors[@armor1_id], $data_armors[id])
self.gain_armor(@armor1_id, 1)
@armor1_id = id
self.lose_armor(id, 1)
end
when 2 # 头
if id == 0 or self.armor_number(id) > 0
update_auto_state($data_armors[@armor2_id], $data_armors[id])
self.gain_armor(@armor2_id, 1)
@armor2_id = id
self.lose_armor(id, 1)
end
when 3 # 身体
if id == 0 or self.armor_number(id) > 0
update_auto_state($data_armors[@armor3_id], $data_armors[id])
self.gain_armor(@armor3_id, 1)
@armor3_id = id
self.lose_armor(id, 1)
end
when 4 # 装饰品
if id == 0 or self.armor_number(id) > 0
update_auto_state($data_armors[@armor4_id], $data_armors[id])
self.gain_armor(@armor4_id, 1)
@armor4_id = id
self.lose_armor(id, 1)
end
end
end
end
#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
# 处理菜单画面的类。
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# ● 初始化对像
# menu_index : 命令光标的初期位置
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成命令窗口
s1 = "对话"
s2 = "乘降"
s3 = "强度"
s4 = "工具"
s5 = "装备"
s6 = "炮弹"
s7 = "调查"
s8 = "系统"
@command_window = Window_Menu.new(200, [s1, s2, s3, s4, s5, s6, s7, s8],2)
@command_window.index = @menu_index
# 同伴人数为 0 的情况下
if $game_party.actors.size == 0
# 物品、特技、装备、状态无效化
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# 生成金钱窗口
@gold_window = Window_Gold.new
@gold_window.x = 485
# 生成状态窗口
@status_window = Window_MenuStatus.new
@status_window.x = 193
@status_window.y = 315
# 生成地图名窗口
@mapname_window = Window_Mapname.new
@mapname_window.x = 0
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果切换画面就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 准备过渡
Graphics.freeze
# 释放窗口
@command_window.dispose
@gold_window.dispose
@status_window.dispose
@mapname_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@command_window.update
@status_window.update
# 命令窗口被激活的情况下: 调用 update_command
if @command_window.active
update_command
return
end
# 状态窗口被激活的情况下: 调用 update_status
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (命令窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_command
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换的地图画面
$scene = Scene_Map.new
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 同伴人数为 0、存档、游戏结束以外的场合
if $game_party.actors.size == 0 and @command_window.index < 4
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 命令窗口的光标位置分支
case @command_window.index
when 5 # 特技
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
$game_temp.message_text = "只有对话和调查"
$scene = Scene_Map.new
when 3 # 物品
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到物品画面
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # 装备
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # 状态
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
$game_temp.message_text = "只有对话和调查"
$scene = Scene_Map.new
when 6 # 调查
$game_system.se_play($data_system.decision_se)
$game_temp.check_judge = true
$scene = Scene_Map.new
when 7 # 系统
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
$game_temp.common_event_id = 4
$scene = Scene_Map.new
when 0 # 对话
$game_system.se_play($data_system.decision_se)
$game_temp.conversation_judge = true
$scene = Scene_Map.new
when 1 # 乘降
$game_system.se_play($data_system.decision_se)
$game_temp.common_event_id = 6
$scene = Scene_Map.new
end
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (状态窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_status
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 激活命令窗口
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 命令窗口的光标位置分支
case @command_window.index
when 5 # 特技
# 本角色的行动限制在 2 以上的情况下
if $game_party.actors[@status_window.index].restriction >= 2
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到特技画面
$scene = Scene_Skill.new(@status_window.index)
when 4 # 装备
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换的装备画面
$scene = Scene_Equip.new(@status_window.index)
when 2 # 状态
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到状态画面
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end
#==============================================================================
# ■ Scene_IndiItem
#------------------------------------------------------------------------------
# 处理单人物品画面的类。
#==============================================================================
class Scene_IndiItem
#--------------------------------------------------------------------------
# ● 初始化对像
# actor_index : 角色索引
# equip_index : 装备索引
#--------------------------------------------------------------------------
def initialize(actor_index)
@actor_index = actor_index
@actor = $game_party.actors[@actor_index]
$正在丢弃物品 = 0
$正在交付物品 = 0
$指定人物=0
$交付数量=0
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成帮助窗口、物品窗口
@help_window = Window_Help.new
@item_window = Window_IndiItem.new(@actor)
# 关联帮助窗口
@item_window.help_window = @help_window
# 生成目标窗口 (设置为不可见・不活动)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
@num_window = Window_GiveNum.new(@actor, nil)
@num_window.visible=false
@num_window.active=false
@give_window = Window_Give.new(@actor)
@give_window.visible=false
@give_window.active=false
@dowi_window = Window_Dowi.new
@dowi_window.visible=false
@dowi_window.active=false
# 执行过度
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换就中断循环
if $scene != self
break
end
end
# 装备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
@item_window.dispose
@target_window.dispose
@num_window.dispose
@give_window.dispose
@dowi_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@item_window.update
@target_window.update
# 物品窗口被激活的情况下: 调用 update_item
if @item_window.active
update_item
return
end
# 目标窗口被激活的情况下: 调用 update_target
if @target_window.active
update_target
return
end
if @num_window.active
update_num
return
end
if @give_window.active
update_give
return
end
if @dowi_window.active
update_dowi
return
end
end
def update_num
if Input.trigger?(Input::B)
@num_window.active=false
@num_window.visible=false
@give_window.active=false
@give_window.visible=false
@item_window.active=true
$game_system.se_play($data_system.cancel_se)
return
end
if Input.trigger?(Input::C)
@item = @item_window.item
wwwt = @item.weight * $交付数量
if @dowi_window.index == 1
if wwwt > ($game_party.actors[$指定人物].indi_capacity-$game_party.actors[$指定人物].total_weight)
$game_system.se_play($data_system.buzzer_se)
return
end
case @item
when RPG::Item
$game_party.actors[$指定人物].gain_item(@item.id,$交付数量)
when RPG::Weapon
$game_party.actors[$指定人物].gain_weapon(@item.id,$交付数量)
when RPG::Armor
$game_party.actors[$指定人物].gain_armor(@item.id,$交付数量)
end
end
case @item
when RPG::Item
@actor.lose_item(@item.id,$交付数量)
when RPG::Weapon
@actor.lose_weapon(@item.id,$交付数量)
when RPG::Armor
@actor.lose_armor(@item.id,$交付数量)
end
@num_window.active=false
@num_window.visible=false
@give_window.active=false
@give_window.visible=false
@item_window.active=true
$game_system.se_play($data_system.decision_se)
@item_window.refresh
@weight_window.refresh(@item.weight)
return
end
@num_window.update
end
def update_give
if Input.trigger?(Input::B)
@give_window.active=false
@give_window.visible=false
@item_window.active=true
$game_system.se_play($data_system.cancel_se)
return
end
if Input.trigger?(Input::C)
@item = @item_window.item
@give_window.active=false
@num_window.dispose
@num_window = Window_GiveNum.new(@actor, @item)
@num_window.active=true
@num_window.visible=true
$game_system.se_play($data_system.decision_se)
return
end
if Input.trigger?(Input::DOWN)
@give_window.index+=1
if @give_window.index>=$give_max
@give_window.index=0
end
$game_system.se_play($data_system.cursor_se)
return
end
if Input.trigger?(Input::UP)
@give_window.index-=1
if @give_window.index<0
@give_window.index+=$give_max
end
$game_system.se_play($data_system.cursor_se)
return
end
@give_window.update
end
def update_dowi
if Input.trigger?(Input::B)
@dowi_window.active=false
@dowi_window.visible=false
@item_window.active=true
$game_system.se_play($data_system.cancel_se)
return
end
if Input.trigger?(Input::C)
@item = @item_window.item
if @dowi_window.index == 0
#==============================================================================
# 不使用物品的情况下
unless @item.is_a?(RPG::Item)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 不能使用的情况下
unless @actor.item_can_use?(@item.id)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 效果范围是我方的情况下
if @item.scope >= 3
# 激活目标窗口
@dowi_window.active=false
@dowi_window.visible=false
@target_window.x = (@item_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# 设置效果范围 (单体/全体) 的对应光标位置
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# 效果在我方以外的情况下
else
# 公共事件 ID 有效的情况下
if @item.common_event_id > 0
# 预约调用公共事件
$game_temp.common_event_id = @item.common_event_id
# 演奏物品使用时的 SE
$game_system.se_play(@item.menu_se)
# 消耗品的情况下
if @item.consumable
# 使用的物品数减 1
@actor.lose_item(@item.id, 1)
# 再描绘物品窗口的项目
@item_window.draw_item(@item_window.index)
end
# 切换到地图画面
$scene = Scene_Map.new
return
end
return
end
#==============================================================================
else
if @dowi_window.index==1
if $game_party.actors.size<2
$game_system.se_play($data_system.buzzer_se)
return
end
$正在交付物品=1
$正在丢弃物品=0
@dowi_window.active=false
@dowi_window.visible=false
@give_window.dispose
@give_window=Window_Give.new(@actor)
@give_window.active=true
@give_window.visible=true
else
$正在交付物品=0
$正在丢弃物品=1
@dowi_window.active=false
@dowi_window.visible=false
@item = @item_window.item
@num_window.dispose
@num_window = Window_GiveNum.new(@actor, @item)
@num_window.active=true
@num_window.visible=true
end
$game_system.se_play($data_system.decision_se)
return
end
end
if Input.trigger?(Input::DOWN)
@dowi_window.index+=1
if @dowi_window.index>2
@dowi_window.index=0
end
$game_system.se_play($data_system.cursor_se)
return
end
if Input.trigger?(Input::UP)
@dowi_window.index-=1
if @dowi_window.index<0
@dowi_window.index=2
end
$game_system.se_play($data_system.cursor_se)
return
end
@dowi_window.update
end
#--------------------------------------------------------------------------
# ● 刷新画面 (物品窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_item
# 按下 R 键的情况下
if Input.trigger?(Input::R)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至下一位角色
@actor_index += 1
@actor_index %= $game_party.actors.size
# 切换到别的装备画面
$scene = Scene_IndiItem.new(@actor_index)
return
end
# 按下 L 键的情况下
if Input.trigger?(Input::L)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至上一位角色
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# 切换到别的装备画面
$scene = Scene_IndiItem.new(@actor_index)
return
end
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(0)
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品窗口当前选中的物品数据
@item = @item_window.item
@item_window.active=false
@dowi_window.dispose
@dowi_window=Window_Dowi.new(@item)
@dowi_window.visible=true
@dowi_window.active=true
$game_system.se_play($data_system.decision_se)
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (目标窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_target
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 由于物品用完而不能使用的场合
unless @actor.item_can_use?(@item.id)
# 再次生成物品窗口的内容
@item_window.refresh
end
# 删除目标窗口
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 如果物品用完的情况下
if @actor.item_number(@item.id) == 0
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 目标是全体的情况下
if @target_window.index == -1
# 对同伴全体应用物品使用效果
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# 目标是单体的情况下
if @target_window.index >= 0
# 对目标角色应用物品的使用效果
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# 使用物品的情况下
if used
# 演奏物品使用时的 SE
$game_system.se_play(@item.menu_se)
# 消耗品的情况下
if @item.consumable
# 使用的物品数减 1
@actor.lose_item(@item.id, 1)
# 再描绘物品窗口的项目
@item_window.draw_item(@item_window.index)
end
# 再生成目标窗口的内容
@target_window.refresh
# 全灭的情况下
if $game_party.all_dead?
# 切换到游戏结束画面
$scene = Scene_Gameover.new
return
end
# 公共事件 ID 有效的情况下
if @item.common_event_id > 0
# 预约调用公共事件
$game_temp.common_event_id = @item.common_event_id
# 切换到地图画面
$scene = Scene_Map.new
return
end
end
# 无法使用物品的情况下
unless used
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
class Scene_Battle
def start_item_select
# 生成物品窗口
@item_window = Window_IndiItem.new(@active_actor)
# 关联帮助窗口
@item_window.help_window = @help_window
# 无效化角色指令窗口
@actor_command_window.active = false
@actor_command_window.visible = false
end
#--------------------------------------------------------------------------
# ● 刷新画面 (角色命令回合 : 选择物品)
#--------------------------------------------------------------------------
def update_phase3_item_select
# 设置物品窗口为可视状态
@item_window.visible = true
# 刷新物品窗口
@item_window.update
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 选择物品结束
end_item_select
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品窗口现在选择的物品资料
@item = @item_window.item
# 无法使用的情况下
unless @active_actor.item_can_use?(@item.id)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 设置行动
@active_actor.current_action.item_id = @item.id
# 设置物品窗口为不可见状态
@item_window.visible = false
# 效果范围是敌单体的情况下
if @item.scope == 1
# 开始选择敌人
start_enemy_select
# 效果范围是我方单体的情况下
elsif @item.scope == 3 or @item.scope == 5
# 开始选择角色
start_actor_select
# 效果范围不是单体的情况下
else
# 物品选择结束
end_item_select
# 转到下一位角色的指令输入
phase3_next_actor
end
return
end
end
def make_item_action_result(battler)
# アイテムを取得
@item = $data_items[battler.current_action.item_id]
# アイテム切れなどで使用できなくなった場合
unless battler.item_can_use?(@item.id)
# ステップ 6 に移行
battler.phase = 6
return
end
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
battler.lose_item(@item.id, 1)
end
# アニメーション ID を設定
battler.anime1 = @item.animation1_id
battler.anime2 = @item.animation2_id
# コモンイベント ID を設定
battler.event = @item.common_event_id
# 対象を決定
index = battler.current_action.target_index
target = $game_party.smooth_target_actor(index)
# 対象側バトラーを設定
set_target_battlers(@item.scope, battler)
# アイテムの効果を適用
for target in battler.target
target.item_effect(@item, battler)
end
end
end
#==============================================================================
# ■ Window_IndiItem
#------------------------------------------------------------------------------
# 物品画面、战斗画面、显示浏览物品的窗口。
#==============================================================================
class Window_IndiItem < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize(actor)
@actor = actor
super(0, 64, 640, 288)
@column_max = 2
refresh
self.index = 0
# 战斗中的情况下将窗口移至中央并将其半透明化
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# 添加报务
for i in 1...$data_items.size
if @actor.item_number(i) > 0
@data.push($data_items[i])
end
end
# 在战斗中以外添加武器、防具
unless $game_temp.in_battle
for i in 1...$data_weapons.size
if @actor.weapon_number(i) > 0
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if @actor.armor_number(i) > 0
@data.push($data_armors[i])
end
end
end
# 如果项目数不是 0 就生成位图、重新描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = @actor.item_number(item.id)
when RPG::Weapon
number = @actor.weapon_number(item.id)
when RPG::Armor
number = @actor.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
@actor.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 192, 32, item.name, 0)
self.contents.draw_text(x + 224, y, 16, 32, ":", 1)
self.contents.draw_text(x + 240, y, 40, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
class Scene_IndiItem
alias ori_main main
def main
@weight_window = Window_Weight.new(@actor)
@weight_window.x = 0
@weight_window.y = 352
@weight_window.z = 0
ori_main
@weight_window.dispose
end
alias ori_update update
def update
case @item_window.item
when RPG::Item
@weight_window.refresh($data_items[@item_window.item.id].weight)
when RPG::Weapon
@weight_window.refresh($data_weapons[@item_window.item.id].weight)
when RPG::Armor
@weight_window.refresh($data_armors[@item_window.item.id].weight)
end
ori_update
end
end
class Window_Weight < Window_Base
def initialize(actor)
@actor=actor
super(0,0,640,128)
self.opacity = 255
self.contents = Bitmap.new(width-32,height-32)
refresh(nil)
end
def refresh(weight)
self.contents.clear
self.contents.draw_text(0,0,160,32,@actor.name)
if weight != nil
self.contents.draw_text(128,0,160,32,"单件重量:#{weight}")
end
self.contents.draw_text(320,0,320,32,"背包重量:"+@actor.total_weight.to_s + "/" + @actor.indi_capacity.to_s , 0)
ssstx=0
sssty=32
self.contents.draw_text(ssstx,sssty,160,32,"装备物品:")
ssstx=128
if @actor.weapon_id != 0
self.contents.draw_text(ssstx,sssty,160,32,$data_weapons[@actor.weapon_id].name + "(" + $data_weapons[@actor.weapon_id].weight.to_s + ")")
end
ssstx=288
if @actor.armor1_id != 0
self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor1_id].name + "(" + $data_armors[@actor.armor1_id].weight.to_s + ")")
end
ssstx=448
if @actor.armor2_id != 0
self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor2_id].name + "(" + $data_armors[@actor.armor2_id].weight.to_s + ")")
end
ssstx=128
sssty=64
if @actor.armor3_id != 0
self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor3_id].name + "(" + $data_armors[@actor.armor3_id].weight.to_s + ")")
end
ssstx=288
if @actor.armor4_id != 0
self.contents.draw_text(ssstx,sssty,160,32,$data_armors[@actor.armor4_id].name + "(" + $data_armors[@actor.armor4_id].weight.to_s + ")")
end
end
end
class Window_Dowi < Window_Selectable
def initialize(item = nil)
super(256, 240, 128, 160)
@item = item
self.opacity = 255
self.contents = Bitmap.new(width-32,height-32)
self.z=120
self.index=0
refresh
end
def refresh
self.contents.draw_text(4, 0, 192, 32, "使用", 0)
self.contents.draw_text(4, 32, 192, 32, "交给", 0)
self.contents.draw_text(4, 64, 192, 32, "丢弃", 0)
end
end
class Window_Give < Window_Selectable
def initialize(actor)
super(256, 240, 128, 160)
@actor = actor
@column_max = 1
self.active = false
self.index = -1
self.contents = Bitmap.new(width - 32, height - 32)
self.z=120
self.index=0
$指定人物=0
# 添加本人以外的角色
@data=[]
@data_target=[]
for iii in 0...$game_party.actors.size
if @actor != $game_party.actors[iii]
@data.push($game_party.actors[iii].name)
@data_target.push(iii)
end
end
@item_max=@data.size
$give_max=@item_max
refresh
end
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
$指定人物=@data_target[self.index]
end
#--------------------------------------------------------------------------
# ● 项目的描绘
# index : 项目符号
#--------------------------------------------------------------------------
def draw_item(index)
#print index
item = @data[index]
#print item
x = 4
y = index * 32
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 192, 32, item, 0)
end
def update
refresh
end
end
class Window_GiveNum < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize(actor, item)
super(160, 80, 320, 160)
self.contents = Bitmap.new(width - 32, height - 32)
@item = item
@number = 1
if item != nil
@max = actor.item_number(item.id)
else
@max = 0
end
self.z=120
refresh
end
def refresh
self.contents.clear
self.contents.font.color = normal_color
if @item != nil
if $正在丢弃物品 != 0
self.contents.draw_text(4, 0, 192, 32, "丢掉几件", 0)
self.contents.draw_text(200, 0, 192, 32, @number.to_s, 0)
self.contents.draw_text(4, 32, 192, 32, "减轻重量", 0)
self.contents.draw_text(200, 32, 192, 32, [@number * @item.weight].to_s, 0)
self.contents.draw_text(4, 96, 240, 32, "请按方向键增减数量", 0)
return
end
if $正在交付物品 != 1
self.contents.draw_text(4, 0, 192, 32, "要交给谁", 0)
else
self.contents.draw_text(4, 0, 192, 32, "交给几件", 0)
self.contents.draw_text(200, 0, 192, 32, @number.to_s, 0)
self.contents.draw_text(4, 32, 192, 32, "交换重量", 0)
self.contents.draw_text(200, 32, 192, 32, [@number * @item.weight].to_s, 0)
self.contents.draw_text(4, 64, 240, 32, "接收方剩余负荷", 0)
lastweight=$game_party.actors[$指定人物].indi_capacity-$game_party.actors[$指定人物].total_weight
self.contents.draw_text(200, 64, 192, 32, lastweight.to_s, 0)
end
self.contents.draw_text(4, 96, 240, 32, "请按方向键增减数量", 0)
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
if @item != nil
if self.active
# 光标右 (+10)
if Input.repeat?(Input::RIGHT) and @number < @max
$game_system.se_play($data_system.cursor_se)
@number = [@number + 10, @max].min
end
# 光标左 (-10)
if Input.repeat?(Input::LEFT) and @number > 1
$game_system.se_play($data_system.cursor_se)
@number = [@number - 10, 1].max
end
# 光标上 (-1)
if Input.repeat?(Input::UP) and @number > 1
$game_system.se_play($data_system.cursor_se)
@number -= 1
end
# 光标下 (+1)
if Input.repeat?(Input::DOWN) and @number < @max
$game_system.se_play($data_system.cursor_se)
@number += 1
end
end
end
$交付数量=@number
refresh
end
end
#==============================================================================
# ■ Window_EquipItem
#------------------------------------------------------------------------------
# 装备画面、显示浏览变更装备的候补物品的窗口。
#==============================================================================
class Window_EquipItem < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
# equip_type : 装备部位 (0~3)
#--------------------------------------------------------------------------
def initialize(actor, equip_type)
super(0, 256, 640, 224)
@actor = actor
@equip_type = equip_type
@column_max = 2
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# 添加可以装备的武器
if @equip_type == 0
weapon_set = $data_classes[@actor.class_id].weapon_set
for i in 1...$data_weapons.size
if @actor.weapon_number(i) > 0 and weapon_set.include?(i)
@data.push($data_weapons[i])
end
end
end
# 添加可以装备的防具
if @equip_type != 0
armor_set = $data_classes[@actor.class_id].armor_set
for i in 1...$data_armors.size
if @actor.armor_number(i) > 0 and armor_set.include?(i)
if $data_armors[i].kind == @equip_type-1
@data.push($data_armors[i])
end
end
end
end
# 添加空白
@data.push(nil)
# 生成位图、描绘全部项目
@item_max = @data.size
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max-1
draw_item(i)
end
end
#--------------------------------------------------------------------------
# ● 项目的描绘
# index : 项目符号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
case item
when RPG::Weapon
number = @actor.weapon_number(item.id)
when RPG::Armor
number = @actor.armor_number(item.id)
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
self.contents.draw_text(x + 28, y, 192, 32, item.name, 0)
self.contents.draw_text(x + 224, y, 16, 32, ":", 1)
self.contents.draw_text(x + 240, y, 40, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
class Game_Party
#--------------------------------------------------------------------------
# ● 增加物品 (减少)
# item_id : 物品 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_item(item_id, n)
# 更新 hash 的个数数据
if item_id > 0
wwwt = $data_items[item_id].weight
straight = 0 #从领队开始依次拿取物品,当领队载重量不够时转至下一个队员获取
for iii in 0...n #检查物品n次
leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
while leftwt < wwwt
straight += 1
if straight>=$game_party.actors.size
return
end
leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
end
$game_party.actors[straight].gain_item(item_id, 1)
end
end
end
#--------------------------------------------------------------------------
# ● 增加武器 (减少)
# weapon_id : 武器 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_weapon(weapon_id, n)
# 更新 hash 的个数数据
if item_id > 0
wwwt = $data_weapons[weapon_id].weight
straight = 0 #从领队开始依次拿取物品,当领队载重量不够时转至下一个队员获取
for iii in 0...n #检查物品n次
leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
while leftwt < wwwt
straight += 1
if straight>=$game_party.actors.size
return
end
leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
end
$game_party.actors[straight].gain_weapon(weapon_id, 1)
end
end
end
#--------------------------------------------------------------------------
# ● 增加防具 (减少)
# armor_id : 防具 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_armor(armor_id, n)
# 更新 hash 的个数数据
if item_id > 0
wwwt = $data_armors[armor_id].weight
straight = 0 #从领队开始依次拿取物品,当领队载重量不够时转至下一个队员获取
for iii in 0...n #检查物品n次
leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
while leftwt < wwwt
straight += 1
if straight>=$game_party.actors.size
return
end
leftwt = $game_party.actors[straight].indi_capacity - $game_party.actors[straight].total_weight
end
$game_party.actors[straight].gain_armor(armor_id, 1)
end
end
end
end
然后如果方便的话就好人做到底,帮忙把那个装备占重量取消,背包负重限度改为背包空间,如果背包空间满了就放不进去东西了,貌似这个我可以改,不过没有时间了......
@myownroc
@芯☆淡茹水
@千夙
|
|