XP口袋妖怪脚本(持续更新)
战斗系统为横版(有5个要分别打在原来的战斗脚本上替换,第五个自己插入在空白处。)战斗系统1:#==============================================================================# ■ Scene_Battle (分割定义 1)#------------------------------------------------------------------------------# 处理战斗画面的类。#==============================================================================class Scene_Battle#--------------------------------------------------------------------------# ● 主处理#--------------------------------------------------------------------------def main ###################### $game_party.remove_actor(387) ###################### # 初始化战斗用的各种暂时数据 $game_temp.in_battle = true $game_temp.battle_turn = 0 $game_temp.battle_event_flags.clear $game_temp.battle_abort = false $game_temp.battle_main_phase = false $game_temp.battleback_name = $game_map.battleback_name $game_temp.forcing_battler = nil # 初始化战斗用事件解释器 $game_system.battle_interpreter.setup(nil, 0) # 准备队伍 @troop_id = $game_temp.battle_troop_id $game_troop.setup(@troop_id) # 生成角色命令窗口 s1 = $data_system.words.attack s2 = $data_system.words.skill s3 = $data_system.words.guard s4 = $data_system.words.item @actor_command_window = Window_Command.new(160, ) @actor_command_window.y = 160 @actor_command_window.back_opacity = 160 @actor_command_window.active = false @actor_command_window.visible = false # 生成其它窗口 @party_command_window = Window_PartyCommand.new @help_window = Window_Help.new @help_window.back_opacity = 160 @help_window.visible = false @status_window = Window_BattleStatus.new @message_window = Window_Message.new # 生成活动块 @spriteset = Spriteset_Battle.new # 初始化等待计数 @wait_count = 0 ########################### $game_variables = $game_temp.battle_troop_id $game_variables += 1 $game_variables += 1 #战斗开始加入图片 @sprite = Sprite.new @sprite.bitmap = RPG::Cache.picture("战斗界面" + $game_party.actors.size.to_s) ########################### # 执行过渡 if $data_system.battle_transition == "" Graphics.transition(20) else Graphics.transition(40, "Graphics/Transitions/" + $data_system.battle_transition) end # 开始自由战斗回合 start_phase1 # 主循环 loop do # 刷新游戏画面 Graphics.update # 刷新输入信息 Input.update # 刷新画面 update # 如果画面切换的话就中断循环 if $scene != self break end end # 刷新地图 $game_map.refresh # 准备过渡 Graphics.freeze # 释放窗口 ###################### # $game_party.add_actor(387) $game_variables = 0 $game_variables -= 1 $game_variables = 0 $game_variables = 0 ###################### @sprite.bitmap.dispose @sprite.dispose ###################### @actor_command_window.dispose @party_command_window.dispose @help_window.dispose @status_window.dispose @message_window.dispose if @skill_window != nil @skill_window.dispose end if @item_window != nil @item_window.dispose end if @result_window != nil @result_window.dispose end # 释放活动块 @spriteset.dispose # 标题画面切换中的情况 if $scene.is_a?(Scene_Title) # 淡入淡出画面 Graphics.transition Graphics.freeze end # 战斗测试或者游戏结束以外的画面切换中的情况 if $BTEST and not $scene.is_a?(Scene_Gameover) $scene = nil endend#--------------------------------------------------------------------------# ● 胜负判定#--------------------------------------------------------------------------def judge # 全灭判定是真、并且同伴人数为 0 的情况下 if $game_party.all_dead? or $game_party.actors.size == 0 # 允许失败的情况下 if $game_temp.battle_can_lose # 还原为战斗开始前的 BGM $game_system.bgm_play($game_temp.map_bgm) ############################# $game_variables += 1 ############################## # 战斗结束 battle_end(2) # 返回 true return true end # 设置游戏结束标志 $game_temp.gameover = true # 返回 true return true end # 如果存在任意 1 个敌人就返回 false for enemy in $game_troop.enemies if enemy.exist? return false end end # 开始结束战斗回合 (胜利) start_phase5 # 返回 true return trueend#--------------------------------------------------------------------------# ● 战斗结束# result : 結果 (0:胜利 1:失败 2:逃跑)#--------------------------------------------------------------------------def battle_end(result) # 清除战斗中标志 $game_temp.in_battle = false # 清除全体同伴的行动 $game_party.clear_actions # 解除战斗用状态 for actor in $game_party.actors actor.remove_states_battle end # 清除敌人 $game_troop.enemies.clear # 调用战斗返回调用 if $game_temp.battle_proc != nil $game_temp.battle_proc.call(result) $game_temp.battle_proc = nil end # 切换到地图画面 $scene = Scene_Map.newend#--------------------------------------------------------------------------# ● 设置战斗事件#--------------------------------------------------------------------------def setup_battle_event # 正在执行战斗事件的情况下 if $game_system.battle_interpreter.running? return end # 搜索全部页的战斗事件 for index in 0...$data_troops[@troop_id].pages.size # 获取事件页 page = $data_troops[@troop_id].pages # 事件条件可以参考 c c = page.condition # 没有指定任何条件的情况下转到下一页 unless c.turn_valid or c.enemy_valid or c.actor_valid or c.switch_valid next end # 执行完毕的情况下转到下一页 if $game_temp.battle_event_flags next end # 确认回合条件 if c.turn_valid n = $game_temp.battle_turn a = c.turn_a b = c.turn_b if (b == 0 and n != a) or (b > 0 and (n < 1 or n < a or n % b != a % b)) next end end # 确认敌人条件 if c.enemy_valid enemy = $game_troop.enemies if enemy == nil or enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp next end end # 确认角色条件 if c.actor_valid actor = $game_actors if actor == nil or actor.hp * 100.0 / actor.maxhp > c.actor_hp next end end # 确认开关条件 if c.switch_valid if $game_switches == false next end end # 设置事件 $game_system.battle_interpreter.setup(page.list, 0) # 本页的范围是 [战斗] 或 [回合] 的情况下 if page.span0 # 减少等待计数 @wait_count -= 1 return end # 强制行动的角色存在、 # 并且战斗事件正在执行的情况下 if $game_temp.forcing_battler == nil and $game_system.battle_interpreter.running? return end # 回合分支 case @phase when 1# 自由战斗回合 update_phase1 when 2# 同伴命令回合 update_phase2 when 3# 角色命令回合 update_phase3 when 4# 主回合 update_phase4 when 5# 战斗结束回合 update_phase5 endendend复制代码战斗系统2:#==============================================================================# ■ Scene_Battle (分割定义 2)#------------------------------------------------------------------------------# 处理战斗画面的类。#==============================================================================class Scene_Battle#--------------------------------------------------------------------------# ● 开始自由战斗回合#--------------------------------------------------------------------------def start_phase1 # 转移到回合 1 @phase = 1 # 清除全体同伴的行动 $game_party.clear_actions # 设置战斗事件 setup_battle_eventend#--------------------------------------------------------------------------# ● 刷新画面 (自由战斗回合)#--------------------------------------------------------------------------def update_phase1 # 胜败判定 if judge # 胜利或者失败的情况下 : 过程结束 return end # 开始同伴命令回合 start_phase3end#--------------------------------------------------------------------------# ● 开始同伴命令回合#--------------------------------------------------------------------------def start_phase2 # 转移到回合 2 @phase = 2 # 设置角色为非选择状态 @actor_index = -1 @active_battler = nil # 有效化同伴指令窗口 @party_command_window.active = true @party_command_window.visible = true # 无效化角色指令窗口 @actor_command_window.active = false @actor_command_window.visible = false # 清除主回合标志 $game_temp.battle_main_phase = false # 清除全体同伴的行动 $game_party.clear_actions # 不能输入命令的情况下 unless $game_party.inputable? # 开始主回合 start_phase4 endend#--------------------------------------------------------------------------# ● 刷新画面 (同伴命令回合)#--------------------------------------------------------------------------def update_phase2 # 开始主回合 start_phase3end#--------------------------------------------------------------------------# ● 开始结束战斗回合#--------------------------------------------------------------------------def start_phase5 # 转移到回合 5 @phase = 5 # 演奏战斗结束 ME $game_system.me_play($game_system.battle_end_me) # 还原为战斗开始前的 BGM $game_system.bgm_play($game_temp.map_bgm) # 初始化 EXP、金钱、宝物 exp = 0 gold = 0 treasures = [] # 循环 for enemy in $game_troop.enemies # 敌人不是隐藏状态的情况下 unless enemy.hidden # 获得 EXP、增加金钱 exp += enemy.exp gold += enemy.gold # 出现宝物判定 if rand(100) < enemy.treasure_prob if enemy.item_id > 0 treasures.push($data_items) end if enemy.weapon_id > 0 treasures.push($data_weapons) end if enemy.armor_id > 0 treasures.push($data_armors) end end end end # 限制宝物数为 6 个 treasures = treasures # 获得 EXP exp=(exp/$game_party.actors.size).to_i # 平分后避免有点数出现,要使用.to_i for i in 0...$game_party.actors.size actor = $game_party.actors if actor.cant_get_exp? == false last_level = actor.level actor.exp += exp if actor.level > last_level @status_window.level_up(i) end end end # 获得金钱 $game_party.gain_gold(gold) # 获得宝物 for item in treasures 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 end # 生成战斗结果窗口 @result_window = Window_BattleResult.new(exp, gold, treasures) # 设置等待计数 @phase5_wait_count = 100end#--------------------------------------------------------------------------# ● 画面更新 (结束战斗回合)#--------------------------------------------------------------------------def update_phase5 # 等待计数大于 0 的情况下 if @phase5_wait_count > 0 # 减少等待计数 @phase5_wait_count -= 1 # 等待计数为 0 的情况下 if @phase5_wait_count == 0 # 显示结果窗口 @result_window.visible = true # 清除主回合标志 $game_temp.battle_main_phase = false # 刷新状态窗口 @status_window.refresh end return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 战斗结束 battle_end(0) endendend复制代码战斗系统3:#==============================================================================# ■ Scene_Battle (分割定义 3)#------------------------------------------------------------------------------# 处理战斗画面的类。#==============================================================================class Scene_Battle#--------------------------------------------------------------------------# ● 开始角色命令回合#--------------------------------------------------------------------------def start_phase3 # 转移到回合 3 @phase = 3 # 设置觉得为非选择状态 @actor_index = -1 @active_battler = nil # 输入下一个角色的命令 phase3_next_actorend#--------------------------------------------------------------------------# ● 转到输入下一个角色的命令#--------------------------------------------------------------------------def phase3_next_actor # 循环 begin # 角色的明灭效果 OFF if @active_battler != nil @active_battler.blink = false end # 最后的角色的情况 if @actor_index == $game_party.actors.size-1 # 开始主回合 start_phase4 return end # 推进角色索引 @actor_index += 1 @active_battler = $game_party.actors[@actor_index] @active_battler.blink = true # 如果角色是在无法接受指令的状态就再试 end until @active_battler.inputable? # 设置角色的命令窗口 phase3_setup_command_windowend#--------------------------------------------------------------------------# ● 转向前一个角色的命令输入#--------------------------------------------------------------------------def phase3_prior_actor # 循环 begin # 角色的明灭效果 OFF if @active_battler != nil @active_battler.blink = false end # 最初的角色的情况下 if @actor_index == 0 # 开始同伴指令回合 start_phase2 return end # 返回角色索引 @actor_index -= 1 @active_battler = $game_party.actors[@actor_index] @active_battler.blink = true # 如果角色是在无法接受指令的状态就再试 end until @active_battler.inputable? # 设置角色的命令窗口 phase3_setup_command_windowend#--------------------------------------------------------------------------# ● 设置角色指令窗口#--------------------------------------------------------------------------def phase3_setup_command_window # 同伴指令窗口无效化 @party_command_window.active = false @party_command_window.visible = false # 角色指令窗口无效化 @actor_command_window.active = true @actor_command_window.visible = true # 设置角色指令窗口的位置 @actor_command_window.x = @actor_index * 120 # 设置索引为 0 @actor_command_window.index = 0end#--------------------------------------------------------------------------# ● 刷新画面 (角色命令回合)#--------------------------------------------------------------------------def update_phase3 # 敌人光标有效的情况下 if @enemy_arrow != nil update_phase3_enemy_select # 角色光标有效的情况下 elsif @actor_arrow != nil update_phase3_actor_select # 特技窗口有效的情况下 elsif @skill_window != nil update_phase3_skill_select # 物品窗口有效的情况下 elsif @item_window != nil update_phase3_item_select # 逃跑窗口有效的情况下 elsif @escape_window != nil update_phase3_escape_select # 角色指令窗口有效的情况下 elsif @actor_command_window.active update_phase3_basic_command endend#--------------------------------------------------------------------------# ● 刷新画面 (角色命令回合 : 基本命令)#--------------------------------------------------------------------------def update_phase3_basic_command # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 转向前一个角色的指令输入 phase3_prior_actor return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 角色指令窗口光标位置分之 case @actor_command_window.index when 0# 攻击 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 设置行动 @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 0 # 开始选择敌人 start_enemy_select when 1# 特技 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 设置行动 @active_battler.current_action.kind = 1 # 开始选择特技 start_skill_select when 2# 防御 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 设置行动 @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 1 # 转向下一位角色的指令输入 phase3_next_actor when 3# 物品 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 设置行动 @active_battler.current_action.kind = 2 # 开始选择物品 start_item_select########################################################################### when 4# 逃跑 if $game_temp.battle_can_escape == false # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 逃走处理 update_phase3_escape_select########################################################################### end return endend#--------------------------------------------------------------------------# ● 刷新画面 (角色命令回合 : 选择特技)#--------------------------------------------------------------------------def update_phase3_skill_select # 设置特技窗口为可视状态 @skill_window.visible = true # 刷新特技窗口 @skill_window.update # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 结束特技选择 end_skill_select return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 获取特技选择窗口现在选择的特技的数据 @skill = @skill_window.skill # 无法使用的情况下 if @skill == nil or not @active_battler.skill_can_use?(@skill.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.skill_id = @skill.id # 设置特技窗口为不可见状态 @skill_window.visible = false # 效果范围是敌单体的情况下 if @skill.scope == 1 # 开始选择敌人 start_enemy_select # 效果范围是我方单体的情况下 elsif @skill.scope == 3 or @skill.scope == 5 # 开始选择角色 start_actor_select # 效果范围不是单体的情况下 else # 选择特技结束 end_skill_select # 转到下一位角色的指令输入 phase3_next_actor end return endend#--------------------------------------------------------------------------# ● 刷新画面 (角色命令回合 : 选择物品)#--------------------------------------------------------------------------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 $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 endend #--------------------------------------------------------------------------# ● 画面更新 (同伴指令回合 : 逃跑)#--------------------------------------------------------------------------def update_phase3_escape_select # 计算敌人速度的平均值 enemies_agi = 0 enemies_number = 0 for enemy in $game_troop.enemies if enemy.exist? enemies_agi += enemy.agi enemies_number += 1 end end if enemies_number > 0 enemies_agi /= enemies_number end # 计算角色速度的平均值 actors_agi = 0 actors_number = 0 for actor in $game_party.actors if actor.exist? actors_agi += actor.agi actors_number += 1 end end if actors_number > 0 actors_agi /= actors_number end # 逃跑成功判定 success = rand(100) < 75 * actors_agi / enemies_agi # 成功逃跑的情况下 if success ############################ $game_variables += 1 ############################ # 演奏逃跑 SE $game_system.se_play($data_system.escape_se) # 还原为战斗开始前的 BGM $game_system.bgm_play($game_temp.map_bgm) # 战斗结束 battle_end(1) # 逃跑失败的情况下 else # 清除全体同伴的行动 $game_party.clear_actions # 开始主回合 start_phase4 endend#--------------------------------------------------------------------------# ● 刷新画面画面 (角色命令回合 : 选择敌人)#--------------------------------------------------------------------------def update_phase3_enemy_select # 刷新敌人箭头 @enemy_arrow.update # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 选择敌人结束 end_enemy_select return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 设置行动 @active_battler.current_action.target_index = @enemy_arrow.index # 选择敌人结束 end_enemy_select # 显示特技窗口中的情况下 if @skill_window != nil # 结束特技选择 end_skill_select end # 显示物品窗口的情况下 if @item_window != nil # 结束物品选择 end_item_select end # 转到下一位角色的指令输入 phase3_next_actor endend#--------------------------------------------------------------------------# ● 画面更新 (角色指令回合 : 选择角色)#--------------------------------------------------------------------------def update_phase3_actor_select # 刷新角色箭头 @actor_arrow.update # 按下 B 键的情况下 if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 选择角色结束 end_actor_select return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 设置行动 @active_battler.current_action.target_index = @actor_arrow.index # 选择角色结束 end_actor_select # 显示特技窗口中的情况下 if @skill_window != nil # 结束特技选择 end_skill_select end # 显示物品窗口的情况下 if @item_window != nil # 结束物品选择 end_item_select end # 转到下一位角色的指令输入 phase3_next_actor endend#--------------------------------------------------------------------------# ● 开始选择敌人#--------------------------------------------------------------------------def start_enemy_select # 生成敌人箭头 @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport1) # 关联帮助窗口 @enemy_arrow.help_window = @help_window # 无效化角色指令窗口 @actor_command_window.active = false @actor_command_window.visible = falseend#--------------------------------------------------------------------------# ● 结束选择敌人#--------------------------------------------------------------------------def end_enemy_select # 释放敌人箭头 @enemy_arrow.dispose @enemy_arrow = nil # 指令为 [战斗] 的情况下 if @actor_command_window.index == 0 # 有效化角色指令窗口 @actor_command_window.active = true @actor_command_window.visible = true # 隐藏帮助窗口 @help_window.visible = false endend#--------------------------------------------------------------------------# ● 开始选择角色#--------------------------------------------------------------------------def start_actor_select # 生成角色箭头 @actor_arrow = Arrow_Actor.new(@spriteset.viewport2) @actor_arrow.index = @actor_index # 关联帮助窗口 @actor_arrow.help_window = @help_window # 无效化角色指令窗口 @actor_command_window.active = false @actor_command_window.visible = falseend#--------------------------------------------------------------------------# ● 结束选择角色#--------------------------------------------------------------------------def end_actor_select # 释放角色箭头 @actor_arrow.dispose @actor_arrow = nilend#--------------------------------------------------------------------------# ● 开始选择特技#--------------------------------------------------------------------------def start_skill_select # 生成特技窗口 @skill_window = Window_Skill.new(@active_battler) # 关联帮助窗口 @skill_window.help_window = @help_window # 无效化角色指令窗口 @actor_command_window.active = false @actor_command_window.visible = falseend#--------------------------------------------------------------------------# ● 选择特技结束#--------------------------------------------------------------------------def end_skill_select # 释放特技窗口 @skill_window.dispose @skill_window = nil # 隐藏帮助窗口 @help_window.visible = false # 有效化角色指令窗口 @actor_command_window.active = true @actor_command_window.visible = trueend#--------------------------------------------------------------------------# ● 开始选择物品#--------------------------------------------------------------------------def start_item_select # 生成物品窗口 @item_window = Window_Item.new # 关联帮助窗口 @item_window.help_window = @help_window # 无效化角色指令窗口 @actor_command_window.active = false @actor_command_window.visible = falseend#--------------------------------------------------------------------------# ● 结束选择物品#--------------------------------------------------------------------------def end_item_select # 释放物品窗口 @item_window.dispose @item_window = nil # 隐藏帮助窗口 @help_window.visible = false # 有效化角色指令窗口 @actor_command_window.active = true @actor_command_window.visible = trueendend复制代码战斗系统4:#==============================================================================# ■ Scene_Battle (分割定义 4)#------------------------------------------------------------------------------# 处理战斗画面的类。#==============================================================================class Scene_Battle#--------------------------------------------------------------------------# ● 开始主回合#--------------------------------------------------------------------------def start_phase4 # 转移到回合 4 @phase = 4 # 回合数计数 $game_temp.battle_turn += 1 # 搜索全页的战斗事件 for index in 0...$data_troops[@troop_id].pages.size # 获取事件页 page = $data_troops[@troop_id].pages # 本页的范围是 [回合] 的情况下 if page.span == 1 # 设置已经执行标志 $game_temp.battle_event_flags = false end end # 设置角色为非选择状态 @actor_index = -1 @active_battler = nil # 有效化同伴指令窗口 @party_command_window.active = false @party_command_window.visible = false # 无效化角色指令窗口 @actor_command_window.active = false @actor_command_window.visible = false # 设置主回合标志 $game_temp.battle_main_phase = true # 生成敌人行动 for enemy in $game_troop.enemies enemy.make_action end # 生成行动顺序 make_action_orders # 移动到步骤 1 @phase4_step = 1end#--------------------------------------------------------------------------# ● 生成行动循序#--------------------------------------------------------------------------def make_action_orders # 初始化序列 @action_battlers @action_battlers = [] # 添加敌人到 @action_battlers 序列 for enemy in $game_troop.enemies @action_battlers.push(enemy) end # 添加角色到 @action_battlers 序列 for actor in $game_party.actors @action_battlers.push(actor) end # 确定全体的行动速度 for battler in @action_battlers battler.make_action_speed end # 按照行动速度从大到小排列 @action_battlers.sort! {|a,b| b.current_action.speed - a.current_action.speed }end#--------------------------------------------------------------------------# ● 刷新画面 (主回合)#--------------------------------------------------------------------------def update_phase4 case @phase4_step when 1 update_phase4_step1 when 2 update_phase4_step2 when 3 update_phase4_step3 when 4 update_phase4_step4 when 5 update_phase4_step5 when 6 update_phase4_step6 endend#--------------------------------------------------------------------------# ● 刷新画面 (主回合步骤 1 : 准备行动)#--------------------------------------------------------------------------def update_phase4_step1 # 隐藏帮助窗口 @help_window.visible = false # 判定胜败 if judge # 胜利或者失败的情况下 : 过程结束 return end # 强制行动的战斗者不存在的情况下 if $game_temp.forcing_battler == nil # 设置战斗事件 setup_battle_event # 执行战斗事件中的情况下 if $game_system.battle_interpreter.running? return end end # 强制行动的战斗者存在的情况下 if $game_temp.forcing_battler != nil # 在头部添加后移动 @action_battlers.delete($game_temp.forcing_battler) @action_battlers.unshift($game_temp.forcing_battler) end # 未行动的战斗者不存在的情况下 (全员已经行动) if @action_battlers.size == 0 # 开始同伴命令回合 start_phase2 return end # 初始化动画 ID 和公共事件 ID @animation1_id = 0 @animation2_id = 0 @common_event_id = 0 # 未行动的战斗者移动到序列的头部 @active_battler = @action_battlers.shift # 如果已经在战斗之外的情况下 if @active_battler.index == nil return end # 连续伤害 if @active_battler.hp > 0 and @active_battler.slip_damage? @active_battler.slip_damage_effect @active_battler.damage_pop = true end # 当角色生命>0并且中了22号状态 if @active_battler.hp > 0 and @active_battler.state?(22) @active_battler.hp += @active_battler.maxhp/10 # 恢复1/10的最大生命 end # 自然解除状态 @active_battler.remove_states_auto # 刷新状态窗口 @status_window.refresh # 移至步骤 2 @phase4_step = 2end#--------------------------------------------------------------------------# ● 刷新画面 (主回合步骤 2 : 开始行动)#--------------------------------------------------------------------------def update_phase4_step2 # 如果不是强制行动 unless @active_battler.current_action.forcing # 限制为 [敌人为普通攻击] 或 [我方为普通攻击] 的情况下 if @active_battler.restriction == 2 or @active_battler.restriction == 3 # 设置行动为攻击 @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 0 end # 限制为 [不能行动] 的情况下 if @active_battler.restriction == 4 # 清除行动强制对像的战斗者 $game_temp.forcing_battler = nil # 移至步骤 1 @phase4_step = 1 return end end # 清除对像战斗者 @target_battlers = [] # 行动种类分支 case @active_battler.current_action.kind when 0# 基本 make_basic_action_result when 1# 特技 make_skill_action_result when 2# 物品 make_item_action_result when 3# 逃跑 make_escape_action_result end # 移至步骤 3 if @phase4_step == 2 @phase4_step = 3 endend#--------------------------------------------------------------------------# ● 生成基本行动结果#--------------------------------------------------------------------------def make_basic_action_result # 攻击的情况下 if @active_battler.current_action.basic == 0 # 设置攻击 ID @animation1_id = @active_battler.animation1_id @animation2_id = @active_battler.animation2_id # 行动方的战斗者是敌人的情况下 if @active_battler.is_a?(Game_Enemy) if @active_battler.restriction == 3 target = $game_troop.random_target_enemy elsif @active_battler.restriction == 2 target = $game_party.random_target_actor else index = @active_battler.current_action.target_index target = $game_party.smooth_target_actor(index) end end # 行动方的战斗者是角色的情况下 if @active_battler.is_a?(Game_Actor) if @active_battler.restriction == 3 target = $game_party.random_target_actor elsif @active_battler.restriction == 2 target = $game_troop.random_target_enemy else index = @active_battler.current_action.target_index target = $game_troop.smooth_target_enemy(index) end end # 设置对像方的战斗者序列 @target_battlers = # 应用通常攻击效果 for target in @target_battlers target.attack_effect(@active_battler) end return end # 防御的情况下 if @active_battler.current_action.basic == 1 # 帮助窗口显示"防御" @help_window.set_text($data_system.words.guard, 1) return end # 逃跑的情况下 if @active_battler.is_a?(Game_Enemy) and @active_battler.current_action.basic == 2 #帮助窗口显示"逃跑" @help_window.set_text("逃跑", 1) # 逃跑 @active_battler.escape return end # 什么也不做的情况下 if @active_battler.current_action.basic == 3 # 清除强制行动对像的战斗者 $game_temp.forcing_battler = nil # 移至步骤 1 @phase4_step = 1 return endend#--------------------------------------------------------------------------# ● 设置物品或特技对像方的战斗者# scope : 特技或者是物品的范围#--------------------------------------------------------------------------def set_target_battlers(scope) # 行动方的战斗者是敌人的情况下 if @active_battler.is_a?(Game_Enemy) # 效果范围分支 case scope when 1# 敌单体 index = @active_battler.current_action.target_index @target_battlers.push($game_party.smooth_target_actor(index)) when 2# 敌全体 for actor in $game_party.actors if actor.exist? @target_battlers.push(actor) end end when 3# 我方单体 index = @active_battler.current_action.target_index @target_battlers.push($game_troop.smooth_target_enemy(index)) when 4# 我方全体 for enemy in $game_troop.enemies if enemy.exist? @target_battlers.push(enemy) end end when 5# 我方单体 (HP 0) index = @active_battler.current_action.target_index enemy = $game_troop.enemies if enemy != nil and enemy.hp0? @target_battlers.push(enemy) end when 6# 我方全体 (HP 0) for enemy in $game_troop.enemies if enemy != nil and enemy.hp0? @target_battlers.push(enemy) end end when 7# 使用者 @target_battlers.push(@active_battler) end end # 行动方的战斗者是角色的情况下 if @active_battler.is_a?(Game_Actor) # 效果范围分支 case scope when 1# 敌单体 index = @active_battler.current_action.target_index @target_battlers.push($game_troop.smooth_target_enemy(index)) when 2# 敌全体 for enemy in $game_troop.enemies if enemy.exist? @target_battlers.push(enemy) end end when 3# 我方单体 index = @active_battler.current_action.target_index @target_battlers.push($game_party.smooth_target_actor(index)) when 4# 我方全体 for actor in $game_party.actors if actor.exist? @target_battlers.push(actor) end end when 5# 我方单体 (HP 0) index = @active_battler.current_action.target_index actor = $game_party.actors if actor != nil and actor.hp0? @target_battlers.push(actor) end when 6# 我方全体 (HP 0) for actor in $game_party.actors if actor != nil and actor.hp0? @target_battlers.push(actor) end end when 7# 使用者 @target_battlers.push(@active_battler) end endend#--------------------------------------------------------------------------# ● 生成特技行动结果#--------------------------------------------------------------------------def make_skill_action_result # 获取特技 @skill = $data_skills[@active_battler.current_action.skill_id] # 如果不是强制行动 unless @active_battler.current_action.forcing # 因为 SP 耗尽而无法使用的情况下 unless @active_battler.skill_can_use?(@skill.id) # 清除强制行动对像的战斗者 $game_temp.forcing_battler = nil # 移至步骤 1 @phase4_step = 1 return end end # 消耗 SP @active_battler.sp -= @skill.sp_cost # 刷新状态窗口 @status_window.refresh # 在帮助窗口显示特技名 @help_window.set_text(@skill.name, 1) # 设置动画 ID @animation1_id = @skill.animation1_id @animation2_id = @skill.animation2_id # 设置公共事件 ID @common_event_id = @skill.common_event_id # 设置对像侧战斗者 set_target_battlers(@skill.scope) # 应用特技效果 for target in @target_battlers target.skill_effect(@active_battler, @skill) endend#--------------------------------------------------------------------------# ● 生成物品行动结果#--------------------------------------------------------------------------def make_item_action_result # 获取物品 @item = $data_items[@active_battler.current_action.item_id] # 因为物品耗尽而无法使用的情况下 unless $game_party.item_can_use?(@item.id) # 移至步骤 1 @phase4_step = 1 return end # 消耗品的情况下 if @item.consumable # 使用的物品减 1 $game_party.lose_item(@item.id, 1) end # 在帮助窗口显示物品名 @help_window.set_text(@item.name, 1) # 设置动画 ID @animation1_id = @item.animation1_id @animation2_id = @item.animation2_id # 设置公共事件 ID @common_event_id = @item.common_event_id # 确定对像 index = @active_battler.current_action.target_index target = $game_party.smooth_target_actor(index) # 设置对像侧战斗者 set_target_battlers(@item.scope) # 应用物品效果 for target in @target_battlers target.item_effect(@item) endend#--------------------------------------------------------------------------# ● 生成逃跑行动结果#--------------------------------------------------------------------------def make_escape_action_result # 计算敌人速度的平均值 enemies_agi = 0 enemies_number = 0 for enemy in $game_troop.enemies if enemy.exist? enemies_agi += enemy.agi enemies_number += 1 end end if enemies_number > 0 enemies_agi /= enemies_number end # 计算角色速度的平均值 actors_agi = 0 actors_number = 0 for actor in $game_party.actors if actor.exist? actors_agi += actor.agi actors_number += 1 end end if actors_number > 0 actors_agi /= actors_number end # 逃跑成功判定 success = rand(100) < 75 * actors_agi / enemies_agi # 成功逃跑的情况下 if success ############################ $game_variables += 1 $data_common_events ############################ # 演奏逃跑 SE $game_system.se_play($data_system.escape_se) # 还原为战斗开始前的 BGM $game_system.bgm_play($game_temp.map_bgm) # 战斗结束 battle_end(1) # 逃跑失败的情况下 else # 清除全体同伴的行动 $game_party.clear_actions # 开始主回合 start_phase4 endend#--------------------------------------------------------------------------# ● 刷新画面 (主回合步骤 3 : 行动方动画)#--------------------------------------------------------------------------def update_phase4_step3 # 行动方动画 (ID 为 0 的情况下是白色闪烁) if @animation1_id == 0 @active_battler.white_flash = true else @active_battler.animation_id = @animation1_id @active_battler.animation_hit = true end # 移至步骤 4 @phase4_step = 4end#--------------------------------------------------------------------------# ● 刷新画面 (主回合步骤 4 : 对像方动画)#--------------------------------------------------------------------------def update_phase4_step4 # 对像方动画 for target in @target_battlers target.animation_id = @animation2_id target.animation_hit = (target.damage != "Miss") if target.is_a?(Game_Actor) end end # 限制动画长度、最低 8 帧 @wait_count = 8 # 移至步骤 5 @phase4_step = 5end#--------------------------------------------------------------------------# ● 刷新画面 (主回合步骤 5 : 显示伤害)#--------------------------------------------------------------------------def update_phase4_step5 # 隐藏帮助窗口 @help_window.visible = false # 刷新状态窗口 @status_window.refresh # 显示伤害 for target in @target_battlers if @active_battler.current_action.kind == 1 and @skill.name == "精灵球" $game_switches = false rate_a = [( target.int*10 ),100].min rate_b = (100 - rate_a) bingo = (rand(100) < rate_b) if bingo #成功偷窃,生成偷窃物品 make_steal_result #成功偷窃,设置伤害文字为Success target.damage = "" target.damage = "Success!!" #播放偷窃成功音效 Audio.se_play("Audio/SE/"+"002-System02",100,100) $game_switches = true $game_variables += 1 else #偷窃失败,设置伤害为Failed target.damage = "" target.damage = "Failed!!" #播放偷窃失败音效 Audio.se_play("Audio/SE/"+"010-System10",100,100) end target.damage_pop = true elsif target.damage != nil target.damage_pop = true end end # 移至步骤 6 @phase4_step = 6end#--------------------------------------------------------------------------# ● 刷新画面 (主回合步骤 6 : 刷新)#--------------------------------------------------------------------------def update_phase4_step6 # 清除强制行动对像的战斗者 $game_temp.forcing_battler = nil # 公共事件 ID 有效的情况下 if @common_event_id > 0 # 设置事件 common_event = $data_common_events[@common_event_id] $game_system.battle_interpreter.setup(common_event.list, 0) end # 移至步骤 1 @phase4_step = 1endend复制代码战斗系统5:#-----------------------------------------------------------------------class Scene_Battle#表示这是一个Scene_Battle类 def make_steal_result#在这个类中定义一个方法:make_steal_result item_ser_num = rand(50)#获取随机数item_ser_num,值为0~49中的一个 item_ser = 0#初始化item_ser为0,这个变量是用来表示偷到的物品种类,是武器,还是道具或者(可参照公共事件和下面的脚本理解) item_id = 101#初始化item_id为0,这个变量用来储存偷到的物品ID item_num = 102#初始化item_num为0,这个变量用来储存偷到的该物品数量 case item_ser_num#对item_ser_num这个随机数进行条件分歧 when 0 #当其值为0的时候 item_ser = 1#item_ser = 1,表示这是一个武器 item_id = 7#item_id = ,表示ID为7 item_num = 1#表示数量为1 when 1#当其值为1的时候 item_ser = 1#表示这是一个武器 item_id = (rand(3) + 1)#ID为1~3中的一个 item_num = 1#数量为1 when 2#当其值为2的时候 item_ser = 2#表示这是一个防具 item_id = (rand(3) + 5)#ID为5~7中的任意一个 item_num = 1#数量为1 when 3..9#当其值为3~9之间的一个数字时 item_ser = 0#表示这是一个物品 item_id = $game_variables#ID为9~11中的任意一个数 item_num = 1#数量为1 else #酒类#如果不是以上提到的任何数字且在49以内 item_ser = 0#表示这是一个物品 item_id = $game_variables#ID为89~93中任意一个数字 item_num = 1#数量为1个 end#结束对于item_ser_num的条件分歧 case item_ser#对于item_ser(即物品种类)进行条件分歧 when 0 #物品 $game_variables = 0#是物品的话,第100号变量 = 0,用来告诉公共事件这是个物品 when 1 #武器 $game_variables = 1#是武器的话,第100号变量 = 1,用来告诉公共事件这是个武器 when 2 #防具 $game_variables = 2#是防具的话,第100号变量 = 2,用来告诉公共事件这是个防具 end#结束对于item_ser的条件分歧 $game_variables = item_id#用第101号变量存储得到的道具ID $game_variables = item_num#用第102号变量存储得到的道具数量 endend#结束#------------------------------------------------------------复制代码战斗系统行走图战斗:#==============================================================================# 本脚本来自www.66RPG.com,使用和转载请保留此信息#============================================================================== #==============================================================================#冲突脚本:宠物脚本1.2版(66主页拿的宠物脚本应该都会冲突)#注意:以下一共有两个脚本,插入后就能达到战斗动画。#插入脚本后先进入游戏进行战斗一下,然后就会明白素材问题了#素材问题:脚本采用了战斗图自动选择行走图~~~#使用方法:插入main前即可#==============================================================================#==============================================================================# ■ Sprite_Battler#==============================================================================class Sprite_Battler < RPG::Sprite #-------------------------------------------------------------------------- # ● instance变量 #-------------------------------------------------------------------------- attr_accessor :battler # butler #-------------------------------------------------------------------------- # ● 初始化 # viewport : viewport # battler: butler(Game_Battler) #-------------------------------------------------------------------------- def initialize(viewport, battler = nil) super(viewport) @battler = battler @battler_visible = false # 定义动画用变量 @hoko_wait = 0 @hoko_pattern = 0 end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose if self.bitmap != nil self.bitmap.dispose end super end #-------------------------------------------------------------------------- # ● 更新 #-------------------------------------------------------------------------- def update super # butler nil 的场合 if @battler == nil self.bitmap = nil loop_animation(nil) return end # 如果文件名或者色相与现在的东西不同 if @battler.battler_name != @battler_name or @battler.battler_hue != @battler_hue # 取得位图设定 @battler_name = @battler.battler_name @battler_hue = @battler.battler_hue # battler→character变更 #self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue) self.bitmap = RPG::Cache.character(@battler_name, @battler_hue) # width→宽度height→高度 @width = bitmap.width / 4 @height = bitmap.height / 4 self.ox = @width / 2 self.oy = @height self.src_rect.set(@hoko_pattern * @width, 0, @width, @height) # 战斗不能再隐藏要是状态把不透明度做为 0 if @battler.dead? or @battler.hidden self.opacity = 0 end end # 如果动画ID与现在的东西有差异 if @battler.damage == nil and @battler.state_animation_id != @state_animation_id @state_animation_id = @battler.state_animation_id loop_animation($data_animations[@state_animation_id]) end # 应该被表示actor的场合 if @battler.is_a?(Game_Actor) and @battler_visible # 不是主要阶段的时候把不透明度稍稍下降 if $game_temp.battle_main_phase self.opacity += 3 if self.opacity < 255 else self.opacity -= 3 if self.opacity > 207 end end # 闪烁 if @battler.blink blink_on else blink_off end # 不可见的场合 unless @battler_visible # 出现 if not @battler.hidden and not @battler.dead? and (@battler.damage == nil or @battler.damage_pop) appear @battler_visible = true end end # 可见的场合 if @battler_visible # 逃走 if @battler.hidden $game_system.se_play($data_system.escape_se) escape @battler_visible = false end # 白闪光 if @battler.white_flash whiten @battler.white_flash = false end # 动画 if @battler.animation_id != 0 animation = $data_animations[@battler.animation_id] animation(animation, @battler.animation_hit) @battler.animation_id = 0 end # 损坏 if @battler.damage_pop damage(@battler.damage, @battler.critical) @battler.damage = nil @battler.critical = false @battler.damage_pop = false end # korapusu if @battler.damage == nil and @battler.dead? if @battler.is_a?(Game_Enemy) $game_system.se_play($data_system.enemy_collapse_se) else $game_system.se_play($data_system.actor_collapse_se) end collapse @battler_visible = false end # 行走动画 hoko_anime() # p @hoko_pattern end # 设定行走图位置的坐标 self.x = @battler.screen_x self.y = @battler.screen_y - 43 self.z = @battler.screen_z end #-------------------------------------------------------------------------- # ● 行走动画(@hoko_pattern * @width, 0, @width, @height)能设置行走图方向 #-------------------------------------------------------------------------- def hoko_anime() @hoko_wait += 1 if @hoko_wait > 6 # wait 等待 @hoko_wait = 0 @hoko_pattern += 1 if @hoko_pattern > 3 @hoko_pattern = 0 # p "0" end #pattern图案/width宽度/height高度 self.src_rect.set(@hoko_pattern * @width, @height * 2, @width, @height) if battler.is_a?(Game_Actor) self.src_rect.set(@hoko_pattern * @width, @height, @width, @height) endend endend #enemy敌人#==============================================================================#冲突脚本:宠物脚本1.2版(66主页拿的宠物脚本应该都会冲突)#注意:以下一共有两个脚本,插入后就能达到战斗动画。#插入脚本后先进入游戏进行战斗一下,然后就会明白素材问题了#素材问题:脚本采用了战斗图自动选择行走图~~~#==============================================================================#==============================================================================# ■ Game_BattleAction#------------------------------------------------------------------------------#是处理动作 (战斗中的行动)的级。这个级 在 Game_Battler kura# su内部被使用。#==============================================================================class Game_BattleAction #-------------------------------------------------------------------------- # ● instance变量 #-------------------------------------------------------------------------- attr_accessor :speed # 速度 attr_accessor :kind # 类别(基本/ 技艺 / 物品) attr_accessor :basic # 基本(攻击/防御/逃跑) attr_accessor :skill_id # 特技ID attr_accessor :item_id # 物品ID attr_accessor :target_index # 对象禁书目录 attr_accessor :forcing # 强制标志 #-------------------------------------------------------------------------- # ● 初始化 #-------------------------------------------------------------------------- def initialize clear end #-------------------------------------------------------------------------- # ● clearness #-------------------------------------------------------------------------- def clear @speed = 0 @kind = 0 @basic = 3 @skill_id = 0 @item_id = 0 @target_index = -1 @forcing = false end #-------------------------------------------------------------------------- # ● 判断 #-------------------------------------------------------------------------- def valid? return (not (@kind == 0 and @basic == 3)) end #-------------------------------------------------------------------------- # ● 单体判断 #-------------------------------------------------------------------------- def for_one_friend? # 类别特技,效果范围包含伙伴单体(HP 0 的)场合 if @kind == 1 and .include?($data_skills[@skill_id].scope) return true end # 类别以条款,效果范围包含伙伴单体(HP 0 的)场合 if @kind == 2 and .include?($data_items[@item_id].scope) return true end return false end #-------------------------------------------------------------------------- # ● 单体用(HP 0)判断 #-------------------------------------------------------------------------- def for_one_friend_hp0? # 特技效果范围单体(HP 0 )的场合 if @kind == 1 and .include?($data_skills[@skill_id].scope) return true end # 物品效果范围单体(HP 0 )的场合 if @kind == 2 and .include?($data_items[@item_id].scope) return true end return false end #-------------------------------------------------------------------------- # ● random目标 (actor用) #-------------------------------------------------------------------------- def decide_random_target_for_actor # 效果范围分歧 if for_one_friend_hp0? battler = $game_party.random_target_actor_hp0 elsif for_one_friend? battler = $game_party.random_target_actor else battler = $game_troop.random_target_enemy end # 如果对象存在取得禁书目录, # 对象不存在的情况clearness动作 if battler != nil @target_index = battler.index else clear end end #-------------------------------------------------------------------------- # ● random目标 (enemy用) #-------------------------------------------------------------------------- def decide_random_target_for_enemy # 效果范围分歧 if for_one_friend_hp0? battler = $game_troop.random_target_enemy_hp0 elsif for_one_friend? battler = $game_troop.random_target_enemy else battler = $game_party.random_target_actor end # 如果对象存在取得禁书目录, # 对象不存在的情况clearness动作 if battler != nil @target_index = battler.index else clear end end #-------------------------------------------------------------------------- # ● 最后目标 (actor) #-------------------------------------------------------------------------- def decide_last_target_for_actor # 单体actor效果范围,(enemy) if @target_index == -1 battler = nil elsif for_one_friend? battler = $game_party.actors[@target_index] else battler = $game_troop.enemies[@target_index] end # 对象不存在的情况clearness动作 if battler == nil or not battler.exist? clear end end #-------------------------------------------------------------------------- # ● 最后目标 (enemy) #-------------------------------------------------------------------------- def decide_last_target_for_enemy # 单体enemy效果范围 (actor) if @target_index == -1 battler = nil elsif for_one_friend? battler = $game_troop.enemies[@target_index] else battler = $game_party.actors[@target_index] end # 对象不存在的情况clearness动作 if battler == nil or not battler.exist? clear end endend#==============================================================================# 本脚本来自www.66RPG.com,使用和转载请保留此信息#==============================================================================复制代码口袋妖怪新创意(加点脚本):#==============================================================================# 本脚本来自www.66RPG.com,使用和转载请保留此信息#============================================================================== # 脚本使用设定:LEVEL_UP_POINT = 1# 每升一级所增加的点数LEVEL_UP_VARIABLE = 110# 储存角色点数的变量编号与角色id编号的差值 # 默认情况 = 100, # 则是数据库里1号角色的加点数存于101号变量 # 3号角色的加点数存于103号变量。 # 你可以直接操作变量赠与角色可分配点数# 每增加一次点数,各项能力值的变化:357-410行 # 使用方法介绍:# 本脚本不会取代原猩豆δ埽皇且桓龈郊庸δ堋?BR># 也就是说,默认的升级还在,但可以用这个功能手动追加点数。# 如果你想纯粹使用手动加点(而升级不提升能力),只要把数据库中角色升级能力,# 1-99级全部等于一个相同数值就行了。# 呼唤加点场景的方法:$scene = Scene_Lvup.new(角色编号,返回菜单编号)。# 默认都是0号# 加点场景中,page up,page down换人,如果想加点完毕后返回地图,# 464行$scene = Scene_Menu.new(0)改为$scene = Scene_Map.new# 推荐脚本搭配:魔法商店脚本,两者结合,制作自由型RPG#==============================================================================# ■ Window_Command#------------------------------------------------------------------------------# 一般的命令选择行窗口。(追加定义)#==============================================================================class Window_Command < Window_Selectable#--------------------------------------------------------------------------# ● 项目有效化# index : 项目编号#--------------------------------------------------------------------------def able_item(index) draw_item(index, normal_color)endend#==============================================================================# ■ Game_Actor#------------------------------------------------------------------------------# 处理角色的类。(再定义)#==============================================================================class Game_Actor < Game_Battler#--------------------------------------------------------------------------# ● 更改 EXP# exp : 新的 EXP#--------------------------------------------------------------------------def exp=(exp) @exp = [.min, 0].max # 升级 while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0 @level += 1 # 增加4点可自由分配的点数 $game_variables += LEVEL_UP_POINT # 学会特技 for j in $data_classes[@class_id].learnings if j.level == @level learn_skill(j.skill_id) end end end # 降级 while @exp < @exp_list[@level] @level -= 1 end # 修正当前的 HP 与 SP 超过最大值 @hp = [@hp, self.maxhp].min @sp = [@sp, self.maxsp].minendend#==============================================================================# ■ Window_Base#------------------------------------------------------------------------------# 游戏中全部窗口的超级类(追加定义)#==============================================================================class Window_Base < Window#--------------------------------------------------------------------------# ● 描绘 HP# actor : 角色# x : 描画目标 X 坐标# y : 描画目标 Y 坐标# width : 描画目标的宽#--------------------------------------------------------------------------def draw_actor_hp_lvup(actor, x, y) self.contents.font.color = system_color self.contents.draw_text(x , y, 96, 32, "最大" + $data_system.words.hp) if $temp_hp == 0 self.contents.font.color = normal_color self.contents.draw_text(x + 120 , y, 48, 32, actor.maxhp.to_s, 2) else maxhp = actor.maxhp + $temp_hp self.contents.font.color = Color.new(255, 128, 128, 255) self.contents.draw_text(x + 120 , y, 48, 32, maxhp.to_s ,2) self.contents.font.color = normal_color self.contents.draw_text(x + 155, y, 36, 32, "( ", 2) if $temp_hp >=0 self.contents.font.color = Color.new(255, 128, 128, 255) self.contents.draw_text(x + 155, y, 36, 32, " +",2) else self.contents.font.color = Color.new(255,255,0,255) self.contents.draw_text(x + 155, y, 36, 32, " -",2) end self.contents.draw_text(x + 200, y, 36, 32, $temp_hp.to_s, 2) self.contents.font.color = normal_color self.contents.draw_text(x + 215, y, 36, 32, ")", 2) endend#--------------------------------------------------------------------------# ● 描绘 SP# actor : 角色# x : 描画目标 X 坐标# y : 描画目标 Y 坐标# width : 描画目标的宽#--------------------------------------------------------------------------def draw_actor_sp_lvup(actor, x, y) self.contents.font.color = system_color self.contents.draw_text(x , y, 96, 32, "最大" + $data_system.words.sp) if $temp_sp == 0 self.contents.font.color = normal_color self.contents.draw_text(x + 120 , y, 48, 32, actor.maxsp.to_s, 2) else maxsp = actor.maxsp + $temp_sp self.contents.font.color = Color.new(255, 128, 128, 255) self.contents.draw_text(x + 120 , y, 48, 32, maxsp.to_s ,2) self.contents.font.color = normal_color self.contents.draw_text(x + 155, y, 36, 32, "( ", 2) if $temp_sp >=0 self.contents.font.color = Color.new(255, 128, 128, 255) self.contents.draw_text(x + 155, y, 36, 32, " +",2) else self.contents.font.color = Color.new(255,255,0,255) self.contents.draw_text(x + 155, y, 36, 32, " -",2) end self.contents.draw_text(x + 200, y, 36, 32, $temp_sp.to_s, 2) self.contents.font.color = normal_color self.contents.draw_text(x + 215, y, 36, 32, ")", 2) endend#--------------------------------------------------------------------------# ● 描绘能力值# actor : 角色# x : 描画目标 X 坐标# y : 描画目标 Y 坐标# type: 能力值种类 (0~4)#--------------------------------------------------------------------------def draw_actor_lvup(actor, x, y, type) # 定义数字颜色 lvup = normal_color upcolor = Color.new(255, 128, 128, 255) self.contents.font.color = normal_color case type when 0 parameter_name = $data_system.words.str parameter_value = actor.str parameter_value_temp = parameter_value + $temp_str if $temp_str != 0 lvup = upcolor self.contents.draw_text(x + 256, y, 16, 32, "(") if $temp_str >= 0 self.contents.font.color = lvup self.contents.draw_text(x + 272, y, 80, 32, "+",0) else self.contents.font.color = Color.new(255,255,0,255) self.contents.draw_text(x + 272, y, 80, 32, "-",0) end self.contents.draw_text(x + 272, y, 80, 32, $temp_str.abs.to_s,1) self.contents.font.color = normal_color self.contents.draw_text(x + 272, y, 80, 32, ")", 2) end when 1 parameter_name = $data_system.words.dex parameter_value = actor.dex parameter_value_temp = parameter_value + $temp_dex if $temp_dex != 0 lvup = upcolor self.contents.draw_text(x + 256, y, 16, 32, "(") if $temp_dex >= 0 self.contents.font.color = lvup self.contents.draw_text(x + 272, y, 80, 32, "+",0) else self.contents.font.color = Color.new(255,255,0,255) self.contents.draw_text(x + 272, y, 80, 32, "-",0) end self.contents.draw_text(x + 272, y, 80, 32, $temp_dex.abs.to_s,1) self.contents.font.color = normal_color self.contents.draw_text(x + 272, y, 80, 32, ")", 2) end when 2 parameter_name = $data_system.words.agi parameter_value = actor.agi parameter_value_temp = parameter_value + $temp_agi if $temp_agi != 0 lvup = upcolor self.contents.draw_text(x + 256, y, 16, 32, "(") if $temp_agi >= 0 self.contents.font.color = lvup self.contents.draw_text(x + 272, y, 80, 32, "+",0) else self.contents.font.color = Color.new(255,255,0,255) self.contents.draw_text(x + 272, y, 80, 32, "-",0) end self.contents.draw_text(x + 272, y, 80, 32, $temp_agi.abs.to_s,1) self.contents.font.color = normal_color self.contents.draw_text(x + 272, y, 80, 32, ")", 2) end when 3 parameter_name = $data_system.words.int parameter_value = actor.int parameter_value_temp = parameter_value + $temp_int if $temp_int != 0 lvup = upcolor self.contents.draw_text(x + 256, y, 16, 32, "(") if $temp_int >= 0 self.contents.font.color = lvup self.contents.draw_text(x + 272, y, 80, 32, "+",0) else self.contents.font.color = Color.new(255,255,0,255) self.contents.draw_text(x + 272, y, 80, 32, "-",0) end self.contents.draw_text(x + 272, y, 80, 32, $temp_int.abs.to_s,1) self.contents.font.color = normal_color self.contents.draw_text(x + 272, y, 80, 32, ")", 2) end when 4 parameter_name = "剩余点数" parameter_value = $point if $point != 0 lvup = upcolor end end self.contents.font.color = system_color self.contents.draw_text(x, y, 120, 32, parameter_name) self.contents.font.color = normal_color self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s) if type != 4 self.contents.draw_text(x + 150, y, 36, 32, "→") end self.contents.font.color = lvup self.contents.draw_text(x + 180, y, 60, 32, parameter_value_temp.to_s) self.contents.font.color = normal_color endend#==============================================================================# ■ Window_lvup#------------------------------------------------------------------------------# 显示升级状态窗口。#==============================================================================class Window_Lvup < Window_Base#--------------------------------------------------------------------------# ● 初始化对像# actor : 角色#--------------------------------------------------------------------------def initialize(actor) super(0, 0, 512, 320) self.contents = Bitmap.new(width - 32, height - 32) @actor = actor refreshend #--------------------------------------------------------------------------# ● 刷新#--------------------------------------------------------------------------def refresh self.contents.clear draw_actor_graphic(@actor, 40, 112) draw_actor_name(@actor, 4, 0) draw_actor_class(@actor, 4 + 144, 0) draw_actor_level(@actor, 96, 32) draw_actor_state(@actor, 96, 64) draw_actor_hp_lvup(@actor, 96+128, 32) draw_actor_sp_lvup(@actor, 96+128, 64) draw_actor_lvup(@actor, 96, 128, 0) draw_actor_lvup(@actor, 96, 160, 1) draw_actor_lvup(@actor, 96, 192, 2) draw_actor_lvup(@actor, 96, 224, 3) draw_actor_lvup(@actor, 96, 256, 4)endend#==============================================================================# ■ Window_Help#------------------------------------------------------------------------------# 特技及物品的说明、角色的状态显示的窗口。#==============================================================================class Window_Lvup_Help < Window_Base#--------------------------------------------------------------------------# ● 初始化对像#--------------------------------------------------------------------------def initialize super(0, 320, 640, 160) self.contents = Bitmap.new(width - 32, height - 32) @test = "" #——这个东西用来检测,节约内存专用end #--------------------------------------------------------------------------# ● 设置文本#--------------------------------------------------------------------------def lvup_text(text1, text2 = nil, text3 = nil, text4 = nil, text5 = nil) if @test != text1 @test = text1 else return end self.contents.clear self.contents.font.color = normal_color self.contents.draw_text(5, 0, self.width - 40, 32, text1) if text2 != nil self.contents.draw_text(5 , 32, self.width - 40, 32, text2) end self.contents.font.size -= 5 if text3 != nil self.contents.draw_text(5 , 64, self.width - 40, 32, text3) end if text4 != nil self.contents.draw_text(5 , 96, self.width - 40, 32, text4) end if text5 != nil self.contents.draw_text(5 , 96, self.width - 40, 32, text5) end self.contents.font.size += 5endend#==============================================================================# ■ Scene_lvup#------------------------------------------------------------------------------# 处理升级画面的类。#==============================================================================class Scene_Lvup#--------------------------------------------------------------------------# ● 初始化对像# actor_index : 角色索引# menu_index : 选项起始位置#--------------------------------------------------------------------------def initialize(actor_index = 0 , menu_index = 0) @actor_index = actor_index @menu_index = menu_indexend#--------------------------------------------------------------------------# ● 主处理#--------------------------------------------------------------------------def main s1 = "增加HP" s2 = "增加PP" s3 = "增加"+$data_system.words.str s4 = "增加"+$data_system.words.dex s5 = "增加"+$data_system.words.agi s6 = "增加"+$data_system.words.int s7 = "确认加点" s8 = "点数重置" @command_window = Window_Command.new(128, ) @command_window.index = @menu_index # 获取角色 @actor = $game_party.actors[@actor_index] # 将角色的剩余点数带入 $point = $game_variables[@actor.id + LEVEL_UP_VARIABLE] # 初始化临时量 $temp_str = 0 $temp_dex = 0 $temp_agi = 0 $temp_int = 0 $temp_hp = 0 $temp_sp = 0 #========================================================================= # 特别提示:这些设置也可以使用小数,但是可能出现0值意外错误 #(各种编程语言都有这种意外),建议还是使用整数,正负不限 #========================================================================= #========================================================================= # 每提升一次HP,提升多少附加能力 #========================================================================= @hp_hp = 11 # 每提升一次体力提升多少HP @hp_sp = 0 # 每提升一次体力提升多少SP @hp_str = 0 # 每提升一次体力提升多少力量 @hp_dex = 0 # 每提升一次体力提升多少速度 @hp_agi = 0 # 每提升一次体力提升多少灵巧 @hp_int = 0 # 每提升一次体力提升多少魔力 #========================================================================= # 每提升一次SP,提升多少附加能力 #========================================================================= @sp_hp = 1 # 每提升一次体力提升多少HP @sp_sp = 10 # 每提升一次体力提升多少SP @sp_str = 0 # 每提升一次体力提升多少力量 @sp_dex = 0 # 每提升一次体力提升多少速度 @sp_agi = 0 # 每提升一次体力提升多少灵巧 @sp_int = 0 # 每提升一次体力提升多少魔力 #========================================================================= # 每提升一次力量,提升多少附加能力 #========================================================================= @str_hp = 1 # 每提升一次力量附加提升多少HP @str_sp = 0 # 每提升一次力量附加提升多少SP @str_dex = 0 # 每提升一次力量附加提升多少灵巧 @str_agi = 0 # 每提升一次力量附加提升多少速度 @str_int = 0 # 每提升一次力量附加提升多少魔力 @str_str = 1 # 每提升一次力量附加提升多少力量 #========================================================================= # 每提升一次灵巧,提升多少附加能力 #========================================================================= @dex_hp = 1 # 每提升一次灵巧附加提升多少HP @dex_sp = 0 # 每提升一次灵巧附加提升多少SP @dex_str = 0 # 每提升一次灵巧附加提升多少力量 @dex_agi = 0 # 每提升一次灵巧附加提升多少速度 @dex_int = 0 # 每提升一次灵巧附加提升多少魔力 @dex_dex = 1 # 每提升一次灵巧附加提升多少灵巧 #========================================================================= # 每提升一次速度,提升多少附加能力 #========================================================================= @agi_hp = 1 # 每提升一次速度附加提升多少HP @agi_sp = 0 # 每提升一次速度附加提升多少SP @agi_str = 0 # 每提升一次速度附加提升多少力量 @agi_dex = 0 # 每提升一次速度附加提升多少灵巧 @agi_int = 0 # 每提升一次速度附加提升多少魔力 @agi_agi = 1 # 每提升一次速度附加提升多少速度 #========================================================================= # 每提升一次魔力,提升多少附加能力 #========================================================================= @int_hp = 1 # 每提升一次魔力附加提升多少HP @int_sp = 0 # 每提升一次魔力附加提升多少SP @int_str = 0 # 每提升一次魔力附加提升多少力量 @int_dex = 0 # 每提升一次魔力附加提升多少灵巧 @int_agi = 0 # 每提升一次魔力附加提升多少速度 @int_int = 1 # 每提升一次魔力附加提升多少魔力 # 定义说明文字 @text_hp_sc = "HP可以增加生存的能力,可以延长生存的时间!" @text_sp_sc = "PP可以增加特技的次数,还可提升自身特防!" @text_str_sc = $data_system.words.str + "可以增加普攻的威力!" @text_dex_sc = $data_system.words.dex + "可以提高防御力、命中率和必杀!" @text_agi_sc = $data_system.words.agi + "可以提高回避、命中!" @text_int_sc = $data_system.words.int + "可以提高特攻的效果!" @text_save = "保存分配情况并返回游戏" @text_reset= "重新分配能力点数" @text_2 = "每增加一次此项能力值,可以提升能力值" @text_hp = "最大" + $data_system.words.hp + "值" @text_sp = "最大" + $data_system.words.sp + "值" @text_str = "最大" + $data_system.words.str + "值" @text_dex = "最大" + $data_system.words.dex + "值" @text_agi = "最大" + $data_system.words.agi + "值" @text_int = "最大" + $data_system.words.int + "值" s_disable # 生成状态窗口 @lvup_window = Window_Lvup.new(@actor) @lvup_window.x = 128 @lvup_window.y = 0 # 生成帮助窗口并初始化帮助文本 @help_window = Window_Lvup_Help.new # 执行过渡 Graphics.transition(0, "Graphics/Transitions/" + $data_system.battle_transition) # 主循环 loop do # 刷新游戏画面 Graphics.update # 刷新输入信息 Input.update # 刷新画面 update # 如果切换画面就中断循环 if $scene != self break end end # 准备过渡 Graphics.freeze # 释放窗口 @command_window.dispose @lvup_window.dispose @help_window.disposeend#--------------------------------------------------------------------------# ● 刷新画面#--------------------------------------------------------------------------def update # 刷新窗口 @command_window.update # 选项明暗判断(因为太消耗资源,所以屏蔽掉了) s_disable @lvup_window.update #============================================================= # 按下 B 键的情况下 #============================================================= if Input.trigger?(Input::B) # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 切换到地图画面 ################################################# $scene = Scene_Menu.new(3) ################################################# return end #============================================================= # 按下 C 键的情况下 #============================================================= if Input.trigger?(Input::C) if @command_window.index == 6 # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 将角色的剩余点数带回 $game_variables[@actor.id + LEVEL_UP_VARIABLE] = $point # 将角色点数实际加上 @actor.str += $temp_str @actor.dex += $temp_dex @actor.agi += $temp_agi @actor.int += $temp_int @actor.maxhp += $temp_hp @actor.maxsp += $temp_sp # 切换到地图画面 ################################################# $scene = Scene_Menu.new(3) ################################################# return end if @command_window.index == 7 # 演奏确定 SE $game_system.se_play($data_system.cancel_se) # 将角色的剩余点数带入 $point = $game_variables[@actor.id + LEVEL_UP_VARIABLE] # 初始化临时量 $temp_str = 0 $temp_dex = 0 $temp_agi = 0 $temp_int = 0 $temp_hp = 0 $temp_sp = 0 @lvup_window.refresh return end if $point == 0 # 演奏冻结 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) $temp_hp += @hp_hp $temp_sp += @hp_sp $temp_str += @hp_str $temp_dex += @hp_dex $temp_agi += @hp_agi $temp_int += @hp_int $point -= 1 @lvup_window.refresh s_disable return when 1 # 演奏确定 SE $game_system.se_play($data_system.decision_se) $temp_sp += @sp_sp $temp_hp += @sp_hp $temp_str += @hp_str $temp_dex += @hp_dex $temp_agi += @hp_agi $temp_int += @hp_int $point -= 1 @lvup_window.refresh s_disable return when 2 # 演奏确定 SE $game_system.se_play($data_system.decision_se) $temp_str += @str_str $temp_hp += @str_hp $temp_sp += @str_sp $temp_dex += @str_dex $temp_agi += @str_agi $temp_int += @str_int $point -= 1 @lvup_window.refresh s_disable return when 3 # 演奏确定 SE $game_system.se_play($data_system.decision_se) $temp_dex += @dex_dex $temp_hp += @dex_hp $temp_sp += @dex_sp $temp_str += @dex_str $temp_agi += @dex_agi $temp_int += @dex_int $point -= 1 @lvup_window.refresh s_disable return when 4 # 演奏确定 SE $game_system.se_play($data_system.decision_se) $temp_agi += @agi_agi $temp_hp += @agi_hp $temp_sp += @agi_sp $temp_str += @agi_str $temp_dex += @agi_dex $temp_int += @agi_int $point -= 1 @lvup_window.refresh s_disable return when 5 # 演奏确定 SE $game_system.se_play($data_system.decision_se) $temp_int += @int_int $temp_hp += @int_hp $temp_sp += @int_sp $temp_str += @int_str $temp_dex += @int_dex $temp_agi += @int_agi $point -= 1 @lvup_window.refresh s_disable return end end #============================================================= # 什么都没有按下的情况 #============================================================= case @command_window.index when 0# 增加HP temptext1 = @text_hp + @hp_hp.to_s + "点 " + @text_str + @hp_str.to_s + "点 " + @text_dex + @hp_dex.to_s + "点" temptext2 = @text_sp + @hp_sp.to_s + "点 " + @text_agi + @hp_agi.to_s + "点 " + @text_int + @hp_int.to_s + "点" @help_window.lvup_text(@text_hp_sc , @text_2 , temptext1 , temptext2) when 1# 增加SP temptext1 = @text_hp + @sp_hp.to_s + "点 " + @text_str + @sp_str.to_s + "点 " + @text_dex + @sp_dex.to_s + "点" temptext2 = @text_sp + @sp_sp.to_s + "点 " + @text_agi + @sp_agi.to_s + "点 " + @text_int + @sp_int.to_s + "点" @help_window.lvup_text(@text_sp_sc , @text_2 , temptext1 , temptext2) when 2# 增加力量 temptext1 = @text_hp + @str_hp.to_s + "点 " + @text_str + @str_str.to_s + "点 " + @text_dex + @str_dex.to_s + "点" temptext2 = @text_sp + @str_sp.to_s + "点 " + @text_agi + @str_agi.to_s + "点 " + @text_int + @str_int.to_s + "点" @help_window.lvup_text(@text_str_sc , @text_2 , temptext1 , temptext2) when 3# 增加灵巧 temptext1 = @text_hp + @dex_hp.to_s + "点 " + @text_str + @dex_agi.to_s + "点 " + @text_dex + @dex_dex.to_s + "点" temptext2 = @text_sp + @dex_sp.to_s + "点 " + @text_agi + @dex_agi.to_s + "点 " + @text_int + @dex_int.to_s + "点" @help_window.lvup_text(@text_dex_sc , @text_2 , temptext1 , temptext2) when 4# 增加速度 temptext1 = @text_hp + @agi_hp.to_s + "点 " + @text_str + @agi_str.to_s + "点 " + @text_dex + @agi_dex.to_s + "点" temptext2 = @text_sp + @agi_sp.to_s + "点 " + @text_agi + @agi_agi.to_s + "点 " + @text_int + @agi_int.to_s + "点" @help_window.lvup_text(@text_agi_sc , @text_2 , temptext1 , temptext2) when 5# 增加魔力 temptext1 = @text_hp + @int_hp.to_s + "点 " + @text_str + @int_str.to_s + "点 " + @text_dex + @int_dex.to_s + "点" temptext2 = @text_sp + @int_sp.to_s + "点 " + @text_agi + @int_agi.to_s + "点 " + @text_int + @int_int.to_s + "点" @help_window.lvup_text(@text_int_sc , @text_2 , temptext1 , temptext2) when 6 # 保存设定 @help_window.lvup_text(@text_save) when 7 # 点数重置 @help_window.lvup_text(@text_reset) end #============================================================= # 按下R与L换人的情况 #============================================================= 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_Lvup.new(@actor_index , @command_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_Lvup.new(@actor_index , @command_window.index) return endend #--------------------------------------------------------------------------# ● 选项明暗判断#--------------------------------------------------------------------------def s_disable # 判断剩余点数是否为0,如果为0,那么增加选项表示为暗色 if $point == 0 @command_window.disable_item(0) @command_window.disable_item(1) @command_window.disable_item(2) @command_window.disable_item(3) @command_window.disable_item(4) @command_window.disable_item(5) else @command_window.able_item(0) @command_window.able_item(1) @command_window.able_item(2) @command_window.able_item(3) @command_window.able_item(4) @command_window.able_item(5) endendend#==============================================================================# 本脚本来自www.66RPG.com,使用和转载请保留此信息#============================================================================== 复制代码
本帖来自P1论坛作者残花;高飞,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=363983若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
页:
[1]