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

Project1

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

[有事请教] MOG的蓄力时间调整(加速减速)求助

[复制链接]

Lv1.梦旅人

梦石
0
星屑
181
在线时间
81 小时
注册时间
2024-1-8
帖子
19
跳转到指定楼层
1
发表于 2024-10-23 21:12:53 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
50星屑
本帖最后由 神隐的主犯 于 2024-10-24 20:00 编辑

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


先放mog系统的代码。然后先迅速解释一下所谓蓄力是怎么回事。

如上图,mog的蓄力就是在技能栏目里编辑速度修正【最大1000】。
这个值越大,玩家(敌人)释放这个技能的时候蓄力的时间就会越长。

↑如图中红圈的头像右下角带了一个元素球(技能icon)说明这个角色正在咏唱这个技能。

↑该技能读到顶部,成功释放。


我希望的功能是,处于xx状态下,这个蓄力的速度可以加速或者减速。比如图中这个技能需要9秒蓄力,
那么在获取【急速】buff后蓄力速度变为1.5倍,也就是需要6秒蓄力就可以走满行动条。




然后是附上我和我朋友一起研究的一点成果(不符合预期),我们把1359行左右的。
RUBY 代码复制
  1. #--------------------------------------------------------------------------
  2.   # ● Set Cast Action
  3.   #--------------------------------------------------------------------------   
  4.   def self.set_cast_action(item)
  5.       if item.speed.abs > 10
  6.          @command_actor.atb_cast = [item,item.speed.abs,0]
  7.       else   
  8.          @command_actor.atb_cast = [item,10,10]
  9.       end  
  10.       @command_actor.animation_id = MOG_ATB_SYSTEM::CAST_ANIMATION
  11.       @command_actor.atb = 0 ; @command_actor.next_turn = false
  12.       @command_actor = nil
  13.   end


改成了
RUBY 代码复制
  1. #--------------------------------------------------------------------------   
  2.   def self.set_cast_action(item)
  3.     value = item.speed.abs
  4.     value *= 1.5 if @command_actor.state?(38)
  5.     value *= 0.5 if @command_actor.state?(39)
  6.       if value > 10
  7.          @command_actor.atb_cast = [item,value,0]
  8.       else   
  9.          @command_actor.atb_cast = [item,10,10]
  10.       end  
  11.       @command_actor.animation_id = MOG_ATB_SYSTEM::CAST_ANIMATION
  12.       @command_actor.atb = 0 ; @command_actor.next_turn = false
  13.       @command_actor = nil
  14.   end


结果我们的设计的效果是改变技能蓄力的初始坐标。(如图)

这个角色的起点窜到行动条之外了。
而我不希望更变读条时的起点。也就是

(只希望在xx状态下改变读条的速度)

求助。

最后附带一个mog包方便各路大佬测试{因为太大放不下所以选择网盘,对不起}
通过网盘分享的文件:汉化Ayesha_3_9.zip
链接: https://pan.baidu.com/s/1ITGy-Ixi0CCzAuPVdstF3A?pwd=xd4c 提取码: xd4c
--来自百度网盘超级会员v5的分享

为了防止失效,解压密码123456

Lv1.梦旅人

梦石
0
星屑
181
在线时间
81 小时
注册时间
2024-1-8
帖子
19
2
 楼主| 发表于 2024-10-24 17:01:24 | 只看该作者
本帖最后由 神隐的主犯 于 2024-10-24 19:58 编辑

等一下没搞定!!!!!!!
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
181
在线时间
81 小时
注册时间
2024-1-8
帖子
19
3
 楼主| 发表于 2024-10-24 20:02:36 | 只看该作者
本帖最后由 神隐的主犯 于 2024-10-24 20:03 编辑

我新的尝试是。直接对速度修正下手【1359行左右代码】
  1. def self.set_cast_action(item)
  2.     item.speed *= 1.5 if @command_actor.state?(38)#结舌
  3.     item.speed *= 0.5 if @command_actor.state?(39)#急速
  4.     value = item.speed.abs
  5.   #  value *= 1.5 if @command_actor.state?(38)
  6.   #  value *= 0.5 if @command_actor.state?(39)
  7.       if value > 10
  8.          @command_actor.atb_cast = [item,value,0]
  9.       else   
  10.          @command_actor.atb_cast = [item,10,10]
  11.       end  
  12.       @command_actor.animation_id = MOG_ATB_SYSTEM::CAST_ANIMATION
  13.       @command_actor.atb = 0 ; @command_actor.next_turn = false
  14.       @command_actor = nil
  15.   end      
复制代码

但是这样发现了一个大问题,队友a拥有急速状态时,队友b也会受到影响(即使b没有状态),然后速度修正会无限重复生效*2*2*2…………
比如原速度修正40,一次急速后变成20,急速消失后再次获得急速行动,就会变成10的修正(且无法返回初值),这该怎麽办啊QAQ

点评

所以会出现你这样的情况,应对方法是先用clone进行复制本体来尝试解决,因为这里只需要读取蓄力时间等信息,所以应该没什么问题  发表于 2024-10-24 21:50
你不能直接对item下手,因为它指向的是数据库的技能,默认脚本所有角色学的技能都是数据库里唯一的那个id,改了会影响所有角色的该id的技能  发表于 2024-10-24 21:46
该方法第一行新写一句item = item.clone然后测试一下看一下  发表于 2024-10-24 21:35
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-11-21 19:54

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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