设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1936|回复: 0
打印 上一主题 下一主题

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
136
在线时间
623 小时
注册时间
2008-11-16
帖子
440
跳转到指定楼层
1
发表于 2016-1-10 15:38:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 萧萧风色 于 2016-1-16 09:38 编辑

RUBY 代码复制
  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.     # 连续伤害
  64.     if @active_battler.hp > 0 and @active_battler.slip_damage?
  65.       @active_battler.slip_damage_effect
  66.       @active_battler.damage_pop = true
  67.     end
  68.     # 自然解除状态
  69.     @active_battler.remove_states_auto
  70.     # 刷新状态窗口
  71.     @status_window.refresh
  72.     # 移至步骤 2
  73.     @phase4_step = 2
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ● 刷新画面 (主回合步骤 2 : 开始行动)
  77.   #--------------------------------------------------------------------------
  78.   def update_phase4_step2
  79.     # 如果不是强制行动
  80.     unless @active_battler.current_action.forcing
  81.       # 限制为 [敌人为普通攻击] 或 [我方为普通攻击] 的情况下
  82.       if @active_battler.restriction == 2 or @active_battler.restriction == 3
  83.         # 设置行动为攻击
  84.         @active_battler.current_action.kind = 0
  85.         @active_battler.current_action.basic = 0
  86.       end
  87.       # 限制为 [不能行动] 的情况下
  88.       if @active_battler.restriction == 4
  89.         # 清除行动强制对像的战斗者
  90.         $game_temp.forcing_battler = nil
  91.         # 移至步骤 1
  92.         @phase4_step = 1
  93.         return
  94.       end
  95.     end
  96.     # 清除对像战斗者
  97.     @target_battlers = []
  98.     # 行动种类分支
  99.     case @active_battler.current_action.kind
  100.     when 0  # 基本
  101.       make_basic_action_result
  102.     when 1  # 特技
  103.       make_skill_action_result
  104.     when 2  # 物品
  105.       make_item_action_result
  106.     end
  107.     # 移至步骤 3
  108.     if @phase4_step == 2
  109.       @phase4_step = 3
  110.     end
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # ● 生成基本行动结果
  114.   #--------------------------------------------------------------------------
  115.   def make_basic_action_result
  116.     # 攻击的情况下
  117.     if @active_battler.current_action.basic == 0
  118.       # 设置攻击 ID
  119.       @animation1_id = @active_battler.animation1_id
  120.       @animation2_id = @active_battler.animation2_id
  121.       # 行动方的战斗者是敌人的情况下
  122.       if @active_battler.is_a?(Game_Enemy)
  123.         if @active_battler.restriction == 3
  124.           target = $game_troop.random_target_enemy
  125.         elsif @active_battler.restriction == 2
  126.           target = $game_party.random_target_actor
  127.         else
  128.           index = @active_battler.current_action.target_index
  129.           target = $game_party.smooth_target_actor(index)
  130.         end
  131.       end
  132.       # 行动方的战斗者是角色的情况下
  133.       if @active_battler.is_a?(Game_Actor)
  134.         if @active_battler.restriction == 3
  135.           target = $game_party.random_target_actor
  136.         elsif @active_battler.restriction == 2
  137.           target = $game_troop.random_target_enemy
  138.         else
  139.           index = @active_battler.current_action.target_index
  140.           target = $game_troop.smooth_target_enemy(index)
  141.         end
  142.       end
  143.       # 设置对像方的战斗者序列
  144.       @target_battlers = [target]
  145.       # 应用通常攻击效果
  146.       for target in @target_battlers
  147.         target.attack_effect(@active_battler)
  148.       end
  149.       return
  150.     end
  151.     # 防御的情况下
  152.     if @active_battler.current_action.basic == 1
  153.       # 帮助窗口显示"防御"
  154.       @help_window.set_text($data_system.words.guard, 1)
  155.       return
  156.     end
  157.     # 逃跑的情况下
  158.     if @active_battler.is_a?(Game_Enemy) and
  159.        @active_battler.current_action.basic == 2
  160.       #  帮助窗口显示"逃跑"
  161.       @help_window.set_text("逃跑", 1)
  162.       # 逃跑
  163.       @active_battler.escape
  164.       return
  165.     end
  166.     # 什么也不做的情况下
  167.     if @active_battler.current_action.basic == 3
  168.       # 清除强制行动对像的战斗者
  169.       $game_temp.forcing_battler = nil
  170.       # 移至步骤 1
  171.       @phase4_step = 1
  172.       return
  173.     end
  174.   end
  175.   #--------------------------------------------------------------------------
  176.   # ● 设置物品或特技对像方的战斗者
  177.   #     scope : 特技或者是物品的范围
  178.   #--------------------------------------------------------------------------
  179.   def set_target_battlers(scope)
  180.     # 行动方的战斗者是敌人的情况下
  181.     if @active_battler.is_a?(Game_Enemy)
  182.       # 效果范围分支
  183.       case scope
  184.       when 1  # 敌单体
  185.         index = @active_battler.current_action.target_index
  186.         @target_battlers.push($game_party.smooth_target_actor(index))
  187.       when 2  # 敌全体
  188.         for actor in $game_party.actors
  189.           if actor.exist?
  190.             @target_battlers.push(actor)
  191.           end
  192.         end
  193.       when 3  # 我方单体
  194.         index = @active_battler.current_action.target_index
  195.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  196.       when 4  # 我方全体
  197.         for enemy in $game_troop.enemies
  198.           if enemy.exist?
  199.             @target_battlers.push(enemy)
  200.           end
  201.         end
  202.       when 5  # 我方单体 (HP 0)
  203.         index = @active_battler.current_action.target_index
  204.         enemy = $game_troop.enemies[index]
  205.         if enemy != nil and enemy.hp0?
  206.           @target_battlers.push(enemy)
  207.         end
  208.       when 6  # 我方全体 (HP 0)
  209.         for enemy in $game_troop.enemies
  210.           if enemy != nil and enemy.hp0?
  211.             @target_battlers.push(enemy)
  212.           end
  213.         end
  214.       when 7  # 使用者
  215.         @target_battlers.push(@active_battler)
  216.       end
  217.     end
  218.     # 行动方的战斗者是角色的情况下
  219.     if @active_battler.is_a?(Game_Actor)
  220.       # 效果范围分支
  221.       case scope
  222.       when 1  # 敌单体
  223.         index = @active_battler.current_action.target_index
  224.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  225.       when 2  # 敌全体
  226.         for enemy in $game_troop.enemies
  227.           if enemy.exist?
  228.             @target_battlers.push(enemy)
  229.           end
  230.         end
  231.       when 3  # 我方单体
  232.         index = @active_battler.current_action.target_index
  233.         @target_battlers.push($game_party.smooth_target_actor(index))
  234.       when 4  # 我方全体
  235.         for actor in $game_party.actors
  236.           if actor.exist?
  237.             @target_battlers.push(actor)
  238.           end
  239.         end
  240.       when 5  # 我方单体 (HP 0)
  241.         index = @active_battler.current_action.target_index
  242.         actor = $game_party.actors[index]
  243.         if actor != nil and actor.hp0?
  244.           @target_battlers.push(actor)
  245.         end
  246.       when 6  # 我方全体 (HP 0)
  247.         for actor in $game_party.actors
  248.           if actor != nil and actor.hp0?
  249.             @target_battlers.push(actor)
  250.           end
  251.         end
  252.       when 7  # 使用者
  253.         @target_battlers.push(@active_battler)
  254.       end
  255.     end
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # ● 生成特技行动结果
  259.   #--------------------------------------------------------------------------
  260.   def make_skill_action_result
  261.     # 获取特技
  262.     @skill = $data_skills[@active_battler.current_action.skill_id]
  263.     # 如果不是强制行动
  264.     unless @active_battler.current_action.forcing
  265.       # 因为 SP 耗尽而无法使用的情况下
  266.       unless @active_battler.skill_can_use?(@skill.id)
  267.         # 清除强制行动对像的战斗者
  268.         $game_temp.forcing_battler = nil
  269.         # 移至步骤 1
  270.         @phase4_step = 1
  271.         return
  272.       end
  273.     end
  274.  
  275.     # 设置公共事件 ID
  276.     @common_event_id = @skill.common_event_id
  277.  
  278. #※※※※※※※※※※※※※※插入点在这里※※※※※※※※※※※※※※※※※※※※※※※
  279.  
  280.     # 消耗 SP
  281.     @active_battler.sp -= @skill.sp_cost
  282.     # 刷新状态窗口
  283.     @status_window.refresh
  284.     # 在帮助窗口显示特技名
  285.     @help_window.set_text(@skill.name, 1)
  286.     # 设置动画 ID
  287.     @animation1_id = @skill.animation1_id
  288.     @animation2_id = @skill.animation2_id
  289.  
  290.     # 设置对像侧战斗者
  291.     set_target_battlers(@skill.scope)
  292.  
  293.  
  294.     # 应用特技效果
  295.     for target in @target_battlers
  296.       target.skill_effect(@active_battler, @skill)
  297.     end
  298.  
  299.  
  300.  
  301.  
  302.  
  303.   end
  304.  
  305.   #--------------------------------------------------------------------------
  306.   # ● 生成物品行动结果
  307.   #--------------------------------------------------------------------------
  308.   def make_item_action_result
  309.     # 获取物品
  310.     @item = $data_items[@active_battler.current_action.item_id]
  311.     # 因为物品耗尽而无法使用的情况下
  312.     unless $game_party.item_can_use?(@item.id)
  313.       # 移至步骤 1
  314.       @phase4_step = 1
  315.       return
  316.     end
  317.     # 消耗品的情况下
  318.     if @item.consumable
  319.       # 使用的物品减 1
  320.       $game_party.lose_item(@item.id, 1)
  321.     end
  322.     # 在帮助窗口显示物品名
  323.     @help_window.set_text(@item.name, 1)
  324.     # 设置动画 ID
  325.     @animation1_id = @item.animation1_id
  326.     @animation2_id = @item.animation2_id
  327.     # 设置公共事件 ID
  328.     @common_event_id = @item.common_event_id
  329.     # 确定对像
  330.     index = @active_battler.current_action.target_index
  331.     target = $game_party.smooth_target_actor(index)
  332.     # 设置对像侧战斗者
  333.     set_target_battlers(@item.scope)
  334.     # 应用物品效果
  335.     for target in @target_battlers
  336.       target.item_effect(@item)
  337.     end
  338.   end
  339.   #--------------------------------------------------------------------------
  340.   # ● 刷新画面 (主回合步骤 3 : 行动方动画)
  341.   #--------------------------------------------------------------------------
  342.   def update_phase4_step3
  343.     # 行动方动画 (ID 为 0 的情况下是白色闪烁)
  344.     if @animation1_id == 0
  345.       @active_battler.white_flash = true
  346.     else
  347.       @active_battler.animation_id = @animation1_id
  348.       @active_battler.animation_hit = true
  349.     end
  350.     # 移至步骤 4
  351.     @phase4_step = 4
  352.   end
  353.   #--------------------------------------------------------------------------
  354.   # ● 刷新画面 (主回合步骤 4 : 对像方动画)
  355.   #--------------------------------------------------------------------------
  356.   def update_phase4_step4
  357.     # 对像方动画
  358.     for target in @target_battlers
  359.       target.animation_id = @animation2_id
  360.       target.animation_hit = (target.damage != "Miss")
  361.     end
  362.     # 限制动画长度、最低 8 帧
  363.     @wait_count = 8
  364.     # 移至步骤 5
  365.     @phase4_step = 5
  366.   end
  367.   #--------------------------------------------------------------------------
  368.   # ● 刷新画面 (主回合步骤 5 : 显示伤害)
  369.   #--------------------------------------------------------------------------
  370.   def update_phase4_step5
  371.     # 隐藏帮助窗口
  372.     @help_window.visible = false
  373.     # 刷新状态窗口
  374.     @status_window.refresh
  375.     # 显示伤害
  376.     for target in @target_battlers
  377.       if target.damage != nil
  378.         target.damage_pop = true
  379.       end
  380.     end
  381.     # 移至步骤 6
  382.     @phase4_step = 6
  383.   end
  384.   #--------------------------------------------------------------------------
  385.   # ● 刷新画面 (主回合步骤 6 : 刷新)
  386.   #--------------------------------------------------------------------------
  387.   def update_phase4_step6
  388.     # 清除强制行动对像的战斗者
  389.     $game_temp.forcing_battler = nil
  390.  
  391.     # 公共事件 ID 有效的情况下
  392.     if @common_event_id > 0
  393.       # 设置事件
  394.       common_event = $data_common_events[@common_event_id]
  395.       $game_system.battle_interpreter.setup(common_event.list, 0)
  396.     end
  397.  
  398.  
  399.     # 移至步骤 1
  400.     @phase4_step = 1
  401.   end
  402. end


这是Scene_Battle 4中的一段脚本,这里定义了一个顺序——默认情况下是先执行技能以及相关动画等,最后执行技能带的公共事件。
我想让公共事件先执行然后再执行其他的东西,也就是把顺序调一下。
所以尝试把
RUBY 代码复制
  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
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-29 20:49

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表