赞 | 204 |
VIP | 13 |
好人卡 | 7 |
积分 | 122 |
经验 | 52899 |
最后登录 | 2021-6-29 |
在线时间 | 4435 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 12157
- 在线时间
- 4435 小时
- 注册时间
- 2014-4-11
- 帖子
- 5955
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
可支付宝
完美物品系统
#============================================================================== # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息 # ■ 使用方法写在发布页 #============================================================================== =begin 部分可能在制作中用到的核心算法: 角色(Game_Actor): 属性:max_size,最大负重,可在游戏更改。如$game_actors[1].max_size += 1 属性:items,物品列表,只可读取,不可修改。如$a = $game_actors[1].items[0] 函数:judge_equip,判断一下是否装备正确。如果不正确就把装备设置为空 函数:gain_item(item_id, kind=1, n=true),给某角色增减物品。 item_id : 物品 ID;n: true是增加,false是减少;kind:种类,1是物品,2是武器,3是防具 函数:item_amount,返回现有负重物品数量 函数:have_item?(item),判断是否拥有某物 函数:item_full?,判断背包是不是满了 队伍(Game_Party): 属性:max_amount,最大背包中物品数量 属性:now_amount,背包中现有物品数量 函数:item_full?,判断背包是否放满 函数:refresh_item_amount,重新刷新背包中现有物品数量,发生意外的时候用 =end #============================================================================== # ■ Game_Actor #------------------------------------------------------------------------------ # 处理角色的类。本类在 Game_Actors 类 ($game_actors) # 的内部使用、Game_Party 类请参考 ($game_party) 。 #============================================================================== class Game_Actor < Game_Battler attr_accessor :max_size attr_reader :items #-------------------------------------------------------------------------- # ● 设置 # actor_id : 角色 ID #-------------------------------------------------------------------------- alias final_items_setup setup def setup(actor_id) final_items_setup(actor_id) #--角色自带的物品建立 @max_size = 8 @items = [] if @weapon_id >0 @items.push($data_weapons[@weapon_id]) end if @armor1_id >0 @items.push($data_armors[@armor1_id]) end if @armor2_id >0 @items.push($data_armors[@armor2_id]) end if @armor3_id >0 @items.push($data_armors[@armor3_id]) end if @armor4_id >0 @items.push($data_armors[@armor4_id]) end end #-------------------------------------------------------------------------- # ● 测试装备是否正确,如果不正确就设置为空 #-------------------------------------------------------------------------- def judge_equip if @armor1_id>0 unless @items.include?($data_armors[@armor1_id]) @armor1_id = 0 end end if @armor2_id>0 unless @items.include?($data_armors[@armor2_id]) @armor2_id = 0 end end if @armor3_id>0 unless @items.include?($data_armors[@armor3_id]) @armor3_id = 0 end end if @armor4_id>0 unless @items.include?($data_armors[@armor4_id]) @armor4_id = 0 end end if @weapon_id>0 unless @items.include?($data_weapons[@weapon_id]) @weapon_id = 0 end end end #-------------------------------------------------------------------------- # ● 增加物品 (减少) # item_id : 物品 ID # n : true是增加,false是减少 # kind : 种类,1是物品,2是武器,3是防具 #-------------------------------------------------------------------------- def gain_item(item_id, kind=1, n=true) return if item_full? if kind == 1 if item_id > 0 and n==true @items.push($data_items[item_id]) elsif item_id >0 and n==false @items.delete($data_items[item_id]) end end if kind == 2 if item_id > 0 and n==true @items.push($data_weapons[item_id]) elsif item_id > 0 and n==false @items.push($data_weapons[item_id]) end end if kind == 3 if item_id > 0 and n==true @items.push($data_armors[item_id]) elsif item_id > 0 and n==true @items.push($data_armors[item_id]) end end end #-------------------------------------------------------------------------- # ● 返回物品数量 #-------------------------------------------------------------------------- def item_amount return @items.size end #-------------------------------------------------------------------------- # ● 判断是否拥有物品 #-------------------------------------------------------------------------- def have_item?(item) return @items.include?(item) end #-------------------------------------------------------------------------- # ● 判断是否物品满了 #-------------------------------------------------------------------------- def item_full? return true if @items.size>=@max_size return false end #-------------------------------------------------------------------------- # ● 变更装备 # equip_type : 装备类型 # id : 武器 or 防具 ID (0 为解除装备) #-------------------------------------------------------------------------- def equip(equip_type, id) case equip_type when 0 # 武器 if id >= 0 @weapon_id = id end when 1 # 盾 if id >= 0 update_auto_state($data_armors[@armor1_id], $data_armors[id]) @armor1_id = id end when 2 # 头 if id >= 0 update_auto_state($data_armors[@armor2_id], $data_armors[id]) @armor2_id = id end when 3 # 身体 if id >= 0 update_auto_state($data_armors[@armor3_id], $data_armors[id]) @armor3_id = id end when 4 # 装饰品 if id >= 0 update_auto_state($data_armors[@armor4_id], $data_armors[id]) @armor4_id = id end end end end #============================================================================== # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息 # ■ 使用方法写在发布页 #============================================================================== # ■ Game_Party #------------------------------------------------------------------------------ # 处理同伴的类。包含金钱以及物品的信息。本类的实例 # 请参考 $game_party。 #============================================================================== class Game_Party #-------------------------------------------------------------------------- # ● 定义实例变量 #-------------------------------------------------------------------------- attr_accessor :max_amount attr_reader :now_amount #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- alias final_item_initialize initialize def initialize final_item_initialize @max_amount = 2 @now_amount = 0 end #-------------------------------------------------------------------------- #-------------------------------------------------------------------------- def item_full? return true if @now_amount>=@max_amount return false end def refresh_item_amount @now_amount = 0 for i in 1...$data_items.size if $game_party.item_number(i) > 0 @now_amount += $game_party.item_number(i) end end for i in 1...$data_weapons.size if $game_party.weapon_number(i) > 0 @now_amount += $game_party.weapon_number(i) end end for i in 1...$data_armors.size if $game_party.armor_number(i) > 0 @now_amount += $game_party.armor_number(i) end end end #-------------------------------------------------------------------------- # ● 增加物品 (减少) # item_id : 物品 ID # n : 个数 #-------------------------------------------------------------------------- def gain_item(item_id, n) # 更新 hash 的个数数据 if item_id > 0 @items[item_id] = [[item_number(item_id) + n, 0].max, @max_amount].min refresh_item_amount end end #-------------------------------------------------------------------------- # ● 增加武器 (减少) # weapon_id : 武器 ID # n : 个数 #-------------------------------------------------------------------------- def gain_weapon(weapon_id, n) # 更新 hash 的个数数据 if weapon_id > 0 @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, @max_amount].min refresh_item_amount end end #-------------------------------------------------------------------------- # ● 增加防具 (减少) # armor_id : 防具 ID # n : 个数 #-------------------------------------------------------------------------- def gain_armor(armor_id, n) # 更新 hash 的个数数据 if armor_id > 0 @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, @max_amount].min refresh_item_amount end 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 end #============================================================================== # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息 # ■ 使用方法写在发布页 #============================================================================== # ■ Window_Command #------------------------------------------------------------------------------ # 一般的命令选择行窗口。 #============================================================================== class Window_Command < Window_Selectable #-------------------------------------------------------------------------- # ● 项目有效化 # index : 项目编号 #-------------------------------------------------------------------------- def enable_item(index) draw_item(index, normal_color) end end #============================================================================== # ■ Window_Item #------------------------------------------------------------------------------ # 物品画面、战斗画面、显示浏览物品的窗口。 #============================================================================== class Window_Item < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize(actor=nil) @actor=actor super(0, 64, 640, 416) @column_max = 1 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 = [] # 添加报务 if @actor==nil for i in 1...$data_items.size if $game_party.item_number(i) > 0 for pushtimes in 0...$game_party.item_number(i) @data.push($data_items[i]) end end end for i in 1...$data_weapons.size if $game_party.weapon_number(i) > 0 for pushtimes in 0...$game_party.weapon_number(i) @data.push($data_weapons[i]) end end end for i in 1...$data_armors.size if $game_party.armor_number(i) > 0 for pushtimes in 0...$game_party.armor_number(i) @data.push($data_armors[i]) end end end else for i in [email]0...@actor.items.size[/email] if @actor.items[i].is_a?(RPG::Item) @data.push(@actor.items[i]) else if @actor.items[i].is_a?(RPG::Weapon) or @actor.items[i].is_a?(RPG::Armor) if @actor.items[i].name==$data_items[@actor.items[i].id].name @data.push($data_items[@actor.items[i].id]) next else @data.push(@actor.items[i]) next end end end end end # 如果项目数不是 0 就生成位图、重新描绘全部项目 @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) self.contents.font.size = 20 for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # ● 描绘项目 # index : 项目编号 #-------------------------------------------------------------------------- def draw_item(index) if @actor==nil item = @data[index] x = 4 y = index * 32 rect = Rect.new(x, y, self.width - 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.font.size = 20 self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.font.size = 14 self.contents.draw_text(x + 150, y, 400, 42, ":"+item.description, 0) else item = @data[index] #if item.is_a?(RPG::Item) and #$game_party.item_can_use?(item.id) #self.contents.font.color = normal_color #else #self.contents.font.color = disabled_color #end x = 4 y = index * 32 rect = Rect.new(x, y, self.width - 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.font.size = 20 self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.font.size = 14 self.contents.draw_text(x + 150, y, 400, 42, ":"+item.description, 0) end end #-------------------------------------------------------------------------- # ● 刷新帮助文本 #-------------------------------------------------------------------------- def update_help @help_window.contents.font.size = 18 if @actor==nil @help_window.set_text(self.item == nil ? ""+" ★仓库目前物品数:"+$game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s : self.item.description+" ★仓库目前物品数:"+$game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s ) else @help_window.set_text(@actor.name+" 物品数量:"+@actor.item_amount.to_s+" 最大负重:"+@actor.max_size.to_s) end end def dispose super @actor.judge_equip if @actor != nil end end #============================================================================== # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息 # ■ 使用方法写在发布页 #============================================================================ # ■ Window_EquipItem #------------------------------------------------------------------------------ # 装备画面、显示浏览变更装备的候补物品的窗口。 #============================================================================== class Window_EquipItem < Window_Selectable #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- 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 item in @actor.items if item.is_a?(RPG::Weapon) and weapon_set.include?(item.id) @data.push(item) end end end # 添加可以装备的防具 if @equip_type != 0 armor_set = $data_classes[@actor.class_id].armor_set for item in @actor.items if item.is_a?(RPG::Armor) and armor_set.include?(item.id) if item.kind == @equip_type-1 @data.push(item) 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 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, 212, 32, item.name, 0) end end #============================================================================== # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息 # ■ 使用方法写在发布页 #============================================================================== # ■ Window_ShopStatus_New #------------------------------------------------------------------------------ # 商店画面、显示物品所持数与角色装备的窗口。 #============================================================================== class Window_ShopStatus_New < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize super(368, 128, 272, 352) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.size = 18 @item = nil @item_max = $game_party.actors.size + 1 refresh end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh self.contents.clear if @item == nil return end case @item when RPG::Item number = $game_party.item_number(@item.id) when RPG::Weapon number = $game_party.weapon_number(@item.id) when RPG::Armor number = $game_party.armor_number(@item.id) end self.contents.font.color = system_color self.contents.draw_text(4, 0, 200, 32, "仓库中本物品数:") self.contents.font.color = normal_color self.contents.draw_text(204, 0, 32, 32, number.to_s, 2) self.contents.font.color = system_color self.contents.draw_text(4, 32, 200, 32, "仓库目前物品数:") self.contents.font.color = normal_color self.contents.draw_text(164, 32, 72, 32, $game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s, 2) #if @item.is_a?(RPG::Item) #return #end # 添加装备品信息 for i in 0...$game_party.actors.size actor = $game_party.actors[i] self.contents.font.color = Color.new(255,255,0) self.contents.draw_text(116, 64 + 64 * i, 132, 32, "负重: ") self.contents.font.color = normal_color self.contents.draw_text(164, 64 + 64 * i, 72, 32, actor.item_amount.to_s+" / "+actor.max_size.to_s,2) # 获取当前的装备品 unless @item == nil or @item.is_a?(RPG::Item) if @item.is_a?(RPG::Weapon) item1 = $data_weapons[actor.weapon_id] elsif @item.kind == 0 item1 = $data_armors[actor.armor1_id] elsif @item.kind == 1 item1 = $data_armors[actor.armor2_id] elsif @item.kind == 2 item1 = $data_armors[actor.armor3_id] else item1 = $data_armors[actor.armor4_id] end # 可以装备为普通文字颜色、不能装备设置为无效文字颜色 if actor.equippable?(@item) self.contents.font.color = normal_color else self.contents.font.color = disabled_color end # 描绘角色名字 self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name) # 可以装备的情况 if actor.equippable?(@item) # 武器的情况 if @item.is_a?(RPG::Weapon) atk1 = item1 != nil ? item1.atk : 0 atk2 = @item != nil ? @item.atk : 0 change = atk2 - atk1 end # 防具的情况 if @item.is_a?(RPG::Armor) pdef1 = item1 != nil ? item1.pdef : 0 mdef1 = item1 != nil ? item1.mdef : 0 pdef2 = @item != nil ? @item.pdef : 0 mdef2 = @item != nil ? @item.mdef : 0 change = pdef2 - pdef1 + mdef2 - mdef1 end # 描绘能力值变化 self.contents.draw_text(124, 96 + 64 * i, 112, 32, sprintf("%+d", change), 2) end # 描绘物品 if item1 != nil x = 4 y = 64 + 64 * i + 32 bitmap = RPG::Cache.icon(item1.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, 212, 32, item1.name) end else self.contents.font.color = normal_color # 描绘角色名字 self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name) end end end #-------------------------------------------------------------------------- # ● 设置物品 # item : 新的物品 #-------------------------------------------------------------------------- def item=(item) if @item != item @item = item refresh end end #-------------------------------------------------------------------------- # ● 刷新光标矩形 #-------------------------------------------------------------------------- def update_cursor_rect if @index < 0 self.cursor_rect.empty else self.cursor_rect.set(0, @index * 64, self.width - 32, 64) end end end #============================================================================== # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息 # ■ 使用方法写在发布页 #============================================================================== # ■ 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 @item_command_window = Window_Command.new(160,["仓库物品","个人物品"]) @item_command_window.x = 120 @item_command_window.visible = false @item_command_window.active = false @item_command_window.z = 999 # 同伴人数为 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 @item_command_window.dispose end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update # 刷新窗口 @command_window.update @playtime_window.update @steps_window.update @gold_window.update @status_window.update @item_command_window.update # 命令窗口被激活的情况下: 调用 update_command if @command_window.active update_command return end # 状态窗口被激活的情况下: 调用 update_status if @status_window.active update_status return end if @item_command_window.active update_item_command return end end def update_item_command if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @item_command_window.active = false @item_command_window.visible = false @command_window.active = true end if Input.trigger?(Input::C) case @item_command_window.index when 0 $game_system.se_play($data_system.decision_se) $scene = Scene_Item.new when 1 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 激活状态窗口 @item_command_window.active = false @item_command_window.visible = false @status_window.active = true @status_window.index = 0 end 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 @item_command_window.active = true @item_command_window.index = 0 @item_command_window.visible = true 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 # 物品 $game_system.se_play($data_system.decision_se) $scene = Scene_Item.new($game_party.actors[@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 #============================================================================== # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息 # ■ 使用方法写在发布页 #============================================================================== # ■ Scene_Item #------------------------------------------------------------------------------ # 处理物品画面的类。 #============================================================================== class Scene_Item #★——添加定义 def initialize(actor = nil) @actor = actor end #-------------------------------------------------------------------------- # ● 主处理 #-------------------------------------------------------------------------- def main # 生成帮助窗口、物品窗口 @help_window = Window_Help.new @item_window = Window_Item.new(@actor) # 关联帮助窗口 @item_window.help_window = @help_window # 生成目标窗口 (设置为不可见・不活动) @target_window = Window_Target.new @target_window.visible = false @target_window.active = false if @actor==nil @command_window = Window_Command.new(160,["使用物品","交给他人","丢弃物品"]) else @command_window = Window_Command.new(160,["使用物品","转交他人","丢弃物品","放回仓库"]) end @command_window.x = 240 @command_window.y = 180 @command_window.visible = false @command_window.active = false @command_window.z = 999 @target_window.z = 10000 # 执行过度 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 @command_window.dispose end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update # 刷新窗口 @help_window.update @item_window.update @target_window.update @command_window.update # 物品窗口被激活的情况下: 调用 update_item if @item_window.active update_item return end # 目标窗口被激活的情况下: 调用 update_target if @target_window.active update_target return end if @command_window.active update_command return end end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update_command # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 切换到菜单画面 @command_window.visible = false @command_window.active = false @item_window.active = true return end # 按下 C 键的情况下 if Input.trigger?(Input::C) case @command_window.index when 0 # 获取物品窗口当前选中的物品数据 @item = @item_window.item # 不使用物品的情况下 if @actor == nil $game_system.se_play($data_system.buzzer_se) return end unless @item.is_a?(RPG::Item) # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 不能使用的情况下 unless $game_party.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 # 激活目标窗口 @command_window.active = 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 if @actor==nil $game_party.lose_item(@item.id, 1) else @actor.items.delete_at(@item_window.index) end # 再描绘物品窗口的项目 @item_window.draw_item(@item_window.index) end # 切换到地图画面 $scene = Scene_Map.new return end end return when 1 $game_system.se_play($data_system.decision_se) @command_window.active = false @target_window.visible = true @target_window.index = 0 @target_window.active = true when 2 $game_system.se_play($data_system.load_se) if @actor != nil @actor.items.delete_at(@item_window.index) @actor.judge_equip else if @item_window.item.is_a?(RPG::Item) $game_party.gain_item(@item_window.item.id,-1) end if @item_window.item.is_a?(RPG::Weapon) $game_party.gain_weapon(@item_window.item.id,-1) end if @item_window.item.is_a?(RPG::Armor) $game_party.gain_armor(@item_window.item.id,-1) end end # 切换到菜单画面 @command_window.visible = false @command_window.active = false @item_window.refresh @item_window.active = true when 3 if $game_party.item_full? $game_system.se_play($data_system.cancel_se) return end $game_system.se_play($data_system.decision_se) if @item_window.item.is_a?(RPG::Item) $game_party.gain_item(@item_window.item.id,1) end if @item_window.item.is_a?(RPG::Weapon) $game_party.gain_weapon(@item_window.item.id,1) end if @item_window.item.is_a?(RPG::Armor) $game_party.gain_armor(@item_window.item.id,1) end @actor.items.delete_at(@item_window.index) # 切换到菜单画面 @command_window.visible = false @command_window.active = false @item_window.refresh @item_window.active = true end end end #-------------------------------------------------------------------------- # ● 刷新画面 (物品窗口被激活的情况下) #-------------------------------------------------------------------------- def update_item # 按下 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 $game_system.se_play($data_system.decision_se) if @item.is_a?(RPG::Item) and $game_party.item_can_use?(@item.id) and @actor != nil @command_window.enable_item(0) else @command_window.disable_item(0) end @command_window.index = 0 @command_window.visible = true @command_window.active = true @item_window.active = false return end # 按下 R 键的情况下 if Input.trigger?(Input::R) $game_system.se_play($data_system.cursor_se) actor_index = 0 for i in 0...$game_party.actors.size if @actor==$game_party.actors[i] actor_index = i break end end actor_index += 1 actor_index %= $game_party.actors.size # 切换到别的特技画面 $scene = Scene_Item.new($game_party.actors[actor_index]) return end # 按下 L 键的情况下 if Input.trigger?(Input::L) # 演奏光标 SE $game_system.se_play($data_system.cursor_se) actor_index = 0 for i in 0...$game_party.actors.size if @actor==$game_party.actors[i] actor_index = i break end end actor_index -= 1 actor_index %= $game_party.actors.size # 切换到别的特技画面 $scene = Scene_Item.new($game_party.actors[actor_index]) return end end #-------------------------------------------------------------------------- # ● 刷新画面 (目标窗口被激活的情况下) #-------------------------------------------------------------------------- def update_target # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 由于物品用完而不能使用的场合 unless $game_party.item_can_use?(@item.id) # 再次生成物品窗口的内容 @item_window.refresh end # 删除目标窗口 @command_window.active = true @target_window.visible = false @target_window.active = false return end # 按下 C 键的情况下 if Input.trigger?(Input::C) if @command_window.index==0 # 目标是全体的情况下 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 if @actor == nil # 使用的物品数减 1 $game_party.lose_item(@item.id, 1) else @actor.items.delete_at(@item_window.index) end # 再描绘物品窗口的项目 @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 @item_window.refresh @item_window.index -= 1 if @item_window.index >0 end # 无法使用物品的情况下 unless used # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) end return end if @command_window.index==1 if $game_party.actors[@target_window.index].item_full? $game_system.se_play($data_system.buzzer_se) return end if @actor != nil @actor.items.delete_at(@item_window.index) else if @item_window.item.is_a?(RPG::Item) $game_party.lose_item(@item_window.item.id, 1) elsif @item_window.item.is_a?(RPG::Weapon) $game_party.lose_weapon(@item_window.item.id, 1) elsif @item_window.item.is_a?(RPG::Armor) $game_party.lose_armor(@item_window.item.id, 1) end end $game_system.se_play($data_system.decision_se) $game_party.actors[@target_window.index].items.push(@item_window.item) @item_window.refresh @item_window.index -= 1 if @item_window.index>0 @item_window.active = true @command_window.visible = false @command_window.active = false @command_window.index = 0 @target_window.visible = false @target_window.active = false end end end end #============================================================================== # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息 # ■ 使用方法写在发布页 #============================================================================== # ■ Scene_Battle (分割定义 3) #------------------------------------------------------------------------------ # 处理战斗画面的类。 #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● 开始选择物品 #-------------------------------------------------------------------------- def start_item_select # 生成物品窗口 @item_window = Window_Item.new($game_party.actors[@actor_index]) # 关联帮助窗口 @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 @item.is_a?(RPG::Item) # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 无法使用的情况下 unless $game_party.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_battler.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 end #============================================================================== # ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息 # ■ 使用方法写在发布页 #============================================================================== # ■ Scene_Shop #------------------------------------------------------------------------------ # 处理商店画面的类。 #============================================================================== class Scene_Shop #-------------------------------------------------------------------------- # ● 主处理 #-------------------------------------------------------------------------- def main @type = 0 # 生成帮助窗口 @help_window = Window_Help.new # 生成指令窗口 @command_window = Window_ShopCommand.new # 生成金钱窗口 @gold_window = Window_Gold.new @gold_window.x = 480 @gold_window.y = 64 # 生成时间窗口 @dummy_window = Window_Base.new(0, 128, 640, 352) # 生成购买窗口 @buy_window = Window_ShopBuy.new($game_temp.shop_goods) @buy_window.active = false @buy_window.visible = false @buy_window.help_window = @help_window # 生成卖出窗口 @sell_window = Window_ShopSell.new @sell_window.active = false @sell_window.visible = false @sell_window.help_window = @help_window # 生成状态窗口 @status_window = Window_ShopStatus_New.new @status_window.visible = false @status_window.index = -1 # 执行过渡 Graphics.transition # 主循环 loop do # 刷新游戏画面 Graphics.update # 刷新输入信息 Input.update # 刷新画面 update # 如果画面切换的话就中断循环 if $scene != self break end end # 准备过渡 Graphics.freeze # 释放窗口 @help_window.dispose @command_window.dispose @gold_window.dispose @dummy_window.dispose @buy_window.dispose @sell_window.dispose @status_window.dispose end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update # 刷新窗口 @help_window.update @command_window.update @gold_window.update @dummy_window.update @buy_window.update @sell_window.update @status_window.update # 指令窗口激活的情况下: 调用 update_command if @command_window.active update_command return end # 购买窗口激活的情况下: 调用 update_buy if @buy_window.active update_buy return end # 卖出窗口激活的情况下: 调用 update_sell if @sell_window.active update_sell return end if @type==1 update_st1 return end end def update_st1 if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @buy_window.active = true @type = 0 @status_window.index = -1 @status_window.active = false return end if Input.trigger?(Input::C) if @status_window.index == 0 if $game_party.item_full? $game_system.se_play($data_system.cancel_se) return end # 演奏商店 SE $game_system.se_play($data_system.shop_se) $game_party.lose_gold(@item.price) case @item when RPG::Item $game_party.gain_item(@item.id, 1) when RPG::Weapon $game_party.gain_weapon(@item.id, 1) when RPG::Armor $game_party.gain_armor(@item.id, 1) end # 刷新各窗口 @gold_window.refresh @buy_window.refresh @status_window.refresh # 窗口状态转向购买模式 @buy_window.active = true @buy_window.visible = true @status_window.active = false @status_window.index = -1 @type = 0 else if $game_party.actors[@status_window.index-1].item_full? $game_system.se_play($data_system.cancel_se) return end # 演奏商店 SE $game_system.se_play($data_system.shop_se) $game_party.lose_gold(@item.price) case @item when RPG::Item $game_party.actors[@status_window.index-1].gain_item(@item.id, 1) when RPG::Weapon $game_party.actors[@status_window.index-1].gain_item(@item.id, 2) when RPG::Armor $game_party.actors[@status_window.index-1].gain_item(@item.id, 3) end # 刷新各窗口 @gold_window.refresh @buy_window.refresh @status_window.refresh # 窗口状态转向购买模式 @buy_window.active = true @status_window.active = false @type = 0 @status_window.index = -1 end 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) # 命令窗口光标位置分支 case @command_window.index when 0 # 购买 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 窗口状态转向购买模式 @command_window.active = false @dummy_window.visible = false @buy_window.active = true @buy_window.visible = true @buy_window.refresh @status_window.visible = true when 1 # 卖出 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 窗口状态转向卖出模式 @command_window.active = false @dummy_window.visible = false @sell_window.active = true @sell_window.visible = true @sell_window.refresh when 2 # 取消 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换到地图画面 $scene = Scene_Map.new end return end end #-------------------------------------------------------------------------- # ● 刷新画面 (购买窗口激活的情况下) #-------------------------------------------------------------------------- def update_buy # 设置状态窗口的物品 @status_window.item = @buy_window.item # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 窗口状态转向初期模式 @command_window.active = true @dummy_window.visible = true @buy_window.active = false @buy_window.visible = false @status_window.visible = false @status_window.item = nil # 删除帮助文本 @help_window.set_text("") return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 获取物品 @item = @buy_window.item # 物品无效的情况下、或者价格在所持金以上的情况下 if @item == nil or @item.price > $game_party.gold # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 获取物品所持数 #case @item #when RPG::Item #number = $game_party.item_number(@item.id) #when RPG::Weapon #number = $game_party.weapon_number(@item.id) #when RPG::Armor #number = $game_party.armor_number(@item.id) #end # 如果已经拥有了 99 个情况下 #if number == 99 # 演奏冻结 SE #$game_system.se_play($data_system.buzzer_se) #return #end # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 计算可以最多购买的数量 #max = @item.price == 0 ? 99 : $game_party.gold / @item.price #max = [max, 99 - number].min # 窗口状态转向数值输入模式 #@buy_window.active = false #@buy_window.visible = false #@number_window.set(@item, max, @item.price) #@number_window.active = true #@number_window.visible = true @buy_window.active = false @status_window.index = 0 @type = 1 @status_window.active = true end end #-------------------------------------------------------------------------- # ● 画面更新 (卖出窗口激活的情况下) #-------------------------------------------------------------------------- def update_sell # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 窗口状态转向初期模式 @command_window.active = true @dummy_window.visible = true @sell_window.active = false @sell_window.visible = false @status_window.item = nil # 删除帮助文本 @help_window.set_text("") return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 获取物品 @item = @sell_window.item # 设置状态窗口的物品 @status_window.item = @item # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下 if @item == nil or @item.price == 0 # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 卖出处理 $game_party.gain_gold(@item.price / 2) case @item when RPG::Item $game_party.lose_item(@item.id, 1) when RPG::Weapon $game_party.lose_weapon(@item.id, 1) when RPG::Armor $game_party.lose_armor(@item.id, 1) end # 刷新各窗口 @gold_window.refresh @sell_window.refresh @status_window.refresh end end end
#==============================================================================
# ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
# ■ 使用方法写在发布页
#==============================================================================
=begin
部分可能在制作中用到的核心算法:
角色(Game_Actor):
属性:max_size,最大负重,可在游戏更改。如$game_actors[1].max_size += 1
属性:items,物品列表,只可读取,不可修改。如$a = $game_actors[1].items[0]
函数:judge_equip,判断一下是否装备正确。如果不正确就把装备设置为空
函数:gain_item(item_id, kind=1, n=true),给某角色增减物品。
item_id : 物品 ID;n: true是增加,false是减少;kind:种类,1是物品,2是武器,3是防具
函数:item_amount,返回现有负重物品数量
函数:have_item?(item),判断是否拥有某物
函数:item_full?,判断背包是不是满了
队伍(Game_Party):
属性:max_amount,最大背包中物品数量
属性:now_amount,背包中现有物品数量
函数:item_full?,判断背包是否放满
函数:refresh_item_amount,重新刷新背包中现有物品数量,发生意外的时候用
=end
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
# 处理角色的类。本类在 Game_Actors 类 ($game_actors)
# 的内部使用、Game_Party 类请参考 ($game_party) 。
#==============================================================================
class Game_Actor < Game_Battler
attr_accessor :max_size
attr_reader :items
#--------------------------------------------------------------------------
# ● 设置
# actor_id : 角色 ID
#--------------------------------------------------------------------------
alias final_items_setup setup
def setup(actor_id)
final_items_setup(actor_id)
#--角色自带的物品建立
@max_size = 8
@items = []
if @weapon_id >0
@items.push($data_weapons[@weapon_id])
end
if @armor1_id >0
@items.push($data_armors[@armor1_id])
end
if @armor2_id >0
@items.push($data_armors[@armor2_id])
end
if @armor3_id >0
@items.push($data_armors[@armor3_id])
end
if @armor4_id >0
@items.push($data_armors[@armor4_id])
end
end
#--------------------------------------------------------------------------
# ● 测试装备是否正确,如果不正确就设置为空
#--------------------------------------------------------------------------
def judge_equip
if @armor1_id>0
unless @items.include?($data_armors[@armor1_id])
@armor1_id = 0
end
end
if @armor2_id>0
unless @items.include?($data_armors[@armor2_id])
@armor2_id = 0
end
end
if @armor3_id>0
unless @items.include?($data_armors[@armor3_id])
@armor3_id = 0
end
end
if @armor4_id>0
unless @items.include?($data_armors[@armor4_id])
@armor4_id = 0
end
end
if @weapon_id>0
unless @items.include?($data_weapons[@weapon_id])
@weapon_id = 0
end
end
end
#--------------------------------------------------------------------------
# ● 增加物品 (减少)
# item_id : 物品 ID
# n : true是增加,false是减少
# kind : 种类,1是物品,2是武器,3是防具
#--------------------------------------------------------------------------
def gain_item(item_id, kind=1, n=true)
return if item_full?
if kind == 1
if item_id > 0 and n==true
@items.push($data_items[item_id])
elsif item_id >0 and n==false
@items.delete($data_items[item_id])
end
end
if kind == 2
if item_id > 0 and n==true
@items.push($data_weapons[item_id])
elsif item_id > 0 and n==false
@items.push($data_weapons[item_id])
end
end
if kind == 3
if item_id > 0 and n==true
@items.push($data_armors[item_id])
elsif item_id > 0 and n==true
@items.push($data_armors[item_id])
end
end
end
#--------------------------------------------------------------------------
# ● 返回物品数量
#--------------------------------------------------------------------------
def item_amount
return @items.size
end
#--------------------------------------------------------------------------
# ● 判断是否拥有物品
#--------------------------------------------------------------------------
def have_item?(item)
return @items.include?(item)
end
#--------------------------------------------------------------------------
# ● 判断是否物品满了
#--------------------------------------------------------------------------
def item_full?
return true if @items.size>=@max_size
return false
end
#--------------------------------------------------------------------------
# ● 变更装备
# equip_type : 装备类型
# id : 武器 or 防具 ID (0 为解除装备)
#--------------------------------------------------------------------------
def equip(equip_type, id)
case equip_type
when 0 # 武器
if id >= 0
@weapon_id = id
end
when 1 # 盾
if id >= 0
update_auto_state($data_armors[@armor1_id], $data_armors[id])
@armor1_id = id
end
when 2 # 头
if id >= 0
update_auto_state($data_armors[@armor2_id], $data_armors[id])
@armor2_id = id
end
when 3 # 身体
if id >= 0
update_auto_state($data_armors[@armor3_id], $data_armors[id])
@armor3_id = id
end
when 4 # 装饰品
if id >= 0
update_auto_state($data_armors[@armor4_id], $data_armors[id])
@armor4_id = id
end
end
end
end
#==============================================================================
# ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
# ■ 使用方法写在发布页
#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
# 处理同伴的类。包含金钱以及物品的信息。本类的实例
# 请参考 $game_party。
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :max_amount
attr_reader :now_amount
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
alias final_item_initialize initialize
def initialize
final_item_initialize
@max_amount = 2
@now_amount = 0
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def item_full?
return true if @now_amount>=@max_amount
return false
end
def refresh_item_amount
@now_amount = 0
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@now_amount += $game_party.item_number(i)
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@now_amount += $game_party.weapon_number(i)
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@now_amount += $game_party.armor_number(i)
end
end
end
#--------------------------------------------------------------------------
# ● 增加物品 (减少)
# item_id : 物品 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_item(item_id, n)
# 更新 hash 的个数数据
if item_id > 0
@items[item_id] = [[item_number(item_id) + n, 0].max, @max_amount].min
refresh_item_amount
end
end
#--------------------------------------------------------------------------
# ● 增加武器 (减少)
# weapon_id : 武器 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_weapon(weapon_id, n)
# 更新 hash 的个数数据
if weapon_id > 0
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, @max_amount].min
refresh_item_amount
end
end
#--------------------------------------------------------------------------
# ● 增加防具 (减少)
# armor_id : 防具 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_armor(armor_id, n)
# 更新 hash 的个数数据
if armor_id > 0
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, @max_amount].min
refresh_item_amount
end
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
end
#==============================================================================
# ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
# ■ 使用方法写在发布页
#==============================================================================
# ■ Window_Command
#------------------------------------------------------------------------------
# 一般的命令选择行窗口。
#==============================================================================
class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
# ● 项目有效化
# index : 项目编号
#--------------------------------------------------------------------------
def enable_item(index)
draw_item(index, normal_color)
end
end
#==============================================================================
# ■ Window_Item
#------------------------------------------------------------------------------
# 物品画面、战斗画面、显示浏览物品的窗口。
#==============================================================================
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize(actor=nil)
@actor=actor
super(0, 64, 640, 416)
@column_max = 1
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 = []
# 添加报务
if @actor==nil
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
for pushtimes in 0...$game_party.item_number(i)
@data.push($data_items[i])
end
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
for pushtimes in 0...$game_party.weapon_number(i)
@data.push($data_weapons[i])
end
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
for pushtimes in 0...$game_party.armor_number(i)
@data.push($data_armors[i])
end
end
end
else
for i in [email]0...@actor.items.size[/email]
if @actor.items[i].is_a?(RPG::Item)
@data.push(@actor.items[i])
else
if @actor.items[i].is_a?(RPG::Weapon) or @actor.items[i].is_a?(RPG::Armor)
if @actor.items[i].name==$data_items[@actor.items[i].id].name
@data.push($data_items[@actor.items[i].id])
next
else
@data.push(@actor.items[i])
next
end
end
end
end
end
# 如果项目数不是 0 就生成位图、重新描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.size = 20
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
if @actor==nil
item = @data[index]
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 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.font.size = 20
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.font.size = 14
self.contents.draw_text(x + 150, y, 400, 42, ":"+item.description, 0)
else
item = @data[index]
#if item.is_a?(RPG::Item) and
#$game_party.item_can_use?(item.id)
#self.contents.font.color = normal_color
#else
#self.contents.font.color = disabled_color
#end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 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.font.size = 20
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.font.size = 14
self.contents.draw_text(x + 150, y, 400, 42, ":"+item.description, 0)
end
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.contents.font.size = 18
if @actor==nil
@help_window.set_text(self.item == nil ? ""+" ★仓库目前物品数:"+$game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s : self.item.description+" ★仓库目前物品数:"+$game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s )
else
@help_window.set_text(@actor.name+" 物品数量:"+@actor.item_amount.to_s+" 最大负重:"+@actor.max_size.to_s)
end
end
def dispose
super
@actor.judge_equip if @actor != nil
end
end
#==============================================================================
# ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
# ■ 使用方法写在发布页
#============================================================================
# ■ Window_EquipItem
#------------------------------------------------------------------------------
# 装备画面、显示浏览变更装备的候补物品的窗口。
#==============================================================================
class Window_EquipItem < Window_Selectable
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
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 item in @actor.items
if item.is_a?(RPG::Weapon) and weapon_set.include?(item.id)
@data.push(item)
end
end
end
# 添加可以装备的防具
if @equip_type != 0
armor_set = $data_classes[@actor.class_id].armor_set
for item in @actor.items
if item.is_a?(RPG::Armor) and armor_set.include?(item.id)
if item.kind == @equip_type-1
@data.push(item)
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
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, 212, 32, item.name, 0)
end
end
#==============================================================================
# ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
# ■ 使用方法写在发布页
#==============================================================================
# ■ Window_ShopStatus_New
#------------------------------------------------------------------------------
# 商店画面、显示物品所持数与角色装备的窗口。
#==============================================================================
class Window_ShopStatus_New < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(368, 128, 272, 352)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 18
@item = nil
@item_max = $game_party.actors.size + 1
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if @item == nil
return
end
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
end
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 200, 32, "仓库中本物品数:")
self.contents.font.color = normal_color
self.contents.draw_text(204, 0, 32, 32, number.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(4, 32, 200, 32, "仓库目前物品数:")
self.contents.font.color = normal_color
self.contents.draw_text(164, 32, 72, 32, $game_party.now_amount.to_s+" / "+$game_party.max_amount.to_s, 2)
#if @item.is_a?(RPG::Item)
#return
#end
# 添加装备品信息
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
self.contents.font.color = Color.new(255,255,0)
self.contents.draw_text(116, 64 + 64 * i, 132, 32, "负重: ")
self.contents.font.color = normal_color
self.contents.draw_text(164, 64 + 64 * i, 72, 32, actor.item_amount.to_s+" / "+actor.max_size.to_s,2)
# 获取当前的装备品
unless @item == nil or @item.is_a?(RPG::Item)
if @item.is_a?(RPG::Weapon)
item1 = $data_weapons[actor.weapon_id]
elsif @item.kind == 0
item1 = $data_armors[actor.armor1_id]
elsif @item.kind == 1
item1 = $data_armors[actor.armor2_id]
elsif @item.kind == 2
item1 = $data_armors[actor.armor3_id]
else
item1 = $data_armors[actor.armor4_id]
end
# 可以装备为普通文字颜色、不能装备设置为无效文字颜色
if actor.equippable?(@item)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
# 描绘角色名字
self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
# 可以装备的情况
if actor.equippable?(@item)
# 武器的情况
if @item.is_a?(RPG::Weapon)
atk1 = item1 != nil ? item1.atk : 0
atk2 = @item != nil ? @item.atk : 0
change = atk2 - atk1
end
# 防具的情况
if @item.is_a?(RPG::Armor)
pdef1 = item1 != nil ? item1.pdef : 0
mdef1 = item1 != nil ? item1.mdef : 0
pdef2 = @item != nil ? @item.pdef : 0
mdef2 = @item != nil ? @item.mdef : 0
change = pdef2 - pdef1 + mdef2 - mdef1
end
# 描绘能力值变化
self.contents.draw_text(124, 96 + 64 * i, 112, 32,
sprintf("%+d", change), 2)
end
# 描绘物品
if item1 != nil
x = 4
y = 64 + 64 * i + 32
bitmap = RPG::Cache.icon(item1.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, 212, 32, item1.name)
end
else
self.contents.font.color = normal_color
# 描绘角色名字
self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
end
end
end
#--------------------------------------------------------------------------
# ● 设置物品
# item : 新的物品
#--------------------------------------------------------------------------
def item=(item)
if @item != item
@item = item
refresh
end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 64, self.width - 32, 64)
end
end
end
#==============================================================================
# ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
# ■ 使用方法写在发布页
#==============================================================================
# ■ 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
@item_command_window = Window_Command.new(160,["仓库物品","个人物品"])
@item_command_window.x = 120
@item_command_window.visible = false
@item_command_window.active = false
@item_command_window.z = 999
# 同伴人数为 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
@item_command_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@command_window.update
@playtime_window.update
@steps_window.update
@gold_window.update
@status_window.update
@item_command_window.update
# 命令窗口被激活的情况下: 调用 update_command
if @command_window.active
update_command
return
end
# 状态窗口被激活的情况下: 调用 update_status
if @status_window.active
update_status
return
end
if @item_command_window.active
update_item_command
return
end
end
def update_item_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@item_command_window.active = false
@item_command_window.visible = false
@command_window.active = true
end
if Input.trigger?(Input::C)
case @item_command_window.index
when 0
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item.new
when 1
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@item_command_window.active = false
@item_command_window.visible = false
@status_window.active = true
@status_window.index = 0
end
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
@item_command_window.active = true
@item_command_window.index = 0
@item_command_window.visible = true
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 # 物品
$game_system.se_play($data_system.decision_se)
$scene = Scene_Item.new($game_party.actors[@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
#==============================================================================
# ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
# ■ 使用方法写在发布页
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
# 处理物品画面的类。
#==============================================================================
class Scene_Item
#★——添加定义
def initialize(actor = nil)
@actor = actor
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成帮助窗口、物品窗口
@help_window = Window_Help.new
@item_window = Window_Item.new(@actor)
# 关联帮助窗口
@item_window.help_window = @help_window
# 生成目标窗口 (设置为不可见・不活动)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
if @actor==nil
@command_window = Window_Command.new(160,["使用物品","交给他人","丢弃物品"])
else
@command_window = Window_Command.new(160,["使用物品","转交他人","丢弃物品","放回仓库"])
end
@command_window.x = 240
@command_window.y = 180
@command_window.visible = false
@command_window.active = false
@command_window.z = 999
@target_window.z = 10000
# 执行过度
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
@command_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@item_window.update
@target_window.update
@command_window.update
# 物品窗口被激活的情况下: 调用 update_item
if @item_window.active
update_item
return
end
# 目标窗口被激活的情况下: 调用 update_target
if @target_window.active
update_target
return
end
if @command_window.active
update_command
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update_command
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
@command_window.visible = false
@command_window.active = false
@item_window.active = true
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
case @command_window.index
when 0
# 获取物品窗口当前选中的物品数据
@item = @item_window.item
# 不使用物品的情况下
if @actor == nil
$game_system.se_play($data_system.buzzer_se)
return
end
unless @item.is_a?(RPG::Item)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 不能使用的情况下
unless $game_party.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
# 激活目标窗口
@command_window.active = 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
if @actor==nil
$game_party.lose_item(@item.id, 1)
else
@actor.items.delete_at(@item_window.index)
end
# 再描绘物品窗口的项目
@item_window.draw_item(@item_window.index)
end
# 切换到地图画面
$scene = Scene_Map.new
return
end
end
return
when 1
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@target_window.visible = true
@target_window.index = 0
@target_window.active = true
when 2
$game_system.se_play($data_system.load_se)
if @actor != nil
@actor.items.delete_at(@item_window.index)
@actor.judge_equip
else
if @item_window.item.is_a?(RPG::Item)
$game_party.gain_item(@item_window.item.id,-1)
end
if @item_window.item.is_a?(RPG::Weapon)
$game_party.gain_weapon(@item_window.item.id,-1)
end
if @item_window.item.is_a?(RPG::Armor)
$game_party.gain_armor(@item_window.item.id,-1)
end
end
# 切换到菜单画面
@command_window.visible = false
@command_window.active = false
@item_window.refresh
@item_window.active = true
when 3
if $game_party.item_full?
$game_system.se_play($data_system.cancel_se)
return
end
$game_system.se_play($data_system.decision_se)
if @item_window.item.is_a?(RPG::Item)
$game_party.gain_item(@item_window.item.id,1)
end
if @item_window.item.is_a?(RPG::Weapon)
$game_party.gain_weapon(@item_window.item.id,1)
end
if @item_window.item.is_a?(RPG::Armor)
$game_party.gain_armor(@item_window.item.id,1)
end
@actor.items.delete_at(@item_window.index)
# 切换到菜单画面
@command_window.visible = false
@command_window.active = false
@item_window.refresh
@item_window.active = true
end
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (物品窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_item
# 按下 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
$game_system.se_play($data_system.decision_se)
if @item.is_a?(RPG::Item) and $game_party.item_can_use?(@item.id) and @actor != nil
@command_window.enable_item(0)
else
@command_window.disable_item(0)
end
@command_window.index = 0
@command_window.visible = true
@command_window.active = true
@item_window.active = false
return
end
# 按下 R 键的情况下
if Input.trigger?(Input::R)
$game_system.se_play($data_system.cursor_se)
actor_index = 0
for i in 0...$game_party.actors.size
if @actor==$game_party.actors[i]
actor_index = i
break
end
end
actor_index += 1
actor_index %= $game_party.actors.size
# 切换到别的特技画面
$scene = Scene_Item.new($game_party.actors[actor_index])
return
end
# 按下 L 键的情况下
if Input.trigger?(Input::L)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
actor_index = 0
for i in 0...$game_party.actors.size
if @actor==$game_party.actors[i]
actor_index = i
break
end
end
actor_index -= 1
actor_index %= $game_party.actors.size
# 切换到别的特技画面
$scene = Scene_Item.new($game_party.actors[actor_index])
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (目标窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_target
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 由于物品用完而不能使用的场合
unless $game_party.item_can_use?(@item.id)
# 再次生成物品窗口的内容
@item_window.refresh
end
# 删除目标窗口
@command_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
if @command_window.index==0
# 目标是全体的情况下
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
if @actor == nil
# 使用的物品数减 1
$game_party.lose_item(@item.id, 1)
else
@actor.items.delete_at(@item_window.index)
end
# 再描绘物品窗口的项目
@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
@item_window.refresh
@item_window.index -= 1 if @item_window.index >0
end
# 无法使用物品的情况下
unless used
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
if @command_window.index==1
if $game_party.actors[@target_window.index].item_full?
$game_system.se_play($data_system.buzzer_se)
return
end
if @actor != nil
@actor.items.delete_at(@item_window.index)
else
if @item_window.item.is_a?(RPG::Item)
$game_party.lose_item(@item_window.item.id, 1)
elsif @item_window.item.is_a?(RPG::Weapon)
$game_party.lose_weapon(@item_window.item.id, 1)
elsif @item_window.item.is_a?(RPG::Armor)
$game_party.lose_armor(@item_window.item.id, 1)
end
end
$game_system.se_play($data_system.decision_se)
$game_party.actors[@target_window.index].items.push(@item_window.item)
@item_window.refresh
@item_window.index -= 1 if @item_window.index>0
@item_window.active = true
@command_window.visible = false
@command_window.active = false
@command_window.index = 0
@target_window.visible = false
@target_window.active = false
end
end
end
end
#==============================================================================
# ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
# ■ 使用方法写在发布页
#==============================================================================
# ■ Scene_Battle (分割定义 3)
#------------------------------------------------------------------------------
# 处理战斗画面的类。
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● 开始选择物品
#--------------------------------------------------------------------------
def start_item_select
# 生成物品窗口
@item_window = Window_Item.new($game_party.actors[@actor_index])
# 关联帮助窗口
@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 @item.is_a?(RPG::Item)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 无法使用的情况下
unless $game_party.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_battler.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
end
#==============================================================================
# ■ 本脚本来自[url]www.66rpg.com[/url],作者柳柳,转载使用请保留此信息
# ■ 使用方法写在发布页
#==============================================================================
# ■ Scene_Shop
#------------------------------------------------------------------------------
# 处理商店画面的类。
#==============================================================================
class Scene_Shop
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
@type = 0
# 生成帮助窗口
@help_window = Window_Help.new
# 生成指令窗口
@command_window = Window_ShopCommand.new
# 生成金钱窗口
@gold_window = Window_Gold.new
@gold_window.x = 480
@gold_window.y = 64
# 生成时间窗口
@dummy_window = Window_Base.new(0, 128, 640, 352)
# 生成购买窗口
@buy_window = Window_ShopBuy.new($game_temp.shop_goods)
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
# 生成卖出窗口
@sell_window = Window_ShopSell.new
@sell_window.active = false
@sell_window.visible = false
@sell_window.help_window = @help_window
# 生成状态窗口
@status_window = Window_ShopStatus_New.new
@status_window.visible = false
@status_window.index = -1
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
@command_window.dispose
@gold_window.dispose
@dummy_window.dispose
@buy_window.dispose
@sell_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@command_window.update
@gold_window.update
@dummy_window.update
@buy_window.update
@sell_window.update
@status_window.update
# 指令窗口激活的情况下: 调用 update_command
if @command_window.active
update_command
return
end
# 购买窗口激活的情况下: 调用 update_buy
if @buy_window.active
update_buy
return
end
# 卖出窗口激活的情况下: 调用 update_sell
if @sell_window.active
update_sell
return
end
if @type==1
update_st1
return
end
end
def update_st1
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@buy_window.active = true
@type = 0
@status_window.index = -1
@status_window.active = false
return
end
if Input.trigger?(Input::C)
if @status_window.index == 0
if $game_party.item_full?
$game_system.se_play($data_system.cancel_se)
return
end
# 演奏商店 SE
$game_system.se_play($data_system.shop_se)
$game_party.lose_gold(@item.price)
case @item
when RPG::Item
$game_party.gain_item(@item.id, 1)
when RPG::Weapon
$game_party.gain_weapon(@item.id, 1)
when RPG::Armor
$game_party.gain_armor(@item.id, 1)
end
# 刷新各窗口
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
# 窗口状态转向购买模式
@buy_window.active = true
@buy_window.visible = true
@status_window.active = false
@status_window.index = -1
@type = 0
else
if $game_party.actors[@status_window.index-1].item_full?
$game_system.se_play($data_system.cancel_se)
return
end
# 演奏商店 SE
$game_system.se_play($data_system.shop_se)
$game_party.lose_gold(@item.price)
case @item
when RPG::Item
$game_party.actors[@status_window.index-1].gain_item(@item.id, 1)
when RPG::Weapon
$game_party.actors[@status_window.index-1].gain_item(@item.id, 2)
when RPG::Armor
$game_party.actors[@status_window.index-1].gain_item(@item.id, 3)
end
# 刷新各窗口
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
# 窗口状态转向购买模式
@buy_window.active = true
@status_window.active = false
@type = 0
@status_window.index = -1
end
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)
# 命令窗口光标位置分支
case @command_window.index
when 0 # 购买
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 窗口状态转向购买模式
@command_window.active = false
@dummy_window.visible = false
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
@status_window.visible = true
when 1 # 卖出
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 窗口状态转向卖出模式
@command_window.active = false
@dummy_window.visible = false
@sell_window.active = true
@sell_window.visible = true
@sell_window.refresh
when 2 # 取消
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到地图画面
$scene = Scene_Map.new
end
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (购买窗口激活的情况下)
#--------------------------------------------------------------------------
def update_buy
# 设置状态窗口的物品
@status_window.item = @buy_window.item
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 窗口状态转向初期模式
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = false
@status_window.item = nil
# 删除帮助文本
@help_window.set_text("")
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品
@item = @buy_window.item
# 物品无效的情况下、或者价格在所持金以上的情况下
if @item == nil or @item.price > $game_party.gold
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 获取物品所持数
#case @item
#when RPG::Item
#number = $game_party.item_number(@item.id)
#when RPG::Weapon
#number = $game_party.weapon_number(@item.id)
#when RPG::Armor
#number = $game_party.armor_number(@item.id)
#end
# 如果已经拥有了 99 个情况下
#if number == 99
# 演奏冻结 SE
#$game_system.se_play($data_system.buzzer_se)
#return
#end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 计算可以最多购买的数量
#max = @item.price == 0 ? 99 : $game_party.gold / @item.price
#max = [max, 99 - number].min
# 窗口状态转向数值输入模式
#@buy_window.active = false
#@buy_window.visible = false
#@number_window.set(@item, max, @item.price)
#@number_window.active = true
#@number_window.visible = true
@buy_window.active = false
@status_window.index = 0
@type = 1
@status_window.active = true
end
end
#--------------------------------------------------------------------------
# ● 画面更新 (卖出窗口激活的情况下)
#--------------------------------------------------------------------------
def update_sell
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 窗口状态转向初期模式
@command_window.active = true
@dummy_window.visible = true
@sell_window.active = false
@sell_window.visible = false
@status_window.item = nil
# 删除帮助文本
@help_window.set_text("")
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品
@item = @sell_window.item
# 设置状态窗口的物品
@status_window.item = @item
# 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
if @item == nil or @item.price == 0
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 卖出处理
$game_party.gain_gold(@item.price / 2)
case @item
when RPG::Item
$game_party.lose_item(@item.id, 1)
when RPG::Weapon
$game_party.lose_weapon(@item.id, 1)
when RPG::Armor
$game_party.lose_armor(@item.id, 1)
end
# 刷新各窗口
@gold_window.refresh
@sell_window.refresh
@status_window.refresh
end
end
end
物品詳細幫助窗口
#============================================================================== # 禾西製作 / Created by Quarcy #============================================================================== class Window_Help < Window_Base attr_reader :materia #-------------------------------------------------------------------------- # ● 定義不顯示的屬性與狀態 #-------------------------------------------------------------------------- def unshown @unshow_elements = [23,24] @unshow_states = [] end #-------------------------------------------------------------------------- # ● 初始化對象 #-------------------------------------------------------------------------- def initialize super(0, 0, 640, 64) self.opacity = 225 self.z=150 self.visible = false unless $scene.is_a?Scene_Shop or $scene.is_a?Scene_Battle or $scene.is_a?Scene_Item or $scene.is_a?Scene_Equip self.opacity = 0 end end #-------------------------------------------------------------------------- # ● 設置文本 # data : 窗口顯示的字符串/物品資料 # align : 對齊方式 (0..左對齊、1..中間對齊、2..右對齊) #-------------------------------------------------------------------------- def set_text(data, align=0) #------------------------------------------------------------------------ # ● 當資料爲文字時候 #------------------------------------------------------------------------ # 如果文本或對齊方式至少一方与上次的不同 if data != @text or align != @align if data.is_a?(String) # 再描繪文本 self.width = 640 self.height = 64 self.x=0 self.y=0 self.contents = Bitmap.new(width - 32, height - 32) if self.contents.nil? self.contents.clear self.contents.font.color = normal_color self.contents.font.size = 20 self.contents.draw_text(4, 0, self.width - 40, 32, data, align) @text = data @align = align @actor = nil self.visible = true end end return if data.is_a?(String) #------------------------------------------------------------------------ # ● 當沒有資料時候 #------------------------------------------------------------------------ if data.nil? self.visible=false else self.visible=true end #------------------------------------------------------------------------ # ● 當資料爲物品/技能時候 #------------------------------------------------------------------------ if data != nil && @data != data self.width = 210 self.height = 430 self.x=0 self.y=200 unshown non_auto_update(data) else return end end #-------------------------------------------------------------------------- # ● 更新帮助窗口 #-------------------------------------------------------------------------- def non_auto_update(data=@data) @data = data case @data when RPG::Item set_item_text(@data) when RPG::Weapon set_equipment_text(@data) when RPG::Armor set_equipment_text(@data) end end #-------------------------------------------------------------------------- # ● 裝備帮助窗口 #-------------------------------------------------------------------------- def set_equipment_text(equipment) #------------------------------------------------------------------------ # ● 取得基本質料 #------------------------------------------------------------------------ # 取得屬性、附加狀態、解除狀態之副本 case equipment when RPG::Weapon element_set = equipment.element_set.clone plus_state_set = equipment.plus_state_set.clone minus_state_set = equipment.minus_state_set.clone #----------------------# # 過濾不顯示的狀態描述 # #----------------------# plus_state_set -= @unshow_states minus_state_set -= @unshow_states when RPG::Armor element_set = equipment.guard_element_set.clone guard_state_set = equipment.guard_state_set.clone #----------------------# # 過濾不顯示的狀態描述 # #----------------------# auto_state_id = equipment.auto_state_id guard_state_set -= @unshow_states end #----------------------# # 過濾不顯示的屬性描述 # #----------------------# element_set -= @unshow_elements #--------------# # 取得說明文字 # #--------------# description = equipment.description.clone # 初始化數據設定 x = 0 y = 0 h = 0 phrase = {} # 基本文字設定 phrase["price"] = "价格:" phrase["elements"] = "属性:" phrase["minus_states"] = "解除状态:" phrase["plus_states"] = "附加状态:" phrase["guard_elements"] = "防御属性" phrase["guard_states"] = "防御状态" phrase["auto_state"] = "附加:" phrase["hp-max"] = "HP MAX:" # 基本數據設定 =begin name_size = 名字文字大小 size = 描述文字大小 word = 每行的描述文字數 move = 全體描述偏移幅度 =end name_size = 18 size = 14 word = 12 move = 80 #------------------------------------------------------------------------ # ● 確定背景圖片的高度 #------------------------------------------------------------------------ h += (description.size/3/word) h += 1 if (description.size/3%word) > 0 h += 1 if equipment.is_a?(RPG::Weapon) now_h = h h += 1 h += 1 unless equipment.pdef.zero? h += 1 unless equipment.mdef.zero? h += 1 if element_set.size > 0 h += 1 if element_set.size >= 5 case equipment when RPG::Weapon h += 1 unless minus_state_set.empty? h += minus_state_set.size h += 1 unless plus_state_set.empty? h += plus_state_set.size when RPG::Armor h += 1 unless guard_state_set.empty? h += guard_state_set.size h += 1 unless auto_state_id.zero? end h += 1 h += 1 unless equipment.str_plus.zero? h += 1 unless equipment.dex_plus.zero? h += 1 unless equipment.agi_plus.zero? h += 1 unless equipment.int_plus.zero? #h += 1 unless equipment.hp_plus.zero? h += materia_height_plus(equipment) unless self.materia.nil? #------------------------------------------------------------------------ # ● 圖片顯示保證高度 #------------------------------------------------------------------------ h = 6 + now_h if (h - now_h) < 6 #------------------------------------------------------------------------ # ● 換算高度 #------------------------------------------------------------------------ self.height = h * size + name_size + 100 #------------------------------------------------------------------------ # ● 生成背景 #------------------------------------------------------------------------ self.contents = Bitmap.new(self.width - 32, self.height - 32) self.contents.clear #------------------------------------------------------------------------ # ● 名字描繪 #------------------------------------------------------------------------ text = equipment.name self.contents.font.color = text_color(1)#(equipment.name_color) self.contents.font.size = name_size if text.nil? self.visible = false else self.visible = true self.contents.draw_text(0, 0, text.size*7, name_size, text, 0) end #------------------------------------------------------------------------ # ● 說明描繪 #------------------------------------------------------------------------ x = 0 y += 1 while ((text = description.slice!(/./m)) != nil) self.contents.font.color = system_color self.contents.font.size = size self.contents.draw_text(x*size, y*size+5, size, size, text, 0) x+=1 if x == word x=0 y+=1 end end #------------------------------------------------------------------------ # ● 圖標描繪 #------------------------------------------------------------------------ bitmap = RPG::Cache.icon(equipment.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(0 ,y*size + 20, bitmap, Rect.new(0, 0, 95, 100), 225) #------------------------------------------------------------------------ # ● 攻擊力描繪(武器) #------------------------------------------------------------------------ if equipment.is_a?(RPG::Weapon) x = 0 y += 1 text = $data_system.words.atk+":"+equipment.atk.to_s self.contents.font.color = Color.new(255, 0, 0, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end #------------------------------------------------------------------------ # ● 價格描繪 #------------------------------------------------------------------------ x = 0 y += 1 text = phrase["price"] + equipment.price.to_s self.contents.font.color = Color.new(255, 255, 0, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) #------------------------------------------------------------------------ # ● 物理防禦 #------------------------------------------------------------------------ unless equipment.pdef.zero? x = 0 y += 1 text = $data_system.words.pdef+":"+equipment.pdef.to_s self.contents.font.color = Color.new(0, 255, 255, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end #------------------------------------------------------------------------ # ● 魔法防禦 #------------------------------------------------------------------------ unless equipment.mdef.zero? x = 0 y += 1 text=$data_system.words.mdef+":"+equipment.mdef.to_s self.contents.font.color = Color.new(255, 0, 255, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end #------------------------------------------------------------------------ # ● 屬性 #------------------------------------------------------------------------ #------------------------------------------------------------------------ # ● 屬性 #------------------------------------------------------------------------ if element_set.size > 0 x = 0 y += 1 text = phrase["elements"] self.contents.font.size = size self.contents.font.color = Color.new(255, 0, 255, 255) self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) ax = (phrase["elements"].size)*5+40 for i in 0...element_set.size text = $data_system.elements[element_set[i]] self.contents.draw_text(ax, y*size+18, text.size*6, size, text, 0) y += 1 end end #------------------------------------------------------------------------ # ● 描述分流 武器/防具 #------------------------------------------------------------------------ case equipment when RPG::Weapon #------------------------------------------------------------------------ # ● 解除狀態(武器) #------------------------------------------------------------------------ unless minus_state_set.empty? x = 0 y += 1 text=phrase["minus_states"] text=phrase["guard_states"] self.contents.font.color = Color.new(0, 255, 255, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) for i in 0...minus_state_set.size y += 1 text = $data_states[minus_state_set[i]].name self.contents.font.color = Color.new(0, 255, 255, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end end #------------------------------------------------------------------------ # ● 附加狀態(武器) #------------------------------------------------------------------------ unless plus_state_set.empty? x = 0 y += 1 text = phrase["plus_states"] self.contents.font.color = Color.new(255, 0, 0, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) for i in 0...plus_state_set.size y += 1 text=$data_states[plus_state_set[i]].name self.contents.font.color = Color.new(255, 0, 0, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end end when RPG::Armor #------------------------------------------------------------------------ # ● 防禦狀態(防具) #------------------------------------------------------------------------ unless guard_state_set.empty? x = 0 y += 1 text=phrase["guard_states"] self.contents.font.color = Color.new(0, 255, 0, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) for i in 0...guard_state_set.size y += 1 text = $data_states[guard_state_set[i]].name self.contents.font.color = Color.new(0, 255, 0, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end end #------------------------------------------------------------------------ # ● 自動狀態(防具) #------------------------------------------------------------------------ unless auto_state_id.zero? x = 0 y += 1 text = phrase["auto_state"] + $data_states[auto_state_id].name self.contents.font.color = Color.new(0, 255, 0, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end end #------------------------------------------------------------------------ # ● 空行 #------------------------------------------------------------------------ y+=1 #------------------------------------------------------------------------ # ● 力量 #------------------------------------------------------------------------ unless equipment.str_plus.zero? x = 0 y += 1 h += 1 if equipment.str_plus > 0 text=$data_system.words.str+" +"+ equipment.str_plus.to_s else text=$data_system.words.str+" -"+ (-equipment.str_plus).to_s end self.contents.font.color = Color.new(255, 0, 0, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end #------------------------------------------------------------------------ # ● 靈巧 #------------------------------------------------------------------------ unless equipment.dex_plus.zero? x = 0 y += 1 h += 1 if equipment.dex_plus > 0 text=$data_system.words.dex+" +"+ equipment.dex_plus.to_s else text=$data_system.words.dex+" -"+ (-equipment.dex_plus).to_s end self.contents.font.color = Color.new(255, 255, 0, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end #------------------------------------------------------------------------ # ● 速度 #------------------------------------------------------------------------ unless equipment.agi_plus.zero? x = 0 y += 1 h += 1 if equipment.agi_plus > 0 text=$data_system.words.agi+" +"+ equipment.agi_plus.to_s else text=$data_system.words.agi+" -"+ (-equipment.agi_plus).to_s end self.contents.font.color = Color.new(0, 255, 255, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end #------------------------------------------------------------------------ # ● 智力 #------------------------------------------------------------------------ unless equipment.int_plus.zero? x = 0 y += 1 h += 1 if equipment.int_plus > 0 text=$data_system.words.int+" +"+ equipment.int_plus.to_s else text=$data_system.words.int+" -"+ (-equipment.int_plus).to_s end self.contents.font.color = Color.new(255, 0, 255, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end #------------------------------------------------------------------------ # ● HP MAX增加值 #------------------------------------------------------------------------ #unless equipment.hp_plus.zero? # x = 0 # y += 1 # h += 1 # if equipment.hp_plus > 0 # text=phrase["hp-max"]+" +"+ equipment.hp_plus.to_s # else # text=phrase["hp-max"]+" -"+ (-equipment.hp_plus).to_s # end # self.contents.font.color = normal_color # self.contents.font.size = size # self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) #end #------------------------------------------------------------------------ # ● 魔力石描繪 #------------------------------------------------------------------------ y += draw_materia(equipment, move, y, size) unless self.materia.nil? end #-------------------------------------------------------------------------- # ● 物品幫助窗口 #-------------------------------------------------------------------------- def set_item_text(item) # 取得描述 description = item.description.clone # 取得屬性、附加狀態、解除狀態之副本 element_set = item.element_set.clone plus_state_set = item.plus_state_set.clone minus_state_set = item.minus_state_set.clone # 過濾不顯示的描述 element_set -= @unshow_elements plus_state_set -= @unshow_states minus_state_set -= @unshow_states # 初始化數據設定 x = 0 y = 0 h = 0 phrase = {} scope ={} parameter_type = {} # 基本數據設定 =begin name_size = 名字文字大小 size = 描述文字大小 word = 每行的描述文字數 move = 全體描述偏移幅度 =end name_size = 18 size = 14 word = 12 move = 80 # 基本文字設定 phrase["scope"] = "范围:" phrase["price"] = "价格:" phrase["recover_hp_rate"] = "HP 回复率:" phrase["recover_hp"] = "HP 回复:" phrase["recover_sp_rate"] = "SP 回复率:" phrase["recover_sp"] = "SP 回复:" phrase["elements"] = "属性:" phrase["plus"] = "附加" phrase["minus"] = "解除" phrase["states"] = "状态" scope[0] = "特殊物品" scope[1] = "敌单体" scope[2] = "敌全体" scope[3] = "己方单体" scope[4] = "己方全体" scope[5] = "己方单体(HP=0)" scope[6] = "己方全体(HP=0)" scope[7] = "使用者" scope[8] = "使用者" parameter_type[1] = "MaxHP" parameter_type[2] = "MaxSP" parameter_type[3] = $data_system.words.str parameter_type[4] = $data_system.words.dex parameter_type[5] = $data_system.words.agi parameter_type[6] = $data_system.words.int #依顯示内容確定自身高 h = (description.size/3/word) h +=1 if (description.size/3%word)> 0 now_h = h h +=3 # 空行,效果範圍,價格 h += 1 unless item.recover_hp_rate.zero? h += 1 unless item.recover_hp.zero? h += 1 unless item.recover_sp_rate.zero? h += 1 unless item.recover_sp.zero? h += 1 unless item.parameter_type.zero? h += 1 unless element_set[0].nil? h += 1 unless element_set[4].nil? h += (1+plus_state_set.size) unless plus_state_set.empty? h += (1+minus_state_set.size) unless minus_state_set.empty? #------------------------------------------------------------------------ # ● 圖片顯示保證高度 #------------------------------------------------------------------------ h = 6 + now_h if (h - now_h) < 6 #------------------------------------------------------------------------ # ● 換算高度 #------------------------------------------------------------------------ self.height = h * size + name_size + 32 #------------------------------------------------------------------------ # ● 生成背景 #------------------------------------------------------------------------ self.contents = Bitmap.new(self.width - 32, self.height - 32) self.contents.clear #------------------------------------------------------------------------ # ● 名字描繪 #------------------------------------------------------------------------ text = item.name self.contents.font.color = Color.new(0, 0, 255, 255) self.contents.font.size = name_size if text.nil? self.visible = false else self.visible = true self.contents.draw_text(0,0, text.size*7, 20, text, 0) end #------------------------------------------------------------------------ # ● 說明描繪 #------------------------------------------------------------------------ x = 0 y += 1 while ((text = description.slice!(/./m)) != nil) self.contents.font.color = system_color self.contents.font.size = size self.contents.draw_text(x*size, y*size+5, size, size, text, 0) x+=1 if x == word x = 0 y += 1 end end #------------------------------------------------------------------------ # ● 圖標描繪 #------------------------------------------------------------------------ bitmap = RPG::Cache.icon(item.icon_name) unless item.icon_name.nil? opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(0 ,y*size + 20, bitmap, Rect.new(0, 0, 95, 100), 225) #------------------------------------------------------------------------ # ● 魔力石接口 #------------------------------------------------------------------------ unless self.materia.nil? return if is_materia?(item) end #------------------------------------------------------------------------ # ● 效果範圍 #------------------------------------------------------------------------ text= phrase["scope"] + scope[item.scope] x = 0 y += 1 self.contents.font.color = normal_color self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) #------------------------------------------------------------------------ # ● 價格 #------------------------------------------------------------------------ x = 0 y += 1 text = phrase["price"] + item.price.to_s self.contents.font.color = Color.new(255, 255, 0, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) #------------------------------------------------------------------------ # ● HP回復率 #------------------------------------------------------------------------ unless item.recover_hp_rate.zero? x = 0 y += 1 text = phrase["recover_hp_rate"] + item.recover_hp_rate.to_s+"%" self.contents.font.color = Color.new(255, 0, 0, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end #------------------------------------------------------------------------ # ● HP回復量 #------------------------------------------------------------------------ unless item.recover_hp.zero? x = 0 y += 1 text = phrase["recover_hp"] + item.recover_hp.to_s self.contents.font.color = Color.new(255, 0, 100, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end #------------------------------------------------------------------------ # ● SP回復率 #------------------------------------------------------------------------ unless item.recover_sp_rate.zero? x = 0 y += 1 text = phrase["recover_sp_rate"] + item.recover_sp_rate.to_s+"%" self.contents.font.color = Color.new(0, 0, 255, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end #------------------------------------------------------------------------ # ● SP回復量 #------------------------------------------------------------------------ unless item.recover_sp.zero? x = 0 y += 1 text = phrase["recover_sp"] + item.recover_sp.to_s self.contents.font.color = Color.new(0, 100, 255, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end #------------------------------------------------------------------------ # ● 能力值增加 #------------------------------------------------------------------------ unless item.parameter_type.zero? x = 0 y += 1 text= parameter_type[item.parameter_type]+" +"+item.parameter_points.to_s self.contents.font.color = Color.new(0, 255, 0, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end #------------------------------------------------------------------------ # ● 屬性 #------------------------------------------------------------------------ #------------------------------------------------------------------------ # ● 屬性 #------------------------------------------------------------------------ if element_set.size > 0 x = 0 y += 1 text = phrase["elements"] self.contents.font.size = size self.contents.font.color = Color.new(255, 0, 255, 255) self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) ax = (phrase["elements"].size)*5+40 for i in 0...element_set.size text = $data_system.elements[element_set[i]] self.contents.draw_text(ax, y*size+18, text.size*6, size, text, 0) y += 1 end end #------------------------------------------------------------------------ # ● 狀態添加 #------------------------------------------------------------------------ unless plus_state_set.empty? text = phrase["plus"] x = 0 y += 1 self.contents.font.color = normal_color self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) plus_state_set.each do |plus_state| y += 1 text = $data_states[plus_state].name self.contents.font.color = Color.new(255, 100, 0, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end end #------------------------------------------------------------------------ # ● 狀態解除 #------------------------------------------------------------------------ unless minus_state_set.empty? text = phrase["minus"] x = 0 y += 1 self.contents.font.color = Color.new(100, 0, 200, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) minus_state_set.each do |minus_state| y += 1 text = $data_states[minus_state].name self.contents.font.color = Color.new(100, 0, 200, 255) self.contents.font.size = size self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0) end end end #-------------------------------------------------------------------------- # ● 设置角色 # actor : 要显示状态的角色 #-------------------------------------------------------------------------- def set_actor(actor) if actor != @actor self.contents.clear draw_actor_name(actor, 4, 0) draw_actor_state(actor, 140, 0) draw_actor_hp(actor, 284, 0) draw_actor_sp(actor, 460, 0) @actor = actor @text = nil self.visible = true end end #-------------------------------------------------------------------------- # ● 設置角色 # actor : 要顯示狀態之角色 #-------------------------------------------------------------------------- def set_actor(actor) self.contents = Bitmap.new(width - 32, height - 32) if self.contents.nil? if actor != @actor self.contents.clear draw_actor_name(actor, 4, 0) draw_actor_state(actor, 140, 0) draw_actor_hp(actor, 284, 0) draw_actor_sp(actor, 460, 0) @actor = actor @text = nil self.visible = true end end #-------------------------------------------------------------------------- # ● 設置敵人 # enemy : 要顯示名字與狀態之敵人 #-------------------------------------------------------------------------- def set_enemy(enemy) self.contents = Bitmap.new(width - 32, height - 32) if self.contents.nil? text = enemy.name.sub(/\\[Ff]\[([0-9]+)\]/) {""} state_text = make_battler_state_text(enemy, 112, false) if state_text != "" text += " " + state_text end set_text(text, 1) self.visible = true end #-------------------------------------------------------------------------- # ● 校正帮助窗口位置 #-------------------------------------------------------------------------- def set_pos(x,y,width,oy,index,column_max) #光标坐标 cursor_width = width / column_max - 32 xx = index % column_max * (cursor_width + 32) yy = index / column_max * 32 - oy self.x=xx+x+150 self.y=yy+y+30 if self.x+self.width>640 self.x=640-self.width end if self.y+self.height>480 self.y=480-self.height end end #------------------------------------------------------------------------ # ● 裝備名字顔色變化 接口 #------------------------------------------------------------------------ def draw_name_color(equipment) return normal_color end #------------------------------------------------------------------------ # ● 自身身份確認 #------------------------------------------------------------------------ def original_help? return false end end #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ #============================================================================== # ■ Window_Item #------------------------------------------------------------------------------ # 物品画面、战斗画面、显示浏览物品的窗口。 #============================================================================== class Window_Item < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize super(0, 0, 640, 480) @column_max = 2 unless $scene.is_a?Scene_Battle self.opacity = 0#■■■透明 end refresh self.index = 0 # 战斗中的情况下将窗口移至中央并将其半透明化 if $game_temp.in_battle self.y = 64 self.height = 256 self.back_opacity = 160 end end #-------------------------------------------------------------------------- # ● 刷新帮助文本 #-------------------------------------------------------------------------- def update_help @help_window.set_text(item) #校正帮助窗口位置 @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max) end end #============================================================================== # ■ Window_EquipLeft #------------------------------------------------------------------------------ # 装备画面的、显示角色能力值变化的窗口。 #============================================================================== class Window_EquipLeft < Window_Base #-------------------------------------------------------------------------- # ● 初始化对像 # actor : 角色 #-------------------------------------------------------------------------- def initialize(actor) # ------------------- # 修改開始 super(0, 64-64, 272, 416+64)#★★★★★★★★★★★★★★★★★★★★ # 修改終了 # ------------------- self.contents = Bitmap.new(width - 32, height - 32) @actor = actor self.opacity = 0#■■■透明 refresh end end #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ #============================================================================== # ■ Window_EquipRight #------------------------------------------------------------------------------ # 装备画面、显示角色现在装备的物品的窗口。 #============================================================================== class Window_EquipRight < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 # actor : 角色 #-------------------------------------------------------------------------- def initialize(actor) # ------------------- # 修改開始 super(272, 64-64, 368, 192)#★★★★★★★★★★★★★★★★★★★★ # 修改終了 # ------------------- self.contents = Bitmap.new(width - 32, height - 32) @actor = actor self.opacity = 0#■■■透明 refresh self.index = 0 end #-------------------------------------------------------------------------- # ● 刷新帮助文本 #-------------------------------------------------------------------------- def update_help @help_window.set_text(item) #校正帮助窗口位置 @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max) end end #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ #============================================================================== # ■ Window_EquipItem #------------------------------------------------------------------------------ # 装备画面、显示浏览变更装备的候补物品的窗口。 #============================================================================== class Window_EquipItem < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 # actor : 角色 # equip_type : 装备部位 (0~3) #-------------------------------------------------------------------------- def initialize(actor, equip_type) # ------------------- # 修改開始 super(272, 320, 368, 160)#★★★★★★★★★★★★★★★★★★★★ # 修改終了 # ------------------- @actor = actor @equip_type = equip_type @column_max = 1 self.opacity = 0#■■■透明 refresh self.active = false self.index = -1 end def update_help @help_window.set_text(item) #校正帮助窗口位置 @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max) end end #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ #============================================================================== # ■ Window_ShopCommand #------------------------------------------------------------------------------ # 商店画面、选择要做的事的窗口 #============================================================================== class Window_ShopCommand < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize # ------------------- # 修改開始 super(0, 64-64, 480, 64)#★★★★★★★★★★★★★★★★★ # 修改終了 # ------------------- self.contents = Bitmap.new(width - 32, height - 32) @item_max = 3 @column_max = 3 @commands = ["买", "卖", "取消"] refresh self.index = 0 end end #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ #======================================================================================================================== # ■ Window_ShopBuy #------------------------------------------------------------------------------ # 商店画面、浏览显示可以购买的商品的窗口。 #============================================================================== class Window_ShopBuy < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 # shop_goods : 商品 #-------------------------------------------------------------------------- def initialize(shop_goods) # ------------------- # 修改開始 super(0, 128-64, 368, 352+64)#★★★★★★★★★★★★★★★★ # 修改終了 # ------------------- @shop_goods = shop_goods refresh self.index = 0 end #-------------------------------------------------------------------------- # ● 刷新帮助文本 #-------------------------------------------------------------------------- def update_help @help_window.set_text(item) #校正帮助窗口位置 @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max) end end #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ #============================================================================== # ■ Window_ShopSell #------------------------------------------------------------------------------ # 商店画面、浏览显示可以卖掉的商品的窗口。 #============================================================================== class Window_ShopSell < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize # ------------------- # 修改開始 super(0, 128-64, 640, 352+64)#★★★★★★★★★★★★★★★★ # 修改終了 # ------------------- @column_max = 2 refresh self.index = 0 end #-------------------------------------------------------------------------- # ● 刷新帮助文本 #-------------------------------------------------------------------------- def update_help @help_window.set_text(item) #校正帮助窗口位置 @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max) end end #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ #============================================================================== # ■ Window_ShopNumber #------------------------------------------------------------------------------ # 商店画面、输入买卖数量的窗口。 #============================================================================== class Window_ShopNumber < Window_Base #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize # ------------------- # 修改開始 super(0, 128-64, 368, 352+64)#★★★★★★★★★★★★★★★★ # 修改終了 # ------------------- self.contents = Bitmap.new(width - 32, height - 32) @item = nil @max = 1 @price = 0 @number = 1 end end #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ #============================================================================== # ■ Window_ShopStatus #------------------------------------------------------------------------------ # 商店画面、显示物品所持数与角色装备的窗口。 #============================================================================== class Window_ShopStatus < Window_Base #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize # ------------------- # 修改開始 super(368, 128-64, 272, 352+64)#★★★★★★★★★★★★ # 修改終了 # ------------------- self.contents = Bitmap.new(width - 32, height - 32) @item = nil refresh end end #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ #============================================================================== # ■ Scene_Equip #------------------------------------------------------------------------------ # 处理装备画面的类。 #============================================================================== class Scene_Equip #-------------------------------------------------------------------------- # ● 刷新画面 (右侧窗口被激活的情况下) #-------------------------------------------------------------------------- def update_right # ------------------- # 修改開始 if @right_window.item==nil @help_window.visible=false else @help_window.visible=true end # 修改終了 # ------------------- # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 切换到菜单画面 $scene = Scene_Menu.new(2) return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 固定装备的情况下 if @actor.equip_fix?(@right_window.index) # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 激活物品窗口 @right_window.active = false @item_window.active = true @item_window.index = 0 return end # 按下 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_Equip.new(@actor_index, @right_window.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_Equip.new(@actor_index, @right_window.index) return end end #-------------------------------------------------------------------------- # ● 刷新画面 (物品窗口被激活的情况下) #-------------------------------------------------------------------------- def update_item # ------------------- # 修改開始 if @item_window.item==nil @help_window.visible=false else @help_window.visible=true end # 修改終了 # ------------------- # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 激活右侧窗口 @right_window.active = true @item_window.active = false @item_window.index = -1 return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 演奏装备 SE $game_system.se_play($data_system.equip_se) # 获取物品窗口现在选择的装备数据 item = @item_window.item # 变更装备 @actor.equip(@right_window.index, item == nil ? 0 : item.id) # 激活右侧窗口 @right_window.active = true @item_window.active = false @item_window.index = -1 # 再生成右侧窗口、物品窗口的内容 @right_window.refresh @item_window.refresh @sprite.bitmap.clear @sprite.bitmap.draw_actor_element_radar_graph(@actor,16,255+16) return end end end #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ #======================================================================================================================== # ■ Scene_Battle (分割定义 3) #------------------------------------------------------------------------------ # 处理战斗画面的类。 #======================================================================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● 刷新画面 (角色命令回合 : 选择物品) #-------------------------------------------------------------------------- alias first_reupdate_phase3_item_select update_phase3_item_select def update_phase3_item_select # ------------------- # 修改開始 @item_window.help_window.visible = false#★★★★★★★★★★★★ # 修改終了 # ------------------- first_reupdate_phase3_item_select end #-------------------------------------------------------------------------- # ● 开始选择物品 #-------------------------------------------------------------------------- def start_item_select # 生成物品窗口 @item_window = Window_Item.new # 关联帮助窗口 # ------------------- # 修改開始 @item_window.help_window = Window_Help.new#★★★★★★★★★★★★ # 修改終了 # ------------------- # 无效化角色指令窗口 @actor_command_window.active = false @actor_command_window.visible = false end #-------------------------------------------------------------------------- # ● 结束选择物品 #-------------------------------------------------------------------------- alias first_update_end_item_select end_item_select def end_item_select # ------------------- # 修改開始 @item_window.help_window.visible = false#★★★★★★★★★★★★ # 修改終了 # ------------------- first_update_end_item_select end end #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ #============================================================================== # ■ Scene_Shop #------------------------------------------------------------------------------ # 处理商店画面的类。 #============================================================================== class Scene_Shop #-------------------------------------------------------------------------- # ● 主处理 #-------------------------------------------------------------------------- # -------------------- # 衝突可能 def main # 生成帮助窗口 # ------------------- # 修改開始 @help_window = Window_Help.new#★★★★★★★★★★★★★★★★ # 修改終了 # ------------------- # 生成指令窗口 @command_window = Window_ShopCommand.new # 生成金钱窗口 @gold_window = Window_Gold.new @gold_window.x = 480 @gold_window.y = 0 # ------------------- # 修改終了 # ------------------- # 生成时间窗口 # ------------------- # 修改開始 @dummy_window = Window_Base.new(0, 128-64, 640, 352+64)#★★★★★★★★★★★★★ # 修改終了 # ------------------- # 生成购买窗口 @buy_window = Window_ShopBuy.new($game_temp.shop_goods) @buy_window.active = false @buy_window.visible = false @buy_window.help_window = @help_window # 生成卖出窗口 @sell_window = Window_ShopSell.new @sell_window.active = false @sell_window.visible = false @sell_window.help_window = @help_window # 生成数量输入窗口 @number_window = Window_ShopNumber.new @number_window.active = false @number_window.visible = false # 生成状态窗口 @status_window = Window_ShopStatus.new @status_window.visible = false # 执行过渡 Graphics.transition # 主循环 loop do # 刷新游戏画面 Graphics.update # 刷新输入信息 Input.update # 刷新画面 update # 如果画面切换的话就中断循环 if $scene != self break end end # 准备过渡 Graphics.freeze # 释放窗口 @help_window.dispose @command_window.dispose @gold_window.dispose @dummy_window.dispose @buy_window.dispose @sell_window.dispose @number_window.dispose @status_window.dispose end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- # -------------------- # 衝突可能 def update # 刷新窗口 @help_window.update @command_window.update @gold_window.update @dummy_window.update @buy_window.update @sell_window.update @number_window.update @status_window.update # 指令窗口激活的情况下: 调用 update_command if @command_window.active # ------------------- # 修改開始 @help_window.visible=false # 修改終了 # ------------------- update_command return end # 购买窗口激活的情况下: 调用 update_buy if @buy_window.active # ------------------- # 修改開始 @help_window.visible=true#★★★★★★★★★★★★★★★★ if @buy_window.item==nil#★★★★★★★★★★★★★★★★ @help_window.visible=false#★★★★★★★★★★★★★★★★ end #★★★★★★★★★★★★★★★★ # 修改終了 # ------------------- update_buy return end # 卖出窗口激活的情况下: 调用 update_sell if @sell_window.active # ------------------- # 修改開始 @help_window.visible=true#★★★★★★★★★★★★★★★★ if @sell_window.item==nil#★★★★★★★★★★★★★★★★ @help_window.visible=false#★★★★★★★★★★★★★★★★ end #★★★★★★★★★★★★★★★★ # 修改終了 # ------------------- update_sell return end # 个数输入窗口激活的情况下: 调用 update_number if @number_window.active # ------------------- # 修改開始 @help_window.visible=false#★★★★★★★★★★★★★★★★ # 修改終了 # ------------------- update_number return end end end
#==============================================================================
# 禾西製作 / Created by Quarcy
#==============================================================================
class Window_Help < Window_Base
attr_reader :materia
#--------------------------------------------------------------------------
# ● 定義不顯示的屬性與狀態
#--------------------------------------------------------------------------
def unshown
@unshow_elements = [23,24]
@unshow_states = []
end
#--------------------------------------------------------------------------
# ● 初始化對象
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 64)
self.opacity = 225
self.z=150
self.visible = false
unless $scene.is_a?Scene_Shop or $scene.is_a?Scene_Battle or $scene.is_a?Scene_Item or $scene.is_a?Scene_Equip
self.opacity = 0
end
end
#--------------------------------------------------------------------------
# ● 設置文本
# data : 窗口顯示的字符串/物品資料
# align : 對齊方式 (0..左對齊、1..中間對齊、2..右對齊)
#--------------------------------------------------------------------------
def set_text(data, align=0)
#------------------------------------------------------------------------
# ● 當資料爲文字時候
#------------------------------------------------------------------------
# 如果文本或對齊方式至少一方与上次的不同
if data != @text or align != @align
if data.is_a?(String)
# 再描繪文本
self.width = 640
self.height = 64
self.x=0
self.y=0
self.contents = Bitmap.new(width - 32, height - 32) if self.contents.nil?
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
self.contents.draw_text(4, 0, self.width - 40, 32, data, align)
@text = data
@align = align
@actor = nil
self.visible = true
end
end
return if data.is_a?(String)
#------------------------------------------------------------------------
# ● 當沒有資料時候
#------------------------------------------------------------------------
if data.nil?
self.visible=false
else
self.visible=true
end
#------------------------------------------------------------------------
# ● 當資料爲物品/技能時候
#------------------------------------------------------------------------
if data != nil && @data != data
self.width = 210
self.height = 430
self.x=0
self.y=200
unshown
non_auto_update(data)
else
return
end
end
#--------------------------------------------------------------------------
# ● 更新帮助窗口
#--------------------------------------------------------------------------
def non_auto_update(data=@data)
@data = data
case @data
when RPG::Item
set_item_text(@data)
when RPG::Weapon
set_equipment_text(@data)
when RPG::Armor
set_equipment_text(@data)
end
end
#--------------------------------------------------------------------------
# ● 裝備帮助窗口
#--------------------------------------------------------------------------
def set_equipment_text(equipment)
#------------------------------------------------------------------------
# ● 取得基本質料
#------------------------------------------------------------------------
# 取得屬性、附加狀態、解除狀態之副本
case equipment
when RPG::Weapon
element_set = equipment.element_set.clone
plus_state_set = equipment.plus_state_set.clone
minus_state_set = equipment.minus_state_set.clone
#----------------------#
# 過濾不顯示的狀態描述 #
#----------------------#
plus_state_set -= @unshow_states
minus_state_set -= @unshow_states
when RPG::Armor
element_set = equipment.guard_element_set.clone
guard_state_set = equipment.guard_state_set.clone
#----------------------#
# 過濾不顯示的狀態描述 #
#----------------------#
auto_state_id = equipment.auto_state_id
guard_state_set -= @unshow_states
end
#----------------------#
# 過濾不顯示的屬性描述 #
#----------------------#
element_set -= @unshow_elements
#--------------#
# 取得說明文字 #
#--------------#
description = equipment.description.clone
# 初始化數據設定
x = 0
y = 0
h = 0
phrase = {}
# 基本文字設定
phrase["price"] = "价格:"
phrase["elements"] = "属性:"
phrase["minus_states"] = "解除状态:"
phrase["plus_states"] = "附加状态:"
phrase["guard_elements"] = "防御属性"
phrase["guard_states"] = "防御状态"
phrase["auto_state"] = "附加:"
phrase["hp-max"] = "HP MAX:"
# 基本數據設定
=begin
name_size = 名字文字大小
size = 描述文字大小
word = 每行的描述文字數
move = 全體描述偏移幅度
=end
name_size = 18
size = 14
word = 12
move = 80
#------------------------------------------------------------------------
# ● 確定背景圖片的高度
#------------------------------------------------------------------------
h += (description.size/3/word)
h += 1 if (description.size/3%word) > 0
h += 1 if equipment.is_a?(RPG::Weapon)
now_h = h
h += 1
h += 1 unless equipment.pdef.zero?
h += 1 unless equipment.mdef.zero?
h += 1 if element_set.size > 0
h += 1 if element_set.size >= 5
case equipment
when RPG::Weapon
h += 1 unless minus_state_set.empty?
h += minus_state_set.size
h += 1 unless plus_state_set.empty?
h += plus_state_set.size
when RPG::Armor
h += 1 unless guard_state_set.empty?
h += guard_state_set.size
h += 1 unless auto_state_id.zero?
end
h += 1
h += 1 unless equipment.str_plus.zero?
h += 1 unless equipment.dex_plus.zero?
h += 1 unless equipment.agi_plus.zero?
h += 1 unless equipment.int_plus.zero?
#h += 1 unless equipment.hp_plus.zero?
h += materia_height_plus(equipment) unless self.materia.nil?
#------------------------------------------------------------------------
# ● 圖片顯示保證高度
#------------------------------------------------------------------------
h = 6 + now_h if (h - now_h) < 6
#------------------------------------------------------------------------
# ● 換算高度
#------------------------------------------------------------------------
self.height = h * size + name_size + 100
#------------------------------------------------------------------------
# ● 生成背景
#------------------------------------------------------------------------
self.contents = Bitmap.new(self.width - 32, self.height - 32)
self.contents.clear
#------------------------------------------------------------------------
# ● 名字描繪
#------------------------------------------------------------------------
text = equipment.name
self.contents.font.color = text_color(1)#(equipment.name_color)
self.contents.font.size = name_size
if text.nil?
self.visible = false
else
self.visible = true
self.contents.draw_text(0, 0, text.size*7, name_size, text, 0)
end
#------------------------------------------------------------------------
# ● 說明描繪
#------------------------------------------------------------------------
x = 0
y += 1
while ((text = description.slice!(/./m)) != nil)
self.contents.font.color = system_color
self.contents.font.size = size
self.contents.draw_text(x*size, y*size+5, size, size, text, 0)
x+=1
if x == word
x=0
y+=1
end
end
#------------------------------------------------------------------------
# ● 圖標描繪
#------------------------------------------------------------------------
bitmap = RPG::Cache.icon(equipment.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(0 ,y*size + 20, bitmap, Rect.new(0, 0, 95, 100), 225)
#------------------------------------------------------------------------
# ● 攻擊力描繪(武器)
#------------------------------------------------------------------------
if equipment.is_a?(RPG::Weapon)
x = 0
y += 1
text = $data_system.words.atk+":"+equipment.atk.to_s
self.contents.font.color = Color.new(255, 0, 0, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
#------------------------------------------------------------------------
# ● 價格描繪
#------------------------------------------------------------------------
x = 0
y += 1
text = phrase["price"] + equipment.price.to_s
self.contents.font.color = Color.new(255, 255, 0, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
#------------------------------------------------------------------------
# ● 物理防禦
#------------------------------------------------------------------------
unless equipment.pdef.zero?
x = 0
y += 1
text = $data_system.words.pdef+":"+equipment.pdef.to_s
self.contents.font.color = Color.new(0, 255, 255, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
#------------------------------------------------------------------------
# ● 魔法防禦
#------------------------------------------------------------------------
unless equipment.mdef.zero?
x = 0
y += 1
text=$data_system.words.mdef+":"+equipment.mdef.to_s
self.contents.font.color = Color.new(255, 0, 255, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
#------------------------------------------------------------------------
# ● 屬性
#------------------------------------------------------------------------
#------------------------------------------------------------------------
# ● 屬性
#------------------------------------------------------------------------
if element_set.size > 0
x = 0
y += 1
text = phrase["elements"]
self.contents.font.size = size
self.contents.font.color = Color.new(255, 0, 255, 255)
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
ax = (phrase["elements"].size)*5+40
for i in 0...element_set.size
text = $data_system.elements[element_set[i]]
self.contents.draw_text(ax, y*size+18, text.size*6, size, text, 0)
y += 1
end
end
#------------------------------------------------------------------------
# ● 描述分流 武器/防具
#------------------------------------------------------------------------
case equipment
when RPG::Weapon
#------------------------------------------------------------------------
# ● 解除狀態(武器)
#------------------------------------------------------------------------
unless minus_state_set.empty?
x = 0
y += 1
text=phrase["minus_states"]
text=phrase["guard_states"]
self.contents.font.color = Color.new(0, 255, 255, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
for i in 0...minus_state_set.size
y += 1
text = $data_states[minus_state_set[i]].name
self.contents.font.color = Color.new(0, 255, 255, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
end
#------------------------------------------------------------------------
# ● 附加狀態(武器)
#------------------------------------------------------------------------
unless plus_state_set.empty?
x = 0
y += 1
text = phrase["plus_states"]
self.contents.font.color = Color.new(255, 0, 0, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
for i in 0...plus_state_set.size
y += 1
text=$data_states[plus_state_set[i]].name
self.contents.font.color = Color.new(255, 0, 0, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
end
when RPG::Armor
#------------------------------------------------------------------------
# ● 防禦狀態(防具)
#------------------------------------------------------------------------
unless guard_state_set.empty?
x = 0
y += 1
text=phrase["guard_states"]
self.contents.font.color = Color.new(0, 255, 0, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
for i in 0...guard_state_set.size
y += 1
text = $data_states[guard_state_set[i]].name
self.contents.font.color = Color.new(0, 255, 0, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
end
#------------------------------------------------------------------------
# ● 自動狀態(防具)
#------------------------------------------------------------------------
unless auto_state_id.zero?
x = 0
y += 1
text = phrase["auto_state"] + $data_states[auto_state_id].name
self.contents.font.color = Color.new(0, 255, 0, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
end
#------------------------------------------------------------------------
# ● 空行
#------------------------------------------------------------------------
y+=1
#------------------------------------------------------------------------
# ● 力量
#------------------------------------------------------------------------
unless equipment.str_plus.zero?
x = 0
y += 1
h += 1
if equipment.str_plus > 0
text=$data_system.words.str+" +"+ equipment.str_plus.to_s
else
text=$data_system.words.str+" -"+ (-equipment.str_plus).to_s
end
self.contents.font.color = Color.new(255, 0, 0, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
#------------------------------------------------------------------------
# ● 靈巧
#------------------------------------------------------------------------
unless equipment.dex_plus.zero?
x = 0
y += 1
h += 1
if equipment.dex_plus > 0
text=$data_system.words.dex+" +"+ equipment.dex_plus.to_s
else
text=$data_system.words.dex+" -"+ (-equipment.dex_plus).to_s
end
self.contents.font.color = Color.new(255, 255, 0, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
#------------------------------------------------------------------------
# ● 速度
#------------------------------------------------------------------------
unless equipment.agi_plus.zero?
x = 0
y += 1
h += 1
if equipment.agi_plus > 0
text=$data_system.words.agi+" +"+ equipment.agi_plus.to_s
else
text=$data_system.words.agi+" -"+ (-equipment.agi_plus).to_s
end
self.contents.font.color = Color.new(0, 255, 255, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
#------------------------------------------------------------------------
# ● 智力
#------------------------------------------------------------------------
unless equipment.int_plus.zero?
x = 0
y += 1
h += 1
if equipment.int_plus > 0
text=$data_system.words.int+" +"+ equipment.int_plus.to_s
else
text=$data_system.words.int+" -"+ (-equipment.int_plus).to_s
end
self.contents.font.color = Color.new(255, 0, 255, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
#------------------------------------------------------------------------
# ● HP MAX增加值
#------------------------------------------------------------------------
#unless equipment.hp_plus.zero?
# x = 0
# y += 1
# h += 1
# if equipment.hp_plus > 0
# text=phrase["hp-max"]+" +"+ equipment.hp_plus.to_s
# else
# text=phrase["hp-max"]+" -"+ (-equipment.hp_plus).to_s
# end
# self.contents.font.color = normal_color
# self.contents.font.size = size
# self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
#end
#------------------------------------------------------------------------
# ● 魔力石描繪
#------------------------------------------------------------------------
y += draw_materia(equipment, move, y, size) unless self.materia.nil?
end
#--------------------------------------------------------------------------
# ● 物品幫助窗口
#--------------------------------------------------------------------------
def set_item_text(item)
# 取得描述
description = item.description.clone
# 取得屬性、附加狀態、解除狀態之副本
element_set = item.element_set.clone
plus_state_set = item.plus_state_set.clone
minus_state_set = item.minus_state_set.clone
# 過濾不顯示的描述
element_set -= @unshow_elements
plus_state_set -= @unshow_states
minus_state_set -= @unshow_states
# 初始化數據設定
x = 0
y = 0
h = 0
phrase = {}
scope ={}
parameter_type = {}
# 基本數據設定
=begin
name_size = 名字文字大小
size = 描述文字大小
word = 每行的描述文字數
move = 全體描述偏移幅度
=end
name_size = 18
size = 14
word = 12
move = 80
# 基本文字設定
phrase["scope"] = "范围:"
phrase["price"] = "价格:"
phrase["recover_hp_rate"] = "HP 回复率:"
phrase["recover_hp"] = "HP 回复:"
phrase["recover_sp_rate"] = "SP 回复率:"
phrase["recover_sp"] = "SP 回复:"
phrase["elements"] = "属性:"
phrase["plus"] = "附加"
phrase["minus"] = "解除"
phrase["states"] = "状态"
scope[0] = "特殊物品"
scope[1] = "敌单体"
scope[2] = "敌全体"
scope[3] = "己方单体"
scope[4] = "己方全体"
scope[5] = "己方单体(HP=0)"
scope[6] = "己方全体(HP=0)"
scope[7] = "使用者"
scope[8] = "使用者"
parameter_type[1] = "MaxHP"
parameter_type[2] = "MaxSP"
parameter_type[3] = $data_system.words.str
parameter_type[4] = $data_system.words.dex
parameter_type[5] = $data_system.words.agi
parameter_type[6] = $data_system.words.int
#依顯示内容確定自身高
h = (description.size/3/word)
h +=1 if (description.size/3%word)> 0
now_h = h
h +=3 # 空行,效果範圍,價格
h += 1 unless item.recover_hp_rate.zero?
h += 1 unless item.recover_hp.zero?
h += 1 unless item.recover_sp_rate.zero?
h += 1 unless item.recover_sp.zero?
h += 1 unless item.parameter_type.zero?
h += 1 unless element_set[0].nil?
h += 1 unless element_set[4].nil?
h += (1+plus_state_set.size) unless plus_state_set.empty?
h += (1+minus_state_set.size) unless minus_state_set.empty?
#------------------------------------------------------------------------
# ● 圖片顯示保證高度
#------------------------------------------------------------------------
h = 6 + now_h if (h - now_h) < 6
#------------------------------------------------------------------------
# ● 換算高度
#------------------------------------------------------------------------
self.height = h * size + name_size + 32
#------------------------------------------------------------------------
# ● 生成背景
#------------------------------------------------------------------------
self.contents = Bitmap.new(self.width - 32, self.height - 32)
self.contents.clear
#------------------------------------------------------------------------
# ● 名字描繪
#------------------------------------------------------------------------
text = item.name
self.contents.font.color = Color.new(0, 0, 255, 255)
self.contents.font.size = name_size
if text.nil?
self.visible = false
else
self.visible = true
self.contents.draw_text(0,0, text.size*7, 20, text, 0)
end
#------------------------------------------------------------------------
# ● 說明描繪
#------------------------------------------------------------------------
x = 0
y += 1
while ((text = description.slice!(/./m)) != nil)
self.contents.font.color = system_color
self.contents.font.size = size
self.contents.draw_text(x*size, y*size+5, size, size, text, 0)
x+=1
if x == word
x = 0
y += 1
end
end
#------------------------------------------------------------------------
# ● 圖標描繪
#------------------------------------------------------------------------
bitmap = RPG::Cache.icon(item.icon_name) unless item.icon_name.nil?
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(0 ,y*size + 20, bitmap, Rect.new(0, 0, 95, 100), 225)
#------------------------------------------------------------------------
# ● 魔力石接口
#------------------------------------------------------------------------
unless self.materia.nil?
return if is_materia?(item)
end
#------------------------------------------------------------------------
# ● 效果範圍
#------------------------------------------------------------------------
text= phrase["scope"] + scope[item.scope]
x = 0
y += 1
self.contents.font.color = normal_color
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
#------------------------------------------------------------------------
# ● 價格
#------------------------------------------------------------------------
x = 0
y += 1
text = phrase["price"] + item.price.to_s
self.contents.font.color = Color.new(255, 255, 0, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
#------------------------------------------------------------------------
# ● HP回復率
#------------------------------------------------------------------------
unless item.recover_hp_rate.zero?
x = 0
y += 1
text = phrase["recover_hp_rate"] + item.recover_hp_rate.to_s+"%"
self.contents.font.color = Color.new(255, 0, 0, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
#------------------------------------------------------------------------
# ● HP回復量
#------------------------------------------------------------------------
unless item.recover_hp.zero?
x = 0
y += 1
text = phrase["recover_hp"] + item.recover_hp.to_s
self.contents.font.color = Color.new(255, 0, 100, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
#------------------------------------------------------------------------
# ● SP回復率
#------------------------------------------------------------------------
unless item.recover_sp_rate.zero?
x = 0
y += 1
text = phrase["recover_sp_rate"] + item.recover_sp_rate.to_s+"%"
self.contents.font.color = Color.new(0, 0, 255, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
#------------------------------------------------------------------------
# ● SP回復量
#------------------------------------------------------------------------
unless item.recover_sp.zero?
x = 0
y += 1
text = phrase["recover_sp"] + item.recover_sp.to_s
self.contents.font.color = Color.new(0, 100, 255, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
#------------------------------------------------------------------------
# ● 能力值增加
#------------------------------------------------------------------------
unless item.parameter_type.zero?
x = 0
y += 1
text= parameter_type[item.parameter_type]+" +"+item.parameter_points.to_s
self.contents.font.color = Color.new(0, 255, 0, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
#------------------------------------------------------------------------
# ● 屬性
#------------------------------------------------------------------------
#------------------------------------------------------------------------
# ● 屬性
#------------------------------------------------------------------------
if element_set.size > 0
x = 0
y += 1
text = phrase["elements"]
self.contents.font.size = size
self.contents.font.color = Color.new(255, 0, 255, 255)
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
ax = (phrase["elements"].size)*5+40
for i in 0...element_set.size
text = $data_system.elements[element_set[i]]
self.contents.draw_text(ax, y*size+18, text.size*6, size, text, 0)
y += 1
end
end
#------------------------------------------------------------------------
# ● 狀態添加
#------------------------------------------------------------------------
unless plus_state_set.empty?
text = phrase["plus"]
x = 0
y += 1
self.contents.font.color = normal_color
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
plus_state_set.each do |plus_state|
y += 1
text = $data_states[plus_state].name
self.contents.font.color = Color.new(255, 100, 0, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
end
#------------------------------------------------------------------------
# ● 狀態解除
#------------------------------------------------------------------------
unless minus_state_set.empty?
text = phrase["minus"]
x = 0
y += 1
self.contents.font.color = Color.new(100, 0, 200, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
minus_state_set.each do |minus_state|
y += 1
text = $data_states[minus_state].name
self.contents.font.color = Color.new(100, 0, 200, 255)
self.contents.font.size = size
self.contents.draw_text(x+move, y*size+5, text.size*6, size, text, 0)
end
end
end
#--------------------------------------------------------------------------
# ● 设置角色
# actor : 要显示状态的角色
#--------------------------------------------------------------------------
def set_actor(actor)
if actor != @actor
self.contents.clear
draw_actor_name(actor, 4, 0)
draw_actor_state(actor, 140, 0)
draw_actor_hp(actor, 284, 0)
draw_actor_sp(actor, 460, 0)
@actor = actor
@text = nil
self.visible = true
end
end
#--------------------------------------------------------------------------
# ● 設置角色
# actor : 要顯示狀態之角色
#--------------------------------------------------------------------------
def set_actor(actor)
self.contents = Bitmap.new(width - 32, height - 32) if self.contents.nil?
if actor != @actor
self.contents.clear
draw_actor_name(actor, 4, 0)
draw_actor_state(actor, 140, 0)
draw_actor_hp(actor, 284, 0)
draw_actor_sp(actor, 460, 0)
@actor = actor
@text = nil
self.visible = true
end
end
#--------------------------------------------------------------------------
# ● 設置敵人
# enemy : 要顯示名字與狀態之敵人
#--------------------------------------------------------------------------
def set_enemy(enemy)
self.contents = Bitmap.new(width - 32, height - 32) if self.contents.nil?
text = enemy.name.sub(/\\[Ff]\[([0-9]+)\]/) {""}
state_text = make_battler_state_text(enemy, 112, false)
if state_text != ""
text += " " + state_text
end
set_text(text, 1)
self.visible = true
end
#--------------------------------------------------------------------------
# ● 校正帮助窗口位置
#--------------------------------------------------------------------------
def set_pos(x,y,width,oy,index,column_max)
#光标坐标
cursor_width = width / column_max - 32
xx = index % column_max * (cursor_width + 32)
yy = index / column_max * 32 - oy
self.x=xx+x+150
self.y=yy+y+30
if self.x+self.width>640
self.x=640-self.width
end
if self.y+self.height>480
self.y=480-self.height
end
end
#------------------------------------------------------------------------
# ● 裝備名字顔色變化 接口
#------------------------------------------------------------------------
def draw_name_color(equipment)
return normal_color
end
#------------------------------------------------------------------------
# ● 自身身份確認
#------------------------------------------------------------------------
def original_help?
return false
end
end
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#==============================================================================
# ■ Window_Item
#------------------------------------------------------------------------------
# 物品画面、战斗画面、显示浏览物品的窗口。
#==============================================================================
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 480)
@column_max = 2
unless $scene.is_a?Scene_Battle
self.opacity = 0#■■■透明
end
refresh
self.index = 0
# 战斗中的情况下将窗口移至中央并将其半透明化
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item)
#校正帮助窗口位置
@help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
end
end
#==============================================================================
# ■ Window_EquipLeft
#------------------------------------------------------------------------------
# 装备画面的、显示角色能力值变化的窗口。
#==============================================================================
class Window_EquipLeft < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
#--------------------------------------------------------------------------
def initialize(actor)
# -------------------
# 修改開始
super(0, 64-64, 272, 416+64)#★★★★★★★★★★★★★★★★★★★★
# 修改終了
# -------------------
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
self.opacity = 0#■■■透明
refresh
end
end
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#==============================================================================
# ■ Window_EquipRight
#------------------------------------------------------------------------------
# 装备画面、显示角色现在装备的物品的窗口。
#==============================================================================
class Window_EquipRight < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
#--------------------------------------------------------------------------
def initialize(actor)
# -------------------
# 修改開始
super(272, 64-64, 368, 192)#★★★★★★★★★★★★★★★★★★★★
# 修改終了
# -------------------
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
self.opacity = 0#■■■透明
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item)
#校正帮助窗口位置
@help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
end
end
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#==============================================================================
# ■ Window_EquipItem
#------------------------------------------------------------------------------
# 装备画面、显示浏览变更装备的候补物品的窗口。
#==============================================================================
class Window_EquipItem < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
# equip_type : 装备部位 (0~3)
#--------------------------------------------------------------------------
def initialize(actor, equip_type)
# -------------------
# 修改開始
super(272, 320, 368, 160)#★★★★★★★★★★★★★★★★★★★★
# 修改終了
# -------------------
@actor = actor
@equip_type = equip_type
@column_max = 1
self.opacity = 0#■■■透明
refresh
self.active = false
self.index = -1
end
def update_help
@help_window.set_text(item)
#校正帮助窗口位置
@help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
end
end
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#==============================================================================
# ■ Window_ShopCommand
#------------------------------------------------------------------------------
# 商店画面、选择要做的事的窗口
#==============================================================================
class Window_ShopCommand < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
# -------------------
# 修改開始
super(0, 64-64, 480, 64)#★★★★★★★★★★★★★★★★★
# 修改終了
# -------------------
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = 3
@column_max = 3
@commands = ["买", "卖", "取消"]
refresh
self.index = 0
end
end
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#========================================================================================================================
# ■ Window_ShopBuy
#------------------------------------------------------------------------------
# 商店画面、浏览显示可以购买的商品的窗口。
#==============================================================================
class Window_ShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# shop_goods : 商品
#--------------------------------------------------------------------------
def initialize(shop_goods)
# -------------------
# 修改開始
super(0, 128-64, 368, 352+64)#★★★★★★★★★★★★★★★★
# 修改終了
# -------------------
@shop_goods = shop_goods
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item)
#校正帮助窗口位置
@help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
end
end
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#==============================================================================
# ■ Window_ShopSell
#------------------------------------------------------------------------------
# 商店画面、浏览显示可以卖掉的商品的窗口。
#==============================================================================
class Window_ShopSell < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
# -------------------
# 修改開始
super(0, 128-64, 640, 352+64)#★★★★★★★★★★★★★★★★
# 修改終了
# -------------------
@column_max = 2
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item)
#校正帮助窗口位置
@help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
end
end
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#==============================================================================
# ■ Window_ShopNumber
#------------------------------------------------------------------------------
# 商店画面、输入买卖数量的窗口。
#==============================================================================
class Window_ShopNumber < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
# -------------------
# 修改開始
super(0, 128-64, 368, 352+64)#★★★★★★★★★★★★★★★★
# 修改終了
# -------------------
self.contents = Bitmap.new(width - 32, height - 32)
@item = nil
@max = 1
@price = 0
@number = 1
end
end
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#==============================================================================
# ■ Window_ShopStatus
#------------------------------------------------------------------------------
# 商店画面、显示物品所持数与角色装备的窗口。
#==============================================================================
class Window_ShopStatus < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
# -------------------
# 修改開始
super(368, 128-64, 272, 352+64)#★★★★★★★★★★★★
# 修改終了
# -------------------
self.contents = Bitmap.new(width - 32, height - 32)
@item = nil
refresh
end
end
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#==============================================================================
# ■ Scene_Equip
#------------------------------------------------------------------------------
# 处理装备画面的类。
#==============================================================================
class Scene_Equip
#--------------------------------------------------------------------------
# ● 刷新画面 (右侧窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_right
# -------------------
# 修改開始
if @right_window.item==nil
@help_window.visible=false
else
@help_window.visible=true
end
# 修改終了
# -------------------
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(2)
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 固定装备的情况下
if @actor.equip_fix?(@right_window.index)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活物品窗口
@right_window.active = false
@item_window.active = true
@item_window.index = 0
return
end
# 按下 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_Equip.new(@actor_index, @right_window.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_Equip.new(@actor_index, @right_window.index)
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (物品窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_item
# -------------------
# 修改開始
if @item_window.item==nil
@help_window.visible=false
else
@help_window.visible=true
end
# 修改終了
# -------------------
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 激活右侧窗口
@right_window.active = true
@item_window.active = false
@item_window.index = -1
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 演奏装备 SE
$game_system.se_play($data_system.equip_se)
# 获取物品窗口现在选择的装备数据
item = @item_window.item
# 变更装备
@actor.equip(@right_window.index, item == nil ? 0 : item.id)
# 激活右侧窗口
@right_window.active = true
@item_window.active = false
@item_window.index = -1
# 再生成右侧窗口、物品窗口的内容
@right_window.refresh
@item_window.refresh
@sprite.bitmap.clear
@sprite.bitmap.draw_actor_element_radar_graph(@actor,16,255+16)
return
end
end
end
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#========================================================================================================================
# ■ Scene_Battle (分割定义 3)
#------------------------------------------------------------------------------
# 处理战斗画面的类。
#========================================================================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● 刷新画面 (角色命令回合 : 选择物品)
#--------------------------------------------------------------------------
alias first_reupdate_phase3_item_select update_phase3_item_select
def update_phase3_item_select
# -------------------
# 修改開始
@item_window.help_window.visible = false#★★★★★★★★★★★★
# 修改終了
# -------------------
first_reupdate_phase3_item_select
end
#--------------------------------------------------------------------------
# ● 开始选择物品
#--------------------------------------------------------------------------
def start_item_select
# 生成物品窗口
@item_window = Window_Item.new
# 关联帮助窗口
# -------------------
# 修改開始
@item_window.help_window = Window_Help.new#★★★★★★★★★★★★
# 修改終了
# -------------------
# 无效化角色指令窗口
@actor_command_window.active = false
@actor_command_window.visible = false
end
#--------------------------------------------------------------------------
# ● 结束选择物品
#--------------------------------------------------------------------------
alias first_update_end_item_select end_item_select
def end_item_select
# -------------------
# 修改開始
@item_window.help_window.visible = false#★★★★★★★★★★★★
# 修改終了
# -------------------
first_update_end_item_select
end
end
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
#==============================================================================
# ■ Scene_Shop
#------------------------------------------------------------------------------
# 处理商店画面的类。
#==============================================================================
class Scene_Shop
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
# --------------------
# 衝突可能
def main
# 生成帮助窗口
# -------------------
# 修改開始
@help_window = Window_Help.new#★★★★★★★★★★★★★★★★
# 修改終了
# -------------------
# 生成指令窗口
@command_window = Window_ShopCommand.new
# 生成金钱窗口
@gold_window = Window_Gold.new
@gold_window.x = 480
@gold_window.y = 0
# -------------------
# 修改終了
# -------------------
# 生成时间窗口
# -------------------
# 修改開始
@dummy_window = Window_Base.new(0, 128-64, 640, 352+64)#★★★★★★★★★★★★★
# 修改終了
# -------------------
# 生成购买窗口
@buy_window = Window_ShopBuy.new($game_temp.shop_goods)
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
# 生成卖出窗口
@sell_window = Window_ShopSell.new
@sell_window.active = false
@sell_window.visible = false
@sell_window.help_window = @help_window
# 生成数量输入窗口
@number_window = Window_ShopNumber.new
@number_window.active = false
@number_window.visible = false
# 生成状态窗口
@status_window = Window_ShopStatus.new
@status_window.visible = false
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
@command_window.dispose
@gold_window.dispose
@dummy_window.dispose
@buy_window.dispose
@sell_window.dispose
@number_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
# --------------------
# 衝突可能
def update
# 刷新窗口
@help_window.update
@command_window.update
@gold_window.update
@dummy_window.update
@buy_window.update
@sell_window.update
@number_window.update
@status_window.update
# 指令窗口激活的情况下: 调用 update_command
if @command_window.active
# -------------------
# 修改開始
@help_window.visible=false
# 修改終了
# -------------------
update_command
return
end
# 购买窗口激活的情况下: 调用 update_buy
if @buy_window.active
# -------------------
# 修改開始
@help_window.visible=true#★★★★★★★★★★★★★★★★
if @buy_window.item==nil#★★★★★★★★★★★★★★★★
@help_window.visible=false#★★★★★★★★★★★★★★★★
end #★★★★★★★★★★★★★★★★
# 修改終了
# -------------------
update_buy
return
end
# 卖出窗口激活的情况下: 调用 update_sell
if @sell_window.active
# -------------------
# 修改開始
@help_window.visible=true#★★★★★★★★★★★★★★★★
if @sell_window.item==nil#★★★★★★★★★★★★★★★★
@help_window.visible=false#★★★★★★★★★★★★★★★★
end #★★★★★★★★★★★★★★★★
# 修改終了
# -------------------
update_sell
return
end
# 个数输入窗口激活的情况下: 调用 update_number
if @number_window.active
# -------------------
# 修改開始
@help_window.visible=false#★★★★★★★★★★★★★★★★
# 修改終了
# -------------------
update_number
return
end
end
end
|
|