查看: 2432|回复: 0

[已经过期] 技能公共事件如何优先执行

[复制链接]
梦石
0
星屑
136
在线时间
623 小时
注册时间
2008-11-16
回帖
404
发表于 2016-1-10 15:38:51 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 萧萧风色 于 2016-1-16 09:38 编辑
  1. #--------------------------------------------------------------------------
  2.   # ● 刷新画面 (主回合)
  3.   #--------------------------------------------------------------------------
  4.   def update_phase4
  5.     case @phase4_step
  6.     when 1
  7.       update_phase4_step1
  8.     when 2
  9.       update_phase4_step2
  10.     when 3
  11.       update_phase4_step3
  12.     when 4
  13.       update_phase4_step4
  14.     when 5
  15.       update_phase4_step5
  16.     when 6
  17.       update_phase4_step6
  18.     end
  19.   end
  20.   #--------------------------------------------------------------------------
  21.   # ● 刷新画面 (主回合步骤 1 : 准备行动)
  22.   #--------------------------------------------------------------------------
  23.   def update_phase4_step1
  24.     # 隐藏帮助窗口
  25.     @help_window.visible = false
  26.     # 判定胜败
  27.     if judge
  28.       # 胜利或者失败的情况下 : 过程结束
  29.       return
  30.     end
  31.     # 强制行动的战斗者不存在的情况下
  32.     if $game_temp.forcing_battler == nil
  33.       # 设置战斗事件
  34.       setup_battle_event
  35.       # 执行战斗事件中的情况下
  36.       if $game_system.battle_interpreter.running?
  37.         return
  38.       end
  39.     end
  40.     # 强制行动的战斗者存在的情况下
  41.     if $game_temp.forcing_battler != nil
  42.       # 在头部添加后移动
  43.       @action_battlers.delete($game_temp.forcing_battler)
  44.       @action_battlers.unshift($game_temp.forcing_battler)
  45.     end
  46.     # 未行动的战斗者不存在的情况下 (全员已经行动)
  47.     if @action_battlers.size == 0
  48.       # 开始同伴命令回合
  49.       start_phase2
  50.       return
  51.     end
  52.     # 初始化动画 ID 和公共事件 ID
  53.     @animation1_id = 0
  54.     @animation2_id = 0
  55.     @common_event_id = 0
  56.     # 未行动的战斗者移动到序列的头部
  57.     @active_battler = @action_battlers.shift
  58.     # 如果已经在战斗之外的情况下
  59.     if @active_battler.index == nil
  60.       return
  61.     end

  62.     # 连续伤害
  63.     if @active_battler.hp > 0 and @active_battler.slip_damage?
  64.       @active_battler.slip_damage_effect
  65.       @active_battler.damage_pop = true
  66.     end
  67.     # 自然解除状态
  68.     @active_battler.remove_states_auto
  69.     # 刷新状态窗口
  70.     @status_window.refresh
  71.     # 移至步骤 2
  72.     @phase4_step = 2
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # ● 刷新画面 (主回合步骤 2 : 开始行动)
  76.   #--------------------------------------------------------------------------
  77.   def update_phase4_step2
  78.     # 如果不是强制行动
  79.     unless @active_battler.current_action.forcing
  80.       # 限制为 [敌人为普通攻击] 或 [我方为普通攻击] 的情况下
  81.       if @active_battler.restriction == 2 or @active_battler.restriction == 3
  82.         # 设置行动为攻击
  83.         @active_battler.current_action.kind = 0
  84.         @active_battler.current_action.basic = 0
  85.       end
  86.       # 限制为 [不能行动] 的情况下
  87.       if @active_battler.restriction == 4
  88.         # 清除行动强制对像的战斗者
  89.         $game_temp.forcing_battler = nil
  90.         # 移至步骤 1
  91.         @phase4_step = 1
  92.         return
  93.       end
  94.     end
  95.     # 清除对像战斗者
  96.     @target_battlers = []
  97.     # 行动种类分支
  98.     case @active_battler.current_action.kind
  99.     when 0  # 基本
  100.       make_basic_action_result
  101.     when 1  # 特技
  102.       make_skill_action_result
  103.     when 2  # 物品
  104.       make_item_action_result
  105.     end
  106.     # 移至步骤 3
  107.     if @phase4_step == 2
  108.       @phase4_step = 3
  109.     end
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # ● 生成基本行动结果
  113.   #--------------------------------------------------------------------------
  114.   def make_basic_action_result
  115.     # 攻击的情况下
  116.     if @active_battler.current_action.basic == 0
  117.       # 设置攻击 ID
  118.       @animation1_id = @active_battler.animation1_id
  119.       @animation2_id = @active_battler.animation2_id
  120.       # 行动方的战斗者是敌人的情况下
  121.       if @active_battler.is_a?(Game_Enemy)
  122.         if @active_battler.restriction == 3
  123.           target = $game_troop.random_target_enemy
  124.         elsif @active_battler.restriction == 2
  125.           target = $game_party.random_target_actor
  126.         else
  127.           index = @active_battler.current_action.target_index
  128.           target = $game_party.smooth_target_actor(index)
  129.         end
  130.       end
  131.       # 行动方的战斗者是角色的情况下
  132.       if @active_battler.is_a?(Game_Actor)
  133.         if @active_battler.restriction == 3
  134.           target = $game_party.random_target_actor
  135.         elsif @active_battler.restriction == 2
  136.           target = $game_troop.random_target_enemy
  137.         else
  138.           index = @active_battler.current_action.target_index
  139.           target = $game_troop.smooth_target_enemy(index)
  140.         end
  141.       end
  142.       # 设置对像方的战斗者序列
  143.       @target_battlers = [target]
  144.       # 应用通常攻击效果
  145.       for target in @target_battlers
  146.         target.attack_effect(@active_battler)
  147.       end
  148.       return
  149.     end
  150.     # 防御的情况下
  151.     if @active_battler.current_action.basic == 1
  152.       # 帮助窗口显示"防御"
  153.       @help_window.set_text($data_system.words.guard, 1)
  154.       return
  155.     end
  156.     # 逃跑的情况下
  157.     if @active_battler.is_a?(Game_Enemy) and
  158.        @active_battler.current_action.basic == 2
  159.       #  帮助窗口显示"逃跑"
  160.       @help_window.set_text("逃跑", 1)
  161.       # 逃跑
  162.       @active_battler.escape
  163.       return
  164.     end
  165.     # 什么也不做的情况下
  166.     if @active_battler.current_action.basic == 3
  167.       # 清除强制行动对像的战斗者
  168.       $game_temp.forcing_battler = nil
  169.       # 移至步骤 1
  170.       @phase4_step = 1
  171.       return
  172.     end
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # ● 设置物品或特技对像方的战斗者
  176.   #     scope : 特技或者是物品的范围
  177.   #--------------------------------------------------------------------------
  178.   def set_target_battlers(scope)
  179.     # 行动方的战斗者是敌人的情况下
  180.     if @active_battler.is_a?(Game_Enemy)
  181.       # 效果范围分支
  182.       case scope
  183.       when 1  # 敌单体
  184.         index = @active_battler.current_action.target_index
  185.         @target_battlers.push($game_party.smooth_target_actor(index))
  186.       when 2  # 敌全体
  187.         for actor in $game_party.actors
  188.           if actor.exist?
  189.             @target_battlers.push(actor)
  190.           end
  191.         end
  192.       when 3  # 我方单体
  193.         index = @active_battler.current_action.target_index
  194.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  195.       when 4  # 我方全体
  196.         for enemy in $game_troop.enemies
  197.           if enemy.exist?
  198.             @target_battlers.push(enemy)
  199.           end
  200.         end
  201.       when 5  # 我方单体 (HP 0)
  202.         index = @active_battler.current_action.target_index
  203.         enemy = $game_troop.enemies[index]
  204.         if enemy != nil and enemy.hp0?
  205.           @target_battlers.push(enemy)
  206.         end
  207.       when 6  # 我方全体 (HP 0)
  208.         for enemy in $game_troop.enemies
  209.           if enemy != nil and enemy.hp0?
  210.             @target_battlers.push(enemy)
  211.           end
  212.         end
  213.       when 7  # 使用者
  214.         @target_battlers.push(@active_battler)
  215.       end
  216.     end
  217.     # 行动方的战斗者是角色的情况下
  218.     if @active_battler.is_a?(Game_Actor)
  219.       # 效果范围分支
  220.       case scope
  221.       when 1  # 敌单体
  222.         index = @active_battler.current_action.target_index
  223.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  224.       when 2  # 敌全体
  225.         for enemy in $game_troop.enemies
  226.           if enemy.exist?
  227.             @target_battlers.push(enemy)
  228.           end
  229.         end
  230.       when 3  # 我方单体
  231.         index = @active_battler.current_action.target_index
  232.         @target_battlers.push($game_party.smooth_target_actor(index))
  233.       when 4  # 我方全体
  234.         for actor in $game_party.actors
  235.           if actor.exist?
  236.             @target_battlers.push(actor)
  237.           end
  238.         end
  239.       when 5  # 我方单体 (HP 0)
  240.         index = @active_battler.current_action.target_index
  241.         actor = $game_party.actors[index]
  242.         if actor != nil and actor.hp0?
  243.           @target_battlers.push(actor)
  244.         end
  245.       when 6  # 我方全体 (HP 0)
  246.         for actor in $game_party.actors
  247.           if actor != nil and actor.hp0?
  248.             @target_battlers.push(actor)
  249.           end
  250.         end
  251.       when 7  # 使用者
  252.         @target_battlers.push(@active_battler)
  253.       end
  254.     end
  255.   end
  256.   #--------------------------------------------------------------------------
  257.   # ● 生成特技行动结果
  258.   #--------------------------------------------------------------------------
  259.   def make_skill_action_result
  260.     # 获取特技
  261.     @skill = $data_skills[@active_battler.current_action.skill_id]
  262.     # 如果不是强制行动
  263.     unless @active_battler.current_action.forcing
  264.       # 因为 SP 耗尽而无法使用的情况下
  265.       unless @active_battler.skill_can_use?(@skill.id)
  266.         # 清除强制行动对像的战斗者
  267.         $game_temp.forcing_battler = nil
  268.         # 移至步骤 1
  269.         @phase4_step = 1
  270.         return
  271.       end
  272.     end
  273.    
  274.     # 设置公共事件 ID
  275.     @common_event_id = @skill.common_event_id
  276.    
  277. #※※※※※※※※※※※※※※插入点在这里※※※※※※※※※※※※※※※※※※※※※※※
  278.    
  279.     # 消耗 SP
  280.     @active_battler.sp -= @skill.sp_cost
  281.     # 刷新状态窗口
  282.     @status_window.refresh
  283.     # 在帮助窗口显示特技名
  284.     @help_window.set_text(@skill.name, 1)
  285.     # 设置动画 ID
  286.     @animation1_id = @skill.animation1_id
  287.     @animation2_id = @skill.animation2_id
  288.    
  289.     # 设置对像侧战斗者
  290.     set_target_battlers(@skill.scope)
  291.    

  292.     # 应用特技效果
  293.     for target in @target_battlers
  294.       target.skill_effect(@active_battler, @skill)
  295.     end


  296.   
  297.    
  298.    
  299.   end
  300.   
  301.   #--------------------------------------------------------------------------
  302.   # ● 生成物品行动结果
  303.   #--------------------------------------------------------------------------
  304.   def make_item_action_result
  305.     # 获取物品
  306.     @item = $data_items[@active_battler.current_action.item_id]
  307.     # 因为物品耗尽而无法使用的情况下
  308.     unless $game_party.item_can_use?(@item.id)
  309.       # 移至步骤 1
  310.       @phase4_step = 1
  311.       return
  312.     end
  313.     # 消耗品的情况下
  314.     if @item.consumable
  315.       # 使用的物品减 1
  316.       $game_party.lose_item(@item.id, 1)
  317.     end
  318.     # 在帮助窗口显示物品名
  319.     @help_window.set_text(@item.name, 1)
  320.     # 设置动画 ID
  321.     @animation1_id = @item.animation1_id
  322.     @animation2_id = @item.animation2_id
  323.     # 设置公共事件 ID
  324.     @common_event_id = @item.common_event_id
  325.     # 确定对像
  326.     index = @active_battler.current_action.target_index
  327.     target = $game_party.smooth_target_actor(index)
  328.     # 设置对像侧战斗者
  329.     set_target_battlers(@item.scope)
  330.     # 应用物品效果
  331.     for target in @target_battlers
  332.       target.item_effect(@item)
  333.     end
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # ● 刷新画面 (主回合步骤 3 : 行动方动画)
  337.   #--------------------------------------------------------------------------
  338.   def update_phase4_step3
  339.     # 行动方动画 (ID 为 0 的情况下是白色闪烁)
  340.     if @animation1_id == 0
  341.       @active_battler.white_flash = true
  342.     else
  343.       @active_battler.animation_id = @animation1_id
  344.       @active_battler.animation_hit = true
  345.     end
  346.     # 移至步骤 4
  347.     @phase4_step = 4
  348.   end
  349.   #--------------------------------------------------------------------------
  350.   # ● 刷新画面 (主回合步骤 4 : 对像方动画)
  351.   #--------------------------------------------------------------------------
  352.   def update_phase4_step4
  353.     # 对像方动画
  354.     for target in @target_battlers
  355.       target.animation_id = @animation2_id
  356.       target.animation_hit = (target.damage != "Miss")
  357.     end
  358.     # 限制动画长度、最低 8 帧
  359.     @wait_count = 8
  360.     # 移至步骤 5
  361.     @phase4_step = 5
  362.   end
  363.   #--------------------------------------------------------------------------
  364.   # ● 刷新画面 (主回合步骤 5 : 显示伤害)
  365.   #--------------------------------------------------------------------------
  366.   def update_phase4_step5
  367.     # 隐藏帮助窗口
  368.     @help_window.visible = false
  369.     # 刷新状态窗口
  370.     @status_window.refresh
  371.     # 显示伤害
  372.     for target in @target_battlers
  373.       if target.damage != nil
  374.         target.damage_pop = true
  375.       end
  376.     end
  377.     # 移至步骤 6
  378.     @phase4_step = 6
  379.   end
  380.   #--------------------------------------------------------------------------
  381.   # ● 刷新画面 (主回合步骤 6 : 刷新)
  382.   #--------------------------------------------------------------------------
  383.   def update_phase4_step6
  384.     # 清除强制行动对像的战斗者
  385.     $game_temp.forcing_battler = nil

  386.     # 公共事件 ID 有效的情况下
  387.     if @common_event_id > 0
  388.       # 设置事件
  389.       common_event = $data_common_events[@common_event_id]
  390.       $game_system.battle_interpreter.setup(common_event.list, 0)
  391.     end

  392.    
  393.     # 移至步骤 1
  394.     @phase4_step = 1
  395.   end
  396. end
复制代码


这是Scene_Battle 4中的一段脚本,这里定义了一个顺序——默认情况下是先执行技能以及相关动画等,最后执行技能带的公共事件。
我想让公共事件先执行然后再执行其他的东西,也就是把顺序调一下。
所以尝试把
  1. # 公共事件 ID 有效的情况下
  2.     if @common_event_id > 0
  3.       # 设置事件
  4.       common_event = $data_common_events[@common_event_id]
  5.       $game_system.battle_interpreter.setup(common_event.list, 0)
  6.     end
复制代码

这段放到了“※※※※※※※插入点在这里※※※※※※※※”的位置中去。

测试后发现公共事件确实先于技能处理执行了,但是有一个问题出现了:如果该技能恰好可以使战斗结束(比如设置一个伤害巨大的AOE,可以直接把敌人全歼),那么将会不显示任何技能的动画和伤害处理的过程,而是在公共事件执行完后直接跳到战斗结束画面上。请教一下这个问题怎么解决?谢谢
(注:我还使用了全动画战斗脚本,不知道是否和这个脚本有关)  
希望大家可以支持《吃货计划:绫重奏》https://rpg.blue/forum.php?mod=viewthread&tid=402357&extra=&page=1
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部