#==============================================================================# # ▼ Yami Engine Ace - Battle Control# -- Last Updated: 2012.07.09# -- Level: Nothing# -- Requires: n/a# #==============================================================================$imported = {} if $imported.nil?$imported["YSE-BattleControl"] = true#==============================================================================# ▼ Updates# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 2012.07.30 - Bugfix for Large Party.# 2012.07.09 - Compatible with: Battle PTB.# 2012.07.05 - Compatible with: Battle TBB.# 2012.07.04 - Compatible with: Battle CTB.# 2012.07.01 - Started and Finished Script.# #==============================================================================# ▼ Introduction# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# This script controls the Battle flow and manages battle mechanism from Yami# Engine. This is requirement for Battle Mechanism of Yami Engine.# #==============================================================================# ▼ Instructions# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# To install this script, open up your script editor and copy/paste this script# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.## To change Battle Type (Battle Mechanism) during gameplay, use this script call# BattleControl.change_btype(type)##==============================================================================# ▼ Compatibility# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that# it will run with RPG Maker VX without adjusting.# #==============================================================================module YSE module BattleControl # Set Default Battle. DEFAULT_BATTLE_TYPE = :tbb end # BattleControlend # YSE#==============================================================================# ▼ Editting anything past this point may potentially result in causing# computer damage, incontinence, explosion of user's head, coma, death, and/or# halitosis so edit at your own risk.#==============================================================================#==============================================================================# ■ BattleControl#==============================================================================module BattleControl #-------------------------------------------------------------------------- # setup #-------------------------------------------------------------------------- def self.setup @battle_type ||= correct_battle_type(YSE::BattleControl::DEFAULT_BATTLE_TYPE) @last_size = 0 @battlers = [] filter_battlers setup_battle end #-------------------------------------------------------------------------- # filter_battlers #-------------------------------------------------------------------------- def self.filter_battlers @last_size = @battlers.size @battlers = $game_party.members + $game_troop.members @last_size = @last_size == 0 ? @battlers.size : @last_size end #-------------------------------------------------------------------------- # setup_battle #-------------------------------------------------------------------------- def self.setup_battle # Compatible Method. end #-------------------------------------------------------------------------- # turn_end? #-------------------------------------------------------------------------- def self.turn_end? return true end #-------------------------------------------------------------------------- # turn_end #-------------------------------------------------------------------------- def self.turn_end # Compatible Method. end #-------------------------------------------------------------------------- # correct_battle_type #-------------------------------------------------------------------------- def self.correct_battle_type(type) case type when :dtb; return :dtb when :ctb; return $imported["YSE-BattleCTB"] ? :ctb : :dtb when :tbb; return $imported["YSE-BattleTBB"] ? :tbb : :dtb when :ptbn; return $imported["YSE-BattlePTBN"] ? :ptbn : :dtb else; return :dtb end end #-------------------------------------------------------------------------- # battle_type #-------------------------------------------------------------------------- def self.battle_type return @battle_type end #-------------------------------------------------------------------------- # change_btype #-------------------------------------------------------------------------- def self.change_btype(type) @battle_type = correct_battle_type(type) end end # BattleControl#==============================================================================# ■ BattleManager#==============================================================================module BattleManager #-------------------------------------------------------------------------- # alias method: setup #-------------------------------------------------------------------------- class <<self; alias yse_bc_setup setup; end def self.setup(troop_id, can_escape = true, can_lose = false) yse_bc_setup(troop_id, can_escape, can_lose) BattleControl.setup() end #-------------------------------------------------------------------------- # new method: encounter_flag #-------------------------------------------------------------------------- def self.encounter_flag return 1 if @preemptive return 2 if @surprise return 0 end #-------------------------------------------------------------------------- # new method: set_actor #-------------------------------------------------------------------------- def self.set_actor(actor) @actor_index = actor.index end end # BattleManager#==============================================================================# ■ Game_Actor#==============================================================================class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # Define method :screen_x #-------------------------------------------------------------------------- unless Game_Actor.instance_methods.include?(:screen_x) def screen_x return self.index end end end # Game_Actor#==============================================================================# ■ Game_Unit#==============================================================================class Game_Unit #-------------------------------------------------------------------------- # new method: ye_alive_members #-------------------------------------------------------------------------- def ye_alive_members self.is_a?(Game_Party) ? battle_members.select {|member| member.alive? } : members.select {|member| member.alive? } end #-------------------------------------------------------------------------- # new method: ye_movable_members #-------------------------------------------------------------------------- def ye_movable_members self.is_a?(Game_Party) ? battle_members.select {|member| member.movable? } : members.select {|member| member.movable? } end end # Game_Unit#==============================================================================# ■ Scene_Battle#==============================================================================class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # overwrite method: update #-------------------------------------------------------------------------- def update super if BattleManager.in_turn? && process_condition process_in_turn process_event process_action end BattleManager.judge_win_loss end #-------------------------------------------------------------------------- # new method: process_in_turn #-------------------------------------------------------------------------- def process_in_turn # Compatible Method. end #-------------------------------------------------------------------------- # new method: process_condition #-------------------------------------------------------------------------- def process_condition return true if BattleControl.battle_type == :dtb end #-------------------------------------------------------------------------- # overwrite method: process_action #-------------------------------------------------------------------------- def process_action return if scene_changing? if !@subject || !@subject.current_action @subject = BattleManager.next_subject end unless @subject return turn_end if BattleControl.turn_end? return end if @subject.current_action @subject.current_action.prepare if @subject.current_action.valid? @status_window.open execute_action end @subject.remove_current_action end process_action_end unless @subject.current_action end #-------------------------------------------------------------------------- # alias method: turn_end #-------------------------------------------------------------------------- alias yse_bc_turn_end turn_end def turn_end return yse_bc_turn_end if BattleControl.battle_type == :dtb return unless BattleControl.turn_end? while BattleControl.turn_end? BattleControl.turn_end yse_bc_turn_end #--- turn_start if BattleControl.battle_type == :ctb turn_start if BattleControl.battle_type == :tbb turn_start if BattleControl.battle_type == :ptbn end end end # Scene_Battle#==============================================================================# # ▼ End of File# #==============================================================================
#==============================================================================# # ▼ Yami Engine Ace - Battle Mechanism# -- Type: Turn Based Battle# -- Last Updated: 2012.07.05# -- Level: Normal# -- Requires: n/a# #==============================================================================$imported = {} if $imported.nil?$imported["YSE-BattleTBB"] = true#==============================================================================# ▼ Updates# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 2012.07.30 - Bugfix for Large Party.# 2012.07.05 - Started and Finished Script.# #==============================================================================# ▼ Introduction# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# This script provides battle mechanism Turn Based Battle (TBB). TBB is another# version of Default Battle, which You individually choose action for Battler.##==============================================================================# ▼ Instructions# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# To install this script, open up your script editor and copy/paste this script# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.##==============================================================================# ▼ Compatibility# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that# it will run with RPG Maker VX without adjusting.# This script may not be compatible with other battle scripts. It is highly# recommended putting this script above all other battle scripts, except YEA - # Ace Battle Engine and other scripts that Author recommends putting above this.# #==============================================================================#==============================================================================# ▼ Editting anything past this point may potentially result in causing# computer damage, incontinence, explosion of user's head, coma, death, and/or# halitosis so edit at your own risk.#==============================================================================#==============================================================================# ■ BattleControl#==============================================================================module BattleControl #-------------------------------------------------------------------------- # alias method: setup_battle #-------------------------------------------------------------------------- class <<self; alias tbb_setup_battle setup_battle; end def self.setup_battle tbb_setup_battle setup_tbb if battle_type == :tbb end #-------------------------------------------------------------------------- # alias method: turn_end? #-------------------------------------------------------------------------- class <<self; alias tbb_turn_end? turn_end?; end def self.turn_end? return tbb_turn_end? unless battle_type == :tbb return turn_end_tbb? if battle_type == :tbb end #-------------------------------------------------------------------------- # alias method: turn_end #-------------------------------------------------------------------------- class <<self; alias tbb_turn_end turn_end; end def self.turn_end tbb_turn_end unless battle_type == :tbb turn_end_tbb if battle_type == :tbb end #-------------------------------------------------------------------------- # new method: turn_end_tbb? #-------------------------------------------------------------------------- def self.turn_end_tbb? @active_battlers.size == 0 end #-------------------------------------------------------------------------- # new method: turn_end_tbb #-------------------------------------------------------------------------- def self.turn_end_tbb @active_battlers.clear @performed_battlers.clear #--- make_action_orders_tbb end #-------------------------------------------------------------------------- # new method: setup_tbb #-------------------------------------------------------------------------- def self.setup_tbb @active_battlers = [] @performed_battlers = [] #--- make_action_orders_tbb end #-------------------------------------------------------------------------- # new method: make_action_orders_tbb #-------------------------------------------------------------------------- def self.make_action_orders_tbb @active_battlers.clear @active_battlers += $game_party.battle_members if BattleManager.encounter_flag != 2 @active_battlers += $game_troop.members if BattleManager.encounter_flag != 1 #--- sort_action_orders_tbb end #-------------------------------------------------------------------------- # new method: sort_action_orders_tbb #-------------------------------------------------------------------------- def self.sort_action_orders_tbb @active_battlers.sort! { |a,b| b.agi <=> a.agi } end #-------------------------------------------------------------------------- # new method: tbb_get_subject #-------------------------------------------------------------------------- def self.tbb_get_subject loop do battler = @active_battlers.shift return nil unless battler next unless battler.movable? @performed_battlers.push(battler) return battler end end end # BattleControl#==============================================================================# ■ BattleManager#==============================================================================module BattleManager #-------------------------------------------------------------------------- # alias method: turn_start #-------------------------------------------------------------------------- class <<self; alias tbb_turn_start turn_start; end def self.turn_start tbb_turn_start unless BattleControl.battle_type == :tbb turn_start_tbb if BattleControl.battle_type == :tbb end #-------------------------------------------------------------------------- # alias method: turn_end #-------------------------------------------------------------------------- class <<self; alias tbb_turn_end turn_end; end def self.turn_end tbb_turn_end unless BattleControl.battle_type == :tbb turn_end_tbb if BattleControl.battle_type == :tbb end #-------------------------------------------------------------------------- # alias method: on_encounter #-------------------------------------------------------------------------- class <<self; alias tbb_on_encounter on_encounter; end def self.on_encounter tbb_on_encounter BattleControl.make_action_orders_tbb if BattleControl.battle_type == :tbb end #-------------------------------------------------------------------------- # new method: turn_start_tbb #-------------------------------------------------------------------------- def self.turn_start_tbb @phase = :turn clear_actor end #-------------------------------------------------------------------------- # new method: turn_end_tbb #-------------------------------------------------------------------------- def self.turn_end_tbb @phase = :turn_end @preemptive = false @surprise = false $game_troop.increase_turn end end # BattleManager#==============================================================================# ■ Game_Actor#==============================================================================class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # alias method: input #-------------------------------------------------------------------------- alias tbb_input input def input if BattleControl.battle_type == :tbb if @actions[@action_input_index] == nil @actions[@action_input_index] = Game_Action.new(self) end end return tbb_input end end # Game_Actor#==============================================================================# ■ Window_ActorCommand#==============================================================================class Window_ActorCommand < Window_Command #-------------------------------------------------------------------------- # alias method: process_dir6 #-------------------------------------------------------------------------- if $imported["YEA-BattleEngine"] alias tbb_process_dir6 process_dir6 def process_dir6 return if BattleControl.battle_type == :tbb tbb_process_dir6 end end end # Window_ActorCommand#==============================================================================# ■ Scene_Battle#==============================================================================class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # alias method: process_condition #-------------------------------------------------------------------------- alias tbb_process_condition process_condition def process_condition return tbb_process_condition unless BattleControl.battle_type == :tbb return process_condition_tbb if BattleControl.battle_type == :tbb end #-------------------------------------------------------------------------- # alias method: process_in_turn #-------------------------------------------------------------------------- alias tbb_process_in_turn process_in_turn def process_in_turn tbb_process_in_turn unless BattleControl.battle_type == :tbb process_in_turn_tbb if BattleControl.battle_type == :tbb end #-------------------------------------------------------------------------- # alias method: update_info_viewport #-------------------------------------------------------------------------- alias tbb_update_info_viewport update_info_viewport def update_info_viewport tbb_update_info_viewport unless BattleControl.battle_type == :tbb update_info_viewport_tbb if BattleControl.battle_type == :tbb end #-------------------------------------------------------------------------- # alias method: next_command #-------------------------------------------------------------------------- alias tbb_next_command next_command def next_command tbb_next_command unless BattleControl.battle_type == :tbb next_command_tbb if BattleControl.battle_type == :tbb end #-------------------------------------------------------------------------- # alias method: prior_command #-------------------------------------------------------------------------- alias tbb_prior_command prior_command def prior_command tbb_prior_command unless BattleControl.battle_type == :tbb prior_command_tbb if BattleControl.battle_type == :tbb end #-------------------------------------------------------------------------- # alias method: command_fight #-------------------------------------------------------------------------- alias tbb_command_fight command_fight def command_fight tbb_command_fight unless BattleControl.battle_type == :tbb command_fight_tbb if BattleControl.battle_type == :tbb end #-------------------------------------------------------------------------- # alias method: command_escape #-------------------------------------------------------------------------- alias tbb_command_escape command_escape def command_escape tbb_command_escape unless BattleControl.battle_type == :tbb command_escape_tbb if BattleControl.battle_type == :tbb end #-------------------------------------------------------------------------- # new method: process_condition_tbb #-------------------------------------------------------------------------- def process_condition_tbb inputting = @actor_command_window.active || @skill_window.active || @item_window.active || @actor_window.active || @enemy_window.active inputting = inputting || @summon_window.active if $imported["YSE-GuardianSummon"] return !inputting end #-------------------------------------------------------------------------- # new method: process_in_turn_tbb #-------------------------------------------------------------------------- def process_in_turn_tbb if @status_window.close? @status_window.open end @actor_command_window.close @status_window.unselect return if @subject #--- battler = BattleControl.tbb_get_subject battler.make_actions @subject = battler #--- if @subject.inputable? and battler.is_a?(Game_Actor) @actor_command_window.setup(@subject) BattleManager.set_actor(battler) @status_window.select(BattleManager.actor.index) end end #-------------------------------------------------------------------------- # new method: update_info_viewport_tbb #-------------------------------------------------------------------------- def update_info_viewport_tbb move_info_viewport(0) if @party_command_window.active move_info_viewport(128) if @actor_command_window.active move_info_viewport(64) if BattleManager.in_turn? && process_condition end #-------------------------------------------------------------------------- # new method: next_command_tbb #-------------------------------------------------------------------------- def next_command_tbb @status_window.show @actor_command_window.show @status_aid_window.hide if $imported["YEA-BattleEngine"] end #-------------------------------------------------------------------------- # new method: prior_command_tbb #-------------------------------------------------------------------------- def prior_command_tbb $imported["YEA-BattleEngine"] ? redraw_current_status : @status_window.refresh start_party_command_selection end #-------------------------------------------------------------------------- # new method: command_fight_tbb #-------------------------------------------------------------------------- def command_fight_tbb turn_start end #-------------------------------------------------------------------------- # new method: command_escape_tbb #-------------------------------------------------------------------------- def command_escape_tbb unless BattleManager.process_escape turn_start end end #-------------------------------------------------------------------------- # alias method: turn_end #-------------------------------------------------------------------------- alias tbb_turn_end turn_end def turn_end tbb_turn_end return unless BattleControl.battle_type == :tbb @party_command_window.deactivate end end # Scene_Battle#==============================================================================# # ▼ End of File# #==============================================================================