搜索附件  

全员攻击.zip

 

战斗中添加全员攻击选项:
添加这个项目的目的在于,有时候打怪的时候自己队伍比较强了。不想一个一个队员去点击攻击,所以添加一个“全员攻击”的选择项,让队伍里的所以伙伴对敌人发起普通攻击
首先我们在Scene_Battle 1里的30~31行处修改.看30~31处就行.
  1. #==============================================================================# ■ Scene_Battle (分割定义 1)#------------------------------------------------------------------------------#  处理战斗画面的类。#==============================================================================class Scene_Battle  #--------------------------------------------------------------------------  # ● 主处理  #--------------------------------------------------------------------------  def main    # 初始化战斗用的各种暂时数据    $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, ["全员攻击",s1, s2, s3, s4])    @actor_command_window.y = 128    @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    # 执行过渡    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    # 释放窗口    @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    end  end  #--------------------------------------------------------------------------  # ● 胜负判定  #--------------------------------------------------------------------------  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)        # 战斗结束        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 true  end  #--------------------------------------------------------------------------  # ● 战斗结束  #     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.new  end  #--------------------------------------------------------------------------  # ● 设置战斗事件  #--------------------------------------------------------------------------  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[index]      # 事件条件可以参考 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[index]        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[c.enemy_index]        if enemy == nil or enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp          next        end      end      # 确认角色条件      if c.actor_valid        actor = $game_actors[c.actor_id]        if actor == nil or actor.hp * 100.0 / actor.maxhp > c.actor_hp          next        end      end      # 确认开关条件      if c.switch_valid        if $game_switches[c.switch_id] == false          next        end      end      # 设置事件      $game_system.battle_interpreter.setup(page.list, 0)      # 本页的范围是 [战斗] 或 [回合] 的情况下      if page.span  0      # 减少等待计数      @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    end  endend复制代码
复制代码
然后换到Scene_Battle 3里的118行。将部分内容修改.以下是整个Scene_Battle 3
注意359行处.现在战斗是when 1 .
  1. #==============================================================================# ■ Scene_Battle (分割定义 3)#------------------------------------------------------------------------------#  处理战斗画面的类。#==============================================================================class Scene_Battle  #--------------------------------------------------------------------------  # ● 开始角色命令回合  #--------------------------------------------------------------------------  def start_phase3    # 转移到回合 3    @phase = 3    # 设置角色为非选择状态    @actor_index = -1    @active_battler = nil    # 输入下一个角色的命令    phase3_next_actor  end  #--------------------------------------------------------------------------  # ● 转到输入下一个角色的命令  #--------------------------------------------------------------------------  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_window  end  #--------------------------------------------------------------------------  # ● 转向前一个角色的命令输入  #--------------------------------------------------------------------------  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_window  end  #--------------------------------------------------------------------------  # ● 设置角色指令窗口  #--------------------------------------------------------------------------  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 * 160    # 设置索引为 0    @actor_command_window.index = 0  end  #--------------------------------------------------------------------------  # ● 刷新画面 (角色命令回合)  #--------------------------------------------------------------------------  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 @actor_command_window.active      update_phase3_basic_command    end  end  #--------------------------------------------------------------------------  # ● 刷新画面 (角色命令回合 : 基本命令)  #--------------------------------------------------------------------------  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 #全员攻击        while @actor_index != $game_party.actors.size-1        # 符合时执行以下内容        @active_battler.current_action.kind = 0        @active_battler.current_action.basic = 0        phase3_next_actor      end        #跳出循环,赋予队伍最后一名伙伴的命令        @active_battler.current_action.kind = 0        @active_battler.current_action.basic = 0        @active_battler.blink = false        start_phase4      when 1  # 攻击        # 演奏确定 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 2  # 特技        # 演奏确定 SE        $game_system.se_play($data_system.decision_se)        # 设置行动        @active_battler.current_action.kind = 1        # 开始选择特技        start_skill_select      when 3  # 防御        # 演奏确定 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 4  # 物品        # 演奏确定 SE        $game_system.se_play($data_system.decision_se)        # 设置行动        @active_battler.current_action.kind = 2        # 开始选择物品        start_item_select      end      return    end  end  #--------------------------------------------------------------------------  # ● 刷新画面 (角色命令回合 : 选择特技)  #--------------------------------------------------------------------------  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)      # 获取特技选择窗口现在选择的特技的数据      [url=home.php?mod=space&uid=260100]@skill[/url] = @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    end  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 $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  #--------------------------------------------------------------------------  # ● 刷新画面画面 (角色命令回合 : 选择敌人)  #--------------------------------------------------------------------------  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    end  end  #--------------------------------------------------------------------------  # ● 画面更新 (角色指令回合 : 选择角色)  #--------------------------------------------------------------------------  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    end  end  #--------------------------------------------------------------------------  # ● 开始选择敌人  #--------------------------------------------------------------------------  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 = false  end  #--------------------------------------------------------------------------  # ● 结束选择敌人  #--------------------------------------------------------------------------  def end_enemy_select    # 释放敌人箭头    @enemy_arrow.dispose    @enemy_arrow = nil    # 指令为 [战斗] 的情况下    if @actor_command_window.index == 1      # 有效化角色指令窗口      @actor_command_window.active = true      @actor_command_window.visible = true      # 隐藏帮助窗口      @help_window.visible = false    end  end  #--------------------------------------------------------------------------  # ● 开始选择角色  #--------------------------------------------------------------------------  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 = false  end  #--------------------------------------------------------------------------  # ● 结束选择角色  #--------------------------------------------------------------------------  def end_actor_select    # 释放角色箭头    @actor_arrow.dispose    @actor_arrow = nil  end  #--------------------------------------------------------------------------  # ● 开始选择特技  #--------------------------------------------------------------------------  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 = false  end  #--------------------------------------------------------------------------  # ● 选择特技结束  #--------------------------------------------------------------------------  def end_skill_select    # 释放特技窗口    @skill_window.dispose    @skill_window = nil    # 隐藏帮助窗口    @help_window.visible = false    # 有效化角色指令窗口    @actor_command_window.active = true    @actor_command_window.visible = true  end  #--------------------------------------------------------------------------  # ● 开始选择物品  #--------------------------------------------------------------------------  def start_item_select    # 生成物品窗口    @item_window = Window_Item.new    # 关联帮助窗口    @item_window.help_window = @help_window    # 无效化角色指令窗口    @actor_command_window.active = false    @actor_command_window.visible = false  end  #--------------------------------------------------------------------------  # ● 结束选择物品  #--------------------------------------------------------------------------  def end_item_select    # 释放物品窗口    @item_window.dispose    @item_window = nil    # 隐藏帮助窗口    @help_window.visible = false    # 有效化角色指令窗口    @actor_command_window.active = true    @actor_command_window.visible = true  endend复制代码
复制代码
弄好后效果如下图

下面是范例工程

            本帖来自P1论坛作者夜狠简单,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=314759  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

GMT+8, 2024-9-21 16:36 , Processed in 0.038345 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

返回顶部