Project1

标题: 关于复活技能的问题 [打印本页]

作者: MLRPG    时间: 2017-5-18 23:18
标题: 关于复活技能的问题
本帖最后由 MLRPG 于 2017-5-19 01:05 编辑

我根据这个帖子的内容设置了复活技能 效果的确实现了没有毛病
但是 全体复活技能的动画播放出现了问题:使用时播放一次 复活后又会播放一次 也就是说动画播放了2次(仅仅是播放动画 其他的没有问题)
那么请问可能是哪里出了问题 我的脚本有改动
RUBY 代码复制
  1. # ■ Scene_Battle (分割定义 4)
  2. #------------------------------------------------------------------------------
  3. #  处理战斗画面的类。
  4. #==============================================================================
  5.  
  6. class Scene_Battle
  7.   #--------------------------------------------------------------------------
  8.   # ● 开始主回合
  9.   #--------------------------------------------------------------------------
  10.   def start_phase4
  11.     # 转移到回合 4
  12.     @phase = 4
  13.     # 回合数计数
  14.     $game_temp.battle_turn += 1
  15.     # 搜索全页的战斗事件
  16.     for index in 0...$data_troops[@troop_id].pages.size
  17.       # 获取事件页
  18.       page = $data_troops[@troop_id].pages[index]
  19.       # 本页的范围是 [回合] 的情况下
  20.       if page.span == 1
  21.         # 设置已经执行标志
  22.         $game_temp.battle_event_flags[index] = false
  23.       end
  24.     end
  25.     # 设置角色为非选择状态
  26.     @actor_index = -1
  27.     @active_battler = nil
  28.     # 有效化同伴指令窗口
  29.     @party_command_window.active = false
  30.     @party_command_window.visible = false
  31.     # 无效化角色指令窗口
  32.     @actor_command_window.active = false
  33.     @actor_command_window.visible = false
  34.     # 设置主回合标志
  35.     $game_temp.battle_main_phase = true
  36.     # 生成敌人行动
  37.     for enemy in $game_troop.enemies
  38.       enemy.make_action
  39.     end
  40.     # 生成行动顺序
  41.     make_action_orders
  42.     # 移动到步骤 1
  43.     @phase4_step = 1
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # ● 生成行动循序
  47.   #--------------------------------------------------------------------------
  48.   def make_action_orders
  49.     # 初始化序列 @action_battlers
  50.     @action_battlers = []
  51.     # 添加敌人到 @action_battlers 序列
  52.     for enemy in $game_troop.enemies
  53.       @action_battlers.push(enemy)
  54.     end
  55.     # 添加角色到 @action_battlers 序列
  56.     for actor in $game_party.actors
  57.       @action_battlers.push(actor)
  58.     end
  59.     # 确定全体的行动速度
  60.     for battler in @action_battlers
  61.       battler.make_action_speed
  62.     end
  63.     # 按照行动速度从大到小排列
  64.     @action_battlers.sort! {|a,b|
  65.       b.current_action.speed - a.current_action.speed }
  66.   end
  67.   #--------------------------------------------------------------------------
  68.   # ● 刷新画面 (主回合)
  69.   #--------------------------------------------------------------------------
  70.   def update_phase4
  71.     case @phase4_step
  72.     when 1
  73.       update_phase4_step1
  74.     when 2
  75.       update_phase4_step2
  76.     when 3
  77.       update_phase4_step3
  78.     when 4
  79.       update_phase4_step4
  80.     when 5
  81.       update_phase4_step5
  82.     when 6
  83.       update_phase4_step6
  84.     end
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● 刷新画面 (主回合步骤 1 : 准备行动)
  88.   #--------------------------------------------------------------------------
  89.   def update_phase4_step1
  90.     # 隐藏帮助窗口
  91.     @help_window.visible = false
  92.     # 判定胜败
  93.     if judge
  94.       # 胜利或者失败的情况下 : 过程结束
  95.       return
  96.     end
  97.     # 强制行动的战斗者不存在的情况下
  98.     if $game_temp.forcing_battler == nil
  99.       # 设置战斗事件
  100.       setup_battle_event
  101.       # 执行战斗事件中的情况下
  102.       if $game_system.battle_interpreter.running?
  103.         return
  104.       end
  105.     end
  106.     # 强制行动的战斗者存在的情况下
  107.     if $game_temp.forcing_battler != nil
  108.       # 在头部添加后移动
  109.       @action_battlers.delete($game_temp.forcing_battler)
  110.       @action_battlers.unshift($game_temp.forcing_battler)
  111.     end
  112.     # 未行动的战斗者不存在的情况下 (全员已经行动)
  113.     if @action_battlers.size == 0
  114.       # 开始同伴命令回合
  115.       start_phase2
  116.       return
  117.     end
  118.     # 初始化动画 ID 和公共事件 ID
  119.     @animation1_id = 0
  120.     @animation2_id = 0
  121.     @common_event_id = 0
  122.     # 未行动的战斗者移动到序列的头部
  123.     @active_battler = @action_battlers.shift
  124.     # 如果已经在战斗之外的情况下
  125.     if @active_battler.index == nil
  126.       return
  127.     end
  128.     # 连续伤害
  129.     if @active_battler.hp > 0 and @active_battler.slip_damage?
  130.       @active_battler.slip_damage_effect
  131.       @active_battler.damage_pop = true
  132.     end
  133.     # 自然解除状态
  134.     @active_battler.remove_states_auto
  135.     # 刷新状态窗口
  136.     @status_window.refresh
  137.     # 移至步骤 2
  138.     @phase4_step = 2
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # ● 刷新画面 (主回合步骤 2 : 开始行动)
  142.   #--------------------------------------------------------------------------
  143.   def update_phase4_step2
  144.     # 如果不是强制行动
  145.     unless @active_battler.current_action.forcing
  146.       # 限制为 [敌人为普通攻击] 或 [我方为普通攻击] 的情况下
  147.       if @active_battler.restriction == 2 or @active_battler.restriction == 3
  148.         # 设置行动为攻击
  149.         @active_battler.current_action.kind = 0
  150.         @active_battler.current_action.basic = 0
  151.       end
  152.       # 限制为 [不能行动] 的情况下
  153.       if @active_battler.restriction == 4
  154.         # 清除行动强制对像的战斗者
  155.         $game_temp.forcing_battler = nil
  156.         # 移至步骤 1
  157.         @phase4_step = 1
  158.         return
  159.       end
  160.     end
  161.     # 清除对像战斗者
  162.     @target_battlers = []
  163.     # 行动种类分支
  164.     case @active_battler.current_action.kind
  165.     when 0  # 基本
  166.       make_basic_action_result
  167.     when 1  # 特技
  168.       make_skill_action_result
  169.     when 2  # 物品
  170.       make_item_action_result
  171.     end
  172.     # 移至步骤 3
  173.     if @phase4_step == 2
  174.       @phase4_step = 3
  175.     end
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # ● 生成基本行动结果
  179.   #--------------------------------------------------------------------------
  180.   def make_basic_action_result
  181.     # 攻击的情况下
  182.     if @active_battler.current_action.basic == 0
  183.       # 设置攻击 ID
  184.       @animation1_id = @active_battler.animation1_id
  185.       @animation2_id = @active_battler.animation2_id
  186.       # 行动方的战斗者是敌人的情况下
  187.       if @active_battler.is_a?(Game_Enemy)
  188.         if @active_battler.restriction == 3
  189.           target = $game_troop.random_target_enemy
  190.         elsif @active_battler.restriction == 2
  191.           target = $game_party.random_target_actor
  192.         else
  193.            #=====以下更改内容=========
  194.          target_got = false
  195.          for a in $game_party.actors
  196.            if (@active_battler.state?(50) and a.state?(50)) \
  197.              or (@active_battler.state?(51) and a.state?(51)) \
  198.              or (@active_battler.state?(52) and a.state?(52)) \
  199.              or (@active_battler.state?(53) and a.state?(53))
  200.                target = a
  201.                target_got = true  if a.hp>0
  202.            end
  203.          end
  204.          unless target_got
  205.              index = @active_battler.current_action.target_index
  206.              target = $game_party.smooth_target_actor(index) #原有内容
  207.          end
  208.         #=====以上更改内容=========
  209.         end
  210.       end
  211.       # 行动方的战斗者是角色的情况下
  212.       if @active_battler.is_a?(Game_Actor)
  213.         if @active_battler.restriction == 3
  214.           target = $game_party.random_target_actor
  215.         elsif @active_battler.restriction == 2
  216.           target = $game_troop.random_target_enemy
  217.         else
  218.           index = @active_battler.current_action.target_index
  219.           target = $game_troop.smooth_target_enemy(index)
  220.         end
  221.       end
  222.       # 设置对像方的战斗者序列
  223.       @target_battlers = [target]
  224.       # 应用通常攻击效果
  225.       for target in @target_battlers
  226.         target.attack_effect(@active_battler)
  227.       end
  228.       return
  229.     end
  230.     # 防御的情况下
  231.     if @active_battler.current_action.basic == 1
  232.       # 帮助窗口显示"防御"
  233.       @help_window.set_text($data_system.words.guard, 1)
  234.       return
  235.     end
  236.     # 逃跑的情况下
  237.     if @active_battler.is_a?(Game_Enemy) and
  238.        @active_battler.current_action.basic == 2
  239.       #  帮助窗口显示"逃跑"
  240.       @help_window.set_text("逃跑", 1)
  241.       # 逃跑
  242.       @active_battler.escape
  243.       return
  244.     end
  245.     # 什么也不做的情况下
  246.     if @active_battler.current_action.basic == 3
  247.       # 清除强制行动对像的战斗者
  248.       $game_temp.forcing_battler = nil
  249.       # 移至步骤 1
  250.       @phase4_step = 1
  251.       return
  252.     end
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # ● 设置物品或特技对像方的战斗者
  256.   #     scope : 特技或者是物品的范围
  257.   #--------------------------------------------------------------------------
  258.   def set_target_battlers(scope)
  259.     # 行动方的战斗者是敌人的情况下
  260.     if @active_battler.is_a?(Game_Enemy)
  261.       # 效果范围分支
  262.       case scope
  263.       when 1  # 敌单体
  264.         index = @active_battler.current_action.target_index
  265.         @target_battlers.push($game_party.smooth_target_actor(index))
  266.       when 2  # 敌全体
  267.         for actor in $game_party.actors
  268.           if actor.exist?
  269.             @target_battlers.push(actor)
  270.           end
  271.         end
  272.       when 3  # 我方单体
  273.         index = @active_battler.current_action.target_index
  274.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  275.       when 4  # 我方全体
  276.         for enemy in $game_troop.enemies
  277.           if enemy.exist?
  278.             @target_battlers.push(enemy)
  279.           end
  280.         end
  281.       when 5  # 我方单体 (HP 0)
  282.         index = @active_battler.current_action.target_index
  283.         enemy = $game_troop.enemies[index]
  284.         if enemy != nil
  285.           @target_battlers.push(enemy)
  286.         end
  287.       when 6  # 我方全体 (HP 0)
  288.         for enemy in $game_troop.enemies
  289.           if enemy != nil
  290.             @target_battlers.push(enemy)
  291.           end
  292.         end
  293.       when 7  # 使用者
  294.         @target_battlers.push(@active_battler)
  295.       end
  296.     end
  297.     # 行动方的战斗者是角色的情况下
  298.     if @active_battler.is_a?(Game_Actor)
  299.       # 效果范围分支
  300.       case scope
  301.       when 1  # 敌单体
  302.         index = @active_battler.current_action.target_index
  303.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  304.       when 2  # 敌全体
  305.         for enemy in $game_troop.enemies
  306.           if enemy.exist?
  307.             @target_battlers.push(enemy)
  308.           end
  309.         end
  310.       when 3  # 我方单体
  311.         index = @active_battler.current_action.target_index
  312.         @target_battlers.push($game_party.smooth_target_actor(index))
  313.       when 4  # 我方全体
  314.         for actor in $game_party.actors
  315.           if actor.exist?
  316.             @target_battlers.push(actor)
  317.           end
  318.         end
  319.       when 5  # 我方单体 (HP 0)
  320.         index = @active_battler.current_action.target_index
  321.         actor = $game_party.actors[index]
  322.         if actor != nil
  323.           @target_battlers.push(actor)
  324.         end
  325.       when 6  # 我方全体 (HP 0)
  326.         for actor in $game_party.actors
  327.           if actor != nil
  328.             @target_battlers.push(actor)
  329.           end
  330.         end
  331.       when 7  # 使用者
  332.         @target_battlers.push(@active_battler)
  333.       end
  334.     end
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # ● 生成特技行动结果
  338.   #--------------------------------------------------------------------------
  339.   def make_skill_action_result
  340.     # 获取特技
  341.     @skill = $data_skills[@active_battler.current_action.skill_id]
  342.     # 如果不是强制行动
  343.     unless @active_battler.current_action.forcing
  344.       # 因为 SP 耗尽而无法使用的情况下
  345.       unless @active_battler.skill_can_use?(@skill.id)
  346.         # 清除强制行动对像的战斗者
  347.         $game_temp.forcing_battler = nil
  348.         # 移至步骤 1
  349.         @phase4_step = 1
  350.         return
  351.       end
  352.     end
  353.     # 消耗 SP
  354.     @active_battler.sp -= @skill.sp_cost
  355.     # 刷新状态窗口
  356.     @status_window.refresh
  357.     # 在帮助窗口显示特技名
  358.     @help_window.set_text(@skill.name, 1)
  359.     # 设置动画 ID
  360.     @animation1_id = @skill.animation1_id
  361.     @animation2_id = @skill.animation2_id
  362.     # 设置公共事件 ID
  363.     @common_event_id = @skill.common_event_id
  364.     # 设置对像侧战斗者
  365.     set_target_battlers(@skill.scope)
  366.     # 应用特技效果
  367.     for target in @target_battlers
  368.       target.skill_effect(@active_battler, @skill)
  369.     end
  370.   end
  371.   #--------------------------------------------------------------------------
  372.   # ● 生成物品行动结果
  373.   #--------------------------------------------------------------------------
  374.   def make_item_action_result
  375.     # 获取物品
  376.     @item = $data_items[@active_battler.current_action.item_id]
  377.     # 因为物品耗尽而无法使用的情况下
  378.     unless $game_party.item_can_use?(@item.id)
  379.       # 移至步骤 1
  380.       @phase4_step = 1
  381.       return
  382.     end
  383.     # 消耗品的情况下
  384.     if @item.consumable
  385.       # 使用的物品减 1
  386.       $game_party.lose_item(@item.id, 1)
  387.     end
  388.     # 在帮助窗口显示物品名
  389.     @help_window.set_text(@item.name, 1)
  390.     # 设置动画 ID
  391.     @animation1_id = @item.animation1_id
  392.     @animation2_id = @item.animation2_id
  393.     # 设置公共事件 ID
  394.     @common_event_id = @item.common_event_id
  395.     # 确定对像
  396.     index = @active_battler.current_action.target_index
  397.     target = $game_party.smooth_target_actor(index)
  398.     # 设置对像侧战斗者
  399.     set_target_battlers(@item.scope)
  400.     # 应用物品效果
  401.     for target in @target_battlers
  402.       target.item_effect(@item)
  403.     end
  404.   end
  405.   #--------------------------------------------------------------------------
  406.   # ● 刷新画面 (主回合步骤 3 : 行动方动画)
  407.   #--------------------------------------------------------------------------
  408.   def update_phase4_step3
  409.     # 行动方动画 (ID 为 0 的情况下是白色闪烁)
  410.     if @animation1_id == 0
  411.       @active_battler.white_flash = true
  412.     else
  413.       @active_battler.animation_id = @animation1_id
  414.       @active_battler.animation_hit = true
  415.     end
  416.     # 移至步骤 4
  417.     @phase4_step = 4
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # ● 刷新画面 (主回合步骤 4 : 对像方动画)
  421.   #--------------------------------------------------------------------------
  422.   def update_phase4_step4
  423.     # 对像方动画
  424.     for target in @target_battlers
  425.       target.animation_id = @animation2_id
  426.       target.animation_hit = (target.damage != "Miss")
  427.     end
  428.     # 限制动画长度、最低 8 帧
  429.     @wait_count = 8
  430.     # 移至步骤 5
  431.     @phase4_step = 5
  432.   end
  433.   #--------------------------------------------------------------------------
  434.   # ● 刷新画面 (主回合步骤 5 : 显示伤害)
  435.   #--------------------------------------------------------------------------
  436.   def update_phase4_step5
  437.     # 隐藏帮助窗口
  438.     @help_window.visible = false
  439.     # 刷新状态窗口
  440.     @status_window.refresh
  441.     # 显示伤害
  442.     for target in @target_battlers
  443.       if target.damage != nil
  444.         target.damage_pop = true
  445.       end
  446.     end
  447.     # 移至步骤 6
  448.     @phase4_step = 6
  449.   end
  450.   #--------------------------------------------------------------------------
  451.   # ● 刷新画面 (主回合步骤 6 : 刷新)
  452.   #--------------------------------------------------------------------------
  453.   def update_phase4_step6
  454.     # 清除强制行动对像的战斗者
  455.     $game_temp.forcing_battler = nil
  456.     # 公共事件 ID 有效的情况下
  457.     if @common_event_id > 0
  458.       # 设置事件
  459.       common_event = $data_common_events[@common_event_id]
  460.       $game_system.battle_interpreter.setup(common_event.list, 0)
  461.     end
  462.     # 移至步骤 1
  463.     @phase4_step = 1
  464.   end
  465. end

作者: guoxiaomi    时间: 2017-5-19 02:21
可能是你设置了2个动画?去掉对象方的动画试试?




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1