#======================================================= # 本脚本来自66RPG.COM,作者神思 # 转载、学习和使用请保留此声明,谢谢 ^_^ #======================================================= module RPG class Armor def name name = @name.split(/@/)[0] return name != nil ? name : '' end def sk_exp exp = @name.split(/@/)[1] return exp != nil ? exp.to_i : 0 end def sk_id id = @name.split(/,/)[1] return id != nil ? id.to_i : 0 end end end class Game_Actor < Game_Battler attr_accessor :ap attr_accessor :svap #--------------------------------------------------- # ● 设置 # actor_id : 角色 ID #--------------------------------------------------- alias old_setup setup def setup(actor_id) old_setup(actor_id) @ap = 0 @svap = {} end end #======================================================= # ■ Window_EquipRight #------------------------------------------------------- # 装备画面、显示角色现在装备的物品的窗口。 #======================================================= class Window_EquipRight < Window_Selectable #--------------------------------------------------- # ● 初始化对像 # actor : 角色 #--------------------------------------------------- def initialize(actor) super(272, 64, 368, 192) self.contents = Bitmap.new(width - 32, height - 32) @actor = actor refresh self.index = 0 end #--------------------------------------------------- # ● 获取物品 #--------------------------------------------------- def item return @data[self.index] end #--------------------------------------------------- # ● 刷新 #--------------------------------------------------- def refresh self.contents.clear @data = [] @data.push($data_weapons[@actor.weapon_id]) @data.push($data_armors[@actor.armor1_id]) @data.push($data_armors[@actor.armor2_id]) @data.push($data_armors[@actor.armor3_id]) @data.push($data_armors[@actor.armor4_id]) @item_max = @data.size self.contents.font.color = system_color self.contents.draw_text(4, 32 * 0, 92, 32, $data_system.words.weapon) self.contents.draw_text(4, 32 * 1, 92, 32, $data_system.words.armor1) self.contents.draw_text(4, 32 * 2, 92, 32, $data_system.words.armor2) self.contents.draw_text(4, 32 * 3, 92, 32, $data_system.words.armor3) self.contents.draw_text(5, 32 * 4, 92, 32, $data_system.words.armor4) if @actor.armor4_id > 0 @actor.svap[$data_armors[@actor.armor4_id].id] = @actor.ap x = 5 y = 128 if @actor.skill_learn?($data_armors[@actor.armor4_id].sk_id) or @actor.ap >= $data_armors[@actor.armor4_id].sk_exp @actor.ap = $data_armors[@actor.armor4_id].sk_exp end a = Color.new(255,255,255,200) b = Color.new(0,0,0,255) if $data_armors[@actor.armor4_id].sk_exp > 0 c_1 = 255 * @actor.ap / $data_armors[@actor.armor4_id].sk_exp c = Color.new(255,255-c_1,255,200) w = 98 * @actor.ap / $data_armors[@actor.armor4_id].sk_exp self.contents.fill_rect(x+190, y+18, 100, 10, a) self.contents.fill_rect(x+191, y+19, 98, 8, b) self.contents.fill_rect(x+191, y+19, w, 8, c) self.contents.font.size = 16 self.contents.font.color = Color.new(255,255,255,255) self.contents.draw_text(x+150, y-6, 92, 32, "技能:",2) self.contents.draw_text(x+250, y-6, 92, 32, $data_skills[$data_armors[@actor.armor4_id].sk_id].name) if @actor.ap == $data_armors[@actor.armor4_id].sk_exp or @actor.skill_learn?($data_skills[$data_armors[@actor.armor4_id].sk_id]) self.contents.draw_text(x+160, y+5, 92, 32, "MAX",2) else self.contents.draw_text(x+135, y+5, 92, 32, @actor.ap.to_s,2) self.contents.draw_text(x+145, y+5, 92, 32, "/",2) self.contents.draw_text(x+170, y+5, 92, 32, $data_armors[@actor.armor4_id].sk_exp.to_s,2) end end end self.contents.font.size = 22 draw_item_name(@data[0], 92, 32 * 0) draw_item_name(@data[1], 92, 32 * 1) draw_item_name(@data[2], 92, 32 * 2) draw_item_name(@data[3], 92, 32 * 3) draw_item_name(@data[4], 92, 32 * 4) end #--------------------------------------------------- # ● 刷新帮助文本 #--------------------------------------------------- def update_help @help_window.set_text(self.item == nil ? "" : self.item.description) end end class Game_Battler #--------------------------------------------------- # ● 应用通常攻击效果 # attacker : 攻击者 (battler) #--------------------------------------------------- def attack_effect(attacker) # 清除会心一击标志 self.critical = false # 第一命中判定 hit_result = (rand(100) < attacker.hit) # 命中的情况下 if hit_result == true # 计算基本伤害 atk = [attacker.atk - self.pdef / 2, 0].max self.damage = atk * (20 + attacker.str) / 20 if attacker.is_a?(Game_Actor) and attacker.armor4_id > 0 attacker.ap += self.damage / 10 if attacker.ap > $data_armors[attacker.armor4_id].sk_exp attacker.ap = $data_armors[attacker.armor4_id].sk_exp end end # 属性修正 self.damage *= elements_correct(attacker.element_set) self.damage /= 100 # 伤害符号正确的情况下 if self.damage > 0 # 会心一击修正 if rand(100) < 4 * attacker.dex / self.agi self.damage *= 2 self.critical = true end # 防御修正 if self.guarding? self.damage /= 2 end end # 分散 if self.damage.abs > 0 amp = [self.damage.abs * 15 / 100, 1].max self.damage += rand(amp+1) + rand(amp+1) - amp end # 第二命中判定 eva = 8 * self.agi / attacker.dex + self.eva hit = self.damage < 0 ? 100 : 100 - eva hit = self.cant_evade? ? 100 : hit hit_result = (rand(100) < hit) end # 命中的情况下 if hit_result == true # 状态冲击解除 remove_states_shock # HP 的伤害计算 self.hp -= self.damage # 状态变化 @state_changed = false states_plus(attacker.plus_state_set) states_minus(attacker.minus_state_set) # Miss 的情况下 else # 伤害设置为 "Miss" self.damage = "Miss" # 清除会心一击标志 self.critical = false end # 过程结束 return true end #--------------------------------------------------- # ● 应用特技效果 # user : 特技的使用者 (battler) # skill : 特技 #--------------------------------------------------- def skill_effect(user, skill) # 清除会心一击标志 self.critical = false # 特技的效果范围是 HP 1 以上的己方、自己的 HP 为 0、 # 或者特技的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下 if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1) # 过程结束 return false end # 清除有效标志 effective = false # 公共事件 ID 是有效的情况下,设置为有效标志 effective |= skill.common_event_id > 0 # 第一命中判定 hit = skill.hit if skill.atk_f > 0 hit *= user.hit / 100 end hit_result = (rand(100) < hit) # 不确定的特技的情况下设置为有效标志 effective |= hit < 100 # 命中的情况下 if hit_result == true # 计算威力 power = skill.power + user.atk * skill.atk_f / 100 if power > 0 power -= self.pdef * skill.pdef_f / 200 power -= self.mdef * skill.mdef_f / 200 power = [power, 0].max end # 计算倍率 rate = 20 rate += (user.str * skill.str_f / 100) rate += (user.dex * skill.dex_f / 100) rate += (user.agi * skill.agi_f / 100) rate += (user.int * skill.int_f / 100) # 计算基本伤害 self.damage = power * rate / 20 if user.is_a?(Game_Actor) and user.armor4_id > 0 if self.damage < 0 user.ap += -self.damage / 10 else user.ap += self.damage / 10 end if user.ap > $data_armors[user.armor4_id].sk_exp or user.ap < 0 user.ap = $data_armors[user.armor4_id].sk_exp end end # 属性修正 self.damage *= elements_correct(skill.element_set) self.damage /= 100 # 伤害符号正确的情况下 if self.damage > 0 # 防御修正 if self.guarding? self.damage /= 2 end end # 分散 if skill.variance > 0 and self.damage.abs > 0 amp = [self.damage.abs * skill.variance / 100, 1].max self.damage += rand(amp+1) + rand(amp+1) - amp end # 第二命中判定 eva = 8 * self.agi / user.dex + self.eva hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100 hit = self.cant_evade? ? 100 : hit hit_result = (rand(100) < hit) # 不确定的特技的情况下设置为有效标志 effective |= hit < 100 end # 命中的情况下 if hit_result == true # 威力 0 以外的物理攻击的情况下 if skill.power != 0 and skill.atk_f > 0 # 状态冲击解除 remove_states_shock # 设置有效标志 effective = true end # HP 的伤害减法运算 last_hp = self.hp self.hp -= self.damage effective |= self.hp != last_hp # 状态变化 @state_changed = false effective |= states_plus(skill.plus_state_set) effective |= states_minus(skill.minus_state_set) # 威力为 0 的场合 if skill.power == 0 # 伤害设置为空的字串 self.damage = "" # 状态没有变化的情况下 unless @state_changed # 伤害设置为 "Miss" self.damage = "Miss" end end # Miss 的情况下 else # 伤害设置为 "Miss" self.damage = "Miss" end # 不在战斗中的情况下 unless $game_temp.in_battle # 伤害设置为 nil self.damage = nil end # 过程结束 return effective end end class Window_Sklb < Window_Base def initialize(actor) @actor = actor super(640-256, 0, 256, 480) self.contents = Bitmap.new(width - 32, height - 32) refresh end def refresh i = 0 self.contents.clear a = Color.new(255,255,255,200) b = Color.new(0,0,0,255) for j in @actor.svap.keys if @actor.svap[j] > 0 c_1 = 255 * @actor.svap[j] / $data_armors[j].sk_exp c = Color.new(255,255-c_1,255,200) w = 218 * @actor.svap[j] / $data_armors[j].sk_exp self.contents.font.size = 18 bitmap = RPG::Cache.icon($data_armors[j].icon_name) self.contents.blt(4, i*46, bitmap, Rect.new(0, 0, 24, 24)) self.contents.fill_rect(0, i*46+32, 220, 10,a) self.contents.fill_rect(0+1, i*46+1+32, 218, 8,b) self.contents.fill_rect(0+1, i*46+1+32, w, 8,c) self.contents.draw_text(4+24, i*46, 128, 32,$data_armors[j].name) self.contents.draw_text(4+128, i*46, 128, 32,$data_skills[$data_armors[j].sk_id].name) if @actor.svap[j] >= $data_armors[j].sk_exp self.contents.draw_text(4+100, i*46+16, 128, 32,"MAX") else self.contents.draw_text(4+32, i*46+16, 128, 32,@actor.svap[j].to_s,1) self.contents.draw_text(4+113, i*46+16, 128, 32,"/") self.contents.draw_text(4+128, i*46+16, 128, 32,$data_armors[j].sk_exp.to_s) end i+=1 end end end end class Scene_Equip #--------------------------------------------------- # ● 主处理 #--------------------------------------------------- def main # 获取角色 @actor = $game_party.actors[@actor_index] # 生成窗口 @help_window = Window_Help.new @left_window = Window_EquipLeft.new(@actor) @right_window = Window_EquipRight.new(@actor) @item_window1 = Window_EquipItem.new(@actor, 0) @item_window2 = Window_EquipItem.new(@actor, 1) @item_window3 = Window_EquipItem.new(@actor, 2) @item_window4 = Window_EquipItem.new(@actor, 3) @item_window5 = Window_EquipItem.new(@actor, 4) # 关联帮助窗口 @right_window.help_window = @help_window @item_window1.help_window = @help_window @item_window2.help_window = @help_window @item_window3.help_window = @help_window @item_window4.help_window = @help_window @item_window5.help_window = @help_window @sklb = Window_Sklb.new(@actor) @sklb.visible=false @sklb.z += 5 # 设置光标位置 @right_window.index = @equip_index refresh # 执行过渡 Graphics.transition # 主循环 loop do # 刷新游戏画面 Graphics.update # 刷新输入信息 Input.update # 刷新画面 update # 如果画面切换的话的就中断循环 if $scene != self break end end # 准备过渡 Graphics.freeze # 释放窗口 @help_window.dispose @left_window.dispose @right_window.dispose @item_window1.dispose @item_window2.dispose @item_window3.dispose @item_window4.dispose @item_window5.dispose @sklb.dispose end alias up_right update_right def update_right up_right if Input.trigger?(Input::X) @sklb.visible=true end if Input.trigger?(Input::Y) @sklb.visible=false end end #--------------------------------------------------- # ● 刷新画面 (物品窗口被激活的情况下) #--------------------------------------------------- def update_item # 按下 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 # 变更装备 if item != nil and item.is_a?(RPG::Armor) @actor.svap[$data_armors[@actor.armor4_id].id] = @actor.ap @actor.svap.include?(item.id) ? @actor.ap = @actor.svap[item.id] : @actor.ap = 0 end @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 return end end end class Scene_Map alias shensi_update update def update shensi_update for i in 0...$game_party.actors.size @actor = $game_party.actors[i] if @actor.armor4_id > 0 and @actor.ap >= $data_armors[@actor.armor4_id].sk_exp @actor = $game_party.actors[i] @actor.learn_skill($data_armors[@actor.armor4_id].sk_id) end end end end |