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

Project1

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

[已经过期] MOG - ATB System (v 6.1)删除合击技部分

[复制链接]

Lv1.梦旅人

梦石
0
星屑
185
在线时间
373 小时
注册时间
2013-10-10
帖子
83
跳转到指定楼层
1
发表于 2016-5-8 14:07:51 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
因为MOG - ATB System搭配横版SideView,

在魔法咏唱时,待机动画会强制使用ATB指定的合击技动画,

所以想删掉合击技的功能,但保留ATB的功能, 该怎么正确删除合击技的部分?



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

本版积分规则

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

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

GMT+8, 2025-2-20 04:07

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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