Project1

标题: 求助 MOG_ATB_战斗系统战斗内弹选项卡死 [打印本页]

作者: 神隐的主犯    时间: 前天 23:36
标题: 求助 MOG_ATB_战斗系统战斗内弹选项卡死



大佬们救救,我这边用的mog系统,不知道为什么,战斗内只要一安排选项,就会卡死。

就上边那个图出现后,按啥都没反应,这是为什么啊。该怎麽办?


附上mog脚本
RUBY 代码复制
  1. #mogztb核心
  2. # By Moghunter
  3. # https://atelierrgss.wordpress.com/
  4. #==============================================================================
  5. # 即时战斗系统.为全部角色和敌人添加AT值,AT值决定其行动顺序
  6. #==============================================================================
  7.  
  8. #==============================================================================
  9. # 注意 1
  10. #==============================================================================
  11. # 本脚本不包含ATB行动条功能,要显示行动条还需要脚本以下脚本:
  12. #
  13. # 战斗 Hud EX
  14. # Ayesha ATB Gauge
  15. # ATB 行动条
  16. #
  17. #==============================================================================
  18. # 注意 2
  19. #==============================================================================
  20. # 本脚本隐藏了画面上方的战斗日志,所以最好额外使用一些伤害显示的脚本。
  21. #==============================================================================
  22.  
  23. #==============================================================================
  24. # ● ATB 系统
  25. #==============================================================================
  26. # 角色的AT速度(行动速度)由其敏捷值决定。一般情况下,战斗开始时角色和敌人的AT
  27. # 值都为40%;队伍先发制人的情况下角色的AT值为80%,而敌人的为0;队伍被偷袭的情
  28. # 况下角色的AT值为0,而敌人的为80%。
  29. #==============================================================================
  30. # ● 施放时间
  31. #==============================================================================
  32. # 如果要对技能/物品设定施放等待时间的效果,设定其"速度修正"不为0就行。
  33. #
  34. # 注意 - 在同一轮中不能同时使用2个或多个带有"速度修正"的技能/物品。
  35. # (如果你还用了有多行动回合功能的脚本的话)
  36. #==============================================================================
  37.  
  38. #==============================================================================
  39. # 脚本
  40. #==============================================================================
  41. #
  42. # atb_type(类型)                - 改变 ATB 的类型(下面有介绍).
  43. # atb_max(X)                    - 设定 ATB 总时间.
  44. # atb_stop                      - 暂停 ATB 的流动.
  45. # atb_turn_speed(X)             - 设置多长时间算一个回合.
  46. # atb_turn_stop                 - 停止回合计数.
  47. # atb_turn_reset                - 回合数清零.
  48. # atb_sprite_turn(false)        - 显示或隐藏回合数精灵.
  49. #
  50. #==============================================================================
  51.  
  52. #==============================================================================
  53. # Histórico
  54. #==============================================================================
  55. # v6.1 - Correção do crash na seleção de skills vazias.
  56. # v6.0 - Melhorias no sistema do evento comum.
  57. #==============================================================================
  58.  
  59. $imported = {} if $imported.nil?
  60. $imported[:mog_atb_system] = true
  61.  
  62. #==============================================================================
  63. # 组合技
  64. #==============================================================================
  65. module MOG_COOPERATION_SKILLS
  66.   COOPERATION_SKILLS = []  # ☢注意!!☢ 勿动.^_^
  67.   #--------------------------------------------------------------------------
  68.   # 设定组合技
  69.   #
  70.   # COOPERATION_SKILLS[技能ID] = [角色ID, 角色ID, 角色ID……]
  71.   #--------------------------------------------------------------------------
  72.  
  73.   # COOPERATION_SKILLS[51] = [2,4]     # 火
  74.   # COOPERATION_SKILLS[66] = [2,4,3]   # 地震
  75. #  COOPERATION_SKILLS[104] = [1,5]      # Ouka Mugen jin
  76. #  COOPERATION_SKILLS[143] = [3,4]      # 闪烁
  77. #  COOPERATION_SKILLS[151] = [1,2,3,4]  # 终结  
  78. #  COOPERATION_SKILLS[153] = [2,4]      # W 终结 结束
  79.  
  80.  
  81.   #--------------------------------------------------------------------------
  82.   # 释放组合技时显示的动画.
  83.   #--------------------------------------------------------------------------
  84.   COOPERATION_SKILL_ANIMATION = 49  
  85. end
  86.  
  87. #==============================================================================
  88. # 通用设定
  89. #==============================================================================
  90. module MOG_ATB_SYSTEM
  91.   #--------------------------------------------------------------------------
  92.   # 设定 ATB 类型
  93.   #
  94.   # 0 - 玩家操控时等待
  95.   # 1 - 半即时
  96.   # 2 - 全即时
  97.   #
  98.   # 改变ATB类型的脚本:
  99.   #
  100.   # atb_type(类型)
  101.   #
  102.   #--------------------------------------------------------------------------
  103.   ATB_TYPE = 0
  104.   #--------------------------------------------------------------------------
  105.   # 轮到某一角色时播放的音效
  106.   #--------------------------------------------------------------------------
  107.   SE_ACTIVE = "Decision2"
  108.   #--------------------------------------------------------------------------
  109.   # 设定最大 ATB 值
  110.   # 改变最大 ATB 值的脚本:
  111.   #
  112.   # atb_max(X)
  113.   #
  114.   #--------------------------------------------------------------------------
  115.   ATB_MAX = 10000
  116.   #--------------------------------------------------------------------------
  117.   # 定义"回合"的方式,多少时间过去算是一个回合?
  118.   #
  119.   # 0 - 一个回合的时间是个固定值.
  120.   # 1 - 一个回合的时间为全部参战者数量的乘积
  121.   # 2 - 一个回合的时间为全部参战者敏捷值的平均值
  122.   #
  123.   #--------------------------------------------------------------------------
  124.   TURN_DURATION_TYPE = 0
  125.   #--------------------------------------------------------------------------
  126.   # 当上一项设定为"0"时的数值
  127.   #-------------------------------------------------------------------------
  128.   TURN_DURATION = 150
  129.   #--------------------------------------------------------------------------
  130.   # 技能蓄力默认施放动画
  131.   #--------------------------------------------------------------------------
  132.   CAST_ANIMATION = 0
  133.   #--------------------------------------------------------------------------
  134.   # 是否在战斗开始时显示敌人出现的窗口
  135.   #--------------------------------------------------------------------------
  136.   MESSAGE_ENEMY_APPEAR = false
  137.   #--------------------------------------------------------------------------
  138.   # 是否启用切换角色按钮
  139.   #--------------------------------------------------------------------------
  140.   ENABLE_BUTTON_NEXT_ACTOR = false
  141.   #--------------------------------------------------------------------------
  142.   # 设定切换角色的按钮(当多个角色都可以行动时可以在其间相互切换)
  143.   #--------------------------------------------------------------------------
  144.   BUTTON_NEXT_ACTOR_RIGHT = :R
  145.   BUTTON_NEXT_ACTOR_LEFT = :L
  146.   #--------------------------------------------------------------------------
  147.   # 是否显示回合数.
  148.   # 开启或关闭回合数的脚本:
  149.   #
  150.   # atb_sprite_turn(false)
  151.   #
  152.   #--------------------------------------------------------------------------
  153.   DISPLAY_TURN_NUMBER = true
  154.   #--------------------------------------------------------------------------
  155.   # 回合数的文本.
  156.   #--------------------------------------------------------------------------
  157.   TURN_WORD = "回合数 "
  158.   #--------------------------------------------------------------------------
  159.   # 回合数文字大小
  160.   #--------------------------------------------------------------------------
  161.   TURN_NUMBER_FONT_SIZE = 24
  162.   #--------------------------------------------------------------------------
  163.   # 回合数文字是否加粗.
  164.   #--------------------------------------------------------------------------
  165.   TURN_NUMBER_FONT_BOLD = true
  166.   #--------------------------------------------------------------------------
  167.   # 回合数文字 Z 坐标.
  168.   #--------------------------------------------------------------------------
  169.   TURN_NUMBER_Z = 100
  170.   #--------------------------------------------------------------------------
  171.   # 回合数文字位置.
  172.   #--------------------------------------------------------------------------
  173.   TURN_NUMBER_POS = [5,0]   
  174. end
  175.  
  176. #==============================================================================
  177. # ■ Game Temp
  178. #==============================================================================
  179. class Game_Temp
  180.  
  181.   attr_accessor :atb_in_turn
  182.   attr_accessor :atb_wait
  183.   attr_accessor :atb_user
  184.   attr_accessor :atb_stop
  185.   attr_accessor :atb_actor_order
  186.   attr_accessor :atb_break_duration
  187.   attr_accessor :battle_end
  188.   attr_accessor :battle_end2
  189.   attr_accessor :turn_duration_clear
  190.   attr_accessor :refresh_battle_atb
  191.   attr_accessor :end_phase_duration
  192.   attr_accessor :atb_frame_skip
  193.   attr_accessor :refresh_actor_command  
  194.   attr_accessor :refresh_target_windows
  195.   attr_accessor :refresh_item_window
  196.   attr_accessor :actor_command_index
  197.   attr_accessor :actor_process_event
  198.   attr_accessor :break_command
  199.   attr_accessor :hwindow_atb
  200.  
  201.   #--------------------------------------------------------------------------
  202.   # ● Initialize
  203.   #--------------------------------------------------------------------------         
  204.   alias mog_atb_temp_initialize initialize
  205.   def initialize
  206.       @atb_in_turn = false
  207.       @atb_wait = false
  208.       @atb_break_duration = 0
  209.       @atb_stop = [false,false]
  210.       @atb_actor_order = []
  211.       @turn_duration_clear = false
  212.       @battle_end = true
  213.       @battle_end2 = true
  214.       @refresh_battle_atb = false
  215.       @end_phase_duration = [false,0]
  216.       @atb_frame_skip = 0
  217.       @refresh_actor_command = false
  218.       @refresh_target_windows = [false,false]
  219.       @actor_command_index = 0
  220.       @refresh_item_window = false
  221.       @break_command = false
  222.       @actor_process_event = nil
  223.       @hwindow_atb = false
  224.       mog_atb_temp_initialize
  225.   end
  226.  
  227.   #--------------------------------------------------------------------------
  228.   # ● Sprite Visible
  229.   #--------------------------------------------------------------------------   
  230.   def sprite_visible
  231.       return false if $game_message.visible
  232.       return false if $game_temp.battle_end
  233.       return true
  234.   end   
  235.  
  236.   #--------------------------------------------------------------------------
  237.   # ● add Order
  238.   #--------------------------------------------------------------------------   
  239.   def add_order(battler)
  240.       return if battler == nil
  241.       return if battler.is_a?(Game_Enemy)
  242.       $game_temp.atb_actor_order.push(battler)
  243.   end  
  244.  
  245.   #--------------------------------------------------------------------------
  246.   # ● Remove Order
  247.   #--------------------------------------------------------------------------   
  248.   def remove_order(battler)
  249.       return if battler == nil
  250.       return if battler.is_a?(Game_Enemy)
  251.       $game_temp.atb_actor_order.delete(battler) rescue nil
  252.   end  
  253.  
  254. end
  255.  
  256. #==============================================================================
  257. # ■ Game_System
  258. #==============================================================================
  259. class Game_System
  260.  
  261.   attr_accessor :atb_max
  262.   attr_accessor :atb_type
  263.   attr_accessor :atb_turn_duration
  264.   attr_accessor :atb_sprite_turn
  265.  
  266.   #--------------------------------------------------------------------------
  267.   # ● Initialize
  268.   #--------------------------------------------------------------------------         
  269.   alias mog_at_system_initialize initialize
  270.   def initialize
  271.       @atb_max = [[MOG_ATB_SYSTEM::ATB_MAX, 999999].min, 1500].max
  272.       @atb_type = MOG_ATB_SYSTEM::ATB_TYPE ; @atb_sprite_turn = true
  273.       @atb_turn_duration = [0,
  274.       [[MOG_ATB_SYSTEM::TURN_DURATION, 999999].min, 50].max]
  275.       mog_at_system_initialize
  276.   end
  277.  
  278. end
  279.  
  280. #==============================================================================
  281. # ■ Game Interpreter
  282. #==============================================================================
  283. class Game_Interpreter
  284.  
  285.   #--------------------------------------------------------------------------
  286.   # ● ATB Type
  287.   #--------------------------------------------------------------------------         
  288.   def atb_type(type)
  289.       $game_system.atb_type = type
  290.   end
  291.  
  292.   #--------------------------------------------------------------------------
  293.   # ● ATB Max
  294.   #--------------------------------------------------------------------------         
  295.   def atb_max(value)
  296.       $game_system.atb_max = [[value, 9999999].min, 1500].max
  297.   end
  298.  
  299.   #--------------------------------------------------------------------------
  300.   # ● ATB Sprite Turn
  301.   #--------------------------------------------------------------------------         
  302.   def atb_sprite_turn(value = true)
  303.       $game_system.atb_sprite_turn = value
  304.   end  
  305.  
  306.   #--------------------------------------------------------------------------
  307.   # ● ATB Turn Speed
  308.   #--------------------------------------------------------------------------         
  309.   def atb_turn_speed(value = 400)
  310.       $game_system.atb_turn_duration[1] = [[value, 999999].min, 50].max
  311.   end
  312.  
  313.   #--------------------------------------------------------------------------
  314.   # ● ATB force Turn
  315.   #--------------------------------------------------------------------------         
  316.   def atb_force_turn(value)
  317.       $game_troop.turn_count = value
  318.   end
  319.  
  320.   #--------------------------------------------------------------------------
  321.   # ● ATB Turn Reset
  322.   #--------------------------------------------------------------------------         
  323.   def atb_turn_reset
  324.       $game_system.atb_turn_duration[0] = 0
  325.   end
  326.  
  327.   #--------------------------------------------------------------------------
  328.   # ● Command 339
  329.   #--------------------------------------------------------------------------         
  330.   def command_339
  331.       iterate_battler(@params[0], @params[1]) do |battler|
  332.       next if battler.death_state?
  333.       battler.turn_clear
  334.       if BattleManager.actor!= nil and battler == BattleManager.actor
  335.          BattleManager.actor.turn_clear
  336.          $game_temp.break_command = true
  337.          BattleManager.command_selection_clear
  338.       end
  339.       battler.force_action(@params[2], @params[3])
  340.       BattleManager.force_action(battler)
  341.       Fiber.yield while BattleManager.action_forced?
  342.       end  
  343.   end
  344.  
  345. end
  346.  
  347. #==============================================================================
  348. # ■ Game Troop
  349. #==============================================================================
  350. class Game_Troop < Game_Unit
  351.  
  352.   #--------------------------------------------------------------------------
  353.   # ● Can Interpreter Running?
  354.   #--------------------------------------------------------------------------         
  355.   def can_interpreter_running?(tend = false)      
  356.       BattleManager.turn_end if tend
  357.       return true if $game_temp.common_event_reserved?
  358.       return false if @interpreter.running?      
  359.       return false if @interpreter.setup_reserved_common_event
  360.       troop.pages.each do |page|
  361.          next unless conditions_met?(page)
  362.          @current_page = page
  363.          return true
  364.       end   
  365.       return false
  366.    end   
  367.  
  368.   #--------------------------------------------------------------------------
  369.   # ● Can Interpreter Hide Window?
  370.   #--------------------------------------------------------------------------   
  371.   def can_interpreter_hide_window?      
  372.       return false if @current_page == nil
  373.       @current_page.list.each do |l|
  374.       if l.code.between?(101,105) ; @current_page = nil ; return true ; end
  375.       end
  376.       @current_page = nil
  377.       return false
  378.    end   
  379.  
  380.   #--------------------------------------------------------------------------
  381.   # ● Can Interpreter Hide Window 2?
  382.   #--------------------------------------------------------------------------   
  383.   def can_interpreter_hide_window_2?
  384.       return false if $game_temp.common_event_id == 0
  385.       common_event = $data_common_events[$game_temp.common_event_id] rescue nil
  386.       return false if common_event.nil?
  387.       common_event.list.each do |l|
  388.       return true if l.code.between?(101,105)
  389.       end
  390.       return false
  391.   end
  392.  
  393.   #--------------------------------------------------------------------------
  394.   # ● Set Turn
  395.   #--------------------------------------------------------------------------         
  396.   def set_turn(turn_value)
  397.       @turn_count = turn_value
  398.   end
  399.  
  400. end
  401.  
  402. #==============================================================================
  403. # ■ Window Base
  404. #==============================================================================
  405. class Window_Base < Window
  406.  
  407.   #--------------------------------------------------------------------------
  408.   # ● Initialize
  409.   #--------------------------------------------------------------------------         
  410.   alias mog_atb_wbase_initialize initialize
  411.   def initialize(x, y, width, height)
  412.       mog_atb_wbase_initialize(x, y, width, height)
  413.       @pre_data = [0,self.visible,self.active,self.opacity]
  414.   end
  415.  
  416.   #--------------------------------------------------------------------------
  417.   # ● Hide All
  418.   #--------------------------------------------------------------------------         
  419.   def hide_all
  420.       @index = 0 if @index ; self.visible = false ; self.active = false
  421.       update
  422.   end
  423.  
  424.   #--------------------------------------------------------------------------
  425.   # ● Record Data
  426.   #--------------------------------------------------------------------------         
  427.   def record_data
  428.       @pre_data = [@index ,self.visible ,self.active ,self.opacity]
  429.       update
  430.   end
  431.  
  432.   #--------------------------------------------------------------------------
  433.   # ● Restore Data
  434.   #--------------------------------------------------------------------------         
  435.   def restore_data
  436.       @index = @pre_data[0] if @index ; self.visible = @pre_data[1]
  437.       self.active = @pre_data[2] ; self.opacity = @pre_data[3]
  438.       update
  439.   end
  440.  
  441. end
  442.  
  443. #==============================================================================
  444. # ■ Window Selectable
  445. #==============================================================================
  446. class Window_Selectable < Window_Base
  447.  
  448.   attr_accessor :pre_data
  449.  
  450.   #--------------------------------------------------------------------------
  451.   # ● Row Max
  452.   #--------------------------------------------------------------------------
  453.   def row_max
  454.       cm = col_max > 0 ? col_max : 1
  455.       [(item_max + cm - 1) / cm, 1].max
  456.   end  
  457.  
  458.   #--------------------------------------------------------------------------
  459.   # ● Row
  460.   #--------------------------------------------------------------------------
  461.   def row
  462.       cm = col_max > 0 ? col_max : 1
  463.       index / cm
  464.   end  
  465.  
  466.   #--------------------------------------------------------------------------
  467.   # ● Item Width
  468.   #--------------------------------------------------------------------------
  469.   def item_width
  470.       cm = col_max > 0 ? col_max : 1
  471.       (width - standard_padding * 2 + spacing) / cm - spacing
  472.   end  
  473.  
  474.   #--------------------------------------------------------------------------
  475.   # ● Item Rect
  476.   #--------------------------------------------------------------------------
  477.   def item_rect(index)
  478.       cm = col_max > 0 ? col_max : 1
  479.       rect = Rect.new
  480.       rect.width = item_width
  481.       rect.height = item_height
  482.       rect.x = index % cm * (item_width + spacing)
  483.       rect.y = index / cm * item_height
  484.       rect
  485.   end  
  486.  
  487.   #--------------------------------------------------------------------------
  488.   # ● Initialize
  489.   #-------------------------------------------------------------------------
  490.   alias mog_atb_sel_initialize initialize
  491.   def initialize(x, y, width, height)
  492.       mog_atb_sel_initialize(x, y, width, height)
  493.       @pre_data = [@index,self.visible,self.active,self.opacity]
  494.   end  
  495.  
  496.   #--------------------------------------------------------------------------
  497.   # ● Process Cursor Move
  498.   #--------------------------------------------------------------------------
  499.   alias mog_atb_wactor_process_cursor_move process_cursor_move
  500.   def process_cursor_move
  501.       return if  SceneManager.scene_is?(Scene_Battle) and skip_command?
  502.       mog_atb_wactor_process_cursor_move
  503.   end
  504.  
  505.   #--------------------------------------------------------------------------
  506.   # ● Process Handling
  507.   #--------------------------------------------------------------------------
  508.   alias mog_atb_wactor_process_handling process_handling
  509.   def process_handling  
  510.       return if SceneManager.scene_is?(Scene_Battle) and skip_command?
  511.       mog_atb_wactor_process_handling
  512.   end   
  513.  
  514.   #--------------------------------------------------------------------------
  515.   # ● Process Handling
  516.   #--------------------------------------------------------------------------
  517.   def skip_command?
  518.       return false if self.is_a?(Window_VictorySpoils) if $imported["YEA-VictoryAftermath"]
  519.       return true if !$game_temp.sprite_visible
  520.       return true if $game_temp.battle_end
  521.       return true if $game_temp.end_phase_duration[1] > 0
  522.       return true if BattleManager.actor == nil
  523.       return false  
  524.   end  
  525.  
  526. end
  527.  
  528. #==============================================================================
  529. # ■ Window_ActorCommand
  530. #==============================================================================
  531. class Window_ActorCommand < Window_Command
  532.  
  533.   attr_accessor :actor
  534.  
  535.   #--------------------------------------------------------------------------
  536.   # ● Update
  537.   #--------------------------------------------------------------------------
  538.   alias mog_atb_ac_update update
  539.   def update
  540.       mog_atb_ac_update
  541.       $game_temp.actor_command_index = self.index if self.active
  542.   end
  543.  
  544.   if MOG_ATB_SYSTEM::ENABLE_BUTTON_NEXT_ACTOR
  545.   #--------------------------------------------------------------------------
  546.   # ● Process_Cursor Move
  547.   #--------------------------------------------------------------------------
  548.   def process_cursor_move
  549.       return unless cursor_movable?
  550.       last_index = @index
  551.       cursor_down (Input.trigger?(:DOWN))  if Input.repeat?(:DOWN)
  552.       cursor_up   (Input.trigger?(:UP))    if Input.repeat?(:UP)
  553.       cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
  554.       cursor_left (Input.trigger?(:LEFT))  if Input.repeat?(:LEFT)
  555.       Sound.play_cursor if @index != last_index
  556.   end
  557.   end
  558.  
  559.   if $imported["YEA-BattleEngine"]
  560.   #--------------------------------------------------------------------------
  561.   # ● Process_dir4
  562.   #--------------------------------------------------------------------------
  563.   def process_dir4
  564.   end
  565.  
  566.   #--------------------------------------------------------------------------
  567.   # ● Process_dir6
  568.   #--------------------------------------------------------------------------
  569.   def process_dir6
  570.   end  
  571.   end  
  572.  
  573.   #--------------------------------------------------------------------------
  574.   # ● Process Cursor Move
  575.   #--------------------------------------------------------------------------  
  576.   alias mog_atb_bm_process_cursor_move process_cursor_move
  577.   def process_cursor_move
  578.       return if SceneManager.scene_is?(Scene_Battle) and BattleManager.actor == nil
  579.       mog_atb_bm_process_cursor_move
  580.   end
  581.  
  582.   #--------------------------------------------------------------------------
  583.   # ● Process Handling
  584.   #--------------------------------------------------------------------------   
  585.   alias mog_atb_bm_process_handling process_handling
  586.   def process_handling
  587.       return if SceneManager.scene_is?(Scene_Battle) and BattleManager.actor == nil
  588.       mog_atb_bm_process_handling
  589.   end  
  590.  
  591. end
  592.  
  593. #==============================================================================
  594. # ■ Window_BattleEnemy
  595. #==============================================================================
  596. class Window_BattleEnemy < Window_Selectable
  597.  
  598.   #--------------------------------------------------------------------------
  599.   # ● Refresh
  600.   #--------------------------------------------------------------------------  
  601.   alias mog_atb_battle_enemy_update update
  602.   def update
  603.       return if enemy == nil      
  604.       mog_atb_battle_enemy_update
  605.   end
  606.  
  607. end
  608.  
  609. #==============================================================================
  610. # ■ Window BattleLog
  611. #==============================================================================
  612. class Window_BattleLog < Window_Selectable
  613.  
  614.   #--------------------------------------------------------------------------
  615.   # ● Display Added States
  616.   #--------------------------------------------------------------------------   
  617.   def display_added_states(target)
  618.       return if target.turn_collapse
  619.       target.result.added_state_objects.each do |state|
  620.          state_msg = target.actor? ? state.message1 : state.message2
  621.          if state.id == target.death_state_id
  622.             target.perform_collapse_effect if target.hp == 0
  623.          end
  624.          next if state_msg.empty?
  625.          replace_text(target.name + state_msg)
  626.          target.turn_collapse = true if state.id == target.death_state_id
  627.          wait
  628.          wait_for_effect
  629.       end
  630.   end  
  631.  
  632.   #--------------------------------------------------------------------------
  633.   # ● Refresh
  634.   #--------------------------------------------------------------------------   
  635.   def refresh
  636.   end  
  637.  
  638.   #--------------------------------------------------------------------------
  639.   # ● Message Speed
  640.   #--------------------------------------------------------------------------   
  641.   def message_speed
  642.       return 10 if $imported["YEA-BattleEngine"]
  643.       return 5
  644.   end
  645.  
  646.   #--------------------------------------------------------------------------
  647.   # * Wait for Effect
  648.   #--------------------------------------------------------------------------
  649.   def wait_for_effect
  650.       return false
  651.   end  
  652.  
  653. end
  654.  
  655. #==============================================================================
  656. # ■ Sprite Battler
  657. #==============================================================================
  658. class Sprite_Battler < Sprite_Base
  659.  
  660.   #--------------------------------------------------------------------------
  661.   # ● Update
  662.   #--------------------------------------------------------------------------      
  663.   alias mog_atb_sprite_update update
  664.   def update      
  665.       mog_atb_sprite_update
  666.       clear_atb_battler_dead if clear_atb_battler_dead?
  667.   end
  668.  
  669.   #--------------------------------------------------------------------------
  670.   # ● Init Visibility
  671.   #--------------------------------------------------------------------------      
  672.   alias mog_atb_init_visibility init_visibility
  673.   def init_visibility
  674.       self.visible = true
  675.       self.opacity = 255 if @battler.alive?
  676.       mog_atb_init_visibility
  677.   end
  678.  
  679.   #--------------------------------------------------------------------------
  680.   # ● Clear ATB Battler
  681.   #--------------------------------------------------------------------------      
  682.   def clear_atb_battler_dead?
  683.       return false if !self.visible
  684.       return false if @battler.nil?
  685.       return false if !@battler.dead?
  686.       return false if @battler.is_a?(Game_Actor)
  687.       return false if !@effect_type.nil?
  688.       return false if $imported[:mog_battler_motion] and !@collapse_done
  689.       return true
  690.   end
  691.  
  692.   #--------------------------------------------------------------------------
  693.   # ● Clear ATB Battler Dead
  694.   #--------------------------------------------------------------------------      
  695.   def clear_atb_battler_dead
  696.       self.opacity = 0
  697.       self.visible = false
  698.       @battler.atb_initial
  699.   end
  700.  
  701. end
  702.  
  703. #==============================================================================
  704. # ■ Game Battler Base
  705. #==============================================================================
  706. class Game_BattlerBase  
  707.  
  708.   attr_accessor :hidden
  709.  
  710.   #--------------------------------------------------------------------------
  711.   # ● Inputable?
  712.   #--------------------------------------------------------------------------            
  713.   def inputable?
  714.       normal? && !auto_battle? && self.atb_max?
  715.   end
  716.  
  717. end
  718.  
  719. #==============================================================================
  720. # ■ Game_Battler
  721. #==============================================================================
  722. class Game_Battler < Game_BattlerBase
  723.  
  724.    attr_accessor :atb
  725.    attr_accessor :atb_max
  726.    attr_accessor :atb_cast
  727.    attr_accessor :atb_action
  728.    attr_accessor :atb_turn_duration
  729.    attr_accessor :atb_escape
  730.    attr_accessor :next_turn
  731.    attr_accessor :turn_collapse
  732.    attr_accessor :actions
  733.  
  734.   #--------------------------------------------------------------------------
  735.   # ● Initialize
  736.   #--------------------------------------------------------------------------      
  737.    alias mog_at_system_initialize initialize
  738.    def initialize
  739.        mog_at_system_initialize
  740.        atb_init_setup
  741.    end
  742.  
  743.   #--------------------------------------------------------------------------
  744.   # ● Atb Init Setup
  745.   #--------------------------------------------------------------------------      
  746.    def atb_init_setup
  747.        @atb = 0
  748.        @atb_max = $game_system.atb_max
  749.        @atb_cast = []
  750.        @atb_turn_duration = 0
  751.        @next_turn = false
  752.        @atb_escape = false
  753.        @turn_collapse = false
  754.        @wait_motion = $imported[:mog_battler_motion] != nil ? true : false
  755.    end     
  756.  
  757.   #--------------------------------------------------------------------------
  758.   # ● Atb
  759.   #--------------------------------------------------------------------------         
  760.    def atb
  761.        return 0 if self.hp == 0
  762.        return [[@atb, atb_max].min, 0].max
  763.    end  
  764.  
  765.   #--------------------------------------------------------------------------
  766.   # ● Max ATB
  767.   #--------------------------------------------------------------------------         
  768.    def atb_max
  769.        return [$game_system.atb_max,100].max
  770.    end   
  771.  
  772.   #--------------------------------------------------------------------------
  773.   # ● Max AT?
  774.   #--------------------------------------------------------------------------         
  775.    def atb_max?
  776.        self.atb >= atb_max
  777.    end
  778.  
  779.   #--------------------------------------------------------------------------
  780.   # ● Atb Speed
  781.   #--------------------------------------------------------------------------         
  782.    def atb_speed
  783.        return self.agi
  784.    end
  785.  
  786.   #--------------------------------------------------------------------------
  787.   # ● ATB Update
  788.   #--------------------------------------------------------------------------   
  789.   def atb_update?
  790. #     return false if restriction >= 4
  791.       return false if self.hp == 0
  792.       return false if self.hidden
  793.       return false if @wait_motion && $game_temp.battler_in_motion
  794.       return true
  795.   end
  796.  
  797.   #--------------------------------------------------------------------------
  798.   # ● ATB Update
  799.   #--------------------------------------------------------------------------   
  800.   def atb_update
  801.       return if !atb_update?
  802.       if self.atb_cast.empty?
  803.          if !atb_max?
  804.             #self.atb += self.atb_speed持有87号状态时瞬间行动。
  805.             self.atb += self.state?(87) ? atb_max : self.atb_speed
  806.             execute_atb_max_effect if atb_max?
  807.          end   
  808.        else   
  809.  
  810.         yongchang=1
  811.         yongchang *= 0.5 if self.state?(38) #结舌,蓄力速度*0.5
  812.         yongchang *= 1.5 if self.state?(39) #急速,蓄力速度*1.5
  813.         yongchang *= 1.5 if self.state?(199) #拉文凝神施咒
  814.         yongchang *= 1.1 if self.skill?(1064) #潜能兔子1
  815.         yongchang *= 1.2 if self.skill?(1065) #潜能兔子2
  816.         yongchang *= 1.3 if self.skill?(1066) #潜能兔子3
  817.         yongchang *= 2.6 if self.skill?(2008) #风岚蓄力加速
  818.  
  819. #self.atb_cast[1] -= yongchang      
  820.         self.atb_cast[1] -= yongchang #正常情况下,本值为1.也就是每次咏唱1进度。
  821.          #atb_cast[1]其实就是那个技能速度,然后mog的咏唱条长度,就是技能速度,
  822.          #原理是每帧-1,减到0就释放技能
  823.          execute_cast_action if self.atb_cast[1] <= 0
  824.       end
  825.   end
  826.  
  827.   #--------------------------------------------------------------------------
  828.   # ● Execute Atb Max Effect
  829.   #--------------------------------------------------------------------------   
  830.   def execute_atb_max_effect
  831.       $game_temp.refresh_item_window = true if need_refresh_item_window?
  832.       $game_temp.add_order(self)
  833.   end
  834.  
  835.   #--------------------------------------------------------------------------
  836.   # ● Need Refresh Item Window?
  837.   #--------------------------------------------------------------------------   
  838.   def need_refresh_item_window?
  839.       return false
  840.   end
  841.  
  842.   #--------------------------------------------------------------------------
  843.   # ● Execute Cast Action
  844.   #--------------------------------------------------------------------------   
  845.   def execute_cast_action
  846.       self.next_turn = true ; self.atb = self.atb_max ; self.atb_cast.clear
  847.   end
  848.  
  849.   #--------------------------------------------------------------------------
  850.   # ● Atb Clear
  851.   #--------------------------------------------------------------------------   
  852.   def atb_clear
  853.       self.atb = 0 ; self.atb_cast.clear ; self.turn_collapse = false
  854.   end
  855.  
  856.   #--------------------------------------------------------------------------
  857.   # ● Atb Initial
  858.   #--------------------------------------------------------------------------   
  859.   def atb_initial
  860.       @atb = 0 ; @atb_cast = [] ; @atb_turn_duration = 0
  861.       @atb_escape = false ; @next_turn = false ; clear_actions
  862.   end     
  863.  
  864.   #--------------------------------------------------------------------------
  865.   # ● Movable ATB
  866.   #--------------------------------------------------------------------------   
  867.   def movable_atb?
  868.       return false if !atb_max?
  869.       return false if self.dead?
  870.       return false if self.restriction != 0
  871.       return false if self.next_turn
  872.       return false if !self.atb_cast.empty?
  873.       return true
  874.   end
  875.  
  876.   #--------------------------------------------------------------------------
  877.   # ● Item Apply
  878.   #--------------------------------------------------------------------------  
  879.   alias mog_atb_item_apply item_apply
  880.   def item_apply(user, item)      
  881.       pre_item = self.current_action.item rescue nil
  882.       mog_atb_item_apply(user, item)      
  883.       if SceneManager.scene_is?(Scene_Battle)
  884.          effect_for_dead if self.dead?
  885.          atb_after_damage(pre_item)
  886.       end   
  887.   end  
  888.  
  889.   #--------------------------------------------------------------------------
  890.   # ● ATB After Damage
  891.   #--------------------------------------------------------------------------  
  892.   def atb_after_damage(pre_item = nil)
  893.       $game_temp.break_command = true if can_damage_break_command?
  894.       turn_clear if self.restriction == 4 or self.dead?
  895.       $game_temp.remove_order(self) if self.restriction > 0 or self.dead?
  896.       $game_temp.battle_end2 = true if $game_troop.all_dead? or $game_party.all_dead?
  897.   end
  898.  
  899.   #--------------------------------------------------------------------------
  900.   # ● Can Damage Break Command
  901.   #--------------------------------------------------------------------------  
  902.   def can_damage_break_command?
  903.       return false if BattleManager.actor == nil
  904.       return false if BattleManager.actor != self
  905.       return true if BattleManager.actor.restriction > 0
  906.       return true if BattleManager.actor.dead?
  907.       return true if BattleManager.actor.hp == 0
  908.       return false
  909.   end
  910.  
  911.   #--------------------------------------------------------------------------
  912.   # ● Turn Clear
  913.   #--------------------------------------------------------------------------  
  914.   def turn_clear
  915.       self.atb_clear
  916.       self.atb_escape = false
  917.       self.clear_actions
  918.       self.next_turn = false
  919.       $game_temp.remove_order(self)
  920.   end  
  921.  
  922.   #--------------------------------------------------------------------------
  923.   # ● Effect for Dead
  924.   #--------------------------------------------------------------------------  
  925.   def effect_for_dead      
  926.       atb_initial
  927.       $game_temp.refresh_target_windows[0] = true if self.is_a?(Game_Actor)
  928.       $game_temp.refresh_target_windows[1] = true if self.is_a?(Game_Enemy)
  929.       if $imported[:mog_battle_cursor]
  930.          $game_temp.battle_cursor_need_refresh[0] = true if self.is_a?(Game_Actor)
  931.          $game_temp.battle_cursor_need_refresh[1] = true if self.is_a?(Game_Enemy)
  932.       end         
  933.   end
  934.  
  935.   #--------------------------------------------------------------------------
  936.   # ● Remove State Auto
  937.   #--------------------------------------------------------------------------  
  938.   alias mog_atb_remove_states_auto remove_states_auto
  939.   def remove_states_auto(timing)
  940.       if SceneManager.scene_is?(Scene_Battle)
  941.          remove_states_auto_atb(timing) ; return
  942.       end
  943.       mog_atb_remove_states_auto(timing)
  944.   end  
  945.  
  946.   #--------------------------------------------------------------------------
  947.   # ● Remove State Auto ATB
  948.   #--------------------------------------------------------------------------  
  949.   def remove_states_auto_atb(timing)
  950.       states.each do |state|
  951.       if @state_turns[state.id] == 0
  952.          if restriction == 4 ; remove_state(state.id) ; return ; end
  953.             unless state.auto_removal_timing == 2 and state.max_turns <= 1
  954.             remove_state(state.id)
  955.             end
  956.          end
  957.       end
  958.   end  
  959.  
  960.   #--------------------------------------------------------------------------
  961.   # ● Remove State Turn End
  962.   #--------------------------------------------------------------------------  
  963.   def remove_state_turn_end
  964.       states.each do |state|
  965.          next if state.auto_removal_timing != 2
  966.          next if state.max_turns > 1
  967.          remove_state(state.id)
  968.       end
  969.   end  
  970.  
  971.   #--------------------------------------------------------------------------
  972.   # ● Die
  973.   #--------------------------------------------------------------------------  
  974.   alias mog_atb_die die
  975.   def die
  976.       mog_atb_die
  977.       self.turn_clear ; self.atb_turn_duration = 0
  978.   end
  979.  
  980.   #--------------------------------------------------------------------------
  981.   # ● Revive
  982.   #--------------------------------------------------------------------------  
  983.   alias mog_atb_revive revive
  984.   def revive
  985.       mog_atb_revive
  986.       self.turn_clear ; per = 25 * self.atb_max / 100 ; self.atb = rand(per)
  987.       self.atb_turn_duration = 0
  988.   end  
  989.  
  990.   #--------------------------------------------------------------------------
  991.   # ● Create Battle Action
  992.   #--------------------------------------------------------------------------
  993.   alias mog_atb_make_actions make_actions
  994.   def make_actions
  995.       return if !self.atb_cast.empty?
  996.       item = self.current_action.item rescue nil
  997.       return if item != nil
  998.       mog_atb_make_actions
  999.   end  
  1000.  
  1001. end
  1002.  
  1003. #==============================================================================
  1004. # ■ Game Enemy
  1005. #==============================================================================
  1006. class Game_Enemy < Game_Battler
  1007.  
  1008.   #--------------------------------------------------------------------------
  1009.   # ● Tranform
  1010.   #--------------------------------------------------------------------------  
  1011.    alias mog_at_system_transform transform
  1012.    def transform(enemy_id)
  1013.        mog_at_system_transform(enemy_id)
  1014.        self.atb_clear
  1015.    end
  1016.  
  1017. end
  1018.  
  1019. #==============================================================================
  1020. # ■ BattleManager
  1021. #==============================================================================
  1022. module BattleManager
  1023.  
  1024.   #--------------------------------------------------------------------------
  1025.   # ● Start Command Input
  1026.   #--------------------------------------------------------------------------
  1027.   def self.input_start
  1028.       @phase = :input if @phase != :input
  1029.       return !@surprise && $game_party.inputable?
  1030.   end
  1031.  
  1032.   #--------------------------------------------------------------------------
  1033.   # ● Battle Start
  1034.   #--------------------------------------------------------------------------  
  1035.   def self.battle_start
  1036.       $game_system.battle_count += 1
  1037.       $game_party.on_battle_start
  1038.       $game_troop.on_battle_start
  1039.       atb_initial_setup ; @turn_duration = set_turn_duration
  1040.       if MOG_ATB_SYSTEM::MESSAGE_ENEMY_APPEAR
  1041.          $game_troop.enemy_names.each do |name|
  1042.          $game_message.add(sprintf(Vocab::Emerge, name))
  1043.          end
  1044.       end
  1045.       if @preemptive
  1046.          $game_message.add(sprintf(Vocab::Preemptive, $game_party.name))
  1047.       elsif @surprise
  1048.          $game_message.add(sprintf(Vocab::Surprise, $game_party.name))
  1049.       end
  1050.       wait_for_message ; @preemptive = false ; @surprise = false
  1051.   end
  1052.  
  1053.   #--------------------------------------------------------------------------
  1054.   # ● ATB Initial Setup
  1055.   #--------------------------------------------------------------------------  
  1056.   def self.atb_initial_setup
  1057.       battlers.each do |battler|
  1058.       battler.atb_initial ; initial_atb_parameter(battler)
  1059.       end
  1060.   end
  1061.  
  1062.   #--------------------------------------------------------------------------
  1063.   # ● Initial ATB Parameter
  1064.   #--------------------------------------------------------------------------  
  1065.   def self.initial_atb_parameter(battler)
  1066.       @at_phase = 0
  1067.       nt = battler.atb_max * 30 / 100
  1068.       st = battler.atb_max * 20 / 100      
  1069.       pt = battler.atb_max * 65 / 100
  1070.       n_at = rand(nt) ; p_at = pt + rand(nt) ; s_at = rand(st)        
  1071.       if BattleManager.preemptive_attack
  1072.          battler.atb = p_at if battler.is_a?(Game_Actor)
  1073.          battler.atb = s_at if battler.is_a?(Game_Enemy)
  1074.       elsif BattleManager.surprise_attack   
  1075.          battler.atb = p_at if battler.is_a?(Game_Enemy)
  1076.          battler.atb = s_at if battler.is_a?(Game_Actor)
  1077.       else   
  1078.          battler.atb = n_at
  1079.       end
  1080.       battler.atb = battler.atb_max - 1  if battler.atb >= battler.atb_max
  1081.       battler.turn_clear if battler.dead? or battler.restriction == 4
  1082.   end
  1083.  
  1084.   #--------------------------------------------------------------------------
  1085.   # ● Set Turn Duration
  1086.   #--------------------------------------------------------------------------  
  1087.   def self.set_turn_duration
  1088.       max_battlers = battlers.size > 0 ? battlers.size : 1      
  1089.       case MOG_ATB_SYSTEM::TURN_DURATION_TYPE
  1090.         when 1 ; n  = $game_system.atb_turn_duration[1] * max_battlers         
  1091.         when 2
  1092.            turn_sp = 0
  1093.            battlers.each do |battler| turn_sp += battler.agi ; end  
  1094.            n = $game_system.atb_turn_duration[1] + (turn_sp / max_battlers)
  1095.         else ; n = $game_system.atb_turn_duration[1]
  1096.       end
  1097.       n2 = [[n, 9999].min, 120].max     
  1098.       battlers.each do |battler|
  1099.           perc = 30 * n2 / 100
  1100.           battler.atb_turn_duration = rand(perc)      
  1101.       end  
  1102.       return n2
  1103.   end
  1104.  
  1105.   #--------------------------------------------------------------------------
  1106.   # ● Force Clear Battler ATB
  1107.   #--------------------------------------------------------------------------  
  1108.   def self.force_clear_battler_atb
  1109.       battlers.each do |battler|
  1110.       battler.turn_clear if battler.dead? or battler.restriction == 4
  1111.       end
  1112.   end
  1113.  
  1114.   #--------------------------------------------------------------------------
  1115.   # ● Turn Start
  1116.   #--------------------------------------------------------------------------
  1117.   def self.turn_start   
  1118.       @phase = :turn ; clear_actor
  1119.   end  
  1120.  
  1121.   #--------------------------------------------------------------------------
  1122.   # ● Preemtive Attack
  1123.   #--------------------------------------------------------------------------  
  1124.   def self.preemptive_attack
  1125.       @preemptive
  1126.   end  
  1127.  
  1128.   #--------------------------------------------------------------------------
  1129.   # ● Suprise Attack
  1130.   #--------------------------------------------------------------------------   
  1131.   def self.surprise_attack
  1132.       @surprise
  1133.   end
  1134.  
  1135.   #--------------------------------------------------------------------------
  1136.   # ● Battlers
  1137.   #--------------------------------------------------------------------------   
  1138.   def self.battlers
  1139.       return $game_troop.members + $game_party.battle_members
  1140.   end  
  1141.  
  1142.   #--------------------------------------------------------------------------
  1143.   # ● Update ATB
  1144.   #--------------------------------------------------------------------------   
  1145.   def update_atb?
  1146.       return false if @atb_in_turn
  1147.       return true
  1148.   end
  1149.  
  1150.   #--------------------------------------------------------------------------
  1151.   # ● Update ATB
  1152.   #--------------------------------------------------------------------------   
  1153.   def self.update_atb
  1154.       return if $game_temp.atb_wait
  1155.       return if $game_temp.end_phase_duration[1] > 0
  1156.       return if $game_temp.battle_end      
  1157.       return if $game_temp.atb_frame_skip > 0
  1158.       return @current_battler if @current_battler
  1159.       for battler in battlers
  1160.           next if !battler_update?(battler)
  1161.           battler.atb_update
  1162.           update_battler_turn(battler)
  1163.           @current_battler = set_current_battler(battler)
  1164.           break if $game_temp.atb_frame_skip > 0
  1165.       end
  1166.       return nil
  1167.   end
  1168.  
  1169.   #--------------------------------------------------------------------------
  1170.   # ● Battler Update?
  1171.   #--------------------------------------------------------------------------   
  1172.   def self.battler_update?(battler)
  1173.       return false if battler.dead? or battler.hp == 0
  1174.       return true
  1175.   end
  1176.  
  1177.   #--------------------------------------------------------------------------
  1178.   # ● Update Battler Turn
  1179.   #--------------------------------------------------------------------------   
  1180.   def self.update_battler_turn(battler)
  1181.       return if @turn_duration == nil
  1182.       battler.atb_turn_duration += 1
  1183.       return if battler.atb_turn_duration < @turn_duration
  1184.       battler.atb_turn_duration = 0
  1185.       old_battler = battler
  1186.       battler.on_turn_end
  1187.       @refresh_status = true
  1188.   end
  1189.  
  1190.   #--------------------------------------------------------------------------
  1191.   # ● Set Current Battler
  1192.   #--------------------------------------------------------------------------   
  1193.   def self.set_current_battler(battler)
  1194.       return @current_battler if @current_battler
  1195.       return nil if !battler.atb_max?
  1196.       if battler.next_turn
  1197.          battler.remove_state_turn_end            
  1198.          $game_temp.remove_order(battler)
  1199.          return battler
  1200.       end
  1201.       if battler.is_a?(Game_Actor)
  1202.         if BattleManager.actor == nil         
  1203.             if $game_temp.actor_process_event != nil
  1204.                enable_actor_command?($game_temp.actor_process_event)
  1205.                prepare_actor_command($game_temp.actor_process_event)      
  1206.                $game_temp.actor_process_event = nil
  1207.             elsif $game_temp.atb_actor_order[0] != nil and
  1208.                 enable_actor_command?($game_temp.atb_actor_order[0])
  1209.                 prepare_actor_command($game_temp.atb_actor_order[0])
  1210.             else
  1211.                 prepare_actor_command(battler) if enable_actor_command?(battler)
  1212.                 if battler_confusion?(battler)                  
  1213.                    battler.make_actions
  1214.                    battler.next_turn = true if !can_execute_cast_action?(battler)
  1215.                 end      
  1216.              end
  1217.          else      
  1218.              if battler_confusion?(battler)                  
  1219.                 battler.make_actions
  1220.                 battler.next_turn = true if !can_execute_cast_action?(battler)
  1221.              end
  1222.          end
  1223.      else
  1224.          battler.make_actions
  1225.          battler.next_turn = true if !can_execute_cast_action?(battler)
  1226.       end   
  1227.       return nil
  1228.   end
  1229.  
  1230.   #--------------------------------------------------------------------------
  1231.   # ●  Enable Actor Command
  1232.   #--------------------------------------------------------------------------   
  1233.   def self.battler_confusion?(battler)
  1234.       return false if battler.hp == 0 or battler.dead?
  1235.       return true if battler.confusion?
  1236.       return false
  1237.   end
  1238.  
  1239.   #--------------------------------------------------------------------------
  1240.   # ●  Enable Actor Command
  1241.   #--------------------------------------------------------------------------   
  1242.   def self.enable_actor_command?(battler)
  1243.       return false if @command_actor != nil
  1244.       return false if battler.dead?
  1245.       return false if battler.restriction != 0
  1246.       return true
  1247.   end  
  1248.  
  1249.   #--------------------------------------------------------------------------
  1250.   # ● Prepare Actor Command
  1251.   #--------------------------------------------------------------------------   
  1252.   def self.prepare_actor_command(battler)
  1253.       battler.remove_state_turn_end      
  1254.       @command_actor = battler ; @command_selection = true
  1255.       $game_temp.remove_order(battler)      
  1256.   end
  1257.  
  1258.   #--------------------------------------------------------------------------
  1259.   # ● Can Execute Cast Action?
  1260.   #--------------------------------------------------------------------------   
  1261.   def self.can_execute_cast_action?(battler)
  1262.       item = battler.current_action.item rescue nil  
  1263.       return false if item == nil
  1264.       if item.speed != 0 and battler.atb_cast.empty?
  1265. #         item.speed.abs *= 0.01
  1266.          battler.atb_cast = [item,item.speed.abs,0]
  1267.          battler.animation_id = MOG_ATB_SYSTEM::CAST_ANIMATION
  1268.          battler.atb = 0
  1269.          return true
  1270.       end   
  1271.       return false
  1272.   end
  1273.  
  1274.   #--------------------------------------------------------------------------
  1275.   # ● Actor in turn
  1276.   #--------------------------------------------------------------------------   
  1277.   def self.actor_command?
  1278.       return false if !@command_selection
  1279.       return false if @command_actor == nil
  1280.       if @command_actor.restriction != 0
  1281.          @command_selection = false
  1282.          return false
  1283.       end   
  1284.       @command_selection = false      
  1285.       return true
  1286.   end
  1287.  
  1288.   #--------------------------------------------------------------------------
  1289.   # ● Current Battler Clear
  1290.   #--------------------------------------------------------------------------   
  1291.   def self.current_battler_clear(subject)
  1292.       return if subject == nil
  1293.       return if @current_battler == nil
  1294.       return if @current_battler != subject
  1295.       @current_battler.atb_clear
  1296.       @current_battler.atb_escape = false
  1297.       @current_battler.clear_actions
  1298.       @current_battler.next_turn = false
  1299.       @current_battler = nil
  1300.   end  
  1301.  
  1302.   #--------------------------------------------------------------------------
  1303.   # ● Command Selection Clear
  1304.   #--------------------------------------------------------------------------   
  1305.   def self.command_selection_clear
  1306.       $game_temp.remove_order(@command_actor)
  1307.       @command_selection = false ; @command_actor = nil
  1308.       $game_temp.actor_command_index = 0
  1309.   end
  1310.  
  1311.   #--------------------------------------------------------------------------
  1312.   # ● Command Selection
  1313.   #--------------------------------------------------------------------------   
  1314.   def self.command_selection?
  1315.       @command_selection
  1316.   end
  1317.  
  1318.   #--------------------------------------------------------------------------
  1319.   # ● Command Selection need clear?
  1320.   #--------------------------------------------------------------------------   
  1321.   def self.command_need_clear?
  1322.       return true if @command_actor == nil and @command_selection
  1323.       return false
  1324.   end
  1325.  
  1326.   #--------------------------------------------------------------------------
  1327.   # ● Next Command
  1328.   #--------------------------------------------------------------------------   
  1329.   def self.next_command
  1330.       if @command_actor ; @command_actor.make_actions ; return true ;end
  1331.       return false
  1332.   end  
  1333.  
  1334.   #--------------------------------------------------------------------------
  1335.   # ● Command End
  1336.   #--------------------------------------------------------------------------   
  1337.   def self.command_end
  1338.       $game_temp.remove_order(@command_actor)
  1339.       @command_selection = false
  1340.       $game_temp.actor_command_index = 0
  1341.       command_end_actor if @command_actor
  1342.       @command_actor = nil
  1343.   end
  1344.  
  1345.   #--------------------------------------------------------------------------
  1346.   # ● Command End Actor
  1347.   #--------------------------------------------------------------------------   
  1348.   def self.command_end_actor
  1349.       item = @command_actor.current_action.item rescue nil  
  1350.       set_cast_action(item) if set_cast_action?(item)
  1351.       @command_actor.next_turn = true if @command_actor != nil
  1352.       @current_battler = @command_actor if @current_battler == nil
  1353.       $game_temp.actor_process_event = nil
  1354.   end
  1355.  
  1356.   #--------------------------------------------------------------------------
  1357.   # ●
  1358.   #--------------------------------------------------------------------------   
  1359.   def self.set_cast_action?(item)
  1360.       if item.is_a?(RPG::Skill)
  1361.          return false if @command_actor.guard_skill_id == item.id
  1362.       end
  1363.       return false if item.nil?
  1364.       return false if item.speed == 0
  1365.       return false if !@command_actor.atb_cast.empty?
  1366.       return true
  1367.   end
  1368.  
  1369.   #--------------------------------------------------------------------------
  1370.   # ● 行动蓄力时间(急速和结舌等)item.speed是速度修正
  1371.   #--------------------------------------------------------------------------   
  1372.   def self.set_cast_action(item)
  1373. #   item.speed *= 1.5 if @command_actor.state?(38)#结舌
  1374. #   item.speed *= 0.5 if @command_actor.state?(39)#急速
  1375.     value = item.speed.abs
  1376.   #  value *= 1.5 if @command_actor.state?(38)
  1377.   #  value *= 0.5 if @command_actor.state?(39)
  1378.       if value > 10
  1379.          @command_actor.atb_cast = [item,value,0]
  1380.       else   
  1381.          @command_actor.atb_cast = [item,10,10]
  1382.       end  
  1383.       @command_actor.animation_id = MOG_ATB_SYSTEM::CAST_ANIMATION
  1384.       @command_actor.atb = 0 ; @command_actor.next_turn = false
  1385.       @command_actor = nil
  1386.   end      
  1387.  
  1388.   #--------------------------------------------------------------------------
  1389.   # ● End Turn
  1390.   #--------------------------------------------------------------------------
  1391.   def self.in_turn?
  1392.       return $game_temp.atb_in_turn
  1393.   end  
  1394.  
  1395.   #--------------------------------------------------------------------------
  1396.   # ● Set Refresh Status
  1397.   #--------------------------------------------------------------------------
  1398.   def self.set_refresh_status(value)
  1399.       @refresh_status = value
  1400.   end
  1401.  
  1402.   #--------------------------------------------------------------------------
  1403.   # ● Refresh Status
  1404.   #--------------------------------------------------------------------------
  1405.   def self.refresh_status?
  1406.       @refresh_status
  1407.   end
  1408.  
  1409.   #--------------------------------------------------------------------------
  1410.   # ● Actor
  1411.   #--------------------------------------------------------------------------
  1412.   def self.actor
  1413.       @command_actor
  1414.   end
  1415.  
  1416.   #--------------------------------------------------------------------------
  1417.   # ● Cancel Actor Command
  1418.   #--------------------------------------------------------------------------
  1419.   def self.cancel_actor_command(minus = false)
  1420.       @command_selection = false
  1421.       return if @command_actor == nil
  1422.       @command_actor.atb = (@command_actor.atb * 80 / 100).truncate if minus
  1423.       @command_actor = nil
  1424.       $game_temp.actor_command_index = 0
  1425.   end
  1426.  
  1427.   #--------------------------------------------------------------------------
  1428.   # ● Battler
  1429.   #--------------------------------------------------------------------------
  1430.   def self.set_battler_in_turn(battler)
  1431.       @battler_in_turn = battler
  1432.   end
  1433.  
  1434.   #--------------------------------------------------------------------------
  1435.   # ● Battler in turn?
  1436.   #--------------------------------------------------------------------------
  1437.   def self.battler_in_turn?(battler)
  1438.       return true if @battler_in_turn == battler
  1439.       return false
  1440.   end
  1441.  
  1442.   #--------------------------------------------------------------------------
  1443.   # ● Turn Start ABS
  1444.   #--------------------------------------------------------------------------
  1445.   def self.turn_start_abs
  1446.       @phase = :turn        
  1447.   end
  1448.  
  1449.   #--------------------------------------------------------------------------
  1450.   # ● Set Subject
  1451.   #--------------------------------------------------------------------------
  1452.   def self.set_subject(subject)
  1453.       @subject = subject
  1454.   end
  1455.  
  1456.   #--------------------------------------------------------------------------
  1457.   # ● Subject
  1458.   #--------------------------------------------------------------------------
  1459.   def self.subject
  1460.       @subject
  1461.   end  
  1462.  
  1463. end  
  1464.  
  1465. #==============================================================================
  1466. # ■ BattleManager
  1467. #==============================================================================
  1468. class << BattleManager
  1469.  
  1470.   #--------------------------------------------------------------------------
  1471.   # ● Init Members
  1472.   #--------------------------------------------------------------------------
  1473.   alias mog_atb_init_members init_members
  1474.   def init_members
  1475.       mog_atb_init_members
  1476.       set_init_atb_data
  1477.   end
  1478.  
  1479.   #--------------------------------------------------------------------------
  1480.   # ● Set Init ATB Data
  1481.   #--------------------------------------------------------------------------
  1482.   def set_init_atb_data
  1483.       @current_battler = nil ; @actor_in_turn = nil ; @command_selection = nil
  1484.       @atb_target_index = nil ; @command_actor = nil ; $game_temp.atb_user = nil
  1485.       $game_temp.turn_duration_clear = false ; $game_temp.battle_end = false
  1486.       $game_temp.atb_in_turn = true ; $game_temp.atb_wait = false
  1487.       @turn_duration = set_turn_duration ; @refresh_status = false
  1488.       $game_temp.atb_frame_skip = 30 ; @battler_in_turn = nil
  1489.       $game_temp.refresh_target_windows = [false,false]
  1490.       $game_temp.refresh_actor_command = false ; @subject = nil
  1491.       $game_temp.refresh_battle_atb = false ; $game_temp.atb_break_duration = 0
  1492.       $game_temp.end_phase_duration = [false,0] ; $game_temp.battle_end2 = false     
  1493.       $game_temp.actor_command_index = 0 ; $game_temp.refresh_item_window = false
  1494.       $game_system.atb_turn_duration[0] = 0 ; $game_temp.atb_stop = [false,false]
  1495.       $game_temp.atb_actor_order = [] ; $game_temp.break_command = false
  1496.       $game_temp.actor_process_event = nil ; $game_temp.hwindow_atb = false
  1497.   end
  1498.  
  1499.   #--------------------------------------------------------------------------
  1500.   # ● Determine Win/Loss Results
  1501.   #--------------------------------------------------------------------------
  1502.   alias mog_atb_judge_win_loss judge_win_loss
  1503.   def judge_win_loss
  1504.       return if $game_temp.end_phase_duration[0]
  1505.       return if $game_troop.interpreter.running?
  1506.       mog_atb_judge_win_loss
  1507.   end
  1508.  
  1509.   #--------------------------------------------------------------------------
  1510.   # ● Clear Base Parameter
  1511.   #--------------------------------------------------------------------------   
  1512.   def clear_base_parameter
  1513.       battlers.each do |battler| battler.atb_initial end
  1514.   end
  1515.  
  1516.   #--------------------------------------------------------------------------
  1517.   # ● Process Abort
  1518.   #--------------------------------------------------------------------------   
  1519.   alias mog_atb_process_abort process_abort  
  1520.   def process_abort  
  1521.       $game_temp.atb_wait = true ; $game_temp.battle_end = true
  1522.       clear_base_parameter
  1523.       mog_atb_process_abort      
  1524.   end
  1525.  
  1526.   #--------------------------------------------------------------------------
  1527.   # ● Process Defeat
  1528.   #--------------------------------------------------------------------------   
  1529.   alias mog_atb_process_defeat process_defeat
  1530.   def process_defeat
  1531.       clear_base_parameter
  1532.       $game_temp.atb_wait = true ; $game_temp.battle_end = true   
  1533.       mog_atb_process_defeat
  1534.   end  
  1535.  
  1536.   #--------------------------------------------------------------------------
  1537.   # ● Process Victory
  1538.   #--------------------------------------------------------------------------   
  1539.   alias mog_atb_process_victory process_victory
  1540.   def process_victory
  1541.       $game_temp.atb_wait = true ; $game_temp.battle_end = true
  1542.       mog_atb_process_victory
  1543.   end
  1544.  
  1545.   #--------------------------------------------------------------------------
  1546.   # ● Prior Command
  1547.   #--------------------------------------------------------------------------   
  1548.   alias mog_atb_prior_command prior_command
  1549.   def prior_command
  1550.       if $sv_camera != nil
  1551.          actor = $game_party.battle_members[@actor_index] rescue nil
  1552.          return if actor == nil
  1553.       end
  1554.       mog_atb_prior_command
  1555.   end   
  1556.  
  1557. end
  1558.  
  1559. #==============================================================================
  1560. # ■ Scene Battle
  1561. #==============================================================================
  1562. class Scene_Battle < Scene_Base
  1563.   include MOG_ATB_SYSTEM
  1564.  
  1565.   #--------------------------------------------------------------------------
  1566.   # ● Battle Start
  1567.   #--------------------------------------------------------------------------
  1568.   def battle_start
  1569.       BattleManager.battle_start
  1570.       process_event
  1571.       set_turn_duration
  1572.   end   
  1573.  
  1574.   #--------------------------------------------------------------------------
  1575.   # ● Set Turn Duration
  1576.   #--------------------------------------------------------------------------
  1577.   def set_turn_duration
  1578.       $game_system.atb_turn_duration = [0,BattleManager.set_turn_duration]
  1579.       @status_window.open if @status_window != nil
  1580.       BattleManager.turn_start_abs
  1581.   end     
  1582.  
  1583.   #--------------------------------------------------------------------------
  1584.   # ● Next Command
  1585.   #--------------------------------------------------------------------------  
  1586.   alias mog_atb_next_command next_command
  1587.   def next_command
  1588.       BattleManager.command_selection_clear if BattleManager.command_selection_clear?
  1589.       mog_atb_next_command
  1590.   end   
  1591.  
  1592.   #--------------------------------------------------------------------------
  1593.   # ● Process Action
  1594.   #--------------------------------------------------------------------------  
  1595.   def process_action
  1596.       process_atb_type
  1597.       return if !process_action_atb?
  1598.       update_turn if update_turn?
  1599.       @subject = BattleManager.update_atb
  1600.       process_actor_command if BattleManager.actor_command?
  1601.       force_refresh_status if BattleManager.refresh_status?
  1602.       process_action_atb if @subject
  1603.   end  
  1604.  
  1605.   #--------------------------------------------------------------------------
  1606.   # ● Update Break Phase
  1607.   #--------------------------------------------------------------------------  
  1608.   def update_break_phase
  1609.       $game_temp.atb_break_duration += 1
  1610.       return if $game_temp.atb_break_duration < 30
  1611.       $game_temp.atb_break_duration = 0
  1612.       process_atb_break if proccess_atb_break?
  1613.   end
  1614.  
  1615.   #--------------------------------------------------------------------------
  1616.   # ● Process ATB Break
  1617.   #--------------------------------------------------------------------------  
  1618.   def process_atb_break      
  1619.       if BattleManager.actor != nil
  1620.          BattleManager.actor.atb -= 1
  1621.          if BattleManager.actor.restriction == 4 or BattleManager.actor.hp == 0 or
  1622.             BattleManager.actor.dead?
  1623.             BattleManager.actor.turn_clear
  1624.          end
  1625.       end
  1626.       hide_base_window
  1627.       BattleManager.command_selection_clear
  1628.   end
  1629.  
  1630.   #--------------------------------------------------------------------------
  1631.   # ● Process Action
  1632.   #--------------------------------------------------------------------------  
  1633.   def proccess_atb_break?
  1634.       return false if $game_troop.interpreter.running?
  1635.       members_atb_max = true
  1636.       members_next_turn = true
  1637.       for battler in $game_party.battle_members
  1638.           members_atb_max = false if !battler.atb_max?
  1639.           members_next_turn = false if !battler.next_turn         
  1640.       end
  1641.       if BattleManager.actor != nil
  1642.          return true if can_break_actor_command?
  1643.        else
  1644.          return true if members_atb_max and !members_next_turn
  1645.       end
  1646.       return false
  1647.   end
  1648.  
  1649.   #--------------------------------------------------------------------------
  1650.   # ● Can Break Actor Command
  1651.   #--------------------------------------------------------------------------  
  1652.   def can_break_actor_command?
  1653.       return true if BattleManager.actor.next_turn
  1654.       return true if BattleManager.actor.restriction > 0
  1655.       return true if BattleManager.actor.dead? or BattleManager.actor.hp == 0
  1656.       return true if !base_window_active?
  1657.       return false
  1658.   end
  1659.  
  1660.   #--------------------------------------------------------------------------
  1661.   # ● Base Window Active
  1662.   #--------------------------------------------------------------------------  
  1663.   def base_window_active?
  1664.       return true if @actor_window.active
  1665.       return true if @enemy_window.active
  1666.       return true if @item_window.active
  1667.       return true if @skill_window.active
  1668.       return true if @party_command_window.active
  1669.       return true if @actor_command_window.active
  1670.       return false
  1671.   end
  1672.  
  1673.   #--------------------------------------------------------------------------
  1674.   # ● Process Action
  1675.   #--------------------------------------------------------------------------  
  1676.   def process_action_atb
  1677.       $game_temp.remove_order(@subject)
  1678.       loop do
  1679.           if @subject == nil
  1680.              turn_end_subject_nil
  1681.              break
  1682.           end   
  1683.           BattleManager.set_battler_in_turn(@subject)
  1684.           BattleManager.set_subject(@subject)
  1685.           @log_window.clear
  1686.           if @subject.atb_escape
  1687.              process_escape
  1688.              break
  1689.           end
  1690.           process_before_execute_action
  1691.           process_execute_action if @subject.current_action
  1692.           process_after_execute_action
  1693.           hide_windows_for_dead
  1694.           if break_process_action_atb?
  1695.              process_action_end
  1696.              turn_end
  1697.              break
  1698.           end  
  1699.       end
  1700.   end
  1701.  
  1702.   #--------------------------------------------------------------------------
  1703.   # ● Break Process Action Atb
  1704.   #--------------------------------------------------------------------------   
  1705.   def break_process_action_atb?
  1706.       return true if !@subject.current_action
  1707.       return true if @subject.restriction == 4
  1708.       return true if @subject.dead? or @subject.hp == 0
  1709.       return false
  1710.   end
  1711.  
  1712.   #--------------------------------------------------------------------------
  1713.   # ● Can Break Process Action?
  1714.   #--------------------------------------------------------------------------  
  1715.   def can_break_process_action?
  1716.       return true if @subject == nil
  1717.       return false
  1718.   end
  1719.  
  1720.   #--------------------------------------------------------------------------
  1721.   # ● Can Break Command?
  1722.   #--------------------------------------------------------------------------   
  1723.   def can_break_command?
  1724.       return false if BattleManager.actor == nil
  1725.       return true if BattleManager.actor.hp == 0
  1726.       return true if BattleManager.actor.dead?
  1727.       return true if BattleManager.actor.restriction != 0
  1728.       return false
  1729.   end
  1730.  
  1731.   #--------------------------------------------------------------------------
  1732.   # ● Can Break Command2
  1733.   #--------------------------------------------------------------------------   
  1734.   def can_break_command2?
  1735.       return false if BattleManager.actor != nil
  1736.       return true if BattleManager.command_selection?
  1737.       return false
  1738.   end  
  1739.  
  1740.   #--------------------------------------------------------------------------
  1741.   # ● Break Command
  1742.   #--------------------------------------------------------------------------   
  1743.   def break_command
  1744.       $game_temp.break_command = false
  1745.       BattleManager.actor.turn_clear if BattleManager.actor != nil
  1746.       hide_base_window
  1747.       BattleManager.command_selection_clear
  1748.   end      
  1749.  
  1750.   #--------------------------------------------------------------------------
  1751.   # ● Turn End Subject Nil
  1752.   #--------------------------------------------------------------------------   
  1753.   def turn_end_subject_nil
  1754.       refresh_status
  1755.       BattleManager.judge_win_loss
  1756.       @subject =  nil
  1757.       BattleManager.set_subject(@subject)
  1758.       @log_window.wait
  1759.       @log_window.clear
  1760.       $game_temp.atb_break_duration = 100
  1761.       execute_event_phase if execute_event_phase_turn?
  1762.   end   
  1763.  
  1764.   #--------------------------------------------------------------------------
  1765.   # ● Process Escape
  1766.   #--------------------------------------------------------------------------  
  1767.   def process_escape
  1768.       if BattleManager.process_escape     
  1769.          process_execute_escape
  1770.       else   
  1771.          start_actor_command_selection if BattleManager.actor
  1772.          @status_window.open
  1773.       end  
  1774.       turn_end   
  1775.   end
  1776.  
  1777.   #--------------------------------------------------------------------------
  1778.   # ● Process Actor Command
  1779.   #--------------------------------------------------------------------------  
  1780.   def process_actor_command
  1781.       start_actor_command_selection
  1782.   end
  1783.  
  1784.   #--------------------------------------------------------------------------
  1785.   # ● Process Before Execute Action
  1786.   #--------------------------------------------------------------------------  
  1787.   def process_before_execute_action   
  1788.   end  
  1789.  
  1790.   #--------------------------------------------------------------------------
  1791.   # ● Process After Execute Action
  1792.   #--------------------------------------------------------------------------  
  1793.   def process_after_execute_action   
  1794.   end   
  1795.  
  1796.   #--------------------------------------------------------------------------
  1797.   # ● Refresh Actor Command
  1798.   #--------------------------------------------------------------------------  
  1799.   def refresh_actor_command?
  1800.       return false if !$game_temp.refresh_actor_command
  1801.       return false if !@actor_command_window.active
  1802.       return false if !BattleManager.actor
  1803.       return true
  1804.   end  
  1805.  
  1806.   #--------------------------------------------------------------------------
  1807.   # ● Update Actor Command
  1808.   #--------------------------------------------------------------------------  
  1809.   def update_actor_command
  1810.       return if !@actor_command_window.active
  1811.       return if !BattleManager.actor
  1812.       if ENABLE_BUTTON_NEXT_ACTOR
  1813.          if Input.trigger?(BUTTON_NEXT_ACTOR_LEFT) ; turn_to_next_actor(-1) rescue nil
  1814.          elsif Input.trigger?(BUTTON_NEXT_ACTOR_RIGHT) ; turn_to_next_actor(1) rescue nil
  1815.          end  
  1816.       end   
  1817.   end  
  1818.  
  1819.   #--------------------------------------------------------------------------
  1820.   # ● Turn To Next Actor
  1821.   #--------------------------------------------------------------------------  
  1822.   def turn_to_next_actor(value)
  1823.       return if BattleManager.actor == nil
  1824.       next_index = BattleManager.actor.index + value
  1825.       next_index = 0 if next_index >= $game_party.battle_members.size
  1826.       battler = $game_party.battle_members[next_index]
  1827.       next_act = false
  1828.       if battler.movable_atb?
  1829.          cancel_actor_command_scene(false) ; BattleManager.prepare_actor_command(battler)
  1830.          process_actor_command if BattleManager.actor_command?
  1831.          next_act = true
  1832.       else           
  1833.         @tnext_index = value   
  1834.          for battler in $game_party.battle_members
  1835.              next_index += @tnext_index
  1836.              if next_index >= $game_party.battle_members.size
  1837.                 next_index = 0 ; @tnext_index = 1
  1838.                 if next_actor_command?(next_index) ; next_act = true ; break ; end
  1839.              elsif next_index < 0
  1840.                 next_index = $game_party.battle_members.size ;  @tnext_index = -1
  1841.                 if next_actor_command?(next_index) ; next_act = true ; break ; end
  1842.              end
  1843.              if next_actor_command?(next_index) ; next_act = true ; break ; end
  1844.          end  
  1845.       end
  1846.      Sound.play_cancel if !next_act
  1847.   end
  1848.  
  1849.   #--------------------------------------------------------------------------
  1850.   # ● Next Actor Command?
  1851.   #--------------------------------------------------------------------------  
  1852.   def next_actor_command?(next_index)
  1853.       for battler in $game_party.battle_members
  1854.           next if next_index == BattleManager.actor.index
  1855.           if next_index == battler.index and battler.movable_atb?
  1856.              cancel_actor_command_scene(false)
  1857.              BattleManager.prepare_actor_command(battler)
  1858.              process_actor_command if BattleManager.actor_command?
  1859.              return true
  1860.           end            
  1861.       end
  1862.       return false
  1863.   end  
  1864.  
  1865.   #--------------------------------------------------------------------------
  1866.   # ● Cancel Actor Command scene
  1867.   #--------------------------------------------------------------------------  
  1868.   def cancel_actor_command_scene(atb_cost = false)
  1869.       @actor_command_window.close ; @actor_command_window.hide_all
  1870.       BattleManager.cancel_actor_command(atb_cost)
  1871.   end
  1872.  
  1873.   #--------------------------------------------------------------------------
  1874.   # ● Update Party Command
  1875.   #--------------------------------------------------------------------------      
  1876.   def update_party_command
  1877.       return if !@party_command_window.active
  1878.       return if !BattleManager.actor
  1879.       if Input.trigger?(:B)
  1880.          Sound.play_cancel
  1881.          @party_command_window.deactivate ; start_actor_command_selection
  1882.       end  
  1883.   end
  1884.  
  1885.   #--------------------------------------------------------------------------
  1886.   # ● Create All Windows
  1887.   #--------------------------------------------------------------------------      
  1888.   alias mog_atb_create_all_windows create_all_windows
  1889.   def create_all_windows
  1890.       mog_atb_create_all_windows
  1891.       @pre_viewport_visible = true
  1892.       @info_xy = [0,(Graphics.width - @status_window.width) / 2, Graphics.width - @status_window.width ]
  1893.   end  
  1894.  
  1895.   #--------------------------------------------------------------------------
  1896.   # ● Update Info Viewport
  1897.   #--------------------------------------------------------------------------      
  1898.   def update_info_viewport
  1899.       if center_viewport?
  1900.          move_info_viewport(@info_xy[1]) ; return
  1901.       end
  1902.       if @party_command_window.active ; move_info_viewport(@info_xy[0])   
  1903.       elsif BattleManager.actor ; move_info_viewport(@info_xy[2])
  1904.       else ; move_info_viewport(@info_xy[1])
  1905.       end  
  1906.   end  
  1907.  
  1908.   #--------------------------------------------------------------------------
  1909.   # ● Update Info Viewport
  1910.   #--------------------------------------------------------------------------      
  1911.   def center_viewport?
  1912.       return true if $game_message.visible
  1913.       return true if BattleManager.actor == nil
  1914.       return true if $game_temp.battle_end
  1915.       return false
  1916.   end
  1917.  
  1918.   #--------------------------------------------------------------------------
  1919.   # ● Process Action ATB
  1920.   #--------------------------------------------------------------------------  
  1921.   def process_action_atb?  
  1922.       return false if $game_troop.interpreter.running?
  1923.       return false if $game_temp.end_phase_duration[1] > 0  
  1924.       return false if $game_temp.atb_wait
  1925.       return false if $game_temp.battle_end
  1926.       return false if $game_temp.battle_end2
  1927.       return false if scene_changing?
  1928.       return false if !$game_temp.sprite_visible
  1929.       return false if $game_temp.atb_stop[1]
  1930.       return false if @combatlog_window.visible if @combatlog_window != nil
  1931.       return true
  1932.   end
  1933.  
  1934.   #--------------------------------------------------------------------------
  1935.   # ● Process ATB Type
  1936.   #--------------------------------------------------------------------------  
  1937.   def process_atb_type
  1938.       $game_temp.atb_frame_skip -= 1 if $game_temp.atb_frame_skip > 0
  1939.       return if $game_temp.battle_end
  1940.       return if $game_temp.end_phase_duration[1] > 0
  1941.       case $game_system.atb_type
  1942.            when 0 ; $game_temp.atb_wait = set_atb_type_wait
  1943.            when 1 ; $game_temp.atb_wait = set_atb_type_semi_wait
  1944.            else ; $game_temp.atb_wait = false
  1945.       end
  1946.   end
  1947.  
  1948.   #--------------------------------------------------------------------------
  1949.   # ● Set Atb Type Wait
  1950.   #--------------------------------------------------------------------------  
  1951.   def set_atb_type_wait
  1952.       return true if @actor_window.active
  1953.       return true if @enemy_window.active
  1954.       return true if @item_window.active
  1955.       return true if @skill_window.active
  1956.       return true if @party_command_window.active
  1957.       return true if @actor_command_window.active
  1958.       return false
  1959.   end
  1960.  
  1961.   #--------------------------------------------------------------------------
  1962.   # ● Set Atb Type Semi Wait
  1963.   #--------------------------------------------------------------------------  
  1964.   def set_atb_type_semi_wait
  1965.       return true if @item_window.active
  1966.       return true if @skill_window.active
  1967.       return false   
  1968.   end
  1969.  
  1970.   #--------------------------------------------------------------------------
  1971.   # ● Process Execute Escape
  1972.   #--------------------------------------------------------------------------  
  1973.   def process_execute_escape
  1974.       $game_temp.battle_end = true
  1975.       hide_base_window
  1976.       $game_temp.atb_user = nil
  1977.       $game_temp.battle_cursor[2] = false if $imported[:mog_battle_cursor]
  1978.       BattleManager.command_selection_clear
  1979.   end
  1980.  
  1981.   #--------------------------------------------------------------------------
  1982.   # ● Battle End?
  1983.   #--------------------------------------------------------------------------  
  1984.   def battle_end?
  1985.       return true if $game_party.members.empty?
  1986.       return true if $game_party.all_dead?
  1987.       return true if $game_troop.all_dead?
  1988.       return true if $game_temp.battle_end
  1989.       return false
  1990.   end
  1991.  
  1992.   #--------------------------------------------------------------------------
  1993.   # ● Command Escape
  1994.   #--------------------------------------------------------------------------  
  1995.   def command_escape
  1996.       BattleManager.actor.atb_escape = true if BattleManager.actor
  1997.       BattleManager.command_end
  1998.       @party_command_window.close
  1999.       hide_base_window
  2000.   end  
  2001.  
  2002.   #--------------------------------------------------------------------------
  2003.   # ● Command Escape2
  2004.   #--------------------------------------------------------------------------  
  2005.   def command_escape2
  2006.      turn_start unless BattleManager.process_escape
  2007.   end
  2008.  
  2009.   #--------------------------------------------------------------------------
  2010.   # ● Execute Action
  2011.   #--------------------------------------------------------------------------  
  2012.   alias mog_atb_execute_action execute_action
  2013.   def execute_action
  2014.       @cp_members = []
  2015.       return if battle_end? or @subject == nil
  2016.       @cp_members = current_cp_members if can_execute_cooperation_skill?            
  2017.       mog_atb_execute_action
  2018.   end
  2019.  
  2020.   #--------------------------------------------------------------------------
  2021.   # ● Use Item
  2022.   #--------------------------------------------------------------------------  
  2023.   alias mog_atb_use_item use_item
  2024.   def use_item
  2025.       return if battle_end? or @subject == nil
  2026.       mog_atb_use_item
  2027.   end
  2028.  
  2029.   #--------------------------------------------------------------------------
  2030.   # ● Show Animation
  2031.   #--------------------------------------------------------------------------  
  2032.   alias mog_atb_event_show_animation show_animation
  2033.   def show_animation(targets, animation_id)
  2034.       execute_event_phase if execute_event_phase_turn?
  2035.       mog_atb_event_show_animation(targets, animation_id)   
  2036.   end
  2037.  
  2038.   #--------------------------------------------------------------------------
  2039.   # ● Force Refresh Status
  2040.   #--------------------------------------------------------------------------  
  2041.   def force_refresh_status
  2042.       BattleManager.set_refresh_status(false)
  2043.       refresh_status
  2044.   end
  2045.  
  2046.   #--------------------------------------------------------------------------
  2047.   # ● Refresh Battle ATB
  2048.   #--------------------------------------------------------------------------  
  2049.   def refresh_battle_atb
  2050.       $game_temp.refresh_battle_atb = false
  2051.       hide_base_window
  2052.       battle_start      
  2053.   end
  2054.  
  2055.   #--------------------------------------------------------------------------
  2056.   # ● Hide Base Window
  2057.   #--------------------------------------------------------------------------  
  2058.   def hide_base_window(target_window = true,actor_window = false)
  2059.       @actor_window.hide
  2060.       @actor_window.active = false
  2061.       @enemy_window.hide
  2062.       @enemy_window.active = false
  2063.       @help_window.hide
  2064.       @party_command_window.deactivate
  2065.       @party_command_window.close
  2066.       @status_window.unselect
  2067.       instance_variables.each do |varname|
  2068.          ivar = instance_variable_get(varname)
  2069.          if ivar.is_a?(Window)
  2070.             next if !need_hide_window?(ivar,actor_window)            
  2071.             ivar.hide_all
  2072.          end   
  2073.       end
  2074.       @pre_viewport_visible = @info_viewport.visible
  2075.       @info_viewport.visible = true ; @status_window.show
  2076.       @status_aid_window.hide_all if @status_aid_window != nil
  2077.   end
  2078.  
  2079.   #--------------------------------------------------------------------------
  2080.   # ● Need Hide Window?
  2081.   #--------------------------------------------------------------------------  
  2082.   def need_hide_window?(ivar,actor_window)
  2083.       return false if ivar.is_a?(Window_Message)
  2084.       return false if ivar.is_a?(Window_BattleActor)
  2085.       return false if ivar.is_a?(Window_BattleEnemy)
  2086.       return false if ivar.is_a?(Window_BattleStatus)
  2087.       return false if ivar.is_a?(Window_PartyCommand)
  2088.       return false if ivar.is_a?(Window_ActorCommand) and actor_window
  2089.       if $imported["YEA-VictoryAftermath"]
  2090.          return false if ivar.is_a?(Window_VictoryTitle)
  2091.          return false if ivar.is_a?(Window_VictoryEXP_Back)
  2092.          return false if ivar.is_a?(Window_VictoryEXP_Front)
  2093.          return false if ivar.is_a?(Window_VictoryLevelUp)
  2094.          return false if ivar.is_a?(Window_VictorySkills)
  2095.          return false if ivar.is_a?(Window_VictorySpoils)
  2096.       end      
  2097.       return true
  2098.   end     
  2099.  
  2100.   #--------------------------------------------------------------------------
  2101.   # ● Record Window Data
  2102.   #--------------------------------------------------------------------------  
  2103.   def record_window_data(target_window = true)
  2104.       return if $game_temp.hwindow_atb
  2105.       $game_temp.hwindow_atb = true
  2106.       @pre_battler = BattleManager.actor
  2107.       @battler_in_turn_temp = @actor_command_window.active
  2108.       instance_variables.each do |varname|
  2109.          ivar = instance_variable_get(varname)
  2110.          ivar.record_data if ivar.is_a?(Window)
  2111.       end      
  2112.       if $imported[:mog_battle_cursor]
  2113.          @battle_cursor_visible = $game_temp.battle_cursor[2]
  2114.          $game_temp.battle_cursor[2] = false
  2115.       end         
  2116.       hide_base_window(target_window)   
  2117.   end
  2118.  
  2119.   #--------------------------------------------------------------------------
  2120.   # ● Fade Base Window
  2121.   #--------------------------------------------------------------------------  
  2122.   def fade_base_window(fade_value)
  2123.       instance_variables.each do |varname|
  2124.          ivar = instance_variable_get(varname)
  2125.          if ivar.is_a?(Window)
  2126.             next if !need_fade_after_battle?(ivar)
  2127.             ivar.opacity -= fade_value
  2128.             ivar.contents_opacity -= fade_value
  2129.          end
  2130.       end
  2131.   end  
  2132.  
  2133.   #--------------------------------------------------------------------------
  2134.   # ● Need Fade After Battle?
  2135.   #--------------------------------------------------------------------------  
  2136.   def need_fade_after_battle?(ivar)
  2137.       return false if ivar.is_a?(Window_Message)
  2138.       if $imported["YEA-VictoryAftermath"]
  2139.          return false if ivar.is_a?(Window_VictoryTitle)
  2140.          return false if ivar.is_a?(Window_VictoryEXP_Back)
  2141.          return false if ivar.is_a?(Window_VictoryEXP_Front)
  2142.          return false if ivar.is_a?(Window_VictoryLevelUp)
  2143.          return false if ivar.is_a?(Window_VictorySkills)
  2144.          return false if ivar.is_a?(Window_VictorySpoils)
  2145.       end
  2146.       return true
  2147.   end   
  2148.  
  2149.   #--------------------------------------------------------------------------
  2150.   # ● Record Window Data
  2151.   #--------------------------------------------------------------------------  
  2152.   def restore_window_data
  2153.       return if battle_end?
  2154.        if @pre_battler and @pre_battler.dead?
  2155.           hide_windows_for_dead
  2156.        else
  2157.           instance_variables.each do |varname|
  2158.              ivar = instance_variable_get(varname)
  2159.              ivar.restore_data if ivar.is_a?(Window)
  2160.           end   
  2161.           @info_viewport.visible = @pre_viewport_visible
  2162.           @actor_command_window.open if @actor_command_window.visible
  2163.           @status_window.open if @status_window.visible
  2164.           @actor_window.show if @actor_window.active
  2165.           @actor_window.restore_data if @actor_window.active
  2166.           @enemy_window.show if @enemy_window.active
  2167.           @enemy_window.restore_data if @enemy_window.active
  2168.           start_actor_command_selection(false) if @actor_command_window.active
  2169.           start_party_command_selection if @party_command_window.active
  2170.           if $imported[:mog_battle_cursor]
  2171.              $game_temp.battle_cursor[2] = @battle_cursor_visible
  2172.           end
  2173.       end
  2174.       $game_temp.hwindow_atb = false
  2175.   end
  2176.  
  2177.   #--------------------------------------------------------------------------
  2178.   # ● Hide Windows for dead
  2179.   #--------------------------------------------------------------------------  
  2180.   def hide_windows_for_dead
  2181.       return if BattleManager.actor == nil
  2182.       return if !BattleManager.actor.dead?
  2183.       hide_base_window
  2184.       $game_temp.atb_user = nil
  2185.       $game_temp.battle_cursor[2] = false if $imported[:mog_battle_cursor]
  2186.       BattleManager.command_selection_clear
  2187.   end
  2188.  
  2189.   #--------------------------------------------------------------------------
  2190.   # ● Update Target Windows
  2191.   #--------------------------------------------------------------------------  
  2192.   def update_target_windows
  2193.       if @actor_window.active and $game_temp.refresh_target_windows[0]
  2194.          @actor_window.refresh
  2195.          @actor_window.update
  2196.          $game_temp.refresh_target_windows[0] = false
  2197.       end  
  2198.       if @enemy_window.active and $game_temp.refresh_target_windows[1]
  2199.          @enemy_window.refresh
  2200.          @enemy_window.cursor_left if @enemy_window.enemy == nil
  2201.          @enemy_window.update
  2202.          $game_temp.refresh_target_windows[1] = false
  2203.       end
  2204.   end  
  2205.  
  2206.   #--------------------------------------------------------------------------
  2207.   # ● Process Execute Action
  2208.   #--------------------------------------------------------------------------  
  2209.   def process_execute_action
  2210.       @subject.current_action.prepare
  2211.       if @subject.current_action.valid?      
  2212.          @status_window.open ; execute_action
  2213.       end
  2214.       process_before_remove_action
  2215.       @subject.remove_current_action
  2216.   end
  2217.  
  2218.   #--------------------------------------------------------------------------
  2219.   # ● Process Before Remove Action
  2220.   #--------------------------------------------------------------------------  
  2221.   def process_before_remove_action   
  2222.   end
  2223.  
  2224.   #--------------------------------------------------------------------------
  2225.   # * End Turn
  2226.   #--------------------------------------------------------------------------
  2227.   def turn_end
  2228.       BattleManager.set_battler_in_turn(nil)   
  2229.       all_battle_members.each do |battler|
  2230.           refresh_status
  2231.           @log_window.wait_and_clear
  2232.       end
  2233.       turn_reset
  2234.   end  
  2235.  
  2236.   #--------------------------------------------------------------------------
  2237.   # ● Turn Reset
  2238.   #--------------------------------------------------------------------------
  2239.   def turn_reset
  2240.       $game_temp.remove_order(@subject)      
  2241.       BattleManager.current_battler_clear(@subject)
  2242.       BattleManager.command_selection_clear if BattleManager.command_need_clear?
  2243.       @subject =  nil
  2244.       BattleManager.set_subject(@subject)
  2245.       @log_window.wait
  2246.       @log_window.clear      
  2247.       $game_temp.atb_break_duration = 100
  2248.   end
  2249.  
  2250.   #--------------------------------------------------------------------------
  2251.   # ● Execute Event Phase Turn?
  2252.   #--------------------------------------------------------------------------
  2253.   def execute_event_phase_turn?
  2254.       return false if !$game_troop.can_interpreter_running?(false)
  2255.       return false if $game_party.members.empty?
  2256.       return false if $game_party.all_dead?
  2257.       return false if $game_troop.all_dead?
  2258.       return true
  2259.   end  
  2260.  
  2261.   #--------------------------------------------------------------------------
  2262.   # ● Update
  2263.   #--------------------------------------------------------------------------            
  2264.   def update
  2265.       update_basic   
  2266.       refresh_battle_atb if $game_temp.refresh_battle_atb
  2267.       process_action if BattleManager.in_turn?
  2268.       update_end_phase if $game_temp.end_phase_duration[1] > 0
  2269.   end  
  2270.  
  2271.   #--------------------------------------------------------------------------
  2272.   # ● Update Basic
  2273.   #--------------------------------------------------------------------------            
  2274.   alias mog_atb_update_basic update_basic
  2275.   def update_basic
  2276.       update_break_phase
  2277.       break_command if force_break_command?
  2278.       update_atb_basic if !$game_troop.interpreter.running?
  2279.       mog_atb_update_basic
  2280.   end
  2281.  
  2282.   #--------------------------------------------------------------------------
  2283.   # ● Force Break Command
  2284.   #--------------------------------------------------------------------------            
  2285.   def force_break_command?
  2286.       return true if $game_temp.break_command
  2287.       return true if can_break_command?
  2288.       return true if can_break_command2?
  2289.       return false
  2290.   end
  2291.  
  2292.   #--------------------------------------------------------------------------
  2293.   # ● Update Atb Basic
  2294.   #--------------------------------------------------------------------------            
  2295.   def update_atb_basic
  2296.       if @actor_command_window.active
  2297.          update_actor_command
  2298.       else   
  2299.          update_party_command
  2300.       end   
  2301.       update_target_windows      
  2302.       refresh_item_skill_window if need_refresh_item_skill_window?
  2303.       start_actor_command_selection if refresh_actor_command?
  2304.       fade_base_window(15) if $game_temp.battle_end
  2305.   end  
  2306.  
  2307.   #--------------------------------------------------------------------------
  2308.   # ● Need Refresh Item Skill Window?
  2309.   #--------------------------------------------------------------------------            
  2310.   def need_refresh_item_skill_window?
  2311.       return true if $game_temp.refresh_item_window
  2312.       return false
  2313.   end
  2314.  
  2315.   #--------------------------------------------------------------------------
  2316.   # ● Refresh Item Skill Window
  2317.   #--------------------------------------------------------------------------            
  2318.   def refresh_item_skill_window
  2319.       $game_temp.refresh_item_window = false
  2320.       @item_window.refresh if @item_window.visible
  2321.       @skill_window.refresh if @skill_window.visible
  2322.   end
  2323.  
  2324.   #--------------------------------------------------------------------------
  2325.   # ● Update End Phase
  2326.   #--------------------------------------------------------------------------            
  2327.   def update_end_phase
  2328.       $game_temp.end_phase_duration[1] -= 1
  2329.       return if $game_temp.end_phase_duration[1] > 0
  2330.       $game_temp.end_phase_duration[0] = false
  2331.       BattleManager.judge_win_loss
  2332.   end
  2333.  
  2334.   #--------------------------------------------------------------------------
  2335.   # ● Process Event
  2336.   #--------------------------------------------------------------------------            
  2337.   alias mog_atb_process_event process_event
  2338.   def process_event
  2339.       if battle_end? ; hide_base_window ; $game_temp.end_phase_duration = [true,30] ; end
  2340.       $game_temp.actor_process_event = BattleManager.actor
  2341.       mog_atb_process_event
  2342.       process_break_atb_event
  2343.   end
  2344.  
  2345.   #--------------------------------------------------------------------------
  2346.   # ● Process Break ATB Event
  2347.   #--------------------------------------------------------------------------            
  2348.   def process_break_atb_event
  2349.       if break_actor_command?
  2350.          BattleManager.actor.turn_clear
  2351.          BattleManager.command_selection_clear
  2352.       end
  2353.       BattleManager.force_clear_battler_atb
  2354.   end
  2355.  
  2356.   #--------------------------------------------------------------------------
  2357.   # ● Break Actor Command
  2358.   #--------------------------------------------------------------------------            
  2359.   def break_actor_command?
  2360.       return false if BattleManager.actor == nil
  2361.       return true if BattleManager.actor.dead?
  2362.       return true if BattleManager.actor.restriction != 0
  2363.       return false
  2364.   end
  2365.  
  2366.   #--------------------------------------------------------------------------
  2367.   # * Processing at End of Action
  2368.   #--------------------------------------------------------------------------
  2369.   alias mog_atb_process_action_end process_action_end
  2370.   def process_action_end
  2371.       if battle_end? ; hide_base_window ; $game_temp.end_phase_duration = [true,30] ; end
  2372.       mog_atb_process_action_end
  2373.   end  
  2374.  
  2375.   #--------------------------------------------------------------------------
  2376.   # ● Update Turn
  2377.   #--------------------------------------------------------------------------            
  2378.   def update_turn
  2379.       force_reset_turn_duration if $game_temp.turn_duration_clear
  2380.       $game_system.atb_turn_duration[0] += 1 unless $game_troop.interpreter.running?
  2381.       if $game_system.atb_turn_duration[0] >= $game_system.atb_turn_duration[1]
  2382.          $game_system.atb_turn_duration[0] = 0
  2383.          $game_troop.increase_turn
  2384.          execute_event_phase if $game_troop.can_interpreter_running?(true)
  2385.       end  
  2386.   end  
  2387.  
  2388.   #--------------------------------------------------------------------------
  2389.   # ● Update Turn
  2390.   #--------------------------------------------------------------------------            
  2391.   def update_turn?
  2392.       return false if $game_system.atb_turn_duration == nil or $game_system.atb_turn_duration[0] == nil
  2393.       return false if $game_temp.end_phase_duration[1] > 0
  2394.       return false if $game_temp.battle_end
  2395.       return false if $game_temp.atb_stop[1]   
  2396.       return true
  2397.   end   
  2398.  
  2399.   #--------------------------------------------------------------------------
  2400.   # ● Execute Event Phase
  2401.   #--------------------------------------------------------------------------            
  2402.   def execute_event_phase
  2403.       if $game_troop.can_interpreter_hide_window? or $game_troop.can_interpreter_hide_window_2?
  2404.       (record_window_data ; rw = true)
  2405.       end
  2406.       process_event
  2407.       refresh_status
  2408.       restore_window_data if rw != nil
  2409.       BattleManager.turn_start_abs      
  2410.   end   
  2411.  
  2412.   #--------------------------------------------------------------------------
  2413.   # ● Force Reset Turn Duration
  2414.   #--------------------------------------------------------------------------            
  2415.   def force_reset_turn_duration
  2416.       $game_temp.turn_duration_clear = false
  2417.       $game_system.atb_turn_duration[0] = 0
  2418.       $game_troop.set_turn(0)
  2419.   end  
  2420.  
  2421.   #--------------------------------------------------------------------------
  2422.   # ● ON Enemy OK
  2423.   #--------------------------------------------------------------------------
  2424.   alias mog_atb_on_enemy_ok on_enemy_ok
  2425.   def on_enemy_ok
  2426.       return if BattleManager.actor == nil
  2427.       return if battle_end?
  2428.       mog_atb_on_enemy_ok           
  2429.       BattleManager.command_end
  2430.       hide_base_window
  2431.   end
  2432.  
  2433.   #--------------------------------------------------------------------------
  2434.   # ● On Enemy Cancel
  2435.   #--------------------------------------------------------------------------
  2436.   alias mog_atb_on_enemy_cancel on_enemy_cancel
  2437.   def on_enemy_cancel
  2438.       return if BattleManager.actor == nil
  2439.       mog_atb_on_enemy_cancel
  2440.       start_actor_command_selection if @actor_command_window.active
  2441.       @skill_window.visible = true if @skill_window.active
  2442.       @item_window.visible = true if @item_window.active
  2443.   end     
  2444.  
  2445.   #--------------------------------------------------------------------------
  2446.   # ● On Actor OK
  2447.   #--------------------------------------------------------------------------
  2448.   alias mog_atb_on_actor_ok on_actor_ok
  2449.   def on_actor_ok
  2450.       return if BattleManager.actor == nil
  2451.       return if battle_end?
  2452.       mog_atb_on_actor_ok
  2453.       BattleManager.command_end
  2454.       hide_base_window
  2455.   end
  2456.  
  2457.   #--------------------------------------------------------------------------
  2458.   # ● On Actor Cancel
  2459.   #--------------------------------------------------------------------------
  2460.   alias mog_atb_on_actor_cancel on_actor_cancel
  2461.   def on_actor_cancel
  2462.       return if BattleManager.actor == nil
  2463.       mog_atb_on_actor_cancel
  2464.       start_actor_command_selection if @actor_command_window.active
  2465.       @skill_window.visible = true if @skill_window.active
  2466.       @item_window.visible = true if @item_window.active      
  2467.   end
  2468.  
  2469.   #--------------------------------------------------------------------------
  2470.   # ● On Skill Cancel
  2471.   #--------------------------------------------------------------------------
  2472.   alias mog_atb_on_skill_cancel on_skill_cancel
  2473.   def on_skill_cancel
  2474.       return if BattleManager.actor == nil
  2475.       mog_atb_on_skill_cancel
  2476.       start_actor_command_selection if @actor_command_window.active
  2477.   end  
  2478.  
  2479.   #--------------------------------------------------------------------------
  2480.   # ● On Item Cancel
  2481.   #--------------------------------------------------------------------------
  2482.   alias mog_atb_on_item_cancel on_item_cancel
  2483.   def on_item_cancel
  2484.       return if BattleManager.actor == nil
  2485.       mog_atb_on_item_cancel
  2486.       start_actor_command_selection if @actor_command_window.active
  2487.   end  
  2488.  
  2489.   #--------------------------------------------------------------------------
  2490.   # ● On Skill OK
  2491.   #--------------------------------------------------------------------------
  2492.   alias mog_atb_on_skill_ok on_skill_ok
  2493.   def on_skill_ok
  2494.       return if BattleManager.actor == nil
  2495.       @skill_window.visible = false unless !@status_window.visible
  2496.       mog_atb_on_skill_ok      
  2497.       if !@skill.need_selection?
  2498.          BattleManager.command_end
  2499.          hide_base_window
  2500.       end   
  2501.   end
  2502.  
  2503.   #--------------------------------------------------------------------------
  2504.   # ● On Item OK
  2505.   #--------------------------------------------------------------------------
  2506.   alias mog_atb_on_item_ok on_item_ok
  2507.   def on_item_ok
  2508.       return if BattleManager.actor == nil
  2509.       @item_window.visible = false unless !@status_window.visible
  2510.       mog_atb_on_item_ok
  2511.       if !@item.need_selection?
  2512.          BattleManager.command_end
  2513.          hide_base_window
  2514.       end
  2515.   end  
  2516.  
  2517.   #--------------------------------------------------------------------------
  2518.   # ● Start Actor Command Selection
  2519.   #--------------------------------------------------------------------------
  2520.   def start_actor_command_selection(se = true)
  2521.       $game_temp.atb_user = BattleManager.actor
  2522.       $game_temp.refresh_actor_command = false
  2523.       $game_temp.actor_process_event = nil
  2524.       if BattleManager.next_command and BattleManager.actor and BattleManager.actor.movable_atb?
  2525.          execute_start_actor_command(se)
  2526.       else   
  2527.          BattleManager.command_selection_clear
  2528.       end   
  2529.   end     
  2530.  
  2531.   #--------------------------------------------------------------------------
  2532.   # ● Execute Start Actor Command
  2533.   #--------------------------------------------------------------------------
  2534.   def execute_start_actor_command(se)
  2535.       $game_temp.remove_order(BattleManager.actor)      
  2536.       Audio.se_play("Audio/SE/" + SE_ACTIVE,100,100) if se
  2537.       hide_base_window(false,true) if se
  2538.       @status_window.select(BattleManager.actor.index)
  2539.       @status_window.open
  2540.       @status_window.select(BattleManager.actor.index)
  2541.       @party_command_window.close
  2542.       @actor_command_window.setup(BattleManager.actor)
  2543.       @actor_command_window.activate
  2544.       @actor_command_window.show
  2545.       @actor_command_window.index = $game_temp.actor_command_index      
  2546.   end
  2547.  
  2548.   #--------------------------------------------------------------------------
  2549.   # ● Next Command
  2550.   #--------------------------------------------------------------------------
  2551.   def next_command
  2552.   end
  2553.  
  2554.   #--------------------------------------------------------------------------
  2555.   # ● Close Base
  2556.   #--------------------------------------------------------------------------
  2557.   def close_base_window
  2558.       @party_command_window.close
  2559.       @actor_command_window.close
  2560.       @status_window.unselect
  2561.   end
  2562.  
  2563.   #--------------------------------------------------------------------------
  2564.   # ● Command Fight
  2565.   #--------------------------------------------------------------------------
  2566.   alias mog_atb_command_fight command_fight
  2567.   def command_fight
  2568.       mog_atb_command_fight
  2569.       start_actor_command_selection
  2570.   end  
  2571.  
  2572.   #--------------------------------------------------------------------------
  2573.   # ● Refresh Status
  2574.   #--------------------------------------------------------------------------
  2575.   alias mog_atb_refresh_status refresh_status
  2576.   def refresh_status
  2577.       mog_atb_refresh_status
  2578.       hide_windows_for_dead
  2579.   end
  2580.  
  2581.   #--------------------------------------------------------------------------
  2582.   # ● Forced Action Processing
  2583.   #--------------------------------------------------------------------------
  2584.   def process_forced_action   
  2585.       if BattleManager.action_forced?
  2586.          last_subject = @subject
  2587.          @subject = BattleManager.action_forced_battler         
  2588.          BattleManager.clear_action_force              
  2589.          execute_force_action         
  2590.          @subject = last_subject
  2591.       end
  2592.   end
  2593.  
  2594.   #--------------------------------------------------------------------------
  2595.   # ● Execute Force Action
  2596.   #--------------------------------------------------------------------------
  2597.   def execute_force_action
  2598.       return if scene_changing?
  2599.       if !@subject || !@subject.current_action
  2600.          @subject = BattleManager.next_subject
  2601.       end
  2602.       return turn_end unless @subject      
  2603.       if @subject.current_action        
  2604.          @subject.current_action.prepare
  2605.          if @subject.current_action.valid?
  2606.             @status_window.open
  2607.             execute_action
  2608.          end
  2609.          @subject.remove_current_action
  2610.        end
  2611.        process_action_end unless @subject.current_action
  2612.   end  
  2613.  
  2614.   #--------------------------------------------------------------------------
  2615.   # ● Subject Action
  2616.   #--------------------------------------------------------------------------  
  2617.   def subject_action
  2618.       return @subject.current_action.item rescue nil
  2619.   end  
  2620.  
  2621.   #--------------------------------------------------------------------------
  2622.   # ● Wait for Effect
  2623.   #--------------------------------------------------------------------------  
  2624.   alias mog_atb_cm_wait_for_effect wait_for_effect
  2625.   def wait_for_effect
  2626.       return if $game_troop.interpreter.running?
  2627.       mog_atb_cm_wait_for_effect
  2628.   end
  2629.  
  2630. end
  2631.  
  2632. #===============================================================================
  2633. # ■ Window Battle Skill
  2634. #===============================================================================
  2635. class Window_BattleSkill < Window_SkillList
  2636.  
  2637.   #--------------------------------------------------------------------------
  2638.   # ● Select Last
  2639.   #--------------------------------------------------------------------------
  2640.   alias mog_atb_f_select_last_skill select_last
  2641.   def select_last
  2642.       act = @actor.last_skill.object rescue nil
  2643.       act_data = @data.index(@actor.last_skill.object) rescue nil
  2644.       if act == nil or act_data == nil ; select(0) ; return ; end
  2645.       mog_atb_f_select_last_skill
  2646.   end
  2647.  
  2648. end
  2649.  
  2650. #===============================================================================
  2651. # ■ Window Battle Item
  2652. #===============================================================================
  2653. class Window_BattleItem < Window_ItemList
  2654.  
  2655.   #--------------------------------------------------------------------------
  2656.   # ● Select Last
  2657.   #--------------------------------------------------------------------------
  2658.   alias mog_atb_f_select_last_item select_last
  2659.   def select_last
  2660.       act = $game_party.last_item.object rescue nil
  2661.       act_data = @data.index($game_party.last_item.object) rescue nil
  2662.       if act == nil or act_data == nil ; select(0) ; return ; end
  2663.       mog_atb_f_select_last_item
  2664.   end
  2665.  
  2666. end
  2667.  
  2668. #===============================================================================
  2669. # ■ Scene Battle
  2670. #===============================================================================
  2671. class Scene_Battle < Scene_Base
  2672.  
  2673.   #--------------------------------------------------------------------------
  2674.   # ● Skip Command?
  2675.   #--------------------------------------------------------------------------
  2676.   def skip_command?
  2677.       return true if BattleManager.actor == nil
  2678.       return true if BattleManager.actor.dead?
  2679.       return true if BattleManager.actor.restriction != 0
  2680.       return false
  2681.   end
  2682.  
  2683.   #--------------------------------------------------------------------------
  2684.   # ● Command Attack
  2685.   #--------------------------------------------------------------------------
  2686.   alias mog_atb_f_command_attack command_attack
  2687.   def command_attack
  2688.       if skip_command? ; break_command ; return ; end
  2689.       mog_atb_f_command_attack
  2690.   end
  2691.  
  2692.   #--------------------------------------------------------------------------
  2693.   # ● Command Skill
  2694.   #--------------------------------------------------------------------------
  2695.   alias mog_atb_f_command_skill command_skill
  2696.   def command_skill
  2697.       if skip_command? ; break_command ; return ; end
  2698.       mog_atb_f_command_skill
  2699.   end
  2700.  
  2701.   #--------------------------------------------------------------------------
  2702.   # ● Command Guard
  2703.   #--------------------------------------------------------------------------
  2704.   alias mog_atb_f_command_guard command_guard
  2705.   def command_guard
  2706.       if skip_command? ; break_command ; return ; end
  2707.       mog_atb_f_command_guard
  2708.       BattleManager.command_end
  2709.       hide_base_window      
  2710.   end
  2711.  
  2712.   #--------------------------------------------------------------------------
  2713.   # ● Command Item
  2714.   #--------------------------------------------------------------------------
  2715.   alias mog_atb_f_command_item command_item
  2716.   def command_item
  2717.       if skip_command? ; break_command ; return ; end
  2718.       mog_atb_f_command_item
  2719.   end  
  2720.  
  2721. end
  2722.  
  2723. #==============================================================================
  2724. # ■ SpritesetBattle
  2725. #==============================================================================
  2726. class Spriteset_Battle
  2727.  
  2728.   include MOG_ATB_SYSTEM
  2729.  
  2730.   #--------------------------------------------------------------------------
  2731.   # ● Initialize
  2732.   #--------------------------------------------------------------------------   
  2733.   alias mog_atb_display_turn_initialize initialize
  2734.   def initialize
  2735.       create_turn_number
  2736.       mog_atb_display_turn_initialize
  2737.   end
  2738.  
  2739.   #--------------------------------------------------------------------------
  2740.   # ● Dispose
  2741.   #--------------------------------------------------------------------------  
  2742.   alias mog_atb_display_turn_dispose dispose
  2743.   def dispose
  2744.       mog_atb_display_turn_dispose
  2745.       dispose_turn_number
  2746.   end
  2747.  
  2748.   #--------------------------------------------------------------------------
  2749.   # ● Update
  2750.   #--------------------------------------------------------------------------   
  2751.   alias mog_atb_display_turn_update update
  2752.   def update
  2753.       mog_atb_display_turn_update
  2754.       update_turn_number
  2755.   end
  2756.  
  2757.   #--------------------------------------------------------------------------
  2758.   # ● Create Turn Number
  2759.   #--------------------------------------------------------------------------   
  2760.   def create_turn_number
  2761.       return if !DISPLAY_TURN_NUMBER
  2762.       @turn_count_old = $game_troop.turn_count
  2763.       @turn_sprite = Sprite.new
  2764.       @turn_sprite.bitmap = Bitmap.new(120,32)
  2765.       @turn_sprite.bitmap.font.size = TURN_NUMBER_FONT_SIZE
  2766.       @turn_sprite.bitmap.font.bold = TURN_NUMBER_FONT_BOLD
  2767.       @turn_sprite.z = TURN_NUMBER_Z
  2768.       @turn_sprite.x = TURN_NUMBER_POS[0] ; @turn_sprite.y = TURN_NUMBER_POS[1]
  2769.       refresh_turn_sprite
  2770.   end  
  2771.  
  2772.   #--------------------------------------------------------------------------
  2773.   # ● Refresh Turn Sprite
  2774.   #--------------------------------------------------------------------------   
  2775.   def refresh_turn_sprite
  2776.       @turn_count_old = $game_troop.turn_count
  2777.       @turn_sprite.bitmap.clear ; @turn_sprite.opacity = 255
  2778.       turn_text = TURN_WORD + $game_troop.turn_count.to_s
  2779.       @turn_sprite.bitmap.draw_text(0,0,120,32,turn_text,0)
  2780.   end
  2781.  
  2782.   #--------------------------------------------------------------------------
  2783.   # ● Dispose Turn Number
  2784.   #--------------------------------------------------------------------------   
  2785.   def dispose_turn_number
  2786.       return if @turn_sprite == nil
  2787.       @turn_sprite.bitmap.dispose ; @turn_sprite.dispose
  2788.   end
  2789.  
  2790.   #--------------------------------------------------------------------------
  2791.   # ● Update Turn Number
  2792.   #--------------------------------------------------------------------------   
  2793.   def update_turn_number
  2794.       return if @turn_sprite == nil
  2795.       refresh_turn_sprite if @turn_count_old != $game_troop.turn_count
  2796.       @turn_sprite.visible = turn_visible?
  2797.   end
  2798.  
  2799.   #--------------------------------------------------------------------------
  2800.   # ● Turn Visible?
  2801.   #--------------------------------------------------------------------------   
  2802.   def turn_visible?
  2803.       return false if !$game_temp.sprite_visible
  2804.       return false if !$game_system.atb_sprite_turn
  2805.       return true
  2806.   end
  2807.  
  2808. end
  2809.  
  2810. #==============================================================================
  2811. # ■ Window BattleLog
  2812. #==============================================================================
  2813. class Window_BattleLog < Window_Selectable   
  2814.   include MOG_COOPERATION_SKILLS
  2815.  
  2816.   #--------------------------------------------------------------------------
  2817.   # ● Display Skill/Item Use
  2818.   #--------------------------------------------------------------------------
  2819.   alias mog_cskill_display_use_item display_use_item
  2820.   def display_use_item(subject, item)
  2821.       return if cooperation_skill_users?(subject, item)
  2822.       mog_cskill_display_use_item(subject, item)
  2823.   end
  2824.  
  2825.   #--------------------------------------------------------------------------
  2826.   # ● Cooperation Skill_users?
  2827.   #--------------------------------------------------------------------------
  2828.   def cooperation_skill_users?(subject, item)
  2829.       return false if subject.is_a?(Game_Enemy)
  2830.       return false if !item.is_a?(RPG::Skill)
  2831.       return false if !BattleManager.is_cskill?(item.id)
  2832.       return false if !BattleManager.actor_included_in_cskill?(subject.id,item.id)
  2833.       members = BattleManager.cskill_members(item.id) ; subject_name = ""
  2834.       if members.size <=0  
  2835.          members.each_with_index do |b,index|     
  2836.          if index == members.size - 1 ; subject_name += b.name
  2837.          else ; subject_name += b.name + " " + "and" + " "
  2838.          end
  2839.          end
  2840.       else
  2841.          subject_name += $game_party.name
  2842.       end
  2843.       add_text(subject_name + item.message1)
  2844.       unless item.message2.empty? ; wait ; add_text(item.message2) ; end
  2845.   end
  2846.  
  2847. end
  2848.  
  2849. #==============================================================================
  2850. # ■ Game_Battler
  2851. #==============================================================================
  2852. class Game_BattlerBase  
  2853.  
  2854.   #--------------------------------------------------------------------------
  2855.   # ● Pay Skill Cost
  2856.   #--------------------------------------------------------------------------   
  2857.   alias mog_cskill_pay_skill_cost pay_skill_cost
  2858.   def pay_skill_cost(skill)
  2859.       if self.is_a?(Game_Actor) and BattleManager.cskill_usable?(skill.id,self.id)
  2860.            BattleManager.pay_cskill_cost(skill)
  2861.          return
  2862.       end
  2863.       mog_cskill_pay_skill_cost(skill)
  2864.   end
  2865.  
  2866. end
  2867.  
  2868. #==============================================================================
  2869. # ■ BattleManager
  2870. #==============================================================================
  2871. module BattleManager
  2872.   include MOG_COOPERATION_SKILLS
  2873.  
  2874.   #--------------------------------------------------------------------------
  2875.   # ● Cooperation Skill Enable?
  2876.   #--------------------------------------------------------------------------
  2877.   def self.cskill_enable?(skill_id)
  2878.       return false if actor == nil
  2879.       return false if !actor_included_in_cskill?(actor.id,skill_id)
  2880.       return false if !ckill_members_usable?(skill_id)
  2881.       return false if !cskill_all_members_available?(skill_id)
  2882.       return true
  2883.   end
  2884.  
  2885.   #--------------------------------------------------------------------------
  2886.   # ● Cskill Usable?
  2887.   #--------------------------------------------------------------------------
  2888.   def self.cskill_usable?(skill_id,actor_id)
  2889.       return false if !is_cskill?(skill_id)
  2890.       return false if !actor_included_in_cskill?(actor_id,skill_id)
  2891.       return false if !cskill_members_alive?(skill_id)
  2892.       return true
  2893.   end  
  2894.  
  2895.   #--------------------------------------------------------------------------
  2896.   # ● Pay Cskill Cost
  2897.   #--------------------------------------------------------------------------
  2898.   def self.pay_cskill_cost(skill)
  2899.       cskill_members(skill.id).each do |battler|
  2900.          battler.face_animation = [60 ,2,0] if $imported[:mog_battle_hud_ex]
  2901.          $game_temp.remove_order(battler)
  2902.          battler.mp -= battler.skill_mp_cost(skill)
  2903.          battler.tp -= battler.skill_tp_cost(skill)
  2904.       end
  2905.   end   
  2906.  
  2907.   #--------------------------------------------------------------------------
  2908.   # ● Cskill Members Usable?
  2909.   #--------------------------------------------------------------------------
  2910.   def self.ckill_members_usable?(skill_id)
  2911.       skill = $data_skills[skill_id] rescue nil
  2912.       return false if skill == nil   
  2913.       cskill_members(skill_id).each do |battler|
  2914.            return false if !battler.atb_max?
  2915.            return false if battler == subject
  2916.            return false if battler.restriction != 0
  2917.            return false if !battler.skill_cost_payable?(skill)
  2918.            return false if !battler.usable?(skill)
  2919.       end
  2920.       return true
  2921.   end
  2922.  
  2923.   #--------------------------------------------------------------------------
  2924.   # ● Cskill Actor?
  2925.   #--------------------------------------------------------------------------
  2926.   def self.ckill_actor?(self_actor)
  2927.       item = self_actor.current_action.item rescue nil
  2928.       return false if item == nil
  2929.       include = false
  2930.       cskill_members(item.id).each do |battler|
  2931.       include = true if self_actor == battler
  2932.       end  
  2933.       return true if include
  2934.       return false
  2935.   end  
  2936.  
  2937.   #--------------------------------------------------------------------------
  2938.   # ● Cskill All Members Available?
  2939.   #--------------------------------------------------------------------------
  2940.   def self.cskill_all_members_available?(skill_id)
  2941.       return false if COOPERATION_SKILLS[skill_id].size != cskill_members(skill_id).size
  2942.       return true
  2943.   end  
  2944.  
  2945.   #--------------------------------------------------------------------------
  2946.   # ● Cooperation Members
  2947.   #--------------------------------------------------------------------------
  2948.   def self.cskill_members(skill_id)
  2949.       return [] if COOPERATION_SKILLS[skill_id].nil?
  2950.       members = []
  2951.       $game_party.battle_members.each do |battler|
  2952.       members.push(battler) if COOPERATION_SKILLS[skill_id].include?(battler.id)
  2953.       end
  2954.       return members
  2955.   end
  2956.  
  2957.   #--------------------------------------------------------------------------
  2958.   # ● Cskill Members Skill Cost?
  2959.   #--------------------------------------------------------------------------
  2960.   def self.cskill_members_skill_cost?(skill_id)
  2961.       skill = $data_skills[skill_id] rescue nil
  2962.       return false if skill == nil
  2963.       cskill_members(skill_id).each do |battler|
  2964.       return false if !battler.skill_conditions_met?(skill)
  2965.       end
  2966.       return true
  2967.   end  
  2968.  
  2969.   #--------------------------------------------------------------------------
  2970.   # ● Cskill Members Usable?
  2971.   #--------------------------------------------------------------------------
  2972.   def self.cskill_members_alive?(skill_id)
  2973.       skill = $data_skills[skill_id] rescue nil
  2974.       return false if skill == nil   
  2975.       alive = true
  2976.       cskill_members(skill_id).each do |battler|
  2977.           alive = false if battler.dead?
  2978.           alive = false if battler.restriction != 0
  2979.           alive = false if !battler.skill_cost_payable?(skill)
  2980.       end
  2981.       if !alive
  2982.          force_clear_cskill(skill_id)
  2983.          return false
  2984.       end
  2985.       return true
  2986.   end
  2987.  
  2988.   #--------------------------------------------------------------------------
  2989.   # ● Force Clear Cskill
  2990.   #--------------------------------------------------------------------------
  2991.   def self.force_clear_cskill(skill_id)
  2992.       cskill_members(skill_id).each do |battler| battler.turn_clear
  2993.       battler.atb_cast.clear
  2994.       battler.bact_sprite_need_refresh = true if $imported[:mog_sprite_actor]
  2995.       end
  2996.   end
  2997.  
  2998.   #--------------------------------------------------------------------------
  2999.   # ● Execute Cast Action Members
  3000.   #--------------------------------------------------------------------------
  3001.   def self.execute_cast_action_members(skill_id)
  3002.       cskill_members(skill_id).each do |battler|
  3003.          battler.next_turn = true
  3004.          battler.atb = battler.atb_max
  3005.          battler.atb_cast.clear
  3006.       end
  3007.   end
  3008.  
  3009.   #--------------------------------------------------------------------------
  3010.   # ● Set Members CP Skills
  3011.   #--------------------------------------------------------------------------
  3012.   def self.set_members_cp_skill(skill_id)
  3013.       skill = $data_skills[skill_id] rescue nil
  3014.       return false if skill == nil   
  3015.       cskill_members(skill_id).each do |battler|
  3016.            battler.atb = 0
  3017.            battler.actions = @command_actor.actions if @command_actor.actions != nil
  3018.            $game_temp.remove_order(battler)
  3019.            if skill.speed.abs == 0
  3020.               battler.atb_cast = [skill,50,50]
  3021.            else
  3022.               battler.atb_cast = [skill,skill.speed.abs,0]#
  3023.            end
  3024.            battler.animation_id = MOG_COOPERATION_SKILLS::COOPERATION_SKILL_ANIMATION
  3025.       end
  3026.   end
  3027.  
  3028.   #--------------------------------------------------------------------------
  3029.   # ● Clear Members Cp Skill
  3030.   #--------------------------------------------------------------------------
  3031.   def self.clear_members_ckill(subject)
  3032.       return if subject.is_a?(Game_Enemy)
  3033.       return if subject == nil
  3034.       skill = subject.current_action.item rescue nil
  3035.       return if skill == nil
  3036.       return if !is_cskill?(skill.id)
  3037.       return if !actor_included_in_cskill?(subject.id,skill.id)
  3038.       cskill_members(skill.id).each do |battler| battler.turn_clear ; end
  3039.   end
  3040.  
  3041.   #--------------------------------------------------------------------------
  3042.   # ● Actor Included in Cooperation Skill?
  3043.   #--------------------------------------------------------------------------
  3044.   def self.actor_included_in_cskill?(actor_id,skill_id)
  3045.       return false if !SceneManager.scene_is?(Scene_Battle)
  3046.       return false if !is_cskill?(skill_id)
  3047.       return false if !COOPERATION_SKILLS[skill_id].include?(actor_id)
  3048.       return true
  3049.   end
  3050.  
  3051.   #--------------------------------------------------------------------------
  3052.   # ● Is Cooperation Skill?
  3053.   #--------------------------------------------------------------------------
  3054.   def self.is_cskill?(skill_id)
  3055.       return false if !SceneManager.scene_is?(Scene_Battle)
  3056.       return false if COOPERATION_SKILLS[skill_id].nil?
  3057.       return true
  3058.   end
  3059.  
  3060. end
  3061.  
  3062. #==============================================================================
  3063. # ■ BattleManager
  3064. #==============================================================================
  3065. class << BattleManager
  3066.  
  3067.   #--------------------------------------------------------------------------
  3068.   # ● Set Cast Action
  3069.   #--------------------------------------------------------------------------
  3070.   alias mog_cskill_command_end_actor command_end_actor
  3071.   def command_end_actor
  3072.       prepare_ckill_members
  3073.       mog_cskill_command_end_actor      
  3074.   end
  3075.  
  3076.   #--------------------------------------------------------------------------
  3077.   # ● Prepare Cskill Members
  3078.   #--------------------------------------------------------------------------
  3079.   def prepare_ckill_members
  3080.       item = @command_actor.current_action.item rescue nil  
  3081.       return if item == nil
  3082.       if is_cskill?(item.id) and ckill_members_usable?(item.id)
  3083.           set_members_cp_skill(item.id)
  3084.           @command_actor = nil
  3085.       end  
  3086.   end
  3087.  
  3088.   #--------------------------------------------------------------------------
  3089.   # ● Clear Cskills Members
  3090.   #--------------------------------------------------------------------------
  3091.   def clear_cskill_members(subject)
  3092.       item = subject.current_action.item rescue nil  
  3093.       return if item == nil
  3094.       clear_members_ckill(item.id) if is_cskill?(item.id)
  3095.   end
  3096.  
  3097. end
  3098.  
  3099. #==============================================================================
  3100. # ■ Window SkillList
  3101. #==============================================================================
  3102. class Window_SkillList < Window_Selectable
  3103.  
  3104.   #--------------------------------------------------------------------------
  3105.   # ● Display Skill in Active State?
  3106.   #--------------------------------------------------------------------------
  3107.   alias mog_atb_skill_list_enable? enable?
  3108.   def enable?(item)
  3109.       if SceneManager.scene_is?(Scene_Battle) and !item.nil?
  3110.          return false if BattleManager.is_cskill?(item.id) and !BattleManager.cskill_enable?(item.id)
  3111.       end
  3112.       mog_atb_skill_list_enable?(item)
  3113.   end   
  3114.  
  3115. end
  3116.  
  3117. #==============================================================================
  3118. # ■ Game Battler
  3119. #==============================================================================
  3120. class Game_Battler < Game_BattlerBase
  3121.  
  3122.   #--------------------------------------------------------------------------
  3123.   # ● Calculate Damage
  3124.   #--------------------------------------------------------------------------
  3125.   alias mog_atb_make_make_damage_value make_damage_value
  3126.   def make_damage_value(user, item)
  3127.       mog_atb_make_make_damage_value(user, item)
  3128.       coop_make_damage_value(user, item) if coop_make_damage_value?(user, item)
  3129.   end
  3130.  
  3131.   #--------------------------------------------------------------------------
  3132.   # ● Calculate Damage
  3133.   #--------------------------------------------------------------------------
  3134.   def coop_make_damage_value?(user, item)
  3135.       return false if item == nil
  3136.       return false if user.is_a?(Game_Enemy)
  3137.       return false if item.is_a?(RPG::Item)
  3138.       return false if !BattleManager.is_cskill?(item.id)
  3139.       return false if BattleManager.cskill_members(item.id).size < 1
  3140.       return true
  3141.   end
  3142.  
  3143.   #--------------------------------------------------------------------------
  3144.   # ● Coop Make Damage Value
  3145.   #--------------------------------------------------------------------------
  3146.   def coop_make_damage_value(user, item)
  3147.       for actor in BattleManager.cskill_members(item.id)
  3148.           next if actor == user
  3149.           value = item.damage.eval(actor, self, $game_variables)
  3150.           value *= item_element_rate(actor, item)
  3151.           value *= pdr if item.physical?
  3152.           value *= mdr if item.magical?
  3153.           value *= rec if item.damage.recover?
  3154.           value = apply_critical(value) if @result.critical
  3155.           value = apply_variance(value, item.damage.variance)
  3156.           value = apply_guard(value)
  3157.           @result.make_damage_coop(value.to_i, item)
  3158.       end
  3159.       @result.make_damage_coop_after(item)
  3160.   end
  3161.  
  3162. end
  3163.  
  3164. #==============================================================================
  3165. # ■ Game ActionResult
  3166. #==============================================================================
  3167. class Game_ActionResult
  3168.  
  3169.   #--------------------------------------------------------------------------
  3170.   # ● Create Damage
  3171.   #--------------------------------------------------------------------------
  3172.   def make_damage_coop(value, item)
  3173.       @hp_damage += value if item.damage.to_hp?
  3174.       @mp_damage += value if item.damage.to_mp?
  3175.   end   
  3176.  
  3177.   #--------------------------------------------------------------------------
  3178.   # ● Make Damage Coop After
  3179.   #--------------------------------------------------------------------------
  3180.   def make_damage_coop_after(item)
  3181.       @hp_damage /= BattleManager.cskill_members(item.id).size if item.damage.to_hp?
  3182.       @mp_damage /= BattleManager.cskill_members(item.id).size if item.damage.to_mp?   
  3183.       @critical = false if @hp_damage == 0
  3184.       @mp_damage = [@battler.mp, @mp_damage].min
  3185.       @hp_drain = @hp_damage if item.damage.drain?
  3186.       @mp_drain = @mp_damage if item.damage.drain?
  3187.       @hp_drain = [@battler.hp, @hp_drain].min
  3188.       @success = true if item.damage.to_hp? || @mp_damage != 0
  3189.   end
  3190.  
  3191. end
  3192.  
  3193. #==============================================================================
  3194. # ■ Game_Battler
  3195. #==============================================================================
  3196. class Game_Battler < Game_BattlerBase
  3197.  
  3198.   #--------------------------------------------------------------------------
  3199.   # ● Execute Cast Action
  3200.   #--------------------------------------------------------------------------   
  3201.   alias mog_cskill_execute_cast_action execute_cast_action
  3202.   def execute_cast_action
  3203.       mog_cskill_execute_cast_action
  3204.       prepare_cast_action_members
  3205.   end
  3206.  
  3207.   #--------------------------------------------------------------------------
  3208.   # ● Prepare Cast Acton Members
  3209.   #--------------------------------------------------------------------------   
  3210.   def prepare_cast_action_members
  3211.       return if self.is_a?(Game_Enemy)
  3212.       item = self.current_action.item rescue nil  
  3213.       return if item == nil   
  3214.       BattleManager.execute_cast_action_members(item.id) if BattleManager.cskill_usable?(item.id,self.id)
  3215.   end
  3216.  
  3217.   #--------------------------------------------------------------------------
  3218.   # ● ATB After Damage
  3219.   #--------------------------------------------------------------------------  
  3220.   alias mog_cpskill_atb_after_damage atb_after_damage
  3221.   def atb_after_damage(pre_item = nil)
  3222.       mog_cpskill_atb_after_damage(pre_item)
  3223.       force_clear_cpkill(pre_item) if pre_item != nil and self.is_a?(Game_Actor)
  3224.   end  
  3225.  
  3226.   #--------------------------------------------------------------------------
  3227.   # ● Force Clear CP skill
  3228.   #--------------------------------------------------------------------------   
  3229.   def force_clear_cpkill(pre_item = nil)
  3230.       $game_temp.refresh_item_window = true if @result.mp_damage != 0
  3231.       BattleManager.cskill_usable?(pre_item.id,self.id) if pre_item != nil      
  3232.   end
  3233.  
  3234.   #--------------------------------------------------------------------------
  3235.   # ● Need Refresh Item Window?
  3236.   #--------------------------------------------------------------------------   
  3237.   alias mog_cskills_need_refresh_item_window? need_refresh_item_window?
  3238.   def need_refresh_item_window?
  3239.       return true
  3240.       mog_cskills_need_refresh_item_window?
  3241.   end
  3242.  
  3243.   #--------------------------------------------------------------------------
  3244.   # ● Execute Damage
  3245.   #--------------------------------------------------------------------------   
  3246.   alias mog_atb_coop_execute_damage execute_damage
  3247.   def execute_damage(user)
  3248.       mog_atb_coop_execute_damage(user)
  3249.       item = user.current_action.item rescue nil
  3250.       execute_damage_coop(user,item) if user.coop_make_damage_value?(user, item)
  3251.   end
  3252.  
  3253.   #--------------------------------------------------------------------------
  3254.   # ● Execute Damage Coop
  3255.   #--------------------------------------------------------------------------   
  3256.   def execute_damage_coop(user,item)
  3257.       for actor in BattleManager.cskill_members(item.id)
  3258.           next if actor == user
  3259.           actor.hp += @result.hp_drain
  3260.           actor.mp += @result.mp_drain
  3261.           if $imported[:mog_damage_popup]
  3262.              actor.damage.push([-@result.hp_drain,"HP",@result.critical]) if @result.hp_drain != 0
  3263.              actor.damage.push([-@result.mp_drain,"MP",@result.critical]) if @result.mp_drain != 0
  3264.           end   
  3265.       end   
  3266.   end
  3267.  
  3268. end
  3269.  
  3270. #==============================================================================
  3271. # ■ Scene Battle
  3272. #==============================================================================
  3273. class Scene_Battle < Scene_Base
  3274.  
  3275.   #--------------------------------------------------------------------------
  3276.   # ● Process Before Execute Action
  3277.   #--------------------------------------------------------------------------  
  3278.   alias mog_cskill_process_before_execute_action  process_before_execute_action
  3279.   def process_before_execute_action
  3280.       mog_cskill_process_before_execute_action
  3281.       before_execute_cooperation_skill if can_execute_cooperation_skill?
  3282.   end
  3283.  
  3284.   #--------------------------------------------------------------------------
  3285.   # ● Process Before Remove Action
  3286.   #--------------------------------------------------------------------------  
  3287.   alias mog_cskill_process_before_remove_action process_before_remove_action
  3288.   def process_before_remove_action
  3289.       mog_cskill_process_before_remove_action
  3290.       BattleManager.clear_members_ckill(@subject)
  3291.   end
  3292.  
  3293.   #--------------------------------------------------------------------------
  3294.   # ● Can Execute Cooperation Skill?
  3295.   #--------------------------------------------------------------------------  
  3296.   def can_execute_cooperation_skill?
  3297.       return false if !@subject.is_a?(Game_Actor)
  3298.       item = @subject.current_action.item rescue nil
  3299.       return false if item == nil
  3300.       return false if !BattleManager.cskill_usable?(item.id,@subject.id)
  3301.       return true
  3302.   end
  3303.  
  3304.   #--------------------------------------------------------------------------
  3305.   # ● Current CP Members
  3306.   #--------------------------------------------------------------------------
  3307.   def current_cp_members
  3308.       return [] if subject_action == nil
  3309.       return BattleManager.cskill_members(subject_action.id)
  3310.   end   
  3311.  
  3312.   #--------------------------------------------------------------------------
  3313.   # ● Before Execute Coomperation Skill. (add-ons)
  3314.   #--------------------------------------------------------------------------  
  3315.   def before_execute_cooperation_skill
  3316.   end
  3317.  
  3318. end

作者: 百里_飞柳    时间: 前天 23:36
这也是个神奇的战斗,怎么直接一刀切把全部选择框的更新都ban了,然后在战斗中又直接忘记了事件里的选择框
  1. class Window_Selectable < Window_Base
  2.   #--------------------------------------------------------------------------
  3.   # ● Process Cursor Move
  4.   #--------------------------------------------------------------------------
  5.   def process_cursor_move
  6.     if SceneManager.scene_is?(Scene_Battle)
  7.       # 如果事件在执行中,则不跳过出现的选择框的光标移动
  8.       if $game_troop.interpreter.running?
  9.       else
  10.         return if skip_command?
  11.       end
  12.     end
  13.     mog_atb_wactor_process_cursor_move
  14.   end
  15.   #--------------------------------------------------------------------------
  16.   # ● Process Handling
  17.   #--------------------------------------------------------------------------
  18.   def process_handling  
  19.     if SceneManager.scene_is?(Scene_Battle)
  20.       # 如果事件在执行中,则不跳过出现的选择框的确定or取消
  21.       if $game_troop.interpreter.running?
  22.       else
  23.         return if skip_command?
  24.       end
  25.     end
  26.     mog_atb_wactor_process_handling
  27.   end   
  28. end
  29. class Scene_Battle
  30.   #--------------------------------------------------------------------------
  31.   # ● Execute Event Phase
  32.   #--------------------------------------------------------------------------            
  33.   alias mog_atb_battle_execute_event_phase execute_event_phase
  34.   def execute_event_phase
  35.     # 如果角色未在行动,则在事件执行结束后,不打开角色指令窗口
  36.     a = BattleManager.actor
  37.     @actor_command_window.visible = false if a == nil
  38.     mog_atb_battle_execute_event_phase   
  39.   end   
  40. end
复制代码





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