查看: 2418|回复: 20

[已经解决] 请问如何在战斗中设定攻略条件?

[复制链接]
梦石
0
星屑
518
在线时间
141 小时
注册时间
2016-12-17
回帖
33
发表于 2017-1-29 18:35:47 | 显示全部楼层 |阅读模式

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

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

×
我想在一个拥有3个敌人的敌群中设定在敌人B、C存活时,

敌人A受到攻击也不会失去HP,

必需在敌人B、C死亡时才能对敌人A造成伤害

请问要怎样才能做到这个效果?
梦石
0
星屑
50
在线时间
85 小时
注册时间
2011-3-6
回帖
36
发表于 2017-1-29 18:50:19 | 显示全部楼层
做一个免疫伤害的状态给A
敌群的事件做一个条件分歧
如果B和C都倒下了
去掉A的这个状态
回复

使用道具 举报

梦石
0
星屑
518
在线时间
141 小时
注册时间
2016-12-17
回帖
33
 楼主| 发表于 2017-1-29 19:12:05 | 显示全部楼层
请问这个条件分歧要怎样设置才会即时生效并且只要符合条件就会反复执行?

我想设定为敌人A解除该无敌状态后,一定回合数后会解除敌人B、C的频死状态,A会重新拥有无敌状态

可是战斗事件中的触发条件似乎都没有一个能做到效果……?望指教,谢谢
回复

使用道具 举报

梦石
0
星屑
50
在线时间
85 小时
注册时间
2011-3-6
回帖
36
发表于 2017-1-29 19:20:30 | 显示全部楼层
本帖最后由 weew163com 于 2017-1-29 19:29 编辑

嗯...战斗事件条件设置一个敌人hp为0一下(每个杂兵为条件设置一页)
内容再判断其他杂兵的状态
都通过的话去除无敌状态
然后再做个条件是回合数的复活事件
QQ截图20170129192839.png

评分

参与人数 1星屑 +250 收起 理由
RaidenInfinity + 250 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
518
在线时间
141 小时
注册时间
2016-12-17
回帖
33
 楼主| 发表于 2017-1-29 20:01:29 | 显示全部楼层
解除状态的事件成功了

可是,复活事件我无论是设定完全恢复或者解除死亡状态,
怪物虽然有复活但看不见怪物图 想请问哪里做错了?
回复

使用道具 举报

老鹰

梦石
40
星屑
38049
在线时间
7128 小时
注册时间
2012-5-26
回帖
3306

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

发表于 2017-1-29 20:02:46 | 显示全部楼层
本帖最后由 百里_飞柳 于 2017-1-29 20:14 编辑

1. 战斗事件 回合数 0 间隔战斗(只触发一次)
给敌人A设置个 特性-抗性-属性抗性 * 0% 的状态

2. 战斗事件 回合结束时 间隔即时(每时每刻都会判定一次,用来即时触发)
(记得用过开关来记录下,让这个事件在执行一次后便不再执行,保证效率)
条件分歧:敌人B、C均死亡时(条件分歧第三页-敌人-状态是 无法战斗 时),敌人A移除状态

评分

参与人数 1梦石 +1 收起 理由
RaidenInfinity + 1 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
518
在线时间
141 小时
注册时间
2016-12-17
回帖
33
 楼主| 发表于 2017-1-29 21:25:56 | 显示全部楼层
本帖最后由 rainaz 于 2017-1-29 21:40 编辑
百里_飞柳 发表于 2017-1-29 20:02
1. 战斗事件 回合数 0 间隔战斗(只触发一次)
给敌人A设置个 特性-抗性-属性抗性 * 0% 的状态


小弟不才,上面的方法比较看得懂,所以我使用了上面的方法了
但也感谢你的帮助,大大是在制作向Glimmer致敬的游戏吗?期待

另外,想请问复活怪物后,怪物虽然有复活但看不见怪物图,是哪里的问题?
我有使用SideView的战斗脚本 谢谢两位大大

点评

好的明白了,十分抱歉  发表于 2017-1-29 23:01
这次只提醒一下,下次要记得本区有这规则。  发表于 2017-1-29 22:18
注意:版规A11 - 不允许追加提问  发表于 2017-1-29 22:10
回复

使用道具 举报

老鹰

梦石
40
星屑
38049
在线时间
7128 小时
注册时间
2012-5-26
回帖
3306

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

发表于 2017-1-29 22:09:42 | 显示全部楼层
本帖最后由 百里_飞柳 于 2017-1-29 22:17 编辑
rainaz 发表于 2017-1-29 21:25
小弟不才,上面的方法比较看得懂,所以我使用了上面的方法了
但也感谢你的帮助,大大是在制作向Glimmer致 ...


的确是sideview的一个小bug,没有处理相关的敌人复活的情况,等我找下如何修复

暂时性的修复,角色复活后去除掉collapse标志,这样就能重新和其他角色刷新待机
  1. class SideView
  2.    attr_accessor   :collapse
  3. end
  4. class Game_Battler < Game_BattlerBase
  5.   def revive
  6.     self.sv.collapse = false
  7.     @hp = 1 if @hp == 0
  8.   end
  9. end
复制代码


注意:
敌人复活如果是去除 战斗不能 状态,默认是回复为1点HP,推荐使用 敌人完全恢复 指令
敌人复活后,RM默认不会重复计算打倒,最后结算只会以实际敌群中敌人数目为主
回复

使用道具 举报

梦石
0
星屑
518
在线时间
141 小时
注册时间
2016-12-17
回帖
33
 楼主| 发表于 2017-1-29 22:59:31 | 显示全部楼层
百里_飞柳 发表于 2017-1-29 22:09
的确是sideview的一个小bug,没有处理相关的敌人复活的情况,等我找下如何修复

暂时性的修复,角色复活 ...

请问是要修改Sideview脚本的哪里?抱歉,我不太会脚本

我找出脚本的
  1. class SideView
复制代码
  1. class Game_Battler < Game_BattlerBase
复制代码

在这两行下面插入大大的语句 
进入战斗时会出现错误,请问是我修改的方法不对吗?

点评

我测试了t触汉化的sideview100,发现复活并没有你说的问题,只有当敌人的元件横纵数不为[1,1]时复活后无法待机bug,请确定没有修改或用其他战斗脚本  发表于 2017-1-30 08:24
请问是这样吗?  发表于 2017-1-30 01:14
图像是用VXA内置的史莱姆,敌群中有3个敌人 设定每过了2个回合,当其中两只怪物状态是死亡时会复活,间隔是回合,复活指令是用完全恢复  发表于 2017-1-30 01:14
那可能和我指的并不是同一个bug,请再详细说下你的敌人图像的设置之类的  发表于 2017-1-30 00:35
在脚本下方开新脚本页插入后错误消失了 但同样是看不见怪物图 我是使用完全恢复指令的  发表于 2017-1-30 00:31
回复

使用道具 举报

梦石
0
星屑
518
在线时间
141 小时
注册时间
2016-12-17
回帖
33
 楼主| 发表于 2017-1-30 11:51:46 | 显示全部楼层
我把所有脚本也试一次后 发现这个脚本存在的时候会发生上述的问题 请问这个ATB脚本大大你会吗?

抱歉,打扰你了

点击展开/收起
  1. #==============================================================================
  2. # +++ MOG - ATB System  (v 6.1) +++
  3. #==============================================================================
  4. # By Moghunter
  5. # [url]https://atelierrgss.wordpress.com/[/url]
  6. #==============================================================================
  7. # Sistema de batalha ativo.
  8. #==============================================================================

  9. #==============================================================================
  10. # NOTA 1
  11. #==============================================================================
  12. # O script não vem com medidor de ATB incluído, será necessário usar scripts
  13. # add-ons para adicionar os medidores.
  14. #
  15. # Battle Hud EX
  16. # Ayesha ATB Gauge
  17. # Schala ATB Gauge
  18. #
  19. #==============================================================================
  20. # NOTA 2
  21. #==============================================================================
  22. # A janela de LOG está desativada para deixar a batalha mais dinâmica.
  23. # Portanto é necessário usar algum script de Damage Popup para ver os danos
  24. # causados no alvo
  25. #==============================================================================

  26. #==============================================================================
  27. # ● ATB SYSTEM
  28. #==============================================================================
  29. # A velocidade de AT é baseaddo na agilidade do Battler.
  30. # Em caso de batalhas preventivas (Preemptive) os aliados começarão com AT em
  31. # 80% e os inimigos começarão com AT em 0 (Zero)
  32. # Em batalhas surpresas (Surprise) é o inverso das batalhas preventivas.
  33. # Em batalhas normais todos os battlers começarão com AT em 40%.
  34. #==============================================================================
  35. # ● CAST TIME
  36. #==============================================================================
  37. # Para definir uma habilidade ou item com a função de Cast Time basta definir
  38. # o valor da velocidade (Speed) diferente de 0 (Zero).
  39. #
  40. # NOTA - Não é possível ativar 2 ou mais habilidades com a função Cast Time no
  41. # mesmo turno. (Caso você esteja usando características de Multi Action em
  42. # seu projeto.)
  43. #==============================================================================

  44. #==============================================================================
  45. # COMANDOS DE EVENTOS
  46. #==============================================================================
  47. #
  48. # atb_type(type)                - Define o tipo de ATB.
  49. # atb_max(X)                    - Define o tempo de ATB.
  50. # atb_stop                      - Pausa o ATB e o Turno.
  51. # atb_turn_speed(X)             - Define o tempo do turno.
  52. # atb_turn_stop                 - Pausa apenas o turno.
  53. # atb_turn_reset                - Zera o tempo do turno atual.
  54. # atb_sprite_turn(false)        - Ativar/Desativa o número do turno.
  55. #
  56. #==============================================================================

  57. #==============================================================================
  58. # Histórico
  59. #==============================================================================
  60. # v6.1 - Correção do crash na seleção de skills vazias.
  61. # v6.0 - Melhorias no sistema do evento comum.
  62. #==============================================================================

  63. $imported = {} if $imported.nil?
  64. $imported[:mog_atb_system] = true

  65. #==============================================================================
  66. # Cooperation Skills
  67. #==============================================================================
  68. module MOG_COOPERATION_SKILLS
  69.   COOPERATION_SKILLS = []  # ☢CAUTION!!☢ Don't Touch.^_^
  70.   #--------------------------------------------------------------------------
  71.   # Definição das skills
  72.   #
  73.   # COOPERATION_SKILLS[SKILL_ID] = [ACTOR_ID, ACTOR_ID, ACTOR_ID, ACTOR_ID]
  74.   #--------------------------------------------------------------------------

  75.   # COOPERATION_SKILLS[51] = [2,4]     # Fire
  76.   # COOPERATION_SKILLS[66] = [2,4,3]   # Quake
  77.   COOPERATION_SKILLS[104] = [1,2]      # Ouka Mugen jin
  78.   COOPERATION_SKILLS[143] = [3,4]      # Flare
  79.   COOPERATION_SKILLS[151] = [1,2,3,4]  # Ultima  
  80.   COOPERATION_SKILLS[153] = [2,4]      # W Ultima End
  81.   
  82.   
  83.   #--------------------------------------------------------------------------
  84.   #Definição da animação ao ativar as habilidades de cooperação.
  85.   #--------------------------------------------------------------------------
  86.   COOPERATION_SKILL_ANIMATION = 112  
  87. end

  88. #==============================================================================
  89. # GENERAL SETTING
  90. #==============================================================================
  91. module MOG_ATB_SYSTEM
  92.   #--------------------------------------------------------------------------
  93.   # Definição do tipo de ATB
  94.   #
  95.   # 0 - Wait
  96.   # 1 - Semi Active
  97.   # 2 - Full ACtive
  98.   #
  99.   # É possível mudar o tipo de ATB no meio do jogo usando o código abaixo.
  100.   #
  101.   # atb_type(type)
  102.   #
  103.   #--------------------------------------------------------------------------
  104.   ATB_TYPE = 0
  105.   #--------------------------------------------------------------------------
  106.   #Som quando o sistema ATB estiver no maximo
  107.   #--------------------------------------------------------------------------
  108.   SE_ACTIVE = "Decision2"
  109.   #--------------------------------------------------------------------------
  110.   # Definição do valor de ATB para ativar a ação.
  111.   # É possível mudar o valor no meio do jogo usando o código abaixo.
  112.   #
  113.   # atb_max(X)
  114.   #
  115.   #--------------------------------------------------------------------------
  116.   ATB_MAX = 5000
  117.   #--------------------------------------------------------------------------
  118.   # Definição do tipo de duração (Contagem/formula) de um turno.
  119.   # Essa definição influência na ativação dos eventos de batalha.
  120.   # (BATTLE EVENTS)
  121.   #
  122.   # 0 - Duração de um turno é um valor fixo.
  123.   # 1 - Duração de um turno é multiplicado pela quantidade de batllers.
  124.   # 2 - Duração de um turno é baseado na média de agilidade dos battlers.
  125.   #
  126.   #--------------------------------------------------------------------------
  127.   TURN_DURATION_TYPE = 0
  128.   #--------------------------------------------------------------------------
  129.   # Definição de valor usado para calcular a duração de um turno.
  130.   #--------------------------------------------------------------------------
  131.   TURN_DURATION = 500
  132.   #--------------------------------------------------------------------------
  133.   # Definição da animação quando o battler usa habilidades de carregamento.
  134.   #--------------------------------------------------------------------------
  135.   CAST_ANIMATION = 112
  136.   #--------------------------------------------------------------------------
  137.   # Ativar a mensagem inicial com os nomes dos inimigos.
  138.   #--------------------------------------------------------------------------
  139.   MESSAGE_ENEMY_APPEAR = false
  140.   #--------------------------------------------------------------------------
  141.   # Ativar o botão de pular turno.
  142.   #--------------------------------------------------------------------------
  143.   ENABLE_BUTTON_NEXT_ACTOR = true
  144.   #--------------------------------------------------------------------------
  145.   # Definição do botão pular turno.
  146.   #--------------------------------------------------------------------------
  147.   BUTTON_NEXT_ACTOR_RIGHT = :R
  148.   BUTTON_NEXT_ACTOR_LEFT = :L
  149.   #--------------------------------------------------------------------------
  150.   # Apresentar o Turno.
  151.   # É possível desativar / ativar o turno usando o código abaixo.
  152.   #
  153.   # atb_sprite_turn(false)
  154.   #
  155.   #--------------------------------------------------------------------------
  156.   DISPLAY_TURN_NUMBER = true
  157.   #--------------------------------------------------------------------------
  158.   # Definição da palavra Turno.
  159.   #--------------------------------------------------------------------------
  160.   TURN_WORD = "Turn "
  161.   #--------------------------------------------------------------------------
  162.   # Tamanho da fonte
  163.   #--------------------------------------------------------------------------
  164.   TURN_NUMBER_FONT_SIZE = 24
  165.   #--------------------------------------------------------------------------
  166.   # Ativar bold.
  167.   #--------------------------------------------------------------------------
  168.   TURN_NUMBER_FONT_BOLD = true
  169.   #--------------------------------------------------------------------------
  170.   # Posição Z.
  171.   #--------------------------------------------------------------------------
  172.   TURN_NUMBER_Z = 100
  173.   #--------------------------------------------------------------------------
  174.   # Posição X & Y.
  175.   #--------------------------------------------------------------------------
  176.   TURN_NUMBER_POS = [5,0]   
  177. end

  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. # ■ Game_System
  259. #==============================================================================
  260. class Game_System
  261.   
  262.   attr_accessor :atb_max
  263.   attr_accessor :atb_type
  264.   attr_accessor :atb_turn_duration
  265.   attr_accessor :atb_sprite_turn
  266.   
  267.   #--------------------------------------------------------------------------
  268.   # ● Initialize
  269.   #--------------------------------------------------------------------------         
  270.   alias mog_at_system_initialize initialize
  271.   def initialize
  272.       @atb_max = [[MOG_ATB_SYSTEM::ATB_MAX, 999999].min, 1500].max
  273.       @atb_type = MOG_ATB_SYSTEM::ATB_TYPE ; @atb_sprite_turn = true
  274.       @atb_turn_duration = [0,
  275.       [[MOG_ATB_SYSTEM::TURN_DURATION, 999999].min, 50].max]
  276.       mog_at_system_initialize
  277.   end
  278.   
  279. end

  280. #==============================================================================
  281. # ■ Game Interpreter
  282. #==============================================================================
  283. class Game_Interpreter
  284.   
  285.   #--------------------------------------------------------------------------
  286.   # ● ATB Type
  287.   #--------------------------------------------------------------------------         
  288.   def atb_type(type)
  289.       $game_system.atb_type = type
  290.   end
  291.   
  292.   #--------------------------------------------------------------------------
  293.   # ● ATB Max
  294.   #--------------------------------------------------------------------------         
  295.   def atb_max(value)
  296.       $game_system.atb_max = [[value, 999999].min, 1500].max
  297.   end
  298.   
  299.   #--------------------------------------------------------------------------
  300.   # ● ATB Sprite Turn
  301.   #--------------------------------------------------------------------------         
  302.   def atb_sprite_turn(value = true)
  303.       $game_system.atb_sprite_turn = value
  304.   end  
  305.   
  306.   #--------------------------------------------------------------------------
  307.   # ● ATB Turn Speed
  308.   #--------------------------------------------------------------------------         
  309.   def atb_turn_speed(value = 400)
  310.       $game_system.atb_turn_duration[1] = [[value, 999999].min, 50].max
  311.   end
  312.   
  313.   #--------------------------------------------------------------------------
  314.   # ● ATB force Turn
  315.   #--------------------------------------------------------------------------         
  316.   def atb_force_turn(value)
  317.       $game_troop.turn_count = value
  318.   end
  319.   
  320.   #--------------------------------------------------------------------------
  321.   # ● ATB Turn Reset
  322.   #--------------------------------------------------------------------------         
  323.   def atb_turn_reset
  324.       $game_system.atb_turn_duration[0] = 0
  325.   end
  326.   
  327.   #--------------------------------------------------------------------------
  328.   # ● Command 339
  329.   #--------------------------------------------------------------------------         
  330.   def command_339
  331.       iterate_battler(@params[0], @params[1]) do |battler|
  332.       next if battler.death_state?
  333.       battler.turn_clear
  334.       if BattleManager.actor!= nil and battler == BattleManager.actor
  335.          BattleManager.actor.turn_clear
  336.          $game_temp.break_command = true
  337.          BattleManager.command_selection_clear
  338.       end
  339.       battler.force_action(@params[2], @params[3])
  340.       BattleManager.force_action(battler)
  341.       Fiber.yield while BattleManager.action_forced?
  342.       end  
  343.   end
  344.    
  345. end

  346. #==============================================================================
  347. # ■ Game Troop
  348. #==============================================================================
  349. class Game_Troop < Game_Unit

  350.   #--------------------------------------------------------------------------
  351.   # ● Can Interpreter Running?
  352.   #--------------------------------------------------------------------------         
  353.   def can_interpreter_running?(tend = false)      
  354.       BattleManager.turn_end if tend
  355.       return true if $game_temp.common_event_reserved?
  356.       return false if @interpreter.running?      
  357.       return false if @interpreter.setup_reserved_common_event
  358.       troop.pages.each do |page|
  359.          next unless conditions_met?(page)
  360.          @current_page = page
  361.          return true
  362.       end   
  363.       return false
  364.    end   
  365.       
  366.   #--------------------------------------------------------------------------
  367.   # ● Can Interpreter Hide Window?
  368.   #--------------------------------------------------------------------------   
  369.   def can_interpreter_hide_window?      
  370.       return false if @current_page == nil
  371.       @current_page.list.each do |l|
  372.       if l.code.between?(101,105) ; @current_page = nil ; return true ; end
  373.       end
  374.       @current_page = nil
  375.       return false
  376.    end   
  377.       
  378.   #--------------------------------------------------------------------------
  379.   # ● Can Interpreter Hide Window 2?
  380.   #--------------------------------------------------------------------------   
  381.   def can_interpreter_hide_window_2?
  382.       return false if $game_temp.common_event_id == 0
  383.       common_event = $data_common_events[$game_temp.common_event_id] rescue nil
  384.       return false if common_event.nil?
  385.       common_event.list.each do |l|
  386.       return true if l.code.between?(101,105)
  387.       end
  388.       return false
  389.   end
  390.   
  391.   #--------------------------------------------------------------------------
  392.   # ● Set Turn
  393.   #--------------------------------------------------------------------------         
  394.   def set_turn(turn_value)
  395.       @turn_count = turn_value
  396.   end
  397.       
  398. end

  399. #==============================================================================
  400. # ■ Window Base
  401. #==============================================================================
  402. class Window_Base < Window
  403.   
  404.   #--------------------------------------------------------------------------
  405.   # ● Initialize
  406.   #--------------------------------------------------------------------------         
  407.   alias mog_atb_wbase_initialize initialize
  408.   def initialize(x, y, width, height)
  409.       mog_atb_wbase_initialize(x, y, width, height)
  410.       @pre_data = [0,self.visible,self.active,self.opacity]
  411.   end
  412.   
  413.   #--------------------------------------------------------------------------
  414.   # ● Hide All
  415.   #--------------------------------------------------------------------------         
  416.   def hide_all
  417.       @index = 0 if @index ; self.visible = false ; self.active = false
  418.       update
  419.   end
  420.   
  421.   #--------------------------------------------------------------------------
  422.   # ● Record Data
  423.   #--------------------------------------------------------------------------         
  424.   def record_data
  425.       @pre_data = [@index ,self.visible ,self.active ,self.opacity]
  426.       update
  427.   end
  428.   
  429.   #--------------------------------------------------------------------------
  430.   # ● Restore Data
  431.   #--------------------------------------------------------------------------         
  432.   def restore_data
  433.       @index = @pre_data[0] if @index ; self.visible = @pre_data[1]
  434.       self.active = @pre_data[2] ; self.opacity = @pre_data[3]
  435.       update
  436.   end
  437.   
  438. end

  439. #==============================================================================
  440. # ■ Window Selectable
  441. #==============================================================================
  442. class Window_Selectable < Window_Base
  443.   
  444.   attr_accessor :pre_data
  445.   
  446.   #--------------------------------------------------------------------------
  447.   # ● Row Max
  448.   #--------------------------------------------------------------------------
  449.   def row_max
  450.       cm = col_max > 0 ? col_max : 1
  451.       [(item_max + cm - 1) / cm, 1].max
  452.   end  
  453.   
  454.   #--------------------------------------------------------------------------
  455.   # ● Row
  456.   #--------------------------------------------------------------------------
  457.   def row
  458.       cm = col_max > 0 ? col_max : 1
  459.       index / cm
  460.   end  
  461.   
  462.   #--------------------------------------------------------------------------
  463.   # ● Item Width
  464.   #--------------------------------------------------------------------------
  465.   def item_width
  466.       cm = col_max > 0 ? col_max : 1
  467.       (width - standard_padding * 2 + spacing) / cm - spacing
  468.   end  
  469.   
  470.   #--------------------------------------------------------------------------
  471.   # ● Item Rect
  472.   #--------------------------------------------------------------------------
  473.   def item_rect(index)
  474.       cm = col_max > 0 ? col_max : 1
  475.       rect = Rect.new
  476.       rect.width = item_width
  477.       rect.height = item_height
  478.       rect.x = index % cm * (item_width + spacing)
  479.       rect.y = index / cm * item_height
  480.       rect
  481.   end  
  482.   
  483.   #--------------------------------------------------------------------------
  484.   # ● Initialize
  485.   #-------------------------------------------------------------------------
  486.   alias mog_atb_sel_initialize initialize
  487.   def initialize(x, y, width, height)
  488.       mog_atb_sel_initialize(x, y, width, height)
  489.       @pre_data = [@index,self.visible,self.active,self.opacity]
  490.   end  
  491.   
  492.   #--------------------------------------------------------------------------
  493.   # ● Process Cursor Move
  494.   #--------------------------------------------------------------------------
  495.   alias mog_atb_wactor_process_cursor_move process_cursor_move
  496.   def process_cursor_move
  497.       return if  SceneManager.scene_is?(Scene_Battle) and skip_command?
  498.       mog_atb_wactor_process_cursor_move
  499.   end

  500.   #--------------------------------------------------------------------------
  501.   # ● Process Handling
  502.   #--------------------------------------------------------------------------
  503.   alias mog_atb_wactor_process_handling process_handling
  504.   def process_handling  
  505.       return if SceneManager.scene_is?(Scene_Battle) and skip_command?
  506.       mog_atb_wactor_process_handling
  507.   end   
  508.    
  509.   #--------------------------------------------------------------------------
  510.   # ● Process Handling
  511.   #--------------------------------------------------------------------------
  512.   def skip_command?
  513.       return false if self.is_a?(Window_VictorySpoils) if $imported["YEA-VictoryAftermath"]
  514.       return true if !$game_temp.sprite_visible
  515.       return true if $game_temp.battle_end
  516.       return true if $game_temp.end_phase_duration[1] > 0
  517.       return true if BattleManager.actor == nil
  518.       return false  
  519.   end  
  520.   
  521. end

  522. #==============================================================================
  523. # ■ Window_ActorCommand
  524. #==============================================================================
  525. class Window_ActorCommand < Window_Command
  526.   
  527.   attr_accessor :actor
  528.   
  529.   #--------------------------------------------------------------------------
  530.   # ● Update
  531.   #--------------------------------------------------------------------------
  532.   alias mog_atb_ac_update update
  533.   def update
  534.       mog_atb_ac_update
  535.       $game_temp.actor_command_index = self.index if self.active
  536.   end
  537.   
  538.   if MOG_ATB_SYSTEM::ENABLE_BUTTON_NEXT_ACTOR
  539.   #--------------------------------------------------------------------------
  540.   # ● Process_Cursor Move
  541.   #--------------------------------------------------------------------------
  542.   def process_cursor_move
  543.       return unless cursor_movable?
  544.       last_index = @index
  545.       cursor_down (Input.trigger?(:DOWN))  if Input.repeat?(:DOWN)
  546.       cursor_up   (Input.trigger?(:UP))    if Input.repeat?(:UP)
  547.       cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
  548.       cursor_left (Input.trigger?(:LEFT))  if Input.repeat?(:LEFT)
  549.       Sound.play_cursor if @index != last_index
  550.   end
  551.   end
  552.   
  553.   if $imported["YEA-BattleEngine"]
  554.   #--------------------------------------------------------------------------
  555.   # ● Process_dir4
  556.   #--------------------------------------------------------------------------
  557.   def process_dir4
  558.   end
  559.   
  560.   #--------------------------------------------------------------------------
  561.   # ● Process_dir6
  562.   #--------------------------------------------------------------------------
  563.   def process_dir6
  564.   end  
  565.   end  
  566.   
  567.   #--------------------------------------------------------------------------
  568.   # ● Process Cursor Move
  569.   #--------------------------------------------------------------------------  
  570.   alias mog_atb_bm_process_cursor_move process_cursor_move
  571.   def process_cursor_move
  572.       return if SceneManager.scene_is?(Scene_Battle) and BattleManager.actor == nil
  573.       mog_atb_bm_process_cursor_move
  574.   end
  575.   
  576.   #--------------------------------------------------------------------------
  577.   # ● Process Handling
  578.   #--------------------------------------------------------------------------   
  579.   alias mog_atb_bm_process_handling process_handling
  580.   def process_handling
  581.       return if SceneManager.scene_is?(Scene_Battle) and BattleManager.actor == nil
  582.       mog_atb_bm_process_handling
  583.   end  
  584.   
  585. end

  586. #==============================================================================
  587. # ■ Window_BattleEnemy
  588. #==============================================================================
  589. class Window_BattleEnemy < Window_Selectable

  590.   #--------------------------------------------------------------------------
  591.   # ● Refresh
  592.   #--------------------------------------------------------------------------  
  593.   alias mog_atb_battle_enemy_update update
  594.   def update
  595.       return if enemy == nil      
  596.       mog_atb_battle_enemy_update
  597.   end
  598.   
  599. end

  600. #==============================================================================
  601. # ■ Window BattleLog
  602. #==============================================================================
  603. class Window_BattleLog < Window_Selectable
  604.   
  605.   #--------------------------------------------------------------------------
  606.   # ● Display Added States
  607.   #--------------------------------------------------------------------------   
  608.   def display_added_states(target)
  609.       return if target.turn_collapse
  610.       target.result.added_state_objects.each do |state|
  611.          state_msg = target.actor? ? state.message1 : state.message2
  612.          if state.id == target.death_state_id
  613.             target.perform_collapse_effect if target.hp == 0
  614.          end
  615.          next if state_msg.empty?
  616.          replace_text(target.name + state_msg)
  617.          target.turn_collapse = true if state.id == target.death_state_id
  618.          wait
  619.          wait_for_effect
  620.       end
  621.   end  
  622.   
  623.   #--------------------------------------------------------------------------
  624.   # ● Refresh
  625.   #--------------------------------------------------------------------------   
  626.   def refresh
  627.   end  

  628.   #--------------------------------------------------------------------------
  629.   # ● Message Speed
  630.   #--------------------------------------------------------------------------   
  631.   def message_speed
  632.       return 10 if $imported["YEA-BattleEngine"]
  633.       return 5
  634.   end

  635.   #--------------------------------------------------------------------------
  636.   # * Wait for Effect
  637.   #--------------------------------------------------------------------------
  638.   def wait_for_effect
  639.       return false
  640.   end  

  641. end

  642. #==============================================================================
  643. # ■ Sprite Battler
  644. #==============================================================================
  645. class Sprite_Battler < Sprite_Base
  646.   
  647.   #--------------------------------------------------------------------------
  648.   # ● Update
  649.   #--------------------------------------------------------------------------      
  650.   alias mog_atb_sprite_update update
  651.   def update      
  652.       mog_atb_sprite_update
  653.       clear_atb_battler_dead if clear_atb_battler_dead?
  654.   end
  655.   
  656.   #--------------------------------------------------------------------------
  657.   # ● Init Visibility
  658.   #--------------------------------------------------------------------------      
  659.   alias mog_atb_init_visibility init_visibility
  660.   def init_visibility
  661.       self.visible = true
  662.       self.opacity = 255 if @battler.alive?
  663.       mog_atb_init_visibility
  664.   end
  665.   
  666.   #--------------------------------------------------------------------------
  667.   # ● Clear ATB Battler
  668.   #--------------------------------------------------------------------------      
  669.   def clear_atb_battler_dead?
  670.       return false if !self.visible
  671.       return false if @battler.nil?
  672.       return false if !@battler.dead?
  673.       return false if @battler.is_a?(Game_Actor)
  674.       return false if !@effect_type.nil?
  675.       return false if $imported[:mog_battler_motion] and !@collapse_done
  676.       return true
  677.   end
  678.   
  679.   #--------------------------------------------------------------------------
  680.   # ● Clear ATB Battler Dead
  681.   #--------------------------------------------------------------------------      
  682.   def clear_atb_battler_dead
  683.       self.opacity = 0
  684.       self.visible = false
  685.       @battler.atb_initial
  686.   end
  687.   
  688. end

  689. #==============================================================================
  690. # ■ Game Battler Base
  691. #==============================================================================
  692. class Game_BattlerBase  
  693.   
  694.   attr_accessor :hidden
  695.   
  696.   #--------------------------------------------------------------------------
  697.   # ● Inputable?
  698.   #--------------------------------------------------------------------------            
  699.   def inputable?
  700.       normal? && !auto_battle? && self.atb_max?
  701.   end
  702.   
  703. end

  704. #==============================================================================
  705. # ■ Game_Battler
  706. #==============================================================================
  707. class Game_Battler < Game_BattlerBase
  708.   
  709.    attr_accessor :atb
  710.    attr_accessor :atb_max
  711.    attr_accessor :atb_cast
  712.    attr_accessor :atb_action
  713.    attr_accessor :atb_turn_duration
  714.    attr_accessor :atb_escape
  715.    attr_accessor :next_turn
  716.    attr_accessor :turn_collapse
  717.    attr_accessor :actions
  718.    
  719.   #--------------------------------------------------------------------------
  720.   # ● Initialize
  721.   #--------------------------------------------------------------------------      
  722.    alias mog_at_system_initialize initialize
  723.    def initialize
  724.        mog_at_system_initialize
  725.        atb_init_setup
  726.    end
  727.    
  728.   #--------------------------------------------------------------------------
  729.   # ● Atb Init Setup
  730.   #--------------------------------------------------------------------------      
  731.    def atb_init_setup
  732.        @atb = 0
  733.        @atb_max = $game_system.atb_max
  734.        @atb_cast = []
  735.        @atb_turn_duration = 0
  736.        @next_turn = false
  737.        @atb_escape = false
  738.        @turn_collapse = false
  739.        @wait_motion = $imported[:mog_battler_motion] != nil ? true : false
  740.    end     
  741.    
  742.   #--------------------------------------------------------------------------
  743.   # ● Atb
  744.   #--------------------------------------------------------------------------         
  745.    def atb
  746.        return 0 if self.hp == 0
  747.        return [[@atb, atb_max].min, 0].max
  748.    end  
  749.    
  750.   #--------------------------------------------------------------------------
  751.   # ● Max ATB
  752.   #--------------------------------------------------------------------------         
  753.    def atb_max
  754.        return [$game_system.atb_max,100].max
  755.    end   
  756.    
  757.   #--------------------------------------------------------------------------
  758.   # ● Max AT?
  759.   #--------------------------------------------------------------------------         
  760.    def atb_max?
  761.        self.atb >= atb_max
  762.    end
  763.    
  764.   #--------------------------------------------------------------------------
  765.   # ● Atb Speed
  766.   #--------------------------------------------------------------------------         
  767.    def atb_speed
  768.        return self.agi
  769.    end
  770.   
  771.   #--------------------------------------------------------------------------
  772.   # ● ATB Update
  773.   #--------------------------------------------------------------------------   
  774.   def atb_update?
  775.       return false if restriction >= 4
  776.       return false if self.hp == 0
  777.       return false if self.hidden
  778.       return false if @wait_motion && $game_temp.battler_in_motion
  779.       return true
  780.   end

  781.   #--------------------------------------------------------------------------
  782.   # ● ATB Update
  783.   #--------------------------------------------------------------------------   
  784.   def atb_update
  785.       return if !atb_update?
  786.       if self.atb_cast.empty?
  787.          if !atb_max?
  788.             self.atb += self.atb_speed
  789.             execute_atb_max_effect if atb_max?
  790.          end   
  791.       else   
  792.          self.atb_cast[1] -= 1
  793.          execute_cast_action if self.atb_cast[1] <= 0
  794.       end
  795.   end
  796.   
  797.   #--------------------------------------------------------------------------
  798.   # ● Execute Atb Max Effect
  799.   #--------------------------------------------------------------------------   
  800.   def execute_atb_max_effect
  801.       $game_temp.refresh_item_window = true if need_refresh_item_window?
  802.       $game_temp.add_order(self)
  803.   end
  804.   
  805.   #--------------------------------------------------------------------------
  806.   # ● Need Refresh Item Window?
  807.   #--------------------------------------------------------------------------   
  808.   def need_refresh_item_window?
  809.       return false
  810.   end
  811.   
  812.   #--------------------------------------------------------------------------
  813.   # ● Execute Cast Action
  814.   #--------------------------------------------------------------------------   
  815.   def execute_cast_action
  816.       self.next_turn = true ; self.atb = self.atb_max ; self.atb_cast.clear
  817.   end
  818.   
  819.   #--------------------------------------------------------------------------
  820.   # ● Atb Clear
  821.   #--------------------------------------------------------------------------   
  822.   def atb_clear
  823.       self.atb = 0 ; self.atb_cast.clear ; self.turn_collapse = false
  824.   end
  825.    
  826.   #--------------------------------------------------------------------------
  827.   # ● Atb Initial
  828.   #--------------------------------------------------------------------------   
  829.   def atb_initial
  830.       @atb = 0 ; @atb_cast = [] ; @atb_turn_duration = 0
  831.       @atb_escape = false ; @next_turn = false ; clear_actions
  832.   end     
  833.       
  834.   #--------------------------------------------------------------------------
  835.   # ● Movable ATB
  836.   #--------------------------------------------------------------------------   
  837.   def movable_atb?
  838.       return false if !atb_max?
  839.       return false if self.dead?
  840.       return false if self.restriction != 0
  841.       return false if self.next_turn
  842.       return false if !self.atb_cast.empty?
  843.       return true
  844.   end
  845.   
  846.   #--------------------------------------------------------------------------
  847.   # ● Item Apply
  848.   #--------------------------------------------------------------------------  
  849.   alias mog_atb_item_apply item_apply
  850.   def item_apply(user, item)      
  851.       pre_item = self.current_action.item rescue nil
  852.       mog_atb_item_apply(user, item)      
  853.       if SceneManager.scene_is?(Scene_Battle)
  854.          effect_for_dead if self.dead?
  855.          atb_after_damage(pre_item)
  856.       end   
  857.   end  

  858.   #--------------------------------------------------------------------------
  859.   # ● ATB After Damage
  860.   #--------------------------------------------------------------------------  
  861.   def atb_after_damage(pre_item = nil)
  862.       $game_temp.break_command = true if can_damage_break_command?
  863.       turn_clear if self.restriction == 4 or self.dead?
  864.       $game_temp.remove_order(self) if self.restriction > 0 or self.dead?
  865.       $game_temp.battle_end2 = true if $game_troop.all_dead? or $game_party.all_dead?
  866.   end

  867.   #--------------------------------------------------------------------------
  868.   # ● Can Damage Break Command
  869.   #--------------------------------------------------------------------------  
  870.   def can_damage_break_command?
  871.       return false if BattleManager.actor == nil
  872.       return false if BattleManager.actor != self
  873.       return true if BattleManager.actor.restriction > 0
  874.       return true if BattleManager.actor.dead?
  875.       return true if BattleManager.actor.hp == 0
  876.       return false
  877.   end
  878.   
  879.   #--------------------------------------------------------------------------
  880.   # ● Turn Clear
  881.   #--------------------------------------------------------------------------  
  882.   def turn_clear
  883.       self.atb_clear
  884.       self.atb_escape = false
  885.       self.clear_actions
  886.       self.next_turn = false
  887.       $game_temp.remove_order(self)
  888.   end  
  889.   
  890.   #--------------------------------------------------------------------------
  891.   # ● Effect for Dead
  892.   #--------------------------------------------------------------------------  
  893.   def effect_for_dead      
  894.       atb_initial
  895.       $game_temp.refresh_target_windows[0] = true if self.is_a?(Game_Actor)
  896.       $game_temp.refresh_target_windows[1] = true if self.is_a?(Game_Enemy)
  897.       if $imported[:mog_battle_cursor]
  898.          $game_temp.battle_cursor_need_refresh[0] = true if self.is_a?(Game_Actor)
  899.          $game_temp.battle_cursor_need_refresh[1] = true if self.is_a?(Game_Enemy)
  900.       end         
  901.   end
  902.   
  903.   #--------------------------------------------------------------------------
  904.   # ● Remove State Auto
  905.   #--------------------------------------------------------------------------  
  906.   alias mog_atb_remove_states_auto remove_states_auto
  907.   def remove_states_auto(timing)
  908.       if SceneManager.scene_is?(Scene_Battle)
  909.          remove_states_auto_atb(timing) ; return
  910.       end
  911.       mog_atb_remove_states_auto(timing)
  912.   end  

  913.   #--------------------------------------------------------------------------
  914.   # ● Remove State Auto ATB
  915.   #--------------------------------------------------------------------------  
  916.   def remove_states_auto_atb(timing)
  917.       states.each do |state|
  918.       if @state_turns[state.id] == 0
  919.          if restriction == 4 ; remove_state(state.id) ; return ; end
  920.             unless state.auto_removal_timing == 2 and state.max_turns <= 1
  921.             remove_state(state.id)
  922.             end
  923.          end
  924.       end
  925.   end  

  926.   #--------------------------------------------------------------------------
  927.   # ● Remove State Turn End
  928.   #--------------------------------------------------------------------------  
  929.   def remove_state_turn_end
  930.       states.each do |state|
  931.          next if state.auto_removal_timing != 2
  932.          next if state.max_turns > 1
  933.          remove_state(state.id)
  934.       end
  935.   end  
  936.   
  937.   #--------------------------------------------------------------------------
  938.   # ● Die
  939.   #--------------------------------------------------------------------------  
  940.   alias mog_atb_die die
  941.   def die
  942.       mog_atb_die
  943.       self.turn_clear ; self.atb_turn_duration = 0
  944.   end
  945.   
  946.   #--------------------------------------------------------------------------
  947.   # ● Revive
  948.   #--------------------------------------------------------------------------  
  949.   alias mog_atb_revive revive
  950.   def revive
  951.       mog_atb_revive
  952.       self.turn_clear ; per = 25 * self.atb_max / 100 ; self.atb = rand(per)
  953.       self.atb_turn_duration = 0
  954.   end  
  955.   
  956.   #--------------------------------------------------------------------------
  957.   # ● Create Battle Action
  958.   #--------------------------------------------------------------------------
  959.   alias mog_atb_make_actions make_actions
  960.   def make_actions
  961.       return if !self.atb_cast.empty?
  962.       item = self.current_action.item rescue nil
  963.       return if item != nil
  964.       mog_atb_make_actions
  965.   end  
  966.   
  967. end

  968. #==============================================================================
  969. # ■ Game Enemy
  970. #==============================================================================
  971. class Game_Enemy < Game_Battler
  972.   
  973.   #--------------------------------------------------------------------------
  974.   # ● Tranform
  975.   #--------------------------------------------------------------------------  
  976.    alias mog_at_system_transform transform
  977.    def transform(enemy_id)
  978.        mog_at_system_transform(enemy_id)
  979.        self.atb_clear
  980.    end
  981.      
  982. end

  983. #==============================================================================
  984. # ■ BattleManager
  985. #==============================================================================
  986. module BattleManager
  987.   
  988.   #--------------------------------------------------------------------------
  989.   # ● Start Command Input
  990.   #--------------------------------------------------------------------------
  991.   def self.input_start
  992.       @phase = :input if @phase != :input
  993.       return !@surprise && $game_party.inputable?
  994.   end
  995.   
  996.   #--------------------------------------------------------------------------
  997.   # ● Battle Start
  998.   #--------------------------------------------------------------------------  
  999.   def self.battle_start
  1000.       $game_system.battle_count += 1
  1001.       $game_party.on_battle_start
  1002.       $game_troop.on_battle_start
  1003.       atb_initial_setup ; @turn_duration = set_turn_duration
  1004.       if MOG_ATB_SYSTEM::MESSAGE_ENEMY_APPEAR
  1005.          $game_troop.enemy_names.each do |name|
  1006.          $game_message.add(sprintf(Vocab::Emerge, name))
  1007.          end
  1008.       end
  1009.       if @preemptive
  1010.          $game_message.add(sprintf(Vocab::Preemptive, $game_party.name))
  1011.       elsif @surprise
  1012.          $game_message.add(sprintf(Vocab::Surprise, $game_party.name))
  1013.       end
  1014.       wait_for_message ; @preemptive = false ; @surprise = false
  1015.   end
  1016.   
  1017.   #--------------------------------------------------------------------------
  1018.   # ● ATB Initial Setup
  1019.   #--------------------------------------------------------------------------  
  1020.   def self.atb_initial_setup
  1021.       battlers.each do |battler|
  1022.       battler.atb_initial ; initial_atb_parameter(battler)
  1023.       end
  1024.   end
  1025.   
  1026.   #--------------------------------------------------------------------------
  1027.   # ● Initial ATB Parameter
  1028.   #--------------------------------------------------------------------------  
  1029.   def self.initial_atb_parameter(battler)
  1030.       @at_phase = 0
  1031.       nt = battler.atb_max * 30 / 100
  1032.       st = battler.atb_max * 20 / 100      
  1033.       pt = battler.atb_max * 65 / 100
  1034.       n_at = rand(nt) ; p_at = pt + rand(nt) ; s_at = rand(st)        
  1035.       if BattleManager.preemptive_attack
  1036.          battler.atb = p_at if battler.is_a?(Game_Actor)
  1037.          battler.atb = s_at if battler.is_a?(Game_Enemy)
  1038.       elsif BattleManager.surprise_attack   
  1039.          battler.atb = p_at if battler.is_a?(Game_Enemy)
  1040.          battler.atb = s_at if battler.is_a?(Game_Actor)
  1041.       else   
  1042.          battler.atb = n_at
  1043.       end
  1044.       battler.atb = battler.atb_max - 1  if battler.atb >= battler.atb_max
  1045.       battler.turn_clear if battler.dead? or battler.restriction == 4
  1046.   end
  1047.   
  1048.   #--------------------------------------------------------------------------
  1049.   # ● Set Turn Duration
  1050.   #--------------------------------------------------------------------------  
  1051.   def self.set_turn_duration
  1052.       max_battlers = battlers.size > 0 ? battlers.size : 1      
  1053.       case MOG_ATB_SYSTEM::TURN_DURATION_TYPE
  1054.         when 1 ; n  = $game_system.atb_turn_duration[1] * max_battlers         
  1055.         when 2
  1056.            turn_sp = 0
  1057.            battlers.each do |battler| turn_sp += battler.agi ; end  
  1058.            n = $game_system.atb_turn_duration[1] + (turn_sp / max_battlers)
  1059.         else ; n = $game_system.atb_turn_duration[1]
  1060.       end
  1061.       n2 = [[n, 9999].min, 120].max     
  1062.       battlers.each do |battler|
  1063.           perc = 30 * n2 / 100
  1064.           battler.atb_turn_duration = rand(perc)      
  1065.       end  
  1066.       return n2
  1067.   end
  1068.   
  1069.   #--------------------------------------------------------------------------
  1070.   # ● Force Clear Battler ATB
  1071.   #--------------------------------------------------------------------------  
  1072.   def self.force_clear_battler_atb
  1073.       battlers.each do |battler|
  1074.       battler.turn_clear if battler.dead? or battler.restriction == 4
  1075.       end
  1076.   end
  1077.   
  1078.   #--------------------------------------------------------------------------
  1079.   # ● Turn Start
  1080.   #--------------------------------------------------------------------------
  1081.   def self.turn_start   
  1082.       @phase = :turn ; clear_actor
  1083.   end  
  1084.   
  1085.   #--------------------------------------------------------------------------
  1086.   # ● Preemtive Attack
  1087.   #--------------------------------------------------------------------------  
  1088.   def self.preemptive_attack
  1089.       @preemptive
  1090.   end  
  1091.   
  1092.   #--------------------------------------------------------------------------
  1093.   # ● Suprise Attack
  1094.   #--------------------------------------------------------------------------   
  1095.   def self.surprise_attack
  1096.       @surprise
  1097.   end

  1098.   #--------------------------------------------------------------------------
  1099.   # ● Battlers
  1100.   #--------------------------------------------------------------------------   
  1101.   def self.battlers
  1102.       return $game_troop.members + $game_party.battle_members
  1103.   end  
  1104.   
  1105.   #--------------------------------------------------------------------------
  1106.   # ● Update ATB
  1107.   #--------------------------------------------------------------------------   
  1108.   def update_atb?
  1109.       return false if @atb_in_turn
  1110.       return true
  1111.   end
  1112.   
  1113.   #--------------------------------------------------------------------------
  1114.   # ● Update ATB
  1115.   #--------------------------------------------------------------------------   
  1116.   def self.update_atb
  1117.       return if $game_temp.atb_wait
  1118.       return if $game_temp.end_phase_duration[1] > 0
  1119.       return if $game_temp.battle_end      
  1120.       return if $game_temp.atb_frame_skip > 0
  1121.       return @current_battler if @current_battler
  1122.       for battler in battlers
  1123.           next if !battler_update?(battler)
  1124.           battler.atb_update
  1125.           update_battler_turn(battler)
  1126.           @current_battler = set_current_battler(battler)
  1127.           break if $game_temp.atb_frame_skip > 0
  1128.       end
  1129.       return nil
  1130.   end
  1131.   
  1132.   #--------------------------------------------------------------------------
  1133.   # ● Battler Update?
  1134.   #--------------------------------------------------------------------------   
  1135.   def self.battler_update?(battler)
  1136.       return false if battler.dead? or battler.hp == 0
  1137.       return true
  1138.   end

  1139.   #--------------------------------------------------------------------------
  1140.   # ● Update Battler Turn
  1141.   #--------------------------------------------------------------------------   
  1142.   def self.update_battler_turn(battler)
  1143.       return if @turn_duration == nil
  1144.       battler.atb_turn_duration += 1
  1145.       return if battler.atb_turn_duration < @turn_duration
  1146.       battler.atb_turn_duration = 0
  1147.       old_battler = battler
  1148.       battler.on_turn_end
  1149.       @refresh_status = true
  1150.   end
  1151.   
  1152.   #--------------------------------------------------------------------------
  1153.   # ● Set Current Battler
  1154.   #--------------------------------------------------------------------------   
  1155.   def self.set_current_battler(battler)
  1156.       return @current_battler if @current_battler
  1157.       return nil if !battler.atb_max?
  1158.       if battler.next_turn
  1159.          battler.remove_state_turn_end            
  1160.          $game_temp.remove_order(battler)
  1161.          return battler
  1162.       end
  1163.       if battler.is_a?(Game_Actor)
  1164.         if BattleManager.actor == nil         
  1165.             if $game_temp.actor_process_event != nil
  1166.                enable_actor_command?($game_temp.actor_process_event)
  1167.                prepare_actor_command($game_temp.actor_process_event)      
  1168.                $game_temp.actor_process_event = nil
  1169.             elsif $game_temp.atb_actor_order[0] != nil and
  1170.                 enable_actor_command?($game_temp.atb_actor_order[0])
  1171.                 prepare_actor_command($game_temp.atb_actor_order[0])
  1172.             else
  1173.                 prepare_actor_command(battler) if enable_actor_command?(battler)
  1174.                 if battler_confusion?(battler)                  
  1175.                    battler.make_actions
  1176.                    battler.next_turn = true if !can_execute_cast_action?(battler)
  1177.                 end      
  1178.              end
  1179.          else      
  1180.              if battler_confusion?(battler)                  
  1181.                 battler.make_actions
  1182.                 battler.next_turn = true if !can_execute_cast_action?(battler)
  1183.              end
  1184.          end
  1185.      else
  1186.          battler.make_actions
  1187.          battler.next_turn = true if !can_execute_cast_action?(battler)
  1188.       end   
  1189.       return nil
  1190.   end
  1191.   
  1192.   #--------------------------------------------------------------------------
  1193.   # ●  Enable Actor Command
  1194.   #--------------------------------------------------------------------------   
  1195.   def self.battler_confusion?(battler)
  1196.       return false if battler.hp == 0 or battler.dead?
  1197.       return true if battler.confusion?
  1198.       return false
  1199.   end
  1200.   
  1201.   #--------------------------------------------------------------------------
  1202.   # ●  Enable Actor Command
  1203.   #--------------------------------------------------------------------------   
  1204.   def self.enable_actor_command?(battler)
  1205.       return false if @command_actor != nil
  1206.       return false if battler.dead?
  1207.       return false if battler.restriction != 0
  1208.       return true
  1209.   end  
  1210.       
  1211.   #--------------------------------------------------------------------------
  1212.   # ● Prepare Actor Command
  1213.   #--------------------------------------------------------------------------   
  1214.   def self.prepare_actor_command(battler)
  1215.       battler.remove_state_turn_end      
  1216.       @command_actor = battler ; @command_selection = true
  1217.       $game_temp.remove_order(battler)      
  1218.   end
  1219.   
  1220.   #--------------------------------------------------------------------------
  1221.   # ● Can Execute Cast Action?
  1222.   #--------------------------------------------------------------------------   
  1223.   def self.can_execute_cast_action?(battler)
  1224.       item = battler.current_action.item rescue nil  
  1225.       return false if item == nil
  1226.       if item.speed != 0 and battler.atb_cast.empty?
  1227.          battler.atb_cast = [item,item.speed.abs,0]
  1228.          battler.animation_id = MOG_ATB_SYSTEM::CAST_ANIMATION
  1229.          battler.atb = 0
  1230.          return true
  1231.       end   
  1232.       return false
  1233.   end
  1234.   
  1235.   #--------------------------------------------------------------------------
  1236.   # ● Actor in turn
  1237.   #--------------------------------------------------------------------------   
  1238.   def self.actor_command?
  1239.       return false if !@command_selection
  1240.       return false if @command_actor == nil
  1241.       if @command_actor.restriction != 0
  1242.          @command_selection = false
  1243.          return false
  1244.       end   
  1245.       @command_selection = false      
  1246.       return true
  1247.   end
  1248.   
  1249.   #--------------------------------------------------------------------------
  1250.   # ● Current Battler Clear
  1251.   #--------------------------------------------------------------------------   
  1252.   def self.current_battler_clear(subject)
  1253.       return if subject == nil
  1254.       return if @current_battler == nil
  1255.       return if @current_battler != subject
  1256.       @current_battler.atb_clear
  1257.       @current_battler.atb_escape = false
  1258.       @current_battler.clear_actions
  1259.       @current_battler.next_turn = false
  1260.       @current_battler = nil
  1261.   end  
  1262.   
  1263.   #--------------------------------------------------------------------------
  1264.   # ● Command Selection Clear
  1265.   #--------------------------------------------------------------------------   
  1266.   def self.command_selection_clear
  1267.       $game_temp.remove_order(@command_actor)
  1268.       @command_selection = false ; @command_actor = nil
  1269.       $game_temp.actor_command_index = 0
  1270.   end
  1271.   
  1272.   #--------------------------------------------------------------------------
  1273.   # ● Command Selection
  1274.   #--------------------------------------------------------------------------   
  1275.   def self.command_selection?
  1276.       @command_selection
  1277.   end
  1278.   
  1279.   #--------------------------------------------------------------------------
  1280.   # ● Command Selection need clear?
  1281.   #--------------------------------------------------------------------------   
  1282.   def self.command_need_clear?
  1283.       return true if @command_actor == nil and @command_selection
  1284.       return false
  1285.   end
  1286.    
  1287.   #--------------------------------------------------------------------------
  1288.   # ● Next Command
  1289.   #--------------------------------------------------------------------------   
  1290.   def self.next_command
  1291.       if @command_actor ; @command_actor.make_actions ; return true ;end
  1292.       return false
  1293.   end  
  1294.   
  1295.   #--------------------------------------------------------------------------
  1296.   # ● Command End
  1297.   #--------------------------------------------------------------------------   
  1298.   def self.command_end
  1299.       $game_temp.remove_order(@command_actor)
  1300.       @command_selection = false
  1301.       $game_temp.actor_command_index = 0
  1302.       command_end_actor if @command_actor
  1303.       @command_actor = nil
  1304.   end

  1305.   #--------------------------------------------------------------------------
  1306.   # ● Command End Actor
  1307.   #--------------------------------------------------------------------------   
  1308.   def self.command_end_actor
  1309.       item = @command_actor.current_action.item rescue nil  
  1310.       set_cast_action(item) if set_cast_action?(item)
  1311.       @command_actor.next_turn = true if @command_actor != nil
  1312.       @current_battler = @command_actor if @current_battler == nil
  1313.       $game_temp.actor_process_event = nil
  1314.   end
  1315.       
  1316.   #--------------------------------------------------------------------------
  1317.   # ● Set Cast Action?
  1318.   #--------------------------------------------------------------------------   
  1319.   def self.set_cast_action?(item)
  1320.       if item.is_a?(RPG::Skill)
  1321.          return false if @command_actor.guard_skill_id == item.id
  1322.       end
  1323.       return false if item.nil?
  1324.       return false if item.speed == 0
  1325.       return false if !@command_actor.atb_cast.empty?
  1326.       return true
  1327.   end
  1328.   
  1329.   #--------------------------------------------------------------------------
  1330.   # ● Set Cast Action
  1331.   #--------------------------------------------------------------------------   
  1332.   def self.set_cast_action(item)
  1333.       if item.speed.abs > 10
  1334.          @command_actor.atb_cast = [item,item.speed.abs,0]
  1335.       else   
  1336.          @command_actor.atb_cast = [item,10,10]
  1337.       end  
  1338.       @command_actor.animation_id = MOG_ATB_SYSTEM::CAST_ANIMATION
  1339.       @command_actor.atb = 0 ; @command_actor.next_turn = false
  1340.       @command_actor = nil
  1341.   end      
  1342.    
  1343.   #--------------------------------------------------------------------------
  1344.   # ● End Turn
  1345.   #--------------------------------------------------------------------------
  1346.   def self.in_turn?
  1347.       return $game_temp.atb_in_turn
  1348.   end  

  1349.   #--------------------------------------------------------------------------
  1350.   # ● Set Refresh Status
  1351.   #--------------------------------------------------------------------------
  1352.   def self.set_refresh_status(value)
  1353.       @refresh_status = value
  1354.   end
  1355.   
  1356.   #--------------------------------------------------------------------------
  1357.   # ● Refresh Status
  1358.   #--------------------------------------------------------------------------
  1359.   def self.refresh_status?
  1360.       @refresh_status
  1361.   end
  1362.   
  1363.   #--------------------------------------------------------------------------
  1364.   # ● Actor
  1365.   #--------------------------------------------------------------------------
  1366.   def self.actor
  1367.       @command_actor
  1368.   end

  1369.   #--------------------------------------------------------------------------
  1370.   # ● Cancel Actor Command
  1371.   #--------------------------------------------------------------------------
  1372.   def self.cancel_actor_command(minus = false)
  1373.       @command_selection = false
  1374.       return if @command_actor == nil
  1375.       @command_actor.atb = (@command_actor.atb * 80 / 100).truncate if minus
  1376.       @command_actor = nil
  1377.       $game_temp.actor_command_index = 0
  1378.   end
  1379.   
  1380.   #--------------------------------------------------------------------------
  1381.   # ● Battler
  1382.   #--------------------------------------------------------------------------
  1383.   def self.set_battler_in_turn(battler)
  1384.       @battler_in_turn = battler
  1385.   end
  1386.   
  1387.   #--------------------------------------------------------------------------
  1388.   # ● Battler in turn?
  1389.   #--------------------------------------------------------------------------
  1390.   def self.battler_in_turn?(battler)
  1391.       return true if @battler_in_turn == battler
  1392.       return false
  1393.   end
  1394.   
  1395.   #--------------------------------------------------------------------------
  1396.   # ● Turn Start ABS
  1397.   #--------------------------------------------------------------------------
  1398.   def self.turn_start_abs
  1399.       @phase = :turn        
  1400.   end
  1401.    
  1402.   #--------------------------------------------------------------------------
  1403.   # ● Set Subject
  1404.   #--------------------------------------------------------------------------
  1405.   def self.set_subject(subject)
  1406.       @subject = subject
  1407.   end

  1408.   #--------------------------------------------------------------------------
  1409.   # ● Subject
  1410.   #--------------------------------------------------------------------------
  1411.   def self.subject
  1412.       @subject
  1413.   end  
  1414.   
  1415. end  

  1416. #==============================================================================
  1417. # ■ BattleManager
  1418. #==============================================================================
  1419. class << BattleManager
  1420.   
  1421.   #--------------------------------------------------------------------------
  1422.   # ● Init Members
  1423.   #--------------------------------------------------------------------------
  1424.   alias mog_atb_init_members init_members
  1425.   def init_members
  1426.       mog_atb_init_members
  1427.       set_init_atb_data
  1428.   end
  1429.   
  1430.   #--------------------------------------------------------------------------
  1431.   # ● Set Init ATB Data
  1432.   #--------------------------------------------------------------------------
  1433.   def set_init_atb_data
  1434.       @current_battler = nil ; @actor_in_turn = nil ; @command_selection = nil
  1435.       @atb_target_index = nil ; @command_actor = nil ; $game_temp.atb_user = nil
  1436.       $game_temp.turn_duration_clear = false ; $game_temp.battle_end = false
  1437.       $game_temp.atb_in_turn = true ; $game_temp.atb_wait = false
  1438.       @turn_duration = set_turn_duration ; @refresh_status = false
  1439.       $game_temp.atb_frame_skip = 30 ; @battler_in_turn = nil
  1440.       $game_temp.refresh_target_windows = [false,false]
  1441.       $game_temp.refresh_actor_command = false ; @subject = nil
  1442.       $game_temp.refresh_battle_atb = false ; $game_temp.atb_break_duration = 0
  1443.       $game_temp.end_phase_duration = [false,0] ; $game_temp.battle_end2 = false     
  1444.       $game_temp.actor_command_index = 0 ; $game_temp.refresh_item_window = false
  1445.       $game_system.atb_turn_duration[0] = 0 ; $game_temp.atb_stop = [false,false]
  1446.       $game_temp.atb_actor_order = [] ; $game_temp.break_command = false
  1447.       $game_temp.actor_process_event = nil ; $game_temp.hwindow_atb = false
  1448.   end
  1449.   
  1450.   #--------------------------------------------------------------------------
  1451.   # ● Determine Win/Loss Results
  1452.   #--------------------------------------------------------------------------
  1453.   alias mog_atb_judge_win_loss judge_win_loss
  1454.   def judge_win_loss
  1455.       return if $game_temp.end_phase_duration[0]
  1456.       return if $game_troop.interpreter.running?
  1457.       mog_atb_judge_win_loss
  1458.   end
  1459.   
  1460.   #--------------------------------------------------------------------------
  1461.   # ● Clear Base Parameter
  1462.   #--------------------------------------------------------------------------   
  1463.   def clear_base_parameter
  1464.       battlers.each do |battler| battler.atb_initial end
  1465.   end
  1466.   
  1467.   #--------------------------------------------------------------------------
  1468.   # ● Process Abort
  1469.   #--------------------------------------------------------------------------   
  1470.   alias mog_atb_process_abort process_abort  
  1471.   def process_abort  
  1472.       $game_temp.atb_wait = true ; $game_temp.battle_end = true
  1473.       clear_base_parameter
  1474.       mog_atb_process_abort      
  1475.   end
  1476.   
  1477.   #--------------------------------------------------------------------------
  1478.   # ● Process Defeat
  1479.   #--------------------------------------------------------------------------   
  1480.   alias mog_atb_process_defeat process_defeat
  1481.   def process_defeat
  1482.       clear_base_parameter
  1483.       $game_temp.atb_wait = true ; $game_temp.battle_end = true   
  1484.       mog_atb_process_defeat
  1485.   end  

  1486.   #--------------------------------------------------------------------------
  1487.   # ● Process Victory
  1488.   #--------------------------------------------------------------------------   
  1489.   alias mog_atb_process_victory process_victory
  1490.   def process_victory
  1491.       $game_temp.atb_wait = true ; $game_temp.battle_end = true
  1492.       mog_atb_process_victory
  1493.   end

  1494.   #--------------------------------------------------------------------------
  1495.   # ● Prior Command
  1496.   #--------------------------------------------------------------------------   
  1497.   alias mog_atb_prior_command prior_command
  1498.   def prior_command
  1499.       if $sv_camera != nil
  1500.          actor = $game_party.battle_members[@actor_index] rescue nil
  1501.          return if actor == nil
  1502.       end
  1503.       mog_atb_prior_command
  1504.   end   
  1505.   
  1506. end

  1507. #==============================================================================
  1508. # ■ Scene Battle
  1509. #==============================================================================
  1510. class Scene_Battle < Scene_Base
  1511.   include MOG_ATB_SYSTEM
  1512.   
  1513.   #--------------------------------------------------------------------------
  1514.   # ● Battle Start
  1515.   #--------------------------------------------------------------------------
  1516.   def battle_start
  1517.       BattleManager.battle_start
  1518.       process_event
  1519.       set_turn_duration
  1520.   end   
  1521.   
  1522.   #--------------------------------------------------------------------------
  1523.   # ● Set Turn Duration
  1524.   #--------------------------------------------------------------------------
  1525.   def set_turn_duration
  1526.       $game_system.atb_turn_duration = [0,BattleManager.set_turn_duration]
  1527.       @status_window.open if @status_window != nil
  1528.       BattleManager.turn_start_abs
  1529.   end     
  1530.   
  1531.   #--------------------------------------------------------------------------
  1532.   # ● Next Command
  1533.   #--------------------------------------------------------------------------  
  1534.   alias mog_atb_next_command next_command
  1535.   def next_command
  1536.       BattleManager.command_selection_clear if BattleManager.command_selection_clear?
  1537.       mog_atb_next_command
  1538.   end   
  1539.   
  1540.   #--------------------------------------------------------------------------
  1541.   # ● Process Action
  1542.   #--------------------------------------------------------------------------  
  1543.   def process_action
  1544.       process_atb_type
  1545.       return if !process_action_atb?
  1546.       update_turn if update_turn?
  1547.       @subject = BattleManager.update_atb
  1548.       process_actor_command if BattleManager.actor_command?
  1549.       force_refresh_status if BattleManager.refresh_status?
  1550.       process_action_atb if @subject
  1551.   end  

  1552.   #--------------------------------------------------------------------------
  1553.   # ● Update Break Phase
  1554.   #--------------------------------------------------------------------------  
  1555.   def update_break_phase
  1556.       $game_temp.atb_break_duration += 1
  1557.       return if $game_temp.atb_break_duration < 30
  1558.       $game_temp.atb_break_duration = 0
  1559.       process_atb_break if proccess_atb_break?
  1560.   end
  1561.   
  1562.   #--------------------------------------------------------------------------
  1563.   # ● Process ATB Break
  1564.   #--------------------------------------------------------------------------  
  1565.   def process_atb_break      
  1566.       if BattleManager.actor != nil
  1567.          BattleManager.actor.atb -= 1
  1568.          if BattleManager.actor.restriction == 4 or BattleManager.actor.hp == 0 or
  1569.             BattleManager.actor.dead?
  1570.             BattleManager.actor.turn_clear
  1571.          end
  1572.       end
  1573.       hide_base_window
  1574.       BattleManager.command_selection_clear
  1575.   end
  1576.   
  1577.   #--------------------------------------------------------------------------
  1578.   # ● Process Action
  1579.   #--------------------------------------------------------------------------  
  1580.   def proccess_atb_break?
  1581.       return false if $game_troop.interpreter.running?
  1582.       members_atb_max = true
  1583.       members_next_turn = true
  1584.       for battler in $game_party.battle_members
  1585.           members_atb_max = false if !battler.atb_max?
  1586.           members_next_turn = false if !battler.next_turn         
  1587.       end
  1588.       if BattleManager.actor != nil
  1589.          return true if can_break_actor_command?
  1590.        else
  1591.          return true if members_atb_max and !members_next_turn
  1592.       end
  1593.       return false
  1594.   end

  1595.   #--------------------------------------------------------------------------
  1596.   # ● Can Break Actor Command
  1597.   #--------------------------------------------------------------------------  
  1598.   def can_break_actor_command?
  1599.       return true if BattleManager.actor.next_turn
  1600.       return true if BattleManager.actor.restriction > 0
  1601.       return true if BattleManager.actor.dead? or BattleManager.actor.hp == 0
  1602.       return true if !base_window_active?
  1603.       return false
  1604.   end
  1605.   
  1606.   #--------------------------------------------------------------------------
  1607.   # ● Base Window Active
  1608.   #--------------------------------------------------------------------------  
  1609.   def base_window_active?
  1610.       return true if @actor_window.active
  1611.       return true if @enemy_window.active
  1612.       return true if @item_window.active
  1613.       return true if @skill_window.active
  1614.       return true if @party_command_window.active
  1615.       return true if @actor_command_window.active
  1616.       return false
  1617.   end
  1618.   
  1619.   #--------------------------------------------------------------------------
  1620.   # ● Process Action
  1621.   #--------------------------------------------------------------------------  
  1622.   def process_action_atb
  1623.       $game_temp.remove_order(@subject)
  1624.       loop do
  1625.           if @subject == nil
  1626.              turn_end_subject_nil
  1627.              break
  1628.           end   
  1629.           BattleManager.set_battler_in_turn(@subject)
  1630.           BattleManager.set_subject(@subject)
  1631.           @log_window.clear
  1632.           if @subject.atb_escape
  1633.              process_escape
  1634.              break
  1635.           end
  1636.           process_before_execute_action
  1637.           process_execute_action if @subject.current_action
  1638.           process_after_execute_action
  1639.           hide_windows_for_dead
  1640.           if break_process_action_atb?
  1641.              process_action_end
  1642.              turn_end
  1643.              break
  1644.           end  
  1645.       end
  1646.   end

  1647.   #--------------------------------------------------------------------------
  1648.   # ● Break Process Action Atb
  1649.   #--------------------------------------------------------------------------   
  1650.   def break_process_action_atb?
  1651.       return true if !@subject.current_action
  1652.       return true if @subject.restriction == 4
  1653.       return true if @subject.dead? or @subject.hp == 0
  1654.       return false
  1655.   end
  1656.   
  1657.   #--------------------------------------------------------------------------
  1658.   # ● Can Break Process Action?
  1659.   #--------------------------------------------------------------------------  
  1660.   def can_break_process_action?
  1661.       return true if @subject == nil
  1662.       return false
  1663.   end
  1664.   
  1665.   #--------------------------------------------------------------------------
  1666.   # ● Can Break Command?
  1667.   #--------------------------------------------------------------------------   
  1668.   def can_break_command?
  1669.       return false if BattleManager.actor == nil
  1670.       return true if BattleManager.actor.hp == 0
  1671.       return true if BattleManager.actor.dead?
  1672.       return true if BattleManager.actor.restriction != 0
  1673.       return false
  1674.   end

  1675.   #--------------------------------------------------------------------------
  1676.   # ● Can Break Command2
  1677.   #--------------------------------------------------------------------------   
  1678.   def can_break_command2?
  1679.       return false if BattleManager.actor != nil
  1680.       return true if BattleManager.command_selection?
  1681.       return false
  1682.   end  
  1683.   
  1684.   #--------------------------------------------------------------------------
  1685.   # ● Break Command
  1686.   #--------------------------------------------------------------------------   
  1687.   def break_command
  1688.       $game_temp.break_command = false
  1689.       BattleManager.actor.turn_clear if BattleManager.actor != nil
  1690.       hide_base_window
  1691.       BattleManager.command_selection_clear
  1692.   end      

  1693.   #--------------------------------------------------------------------------
  1694.   # ● Turn End Subject Nil
  1695.   #--------------------------------------------------------------------------   
  1696.   def turn_end_subject_nil
  1697.       refresh_status
  1698.       BattleManager.judge_win_loss
  1699.       @subject =  nil
  1700.       BattleManager.set_subject(@subject)
  1701.       @log_window.wait
  1702.       @log_window.clear
  1703.       $game_temp.atb_break_duration = 100
  1704.       execute_event_phase if execute_event_phase_turn?
  1705.   end   
  1706.   
  1707.   #--------------------------------------------------------------------------
  1708.   # ● Process Escape
  1709.   #--------------------------------------------------------------------------  
  1710.   def process_escape
  1711.       if BattleManager.process_escape     
  1712.          process_execute_escape
  1713.       else   
  1714.          start_actor_command_selection if BattleManager.actor
  1715.          @status_window.open
  1716.       end  
  1717.       turn_end   
  1718.   end
  1719.       
  1720.   #--------------------------------------------------------------------------
  1721.   # ● Process Actor Command
  1722.   #--------------------------------------------------------------------------  
  1723.   def process_actor_command
  1724.       start_actor_command_selection
  1725.   end
  1726.   
  1727.   #--------------------------------------------------------------------------
  1728.   # ● Process Before Execute Action
  1729.   #--------------------------------------------------------------------------  
  1730.   def process_before_execute_action   
  1731.   end  
  1732.   
  1733.   #--------------------------------------------------------------------------
  1734.   # ● Process After Execute Action
  1735.   #--------------------------------------------------------------------------  
  1736.   def process_after_execute_action   
  1737.   end   
  1738.   
  1739.   #--------------------------------------------------------------------------
  1740.   # ● Refresh Actor Command
  1741.   #--------------------------------------------------------------------------  
  1742.   def refresh_actor_command?
  1743.       return false if !$game_temp.refresh_actor_command
  1744.       return false if !@actor_command_window.active
  1745.       return false if !BattleManager.actor
  1746.       return true
  1747.   end  

  1748.   #--------------------------------------------------------------------------
  1749.   # ● Update Actor Command
  1750.   #--------------------------------------------------------------------------  
  1751.   def update_actor_command
  1752.       return if !@actor_command_window.active
  1753.       return if !BattleManager.actor
  1754.       if ENABLE_BUTTON_NEXT_ACTOR
  1755.          if Input.trigger?(BUTTON_NEXT_ACTOR_LEFT) ; turn_to_next_actor(-1) rescue nil
  1756.          elsif Input.trigger?(BUTTON_NEXT_ACTOR_RIGHT) ; turn_to_next_actor(1) rescue nil
  1757.          end  
  1758.       end   
  1759.   end  

  1760.   #--------------------------------------------------------------------------
  1761.   # ● Turn To Next Actor
  1762.   #--------------------------------------------------------------------------  
  1763.   def turn_to_next_actor(value)
  1764.       return if BattleManager.actor == nil
  1765.       next_index = BattleManager.actor.index + value
  1766.       next_index = 0 if next_index >= $game_party.battle_members.size
  1767.       battler = $game_party.battle_members[next_index]
  1768.       next_act = false
  1769.       if battler.movable_atb?
  1770.          cancel_actor_command_scene(false) ; BattleManager.prepare_actor_command(battler)
  1771.          process_actor_command if BattleManager.actor_command?
  1772.          next_act = true
  1773.       else           
  1774.         @tnext_index = value   
  1775.          for battler in $game_party.battle_members
  1776.              next_index += @tnext_index
  1777.              if next_index >= $game_party.battle_members.size
  1778.                 next_index = 0 ; @tnext_index = 1
  1779.                 if next_actor_command?(next_index) ; next_act = true ; break ; end
  1780.              elsif next_index < 0
  1781.                 next_index = $game_party.battle_members.size ;  @tnext_index = -1
  1782.                 if next_actor_command?(next_index) ; next_act = true ; break ; end
  1783.              end
  1784.              if next_actor_command?(next_index) ; next_act = true ; break ; end
  1785.          end  
  1786.       end
  1787.      Sound.play_cancel if !next_act
  1788.   end
  1789.          
  1790.   #--------------------------------------------------------------------------
  1791.   # ● Next Actor Command?
  1792.   #--------------------------------------------------------------------------  
  1793.   def next_actor_command?(next_index)
  1794.       for battler in $game_party.battle_members
  1795.           next if next_index == BattleManager.actor.index
  1796.           if next_index == battler.index and battler.movable_atb?
  1797.              cancel_actor_command_scene(false)
  1798.              BattleManager.prepare_actor_command(battler)
  1799.              process_actor_command if BattleManager.actor_command?
  1800.              return true
  1801.           end            
  1802.       end
  1803.       return false
  1804.   end  
  1805.          
  1806.   #--------------------------------------------------------------------------
  1807.   # ● Cancel Actor Command scene
  1808.   #--------------------------------------------------------------------------  
  1809.   def cancel_actor_command_scene(atb_cost = false)
  1810.       @actor_command_window.close ; @actor_command_window.hide_all
  1811.       BattleManager.cancel_actor_command(atb_cost)
  1812.   end
  1813.   
  1814.   #--------------------------------------------------------------------------
  1815.   # ● Update Party Command
  1816.   #--------------------------------------------------------------------------      
  1817.   def update_party_command
  1818.       return if !@party_command_window.active
  1819.       return if !BattleManager.actor
  1820.       if Input.trigger?(:B)
  1821.          Sound.play_cancel
  1822.          @party_command_window.deactivate ; start_actor_command_selection
  1823.       end  
  1824.   end
  1825.   
  1826.   #--------------------------------------------------------------------------
  1827.   # ● Create All Windows
  1828.   #--------------------------------------------------------------------------      
  1829.   alias mog_atb_create_all_windows create_all_windows
  1830.   def create_all_windows
  1831.       mog_atb_create_all_windows
  1832.       @pre_viewport_visible = true
  1833.       @info_xy = [0,(Graphics.width - @status_window.width) / 2, Graphics.width - @status_window.width ]
  1834.   end  
  1835.   
  1836.   #--------------------------------------------------------------------------
  1837.   # ● Update Info Viewport
  1838.   #--------------------------------------------------------------------------      
  1839.   def update_info_viewport
  1840.       if center_viewport?
  1841.          move_info_viewport(@info_xy[1]) ; return
  1842.       end
  1843.       if @party_command_window.active ; move_info_viewport(@info_xy[0])   
  1844.       elsif BattleManager.actor ; move_info_viewport(@info_xy[2])
  1845.       else ; move_info_viewport(@info_xy[1])
  1846.       end  
  1847.   end  

  1848.   #--------------------------------------------------------------------------
  1849.   # ● Update Info Viewport
  1850.   #--------------------------------------------------------------------------      
  1851.   def center_viewport?
  1852.       return true if $game_message.visible
  1853.       return true if BattleManager.actor == nil
  1854.       return true if $game_temp.battle_end
  1855.       return false
  1856.   end
  1857.   
  1858.   #--------------------------------------------------------------------------
  1859.   # ● Process Action ATB
  1860.   #--------------------------------------------------------------------------  
  1861.   def process_action_atb?  
  1862.       return false if $game_troop.interpreter.running?
  1863.       return false if $game_temp.end_phase_duration[1] > 0  
  1864.       return false if $game_temp.atb_wait
  1865.       return false if $game_temp.battle_end
  1866.       return false if $game_temp.battle_end2
  1867.       return false if scene_changing?
  1868.       return false if !$game_temp.sprite_visible
  1869.       return false if $game_temp.atb_stop[1]
  1870.       return false if @combatlog_window.visible if @combatlog_window != nil
  1871.       return true
  1872.   end
  1873.   
  1874.   #--------------------------------------------------------------------------
  1875.   # ● Process ATB Type
  1876.   #--------------------------------------------------------------------------  
  1877.   def process_atb_type
  1878.       $game_temp.atb_frame_skip -= 1 if $game_temp.atb_frame_skip > 0
  1879.       return if $game_temp.battle_end
  1880.       return if $game_temp.end_phase_duration[1] > 0
  1881.       case $game_system.atb_type
  1882.            when 0 ; $game_temp.atb_wait = set_atb_type_wait
  1883.            when 1 ; $game_temp.atb_wait = set_atb_type_semi_wait
  1884.            else ; $game_temp.atb_wait = false
  1885.       end
  1886.   end
  1887.       
  1888.   #--------------------------------------------------------------------------
  1889.   # ● Set Atb Type Wait
  1890.   #--------------------------------------------------------------------------  
  1891.   def set_atb_type_wait
  1892.       return true if @actor_window.active
  1893.       return true if @enemy_window.active
  1894.       return true if @item_window.active
  1895.       return true if @skill_window.active
  1896.       return true if @party_command_window.active
  1897.       return true if @actor_command_window.active
  1898.       return false
  1899.   end
  1900.   
  1901.   #--------------------------------------------------------------------------
  1902.   # ● Set Atb Type Semi Wait
  1903.   #--------------------------------------------------------------------------  
  1904.   def set_atb_type_semi_wait
  1905.       return true if @item_window.active
  1906.       return true if @skill_window.active
  1907.       return false   
  1908.   end
  1909.   
  1910.   #--------------------------------------------------------------------------
  1911.   # ● Process Execute Escape
  1912.   #--------------------------------------------------------------------------  
  1913.   def process_execute_escape
  1914.       $game_temp.battle_end = true
  1915.       hide_base_window
  1916.       $game_temp.atb_user = nil
  1917.       $game_temp.battle_cursor[2] = false if $imported[:mog_battle_cursor]
  1918.       BattleManager.command_selection_clear
  1919.   end
  1920.   
  1921.   #--------------------------------------------------------------------------
  1922.   # ● Battle End?
  1923.   #--------------------------------------------------------------------------  
  1924.   def battle_end?
  1925.       return true if $game_party.members.empty?
  1926.       return true if $game_party.all_dead?
  1927.       return true if $game_troop.all_dead?
  1928.       return true if $game_temp.battle_end
  1929.       return false
  1930.   end
  1931.    
  1932.   #--------------------------------------------------------------------------
  1933.   # ● Command Escape
  1934.   #--------------------------------------------------------------------------  
  1935.   def command_escape
  1936.       BattleManager.actor.atb_escape = true if BattleManager.actor
  1937.       BattleManager.command_end
  1938.       @party_command_window.close
  1939.       hide_base_window
  1940.   end  
  1941.   
  1942.   #--------------------------------------------------------------------------
  1943.   # ● Command Escape2
  1944.   #--------------------------------------------------------------------------  
  1945.   def command_escape2
  1946.      turn_start unless BattleManager.process_escape
  1947.   end
  1948.    
  1949.   #--------------------------------------------------------------------------
  1950.   # ● Execute Action
  1951.   #--------------------------------------------------------------------------  
  1952.   alias mog_atb_execute_action execute_action
  1953.   def execute_action
  1954.       @cp_members = []
  1955.       return if battle_end? or @subject == nil
  1956.       @cp_members = current_cp_members if can_execute_cooperation_skill?            
  1957.       mog_atb_execute_action
  1958.   end
  1959.   
  1960.   #--------------------------------------------------------------------------
  1961.   # ● Use Item
  1962.   #--------------------------------------------------------------------------  
  1963.   alias mog_atb_use_item use_item
  1964.   def use_item
  1965.       return if battle_end? or @subject == nil
  1966.       mog_atb_use_item
  1967.   end
  1968.   
  1969.   #--------------------------------------------------------------------------
  1970.   # ● Show Animation
  1971.   #--------------------------------------------------------------------------  
  1972.   alias mog_atb_event_show_animation show_animation
  1973.   def show_animation(targets, animation_id)
  1974.       execute_event_phase if execute_event_phase_turn?
  1975.       mog_atb_event_show_animation(targets, animation_id)   
  1976.   end
  1977.   
  1978.   #--------------------------------------------------------------------------
  1979.   # ● Force Refresh Status
  1980.   #--------------------------------------------------------------------------  
  1981.   def force_refresh_status
  1982.       BattleManager.set_refresh_status(false)
  1983.       refresh_status
  1984.   end

  1985.   #--------------------------------------------------------------------------
  1986.   # ● Refresh Battle ATB
  1987.   #--------------------------------------------------------------------------  
  1988.   def refresh_battle_atb
  1989.       $game_temp.refresh_battle_atb = false
  1990.       hide_base_window
  1991.       battle_start      
  1992.   end

  1993.   #--------------------------------------------------------------------------
  1994.   # ● Hide Base Window
  1995.   #--------------------------------------------------------------------------  
  1996.   def hide_base_window(target_window = true,actor_window = false)
  1997.       @actor_window.hide
  1998.       @actor_window.active = false
  1999.       @enemy_window.hide
  2000.       @enemy_window.active = false
  2001.       @help_window.hide
  2002.       @party_command_window.deactivate
  2003.       @party_command_window.close
  2004.       @status_window.unselect
  2005.       instance_variables.each do |varname|
  2006.          ivar = instance_variable_get(varname)
  2007.          if ivar.is_a?(Window)
  2008.             next if !need_hide_window?(ivar,actor_window)            
  2009.             ivar.hide_all
  2010.          end   
  2011.       end
  2012.       @pre_viewport_visible = @info_viewport.visible
  2013.       @info_viewport.visible = true ; @status_window.show
  2014.       @status_aid_window.hide_all if @status_aid_window != nil
  2015.   end

  2016.   #--------------------------------------------------------------------------
  2017.   # ● Need Hide Window?
  2018.   #--------------------------------------------------------------------------  
  2019.   def need_hide_window?(ivar,actor_window)
  2020.       return false if ivar.is_a?(Window_Message)
  2021.       return false if ivar.is_a?(Window_BattleActor)
  2022.       return false if ivar.is_a?(Window_BattleEnemy)
  2023.       return false if ivar.is_a?(Window_BattleStatus)
  2024.       return false if ivar.is_a?(Window_PartyCommand)
  2025.       return false if ivar.is_a?(Window_ActorCommand) and actor_window
  2026.       if $imported["YEA-VictoryAftermath"]
  2027.          return false if ivar.is_a?(Window_VictoryTitle)
  2028.          return false if ivar.is_a?(Window_VictoryEXP_Back)
  2029.          return false if ivar.is_a?(Window_VictoryEXP_Front)
  2030.          return false if ivar.is_a?(Window_VictoryLevelUp)
  2031.          return false if ivar.is_a?(Window_VictorySkills)
  2032.          return false if ivar.is_a?(Window_VictorySpoils)
  2033.       end      
  2034.       return true
  2035.   end     
  2036.   
  2037.   #--------------------------------------------------------------------------
  2038.   # ● Record Window Data
  2039.   #--------------------------------------------------------------------------  
  2040.   def record_window_data(target_window = true)
  2041.       return if $game_temp.hwindow_atb
  2042.       $game_temp.hwindow_atb = true
  2043.       @pre_battler = BattleManager.actor
  2044.       @battler_in_turn_temp = @actor_command_window.active
  2045.       instance_variables.each do |varname|
  2046.          ivar = instance_variable_get(varname)
  2047.          ivar.record_data if ivar.is_a?(Window)
  2048.       end      
  2049.       if $imported[:mog_battle_cursor]
  2050.          @battle_cursor_visible = $game_temp.battle_cursor[2]
  2051.          $game_temp.battle_cursor[2] = false
  2052.       end         
  2053.       hide_base_window(target_window)   
  2054.   end
  2055.    
  2056.   #--------------------------------------------------------------------------
  2057.   # ● Fade Base Window
  2058.   #--------------------------------------------------------------------------  
  2059.   def fade_base_window(fade_value)
  2060.       instance_variables.each do |varname|
  2061.          ivar = instance_variable_get(varname)
  2062.          if ivar.is_a?(Window)
  2063.             next if !need_fade_after_battle?(ivar)
  2064.             ivar.opacity -= fade_value
  2065.             ivar.contents_opacity -= fade_value
  2066.          end
  2067.       end
  2068.   end  
  2069.   
  2070.   #--------------------------------------------------------------------------
  2071.   # ● Need Fade After Battle?
  2072.   #--------------------------------------------------------------------------  
  2073.   def need_fade_after_battle?(ivar)
  2074.       return false if ivar.is_a?(Window_Message)
  2075.       if $imported["YEA-VictoryAftermath"]
  2076.          return false if ivar.is_a?(Window_VictoryTitle)
  2077.          return false if ivar.is_a?(Window_VictoryEXP_Back)
  2078.          return false if ivar.is_a?(Window_VictoryEXP_Front)
  2079.          return false if ivar.is_a?(Window_VictoryLevelUp)
  2080.          return false if ivar.is_a?(Window_VictorySkills)
  2081.          return false if ivar.is_a?(Window_VictorySpoils)
  2082.       end
  2083.       return true
  2084.   end   

  2085.   #--------------------------------------------------------------------------
  2086.   # ● Record Window Data
  2087.   #--------------------------------------------------------------------------  
  2088.   def restore_window_data
  2089.       return if battle_end?
  2090.        if @pre_battler and @pre_battler.dead?
  2091.           hide_windows_for_dead
  2092.        else
  2093.           instance_variables.each do |varname|
  2094.              ivar = instance_variable_get(varname)
  2095.              ivar.restore_data if ivar.is_a?(Window)
  2096.           end   
  2097.           @info_viewport.visible = @pre_viewport_visible
  2098.           @actor_command_window.open if @actor_command_window.visible
  2099.           @status_window.open if @status_window.visible
  2100.           @actor_window.show if @actor_window.active
  2101.           @actor_window.restore_data if @actor_window.active
  2102.           @enemy_window.show if @enemy_window.active
  2103.           @enemy_window.restore_data if @enemy_window.active
  2104.           start_actor_command_selection(false) if @actor_command_window.active
  2105.           start_party_command_selection if @party_command_window.active
  2106.           if $imported[:mog_battle_cursor]
  2107.              $game_temp.battle_cursor[2] = @battle_cursor_visible
  2108.           end
  2109.       end
  2110.       $game_temp.hwindow_atb = false
  2111.   end
  2112.    
  2113.   #--------------------------------------------------------------------------
  2114.   # ● Hide Windows for dead
  2115.   #--------------------------------------------------------------------------  
  2116.   def hide_windows_for_dead
  2117.       return if BattleManager.actor == nil
  2118.       return if !BattleManager.actor.dead?
  2119.       hide_base_window
  2120.       $game_temp.atb_user = nil
  2121.       $game_temp.battle_cursor[2] = false if $imported[:mog_battle_cursor]
  2122.       BattleManager.command_selection_clear
  2123.   end

  2124.   #--------------------------------------------------------------------------
  2125.   # ● Update Target Windows
  2126.   #--------------------------------------------------------------------------  
  2127.   def update_target_windows
  2128.       if @actor_window.active and $game_temp.refresh_target_windows[0]
  2129.          @actor_window.refresh
  2130.          @actor_window.update
  2131.          $game_temp.refresh_target_windows[0] = false
  2132.       end  
  2133.       if @enemy_window.active and $game_temp.refresh_target_windows[1]
  2134.          @enemy_window.refresh
  2135.          @enemy_window.cursor_left if @enemy_window.enemy == nil
  2136.          @enemy_window.update
  2137.          $game_temp.refresh_target_windows[1] = false
  2138.       end
  2139.   end  
  2140.   
  2141.   #--------------------------------------------------------------------------
  2142.   # ● Process Execute Action
  2143.   #--------------------------------------------------------------------------  
  2144.   def process_execute_action
  2145.       @subject.current_action.prepare
  2146.       if @subject.current_action.valid?      
  2147.          @status_window.open ; execute_action
  2148.       end
  2149.       process_before_remove_action
  2150.       @subject.remove_current_action
  2151.   end

  2152.   #--------------------------------------------------------------------------
  2153.   # ● Process Before Remove Action
  2154.   #--------------------------------------------------------------------------  
  2155.   def process_before_remove_action   
  2156.   end
  2157.   
  2158.   #--------------------------------------------------------------------------
  2159.   # * End Turn
  2160.   #--------------------------------------------------------------------------
  2161.   def turn_end
  2162.       BattleManager.set_battler_in_turn(nil)   
  2163.       all_battle_members.each do |battler|
  2164.           refresh_status
  2165.           @log_window.wait_and_clear
  2166.       end
  2167.       turn_reset
  2168.   end  
  2169.   
  2170.   #--------------------------------------------------------------------------
  2171.   # ● Turn Reset
  2172.   #--------------------------------------------------------------------------
  2173.   def turn_reset
  2174.       $game_temp.remove_order(@subject)      
  2175.       BattleManager.current_battler_clear(@subject)
  2176.       BattleManager.command_selection_clear if BattleManager.command_need_clear?
  2177.       @subject =  nil
  2178.       BattleManager.set_subject(@subject)
  2179.       @log_window.wait
  2180.       @log_window.clear      
  2181.       $game_temp.atb_break_duration = 100
  2182.   end
  2183.      
  2184.   #--------------------------------------------------------------------------
  2185.   # ● Execute Event Phase Turn?
  2186.   #--------------------------------------------------------------------------
  2187.   def execute_event_phase_turn?
  2188.       return false if !$game_troop.can_interpreter_running?(false)
  2189.       return false if $game_party.members.empty?
  2190.       return false if $game_party.all_dead?
  2191.       return false if $game_troop.all_dead?
  2192.       return true
  2193.   end  
  2194.       
  2195.   #--------------------------------------------------------------------------
  2196.   # ● Update
  2197.   #--------------------------------------------------------------------------            
  2198.   def update
  2199.       update_basic   
  2200.       refresh_battle_atb if $game_temp.refresh_battle_atb
  2201.       process_action if BattleManager.in_turn?
  2202.       update_end_phase if $game_temp.end_phase_duration[1] > 0
  2203.   end  
  2204.   
  2205.   #--------------------------------------------------------------------------
  2206.   # ● Update Basic
  2207.   #--------------------------------------------------------------------------            
  2208.   alias mog_atb_update_basic update_basic
  2209.   def update_basic
  2210.       update_break_phase
  2211.       break_command if force_break_command?
  2212.       update_atb_basic if !$game_troop.interpreter.running?
  2213.       mog_atb_update_basic
  2214.   end
  2215.      
  2216.   #--------------------------------------------------------------------------
  2217.   # ● Force Break Command
  2218.   #--------------------------------------------------------------------------            
  2219.   def force_break_command?
  2220.       return true if $game_temp.break_command
  2221.       return true if can_break_command?
  2222.       return true if can_break_command2?
  2223.       return false
  2224.   end
  2225.   
  2226.   #--------------------------------------------------------------------------
  2227.   # ● Update Atb Basic
  2228.   #--------------------------------------------------------------------------            
  2229.   def update_atb_basic
  2230.       if @actor_command_window.active
  2231.          update_actor_command
  2232.       else   
  2233.          update_party_command
  2234.       end   
  2235.       update_target_windows      
  2236.       refresh_item_skill_window if need_refresh_item_skill_window?
  2237.       start_actor_command_selection if refresh_actor_command?
  2238.       fade_base_window(15) if $game_temp.battle_end
  2239.   end  
  2240.   
  2241.   #--------------------------------------------------------------------------
  2242.   # ● Need Refresh Item Skill Window?
  2243.   #--------------------------------------------------------------------------            
  2244.   def need_refresh_item_skill_window?
  2245.       return true if $game_temp.refresh_item_window
  2246.       return false
  2247.   end
  2248.    
  2249.   #--------------------------------------------------------------------------
  2250.   # ● Refresh Item Skill Window
  2251.   #--------------------------------------------------------------------------            
  2252.   def refresh_item_skill_window
  2253.       $game_temp.refresh_item_window = false
  2254.       @item_window.refresh if @item_window.visible
  2255.       @skill_window.refresh if @skill_window.visible
  2256.   end
  2257.   
  2258.   #--------------------------------------------------------------------------
  2259.   # ● Update End Phase
  2260.   #--------------------------------------------------------------------------            
  2261.   def update_end_phase
  2262.       $game_temp.end_phase_duration[1] -= 1
  2263.       return if $game_temp.end_phase_duration[1] > 0
  2264.       $game_temp.end_phase_duration[0] = false
  2265.       BattleManager.judge_win_loss
  2266.   end
  2267.   
  2268.   #--------------------------------------------------------------------------
  2269.   # ● Process Event
  2270.   #--------------------------------------------------------------------------            
  2271.   alias mog_atb_process_event process_event
  2272.   def process_event
  2273.       if battle_end? ; hide_base_window ; $game_temp.end_phase_duration = [true,30] ; end
  2274.       $game_temp.actor_process_event = BattleManager.actor
  2275.       mog_atb_process_event
  2276.       process_break_atb_event
  2277.   end
  2278.   
  2279.   #--------------------------------------------------------------------------
  2280.   # ● Process Break ATB Event
  2281.   #--------------------------------------------------------------------------            
  2282.   def process_break_atb_event
  2283.       if break_actor_command?
  2284.          BattleManager.actor.turn_clear
  2285.          BattleManager.command_selection_clear
  2286.       end
  2287.       BattleManager.force_clear_battler_atb
  2288.   end
  2289.   
  2290.   #--------------------------------------------------------------------------
  2291.   # ● Break Actor Command
  2292.   #--------------------------------------------------------------------------            
  2293.   def break_actor_command?
  2294.       return false if BattleManager.actor == nil
  2295.       return true if BattleManager.actor.dead?
  2296.       return true if BattleManager.actor.restriction != 0
  2297.       return false
  2298.   end
  2299.   
  2300.   #--------------------------------------------------------------------------
  2301.   # * Processing at End of Action
  2302.   #--------------------------------------------------------------------------
  2303.   alias mog_atb_process_action_end process_action_end
  2304.   def process_action_end
  2305.       if battle_end? ; hide_base_window ; $game_temp.end_phase_duration = [true,30] ; end
  2306.       mog_atb_process_action_end
  2307.   end  
  2308.   
  2309.   #--------------------------------------------------------------------------
  2310.   # ● Update Turn
  2311.   #--------------------------------------------------------------------------            
  2312.   def update_turn
  2313.       force_reset_turn_duration if $game_temp.turn_duration_clear
  2314.       $game_system.atb_turn_duration[0] += 1 unless $game_troop.interpreter.running?
  2315.       if $game_system.atb_turn_duration[0] >= $game_system.atb_turn_duration[1]
  2316.          $game_system.atb_turn_duration[0] = 0
  2317.          $game_troop.increase_turn
  2318.          execute_event_phase if $game_troop.can_interpreter_running?(true)
  2319.       end  
  2320.   end  
  2321.   
  2322.   #--------------------------------------------------------------------------
  2323.   # ● Update Turn
  2324.   #--------------------------------------------------------------------------            
  2325.   def update_turn?
  2326.       return false if $game_system.atb_turn_duration == nil or $game_system.atb_turn_duration[0] == nil
  2327.       return false if $game_temp.end_phase_duration[1] > 0
  2328.       return false if $game_temp.battle_end
  2329.       return false if $game_temp.atb_stop[1]   
  2330.       return true
  2331.   end   
  2332.   
  2333.   #--------------------------------------------------------------------------
  2334.   # ● Execute Event Phase
  2335.   #--------------------------------------------------------------------------            
  2336.   def execute_event_phase
  2337.       if $game_troop.can_interpreter_hide_window? or $game_troop.can_interpreter_hide_window_2?
  2338.       (record_window_data ; rw = true)
  2339.       end
  2340.       process_event
  2341.       refresh_status
  2342.       restore_window_data if rw != nil
  2343.       BattleManager.turn_start_abs      
  2344.   end   
  2345.   
  2346.   #--------------------------------------------------------------------------
  2347.   # ● Force Reset Turn Duration
  2348.   #--------------------------------------------------------------------------            
  2349.   def force_reset_turn_duration
  2350.       $game_temp.turn_duration_clear = false
  2351.       $game_system.atb_turn_duration[0] = 0
  2352.       $game_troop.set_turn(0)
  2353.   end  
  2354.   
  2355.   #--------------------------------------------------------------------------
  2356.   # ● ON Enemy OK
  2357.   #--------------------------------------------------------------------------
  2358.   alias mog_atb_on_enemy_ok on_enemy_ok
  2359.   def on_enemy_ok
  2360.       return if BattleManager.actor == nil
  2361.       return if battle_end?
  2362.       mog_atb_on_enemy_ok           
  2363.       BattleManager.command_end
  2364.       hide_base_window
  2365.   end
  2366.   
  2367.   #--------------------------------------------------------------------------
  2368.   # ● On Enemy Cancel
  2369.   #--------------------------------------------------------------------------
  2370.   alias mog_atb_on_enemy_cancel on_enemy_cancel
  2371.   def on_enemy_cancel
  2372.       return if BattleManager.actor == nil
  2373.       mog_atb_on_enemy_cancel
  2374.       start_actor_command_selection if @actor_command_window.active
  2375.       @skill_window.visible = true if @skill_window.active
  2376.       @item_window.visible = true if @item_window.active
  2377.   end     
  2378.   
  2379.   #--------------------------------------------------------------------------
  2380.   # ● On Actor OK
  2381.   #--------------------------------------------------------------------------
  2382.   alias mog_atb_on_actor_ok on_actor_ok
  2383.   def on_actor_ok
  2384.       return if BattleManager.actor == nil
  2385.       return if battle_end?
  2386.       mog_atb_on_actor_ok
  2387.       BattleManager.command_end
  2388.       hide_base_window
  2389.   end
  2390.   
  2391.   #--------------------------------------------------------------------------
  2392.   # ● On Actor Cancel
  2393.   #--------------------------------------------------------------------------
  2394.   alias mog_atb_on_actor_cancel on_actor_cancel
  2395.   def on_actor_cancel
  2396.       return if BattleManager.actor == nil
  2397.       mog_atb_on_actor_cancel
  2398.       start_actor_command_selection if @actor_command_window.active
  2399.       @skill_window.visible = true if @skill_window.active
  2400.       @item_window.visible = true if @item_window.active      
  2401.   end
  2402.   
  2403.   #--------------------------------------------------------------------------
  2404.   # ● On Skill Cancel
  2405.   #--------------------------------------------------------------------------
  2406.   alias mog_atb_on_skill_cancel on_skill_cancel
  2407.   def on_skill_cancel
  2408.       return if BattleManager.actor == nil
  2409.       mog_atb_on_skill_cancel
  2410.       start_actor_command_selection if @actor_command_window.active
  2411.   end  
  2412.   
  2413.   #--------------------------------------------------------------------------
  2414.   # ● On Item Cancel
  2415.   #--------------------------------------------------------------------------
  2416.   alias mog_atb_on_item_cancel on_item_cancel
  2417.   def on_item_cancel
  2418.       return if BattleManager.actor == nil
  2419.       mog_atb_on_item_cancel
  2420.       start_actor_command_selection if @actor_command_window.active
  2421.   end  
  2422.   
  2423.   #--------------------------------------------------------------------------
  2424.   # ● On Skill OK
  2425.   #--------------------------------------------------------------------------
  2426.   alias mog_atb_on_skill_ok on_skill_ok
  2427.   def on_skill_ok
  2428.       return if BattleManager.actor == nil
  2429.       @skill_window.visible = false unless !@status_window.visible
  2430.       mog_atb_on_skill_ok      
  2431.       if !@skill.need_selection?
  2432.          BattleManager.command_end
  2433.          hide_base_window
  2434.       end   
  2435.   end
  2436.    
  2437.   #--------------------------------------------------------------------------
  2438.   # ● On Item OK
  2439.   #--------------------------------------------------------------------------
  2440.   alias mog_atb_on_item_ok on_item_ok
  2441.   def on_item_ok
  2442.       return if BattleManager.actor == nil
  2443.       @item_window.visible = false unless !@status_window.visible
  2444.       mog_atb_on_item_ok
  2445.       if !@item.need_selection?
  2446.          BattleManager.command_end
  2447.          hide_base_window
  2448.       end
  2449.   end  
  2450.   
  2451.   #--------------------------------------------------------------------------
  2452.   # ● Start Actor Command Selection
  2453.   #--------------------------------------------------------------------------
  2454.   def start_actor_command_selection(se = true)
  2455.       $game_temp.atb_user = BattleManager.actor
  2456.       $game_temp.refresh_actor_command = false
  2457.       $game_temp.actor_process_event = nil
  2458.       if BattleManager.next_command and BattleManager.actor and BattleManager.actor.movable_atb?
  2459.          execute_start_actor_command(se)
  2460.       else   
  2461.          BattleManager.command_selection_clear
  2462.       end   
  2463.   end     

  2464.   #--------------------------------------------------------------------------
  2465.   # ● Execute Start Actor Command
  2466.   #--------------------------------------------------------------------------
  2467.   def execute_start_actor_command(se)
  2468.       $game_temp.remove_order(BattleManager.actor)      
  2469.       Audio.se_play("Audio/SE/" + SE_ACTIVE,100,100) if se
  2470.       hide_base_window(false,true) if se
  2471.       @status_window.select(BattleManager.actor.index)
  2472.       @status_window.open
  2473.       @status_window.select(BattleManager.actor.index)
  2474.       @party_command_window.close
  2475.       @actor_command_window.setup(BattleManager.actor)
  2476.       @actor_command_window.activate
  2477.       @actor_command_window.show
  2478.       @actor_command_window.index = $game_temp.actor_command_index      
  2479.   end
  2480.       
  2481.   #--------------------------------------------------------------------------
  2482.   # ● Next Command
  2483.   #--------------------------------------------------------------------------
  2484.   def next_command
  2485.   end
  2486.   
  2487.   #--------------------------------------------------------------------------
  2488.   # ● Close Base
  2489.   #--------------------------------------------------------------------------
  2490.   def close_base_window
  2491.       @party_command_window.close
  2492.       @actor_command_window.close
  2493.       @status_window.unselect
  2494.   end
  2495.    
  2496.   #--------------------------------------------------------------------------
  2497.   # ● Command Fight
  2498.   #--------------------------------------------------------------------------
  2499.   alias mog_atb_command_fight command_fight
  2500.   def command_fight
  2501.       mog_atb_command_fight
  2502.       start_actor_command_selection
  2503.   end  
  2504.   
  2505.   #--------------------------------------------------------------------------
  2506.   # ● Refresh Status
  2507.   #--------------------------------------------------------------------------
  2508.   alias mog_atb_refresh_status refresh_status
  2509.   def refresh_status
  2510.       mog_atb_refresh_status
  2511.       hide_windows_for_dead
  2512.   end

  2513.   #--------------------------------------------------------------------------
  2514.   # ● Forced Action Processing
  2515.   #--------------------------------------------------------------------------
  2516.   def process_forced_action   
  2517.       if BattleManager.action_forced?
  2518.          last_subject = @subject
  2519.          @subject = BattleManager.action_forced_battler         
  2520.          BattleManager.clear_action_force              
  2521.          execute_force_action         
  2522.          @subject = last_subject
  2523.       end
  2524.   end
  2525.   
  2526.   #--------------------------------------------------------------------------
  2527.   # ● Execute Force Action
  2528.   #--------------------------------------------------------------------------
  2529.   def execute_force_action
  2530.       return if scene_changing?
  2531.       if !@subject || !@subject.current_action
  2532.          @subject = BattleManager.next_subject
  2533.       end
  2534.       return turn_end unless @subject      
  2535.       if @subject.current_action        
  2536.          @subject.current_action.prepare
  2537.          if @subject.current_action.valid?
  2538.             @status_window.open
  2539.             execute_action
  2540.          end
  2541.          @subject.remove_current_action
  2542.        end
  2543.        process_action_end unless @subject.current_action
  2544.   end  
  2545.   
  2546.   #--------------------------------------------------------------------------
  2547.   # ● Subject Action
  2548.   #--------------------------------------------------------------------------  
  2549.   def subject_action
  2550.       return @subject.current_action.item rescue nil
  2551.   end  
  2552.   
  2553.   #--------------------------------------------------------------------------
  2554.   # ● Wait for Effect
  2555.   #--------------------------------------------------------------------------  
  2556.   alias mog_atb_cm_wait_for_effect wait_for_effect
  2557.   def wait_for_effect
  2558.       return if $game_troop.interpreter.running?
  2559.       mog_atb_cm_wait_for_effect
  2560.   end
  2561.   
  2562. end

  2563. #===============================================================================
  2564. # ■ Window Battle Skill
  2565. #===============================================================================
  2566. class Window_BattleSkill < Window_SkillList
  2567.   
  2568.   #--------------------------------------------------------------------------
  2569.   # ● Select Last
  2570.   #--------------------------------------------------------------------------
  2571.   alias mog_atb_f_select_last_skill select_last
  2572.   def select_last
  2573.       act = @actor.last_skill.object rescue nil
  2574.       act_data = @data.index(@actor.last_skill.object) rescue nil
  2575.       if act == nil or act_data == nil ; select(0) ; return ; end
  2576.       mog_atb_f_select_last_skill
  2577.   end

  2578. end

  2579. #===============================================================================
  2580. # ■ Window Battle Item
  2581. #===============================================================================
  2582. class Window_BattleItem < Window_ItemList
  2583.   
  2584.   #--------------------------------------------------------------------------
  2585.   # ● Select Last
  2586.   #--------------------------------------------------------------------------
  2587.   alias mog_atb_f_select_last_item select_last
  2588.   def select_last
  2589.       act = $game_party.last_item.object rescue nil
  2590.       act_data = @data.index($game_party.last_item.object) rescue nil
  2591.       if act == nil or act_data == nil ; select(0) ; return ; end
  2592.       mog_atb_f_select_last_item
  2593.   end
  2594.   
  2595. end

  2596. #===============================================================================
  2597. # ■ Scene Battle
  2598. #===============================================================================
  2599. class Scene_Battle < Scene_Base
  2600.   
  2601.   #--------------------------------------------------------------------------
  2602.   # ● Skip Command?
  2603.   #--------------------------------------------------------------------------
  2604.   def skip_command?
  2605.       return true if BattleManager.actor == nil
  2606.       return true if BattleManager.actor.dead?
  2607.       return true if BattleManager.actor.restriction != 0
  2608.       return false
  2609.   end
  2610.   
  2611.   #--------------------------------------------------------------------------
  2612.   # ● Command Attack
  2613.   #--------------------------------------------------------------------------
  2614.   alias mog_atb_f_command_attack command_attack
  2615.   def command_attack
  2616.       if skip_command? ; break_command ; return ; end
  2617.       mog_atb_f_command_attack
  2618.   end

  2619.   #--------------------------------------------------------------------------
  2620.   # ● Command Skill
  2621.   #--------------------------------------------------------------------------
  2622.   alias mog_atb_f_command_skill command_skill
  2623.   def command_skill
  2624.       if skip_command? ; break_command ; return ; end
  2625.       mog_atb_f_command_skill
  2626.   end

  2627.   #--------------------------------------------------------------------------
  2628.   # ● Command Guard
  2629.   #--------------------------------------------------------------------------
  2630.   alias mog_atb_f_command_guard command_guard
  2631.   def command_guard
  2632.       if skip_command? ; break_command ; return ; end
  2633.       mog_atb_f_command_guard
  2634.       BattleManager.command_end
  2635.       hide_base_window      
  2636.   end
  2637.   
  2638.   #--------------------------------------------------------------------------
  2639.   # ● Command Item
  2640.   #--------------------------------------------------------------------------
  2641.   alias mog_atb_f_command_item command_item
  2642.   def command_item
  2643.       if skip_command? ; break_command ; return ; end
  2644.       mog_atb_f_command_item
  2645.   end  
  2646.   
  2647. end

  2648. #==============================================================================
  2649. # ■ SpritesetBattle
  2650. #==============================================================================
  2651. class Spriteset_Battle
  2652.   
  2653.   include MOG_ATB_SYSTEM
  2654.   
  2655.   #--------------------------------------------------------------------------
  2656.   # ● Initialize
  2657.   #--------------------------------------------------------------------------   
  2658.   alias mog_atb_display_turn_initialize initialize
  2659.   def initialize
  2660.       create_turn_number
  2661.       mog_atb_display_turn_initialize
  2662.   end
  2663.   
  2664.   #--------------------------------------------------------------------------
  2665.   # ● Dispose
  2666.   #--------------------------------------------------------------------------  
  2667.   alias mog_atb_display_turn_dispose dispose
  2668.   def dispose
  2669.       mog_atb_display_turn_dispose
  2670.       dispose_turn_number
  2671.   end
  2672.   
  2673.   #--------------------------------------------------------------------------
  2674.   # ● Update
  2675.   #--------------------------------------------------------------------------   
  2676.   alias mog_atb_display_turn_update update
  2677.   def update
  2678.       mog_atb_display_turn_update
  2679.       update_turn_number
  2680.   end

  2681.   #--------------------------------------------------------------------------
  2682.   # ● Create Turn Number
  2683.   #--------------------------------------------------------------------------   
  2684.   def create_turn_number
  2685.       return if !DISPLAY_TURN_NUMBER
  2686.       @turn_count_old = $game_troop.turn_count
  2687.       @turn_sprite = Sprite.new
  2688.       @turn_sprite.bitmap = Bitmap.new(120,32)
  2689.       @turn_sprite.bitmap.font.size = TURN_NUMBER_FONT_SIZE
  2690.       @turn_sprite.bitmap.font.bold = TURN_NUMBER_FONT_BOLD
  2691.       @turn_sprite.z = TURN_NUMBER_Z
  2692.       @turn_sprite.x = TURN_NUMBER_POS[0] ; @turn_sprite.y = TURN_NUMBER_POS[1]
  2693.       refresh_turn_sprite
  2694.   end  
  2695.   
  2696.   #--------------------------------------------------------------------------
  2697.   # ● Refresh Turn Sprite
  2698.   #--------------------------------------------------------------------------   
  2699.   def refresh_turn_sprite
  2700.       @turn_count_old = $game_troop.turn_count
  2701.       @turn_sprite.bitmap.clear ; @turn_sprite.opacity = 255
  2702.       turn_text = TURN_WORD + $game_troop.turn_count.to_s
  2703.       @turn_sprite.bitmap.draw_text(0,0,120,32,turn_text,0)
  2704.   end
  2705.   
  2706.   #--------------------------------------------------------------------------
  2707.   # ● Dispose Turn Number
  2708.   #--------------------------------------------------------------------------   
  2709.   def dispose_turn_number
  2710.       return if @turn_sprite == nil
  2711.       @turn_sprite.bitmap.dispose ; @turn_sprite.dispose
  2712.   end
  2713.   
  2714.   #--------------------------------------------------------------------------
  2715.   # ● Update Turn Number
  2716.   #--------------------------------------------------------------------------   
  2717.   def update_turn_number
  2718.       return if @turn_sprite == nil
  2719.       refresh_turn_sprite if @turn_count_old != $game_troop.turn_count
  2720.       @turn_sprite.visible = turn_visible?
  2721.   end
  2722.   
  2723.   #--------------------------------------------------------------------------
  2724.   # ● Turn Visible?
  2725.   #--------------------------------------------------------------------------   
  2726.   def turn_visible?
  2727.       return false if !$game_temp.sprite_visible
  2728.       return false if !$game_system.atb_sprite_turn
  2729.       return true
  2730.   end
  2731.   
  2732. end

  2733. #==============================================================================
  2734. # ■ Window BattleLog
  2735. #==============================================================================
  2736. class Window_BattleLog < Window_Selectable   
  2737.   include MOG_COOPERATION_SKILLS
  2738.   
  2739.   #--------------------------------------------------------------------------
  2740.   # ● Display Skill/Item Use
  2741.   #--------------------------------------------------------------------------
  2742.   alias mog_cskill_display_use_item display_use_item
  2743.   def display_use_item(subject, item)
  2744.       return if cooperation_skill_users?(subject, item)
  2745.       mog_cskill_display_use_item(subject, item)
  2746.   end
  2747.   
  2748.   #--------------------------------------------------------------------------
  2749.   # ● Cooperation Skill_users?
  2750.   #--------------------------------------------------------------------------
  2751.   def cooperation_skill_users?(subject, item)
  2752.       return false if subject.is_a?(Game_Enemy)
  2753.       return false if !item.is_a?(RPG::Skill)
  2754.       return false if !BattleManager.is_cskill?(item.id)
  2755.       return false if !BattleManager.actor_included_in_cskill?(subject.id,item.id)
  2756.       members = BattleManager.cskill_members(item.id) ; subject_name = ""
  2757.       if members.size <=0  
  2758.          members.each_with_index do |b,index|     
  2759.          if index == members.size - 1 ; subject_name += b.name
  2760.          else ; subject_name += b.name + " " + "and" + " "
  2761.          end
  2762.          end
  2763.       else
  2764.          subject_name += $game_party.name
  2765.       end
  2766.       add_text(subject_name + item.message1)
  2767.       unless item.message2.empty? ; wait ; add_text(item.message2) ; end
  2768.   end
  2769.   
  2770. end

  2771. #==============================================================================
  2772. # ■ Game_Battler
  2773. #==============================================================================
  2774. class Game_BattlerBase  

  2775.   #--------------------------------------------------------------------------
  2776.   # ● Pay Skill Cost
  2777.   #--------------------------------------------------------------------------   
  2778.   alias mog_cskill_pay_skill_cost pay_skill_cost
  2779.   def pay_skill_cost(skill)
  2780.       if self.is_a?(Game_Actor) and BattleManager.cskill_usable?(skill.id,self.id)
  2781.            BattleManager.pay_cskill_cost(skill)
  2782.          return
  2783.       end
  2784.       mog_cskill_pay_skill_cost(skill)
  2785.   end

  2786. end

  2787. #==============================================================================
  2788. # ■ BattleManager
  2789. #==============================================================================
  2790. module BattleManager
  2791.   include MOG_COOPERATION_SKILLS
  2792.   
  2793.   #--------------------------------------------------------------------------
  2794.   # ● Cooperation Skill Enable?
  2795.   #--------------------------------------------------------------------------
  2796.   def self.cskill_enable?(skill_id)
  2797.       return false if actor == nil
  2798.       return false if !actor_included_in_cskill?(actor.id,skill_id)
  2799.       return false if !ckill_members_usable?(skill_id)
  2800.       return false if !cskill_all_members_available?(skill_id)
  2801.       return true
  2802.   end
  2803.   
  2804.   #--------------------------------------------------------------------------
  2805.   # ● Cskill Usable?
  2806.   #--------------------------------------------------------------------------
  2807.   def self.cskill_usable?(skill_id,actor_id)
  2808.       return false if !is_cskill?(skill_id)
  2809.       return false if !actor_included_in_cskill?(actor_id,skill_id)
  2810.       return false if !cskill_members_alive?(skill_id)
  2811.       return true
  2812.   end  
  2813.   
  2814.   #--------------------------------------------------------------------------
  2815.   # ● Pay Cskill Cost
  2816.   #--------------------------------------------------------------------------
  2817.   def self.pay_cskill_cost(skill)
  2818.       cskill_members(skill.id).each do |battler|
  2819.          battler.face_animation = [60 ,2,0] if $imported[:mog_battle_hud_ex]
  2820.          $game_temp.remove_order(battler)
  2821.          battler.mp -= battler.skill_mp_cost(skill)
  2822.          battler.tp -= battler.skill_tp_cost(skill)
  2823.       end
  2824.   end   
  2825.    
  2826.   #--------------------------------------------------------------------------
  2827.   # ● Cskill Members Usable?
  2828.   #--------------------------------------------------------------------------
  2829.   def self.ckill_members_usable?(skill_id)
  2830.       skill = $data_skills[skill_id] rescue nil
  2831.       return false if skill == nil   
  2832.       cskill_members(skill_id).each do |battler|
  2833.            return false if !battler.atb_max?
  2834.            return false if battler == subject
  2835.            return false if battler.restriction != 0
  2836.            return false if !battler.skill_cost_payable?(skill)
  2837.            return false if !battler.usable?(skill)
  2838.       end
  2839.       return true
  2840.   end
  2841.   
  2842.   #--------------------------------------------------------------------------
  2843.   # ● Cskill Actor?
  2844.   #--------------------------------------------------------------------------
  2845.   def self.ckill_actor?(self_actor)
  2846.       item = self_actor.current_action.item rescue nil
  2847.       return false if item == nil
  2848.       include = false
  2849.       cskill_members(item.id).each do |battler|
  2850.       include = true if self_actor == battler
  2851.       end  
  2852.       return true if include
  2853.       return false
  2854.   end  
  2855.   
  2856.   #--------------------------------------------------------------------------
  2857.   # ● Cskill All Members Available?
  2858.   #--------------------------------------------------------------------------
  2859.   def self.cskill_all_members_available?(skill_id)
  2860.       return false if COOPERATION_SKILLS[skill_id].size != cskill_members(skill_id).size
  2861.       return true
  2862.   end  
  2863.    
  2864.   #--------------------------------------------------------------------------
  2865.   # ● Cooperation Members
  2866.   #--------------------------------------------------------------------------
  2867.   def self.cskill_members(skill_id)
  2868.       return [] if COOPERATION_SKILLS[skill_id].nil?
  2869.       members = []
  2870.       $game_party.battle_members.each do |battler|
  2871.       members.push(battler) if COOPERATION_SKILLS[skill_id].include?(battler.id)
  2872.       end
  2873.       return members
  2874.   end
  2875.   
  2876.   #--------------------------------------------------------------------------
  2877.   # ● Cskill Members Skill Cost?
  2878.   #--------------------------------------------------------------------------
  2879.   def self.cskill_members_skill_cost?(skill_id)
  2880.       skill = $data_skills[skill_id] rescue nil
  2881.       return false if skill == nil
  2882.       cskill_members(skill_id).each do |battler|
  2883.       return false if !battler.skill_conditions_met?(skill)
  2884.       end
  2885.       return true
  2886.   end  
  2887.    
  2888.   #--------------------------------------------------------------------------
  2889.   # ● Cskill Members Usable?
  2890.   #--------------------------------------------------------------------------
  2891.   def self.cskill_members_alive?(skill_id)
  2892.       skill = $data_skills[skill_id] rescue nil
  2893.       return false if skill == nil   
  2894.       alive = true
  2895.       cskill_members(skill_id).each do |battler|
  2896.           alive = false if battler.dead?
  2897.           alive = false if battler.restriction != 0
  2898.           alive = false if !battler.skill_cost_payable?(skill)
  2899.       end
  2900.       if !alive
  2901.          force_clear_cskill(skill_id)
  2902.          return false
  2903.       end
  2904.       return true
  2905.   end
  2906.   
  2907.   #--------------------------------------------------------------------------
  2908.   # ● Force Clear Cskill
  2909.   #--------------------------------------------------------------------------
  2910.   def self.force_clear_cskill(skill_id)
  2911.       cskill_members(skill_id).each do |battler| battler.turn_clear
  2912.       battler.atb_cast.clear
  2913.       battler.bact_sprite_need_refresh = true if $imported[:mog_sprite_actor]
  2914.       end
  2915.   end
  2916.   
  2917.   #--------------------------------------------------------------------------
  2918.   # ● Execute Cast Action Members
  2919.   #--------------------------------------------------------------------------
  2920.   def self.execute_cast_action_members(skill_id)
  2921.       cskill_members(skill_id).each do |battler|
  2922.          battler.next_turn = true
  2923.          battler.atb = battler.atb_max
  2924.          battler.atb_cast.clear
  2925.       end
  2926.   end
  2927.   
  2928.   #--------------------------------------------------------------------------
  2929.   # ● Set Members CP Skills
  2930.   #--------------------------------------------------------------------------
  2931.   def self.set_members_cp_skill(skill_id)
  2932.       skill = $data_skills[skill_id] rescue nil
  2933.       return false if skill == nil   
  2934.       cskill_members(skill_id).each do |battler|
  2935.            battler.atb = 0
  2936.            battler.actions = @command_actor.actions if @command_actor.actions != nil
  2937.            $game_temp.remove_order(battler)
  2938.            if skill.speed.abs == 0
  2939.               battler.atb_cast = [skill,50,50]
  2940.            else
  2941.               battler.atb_cast = [skill,skill.speed.abs,0]
  2942.            end
  2943.            battler.animation_id = MOG_COOPERATION_SKILLS::COOPERATION_SKILL_ANIMATION
  2944.       end
  2945.   end
  2946.   
  2947.   #--------------------------------------------------------------------------
  2948.   # ● Clear Members Cp Skill
  2949.   #--------------------------------------------------------------------------
  2950.   def self.clear_members_ckill(subject)
  2951.       return if subject.is_a?(Game_Enemy)
  2952.       return if subject == nil
  2953.       skill = subject.current_action.item rescue nil
  2954.       return if skill == nil
  2955.       return if !is_cskill?(skill.id)
  2956.       return if !actor_included_in_cskill?(subject.id,skill.id)
  2957.       cskill_members(skill.id).each do |battler| battler.turn_clear ; end
  2958.   end
  2959.   
  2960.   #--------------------------------------------------------------------------
  2961.   # ● Actor Included in Cooperation Skill?
  2962.   #--------------------------------------------------------------------------
  2963.   def self.actor_included_in_cskill?(actor_id,skill_id)
  2964.       return false if !SceneManager.scene_is?(Scene_Battle)
  2965.       return false if !is_cskill?(skill_id)
  2966.       return false if !COOPERATION_SKILLS[skill_id].include?(actor_id)
  2967.       return true
  2968.   end
  2969.   
  2970.   #--------------------------------------------------------------------------
  2971.   # ● Is Cooperation Skill?
  2972.   #--------------------------------------------------------------------------
  2973.   def self.is_cskill?(skill_id)
  2974.       return false if !SceneManager.scene_is?(Scene_Battle)
  2975.       return false if COOPERATION_SKILLS[skill_id].nil?
  2976.       return true
  2977.   end
  2978.   
  2979. end

  2980. #==============================================================================
  2981. # ■ BattleManager
  2982. #==============================================================================
  2983. class << BattleManager
  2984.   
  2985.   #--------------------------------------------------------------------------
  2986.   # ● Set Cast Action
  2987.   #--------------------------------------------------------------------------
  2988.   alias mog_cskill_command_end_actor command_end_actor
  2989.   def command_end_actor
  2990.       prepare_ckill_members
  2991.       mog_cskill_command_end_actor      
  2992.   end
  2993.   
  2994.   #--------------------------------------------------------------------------
  2995.   # ● Prepare Cskill Members
  2996.   #--------------------------------------------------------------------------
  2997.   def prepare_ckill_members
  2998.       item = @command_actor.current_action.item rescue nil  
  2999.       return if item == nil
  3000.       if is_cskill?(item.id) and ckill_members_usable?(item.id)
  3001.           set_members_cp_skill(item.id)
  3002.           @command_actor = nil
  3003.       end  
  3004.   end
  3005.    
  3006.   #--------------------------------------------------------------------------
  3007.   # ● Clear Cskills Members
  3008.   #--------------------------------------------------------------------------
  3009.   def clear_cskill_members(subject)
  3010.       item = subject.current_action.item rescue nil  
  3011.       return if item == nil
  3012.       clear_members_ckill(item.id) if is_cskill?(item.id)
  3013.   end
  3014.   
  3015. end

  3016. #==============================================================================
  3017. # ■ Window SkillList
  3018. #==============================================================================
  3019. class Window_SkillList < Window_Selectable
  3020.   
  3021.   #--------------------------------------------------------------------------
  3022.   # ● Display Skill in Active State?
  3023.   #--------------------------------------------------------------------------
  3024.   alias mog_atb_skill_list_enable? enable?
  3025.   def enable?(item)
  3026.       if SceneManager.scene_is?(Scene_Battle) and !item.nil?
  3027.          return false if BattleManager.is_cskill?(item.id) and !BattleManager.cskill_enable?(item.id)
  3028.       end
  3029.       mog_atb_skill_list_enable?(item)
  3030.   end   

  3031. end

  3032. #==============================================================================
  3033. # ■ Game Battler
  3034. #==============================================================================
  3035. class Game_Battler < Game_BattlerBase
  3036.   
  3037.   #--------------------------------------------------------------------------
  3038.   # ● Calculate Damage
  3039.   #--------------------------------------------------------------------------
  3040.   alias mog_atb_make_make_damage_value make_damage_value
  3041.   def make_damage_value(user, item)
  3042.       mog_atb_make_make_damage_value(user, item)
  3043.       coop_make_damage_value(user, item) if coop_make_damage_value?(user, item)
  3044.   end
  3045.   
  3046.   #--------------------------------------------------------------------------
  3047.   # ● Calculate Damage
  3048.   #--------------------------------------------------------------------------
  3049.   def coop_make_damage_value?(user, item)
  3050.       return false if item == nil
  3051.       return false if user.is_a?(Game_Enemy)
  3052.       return false if item.is_a?(RPG::Item)
  3053.       return false if !BattleManager.is_cskill?(item.id)
  3054.       return false if BattleManager.cskill_members(item.id).size < 1
  3055.       return true
  3056.   end
  3057.   
  3058.   #--------------------------------------------------------------------------
  3059.   # ● Coop Make Damage Value
  3060.   #--------------------------------------------------------------------------
  3061.   def coop_make_damage_value(user, item)
  3062.       for actor in BattleManager.cskill_members(item.id)
  3063.           next if actor == user
  3064.           value = item.damage.eval(actor, self, $game_variables)
  3065.           value *= item_element_rate(actor, item)
  3066.           value *= pdr if item.physical?
  3067.           value *= mdr if item.magical?
  3068.           value *= rec if item.damage.recover?
  3069.           value = apply_critical(value) if @result.critical
  3070.           value = apply_variance(value, item.damage.variance)
  3071.           value = apply_guard(value)
  3072.           @result.make_damage_coop(value.to_i, item)
  3073.       end
  3074.       @result.make_damage_coop_after(item)
  3075.   end
  3076.   
  3077. end

  3078. #==============================================================================
  3079. # ■ Game ActionResult
  3080. #==============================================================================
  3081. class Game_ActionResult
  3082.   
  3083.   #--------------------------------------------------------------------------
  3084.   # ● Create Damage
  3085.   #--------------------------------------------------------------------------
  3086.   def make_damage_coop(value, item)
  3087.       @hp_damage += value if item.damage.to_hp?
  3088.       @mp_damage += value if item.damage.to_mp?
  3089.   end   
  3090.      
  3091.   #--------------------------------------------------------------------------
  3092.   # ● Make Damage Coop After
  3093.   #--------------------------------------------------------------------------
  3094.   def make_damage_coop_after(item)
  3095.       @hp_damage /= BattleManager.cskill_members(item.id).size if item.damage.to_hp?
  3096.       @mp_damage /= BattleManager.cskill_members(item.id).size if item.damage.to_mp?   
  3097.       @critical = false if @hp_damage == 0
  3098.       @mp_damage = [@battler.mp, @mp_damage].min
  3099.       @hp_drain = @hp_damage if item.damage.drain?
  3100.       @mp_drain = @mp_damage if item.damage.drain?
  3101.       @hp_drain = [@battler.hp, @hp_drain].min
  3102.       @success = true if item.damage.to_hp? || @mp_damage != 0
  3103.   end
  3104.   
  3105. end

  3106. #==============================================================================
  3107. # ■ Game_Battler
  3108. #==============================================================================
  3109. class Game_Battler < Game_BattlerBase
  3110.   
  3111.   #--------------------------------------------------------------------------
  3112.   # ● Execute Cast Action
  3113.   #--------------------------------------------------------------------------   
  3114.   alias mog_cskill_execute_cast_action execute_cast_action
  3115.   def execute_cast_action
  3116.       mog_cskill_execute_cast_action
  3117.       prepare_cast_action_members
  3118.   end
  3119.   
  3120.   #--------------------------------------------------------------------------
  3121.   # ● Prepare Cast Acton Members
  3122.   #--------------------------------------------------------------------------   
  3123.   def prepare_cast_action_members
  3124.       return if self.is_a?(Game_Enemy)
  3125.       item = self.current_action.item rescue nil  
  3126.       return if item == nil   
  3127.       BattleManager.execute_cast_action_members(item.id) if BattleManager.cskill_usable?(item.id,self.id)
  3128.   end
  3129.   
  3130.   #--------------------------------------------------------------------------
  3131.   # ● ATB After Damage
  3132.   #--------------------------------------------------------------------------  
  3133.   alias mog_cpskill_atb_after_damage atb_after_damage
  3134.   def atb_after_damage(pre_item = nil)
  3135.       mog_cpskill_atb_after_damage(pre_item)
  3136.       force_clear_cpkill(pre_item) if pre_item != nil and self.is_a?(Game_Actor)
  3137.   end  
  3138.   
  3139.   #--------------------------------------------------------------------------
  3140.   # ● Force Clear CP skill
  3141.   #--------------------------------------------------------------------------   
  3142.   def force_clear_cpkill(pre_item = nil)
  3143.       $game_temp.refresh_item_window = true if @result.mp_damage != 0
  3144.       BattleManager.cskill_usable?(pre_item.id,self.id) if pre_item != nil      
  3145.   end

  3146.   #--------------------------------------------------------------------------
  3147.   # ● Need Refresh Item Window?
  3148.   #--------------------------------------------------------------------------   
  3149.   alias mog_cskills_need_refresh_item_window? need_refresh_item_window?
  3150.   def need_refresh_item_window?
  3151.       return true
  3152.       mog_cskills_need_refresh_item_window?
  3153.   end
  3154.   
  3155.   #--------------------------------------------------------------------------
  3156.   # ● Execute Damage
  3157.   #--------------------------------------------------------------------------   
  3158.   alias mog_atb_coop_execute_damage execute_damage
  3159.   def execute_damage(user)
  3160.       mog_atb_coop_execute_damage(user)
  3161.       item = user.current_action.item rescue nil
  3162.       execute_damage_coop(user,item) if user.coop_make_damage_value?(user, item)
  3163.   end
  3164.   
  3165.   #--------------------------------------------------------------------------
  3166.   # ● Execute Damage Coop
  3167.   #--------------------------------------------------------------------------   
  3168.   def execute_damage_coop(user,item)
  3169.       for actor in BattleManager.cskill_members(item.id)
  3170.           next if actor == user
  3171.           actor.hp += @result.hp_drain
  3172.           actor.mp += @result.mp_drain
  3173.           if $imported[:mog_damage_popup]
  3174.              actor.damage.push([[email]-@result.hp_drain[/email],"HP",@result.critical]) if @result.hp_drain != 0
  3175.              actor.damage.push([[email]-@result.mp_drain[/email],"MP",@result.critical]) if @result.mp_drain != 0
  3176.           end   
  3177.       end   
  3178.   end
  3179.   
  3180. end

  3181. #==============================================================================
  3182. # ■ Scene Battle
  3183. #==============================================================================
  3184. class Scene_Battle < Scene_Base

  3185.   #--------------------------------------------------------------------------
  3186.   # ● Process Before Execute Action
  3187.   #--------------------------------------------------------------------------  
  3188.   alias mog_cskill_process_before_execute_action  process_before_execute_action
  3189.   def process_before_execute_action
  3190.       mog_cskill_process_before_execute_action
  3191.       before_execute_cooperation_skill if can_execute_cooperation_skill?
  3192.   end

  3193.   #--------------------------------------------------------------------------
  3194.   # ● Process Before Remove Action
  3195.   #--------------------------------------------------------------------------  
  3196.   alias mog_cskill_process_before_remove_action process_before_remove_action
  3197.   def process_before_remove_action
  3198.       mog_cskill_process_before_remove_action
  3199.       BattleManager.clear_members_ckill(@subject)
  3200.   end

  3201.   #--------------------------------------------------------------------------
  3202.   # ● Can Execute Cooperation Skill?
  3203.   #--------------------------------------------------------------------------  
  3204.   def can_execute_cooperation_skill?
  3205.       return false if !@subject.is_a?(Game_Actor)
  3206.       item = @subject.current_action.item rescue nil
  3207.       return false if item == nil
  3208.       return false if !BattleManager.cskill_usable?(item.id,@subject.id)
  3209.       return true
  3210.   end

  3211.   #--------------------------------------------------------------------------
  3212.   # ● Current CP Members
  3213.   #--------------------------------------------------------------------------
  3214.   def current_cp_members
  3215.       return [] if subject_action == nil
  3216.       return BattleManager.cskill_members(subject_action.id)
  3217.   end   
  3218.   
  3219.   #--------------------------------------------------------------------------
  3220.   # ● Before Execute Coomperation Skill. (add-ons)
  3221.   #--------------------------------------------------------------------------  
  3222.   def before_execute_cooperation_skill
  3223.   end

  3224. end
复制代码

点评

好的,抱歉打扰了,谢谢  发表于 2017-1-30 13:06
葡萄牙语注释,不想看(逃)  发表于 2017-1-30 12:26
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部