Project1

标题: mog系统强制更改行动条AT数值。(已经完成两条) [打印本页]

作者: 神隐的主犯    时间: 2024-8-10 16:31
标题: mog系统强制更改行动条AT数值。(已经完成两条)
本帖最后由 神隐的主犯 于 2024-8-10 20:34 编辑

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 = 10000
  118.   #--------------------------------------------------------------------------
  119.   # 定义"回合"的方式,多少时间过去算是一个回合?
  120.   #
  121.   # 0 - 一个回合的时间是个固定值.
  122.   # 1 - 一个回合的时间为全部参战者数量的乘积
  123.   # 2 - 一个回合的时间为全部参战者敏捷值的平均值
  124.   #
  125.   #--------------------------------------------------------------------------
  126.   TURN_DURATION_TYPE = 0
  127.   #--------------------------------------------------------------------------
  128.   # 当上一项设定为"0"时的数值
  129.   #-------------------------------------------------------------------------
  130.   TURN_DURATION = 150
  131.   #--------------------------------------------------------------------------
  132.   # 技能蓄力默认施放动画
  133.   #--------------------------------------------------------------------------
  134.   CAST_ANIMATION = 999
  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.   # ●
  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.   # ● 行动蓄力时间(急速和结舌等)
  1358.   #--------------------------------------------------------------------------   
  1359.   def self.set_cast_action(item)
  1360.     value = item.speed.abs
  1361.     value *= 1.5 if @command_actor.state?(38)
  1362.     value *= 0.5 if @command_actor.state?(39)
  1363.       if value > 10
  1364.          @command_actor.atb_cast = [item,value,0]
  1365.       else   
  1366.          @command_actor.atb_cast = [item,10,10]
  1367.       end  
  1368.       @command_actor.animation_id = MOG_ATB_SYSTEM::CAST_ANIMATION
  1369.       @command_actor.atb = 0 ; @command_actor.next_turn = false
  1370.       @command_actor = nil
  1371.   end      
  1372.  
  1373.   #--------------------------------------------------------------------------
  1374.   # ● End Turn
  1375.   #--------------------------------------------------------------------------
  1376.   def self.in_turn?
  1377.       return $game_temp.atb_in_turn
  1378.   end  
  1379.  
  1380.   #--------------------------------------------------------------------------
  1381.   # ● Set Refresh Status
  1382.   #--------------------------------------------------------------------------
  1383.   def self.set_refresh_status(value)
  1384.       @refresh_status = value
  1385.   end
  1386.  
  1387.   #--------------------------------------------------------------------------
  1388.   # ● Refresh Status
  1389.   #--------------------------------------------------------------------------
  1390.   def self.refresh_status?
  1391.       @refresh_status
  1392.   end
  1393.  
  1394.   #--------------------------------------------------------------------------
  1395.   # ● Actor
  1396.   #--------------------------------------------------------------------------
  1397.   def self.actor
  1398.       @command_actor
  1399.   end
  1400.  
  1401.   #--------------------------------------------------------------------------
  1402.   # ● Cancel Actor Command
  1403.   #--------------------------------------------------------------------------
  1404.   def self.cancel_actor_command(minus = false)
  1405.       @command_selection = false
  1406.       return if @command_actor == nil
  1407.       @command_actor.atb = (@command_actor.atb * 80 / 100).truncate if minus
  1408.       @command_actor = nil
  1409.       $game_temp.actor_command_index = 0
  1410.   end
  1411.  
  1412.   #--------------------------------------------------------------------------
  1413.   # ● Battler
  1414.   #--------------------------------------------------------------------------
  1415.   def self.set_battler_in_turn(battler)
  1416.       @battler_in_turn = battler
  1417.   end
  1418.  
  1419.   #--------------------------------------------------------------------------
  1420.   # ● Battler in turn?
  1421.   #--------------------------------------------------------------------------
  1422.   def self.battler_in_turn?(battler)
  1423.       return true if @battler_in_turn == battler
  1424.       return false
  1425.   end
  1426.  
  1427.   #--------------------------------------------------------------------------
  1428.   # ● Turn Start ABS
  1429.   #--------------------------------------------------------------------------
  1430.   def self.turn_start_abs
  1431.       @phase = :turn        
  1432.   end
  1433.  
  1434.   #--------------------------------------------------------------------------
  1435.   # ● Set Subject
  1436.   #--------------------------------------------------------------------------
  1437.   def self.set_subject(subject)
  1438.       @subject = subject
  1439.   end
  1440.  
  1441.   #--------------------------------------------------------------------------
  1442.   # ● Subject
  1443.   #--------------------------------------------------------------------------
  1444.   def self.subject
  1445.       @subject
  1446.   end  
  1447.  
  1448. end  
  1449.  
  1450. #==============================================================================
  1451. # ■ BattleManager
  1452. #==============================================================================
  1453. class << BattleManager
  1454.  
  1455.   #--------------------------------------------------------------------------
  1456.   # ● Init Members
  1457.   #--------------------------------------------------------------------------
  1458.   alias mog_atb_init_members init_members
  1459.   def init_members
  1460.       mog_atb_init_members
  1461.       set_init_atb_data
  1462.   end
  1463.  
  1464.   #--------------------------------------------------------------------------
  1465.   # ● Set Init ATB Data
  1466.   #--------------------------------------------------------------------------
  1467.   def set_init_atb_data
  1468.       @current_battler = nil ; @actor_in_turn = nil ; @command_selection = nil
  1469.       @atb_target_index = nil ; @command_actor = nil ; $game_temp.atb_user = nil
  1470.       $game_temp.turn_duration_clear = false ; $game_temp.battle_end = false
  1471.       $game_temp.atb_in_turn = true ; $game_temp.atb_wait = false
  1472.       @turn_duration = set_turn_duration ; @refresh_status = false
  1473.       $game_temp.atb_frame_skip = 30 ; @battler_in_turn = nil
  1474.       $game_temp.refresh_target_windows = [false,false]
  1475.       $game_temp.refresh_actor_command = false ; @subject = nil
  1476.       $game_temp.refresh_battle_atb = false ; $game_temp.atb_break_duration = 0
  1477.       $game_temp.end_phase_duration = [false,0] ; $game_temp.battle_end2 = false     
  1478.       $game_temp.actor_command_index = 0 ; $game_temp.refresh_item_window = false
  1479.       $game_system.atb_turn_duration[0] = 0 ; $game_temp.atb_stop = [false,false]
  1480.       $game_temp.atb_actor_order = [] ; $game_temp.break_command = false
  1481.       $game_temp.actor_process_event = nil ; $game_temp.hwindow_atb = false
  1482.   end
  1483.  
  1484.   #--------------------------------------------------------------------------
  1485.   # ● Determine Win/Loss Results
  1486.   #--------------------------------------------------------------------------
  1487.   alias mog_atb_judge_win_loss judge_win_loss
  1488.   def judge_win_loss
  1489.       return if $game_temp.end_phase_duration[0]
  1490.       return if $game_troop.interpreter.running?
  1491.       mog_atb_judge_win_loss
  1492.   end
  1493.  
  1494.   #--------------------------------------------------------------------------
  1495.   # ● Clear Base Parameter
  1496.   #--------------------------------------------------------------------------   
  1497.   def clear_base_parameter
  1498.       battlers.each do |battler| battler.atb_initial end
  1499.   end
  1500.  
  1501.   #--------------------------------------------------------------------------
  1502.   # ● Process Abort
  1503.   #--------------------------------------------------------------------------   
  1504.   alias mog_atb_process_abort process_abort  
  1505.   def process_abort  
  1506.       $game_temp.atb_wait = true ; $game_temp.battle_end = true
  1507.       clear_base_parameter
  1508.       mog_atb_process_abort      
  1509.   end
  1510.  
  1511.   #--------------------------------------------------------------------------
  1512.   # ● Process Defeat
  1513.   #--------------------------------------------------------------------------   
  1514.   alias mog_atb_process_defeat process_defeat
  1515.   def process_defeat
  1516.       clear_base_parameter
  1517.       $game_temp.atb_wait = true ; $game_temp.battle_end = true   
  1518.       mog_atb_process_defeat
  1519.   end  
  1520.  
  1521.   #--------------------------------------------------------------------------
  1522.   # ● Process Victory
  1523.   #--------------------------------------------------------------------------   
  1524.   alias mog_atb_process_victory process_victory
  1525.   def process_victory
  1526.       $game_temp.atb_wait = true ; $game_temp.battle_end = true
  1527.       mog_atb_process_victory
  1528.   end
  1529.  
  1530.   #--------------------------------------------------------------------------
  1531.   # ● Prior Command
  1532.   #--------------------------------------------------------------------------   
  1533.   alias mog_atb_prior_command prior_command
  1534.   def prior_command
  1535.       if $sv_camera != nil
  1536.          actor = $game_party.battle_members[@actor_index] rescue nil
  1537.          return if actor == nil
  1538.       end
  1539.       mog_atb_prior_command
  1540.   end   
  1541.  
  1542. end
  1543.  
  1544. #==============================================================================
  1545. # ■ Scene Battle
  1546. #==============================================================================
  1547. class Scene_Battle < Scene_Base
  1548.   include MOG_ATB_SYSTEM
  1549.  
  1550.   #--------------------------------------------------------------------------
  1551.   # ● Battle Start
  1552.   #--------------------------------------------------------------------------
  1553.   def battle_start
  1554.       BattleManager.battle_start
  1555.       process_event
  1556.       set_turn_duration
  1557.   end   
  1558.  
  1559.   #--------------------------------------------------------------------------
  1560.   # ● Set Turn Duration
  1561.   #--------------------------------------------------------------------------
  1562.   def set_turn_duration
  1563.       $game_system.atb_turn_duration = [0,BattleManager.set_turn_duration]
  1564.       @status_window.open if @status_window != nil
  1565.       BattleManager.turn_start_abs
  1566.   end     
  1567.  
  1568.   #--------------------------------------------------------------------------
  1569.   # ● Next Command
  1570.   #--------------------------------------------------------------------------  
  1571.   alias mog_atb_next_command next_command
  1572.   def next_command
  1573.       BattleManager.command_selection_clear if BattleManager.command_selection_clear?
  1574.       mog_atb_next_command
  1575.   end   
  1576.  
  1577.   #--------------------------------------------------------------------------
  1578.   # ● Process Action
  1579.   #--------------------------------------------------------------------------  
  1580.   def process_action
  1581.       process_atb_type
  1582.       return if !process_action_atb?
  1583.       update_turn if update_turn?
  1584.       @subject = BattleManager.update_atb
  1585.       process_actor_command if BattleManager.actor_command?
  1586.       force_refresh_status if BattleManager.refresh_status?
  1587.       process_action_atb if @subject
  1588.   end  
  1589.  
  1590.   #--------------------------------------------------------------------------
  1591.   # ● Update Break Phase
  1592.   #--------------------------------------------------------------------------  
  1593.   def update_break_phase
  1594.       $game_temp.atb_break_duration += 1
  1595.       return if $game_temp.atb_break_duration < 30
  1596.       $game_temp.atb_break_duration = 0
  1597.       process_atb_break if proccess_atb_break?
  1598.   end
  1599.  
  1600.   #--------------------------------------------------------------------------
  1601.   # ● Process ATB Break
  1602.   #--------------------------------------------------------------------------  
  1603.   def process_atb_break      
  1604.       if BattleManager.actor != nil
  1605.          BattleManager.actor.atb -= 1
  1606.          if BattleManager.actor.restriction == 4 or BattleManager.actor.hp == 0 or
  1607.             BattleManager.actor.dead?
  1608.             BattleManager.actor.turn_clear
  1609.          end
  1610.       end
  1611.       hide_base_window
  1612.       BattleManager.command_selection_clear
  1613.   end
  1614.  
  1615.   #--------------------------------------------------------------------------
  1616.   # ● Process Action
  1617.   #--------------------------------------------------------------------------  
  1618.   def proccess_atb_break?
  1619.       return false if $game_troop.interpreter.running?
  1620.       members_atb_max = true
  1621.       members_next_turn = true
  1622.       for battler in $game_party.battle_members
  1623.           members_atb_max = false if !battler.atb_max?
  1624.           members_next_turn = false if !battler.next_turn         
  1625.       end
  1626.       if BattleManager.actor != nil
  1627.          return true if can_break_actor_command?
  1628.        else
  1629.          return true if members_atb_max and !members_next_turn
  1630.       end
  1631.       return false
  1632.   end
  1633.  
  1634.   #--------------------------------------------------------------------------
  1635.   # ● Can Break Actor Command
  1636.   #--------------------------------------------------------------------------  
  1637.   def can_break_actor_command?
  1638.       return true if BattleManager.actor.next_turn
  1639.       return true if BattleManager.actor.restriction > 0
  1640.       return true if BattleManager.actor.dead? or BattleManager.actor.hp == 0
  1641.       return true if !base_window_active?
  1642.       return false
  1643.   end
  1644.  
  1645.   #--------------------------------------------------------------------------
  1646.   # ● Base Window Active
  1647.   #--------------------------------------------------------------------------  
  1648.   def base_window_active?
  1649.       return true if @actor_window.active
  1650.       return true if @enemy_window.active
  1651.       return true if @item_window.active
  1652.       return true if @skill_window.active
  1653.       return true if @party_command_window.active
  1654.       return true if @actor_command_window.active
  1655.       return false
  1656.   end
  1657.  
  1658.   #--------------------------------------------------------------------------
  1659.   # ● Process Action
  1660.   #--------------------------------------------------------------------------  
  1661.   def process_action_atb
  1662.       $game_temp.remove_order(@subject)
  1663.       loop do
  1664.           if @subject == nil
  1665.              turn_end_subject_nil
  1666.              break
  1667.           end   
  1668.           BattleManager.set_battler_in_turn(@subject)
  1669.           BattleManager.set_subject(@subject)
  1670.           @log_window.clear
  1671.           if @subject.atb_escape
  1672.              process_escape
  1673.              break
  1674.           end
  1675.           process_before_execute_action
  1676.           process_execute_action if @subject.current_action
  1677.           process_after_execute_action
  1678.           hide_windows_for_dead
  1679.           if break_process_action_atb?
  1680.              process_action_end
  1681.              turn_end
  1682.              break
  1683.           end  
  1684.       end
  1685.   end
  1686.  
  1687.   #--------------------------------------------------------------------------
  1688.   # ● Break Process Action Atb
  1689.   #--------------------------------------------------------------------------   
  1690.   def break_process_action_atb?
  1691.       return true if !@subject.current_action
  1692.       return true if @subject.restriction == 4
  1693.       return true if @subject.dead? or @subject.hp == 0
  1694.       return false
  1695.   end
  1696.  
  1697.   #--------------------------------------------------------------------------
  1698.   # ● Can Break Process Action?
  1699.   #--------------------------------------------------------------------------  
  1700.   def can_break_process_action?
  1701.       return true if @subject == nil
  1702.       return false
  1703.   end
  1704.  
  1705.   #--------------------------------------------------------------------------
  1706.   # ● Can Break Command?
  1707.   #--------------------------------------------------------------------------   
  1708.   def can_break_command?
  1709.       return false if BattleManager.actor == nil
  1710.       return true if BattleManager.actor.hp == 0
  1711.       return true if BattleManager.actor.dead?
  1712.       return true if BattleManager.actor.restriction != 0
  1713.       return false
  1714.   end
  1715.  
  1716.   #--------------------------------------------------------------------------
  1717.   # ● Can Break Command2
  1718.   #--------------------------------------------------------------------------   
  1719.   def can_break_command2?
  1720.       return false if BattleManager.actor != nil
  1721.       return true if BattleManager.command_selection?
  1722.       return false
  1723.   end  
  1724.  
  1725.   #--------------------------------------------------------------------------
  1726.   # ● Break Command
  1727.   #--------------------------------------------------------------------------   
  1728.   def break_command
  1729.       $game_temp.break_command = false
  1730.       BattleManager.actor.turn_clear if BattleManager.actor != nil
  1731.       hide_base_window
  1732.       BattleManager.command_selection_clear
  1733.   end      
  1734.  
  1735.   #--------------------------------------------------------------------------
  1736.   # ● Turn End Subject Nil
  1737.   #--------------------------------------------------------------------------   
  1738.   def turn_end_subject_nil
  1739.       refresh_status
  1740.       BattleManager.judge_win_loss
  1741.       @subject =  nil
  1742.       BattleManager.set_subject(@subject)
  1743.       @log_window.wait
  1744.       @log_window.clear
  1745.       $game_temp.atb_break_duration = 100
  1746.       execute_event_phase if execute_event_phase_turn?
  1747.   end   
  1748.  
  1749.   #--------------------------------------------------------------------------
  1750.   # ● Process Escape
  1751.   #--------------------------------------------------------------------------  
  1752.   def process_escape
  1753.       if BattleManager.process_escape     
  1754.          process_execute_escape
  1755.       else   
  1756.          start_actor_command_selection if BattleManager.actor
  1757.          @status_window.open
  1758.       end  
  1759.       turn_end   
  1760.   end
  1761.  
  1762.   #--------------------------------------------------------------------------
  1763.   # ● Process Actor Command
  1764.   #--------------------------------------------------------------------------  
  1765.   def process_actor_command
  1766.       start_actor_command_selection
  1767.   end
  1768.  
  1769.   #--------------------------------------------------------------------------
  1770.   # ● Process Before Execute Action
  1771.   #--------------------------------------------------------------------------  
  1772.   def process_before_execute_action   
  1773.   end  
  1774.  
  1775.   #--------------------------------------------------------------------------
  1776.   # ● Process After Execute Action
  1777.   #--------------------------------------------------------------------------  
  1778.   def process_after_execute_action   
  1779.   end   
  1780.  
  1781.   #--------------------------------------------------------------------------
  1782.   # ● Refresh Actor Command
  1783.   #--------------------------------------------------------------------------  
  1784.   def refresh_actor_command?
  1785.       return false if !$game_temp.refresh_actor_command
  1786.       return false if !@actor_command_window.active
  1787.       return false if !BattleManager.actor
  1788.       return true
  1789.   end  
  1790.  
  1791.   #--------------------------------------------------------------------------
  1792.   # ● Update Actor Command
  1793.   #--------------------------------------------------------------------------  
  1794.   def update_actor_command
  1795.       return if !@actor_command_window.active
  1796.       return if !BattleManager.actor
  1797.       if ENABLE_BUTTON_NEXT_ACTOR
  1798.          if Input.trigger?(BUTTON_NEXT_ACTOR_LEFT) ; turn_to_next_actor(-1) rescue nil
  1799.          elsif Input.trigger?(BUTTON_NEXT_ACTOR_RIGHT) ; turn_to_next_actor(1) rescue nil
  1800.          end  
  1801.       end   
  1802.   end  
  1803.  
  1804.   #--------------------------------------------------------------------------
  1805.   # ● Turn To Next Actor
  1806.   #--------------------------------------------------------------------------  
  1807.   def turn_to_next_actor(value)
  1808.       return if BattleManager.actor == nil
  1809.       next_index = BattleManager.actor.index + value
  1810.       next_index = 0 if next_index >= $game_party.battle_members.size
  1811.       battler = $game_party.battle_members[next_index]
  1812.       next_act = false
  1813.       if battler.movable_atb?
  1814.          cancel_actor_command_scene(false) ; BattleManager.prepare_actor_command(battler)
  1815.          process_actor_command if BattleManager.actor_command?
  1816.          next_act = true
  1817.       else           
  1818.         @tnext_index = value   
  1819.          for battler in $game_party.battle_members
  1820.              next_index += @tnext_index
  1821.              if next_index >= $game_party.battle_members.size
  1822.                 next_index = 0 ; @tnext_index = 1
  1823.                 if next_actor_command?(next_index) ; next_act = true ; break ; end
  1824.              elsif next_index < 0
  1825.                 next_index = $game_party.battle_members.size ;  @tnext_index = -1
  1826.                 if next_actor_command?(next_index) ; next_act = true ; break ; end
  1827.              end
  1828.              if next_actor_command?(next_index) ; next_act = true ; break ; end
  1829.          end  
  1830.       end
  1831.      Sound.play_cancel if !next_act
  1832.   end
  1833.  
  1834.   #--------------------------------------------------------------------------
  1835.   # ● Next Actor Command?
  1836.   #--------------------------------------------------------------------------  
  1837.   def next_actor_command?(next_index)
  1838.       for battler in $game_party.battle_members
  1839.           next if next_index == BattleManager.actor.index
  1840.           if next_index == battler.index and battler.movable_atb?
  1841.              cancel_actor_command_scene(false)
  1842.              BattleManager.prepare_actor_command(battler)
  1843.              process_actor_command if BattleManager.actor_command?
  1844.              return true
  1845.           end            
  1846.       end
  1847.       return false
  1848.   end  
  1849.  
  1850.   #--------------------------------------------------------------------------
  1851.   # ● Cancel Actor Command scene
  1852.   #--------------------------------------------------------------------------  
  1853.   def cancel_actor_command_scene(atb_cost = false)
  1854.       @actor_command_window.close ; @actor_command_window.hide_all
  1855.       BattleManager.cancel_actor_command(atb_cost)
  1856.   end
  1857.  
  1858.   #--------------------------------------------------------------------------
  1859.   # ● Update Party Command
  1860.   #--------------------------------------------------------------------------      
  1861.   def update_party_command
  1862.       return if !@party_command_window.active
  1863.       return if !BattleManager.actor
  1864.       if Input.trigger?(:B)
  1865.          Sound.play_cancel
  1866.          @party_command_window.deactivate ; start_actor_command_selection
  1867.       end  
  1868.   end
  1869.  
  1870.   #--------------------------------------------------------------------------
  1871.   # ● Create All Windows
  1872.   #--------------------------------------------------------------------------      
  1873.   alias mog_atb_create_all_windows create_all_windows
  1874.   def create_all_windows
  1875.       mog_atb_create_all_windows
  1876.       @pre_viewport_visible = true
  1877.       @info_xy = [0,(Graphics.width - @status_window.width) / 2, Graphics.width - @status_window.width ]
  1878.   end  
  1879.  
  1880.   #--------------------------------------------------------------------------
  1881.   # ● Update Info Viewport
  1882.   #--------------------------------------------------------------------------      
  1883.   def update_info_viewport
  1884.       if center_viewport?
  1885.          move_info_viewport(@info_xy[1]) ; return
  1886.       end
  1887.       if @party_command_window.active ; move_info_viewport(@info_xy[0])   
  1888.       elsif BattleManager.actor ; move_info_viewport(@info_xy[2])
  1889.       else ; move_info_viewport(@info_xy[1])
  1890.       end  
  1891.   end  
  1892.  
  1893.   #--------------------------------------------------------------------------
  1894.   # ● Update Info Viewport
  1895.   #--------------------------------------------------------------------------      
  1896.   def center_viewport?
  1897.       return true if $game_message.visible
  1898.       return true if BattleManager.actor == nil
  1899.       return true if $game_temp.battle_end
  1900.       return false
  1901.   end
  1902.  
  1903.   #--------------------------------------------------------------------------
  1904.   # ● Process Action ATB
  1905.   #--------------------------------------------------------------------------  
  1906.   def process_action_atb?  
  1907.       return false if $game_troop.interpreter.running?
  1908.       return false if $game_temp.end_phase_duration[1] > 0  
  1909.       return false if $game_temp.atb_wait
  1910.       return false if $game_temp.battle_end
  1911.       return false if $game_temp.battle_end2
  1912.       return false if scene_changing?
  1913.       return false if !$game_temp.sprite_visible
  1914.       return false if $game_temp.atb_stop[1]
  1915.       return false if @combatlog_window.visible if @combatlog_window != nil
  1916.       return true
  1917.   end
  1918.  
  1919.   #--------------------------------------------------------------------------
  1920.   # ● Process ATB Type
  1921.   #--------------------------------------------------------------------------  
  1922.   def process_atb_type
  1923.       $game_temp.atb_frame_skip -= 1 if $game_temp.atb_frame_skip > 0
  1924.       return if $game_temp.battle_end
  1925.       return if $game_temp.end_phase_duration[1] > 0
  1926.       case $game_system.atb_type
  1927.            when 0 ; $game_temp.atb_wait = set_atb_type_wait
  1928.            when 1 ; $game_temp.atb_wait = set_atb_type_semi_wait
  1929.            else ; $game_temp.atb_wait = false
  1930.       end
  1931.   end
  1932.  
  1933.   #--------------------------------------------------------------------------
  1934.   # ● Set Atb Type Wait
  1935.   #--------------------------------------------------------------------------  
  1936.   def set_atb_type_wait
  1937.       return true if @actor_window.active
  1938.       return true if @enemy_window.active
  1939.       return true if @item_window.active
  1940.       return true if @skill_window.active
  1941.       return true if @party_command_window.active
  1942.       return true if @actor_command_window.active
  1943.       return false
  1944.   end
  1945.  
  1946.   #--------------------------------------------------------------------------
  1947.   # ● Set Atb Type Semi Wait
  1948.   #--------------------------------------------------------------------------  
  1949.   def set_atb_type_semi_wait
  1950.       return true if @item_window.active
  1951.       return true if @skill_window.active
  1952.       return false   
  1953.   end
  1954.  
  1955.   #--------------------------------------------------------------------------
  1956.   # ● Process Execute Escape
  1957.   #--------------------------------------------------------------------------  
  1958.   def process_execute_escape
  1959.       $game_temp.battle_end = true
  1960.       hide_base_window
  1961.       $game_temp.atb_user = nil
  1962.       $game_temp.battle_cursor[2] = false if $imported[:mog_battle_cursor]
  1963.       BattleManager.command_selection_clear
  1964.   end
  1965.  
  1966.   #--------------------------------------------------------------------------
  1967.   # ● Battle End?
  1968.   #--------------------------------------------------------------------------  
  1969.   def battle_end?
  1970.       return true if $game_party.members.empty?
  1971.       return true if $game_party.all_dead?
  1972.       return true if $game_troop.all_dead?
  1973.       return true if $game_temp.battle_end
  1974.       return false
  1975.   end
  1976.  
  1977.   #--------------------------------------------------------------------------
  1978.   # ● Command Escape
  1979.   #--------------------------------------------------------------------------  
  1980.   def command_escape
  1981.       BattleManager.actor.atb_escape = true if BattleManager.actor
  1982.       BattleManager.command_end
  1983.       @party_command_window.close
  1984.       hide_base_window
  1985.   end  
  1986.  
  1987.   #--------------------------------------------------------------------------
  1988.   # ● Command Escape2
  1989.   #--------------------------------------------------------------------------  
  1990.   def command_escape2
  1991.      turn_start unless BattleManager.process_escape
  1992.   end
  1993.  
  1994.   #--------------------------------------------------------------------------
  1995.   # ● Execute Action
  1996.   #--------------------------------------------------------------------------  
  1997.   alias mog_atb_execute_action execute_action
  1998.   def execute_action
  1999.       @cp_members = []
  2000.       return if battle_end? or @subject == nil
  2001.       @cp_members = current_cp_members if can_execute_cooperation_skill?            
  2002.       mog_atb_execute_action
  2003.   end
  2004.  
  2005.   #--------------------------------------------------------------------------
  2006.   # ● Use Item
  2007.   #--------------------------------------------------------------------------  
  2008.   alias mog_atb_use_item use_item
  2009.   def use_item
  2010.       return if battle_end? or @subject == nil
  2011.       mog_atb_use_item
  2012.   end
  2013.  
  2014.   #--------------------------------------------------------------------------
  2015.   # ● Show Animation
  2016.   #--------------------------------------------------------------------------  
  2017.   alias mog_atb_event_show_animation show_animation
  2018.   def show_animation(targets, animation_id)
  2019.       execute_event_phase if execute_event_phase_turn?
  2020.       mog_atb_event_show_animation(targets, animation_id)   
  2021.   end
  2022.  
  2023.   #--------------------------------------------------------------------------
  2024.   # ● Force Refresh Status
  2025.   #--------------------------------------------------------------------------  
  2026.   def force_refresh_status
  2027.       BattleManager.set_refresh_status(false)
  2028.       refresh_status
  2029.   end
  2030.  
  2031.   #--------------------------------------------------------------------------
  2032.   # ● Refresh Battle ATB
  2033.   #--------------------------------------------------------------------------  
  2034.   def refresh_battle_atb
  2035.       $game_temp.refresh_battle_atb = false
  2036.       hide_base_window
  2037.       battle_start      
  2038.   end
  2039.  
  2040.   #--------------------------------------------------------------------------
  2041.   # ● Hide Base Window
  2042.   #--------------------------------------------------------------------------  
  2043.   def hide_base_window(target_window = true,actor_window = false)
  2044.       @actor_window.hide
  2045.       @actor_window.active = false
  2046.       @enemy_window.hide
  2047.       @enemy_window.active = false
  2048.       @help_window.hide
  2049.       @party_command_window.deactivate
  2050.       @party_command_window.close
  2051.       @status_window.unselect
  2052.       instance_variables.each do |varname|
  2053.          ivar = instance_variable_get(varname)
  2054.          if ivar.is_a?(Window)
  2055.             next if !need_hide_window?(ivar,actor_window)            
  2056.             ivar.hide_all
  2057.          end   
  2058.       end
  2059.       @pre_viewport_visible = @info_viewport.visible
  2060.       @info_viewport.visible = true ; @status_window.show
  2061.       @status_aid_window.hide_all if @status_aid_window != nil
  2062.   end
  2063.  
  2064.   #--------------------------------------------------------------------------
  2065.   # ● Need Hide Window?
  2066.   #--------------------------------------------------------------------------  
  2067.   def need_hide_window?(ivar,actor_window)
  2068.       return false if ivar.is_a?(Window_Message)
  2069.       return false if ivar.is_a?(Window_BattleActor)
  2070.       return false if ivar.is_a?(Window_BattleEnemy)
  2071.       return false if ivar.is_a?(Window_BattleStatus)
  2072.       return false if ivar.is_a?(Window_PartyCommand)
  2073.       return false if ivar.is_a?(Window_ActorCommand) and actor_window
  2074.       if $imported["YEA-VictoryAftermath"]
  2075.          return false if ivar.is_a?(Window_VictoryTitle)
  2076.          return false if ivar.is_a?(Window_VictoryEXP_Back)
  2077.          return false if ivar.is_a?(Window_VictoryEXP_Front)
  2078.          return false if ivar.is_a?(Window_VictoryLevelUp)
  2079.          return false if ivar.is_a?(Window_VictorySkills)
  2080.          return false if ivar.is_a?(Window_VictorySpoils)
  2081.       end      
  2082.       return true
  2083.   end     
  2084.  
  2085.   #--------------------------------------------------------------------------
  2086.   # ● Record Window Data
  2087.   #--------------------------------------------------------------------------  
  2088.   def record_window_data(target_window = true)
  2089.       return if $game_temp.hwindow_atb
  2090.       $game_temp.hwindow_atb = true
  2091.       @pre_battler = BattleManager.actor
  2092.       @battler_in_turn_temp = @actor_command_window.active
  2093.       instance_variables.each do |varname|
  2094.          ivar = instance_variable_get(varname)
  2095.          ivar.record_data if ivar.is_a?(Window)
  2096.       end      
  2097.       if $imported[:mog_battle_cursor]
  2098.          @battle_cursor_visible = $game_temp.battle_cursor[2]
  2099.          $game_temp.battle_cursor[2] = false
  2100.       end         
  2101.       hide_base_window(target_window)   
  2102.   end
  2103.  
  2104.   #--------------------------------------------------------------------------
  2105.   # ● Fade Base Window
  2106.   #--------------------------------------------------------------------------  
  2107.   def fade_base_window(fade_value)
  2108.       instance_variables.each do |varname|
  2109.          ivar = instance_variable_get(varname)
  2110.          if ivar.is_a?(Window)
  2111.             next if !need_fade_after_battle?(ivar)
  2112.             ivar.opacity -= fade_value
  2113.             ivar.contents_opacity -= fade_value
  2114.          end
  2115.       end
  2116.   end  
  2117.  
  2118.   #--------------------------------------------------------------------------
  2119.   # ● Need Fade After Battle?
  2120.   #--------------------------------------------------------------------------  
  2121.   def need_fade_after_battle?(ivar)
  2122.       return false if ivar.is_a?(Window_Message)
  2123.       if $imported["YEA-VictoryAftermath"]
  2124.          return false if ivar.is_a?(Window_VictoryTitle)
  2125.          return false if ivar.is_a?(Window_VictoryEXP_Back)
  2126.          return false if ivar.is_a?(Window_VictoryEXP_Front)
  2127.          return false if ivar.is_a?(Window_VictoryLevelUp)
  2128.          return false if ivar.is_a?(Window_VictorySkills)
  2129.          return false if ivar.is_a?(Window_VictorySpoils)
  2130.       end
  2131.       return true
  2132.   end   
  2133.  
  2134.   #--------------------------------------------------------------------------
  2135.   # ● Record Window Data
  2136.   #--------------------------------------------------------------------------  
  2137.   def restore_window_data
  2138.       return if battle_end?
  2139.        if @pre_battler and @pre_battler.dead?
  2140.           hide_windows_for_dead
  2141.        else
  2142.           instance_variables.each do |varname|
  2143.              ivar = instance_variable_get(varname)
  2144.              ivar.restore_data if ivar.is_a?(Window)
  2145.           end   
  2146.           @info_viewport.visible = @pre_viewport_visible
  2147.           @actor_command_window.open if @actor_command_window.visible
  2148.           @status_window.open if @status_window.visible
  2149.           @actor_window.show if @actor_window.active
  2150.           @actor_window.restore_data if @actor_window.active
  2151.           @enemy_window.show if @enemy_window.active
  2152.           @enemy_window.restore_data if @enemy_window.active
  2153.           start_actor_command_selection(false) if @actor_command_window.active
  2154.           start_party_command_selection if @party_command_window.active
  2155.           if $imported[:mog_battle_cursor]
  2156.              $game_temp.battle_cursor[2] = @battle_cursor_visible
  2157.           end
  2158.       end
  2159.       $game_temp.hwindow_atb = false
  2160.   end
  2161.  
  2162.   #--------------------------------------------------------------------------
  2163.   # ● Hide Windows for dead
  2164.   #--------------------------------------------------------------------------  
  2165.   def hide_windows_for_dead
  2166.       return if BattleManager.actor == nil
  2167.       return if !BattleManager.actor.dead?
  2168.       hide_base_window
  2169.       $game_temp.atb_user = nil
  2170.       $game_temp.battle_cursor[2] = false if $imported[:mog_battle_cursor]
  2171.       BattleManager.command_selection_clear
  2172.   end
  2173.  
  2174.   #--------------------------------------------------------------------------
  2175.   # ● Update Target Windows
  2176.   #--------------------------------------------------------------------------  
  2177.   def update_target_windows
  2178.       if @actor_window.active and $game_temp.refresh_target_windows[0]
  2179.          @actor_window.refresh
  2180.          @actor_window.update
  2181.          $game_temp.refresh_target_windows[0] = false
  2182.       end  
  2183.       if @enemy_window.active and $game_temp.refresh_target_windows[1]
  2184.          @enemy_window.refresh
  2185.          @enemy_window.cursor_left if @enemy_window.enemy == nil
  2186.          @enemy_window.update
  2187.          $game_temp.refresh_target_windows[1] = false
  2188.       end
  2189.   end  
  2190.  
  2191.   #--------------------------------------------------------------------------
  2192.   # ● Process Execute Action
  2193.   #--------------------------------------------------------------------------  
  2194.   def process_execute_action
  2195.       @subject.current_action.prepare
  2196.       if @subject.current_action.valid?      
  2197.          @status_window.open ; execute_action
  2198.       end
  2199.       process_before_remove_action
  2200.       @subject.remove_current_action
  2201.   end
  2202.  
  2203.   #--------------------------------------------------------------------------
  2204.   # ● Process Before Remove Action
  2205.   #--------------------------------------------------------------------------  
  2206.   def process_before_remove_action   
  2207.   end
  2208.  
  2209.   #--------------------------------------------------------------------------
  2210.   # * End Turn
  2211.   #--------------------------------------------------------------------------
  2212.   def turn_end
  2213.       BattleManager.set_battler_in_turn(nil)   
  2214.       all_battle_members.each do |battler|
  2215.           refresh_status
  2216.           @log_window.wait_and_clear
  2217.       end
  2218.       turn_reset
  2219.   end  
  2220.  
  2221.   #--------------------------------------------------------------------------
  2222.   # ● Turn Reset
  2223.   #--------------------------------------------------------------------------
  2224.   def turn_reset
  2225.       $game_temp.remove_order(@subject)      
  2226.       BattleManager.current_battler_clear(@subject)
  2227.       BattleManager.command_selection_clear if BattleManager.command_need_clear?
  2228.       @subject =  nil
  2229.       BattleManager.set_subject(@subject)
  2230.       @log_window.wait
  2231.       @log_window.clear      
  2232.       $game_temp.atb_break_duration = 100
  2233.   end
  2234.  
  2235.   #--------------------------------------------------------------------------
  2236.   # ● Execute Event Phase Turn?
  2237.   #--------------------------------------------------------------------------
  2238.   def execute_event_phase_turn?
  2239.       return false if !$game_troop.can_interpreter_running?(false)
  2240.       return false if $game_party.members.empty?
  2241.       return false if $game_party.all_dead?
  2242.       return false if $game_troop.all_dead?
  2243.       return true
  2244.   end  
  2245.  
  2246.   #--------------------------------------------------------------------------
  2247.   # ● Update
  2248.   #--------------------------------------------------------------------------            
  2249.   def update
  2250.       update_basic   
  2251.       refresh_battle_atb if $game_temp.refresh_battle_atb
  2252.       process_action if BattleManager.in_turn?
  2253.       update_end_phase if $game_temp.end_phase_duration[1] > 0
  2254.   end  
  2255.  
  2256.   #--------------------------------------------------------------------------
  2257.   # ● Update Basic
  2258.   #--------------------------------------------------------------------------            
  2259.   alias mog_atb_update_basic update_basic
  2260.   def update_basic
  2261.       update_break_phase
  2262.       break_command if force_break_command?
  2263.       update_atb_basic if !$game_troop.interpreter.running?
  2264.       mog_atb_update_basic
  2265.   end
  2266.  
  2267.   #--------------------------------------------------------------------------
  2268.   # ● Force Break Command
  2269.   #--------------------------------------------------------------------------            
  2270.   def force_break_command?
  2271.       return true if $game_temp.break_command
  2272.       return true if can_break_command?
  2273.       return true if can_break_command2?
  2274.       return false
  2275.   end
  2276.  
  2277.   #--------------------------------------------------------------------------
  2278.   # ● Update Atb Basic
  2279.   #--------------------------------------------------------------------------            
  2280.   def update_atb_basic
  2281.       if @actor_command_window.active
  2282.          update_actor_command
  2283.       else   
  2284.          update_party_command
  2285.       end   
  2286.       update_target_windows      
  2287.       refresh_item_skill_window if need_refresh_item_skill_window?
  2288.       start_actor_command_selection if refresh_actor_command?
  2289.       fade_base_window(15) if $game_temp.battle_end
  2290.   end  
  2291.  
  2292.   #--------------------------------------------------------------------------
  2293.   # ● Need Refresh Item Skill Window?
  2294.   #--------------------------------------------------------------------------            
  2295.   def need_refresh_item_skill_window?
  2296.       return true if $game_temp.refresh_item_window
  2297.       return false
  2298.   end
  2299.  
  2300.   #--------------------------------------------------------------------------
  2301.   # ● Refresh Item Skill Window
  2302.   #--------------------------------------------------------------------------            
  2303.   def refresh_item_skill_window
  2304.       $game_temp.refresh_item_window = false
  2305.       @item_window.refresh if @item_window.visible
  2306.       @skill_window.refresh if @skill_window.visible
  2307.   end
  2308.  
  2309.   #--------------------------------------------------------------------------
  2310.   # ● Update End Phase
  2311.   #--------------------------------------------------------------------------            
  2312.   def update_end_phase
  2313.       $game_temp.end_phase_duration[1] -= 1
  2314.       return if $game_temp.end_phase_duration[1] > 0
  2315.       $game_temp.end_phase_duration[0] = false
  2316.       BattleManager.judge_win_loss
  2317.   end
  2318.  
  2319.   #--------------------------------------------------------------------------
  2320.   # ● Process Event
  2321.   #--------------------------------------------------------------------------            
  2322.   alias mog_atb_process_event process_event
  2323.   def process_event
  2324.       if battle_end? ; hide_base_window ; $game_temp.end_phase_duration = [true,30] ; end
  2325.       $game_temp.actor_process_event = BattleManager.actor
  2326.       mog_atb_process_event
  2327.       process_break_atb_event
  2328.   end
  2329.  
  2330.   #--------------------------------------------------------------------------
  2331.   # ● Process Break ATB Event
  2332.   #--------------------------------------------------------------------------            
  2333.   def process_break_atb_event
  2334.       if break_actor_command?
  2335.          BattleManager.actor.turn_clear
  2336.          BattleManager.command_selection_clear
  2337.       end
  2338.       BattleManager.force_clear_battler_atb
  2339.   end
  2340.  
  2341.   #--------------------------------------------------------------------------
  2342.   # ● Break Actor Command
  2343.   #--------------------------------------------------------------------------            
  2344.   def break_actor_command?
  2345.       return false if BattleManager.actor == nil
  2346.       return true if BattleManager.actor.dead?
  2347.       return true if BattleManager.actor.restriction != 0
  2348.       return false
  2349.   end
  2350.  
  2351.   #--------------------------------------------------------------------------
  2352.   # * Processing at End of Action
  2353.   #--------------------------------------------------------------------------
  2354.   alias mog_atb_process_action_end process_action_end
  2355.   def process_action_end
  2356.       if battle_end? ; hide_base_window ; $game_temp.end_phase_duration = [true,30] ; end
  2357.       mog_atb_process_action_end
  2358.   end  
  2359.  
  2360.   #--------------------------------------------------------------------------
  2361.   # ● Update Turn
  2362.   #--------------------------------------------------------------------------            
  2363.   def update_turn
  2364.       force_reset_turn_duration if $game_temp.turn_duration_clear
  2365.       $game_system.atb_turn_duration[0] += 1 unless $game_troop.interpreter.running?
  2366.       if $game_system.atb_turn_duration[0] >= $game_system.atb_turn_duration[1]
  2367.          $game_system.atb_turn_duration[0] = 0
  2368.          $game_troop.increase_turn
  2369.          execute_event_phase if $game_troop.can_interpreter_running?(true)
  2370.       end  
  2371.   end  
  2372.  
  2373.   #--------------------------------------------------------------------------
  2374.   # ● Update Turn
  2375.   #--------------------------------------------------------------------------            
  2376.   def update_turn?
  2377.       return false if $game_system.atb_turn_duration == nil or $game_system.atb_turn_duration[0] == nil
  2378.       return false if $game_temp.end_phase_duration[1] > 0
  2379.       return false if $game_temp.battle_end
  2380.       return false if $game_temp.atb_stop[1]   
  2381.       return true
  2382.   end   
  2383.  
  2384.   #--------------------------------------------------------------------------
  2385.   # ● Execute Event Phase
  2386.   #--------------------------------------------------------------------------            
  2387.   def execute_event_phase
  2388.       if $game_troop.can_interpreter_hide_window? or $game_troop.can_interpreter_hide_window_2?
  2389.       (record_window_data ; rw = true)
  2390.       end
  2391.       process_event
  2392.       refresh_status
  2393.       restore_window_data if rw != nil
  2394.       BattleManager.turn_start_abs      
  2395.   end   
  2396.  
  2397.   #--------------------------------------------------------------------------
  2398.   # ● Force Reset Turn Duration
  2399.   #--------------------------------------------------------------------------            
  2400.   def force_reset_turn_duration
  2401.       $game_temp.turn_duration_clear = false
  2402.       $game_system.atb_turn_duration[0] = 0
  2403.       $game_troop.set_turn(0)
  2404.   end  
  2405.  
  2406.   #--------------------------------------------------------------------------
  2407.   # ● ON Enemy OK
  2408.   #--------------------------------------------------------------------------
  2409.   alias mog_atb_on_enemy_ok on_enemy_ok
  2410.   def on_enemy_ok
  2411.       return if BattleManager.actor == nil
  2412.       return if battle_end?
  2413.       mog_atb_on_enemy_ok           
  2414.       BattleManager.command_end
  2415.       hide_base_window
  2416.   end
  2417.  
  2418.   #--------------------------------------------------------------------------
  2419.   # ● On Enemy Cancel
  2420.   #--------------------------------------------------------------------------
  2421.   alias mog_atb_on_enemy_cancel on_enemy_cancel
  2422.   def on_enemy_cancel
  2423.       return if BattleManager.actor == nil
  2424.       mog_atb_on_enemy_cancel
  2425.       start_actor_command_selection if @actor_command_window.active
  2426.       @skill_window.visible = true if @skill_window.active
  2427.       @item_window.visible = true if @item_window.active
  2428.   end     
  2429.  
  2430.   #--------------------------------------------------------------------------
  2431.   # ● On Actor OK
  2432.   #--------------------------------------------------------------------------
  2433.   alias mog_atb_on_actor_ok on_actor_ok
  2434.   def on_actor_ok
  2435.       return if BattleManager.actor == nil
  2436.       return if battle_end?
  2437.       mog_atb_on_actor_ok
  2438.       BattleManager.command_end
  2439.       hide_base_window
  2440.   end
  2441.  
  2442.   #--------------------------------------------------------------------------
  2443.   # ● On Actor Cancel
  2444.   #--------------------------------------------------------------------------
  2445.   alias mog_atb_on_actor_cancel on_actor_cancel
  2446.   def on_actor_cancel
  2447.       return if BattleManager.actor == nil
  2448.       mog_atb_on_actor_cancel
  2449.       start_actor_command_selection if @actor_command_window.active
  2450.       @skill_window.visible = true if @skill_window.active
  2451.       @item_window.visible = true if @item_window.active      
  2452.   end
  2453.  
  2454.   #--------------------------------------------------------------------------
  2455.   # ● On Skill Cancel
  2456.   #--------------------------------------------------------------------------
  2457.   alias mog_atb_on_skill_cancel on_skill_cancel
  2458.   def on_skill_cancel
  2459.       return if BattleManager.actor == nil
  2460.       mog_atb_on_skill_cancel
  2461.       start_actor_command_selection if @actor_command_window.active
  2462.   end  
  2463.  
  2464.   #--------------------------------------------------------------------------
  2465.   # ● On Item Cancel
  2466.   #--------------------------------------------------------------------------
  2467.   alias mog_atb_on_item_cancel on_item_cancel
  2468.   def on_item_cancel
  2469.       return if BattleManager.actor == nil
  2470.       mog_atb_on_item_cancel
  2471.       start_actor_command_selection if @actor_command_window.active
  2472.   end  
  2473.  
  2474.   #--------------------------------------------------------------------------
  2475.   # ● On Skill OK
  2476.   #--------------------------------------------------------------------------
  2477.   alias mog_atb_on_skill_ok on_skill_ok
  2478.   def on_skill_ok
  2479.       return if BattleManager.actor == nil
  2480.       @skill_window.visible = false unless !@status_window.visible
  2481.       mog_atb_on_skill_ok      
  2482.       if !@skill.need_selection?
  2483.          BattleManager.command_end
  2484.          hide_base_window
  2485.       end   
  2486.   end
  2487.  
  2488.   #--------------------------------------------------------------------------
  2489.   # ● On Item OK
  2490.   #--------------------------------------------------------------------------
  2491.   alias mog_atb_on_item_ok on_item_ok
  2492.   def on_item_ok
  2493.       return if BattleManager.actor == nil
  2494.       @item_window.visible = false unless !@status_window.visible
  2495.       mog_atb_on_item_ok
  2496.       if !@item.need_selection?
  2497.          BattleManager.command_end
  2498.          hide_base_window
  2499.       end
  2500.   end  
  2501.  
  2502.   #--------------------------------------------------------------------------
  2503.   # ● Start Actor Command Selection
  2504.   #--------------------------------------------------------------------------
  2505.   def start_actor_command_selection(se = true)
  2506.       $game_temp.atb_user = BattleManager.actor
  2507.       $game_temp.refresh_actor_command = false
  2508.       $game_temp.actor_process_event = nil
  2509.       if BattleManager.next_command and BattleManager.actor and BattleManager.actor.movable_atb?
  2510.          execute_start_actor_command(se)
  2511.       else   
  2512.          BattleManager.command_selection_clear
  2513.       end   
  2514.   end     
  2515.  
  2516.   #--------------------------------------------------------------------------
  2517.   # ● Execute Start Actor Command
  2518.   #--------------------------------------------------------------------------
  2519.   def execute_start_actor_command(se)
  2520.       $game_temp.remove_order(BattleManager.actor)      
  2521.       Audio.se_play("Audio/SE/" + SE_ACTIVE,100,100) if se
  2522.       hide_base_window(false,true) if se
  2523.       @status_window.select(BattleManager.actor.index)
  2524.       @status_window.open
  2525.       @status_window.select(BattleManager.actor.index)
  2526.       @party_command_window.close
  2527.       @actor_command_window.setup(BattleManager.actor)
  2528.       @actor_command_window.activate
  2529.       @actor_command_window.show
  2530.       @actor_command_window.index = $game_temp.actor_command_index      
  2531.   end
  2532.  
  2533.   #--------------------------------------------------------------------------
  2534.   # ● Next Command
  2535.   #--------------------------------------------------------------------------
  2536.   def next_command
  2537.   end
  2538.  
  2539.   #--------------------------------------------------------------------------
  2540.   # ● Close Base
  2541.   #--------------------------------------------------------------------------
  2542.   def close_base_window
  2543.       @party_command_window.close
  2544.       @actor_command_window.close
  2545.       @status_window.unselect
  2546.   end
  2547.  
  2548.   #--------------------------------------------------------------------------
  2549.   # ● Command Fight
  2550.   #--------------------------------------------------------------------------
  2551.   alias mog_atb_command_fight command_fight
  2552.   def command_fight
  2553.       mog_atb_command_fight
  2554.       start_actor_command_selection
  2555.   end  
  2556.  
  2557.   #--------------------------------------------------------------------------
  2558.   # ● Refresh Status
  2559.   #--------------------------------------------------------------------------
  2560.   alias mog_atb_refresh_status refresh_status
  2561.   def refresh_status
  2562.       mog_atb_refresh_status
  2563.       hide_windows_for_dead
  2564.   end
  2565.  
  2566.   #--------------------------------------------------------------------------
  2567.   # ● Forced Action Processing
  2568.   #--------------------------------------------------------------------------
  2569.   def process_forced_action   
  2570.       if BattleManager.action_forced?
  2571.          last_subject = @subject
  2572.          @subject = BattleManager.action_forced_battler         
  2573.          BattleManager.clear_action_force              
  2574.          execute_force_action         
  2575.          @subject = last_subject
  2576.       end
  2577.   end
  2578.  
  2579.   #--------------------------------------------------------------------------
  2580.   # ● Execute Force Action
  2581.   #--------------------------------------------------------------------------
  2582.   def execute_force_action
  2583.       return if scene_changing?
  2584.       if !@subject || !@subject.current_action
  2585.          @subject = BattleManager.next_subject
  2586.       end
  2587.       return turn_end unless @subject      
  2588.       if @subject.current_action        
  2589.          @subject.current_action.prepare
  2590.          if @subject.current_action.valid?
  2591.             @status_window.open
  2592.             execute_action
  2593.          end
  2594.          @subject.remove_current_action
  2595.        end
  2596.        process_action_end unless @subject.current_action
  2597.   end  
  2598.  
  2599.   #--------------------------------------------------------------------------
  2600.   # ● Subject Action
  2601.   #--------------------------------------------------------------------------  
  2602.   def subject_action
  2603.       return @subject.current_action.item rescue nil
  2604.   end  
  2605.  
  2606.   #--------------------------------------------------------------------------
  2607.   # ● Wait for Effect
  2608.   #--------------------------------------------------------------------------  
  2609.   alias mog_atb_cm_wait_for_effect wait_for_effect
  2610.   def wait_for_effect
  2611.       return if $game_troop.interpreter.running?
  2612.       mog_atb_cm_wait_for_effect
  2613.   end
  2614.  
  2615. end
  2616.  
  2617. #===============================================================================
  2618. # ■ Window Battle Skill
  2619. #===============================================================================
  2620. class Window_BattleSkill < Window_SkillList
  2621.  
  2622.   #--------------------------------------------------------------------------
  2623.   # ● Select Last
  2624.   #--------------------------------------------------------------------------
  2625.   alias mog_atb_f_select_last_skill select_last
  2626.   def select_last
  2627.       act = @actor.last_skill.object rescue nil
  2628.       act_data = @data.index(@actor.last_skill.object) rescue nil
  2629.       if act == nil or act_data == nil ; select(0) ; return ; end
  2630.       mog_atb_f_select_last_skill
  2631.   end
  2632.  
  2633. end
  2634.  
  2635. #===============================================================================
  2636. # ■ Window Battle Item
  2637. #===============================================================================
  2638. class Window_BattleItem < Window_ItemList
  2639.  
  2640.   #--------------------------------------------------------------------------
  2641.   # ● Select Last
  2642.   #--------------------------------------------------------------------------
  2643.   alias mog_atb_f_select_last_item select_last
  2644.   def select_last
  2645.       act = $game_party.last_item.object rescue nil
  2646.       act_data = @data.index($game_party.last_item.object) rescue nil
  2647.       if act == nil or act_data == nil ; select(0) ; return ; end
  2648.       mog_atb_f_select_last_item
  2649.   end
  2650.  
  2651. end
  2652.  
  2653. #===============================================================================
  2654. # ■ Scene Battle
  2655. #===============================================================================
  2656. class Scene_Battle < Scene_Base
  2657.  
  2658.   #--------------------------------------------------------------------------
  2659.   # ● Skip Command?
  2660.   #--------------------------------------------------------------------------
  2661.   def skip_command?
  2662.       return true if BattleManager.actor == nil
  2663.       return true if BattleManager.actor.dead?
  2664.       return true if BattleManager.actor.restriction != 0
  2665.       return false
  2666.   end
  2667.  
  2668.   #--------------------------------------------------------------------------
  2669.   # ● Command Attack
  2670.   #--------------------------------------------------------------------------
  2671.   alias mog_atb_f_command_attack command_attack
  2672.   def command_attack
  2673.       if skip_command? ; break_command ; return ; end
  2674.       mog_atb_f_command_attack
  2675.   end
  2676.  
  2677.   #--------------------------------------------------------------------------
  2678.   # ● Command Skill
  2679.   #--------------------------------------------------------------------------
  2680.   alias mog_atb_f_command_skill command_skill
  2681.   def command_skill
  2682.       if skip_command? ; break_command ; return ; end
  2683.       mog_atb_f_command_skill
  2684.   end
  2685.  
  2686.   #--------------------------------------------------------------------------
  2687.   # ● Command Guard
  2688.   #--------------------------------------------------------------------------
  2689.   alias mog_atb_f_command_guard command_guard
  2690.   def command_guard
  2691.       if skip_command? ; break_command ; return ; end
  2692.       mog_atb_f_command_guard
  2693.       BattleManager.command_end
  2694.       hide_base_window      
  2695.   end
  2696.  
  2697.   #--------------------------------------------------------------------------
  2698.   # ● Command Item
  2699.   #--------------------------------------------------------------------------
  2700.   alias mog_atb_f_command_item command_item
  2701.   def command_item
  2702.       if skip_command? ; break_command ; return ; end
  2703.       mog_atb_f_command_item
  2704.   end  
  2705.  
  2706. end
  2707.  
  2708. #==============================================================================
  2709. # ■ SpritesetBattle
  2710. #==============================================================================
  2711. class Spriteset_Battle
  2712.  
  2713.   include MOG_ATB_SYSTEM
  2714.  
  2715.   #--------------------------------------------------------------------------
  2716.   # ● Initialize
  2717.   #--------------------------------------------------------------------------   
  2718.   alias mog_atb_display_turn_initialize initialize
  2719.   def initialize
  2720.       create_turn_number
  2721.       mog_atb_display_turn_initialize
  2722.   end
  2723.  
  2724.   #--------------------------------------------------------------------------
  2725.   # ● Dispose
  2726.   #--------------------------------------------------------------------------  
  2727.   alias mog_atb_display_turn_dispose dispose
  2728.   def dispose
  2729.       mog_atb_display_turn_dispose
  2730.       dispose_turn_number
  2731.   end
  2732.  
  2733.   #--------------------------------------------------------------------------
  2734.   # ● Update
  2735.   #--------------------------------------------------------------------------   
  2736.   alias mog_atb_display_turn_update update
  2737.   def update
  2738.       mog_atb_display_turn_update
  2739.       update_turn_number
  2740.   end
  2741.  
  2742.   #--------------------------------------------------------------------------
  2743.   # ● Create Turn Number
  2744.   #--------------------------------------------------------------------------   
  2745.   def create_turn_number
  2746.       return if !DISPLAY_TURN_NUMBER
  2747.       @turn_count_old = $game_troop.turn_count
  2748.       @turn_sprite = Sprite.new
  2749.       @turn_sprite.bitmap = Bitmap.new(120,32)
  2750.       @turn_sprite.bitmap.font.size = TURN_NUMBER_FONT_SIZE
  2751.       @turn_sprite.bitmap.font.bold = TURN_NUMBER_FONT_BOLD
  2752.       @turn_sprite.z = TURN_NUMBER_Z
  2753.       @turn_sprite.x = TURN_NUMBER_POS[0] ; @turn_sprite.y = TURN_NUMBER_POS[1]
  2754.       refresh_turn_sprite
  2755.   end  
  2756.  
  2757.   #--------------------------------------------------------------------------
  2758.   # ● Refresh Turn Sprite
  2759.   #--------------------------------------------------------------------------   
  2760.   def refresh_turn_sprite
  2761.       @turn_count_old = $game_troop.turn_count
  2762.       @turn_sprite.bitmap.clear ; @turn_sprite.opacity = 255
  2763.       turn_text = TURN_WORD + $game_troop.turn_count.to_s
  2764.       @turn_sprite.bitmap.draw_text(0,0,120,32,turn_text,0)
  2765.   end
  2766.  
  2767.   #--------------------------------------------------------------------------
  2768.   # ● Dispose Turn Number
  2769.   #--------------------------------------------------------------------------   
  2770.   def dispose_turn_number
  2771.       return if @turn_sprite == nil
  2772.       @turn_sprite.bitmap.dispose ; @turn_sprite.dispose
  2773.   end
  2774.  
  2775.   #--------------------------------------------------------------------------
  2776.   # ● Update Turn Number
  2777.   #--------------------------------------------------------------------------   
  2778.   def update_turn_number
  2779.       return if @turn_sprite == nil
  2780.       refresh_turn_sprite if @turn_count_old != $game_troop.turn_count
  2781.       @turn_sprite.visible = turn_visible?
  2782.   end
  2783.  
  2784.   #--------------------------------------------------------------------------
  2785.   # ● Turn Visible?
  2786.   #--------------------------------------------------------------------------   
  2787.   def turn_visible?
  2788.       return false if !$game_temp.sprite_visible
  2789.       return false if !$game_system.atb_sprite_turn
  2790.       return true
  2791.   end
  2792.  
  2793. end
  2794.  
  2795. #==============================================================================
  2796. # ■ Window BattleLog
  2797. #==============================================================================
  2798. class Window_BattleLog < Window_Selectable   
  2799.   include MOG_COOPERATION_SKILLS
  2800.  
  2801.   #--------------------------------------------------------------------------
  2802.   # ● Display Skill/Item Use
  2803.   #--------------------------------------------------------------------------
  2804.   alias mog_cskill_display_use_item display_use_item
  2805.   def display_use_item(subject, item)
  2806.       return if cooperation_skill_users?(subject, item)
  2807.       mog_cskill_display_use_item(subject, item)
  2808.   end
  2809.  
  2810.   #--------------------------------------------------------------------------
  2811.   # ● Cooperation Skill_users?
  2812.   #--------------------------------------------------------------------------
  2813.   def cooperation_skill_users?(subject, item)
  2814.       return false if subject.is_a?(Game_Enemy)
  2815.       return false if !item.is_a?(RPG::Skill)
  2816.       return false if !BattleManager.is_cskill?(item.id)
  2817.       return false if !BattleManager.actor_included_in_cskill?(subject.id,item.id)
  2818.       members = BattleManager.cskill_members(item.id) ; subject_name = ""
  2819.       if members.size <=0  
  2820.          members.each_with_index do |b,index|     
  2821.          if index == members.size - 1 ; subject_name += b.name
  2822.          else ; subject_name += b.name + " " + "and" + " "
  2823.          end
  2824.          end
  2825.       else
  2826.          subject_name += $game_party.name
  2827.       end
  2828.       add_text(subject_name + item.message1)
  2829.       unless item.message2.empty? ; wait ; add_text(item.message2) ; end
  2830.   end
  2831.  
  2832. end
  2833.  
  2834. #==============================================================================
  2835. # ■ Game_Battler
  2836. #==============================================================================
  2837. class Game_BattlerBase  
  2838.  
  2839.   #--------------------------------------------------------------------------
  2840.   # ● Pay Skill Cost
  2841.   #--------------------------------------------------------------------------   
  2842.   alias mog_cskill_pay_skill_cost pay_skill_cost
  2843.   def pay_skill_cost(skill)
  2844.       if self.is_a?(Game_Actor) and BattleManager.cskill_usable?(skill.id,self.id)
  2845.            BattleManager.pay_cskill_cost(skill)
  2846.          return
  2847.       end
  2848.       mog_cskill_pay_skill_cost(skill)
  2849.   end
  2850.  
  2851. end
  2852.  
  2853. #==============================================================================
  2854. # ■ BattleManager
  2855. #==============================================================================
  2856. module BattleManager
  2857.   include MOG_COOPERATION_SKILLS
  2858.  
  2859.   #--------------------------------------------------------------------------
  2860.   # ● Cooperation Skill Enable?
  2861.   #--------------------------------------------------------------------------
  2862.   def self.cskill_enable?(skill_id)
  2863.       return false if actor == nil
  2864.       return false if !actor_included_in_cskill?(actor.id,skill_id)
  2865.       return false if !ckill_members_usable?(skill_id)
  2866.       return false if !cskill_all_members_available?(skill_id)
  2867.       return true
  2868.   end
  2869.  
  2870.   #--------------------------------------------------------------------------
  2871.   # ● Cskill Usable?
  2872.   #--------------------------------------------------------------------------
  2873.   def self.cskill_usable?(skill_id,actor_id)
  2874.       return false if !is_cskill?(skill_id)
  2875.       return false if !actor_included_in_cskill?(actor_id,skill_id)
  2876.       return false if !cskill_members_alive?(skill_id)
  2877.       return true
  2878.   end  
  2879.  
  2880.   #--------------------------------------------------------------------------
  2881.   # ● Pay Cskill Cost
  2882.   #--------------------------------------------------------------------------
  2883.   def self.pay_cskill_cost(skill)
  2884.       cskill_members(skill.id).each do |battler|
  2885.          battler.face_animation = [60 ,2,0] if $imported[:mog_battle_hud_ex]
  2886.          $game_temp.remove_order(battler)
  2887.          battler.mp -= battler.skill_mp_cost(skill)
  2888.          battler.tp -= battler.skill_tp_cost(skill)
  2889.       end
  2890.   end   
  2891.  
  2892.   #--------------------------------------------------------------------------
  2893.   # ● Cskill Members Usable?
  2894.   #--------------------------------------------------------------------------
  2895.   def self.ckill_members_usable?(skill_id)
  2896.       skill = $data_skills[skill_id] rescue nil
  2897.       return false if skill == nil   
  2898.       cskill_members(skill_id).each do |battler|
  2899.            return false if !battler.atb_max?
  2900.            return false if battler == subject
  2901.            return false if battler.restriction != 0
  2902.            return false if !battler.skill_cost_payable?(skill)
  2903.            return false if !battler.usable?(skill)
  2904.       end
  2905.       return true
  2906.   end
  2907.  
  2908.   #--------------------------------------------------------------------------
  2909.   # ● Cskill Actor?
  2910.   #--------------------------------------------------------------------------
  2911.   def self.ckill_actor?(self_actor)
  2912.       item = self_actor.current_action.item rescue nil
  2913.       return false if item == nil
  2914.       include = false
  2915.       cskill_members(item.id).each do |battler|
  2916.       include = true if self_actor == battler
  2917.       end  
  2918.       return true if include
  2919.       return false
  2920.   end  
  2921.  
  2922.   #--------------------------------------------------------------------------
  2923.   # ● Cskill All Members Available?
  2924.   #--------------------------------------------------------------------------
  2925.   def self.cskill_all_members_available?(skill_id)
  2926.       return false if COOPERATION_SKILLS[skill_id].size != cskill_members(skill_id).size
  2927.       return true
  2928.   end  
  2929.  
  2930.   #--------------------------------------------------------------------------
  2931.   # ● Cooperation Members
  2932.   #--------------------------------------------------------------------------
  2933.   def self.cskill_members(skill_id)
  2934.       return [] if COOPERATION_SKILLS[skill_id].nil?
  2935.       members = []
  2936.       $game_party.battle_members.each do |battler|
  2937.       members.push(battler) if COOPERATION_SKILLS[skill_id].include?(battler.id)
  2938.       end
  2939.       return members
  2940.   end
  2941.  
  2942.   #--------------------------------------------------------------------------
  2943.   # ● Cskill Members Skill Cost?
  2944.   #--------------------------------------------------------------------------
  2945.   def self.cskill_members_skill_cost?(skill_id)
  2946.       skill = $data_skills[skill_id] rescue nil
  2947.       return false if skill == nil
  2948.       cskill_members(skill_id).each do |battler|
  2949.       return false if !battler.skill_conditions_met?(skill)
  2950.       end
  2951.       return true
  2952.   end  
  2953.  
  2954.   #--------------------------------------------------------------------------
  2955.   # ● Cskill Members Usable?
  2956.   #--------------------------------------------------------------------------
  2957.   def self.cskill_members_alive?(skill_id)
  2958.       skill = $data_skills[skill_id] rescue nil
  2959.       return false if skill == nil   
  2960.       alive = true
  2961.       cskill_members(skill_id).each do |battler|
  2962.           alive = false if battler.dead?
  2963.           alive = false if battler.restriction != 0
  2964.           alive = false if !battler.skill_cost_payable?(skill)
  2965.       end
  2966.       if !alive
  2967.          force_clear_cskill(skill_id)
  2968.          return false
  2969.       end
  2970.       return true
  2971.   end
  2972.  
  2973.   #--------------------------------------------------------------------------
  2974.   # ● Force Clear Cskill
  2975.   #--------------------------------------------------------------------------
  2976.   def self.force_clear_cskill(skill_id)
  2977.       cskill_members(skill_id).each do |battler| battler.turn_clear
  2978.       battler.atb_cast.clear
  2979.       battler.bact_sprite_need_refresh = true if $imported[:mog_sprite_actor]
  2980.       end
  2981.   end
  2982.  
  2983.   #--------------------------------------------------------------------------
  2984.   # ● Execute Cast Action Members
  2985.   #--------------------------------------------------------------------------
  2986.   def self.execute_cast_action_members(skill_id)
  2987.       cskill_members(skill_id).each do |battler|
  2988.          battler.next_turn = true
  2989.          battler.atb = battler.atb_max
  2990.          battler.atb_cast.clear
  2991.       end
  2992.   end
  2993.  
  2994.   #--------------------------------------------------------------------------
  2995.   # ● Set Members CP Skills
  2996.   #--------------------------------------------------------------------------
  2997.   def self.set_members_cp_skill(skill_id)
  2998.       skill = $data_skills[skill_id] rescue nil
  2999.       return false if skill == nil   
  3000.       cskill_members(skill_id).each do |battler|
  3001.            battler.atb = 0
  3002.            battler.actions = @command_actor.actions if @command_actor.actions != nil
  3003.            $game_temp.remove_order(battler)
  3004.            if skill.speed.abs == 0
  3005.               battler.atb_cast = [skill,50,50]
  3006.            else
  3007.               battler.atb_cast = [skill,skill.speed.abs,0]
  3008.            end
  3009.            battler.animation_id = MOG_COOPERATION_SKILLS::COOPERATION_SKILL_ANIMATION
  3010.       end
  3011.   end
  3012.  
  3013.   #--------------------------------------------------------------------------
  3014.   # ● Clear Members Cp Skill
  3015.   #--------------------------------------------------------------------------
  3016.   def self.clear_members_ckill(subject)
  3017.       return if subject.is_a?(Game_Enemy)
  3018.       return if subject == nil
  3019.       skill = subject.current_action.item rescue nil
  3020.       return if skill == nil
  3021.       return if !is_cskill?(skill.id)
  3022.       return if !actor_included_in_cskill?(subject.id,skill.id)
  3023.       cskill_members(skill.id).each do |battler| battler.turn_clear ; end
  3024.   end
  3025.  
  3026.   #--------------------------------------------------------------------------
  3027.   # ● Actor Included in Cooperation Skill?
  3028.   #--------------------------------------------------------------------------
  3029.   def self.actor_included_in_cskill?(actor_id,skill_id)
  3030.       return false if !SceneManager.scene_is?(Scene_Battle)
  3031.       return false if !is_cskill?(skill_id)
  3032.       return false if !COOPERATION_SKILLS[skill_id].include?(actor_id)
  3033.       return true
  3034.   end
  3035.  
  3036.   #--------------------------------------------------------------------------
  3037.   # ● Is Cooperation Skill?
  3038.   #--------------------------------------------------------------------------
  3039.   def self.is_cskill?(skill_id)
  3040.       return false if !SceneManager.scene_is?(Scene_Battle)
  3041.       return false if COOPERATION_SKILLS[skill_id].nil?
  3042.       return true
  3043.   end
  3044.  
  3045. end
  3046.  
  3047. #==============================================================================
  3048. # ■ BattleManager
  3049. #==============================================================================
  3050. class << BattleManager
  3051.  
  3052.   #--------------------------------------------------------------------------
  3053.   # ● Set Cast Action
  3054.   #--------------------------------------------------------------------------
  3055.   alias mog_cskill_command_end_actor command_end_actor
  3056.   def command_end_actor
  3057.       prepare_ckill_members
  3058.       mog_cskill_command_end_actor      
  3059.   end
  3060.  
  3061.   #--------------------------------------------------------------------------
  3062.   # ● Prepare Cskill Members
  3063.   #--------------------------------------------------------------------------
  3064.   def prepare_ckill_members
  3065.       item = @command_actor.current_action.item rescue nil  
  3066.       return if item == nil
  3067.       if is_cskill?(item.id) and ckill_members_usable?(item.id)
  3068.           set_members_cp_skill(item.id)
  3069.           @command_actor = nil
  3070.       end  
  3071.   end
  3072.  
  3073.   #--------------------------------------------------------------------------
  3074.   # ● Clear Cskills Members
  3075.   #--------------------------------------------------------------------------
  3076.   def clear_cskill_members(subject)
  3077.       item = subject.current_action.item rescue nil  
  3078.       return if item == nil
  3079.       clear_members_ckill(item.id) if is_cskill?(item.id)
  3080.   end
  3081.  
  3082. end
  3083.  
  3084. #==============================================================================
  3085. # ■ Window SkillList
  3086. #==============================================================================
  3087. class Window_SkillList < Window_Selectable
  3088.  
  3089.   #--------------------------------------------------------------------------
  3090.   # ● Display Skill in Active State?
  3091.   #--------------------------------------------------------------------------
  3092.   alias mog_atb_skill_list_enable? enable?
  3093.   def enable?(item)
  3094.       if SceneManager.scene_is?(Scene_Battle) and !item.nil?
  3095.          return false if BattleManager.is_cskill?(item.id) and !BattleManager.cskill_enable?(item.id)
  3096.       end
  3097.       mog_atb_skill_list_enable?(item)
  3098.   end   
  3099.  
  3100. end
  3101.  
  3102. #==============================================================================
  3103. # ■ Game Battler
  3104. #==============================================================================
  3105. class Game_Battler < Game_BattlerBase
  3106.  
  3107.   #--------------------------------------------------------------------------
  3108.   # ● Calculate Damage
  3109.   #--------------------------------------------------------------------------
  3110.   alias mog_atb_make_make_damage_value make_damage_value
  3111.   def make_damage_value(user, item)
  3112.       mog_atb_make_make_damage_value(user, item)
  3113.       coop_make_damage_value(user, item) if coop_make_damage_value?(user, item)
  3114.   end
  3115.  
  3116.   #--------------------------------------------------------------------------
  3117.   # ● Calculate Damage
  3118.   #--------------------------------------------------------------------------
  3119.   def coop_make_damage_value?(user, item)
  3120.       return false if item == nil
  3121.       return false if user.is_a?(Game_Enemy)
  3122.       return false if item.is_a?(RPG::Item)
  3123.       return false if !BattleManager.is_cskill?(item.id)
  3124.       return false if BattleManager.cskill_members(item.id).size < 1
  3125.       return true
  3126.   end
  3127.  
  3128.   #--------------------------------------------------------------------------
  3129.   # ● Coop Make Damage Value
  3130.   #--------------------------------------------------------------------------
  3131.   def coop_make_damage_value(user, item)
  3132.       for actor in BattleManager.cskill_members(item.id)
  3133.           next if actor == user
  3134.           value = item.damage.eval(actor, self, $game_variables)
  3135.           value *= item_element_rate(actor, item)
  3136.           value *= pdr if item.physical?
  3137.           value *= mdr if item.magical?
  3138.           value *= rec if item.damage.recover?
  3139.           value = apply_critical(value) if @result.critical
  3140.           value = apply_variance(value, item.damage.variance)
  3141.           value = apply_guard(value)
  3142.           @result.make_damage_coop(value.to_i, item)
  3143.       end
  3144.       @result.make_damage_coop_after(item)
  3145.   end
  3146.  
  3147. end
  3148.  
  3149. #==============================================================================
  3150. # ■ Game ActionResult
  3151. #==============================================================================
  3152. class Game_ActionResult
  3153.  
  3154.   #--------------------------------------------------------------------------
  3155.   # ● Create Damage
  3156.   #--------------------------------------------------------------------------
  3157.   def make_damage_coop(value, item)
  3158.       @hp_damage += value if item.damage.to_hp?
  3159.       @mp_damage += value if item.damage.to_mp?
  3160.   end   
  3161.  
  3162.   #--------------------------------------------------------------------------
  3163.   # ● Make Damage Coop After
  3164.   #--------------------------------------------------------------------------
  3165.   def make_damage_coop_after(item)
  3166.       @hp_damage /= BattleManager.cskill_members(item.id).size if item.damage.to_hp?
  3167.       @mp_damage /= BattleManager.cskill_members(item.id).size if item.damage.to_mp?   
  3168.       @critical = false if @hp_damage == 0
  3169.       @mp_damage = [@battler.mp, @mp_damage].min
  3170.       @hp_drain = @hp_damage if item.damage.drain?
  3171.       @mp_drain = @mp_damage if item.damage.drain?
  3172.       @hp_drain = [@battler.hp, @hp_drain].min
  3173.       @success = true if item.damage.to_hp? || @mp_damage != 0
  3174.   end
  3175.  
  3176. end
  3177.  
  3178. #==============================================================================
  3179. # ■ Game_Battler
  3180. #==============================================================================
  3181. class Game_Battler < Game_BattlerBase
  3182.  
  3183.   #--------------------------------------------------------------------------
  3184.   # ● Execute Cast Action
  3185.   #--------------------------------------------------------------------------   
  3186.   alias mog_cskill_execute_cast_action execute_cast_action
  3187.   def execute_cast_action
  3188.       mog_cskill_execute_cast_action
  3189.       prepare_cast_action_members
  3190.   end
  3191.  
  3192.   #--------------------------------------------------------------------------
  3193.   # ● Prepare Cast Acton Members
  3194.   #--------------------------------------------------------------------------   
  3195.   def prepare_cast_action_members
  3196.       return if self.is_a?(Game_Enemy)
  3197.       item = self.current_action.item rescue nil  
  3198.       return if item == nil   
  3199.       BattleManager.execute_cast_action_members(item.id) if BattleManager.cskill_usable?(item.id,self.id)
  3200.   end
  3201.  
  3202.   #--------------------------------------------------------------------------
  3203.   # ● ATB After Damage
  3204.   #--------------------------------------------------------------------------  
  3205.   alias mog_cpskill_atb_after_damage atb_after_damage
  3206.   def atb_after_damage(pre_item = nil)
  3207.       mog_cpskill_atb_after_damage(pre_item)
  3208.       force_clear_cpkill(pre_item) if pre_item != nil and self.is_a?(Game_Actor)
  3209.   end  
  3210.  
  3211.   #--------------------------------------------------------------------------
  3212.   # ● Force Clear CP skill
  3213.   #--------------------------------------------------------------------------   
  3214.   def force_clear_cpkill(pre_item = nil)
  3215.       $game_temp.refresh_item_window = true if @result.mp_damage != 0
  3216.       BattleManager.cskill_usable?(pre_item.id,self.id) if pre_item != nil      
  3217.   end
  3218.  
  3219.   #--------------------------------------------------------------------------
  3220.   # ● Need Refresh Item Window?
  3221.   #--------------------------------------------------------------------------   
  3222.   alias mog_cskills_need_refresh_item_window? need_refresh_item_window?
  3223.   def need_refresh_item_window?
  3224.       return true
  3225.       mog_cskills_need_refresh_item_window?
  3226.   end
  3227.  
  3228.   #--------------------------------------------------------------------------
  3229.   # ● Execute Damage
  3230.   #--------------------------------------------------------------------------   
  3231.   alias mog_atb_coop_execute_damage execute_damage
  3232.   def execute_damage(user)
  3233.       mog_atb_coop_execute_damage(user)
  3234.       item = user.current_action.item rescue nil
  3235.       execute_damage_coop(user,item) if user.coop_make_damage_value?(user, item)
  3236.   end
  3237.  
  3238.   #--------------------------------------------------------------------------
  3239.   # ● Execute Damage Coop
  3240.   #--------------------------------------------------------------------------   
  3241.   def execute_damage_coop(user,item)
  3242.       for actor in BattleManager.cskill_members(item.id)
  3243.           next if actor == user
  3244.           actor.hp += @result.hp_drain
  3245.           actor.mp += @result.mp_drain
  3246.           if $imported[:mog_damage_popup]
  3247.              actor.damage.push([-@result.hp_drain,"HP",@result.critical]) if @result.hp_drain != 0
  3248.              actor.damage.push([-@result.mp_drain,"MP",@result.critical]) if @result.mp_drain != 0
  3249.           end   
  3250.       end   
  3251.   end
  3252.  
  3253. end
  3254.  
  3255. #==============================================================================
  3256. # ■ Scene Battle
  3257. #==============================================================================
  3258. class Scene_Battle < Scene_Base
  3259.  
  3260.   #--------------------------------------------------------------------------
  3261.   # ● Process Before Execute Action
  3262.   #--------------------------------------------------------------------------  
  3263.   alias mog_cskill_process_before_execute_action  process_before_execute_action
  3264.   def process_before_execute_action
  3265.       mog_cskill_process_before_execute_action
  3266.       before_execute_cooperation_skill if can_execute_cooperation_skill?
  3267.   end
  3268.  
  3269.   #--------------------------------------------------------------------------
  3270.   # ● Process Before Remove Action
  3271.   #--------------------------------------------------------------------------  
  3272.   alias mog_cskill_process_before_remove_action process_before_remove_action
  3273.   def process_before_remove_action
  3274.       mog_cskill_process_before_remove_action
  3275.       BattleManager.clear_members_ckill(@subject)
  3276.   end
  3277.  
  3278.   #--------------------------------------------------------------------------
  3279.   # ● Can Execute Cooperation Skill?
  3280.   #--------------------------------------------------------------------------  
  3281.   def can_execute_cooperation_skill?
  3282.       return false if !@subject.is_a?(Game_Actor)
  3283.       item = @subject.current_action.item rescue nil
  3284.       return false if item == nil
  3285.       return false if !BattleManager.cskill_usable?(item.id,@subject.id)
  3286.       return true
  3287.   end
  3288.  
  3289.   #--------------------------------------------------------------------------
  3290.   # ● Current CP Members
  3291.   #--------------------------------------------------------------------------
  3292.   def current_cp_members
  3293.       return [] if subject_action == nil
  3294.       return BattleManager.cskill_members(subject_action.id)
  3295.   end   
  3296.  
  3297.   #--------------------------------------------------------------------------
  3298.   # ● Before Execute Coomperation Skill. (add-ons)
  3299.   #--------------------------------------------------------------------------  
  3300.   def before_execute_cooperation_skill
  3301.   end
  3302.  
  3303. end




上边是mog核心代码。(我已经持有行动条的显示图片,顺便发一下行动条的优化脚本吧。)


RUBY 代码复制
  1. #==============================================================================
  2. # +++ MOG - ATB 行动条 (v1.2)+++
  3. #==============================================================================
  4. # By Moghunter
  5. # https://atelierrgss.wordpress.com/
  6. #==============================================================================
  7. # 对敌人和角色显示ATB行动条.
  8. #==============================================================================
  9. # Histórico
  10. #==============================================================================
  11. # v1.2 - Compatibilidade com MOG Battle Camera.
  12. #==============================================================================
  13. $imported = {} if $imported.nil?
  14. $imported[:mog_atb_meter] = true
  15.  
  16. module MOG_ATB_Meter
  17.   #是否显示角色的ATB行动条
  18.   ENABLE_FOR_ACTOR = true
  19.   #是否显示敌人的ATB行动条
  20.   ENABLE_FOR_ENEMY = false
  21.   #是否显示行动条动画.
  22.   GRADIENT_ANIMATION = true
  23.   #是否固定行动条位置.(false = 图片的位置将参考战斗图的位置)
  24.   HUD_POSITION_FIX = false
  25.   #行动条Z坐标.
  26.   SCREEN_Z = -90
  27.   #Layout的位置
  28.   LAYOUT_POSITION = [0,0]
  29.   #行动条的位置.
  30.   METER_POSITION = [0,0]
  31.   # ☢注意!!☢ 以下部分勿动.^_^
  32.   FIXED_ACTOR_POSITION = []
  33.   FIXED_ENEMY_POSITION = []
  34.   #单独确认角色/敌人的行动条位置
  35.   #用于根据精灵位置调整ATB行动条的位置
  36.   FIXED_ACTOR_POSITION[0] = [0,-64]
  37.   FIXED_ACTOR_POSITION[1] = [0,-64]
  38.   FIXED_ACTOR_POSITION[2] = [0,-64]
  39.   FIXED_ACTOR_POSITION[3] = [0,-64]
  40.  
  41.   FIXED_ENEMY_POSITION[11] = [0,-64]
  42.   FIXED_ENEMY_POSITION[12] = [0,-64]
  43.   FIXED_ENEMY_POSITION[950] = [-30,-20]
  44.   FIXED_ENEMY_POSITION[951] = [-50,-30]
  45.   FIXED_ENEMY_POSITION[952] = [-100,-60]
  46. end
  47.  
  48. #==============================================================================
  49. # ■ Game Temp
  50. #==============================================================================
  51. class Game_Temp
  52.  
  53.   attr_accessor :battle_end
  54.  
  55.   #--------------------------------------------------------------------------
  56.   # ● Initialize
  57.   #--------------------------------------------------------------------------      
  58.   alias mog_atb_meter_initialize initialize
  59.   def initialize
  60.       @battle_end = false
  61.       mog_atb_meter_initialize
  62.   end
  63.  
  64. end
  65.  
  66. #===============================================================================
  67. # ■ Spriteset_Battle
  68. #===============================================================================
  69. class Sprite_Battler < Sprite_Base
  70.  
  71.   #--------------------------------------------------------------------------
  72.   # ● Dispose
  73.   #--------------------------------------------------------------------------  
  74.   alias mog_atb_meter_dispose dispose
  75.   def dispose
  76.       dispose_atb_meter
  77.       mog_atb_meter_dispose      
  78.   end
  79.  
  80.   #--------------------------------------------------------------------------
  81.   # ● Update
  82.   #--------------------------------------------------------------------------         
  83.   alias mog_atb_meter_update update
  84.   def update
  85.       mog_atb_meter_update
  86.       update_atb_meter
  87.   end
  88.  
  89.   #--------------------------------------------------------------------------
  90.   # ● Refresh ATB Meter
  91.   #--------------------------------------------------------------------------         
  92.   def refresh_atb_meter
  93.       return if @atb_meter != nil
  94.       @atb_meter = ATB_Meter.new(@battler)
  95.       @atb_created = true
  96.   end
  97.  
  98.   #--------------------------------------------------------------------------
  99.   # ● Dispose ATB Meter
  100.   #--------------------------------------------------------------------------         
  101.   def dispose_atb_meter
  102.       return if @atb_meter == nil
  103.       @atb_meter.dispose
  104.   end
  105.  
  106.   #--------------------------------------------------------------------------
  107.   # ● Update ATB Meter
  108.   #--------------------------------------------------------------------------         
  109.   def update_atb_meter
  110.       refresh_atb_meter if @atb_created == nil
  111.       return if @atb_meter == nil
  112.       @atb_meter.update
  113.   end
  114.  
  115. end
  116.  
  117. #===============================================================================
  118. # ■ Spriteset_Battle
  119. #===============================================================================
  120. class ATB_Meter
  121.   include MOG_ATB_Meter
  122.  
  123.   #--------------------------------------------------------------------------
  124.   # ● Initialize
  125.   #--------------------------------------------------------------------------         
  126.   def initialize(battler)
  127.       screen_x = battler.screen_x rescue nil
  128.       return if screen_x == nil
  129.       if $imported[:mog_battle_hud_ex]
  130.       return if battler.is_a?(Game_Actor) and SceneManager.face_battler?
  131.       end
  132.       if battler.is_a?(Game_Actor) and !ENABLE_FOR_ACTOR ; return ; end
  133.       if battler.is_a?(Game_Enemy) and !ENABLE_FOR_ENEMY ; return ; end
  134.       @battler = battler
  135.       catb = ATB::MAX_AP rescue nil ; @ccwinter_atb = true if catb != nil
  136.       create_sprites ; set_sprites_position ;  update_meter ; update_position
  137.   end
  138.  
  139.   #--------------------------------------------------------------------------
  140.   # ● Create Sprites
  141.   #--------------------------------------------------------------------------         
  142.   def create_sprites
  143.       @layout = Sprite.new ; @layout.bitmap = Cache.system("ATB_Layout")
  144.       @layout.ox = @layout.bitmap.width / 2 ; @layout.oy = @layout.bitmap.height / 2
  145.       @layout_oxy_org = [@layout.ox,@layout.oy]
  146.       @meter_image = Cache.system("ATB_Meter")
  147.       @meter_cw = GRADIENT_ANIMATION ? @meter_image.width / 3 : @meter_image.width
  148.       @meter_ch = @meter_image.height / 3
  149.       @meter_flow = 0 ; @meter_flow_max = @meter_cw * 2
  150.       @meter = Sprite.new ; @meter.bitmap = Bitmap.new(@meter_cw,@meter_ch)
  151.       @meter.ox = @meter.bitmap.width / 2 ; @meter.oy = @meter.bitmap.height / 2
  152.       @meter_oxy_org = [@meter.ox,@meter.oy]
  153.       @layout.opacity = 0 ; @meter.opacity = 0
  154.   end  
  155.  
  156.   #--------------------------------------------------------------------------
  157.   # ● Set Sprites Position
  158.   #--------------------------------------------------------------------------         
  159.   def set_sprites_position
  160.       if @battler.is_a?(Game_Actor)
  161.          if FIXED_ACTOR_POSITION[@battler.index] != nil
  162.             @lp = [FIXED_ACTOR_POSITION[@battler.index][0],FIXED_ACTOR_POSITION[@battler.index][1] + @layout.height]
  163.          else
  164.             @lp = [LAYOUT_POSITION[0],LAYOUT_POSITION[1] + @layout.height]
  165.          end
  166.          @mp = [METER_POSITION[0],METER_POSITION[1]]
  167.       else
  168.          if FIXED_ENEMY_POSITION[@battler.enemy_id] != nil
  169.             @lp = [FIXED_ENEMY_POSITION[@battler.enemy_id][0],FIXED_ENEMY_POSITION[@battler.enemy_id][1] + @layout.height]
  170.          else
  171.             @lp = [LAYOUT_POSITION[0],LAYOUT_POSITION[1] + @layout.height]
  172.          end        
  173.          @mp = [METER_POSITION[0],METER_POSITION[1]]
  174.       end  
  175.       @layout.x = @battler.screen_x + @lp[0]
  176.       @layout.y = @battler.screen_y + @lp[1]   
  177.       @meter.x = @layout.x + @mp[0] ;  @meter.y = @layout.y + @mp[1]
  178.       @layout.z = @battler.screen_z + SCREEN_Z ;  @meter.z = @layout.z + 1   
  179.   end
  180.  
  181.   #--------------------------------------------------------------------------
  182.   # ● Update Meter
  183.   #--------------------------------------------------------------------------         
  184.   def update_meter
  185.       @meter.bitmap.clear
  186.       @meter_flow = 0 if !GRADIENT_ANIMATION
  187.       if actor_cast?
  188.          meter_width = @meter_cw * actor_cast / actor_max_cast rescue nil
  189.          meter_width = 0 if meter_width == nil
  190.          ch = @meter_ch * 2
  191.       else
  192.          meter_width = @meter_cw * actor_at / actor_max_at rescue nil
  193.          meter_width = 0 if meter_width == nil         
  194.          ch = actor_at >= actor_max_at ? @meter_ch : 0
  195.       end   
  196.       meter_src_rect = Rect.new(@meter_flow, ch ,meter_width, @meter_ch)
  197.       @meter.bitmap.blt(0,0, @meter_image, meter_src_rect)  
  198.       @meter_flow += 2
  199.       @meter_flow = 0 if @meter_flow >= @meter_flow_max
  200.       update_battle_camera if  update_battle_camera_atb_m?
  201.   end
  202.  
  203.   #--------------------------------------------------------------------------
  204.   # ● Update Battle Cursor
  205.   #--------------------------------------------------------------------------              
  206.   def update_battle_camera_atb_m?
  207.       return false if $imported[:mog_battle_camera] == nil
  208.       if $imported[:mog_battle_hud_ex] and SceneManager.face_battler?
  209.          return false if @battler.is_a?(Game_Actor)
  210.       end   
  211.       return true
  212.    end     
  213.  
  214.   #--------------------------------------------------------------------------
  215.   # ● Update Battle Camera
  216.   #--------------------------------------------------------------------------              
  217.   def update_battle_camera
  218.       @meter.ox = $game_temp.viewport_oxy[0] + @meter_oxy_org[0]
  219.       @meter.oy = $game_temp.viewport_oxy[1] + @meter_oxy_org[1]
  220.       @layout.ox = $game_temp.viewport_oxy[0] + @layout_oxy_org[0]
  221.       @layout.oy = $game_temp.viewport_oxy[1] + @layout_oxy_org[1]
  222.   end
  223.  
  224.   #--------------------------------------------------------------------------
  225.   # ● Dispose
  226.   #--------------------------------------------------------------------------         
  227.   def dispose
  228.       return if @layout == nil
  229.       @layout.bitmap.dispose ; @layout.dispose
  230.       @meter.bitmap.dispose ; @meter.dispose
  231.   end
  232.  
  233.   #--------------------------------------------------------------------------
  234.   # ● Update
  235.   #--------------------------------------------------------------------------         
  236.   def update
  237.       return if @layout == nil
  238.       update_position if update_atb_position? ; update_meter ; update_visible
  239.   end
  240.  
  241.   #--------------------------------------------------------------------------
  242.   # ● Update
  243.   #--------------------------------------------------------------------------         
  244.   def update_visible
  245.       if sprite_visible? ; @layout.opacity += 10
  246.       else ; @layout.opacity -= 10
  247.       end
  248.       @meter.opacity = @layout.opacity
  249.   end
  250.  
  251.   #--------------------------------------------------------------------------
  252.   # ● Sprite Visible?
  253.   #--------------------------------------------------------------------------         
  254.   def sprite_visible?
  255.       return false if $game_temp.battle_end
  256.       return false if $game_message.visible
  257.       return false if $game_troop.interpreter.running?
  258.       return false if @battler.dead?
  259.       return false if @battler.hidden?
  260.       return true
  261.   end
  262.  
  263.   #--------------------------------------------------------------------------
  264.   # ● Update Position
  265.   #--------------------------------------------------------------------------         
  266.   def update_position
  267.       @layout.z = @battler.screen_z + SCREEN_Z ; @meter.z = @layout.z + 1
  268.       @layout.x = @battler.screen_x + @lp[0]
  269.       @layout.y = @battler.screen_y + @lp[1]  
  270.       @meter.x = @layout.x + @mp[0]
  271.       @meter.y = @layout.y + @mp[1]
  272.   end
  273.  
  274.   #--------------------------------------------------------------------------
  275.   # ● Update ATB Position?
  276.   #--------------------------------------------------------------------------         
  277.   def update_atb_position?
  278.       return false if HUD_POSITION_FIX
  279.       if $imported[:mog_atb_system] and BattleManager.subject != nil
  280.          return false if @battler == BattleManager.subject
  281.          if @battler.is_a?(Game_Actor) and BattleManager.subject.is_a?(Game_Enemy)
  282.             return false
  283.          elsif @battler.is_a?(Game_Enemy) and BattleManager.subject.is_a?(Game_Actor)
  284.             return false
  285.          end
  286.       end
  287.       return true
  288.   end
  289.  
  290.   #--------------------------------------------------------------------------
  291.   # * AT
  292.   #--------------------------------------------------------------------------  
  293.   def actor_at
  294.       return @battler.atb if $imported[:mog_atb_system]
  295.       return @battler.atb if $imported[:ve_active_time_battle]
  296.       return @battler.catb_value if $imported["YSA-CATB"]
  297.       return @battler.ap if @ccwinter_atb != nil
  298.       return 0
  299.   end
  300.  
  301.   #--------------------------------------------------------------------------
  302.   # * Max AT
  303.   #--------------------------------------------------------------------------  
  304.   def actor_max_at
  305.       return @battler.atb_max if $imported[:mog_atb_system]
  306.       return @battler.max_atb if $imported[:ve_active_time_battle]
  307.       return @battler.max_atb if $imported["YSA-CATB"]
  308.       return ATB::MAX_AP if @ccwinter_atb != nil
  309.       return 1
  310.   end
  311.  
  312.   #--------------------------------------------------------------------------
  313.   # ● Actor Cast
  314.   #--------------------------------------------------------------------------            
  315.   def actor_cast
  316.       return @battler.atb_cast[1] rescue nil if $imported[:mog_atb_system]
  317.       return -@battler.atb if $imported[:ve_active_time_battle]
  318.       return @battler.chant_count rescue 0 if @ccwinter_atb != nil
  319.       return 0
  320.   end
  321.  
  322.   #--------------------------------------------------------------------------
  323.   # ● Actor Max Cast
  324.   #--------------------------------------------------------------------------            
  325.   def actor_max_cast
  326.       if $imported[:mog_atb_system]
  327.          return @battler.atb_cast[2] if @battler.atb_cast[2] != 0
  328.          return @battler.atb_cast[0].speed.abs
  329.       end   
  330.       return @battler.max_atb if $imported[:ve_active_time_battle]
  331.       return -@battler.max_chant_count rescue 1 if @ccwinter_atb != nil
  332.       return 1
  333.   end  
  334.  
  335.   #--------------------------------------------------------------------------
  336.   # ● Actor Cast?
  337.   #--------------------------------------------------------------------------            
  338.   def actor_cast?   
  339.       if $imported[:mog_atb_system]
  340.          return true if !@battler.atb_cast.empty?
  341.       end   
  342.       if $imported[:ve_active_time_battle]
  343.          return true if @battler.cast_action?
  344.       end      
  345.       if @ccwinter_atb
  346.          return true if @battler.chanting?
  347.       end
  348.       return false
  349.   end   
  350.  
  351. end



现在所需

我想要达成以下的功能
——持有xx号buff的角色在行动后立刻恢复50%AT行动数值(已经完成)
————某个技能命中目标时扣除(或者恢复)其10%的行动条(已经完成)
————通过引用脚本(就是战斗内执行脚本),可以设定我方x号位置的角色(x号敌人)的具体行动条数值



有没有大佬能看出来该怎么写这个。QAQ


作者: 魔法丶小肉包    时间: 2024-8-10 16:31
三个功能互相没有冲突,可以自由取舍的

持有xx号状态的角色在行动后立刻回复n%AT
使用方法:在数据库-状态-备注里写<AT 数值>
比如<AT 50> 持有该状态的话就会在行动之后回复50%AT(只写了回复,没有写损失,因此不要写负数)
RUBY 代码复制
  1. class RPG::State
  2.   def atrecover_after
  3.     return $1.to_i if @note =~ /<AT\s+(\d+)>/
  4.     return nil
  5.   end
  6. end
  7. class Game_Battler
  8.   attr_accessor :atb_recover
  9.   alias mf240810initialize initialize
  10.   def initialize
  11.     mf240810initialize
  12.     @atb_recover = []
  13.   end
  14.   alias mf240810on_action_end on_action_end
  15.   def on_action_end
  16.     mf240810on_action_end
  17.     @states.each do |i|
  18.       @atb_recover << $data_states[i].atrecover_after if $data_states[i].atrecover_after
  19.     end
  20.   end
  21.   alias mf240810atb_update atb_update
  22.   def atb_update
  23.     mf240810atb_update
  24.     if @atb_recover != []
  25.       @atb += (@atb_max * @atb_recover[0] * 0.01).round
  26.       @atb = [@atb,@atb_max].min
  27.       @atb_recover = []
  28.     end
  29.   end
  30. end


某个技能命中目标时扣除/回复其n%AT
使用方法:在数据库-技能-备注里写<AT 数值>
比如<AT 10> 回复10%AT,<AT -10> 扣除10%AT
RUBY 代码复制
  1. class RPG::Skill
  2.   def change_atb
  3.     return $1.to_i if @note =~ /AT\s+(-\d+|\d+)/
  4.     return 0
  5.   end
  6. end
  7. class Game_ActionResult
  8.   attr_reader :battler
  9. end
  10. class Game_Battler
  11.   alias mf240810item_apply item_apply
  12.   def item_apply(user, item)
  13.     mf240810item_apply(user, item)
  14.     @result.battler.atb += @result.battler.atb_max * item.change_atb * 0.01 if item.is_a?(RPG::Skill)
  15.   end
  16. end


战斗中执行脚本,直接指定角色/敌人AT
使用方法:set_battler_atb(:actor/:enemy,在队伍中的位置,AT)
比如set_battler_atb(:actor,0,8000) #我方队伍0号位(第一个队友)AT变为8000
set_battler_atb(:enemy,1,2000) #敌群1号位(第二个敌人)AT变为2000
RUBY 代码复制
  1. class Game_Interpreter
  2.   def set_battler_atb(target,index,atb)
  3.     return unless [:actor,:enemy].include?(target)
  4.     case target
  5.     when :actor
  6.       $game_party.battle_members[index].atb = atb
  7.     when :enemy
  8.       $game_troop.members[index].atb = atb
  9.     end
  10.   end
  11. end





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