#==============================================================================
# +++ MOG - ATB System (v 6.1) +++
#==============================================================================
# By Moghunter
# https://atelierrgss.wordpress.com/
#==============================================================================
# Sistema de batalha ativo.
#==============================================================================
#==============================================================================
# NOTA 1
#==============================================================================
# O script não vem com medidor de ATB incluído, será necessário usar scripts
# add-ons para adicionar os medidores.
#
# Battle Hud EX
# Ayesha ATB Gauge
# Schala ATB Gauge
#
#==============================================================================
# NOTA 2
#==============================================================================
# A janela de LOG está desativada para deixar a batalha mais dinâmica.
# Portanto é necessário usar algum script de Damage Popup para ver os danos
# causados no alvo
#==============================================================================
#==============================================================================
# ● ATB SYSTEM
#==============================================================================
# A velocidade de AT é baseaddo na agilidade do Battler.
# Em caso de batalhas preventivas (Preemptive) os aliados começarão com AT em
# 80% e os inimigos começarão com AT em 0 (Zero)
# Em batalhas surpresas (Surprise) é o inverso das batalhas preventivas.
# Em batalhas normais todos os battlers começarão com AT em 40%.
#==============================================================================
# ● CAST TIME
#==============================================================================
# Para definir uma habilidade ou item com a função de Cast Time basta definir
# o valor da velocidade (Speed) diferente de 0 (Zero).
#
# NOTA - Não é possível ativar 2 ou mais habilidades com a função Cast Time no
# mesmo turno. (Caso você esteja usando características de Multi Action em
# seu projeto.)
#==============================================================================
#==============================================================================
# COMANDOS DE EVENTOS
#==============================================================================
#
# atb_type(type) - Define o tipo de ATB.
# atb_max(X) - Define o tempo de ATB.
# atb_stop - Pausa o ATB e o Turno.
# atb_turn_speed(X) - Define o tempo do turno.
# atb_turn_stop - Pausa apenas o turno.
# atb_turn_reset - Zera o tempo do turno atual.
# atb_sprite_turn(false) - Ativar/Desativa o número do turno.
#
#==============================================================================
#==============================================================================
# Histórico
#==============================================================================
# v6.1 - Correção do crash na seleção de skills vazias.
# v6.0 - Melhorias no sistema do evento comum.
#==============================================================================
$imported = {} if $imported.nil?
$imported[:mog_atb_system] = true
#==============================================================================
# Cooperation Skills
#==============================================================================
module MOG_COOPERATION_SKILLS
COOPERATION_SKILLS = [] # ☢CAUTION!!☢ Don't Touch.^_^
#--------------------------------------------------------------------------
# Definição das skills
#
# COOPERATION_SKILLS[SKILL_ID] = [ACTOR_ID, ACTOR_ID, ACTOR_ID, ACTOR_ID]
#--------------------------------------------------------------------------
# COOPERATION_SKILLS[51] = [2,4] # Fire
# COOPERATION_SKILLS[66] = [2,4,3] # Quake
COOPERATION_SKILLS[104] = [1,5] # Ouka Mugen jin
COOPERATION_SKILLS[143] = [3,4] # Flare
COOPERATION_SKILLS[151] = [1,2,3,4] # Ultima
COOPERATION_SKILLS[153] = [2,4] # W Ultima End
#--------------------------------------------------------------------------
#Definição da animação ao ativar as habilidades de cooperação.
#--------------------------------------------------------------------------
COOPERATION_SKILL_ANIMATION = 49
end
#==============================================================================
# GENERAL SETTING
#==============================================================================
module MOG_ATB_SYSTEM
#--------------------------------------------------------------------------
# Definição do tipo de ATB
#
# 0 - Wait
# 1 - Semi Active
# 2 - Full ACtive
#
# É possível mudar o tipo de ATB no meio do jogo usando o código abaixo.
#
# atb_type(type)
#
#--------------------------------------------------------------------------
ATB_TYPE = 1
#--------------------------------------------------------------------------
#Som quando o sistema ATB estiver no maximo
#--------------------------------------------------------------------------
SE_ACTIVE = "Decision2"
#--------------------------------------------------------------------------
# Definição do valor de ATB para ativar a ação.
# É possível mudar o valor no meio do jogo usando o código abaixo.
#
# atb_max(X)
#
#--------------------------------------------------------------------------
ATB_MAX = 5000
#--------------------------------------------------------------------------
# Definição do tipo de duração (Contagem/formula) de um turno.
# Essa definição influência na ativação dos eventos de batalha.
# (BATTLE EVENTS)
#
# 0 - Duração de um turno é um valor fixo.
# 1 - Duração de um turno é multiplicado pela quantidade de batllers.
# 2 - Duração de um turno é baseado na média de agilidade dos battlers.
#
#--------------------------------------------------------------------------
TURN_DURATION_TYPE = 0
#--------------------------------------------------------------------------
# Definição de valor usado para calcular a duração de um turno.
#--------------------------------------------------------------------------
TURN_DURATION = 500
#--------------------------------------------------------------------------
# Definição da animação quando o battler usa habilidades de carregamento.
#--------------------------------------------------------------------------
CAST_ANIMATION = 49
#--------------------------------------------------------------------------
# Ativar a mensagem inicial com os nomes dos inimigos.
#--------------------------------------------------------------------------
MESSAGE_ENEMY_APPEAR = false
#--------------------------------------------------------------------------
# Ativar o botão de pular turno.
#--------------------------------------------------------------------------
ENABLE_BUTTON_NEXT_ACTOR = true
#--------------------------------------------------------------------------
# Definição do botão pular turno.
#--------------------------------------------------------------------------
BUTTON_NEXT_ACTOR_RIGHT = :R
BUTTON_NEXT_ACTOR_LEFT = :L
#--------------------------------------------------------------------------
# Apresentar o Turno.
# É possível desativar / ativar o turno usando o código abaixo.
#
# atb_sprite_turn(false)
#
#--------------------------------------------------------------------------
DISPLAY_TURN_NUMBER = false
#--------------------------------------------------------------------------
# Definição da palavra Turno.
#--------------------------------------------------------------------------
TURN_WORD = "Turn "
#--------------------------------------------------------------------------
# Tamanho da fonte
#--------------------------------------------------------------------------
TURN_NUMBER_FONT_SIZE = 24
#--------------------------------------------------------------------------
# Ativar bold.
#--------------------------------------------------------------------------
TURN_NUMBER_FONT_BOLD = true
#--------------------------------------------------------------------------
# Posição Z.
#--------------------------------------------------------------------------
TURN_NUMBER_Z = 100
#--------------------------------------------------------------------------
# Posição X & Y.
#--------------------------------------------------------------------------
TURN_NUMBER_POS = [5,0]
end
#==============================================================================
# ■ Game Temp
#==============================================================================
class Game_Temp
attr_accessor :atb_in_turn
attr_accessor :atb_wait
attr_accessor :atb_user
attr_accessor :atb_stop
attr_accessor :atb_actor_order
attr_accessor :atb_break_duration
attr_accessor :battle_end
attr_accessor :battle_end2
attr_accessor :turn_duration_clear
attr_accessor :refresh_battle_atb
attr_accessor :end_phase_duration
attr_accessor :atb_frame_skip
attr_accessor :refresh_actor_command
attr_accessor :refresh_target_windows
attr_accessor :refresh_item_window
attr_accessor :actor_command_index
attr_accessor :actor_process_event
attr_accessor :break_command
attr_accessor :hwindow_atb
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_atb_temp_initialize initialize
def initialize
@atb_in_turn = false
@atb_wait = false
@atb_break_duration = 0
@atb_stop = [false,false]
@atb_actor_order = []
@turn_duration_clear = false
@battle_end = true
@battle_end2 = true
@refresh_battle_atb = false
@end_phase_duration = [false,0]
@atb_frame_skip = 0
@refresh_actor_command = false
@refresh_target_windows = [false,false]
@actor_command_index = 0
@refresh_item_window = false
@break_command = false
@actor_process_event = nil
@hwindow_atb = false
mog_atb_temp_initialize
end
#--------------------------------------------------------------------------
# ● Sprite Visible
#--------------------------------------------------------------------------
def sprite_visible
return false if $game_message.visible
return false if $game_temp.battle_end
return true
end
#--------------------------------------------------------------------------
# ● add Order
#--------------------------------------------------------------------------
def add_order(battler)
return if battler == nil
return if battler.is_a?(Game_Enemy)
$game_temp.atb_actor_order.push(battler)
end
#--------------------------------------------------------------------------
# ● Remove Order
#--------------------------------------------------------------------------
def remove_order(battler)
return if battler == nil
return if battler.is_a?(Game_Enemy)
$game_temp.atb_actor_order.delete(battler) rescue nil
end
end
#==============================================================================
# ■ Game_System
#==============================================================================
class Game_System
attr_accessor :atb_max
attr_accessor :atb_type
attr_accessor :atb_turn_duration
attr_accessor :atb_sprite_turn
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_at_system_initialize initialize
def initialize
@atb_max = [[MOG_ATB_SYSTEM::ATB_MAX, 999999].min, 1500].max
@atb_type = MOG_ATB_SYSTEM::ATB_TYPE ; @atb_sprite_turn = true
@atb_turn_duration = [0,
[[MOG_ATB_SYSTEM::TURN_DURATION, 999999].min, 50].max]
mog_at_system_initialize
end
end
#==============================================================================
# ■ Game Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● ATB Type
#--------------------------------------------------------------------------
def atb_type(type)
$game_system.atb_type = type
end
#--------------------------------------------------------------------------
# ● ATB Max
#--------------------------------------------------------------------------
def atb_max(value)
$game_system.atb_max = [[value, 999999].min, 1500].max
end
#--------------------------------------------------------------------------
# ● ATB Sprite Turn
#--------------------------------------------------------------------------
def atb_sprite_turn(value = true)
$game_system.atb_sprite_turn = value
end
#--------------------------------------------------------------------------
# ● ATB Turn Speed
#--------------------------------------------------------------------------
def atb_turn_speed(value = 400)
$game_system.atb_turn_duration[1] = [[value, 999999].min, 50].max
end
#--------------------------------------------------------------------------
# ● ATB force Turn
#--------------------------------------------------------------------------
def atb_force_turn(value)
$game_troop.turn_count = value
end
#--------------------------------------------------------------------------
# ● ATB Turn Reset
#--------------------------------------------------------------------------
def atb_turn_reset
$game_system.atb_turn_duration[0] = 0
end
#--------------------------------------------------------------------------
# ● Command 339
#--------------------------------------------------------------------------
def command_339
iterate_battler(@params[0], @params[1]) do |battler|
next if battler.death_state?
battler.turn_clear
if BattleManager.actor!= nil and battler == BattleManager.actor
BattleManager.actor.turn_clear
$game_temp.break_command = true
BattleManager.command_selection_clear
end
battler.force_action(@params[2], @params[3])
BattleManager.force_action(battler)
Fiber.yield while BattleManager.action_forced?
end
end
end
#==============================================================================
# ■ Game Troop
#==============================================================================
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# ● Can Interpreter Running?
#--------------------------------------------------------------------------
def can_interpreter_running?(tend = false)
BattleManager.turn_end if tend
return true if $game_temp.common_event_reserved?
return false if @interpreter.running?
return false if @interpreter.setup_reserved_common_event
troop.pages.each do |page|
next unless conditions_met?(page)
@current_page = page
return true
end
return false
end
#--------------------------------------------------------------------------
# ● Can Interpreter Hide Window?
#--------------------------------------------------------------------------
def can_interpreter_hide_window?
return false if @current_page == nil
@current_page.list.each do |l|
if l.code.between?(101,105) ; @current_page = nil ; return true ; end
end
@current_page = nil
return false
end
#--------------------------------------------------------------------------
# ● Can Interpreter Hide Window 2?
#--------------------------------------------------------------------------
def can_interpreter_hide_window_2?
return false if $game_temp.common_event_id == 0
common_event = $data_common_events[$game_temp.common_event_id] rescue nil
return false if common_event.nil?
common_event.list.each do |l|
return true if l.code.between?(101,105)
end
return false
end
#--------------------------------------------------------------------------
# ● Set Turn
#--------------------------------------------------------------------------
def set_turn(turn_value)
@turn_count = turn_value
end
end
#==============================================================================
# ■ Window Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_atb_wbase_initialize initialize
def initialize(x, y, width, height)
mog_atb_wbase_initialize(x, y, width, height)
@pre_data = [0,self.visible,self.active,self.opacity]
end
#--------------------------------------------------------------------------
# ● Hide All
#--------------------------------------------------------------------------
def hide_all
@index = 0 if @index ; self.visible = false ; self.active = false
update
end
#--------------------------------------------------------------------------
# ● Record Data
#--------------------------------------------------------------------------
def record_data
@pre_data = [@index ,self.visible ,self.active ,self.opacity]
update
end
#--------------------------------------------------------------------------
# ● Restore Data
#--------------------------------------------------------------------------
def restore_data
@index = @pre_data[0] if @index ; self.visible = @pre_data[1]
self.active = @pre_data[2] ; self.opacity = @pre_data[3]
update
end
end
#==============================================================================
# ■ Window Selectable
#==============================================================================
class Window_Selectable < Window_Base
attr_accessor :pre_data
#--------------------------------------------------------------------------
# ● Row Max
#--------------------------------------------------------------------------
def row_max
cm = col_max > 0 ? col_max : 1
[(item_max + cm - 1) / cm, 1].max
end
#--------------------------------------------------------------------------
# ● Row
#--------------------------------------------------------------------------
def row
cm = col_max > 0 ? col_max : 1
index / cm
end
#--------------------------------------------------------------------------
# ● Item Width
#--------------------------------------------------------------------------
def item_width
cm = col_max > 0 ? col_max : 1
(width - standard_padding * 2 + spacing) / cm - spacing
end
#--------------------------------------------------------------------------
# ● Item Rect
#--------------------------------------------------------------------------
def item_rect(index)
cm = col_max > 0 ? col_max : 1
rect = Rect.new
rect.width = item_width
rect.height = item_height
rect.x = index % cm * (item_width + spacing)
rect.y = index / cm * item_height
rect
end
#--------------------------------------------------------------------------
# ● Initialize
#-------------------------------------------------------------------------
alias mog_atb_sel_initialize initialize
def initialize(x, y, width, height)
mog_atb_sel_initialize(x, y, width, height)
@pre_data = [@index,self.visible,self.active,self.opacity]
end
#--------------------------------------------------------------------------
# ● Process Cursor Move
#--------------------------------------------------------------------------
alias mog_atb_wactor_process_cursor_move process_cursor_move
def process_cursor_move
return if SceneManager.scene_is?(Scene_Battle) and skip_command?
mog_atb_wactor_process_cursor_move
end
#--------------------------------------------------------------------------
# ● Process Handling
#--------------------------------------------------------------------------
alias mog_atb_wactor_process_handling process_handling
def process_handling
return if SceneManager.scene_is?(Scene_Battle) and skip_command?
mog_atb_wactor_process_handling
end
#--------------------------------------------------------------------------
# ● Process Handling
#--------------------------------------------------------------------------
def skip_command?
return false if self.is_a?(Window_VictorySpoils) if $imported["YEA-VictoryAftermath"]
return true if !$game_temp.sprite_visible
return true if $game_temp.battle_end
return true if $game_temp.end_phase_duration[1] > 0
return true if BattleManager.actor == nil
return false
end
end
#==============================================================================
# ■ Window_ActorCommand
#==============================================================================
class Window_ActorCommand < Window_Command
attr_accessor :actor
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
alias mog_atb_ac_update update
def update
mog_atb_ac_update
$game_temp.actor_command_index = self.index if self.active
end
if MOG_ATB_SYSTEM::ENABLE_BUTTON_NEXT_ACTOR
#--------------------------------------------------------------------------
# ● Process_Cursor Move
#--------------------------------------------------------------------------
def process_cursor_move
return unless cursor_movable?
last_index = @index
cursor_down (Input.trigger?(:DOWN)) if Input.repeat?(:DOWN)
cursor_up (Input.trigger?(:UP)) if Input.repeat?(:UP)
cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
cursor_left (Input.trigger?(:LEFT)) if Input.repeat?(:LEFT)
Sound.play_cursor if @index != last_index
end
end
if $imported["YEA-BattleEngine"]
#--------------------------------------------------------------------------
# ● Process_dir4
#--------------------------------------------------------------------------
def process_dir4
end
#--------------------------------------------------------------------------
# ● Process_dir6
#--------------------------------------------------------------------------
def process_dir6
end
end
#--------------------------------------------------------------------------
# ● Process Cursor Move
#--------------------------------------------------------------------------
alias mog_atb_bm_process_cursor_move process_cursor_move
def process_cursor_move
return if SceneManager.scene_is?(Scene_Battle) and BattleManager.actor == nil
mog_atb_bm_process_cursor_move
end
#--------------------------------------------------------------------------
# ● Process Handling
#--------------------------------------------------------------------------
alias mog_atb_bm_process_handling process_handling
def process_handling
return if SceneManager.scene_is?(Scene_Battle) and BattleManager.actor == nil
mog_atb_bm_process_handling
end
end
#==============================================================================
# ■ Window_BattleEnemy
#==============================================================================
class Window_BattleEnemy < Window_Selectable
#--------------------------------------------------------------------------
# ● Refresh
#--------------------------------------------------------------------------
alias mog_atb_battle_enemy_update update
def update
return if enemy == nil
mog_atb_battle_enemy_update
end
end
#==============================================================================
# ■ Window BattleLog
#==============================================================================
class Window_BattleLog < Window_Selectable
#--------------------------------------------------------------------------
# ● Display Added States
#--------------------------------------------------------------------------
def display_added_states(target)
return if target.turn_collapse
target.result.added_state_objects.each do |state|
state_msg = target.actor? ? state.message1 : state.message2
if state.id == target.death_state_id
target.perform_collapse_effect if target.hp == 0
end
next if state_msg.empty?
replace_text(target.name + state_msg)
target.turn_collapse = true if state.id == target.death_state_id
wait
wait_for_effect
end
end
#--------------------------------------------------------------------------
# ● Refresh
#--------------------------------------------------------------------------
def refresh
end
#--------------------------------------------------------------------------
# ● Message Speed
#--------------------------------------------------------------------------
def message_speed
return 10 if $imported["YEA-BattleEngine"]
return 5
end
#--------------------------------------------------------------------------
# * Wait for Effect
#--------------------------------------------------------------------------
def wait_for_effect
return false
end
end
#==============================================================================
# ■ Sprite Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
alias mog_atb_sprite_update update
def update
mog_atb_sprite_update
clear_atb_battler_dead if clear_atb_battler_dead?
end
#--------------------------------------------------------------------------
# ● Init Visibility
#--------------------------------------------------------------------------
alias mog_atb_init_visibility init_visibility
def init_visibility
self.visible = true
self.opacity = 255 if @battler.alive?
mog_atb_init_visibility
end
#--------------------------------------------------------------------------
# ● Clear ATB Battler
#--------------------------------------------------------------------------
def clear_atb_battler_dead?
return false if !self.visible
return false if @battler.nil?
return false if [email protected]?
return false if @battler.is_a?(Game_Actor)
return false if !@effect_type.nil?
return false if $imported[:mog_battler_motion] and !@collapse_done
return true
end
#--------------------------------------------------------------------------
# ● Clear ATB Battler Dead
#--------------------------------------------------------------------------
def clear_atb_battler_dead
self.opacity = 0
self.visible = false
@battler.atb_initial
end
end
#==============================================================================
# ■ Game Battler Base
#==============================================================================
class Game_BattlerBase
attr_accessor :hidden
#--------------------------------------------------------------------------
# ● Inputable?
#--------------------------------------------------------------------------
def inputable?
normal? && !auto_battle? && self.atb_max?
end
end
#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
attr_accessor :atb
attr_accessor :atb_max
attr_accessor :atb_cast
attr_accessor :atb_action
attr_accessor :atb_turn_duration
attr_accessor :atb_escape
attr_accessor :next_turn
attr_accessor :turn_collapse
attr_accessor :actions
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_at_system_initialize initialize
def initialize
mog_at_system_initialize
atb_init_setup
end
#--------------------------------------------------------------------------
# ● Atb Init Setup
#--------------------------------------------------------------------------
def atb_init_setup
@atb = 0
@atb_max = $game_system.atb_max
@atb_cast = []
@atb_turn_duration = 0
@next_turn = false
@atb_escape = false
@turn_collapse = false
@wait_motion = $imported[:mog_battler_motion] != nil ? true : false
end
#--------------------------------------------------------------------------
# ● Atb
#--------------------------------------------------------------------------
def atb
return 0 if self.hp == 0
return [[@atb, atb_max].min, 0].max
end
#--------------------------------------------------------------------------
# ● Max ATB
#--------------------------------------------------------------------------
def atb_max
return [$game_system.atb_max,100].max
end
#--------------------------------------------------------------------------
# ● Max AT?
#--------------------------------------------------------------------------
def atb_max?
self.atb >= atb_max
end
#--------------------------------------------------------------------------
# ● Atb Speed
#--------------------------------------------------------------------------
def atb_speed
return self.agi
end
#--------------------------------------------------------------------------
# ● ATB Update
#--------------------------------------------------------------------------
def atb_update?
return false if restriction >= 4
return false if self.hp == 0
return false if self.hidden
return false if @wait_motion && $game_temp.battler_in_motion
return true
end
#--------------------------------------------------------------------------
# ● ATB Update
#--------------------------------------------------------------------------
def atb_update
return if !atb_update?
if self.atb_cast.empty?
if !atb_max?
self.atb += self.atb_speed
execute_atb_max_effect if atb_max?
end
else
self.atb_cast[1] -= 1
execute_cast_action if self.atb_cast[1] <= 0
end
end
#--------------------------------------------------------------------------
# ● Execute Atb Max Effect
#--------------------------------------------------------------------------
def execute_atb_max_effect
$game_temp.refresh_item_window = true if need_refresh_item_window?
$game_temp.add_order(self)
end
#--------------------------------------------------------------------------
# ● Need Refresh Item Window?
#--------------------------------------------------------------------------
def need_refresh_item_window?
return false
end
#--------------------------------------------------------------------------
# ● Execute Cast Action
#--------------------------------------------------------------------------
def execute_cast_action
self.next_turn = true ; self.atb = self.atb_max ; self.atb_cast.clear
end
#--------------------------------------------------------------------------
# ● Atb Clear
#--------------------------------------------------------------------------
def atb_clear
self.atb = 0 ; self.atb_cast.clear ; self.turn_collapse = false
end
#--------------------------------------------------------------------------
# ● Atb Initial
#--------------------------------------------------------------------------
def atb_initial
@atb = 0 ; @atb_cast = [] ; @atb_turn_duration = 0
@atb_escape = false ; @next_turn = false ; clear_actions
end
#--------------------------------------------------------------------------
# ● Movable ATB
#--------------------------------------------------------------------------
def movable_atb?
return false if !atb_max?
return false if self.dead?
return false if self.restriction != 0
return false if self.next_turn
return false if !self.atb_cast.empty?
return true
end
#--------------------------------------------------------------------------
# ● Item Apply
#--------------------------------------------------------------------------
alias mog_atb_item_apply item_apply
def item_apply(user, item)
pre_item = self.current_action.item rescue nil
mog_atb_item_apply(user, item)
if SceneManager.scene_is?(Scene_Battle)
effect_for_dead if self.dead?
atb_after_damage(pre_item)
end
end
#--------------------------------------------------------------------------
# ● ATB After Damage
#--------------------------------------------------------------------------
def atb_after_damage(pre_item = nil)
$game_temp.break_command = true if can_damage_break_command?
turn_clear if self.restriction == 4 or self.dead?
$game_temp.remove_order(self) if self.restriction > 0 or self.dead?
$game_temp.battle_end2 = true if $game_troop.all_dead? or $game_party.all_dead?
end
#--------------------------------------------------------------------------
# ● Can Damage Break Command
#--------------------------------------------------------------------------
def can_damage_break_command?
return false if BattleManager.actor == nil
return false if BattleManager.actor != self
return true if BattleManager.actor.restriction > 0
return true if BattleManager.actor.dead?
return true if BattleManager.actor.hp == 0
return false
end
#--------------------------------------------------------------------------
# ● Turn Clear
#--------------------------------------------------------------------------
def turn_clear
self.atb_clear
self.atb_escape = false
self.clear_actions
self.next_turn = false
$game_temp.remove_order(self)
end
#--------------------------------------------------------------------------
# ● Effect for Dead
#--------------------------------------------------------------------------
def effect_for_dead
atb_initial
$game_temp.refresh_target_windows[0] = true if self.is_a?(Game_Actor)
$game_temp.refresh_target_windows[1] = true if self.is_a?(Game_Enemy)
if $imported[:mog_battle_cursor]
$game_temp.battle_cursor_need_refresh[0] = true if self.is_a?(Game_Actor)
$game_temp.battle_cursor_need_refresh[1] = true if self.is_a?(Game_Enemy)
end
end
#--------------------------------------------------------------------------
# ● Remove State Auto
#--------------------------------------------------------------------------
alias mog_atb_remove_states_auto remove_states_auto
def remove_states_auto(timing)
if SceneManager.scene_is?(Scene_Battle)
remove_states_auto_atb(timing) ; return
end
mog_atb_remove_states_auto(timing)
end
#--------------------------------------------------------------------------
# ● Remove State Auto ATB
#--------------------------------------------------------------------------
def remove_states_auto_atb(timing)
states.each do |state|
if @state_turns[state.id] == 0
if restriction == 4 ; remove_state(state.id) ; return ; end
unless state.auto_removal_timing == 2 and state.max_turns <= 1
remove_state(state.id)
end
end
end
end
#--------------------------------------------------------------------------
# ● Remove State Turn End
#--------------------------------------------------------------------------
def remove_state_turn_end
states.each do |state|
next if state.auto_removal_timing != 2
next if state.max_turns > 1
remove_state(state.id)
end
end
#--------------------------------------------------------------------------
# ● Die
#--------------------------------------------------------------------------
alias mog_atb_die die
def die
mog_atb_die
self.turn_clear ; self.atb_turn_duration = 0
end
#--------------------------------------------------------------------------
# ● Revive
#--------------------------------------------------------------------------
alias mog_atb_revive revive
def revive
mog_atb_revive
self.turn_clear ; per = 25 * self.atb_max / 100 ; self.atb = rand(per)
self.atb_turn_duration = 0
end
#--------------------------------------------------------------------------
# ● Create Battle Action
#--------------------------------------------------------------------------
alias mog_atb_make_actions make_actions
def make_actions
return if !self.atb_cast.empty?
item = self.current_action.item rescue nil
return if item != nil
mog_atb_make_actions
end
end
#==============================================================================
# ■ Game Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ● Tranform
#--------------------------------------------------------------------------
alias mog_at_system_transform transform
def transform(enemy_id)
mog_at_system_transform(enemy_id)
self.atb_clear
end
end
#==============================================================================
# ■ BattleManager
#==============================================================================
module BattleManager
#--------------------------------------------------------------------------
# ● Start Command Input
#--------------------------------------------------------------------------
def self.input_start
@phase = :input if @phase != :input
return !@surprise && $game_party.inputable?
end
#--------------------------------------------------------------------------
# ● Battle Start
#--------------------------------------------------------------------------
def self.battle_start
$game_system.battle_count += 1
$game_party.on_battle_start
$game_troop.on_battle_start
atb_initial_setup ; @turn_duration = set_turn_duration
if MOG_ATB_SYSTEM::MESSAGE_ENEMY_APPEAR
$game_troop.enemy_names.each do |name|
$game_message.add(sprintf(Vocab::Emerge, name))
end
end
if @preemptive
$game_message.add(sprintf(Vocab::Preemptive, $game_party.name))
elsif @surprise
$game_message.add(sprintf(Vocab::Surprise, $game_party.name))
end
wait_for_message ; @preemptive = false ; @surprise = false
end
#--------------------------------------------------------------------------
# ● ATB Initial Setup
#--------------------------------------------------------------------------
def self.atb_initial_setup
battlers.each do |battler|
battler.atb_initial ; initial_atb_parameter(battler)
end
end
#--------------------------------------------------------------------------
# ● Initial ATB Parameter
#--------------------------------------------------------------------------
def self.initial_atb_parameter(battler)
@at_phase = 0
nt = battler.atb_max * 30 / 100
st = battler.atb_max * 20 / 100
pt = battler.atb_max * 65 / 100
n_at = rand(nt) ; p_at = pt + rand(nt) ; s_at = rand(st)
if BattleManager.preemptive_attack
battler.atb = p_at if battler.is_a?(Game_Actor)
battler.atb = s_at if battler.is_a?(Game_Enemy)
elsif BattleManager.surprise_attack
battler.atb = p_at if battler.is_a?(Game_Enemy)
battler.atb = s_at if battler.is_a?(Game_Actor)
else
battler.atb = n_at
end
battler.atb = battler.atb_max - 1 if battler.atb >= battler.atb_max
battler.turn_clear if battler.dead? or battler.restriction == 4
end
#--------------------------------------------------------------------------
# ● Set Turn Duration
#--------------------------------------------------------------------------
def self.set_turn_duration
max_battlers = battlers.size > 0 ? battlers.size : 1
case MOG_ATB_SYSTEM::TURN_DURATION_TYPE
when 1 ; n = $game_system.atb_turn_duration[1] * max_battlers
when 2
turn_sp = 0
battlers.each do |battler| turn_sp += battler.agi ; end
n = $game_system.atb_turn_duration[1] + (turn_sp / max_battlers)
else ; n = $game_system.atb_turn_duration[1]
end
n2 = [[n, 9999].min, 120].max
battlers.each do |battler|
perc = 30 * n2 / 100
battler.atb_turn_duration = rand(perc)
end
return n2
end
#--------------------------------------------------------------------------
# ● Force Clear Battler ATB
#--------------------------------------------------------------------------
def self.force_clear_battler_atb
battlers.each do |battler|
battler.turn_clear if battler.dead? or battler.restriction == 4
end
end
#--------------------------------------------------------------------------
# ● Turn Start
#--------------------------------------------------------------------------
def self.turn_start
@phase = :turn ; clear_actor
end
#--------------------------------------------------------------------------
# ● Preemtive Attack
#--------------------------------------------------------------------------
def self.preemptive_attack
@preemptive
end
#--------------------------------------------------------------------------
# ● Suprise Attack
#--------------------------------------------------------------------------
def self.surprise_attack
@surprise
end
#--------------------------------------------------------------------------
# ● Battlers
#--------------------------------------------------------------------------
def self.battlers
return $game_troop.members + $game_party.battle_members
end
#--------------------------------------------------------------------------
# ● Update ATB
#--------------------------------------------------------------------------
def update_atb?
return false if @atb_in_turn
return true
end
#--------------------------------------------------------------------------
# ● Update ATB
#--------------------------------------------------------------------------
def self.update_atb
return if $game_temp.atb_wait
return if $game_temp.end_phase_duration[1] > 0
return if $game_temp.battle_end
return if $game_temp.atb_frame_skip > 0
return @current_battler if @current_battler
for battler in battlers
next if !battler_update?(battler)
battler.atb_update
update_battler_turn(battler)
@current_battler = set_current_battler(battler)
break if $game_temp.atb_frame_skip > 0
end
return nil
end
#--------------------------------------------------------------------------
# ● Battler Update?
#--------------------------------------------------------------------------
def self.battler_update?(battler)
return false if battler.dead? or battler.hp == 0
return true
end
#--------------------------------------------------------------------------
# ● Update Battler Turn
#--------------------------------------------------------------------------
def self.update_battler_turn(battler)
return if @turn_duration == nil
battler.atb_turn_duration += 1
return if battler.atb_turn_duration < @turn_duration
battler.atb_turn_duration = 0
old_battler = battler
battler.on_turn_end
@refresh_status = true
end
#--------------------------------------------------------------------------
# ● Set Current Battler
#--------------------------------------------------------------------------
def self.set_current_battler(battler)
return @current_battler if @current_battler
return nil if !battler.atb_max?
if battler.next_turn
battler.remove_state_turn_end
$game_temp.remove_order(battler)
return battler
end
if battler.is_a?(Game_Actor)
if BattleManager.actor == nil
if $game_temp.actor_process_event != nil
enable_actor_command?($game_temp.actor_process_event)
prepare_actor_command($game_temp.actor_process_event)
$game_temp.actor_process_event = nil
elsif $game_temp.atb_actor_order[0] != nil and
enable_actor_command?($game_temp.atb_actor_order[0])
prepare_actor_command($game_temp.atb_actor_order[0])
else
prepare_actor_command(battler) if enable_actor_command?(battler)
if battler_confusion?(battler)
battler.make_actions
battler.next_turn = true if !can_execute_cast_action?(battler)
end
end
else
if battler_confusion?(battler)
battler.make_actions
battler.next_turn = true if !can_execute_cast_action?(battler)
end
end
else
battler.make_actions
battler.next_turn = true if !can_execute_cast_action?(battler)
end
return nil
end
#--------------------------------------------------------------------------
# ● Enable Actor Command
#--------------------------------------------------------------------------
def self.battler_confusion?(battler)
return false if battler.hp == 0 or battler.dead?
return true if battler.confusion?
return false
end
#--------------------------------------------------------------------------
# ● Enable Actor Command
#--------------------------------------------------------------------------
def self.enable_actor_command?(battler)
return false if @command_actor != nil
return false if battler.dead?
return false if battler.restriction != 0
return true
end
#--------------------------------------------------------------------------
# ● Prepare Actor Command
#--------------------------------------------------------------------------
def self.prepare_actor_command(battler)
battler.remove_state_turn_end
@command_actor = battler ; @command_selection = true
$game_temp.remove_order(battler)
end
#--------------------------------------------------------------------------
# ● Can Execute Cast Action?
#--------------------------------------------------------------------------
def self.can_execute_cast_action?(battler)
item = battler.current_action.item rescue nil
return false if item == nil
if item.speed != 0 and battler.atb_cast.empty?
battler.atb_cast = [item,item.speed.abs,0]
battler.animation_id = MOG_ATB_SYSTEM::CAST_ANIMATION
battler.atb = 0
return true
end
return false
end
#--------------------------------------------------------------------------
# ● Actor in turn
#--------------------------------------------------------------------------
def self.actor_command?
return false if !@command_selection
return false if @command_actor == nil
if @command_actor.restriction != 0
@command_selection = false
return false
end
@command_selection = false
return true
end
#--------------------------------------------------------------------------
# ● Current Battler Clear
#--------------------------------------------------------------------------
def self.current_battler_clear(subject)
return if subject == nil
return if @current_battler == nil
return if @current_battler != subject
@current_battler.atb_clear
@current_battler.atb_escape = false
@current_battler.clear_actions
@current_battler.next_turn = false
@current_battler = nil
end
#--------------------------------------------------------------------------
# ● Command Selection Clear
#--------------------------------------------------------------------------
def self.command_selection_clear
$game_temp.remove_order(@command_actor)
@command_selection = false ; @command_actor = nil
$game_temp.actor_command_index = 0
end
#--------------------------------------------------------------------------
# ● Command Selection
#--------------------------------------------------------------------------
def self.command_selection?
@command_selection
end
#--------------------------------------------------------------------------
# ● Command Selection need clear?
#--------------------------------------------------------------------------
def self.command_need_clear?
return true if @command_actor == nil and @command_selection
return false
end
#--------------------------------------------------------------------------
# ● Next Command
#--------------------------------------------------------------------------
def self.next_command
if @command_actor ; @command_actor.make_actions ; return true ;end
return false
end
#--------------------------------------------------------------------------
# ● Command End
#--------------------------------------------------------------------------
def self.command_end
$game_temp.remove_order(@command_actor)
@command_selection = false
$game_temp.actor_command_index = 0
command_end_actor if @command_actor
@command_actor = nil
end
#--------------------------------------------------------------------------
# ● Command End Actor
#--------------------------------------------------------------------------
def self.command_end_actor
item = @command_actor.current_action.item rescue nil
set_cast_action(item) if set_cast_action?(item)
@command_actor.next_turn = true if @command_actor != nil
@current_battler = @command_actor if @current_battler == nil
$game_temp.actor_process_event = nil
end
#--------------------------------------------------------------------------
# ● Set Cast Action?
#--------------------------------------------------------------------------
def self.set_cast_action?(item)
if item.is_a?(RPG::Skill)
return false if @command_actor.guard_skill_id == item.id
end
return false if item.nil?
return false if item.speed == 0
return false if !@command_actor.atb_cast.empty?
return true
end
#--------------------------------------------------------------------------
# ● Set Cast Action
#--------------------------------------------------------------------------
def self.set_cast_action(item)
if item.speed.abs > 10
@command_actor.atb_cast = [item,item.speed.abs,0]
else
@command_actor.atb_cast = [item,10,10]
end
@command_actor.animation_id = MOG_ATB_SYSTEM::CAST_ANIMATION
@command_actor.atb = 0 ; @command_actor.next_turn = false
@command_actor = nil
end
#--------------------------------------------------------------------------
# ● End Turn
#--------------------------------------------------------------------------
def self.in_turn?
return $game_temp.atb_in_turn
end
#--------------------------------------------------------------------------
# ● Set Refresh Status
#--------------------------------------------------------------------------
def self.set_refresh_status(value)
@refresh_status = value
end
#--------------------------------------------------------------------------
# ● Refresh Status
#--------------------------------------------------------------------------
def self.refresh_status?
@refresh_status
end
#--------------------------------------------------------------------------
# ● Actor
#--------------------------------------------------------------------------
def self.actor
@command_actor
end
#--------------------------------------------------------------------------
# ● Cancel Actor Command
#--------------------------------------------------------------------------
def self.cancel_actor_command(minus = false)
@command_selection = false
return if @command_actor == nil
@command_actor.atb = (@command_actor.atb * 80 / 100).truncate if minus
@command_actor = nil
$game_temp.actor_command_index = 0
end
#--------------------------------------------------------------------------
# ● Battler
#--------------------------------------------------------------------------
def self.set_battler_in_turn(battler)
@battler_in_turn = battler
end
#--------------------------------------------------------------------------
# ● Battler in turn?
#--------------------------------------------------------------------------
def self.battler_in_turn?(battler)
return true if @battler_in_turn == battler
return false
end
#--------------------------------------------------------------------------