module BattleManager
#--------------------------------------------------------------------------
# * To Previous Command Input
#--------------------------------------------------------------------------
def self.prior_command
begin
if !actor || !actor.prior_command
@actor_index -= 1
if @actor_index < 0
@actor_index = $game_party.members.size - 1
end
end
end until actor.inputable?
return true
end
#--------------------------------------------------------------------------
# * To Next Command Input
#--------------------------------------------------------------------------
def self.next_command
cnt = 0
begin
if !actor || !actor.next_command
@actor_index += 1
if @actor_index > $game_party.members.size - 1
@actor_index = 0
end
cnt += 1
return false if cnt > $game_party.members.size
return false if @actor_index >= $game_party.members.size
end
end until actor.inputable?
return true
end
end
class Scene_Battle < Scene_Base
def prior_command
if BattleManager.prior_command
start_actor_command_selection
else
refresh_status
end
end
#--------------------------------------------------------------------------
# alias method: create_party_command_window
#--------------------------------------------------------------------------
alias create_party_command_window_bcl create_party_command_window
def create_party_command_window
create_party_command_window_bcl
process_custom_party_commands
end
#--------------------------------------------------------------------------
# new method: process_custom_party_commands
#--------------------------------------------------------------------------
def process_custom_party_commands
for command in YEA::BATTLE_COMMANDS::PARTY_COMMANDS
next unless YEA::BATTLE_COMMANDS::CUSTOM_PARTY_COMMANDS.include?(command)
called_method = YEA::BATTLE_COMMANDS::CUSTOM_PARTY_COMMANDS[command][3]
@party_command_window.set_handler(command, method(called_method))
end
end
#--------------------------------------------------------------------------
# alias method: create_actor_command_window
#--------------------------------------------------------------------------
alias create_actor_command_window_bcl create_actor_command_window
def create_actor_command_window
create_actor_command_window_bcl
@actor_command_window.set_handler(:use_skill, method(:command_use_skill))
@actor_command_window.set_handler(:use_item, method(:command_use_item))
end
#--------------------------------------------------------------------------
# alias method: start_actor_command_selection
#--------------------------------------------------------------------------
alias start_actor_command_selection_bcl start_actor_command_selection
def start_actor_command_selection
@confirm_command_window.hide unless @confirm_command_window.nil?
start_actor_command_selection_bcl
@actor_command_window.show
end
#--------------------------------------------------------------------------
# new method: command_use_skill
#--------------------------------------------------------------------------
def command_use_skill
@skill = $data_skills[@actor_command_window.current_ext]
BattleManager.actor.input.set_skill(@skill.id)
BattleManager.actor.last_skill.object = @skill
status_redraw_target(BattleManager.actor)
if $imported["YEA-BattleEngine"]
$game_temp.battle_aid = @skill
if @skill.for_opponent?
select_enemy_selection
elsif @skill.for_friend?
select_actor_selection
else
next_command
$game_temp.battle_aid = nil
end
else
if !@skill.need_selection?
next_command
elsif @skill.for_opponent?
select_enemy_selection
else
select_actor_selection
end
end
end
#--------------------------------------------------------------------------
# new method: command_use_item
#--------------------------------------------------------------------------
def command_use_item
@item = $data_items[@actor_command_window.current_ext]
BattleManager.actor.input.set_item(@item.id)
status_redraw_target(BattleManager.actor)
if $imported["YEA-BattleEngine"]
$game_temp.battle_aid = @item
if @item.for_opponent?
select_enemy_selection
elsif @item.for_friend?
select_actor_selection
else
next_command
$game_temp.battle_aid = nil
end
else
if !@item.need_selection?
next_command
elsif @item.for_opponent?
select_enemy_selection
else
select_actor_selection
end
end
end
#--------------------------------------------------------------------------
# alias method: on_actor_ok
#--------------------------------------------------------------------------
alias scene_battle_on_actor_ok_bcl on_actor_ok
def on_actor_ok
scene_battle_on_actor_ok_bcl
return if !@confirm_command_window.nil? && @confirm_command_window.visible
@actor_command_window.show
end
#--------------------------------------------------------------------------
# alias method: on_actor_cancel
#--------------------------------------------------------------------------
alias scene_battle_on_actor_cancel_bcl on_actor_cancel
def on_actor_cancel
scene_battle_on_actor_cancel_bcl
case @actor_command_window.current_symbol
when :use_skill, :use_item
@help_window.hide
@status_window.show
@actor_command_window.activate
status_redraw_target(BattleManager.actor)
end
end
#--------------------------------------------------------------------------
# alias method: on_enemy_ok
#--------------------------------------------------------------------------
alias scene_battle_on_enemy_ok_bcl on_enemy_ok
def on_enemy_ok
scene_battle_on_enemy_ok_bcl
return if !@confirm_command_window.nil? && @confirm_command_window.visible
@actor_command_window.show
end
#--------------------------------------------------------------------------
# alias method: on_enemy_cancel
#--------------------------------------------------------------------------
alias scene_battle_on_enemy_cancel_bcl on_enemy_cancel
def on_enemy_cancel
scene_battle_on_enemy_cancel_bcl
case @actor_command_window.current_symbol
when :use_skill, :use_item
@help_window.hide
@status_window.show
@actor_command_window.activate
status_redraw_target(BattleManager.actor)
end
end
#--------------------------------------------------------------------------
# new method: status_redraw_target
#--------------------------------------------------------------------------
def status_redraw_target(target)
return unless target.actor?
@status_window.draw_item($game_party.battle_members.index(target))
end
#--------------------------------------------------------------------------
# new method: on_confirm_cancel
#--------------------------------------------------------------------------
def on_confirm_cancel
@confirm_command_window.hide unless @confirm_command_window.nil?
@actor_command_window.show
@actor_command_window.setup(BattleManager.actor)
@status_window.select(BattleManager.actor.index)
prior_command unless BattleManager.actor.inputable?
end
#--------------------------------------------------------------------------
# new method: prompt_next_actor?
#--------------------------------------------------------------------------
def prompt_next_actor?
index = @status_window.index
last_index = $game_party.battle_members.size - 1
for member in $game_party.battle_members.reverse
break if member.inputable?
last_index -= 1
end
if index >= last_index
actor = $game_party.battle_members[index]
return true if prompt_ftb_action?(actor)
return true if actor.next_command_valid?
return false if YEA::BATTLE_COMMANDS::USE_CONFIRM_WINDOW
end
return true
end
#--------------------------------------------------------------------------
# new method: prompt_ftb_action?
#--------------------------------------------------------------------------
def prompt_ftb_action?(actor)
return false unless $imported["YEA-BattleEngine"]
return false unless $imported["YEA-BattleSystem-FTB"]
return false unless BattleManager.btype?(:ftb)
return actor.current_action.valid?
end
end # Scene_Battle