- Joined
- Feb 7, 2018
- Messages
- 20
- Reaction score
- 5
- First Language
- English
- Primarily Uses
- RMVXA
I made a game in RMVXA and then remembered that I accidentally deleted the battle system. Now it's unplayable. Can you guys Copy/Paste the script for me?
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
super
create_spriteset
create_all_windows
BattleManager.method_wait_for_message = method(:wait_for_message)
end
#--------------------------------------------------------------------------
# * Post-Start Processing
#--------------------------------------------------------------------------
def post_start
super
battle_start
end
#--------------------------------------------------------------------------
# * Pre-Termination Processing
#--------------------------------------------------------------------------
def pre_terminate
super
Graphics.fadeout(30) if SceneManager.scene_is?(Scene_Map)
Graphics.fadeout(60) if SceneManager.scene_is?(Scene_Title)
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
dispose_spriteset
@info_viewport.dispose
RPG::ME.stop
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
if BattleManager.in_turn?
process_event
process_action
end
BattleManager.judge_win_loss
end
#--------------------------------------------------------------------------
# * Update Frame (Basic)
#--------------------------------------------------------------------------
def update_basic
super
$game_timer.update
$game_troop.update
@spriteset.update
update_info_viewport
update_message_open
end
#--------------------------------------------------------------------------
# * Update Frame (for Wait)
#--------------------------------------------------------------------------
def update_for_wait
update_basic
end
#--------------------------------------------------------------------------
# * Wait
#--------------------------------------------------------------------------
def wait(duration)
duration.times {|i| update_for_wait if i < duration / 2 || !show_fast? }
end
#--------------------------------------------------------------------------
# * Determine if Fast Forward
#--------------------------------------------------------------------------
def show_fast?
Input.press?(:A) || Input.press?(:C)
end
#--------------------------------------------------------------------------
# * Wait (No Fast Forward)
#--------------------------------------------------------------------------
def abs_wait(duration)
duration.times {|i| update_for_wait }
end
#--------------------------------------------------------------------------
# * Short Wait (No Fast Forward)
#--------------------------------------------------------------------------
def abs_wait_short
abs_wait(15)
end
#--------------------------------------------------------------------------
# * Wait Until Message Display has Finished
#--------------------------------------------------------------------------
def wait_for_message
@message_window.update
update_for_wait while $game_message.visible
end
#--------------------------------------------------------------------------
# * Wait Until Animation Display has Finished
#--------------------------------------------------------------------------
def wait_for_animation
update_for_wait
update_for_wait while @spriteset.animation?
end
#--------------------------------------------------------------------------
# * Wait Until Effect Execution Ends
#--------------------------------------------------------------------------
def wait_for_effect
update_for_wait
update_for_wait while @spriteset.effect?
end
#--------------------------------------------------------------------------
# * Update Information Display Viewport
#--------------------------------------------------------------------------
def update_info_viewport
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?
end
#--------------------------------------------------------------------------
# * Move Information Display Viewport
#--------------------------------------------------------------------------
def move_info_viewport(ox)
current_ox = @info_viewport.ox
@info_viewport.ox = [ox, current_ox + 16].min if current_ox < ox
@info_viewport.ox = [ox, current_ox - 16].max if current_ox > ox
end
#--------------------------------------------------------------------------
# * Update Processing for Opening Message Window
# Set openness to 0 until the status window and so on are finished closing.
#--------------------------------------------------------------------------
def update_message_open
if $game_message.busy? && !@status_window.close?
@message_window.openness = 0
@status_window.close
@party_command_window.close
@actor_command_window.close
end
end
#--------------------------------------------------------------------------
# * Create Sprite Set
#--------------------------------------------------------------------------
def create_spriteset
@spriteset = Spriteset_Battle.new
end
#--------------------------------------------------------------------------
# * Free Sprite Set
#--------------------------------------------------------------------------
def dispose_spriteset
@spriteset.dispose
end
#--------------------------------------------------------------------------
# * Create All Windows
#--------------------------------------------------------------------------
def create_all_windows
create_message_window
create_scroll_text_window
create_log_window
create_status_window
create_info_viewport
create_party_command_window
create_actor_command_window
create_help_window
create_skill_window
create_item_window
create_actor_window
create_enemy_window
end
#--------------------------------------------------------------------------
# * Create Message Window
#--------------------------------------------------------------------------
def create_message_window
@message_window = Window_Message.new
end
#--------------------------------------------------------------------------
# * Create Scrolling Text Window
#--------------------------------------------------------------------------
def create_scroll_text_window
@scroll_text_window = Window_ScrollText.new
end
#--------------------------------------------------------------------------
# * Create Log Window
#--------------------------------------------------------------------------
def create_log_window
@log_window = Window_BattleLog.new
@log_window.method_wait = method(:wait)
@log_window.method_wait_for_effect = method(:wait_for_effect)
end
#--------------------------------------------------------------------------
# * Create Status Window
#--------------------------------------------------------------------------
def create_status_window
@status_window = Window_BattleStatus.new
@status_window.x = 128
end
#--------------------------------------------------------------------------
# * Create Information Display Viewport
#--------------------------------------------------------------------------
def create_info_viewport
@info_viewport = Viewport.new
@info_viewport.rect.y = Graphics.height - @status_window.height
@info_viewport.rect.height = @status_window.height
@info_viewport.z = 100
@info_viewport.ox = 64
@status_window.viewport = @info_viewport
end
#--------------------------------------------------------------------------
# * Create Party Commands Window
#--------------------------------------------------------------------------
def create_party_command_window
@party_command_window = Window_PartyCommand.new
@party_command_window.viewport = @info_viewport
@party_command_window.set_handler(:fight, method(:command_fight))
@party_command_window.set_handler(:escape, method(:command_escape))
@party_command_window.unselect
end
#--------------------------------------------------------------------------
# * Create Actor Commands Window
#--------------------------------------------------------------------------
def create_actor_command_window
@actor_command_window = Window_ActorCommand.new
@actor_command_window.viewport = @info_viewport
@actor_command_window.set_handler(:attack, method(:command_attack))
@actor_command_window.set_handler(:skill, method(:command_skill))
@actor_command_window.set_handler(:guard, method(:command_guard))
@actor_command_window.set_handler(:item, method(:command_item))
@actor_command_window.set_handler(:cancel, method(:prior_command))
@actor_command_window.x = Graphics.width
end
#--------------------------------------------------------------------------
# * Create Help Window
#--------------------------------------------------------------------------
def create_help_window
@help_window = Window_Help.new
@help_window.visible = false
end
#--------------------------------------------------------------------------
# * Create Skill Window
#--------------------------------------------------------------------------
def create_skill_window
@skill_window = Window_BattleSkill.new(@help_window, @info_viewport)
@skill_window.set_handler(:ok, method(:on_skill_ok))
@skill_window.set_handler(:cancel, method(:on_skill_cancel))
end
#--------------------------------------------------------------------------
# * Create Item Window
#--------------------------------------------------------------------------
def create_item_window
@item_window = Window_BattleItem.new(@help_window, @info_viewport)
@item_window.set_handler(:ok, method(:on_item_ok))
@item_window.set_handler(:cancel, method(:on_item_cancel))
end
#--------------------------------------------------------------------------
# * Create Actor Window
#--------------------------------------------------------------------------
def create_actor_window
@actor_window = Window_BattleActor.new(@info_viewport)
@actor_window.set_handler(:ok, method(:on_actor_ok))
@actor_window.set_handler(:cancel, method(:on_actor_cancel))
end
#--------------------------------------------------------------------------
# * Create Enemy Window
#--------------------------------------------------------------------------
def create_enemy_window
@enemy_window = Window_BattleEnemy.new(@info_viewport)
@enemy_window.set_handler(:ok, method(:on_enemy_ok))
@enemy_window.set_handler(:cancel, method(:on_enemy_cancel))
end
#--------------------------------------------------------------------------
# * Update Status Window Information
#--------------------------------------------------------------------------
def refresh_status
@status_window.refresh
end
#--------------------------------------------------------------------------
# * To Next Command Input
#--------------------------------------------------------------------------
def next_command
if BattleManager.next_command
start_actor_command_selection
else
turn_start
end
end
#--------------------------------------------------------------------------
# * To Previous Command Input
#--------------------------------------------------------------------------
def prior_command
if BattleManager.prior_command
start_actor_command_selection
else
start_party_command_selection
end
end
#--------------------------------------------------------------------------
# * Start Party Command Selection
#--------------------------------------------------------------------------
def start_party_command_selection
unless scene_changing?
refresh_status
@status_window.unselect
@status_window.open
if BattleManager.input_start
@actor_command_window.close
@party_command_window.setup
else
@party_command_window.deactivate
turn_start
end
end
end
#--------------------------------------------------------------------------
# * [Fight] Command
#--------------------------------------------------------------------------
def command_fight
next_command
end
#--------------------------------------------------------------------------
# * [Escape] Command
#--------------------------------------------------------------------------
def command_escape
turn_start unless BattleManager.process_escape
end
#--------------------------------------------------------------------------
# * Start Actor Command Selection
#--------------------------------------------------------------------------
def start_actor_command_selection
@status_window.select(BattleManager.actor.index)
@party_command_window.close
@actor_command_window.setup(BattleManager.actor)
end
#--------------------------------------------------------------------------
# * [Attack] Command
#--------------------------------------------------------------------------
def command_attack
BattleManager.actor.input.set_attack
select_enemy_selection
end
#--------------------------------------------------------------------------
# * [Skill] Command
#--------------------------------------------------------------------------
def command_skill
@skill_window.actor = BattleManager.actor
@skill_window.stype_id = @actor_command_window.current_ext
@skill_window.refresh
@skill_window.show.activate
end
#--------------------------------------------------------------------------
# * [Guard] Command
#--------------------------------------------------------------------------
def command_guard
BattleManager.actor.input.set_guard
next_command
end
#--------------------------------------------------------------------------
# * [Item] Command
#--------------------------------------------------------------------------
def command_item
@item_window.refresh
@item_window.show.activate
end
#--------------------------------------------------------------------------
# * Start Actor Selection
#--------------------------------------------------------------------------
def select_actor_selection
@actor_window.refresh
@actor_window.show.activate
end
#--------------------------------------------------------------------------
# * Actor [OK]
#--------------------------------------------------------------------------
def on_actor_ok
BattleManager.actor.input.target_index = @actor_window.index
@actor_window.hide
@skill_window.hide
@item_window.hide
next_command
end
#--------------------------------------------------------------------------
# * Actor [Cancel]
#--------------------------------------------------------------------------
def on_actor_cancel
@actor_window.hide
case @actor_command_window.current_symbol
when :skill
@skill_window.activate
when :item
@item_window.activate
end
end
#--------------------------------------------------------------------------
# * Start Enemy Selection
#--------------------------------------------------------------------------
def select_enemy_selection
@enemy_window.refresh
@enemy_window.show.activate
end
#--------------------------------------------------------------------------
# * Enemy [OK]
#--------------------------------------------------------------------------
def on_enemy_ok
BattleManager.actor.input.target_index = @enemy_window.enemy.index
@enemy_window.hide
@skill_window.hide
@item_window.hide
next_command
end
#--------------------------------------------------------------------------
# * Enemy [Cancel]
#--------------------------------------------------------------------------
def on_enemy_cancel
@enemy_window.hide
case @actor_command_window.current_symbol
when :attack
@actor_command_window.activate
when :skill
@skill_window.activate
when :item
@item_window.activate
end
end
#--------------------------------------------------------------------------
# * Skill [OK]
#--------------------------------------------------------------------------
def on_skill_ok
@skill = @skill_window.item
BattleManager.actor.input.set_skill(@skill.id)
BattleManager.actor.last_skill.object = @skill
if !@skill.need_selection?
@skill_window.hide
next_command
elsif @skill.for_opponent?
select_enemy_selection
else
select_actor_selection
end
end
#--------------------------------------------------------------------------
# * Skill [Cancel]
#--------------------------------------------------------------------------
def on_skill_cancel
@skill_window.hide
@actor_command_window.activate
end
#--------------------------------------------------------------------------
# * Item [OK]
#--------------------------------------------------------------------------
def on_item_ok
@item = @item_window.item
BattleManager.actor.input.set_item(@item.id)
if !@item.need_selection?
@item_window.hide
next_command
elsif @item.for_opponent?
select_enemy_selection
else
select_actor_selection
end
$game_party.last_item.object = @item
end
#--------------------------------------------------------------------------
# * Item [Cancel]
#--------------------------------------------------------------------------
def on_item_cancel
@item_window.hide
@actor_command_window.activate
end
#--------------------------------------------------------------------------
# * Battle Start
#--------------------------------------------------------------------------
def battle_start
BattleManager.battle_start
process_event
start_party_command_selection
end
#--------------------------------------------------------------------------
# * Start Turn
#--------------------------------------------------------------------------
def turn_start
@party_command_window.close
@actor_command_window.close
@status_window.unselect
@subject = nil
BattleManager.turn_start
@log_window.wait
@log_window.clear
end
#--------------------------------------------------------------------------
# * End Turn
#--------------------------------------------------------------------------
def turn_end
all_battle_members.each do |battler|
battler.on_turn_end
refresh_status
@log_window.display_auto_affected_status(battler)
@log_window.wait_and_clear
end
BattleManager.turn_end
process_event
start_party_command_selection
end
#--------------------------------------------------------------------------
# * Get All Battle Members Including Enemies and Allies
#--------------------------------------------------------------------------
def all_battle_members
$game_party.members + $game_troop.members
end
#--------------------------------------------------------------------------
# * Event Processing
#--------------------------------------------------------------------------
def process_event
while !scene_changing?
$game_troop.interpreter.update
$game_troop.setup_battle_event
wait_for_message
wait_for_effect if $game_troop.all_dead?
process_forced_action
BattleManager.judge_win_loss
break unless $game_troop.interpreter.running?
update_for_wait
end
end
#--------------------------------------------------------------------------
# * Forced Action Processing
#--------------------------------------------------------------------------
def process_forced_action
if BattleManager.action_forced?
last_subject = @subject
@subject = BattleManager.action_forced_battler
BattleManager.clear_action_force
process_action
@subject = last_subject
end
end
#--------------------------------------------------------------------------
# * Battle Action Processing
#--------------------------------------------------------------------------
def process_action
return if scene_changing?
if !@subject || !@subject.current_action
@subject = BattleManager.next_subject
end
return turn_end unless @subject
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
#--------------------------------------------------------------------------
# * Processing at End of Action
#--------------------------------------------------------------------------
def process_action_end
@subject.on_action_end
refresh_status
@log_window.display_auto_affected_status(@subject)
@log_window.wait_and_clear
@log_window.display_current_state(@subject)
@log_window.wait_and_clear
BattleManager.judge_win_loss
end
#--------------------------------------------------------------------------
# * Execute Battle Actions
#--------------------------------------------------------------------------
def execute_action
@subject.sprite_effect_type = :whiten
use_item
@log_window.wait_and_clear
end
#--------------------------------------------------------------------------
# * Use Skill/Item
#--------------------------------------------------------------------------
def use_item
item = @subject.current_action.item
@log_window.display_use_item(@subject, item)
@subject.use_item(item)
refresh_status
targets = @subject.current_action.make_targets.compact
show_animation(targets, item.animation_id)
targets.each {|target| item.repeats.times { invoke_item(target, item) } }
end
#--------------------------------------------------------------------------
# * Invoke Skill/Item
#--------------------------------------------------------------------------
def invoke_item(target, item)
if rand < target.item_cnt(@subject, item)
invoke_counter_attack(target, item)
elsif rand < target.item_mrf(@subject, item)
invoke_magic_reflection(target, item)
else
apply_item_effects(apply_substitute(target, item), item)
end
@subject.last_target_index = target.index
end
#--------------------------------------------------------------------------
# * Apply Skill/Item Effect
#--------------------------------------------------------------------------
def apply_item_effects(target, item)
target.item_apply(@subject, item)
refresh_status
@log_window.display_action_results(target, item)
end
#--------------------------------------------------------------------------
# * Invoke Counterattack
#--------------------------------------------------------------------------
def invoke_counter_attack(target, item)
@log_window.display_counter(target, item)
attack_skill = $data_skills[target.attack_skill_id]
@subject.item_apply(target, attack_skill)
refresh_status
@log_window.display_action_results(@subject, attack_skill)
end
#--------------------------------------------------------------------------
# * Invoke Magic Reflection
#--------------------------------------------------------------------------
def invoke_magic_reflection(target, item)
@subject.magic_reflection = true
@log_window.display_reflection(target, item)
apply_item_effects(@subject, item)
@subject.magic_reflection = false
end
#--------------------------------------------------------------------------
# * Apply Substitute
#--------------------------------------------------------------------------
def apply_substitute(target, item)
if check_substitute(target, item)
substitute = target.friends_unit.substitute_battler
if substitute && target != substitute
@log_window.display_substitute(substitute, target)
return substitute
end
end
target
end
#--------------------------------------------------------------------------
# * Check Substitute Condition
#--------------------------------------------------------------------------
def check_substitute(target, item)
target.hp < target.mhp / 4 && (!item || !item.certain?)
end
#--------------------------------------------------------------------------
# * Show Animation
# targets : Target array
# animation_id : Animation ID (-1: Same as normal attack)
#--------------------------------------------------------------------------
def show_animation(targets, animation_id)
if animation_id < 0
show_attack_animation(targets)
else
show_normal_animation(targets, animation_id)
end
@log_window.wait
wait_for_animation
end
#--------------------------------------------------------------------------
# * Show Attack Animation
# targets : Target array
# Account for dual wield in the case of an actor (flip left hand weapon
# display). If enemy, play the [Enemy Attack] SE and wait briefly.
#--------------------------------------------------------------------------
def show_attack_animation(targets)
if @subject.actor?
show_normal_animation(targets, @subject.atk_animation_id1, false)
show_normal_animation(targets, @subject.atk_animation_id2, true)
else
Sound.play_enemy_attack
abs_wait_short
end
end
#--------------------------------------------------------------------------
# * Show Normal Animation
# targets : Target array
# animation_id : Animation ID
# mirror : Flip horizontal
#--------------------------------------------------------------------------
def show_normal_animation(targets, animation_id, mirror = false)
animation = $data_animations[animation_id]
if animation
targets.each do |target|
target.animation_id = animation_id
target.animation_mirror = mirror
abs_wait_short unless animation.to_screen?
end
abs_wait_short if animation.to_screen?
end
end
end
No problem!Thank you so much!!!
It turned out that the script still doesn't workNo problem!
Do you have any additional "third-party" scripts installed? If not I can fix it quickly. If so, it will be more complicated.It turned out that the script still doesn't work
It just says error
I disagree, because of 3rd party scripts. Now I know you saidSeriously - if you start a new project, just copy your Scripts file from that project into your current one, or copy your Data folder from the current project into the new one (and any resources you've added).
That makes sense, but it won't save any parameters/script settings he may have changed.If you used a different battle system script, then you're going to have to find it and redownload it and add it back to your game.
If he's deleted the script, which is what the OP says, he's already lost them anyway.That makes sense, but it won't save any parameters/script settings he may have changed.
I thought he meant he deleted the default battle system scriptIf he's deleted the script, which is what the OP says, he's already lost them anyway.
I deleted the battle manager scriptAh okay. See this screenshot:
View attachment 88975
Put the script I posted right where it is in that screenshot, under "Scene_Debug".
#==============================================================================
# ** BattleManager
#------------------------------------------------------------------------------
# This module manages battle progress.
#==============================================================================
module BattleManager
#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
def self.setup(troop_id, can_escape = true, can_lose = false)
init_members
$game_troop.setup(troop_id)
@can_escape = can_escape
@can_lose = can_lose
make_escape_ratio
end
#--------------------------------------------------------------------------
# * Initialize Member Variables
#--------------------------------------------------------------------------
def self.init_members
@phase = :init # Battle Progress Phase
@can_escape = false # Can Escape Flag
@can_lose = false # Can Lose Flag
@event_proc = nil # Event Callback
@preemptive = false # Preemptive Attack Flag
@surprise = false # Surprise Flag
@actor_index = -1 # Actor for Which Command Is Being Entered
@action_forced = nil # Force Action
@map_bgm = nil # For Memorizing Pre-Battle BGM
@map_bgs = nil # For Memorizing Pre-Battle BGS
@action_battlers = [] # Action Order List
end
#--------------------------------------------------------------------------
# * Processing at Encounter Time
#--------------------------------------------------------------------------
def self.on_encounter
@preemptive = (rand < rate_preemptive)
@surprise = (rand < rate_surprise && !@preemptive)
end
#--------------------------------------------------------------------------
# * Get Probability of Preemptive Attack
#--------------------------------------------------------------------------
def self.rate_preemptive
$game_party.rate_preemptive($game_troop.agi)
end
#--------------------------------------------------------------------------
# * Get Probability of Surprise
#--------------------------------------------------------------------------
def self.rate_surprise
$game_party.rate_surprise($game_troop.agi)
end
#--------------------------------------------------------------------------
# * Save BGM and BGS
#--------------------------------------------------------------------------
def self.save_bgm_and_bgs
@map_bgm = RPG::BGM.last
@map_bgs = RPG::BGS.last
end
#--------------------------------------------------------------------------
# * Play Battle BGM
#--------------------------------------------------------------------------
def self.play_battle_bgm
$game_system.battle_bgm.play
RPG::BGS.stop
end
#--------------------------------------------------------------------------
# * Play Battle End ME
#--------------------------------------------------------------------------
def self.play_battle_end_me
$game_system.battle_end_me.play
end
#--------------------------------------------------------------------------
# * Resume BGM and BGS
#--------------------------------------------------------------------------
def self.replay_bgm_and_bgs
@map_bgm.replay unless $BTEST
@map_bgs.replay unless $BTEST
end
#--------------------------------------------------------------------------
# * Create Escape Success Probability
#--------------------------------------------------------------------------
def self.make_escape_ratio
@escape_ratio = 1.5 - 1.0 * $game_troop.agi / $game_party.agi
end
#--------------------------------------------------------------------------
# * Determine if Turn Is Executing
#--------------------------------------------------------------------------
def self.in_turn?
@phase == :turn
end
#--------------------------------------------------------------------------
# * Determine if Turn Is Ending
#--------------------------------------------------------------------------
def self.turn_end?
@phase == :turn_end
end
#--------------------------------------------------------------------------
# * Determine if Battle Is Aborting
#--------------------------------------------------------------------------
def self.aborting?
@phase == :aborting
end
#--------------------------------------------------------------------------
# * Get Whether Escape Is Possible
#--------------------------------------------------------------------------
def self.can_escape?
@can_escape
end
#--------------------------------------------------------------------------
# * Get Actor for Which Command Is Being Entered
#--------------------------------------------------------------------------
def self.actor
@actor_index >= 0 ? $game_party.members[@actor_index] : nil
end
#--------------------------------------------------------------------------
# * Clear Actor for Which Command Is Being Entered
#--------------------------------------------------------------------------
def self.clear_actor
@actor_index = -1
end
#--------------------------------------------------------------------------
# * To Next Command Input
#--------------------------------------------------------------------------
def self.next_command
begin
if !actor || !actor.next_command
@actor_index += 1
return false if @actor_index >= $game_party.members.size
end
end until actor.inputable?
return true
end
#--------------------------------------------------------------------------
# * To Previous Command Input
#--------------------------------------------------------------------------
def self.prior_command
begin
if !actor || !actor.prior_command
@actor_index -= 1
return false if @actor_index < 0
end
end until actor.inputable?
return true
end
#--------------------------------------------------------------------------
# * Set Proc for Callback to Event
#--------------------------------------------------------------------------
def self.event_proc=(proc)
@event_proc = proc
end
#--------------------------------------------------------------------------
# * Set Wait Method
#--------------------------------------------------------------------------
def self.method_wait_for_message=(method)
@method_wait_for_message = method
end
#--------------------------------------------------------------------------
# * Wait Until Message Display has Finished
#--------------------------------------------------------------------------
def self.wait_for_message
@method_wait_for_message.call if @method_wait_for_message
end
#--------------------------------------------------------------------------
# * Battle Start
#--------------------------------------------------------------------------
def self.battle_start
$game_system.battle_count += 1
$game_party.on_battle_start
$game_troop.on_battle_start
$game_troop.enemy_names.each do |name|
$game_message.add(sprintf(Vocab::Emerge, name))
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
end
#--------------------------------------------------------------------------
# * Battle Abort
#--------------------------------------------------------------------------
def self.abort
@phase = :aborting
end
#--------------------------------------------------------------------------
# * Determine Win/Loss Results
#--------------------------------------------------------------------------
def self.judge_win_loss
if @phase
return process_abort if $game_party.members.empty?
return process_defeat if $game_party.all_dead?
return process_victory if $game_troop.all_dead?
return process_abort if aborting?
end
return false
end
#--------------------------------------------------------------------------
# * Victory Processing
#--------------------------------------------------------------------------
def self.process_victory
play_battle_end_me
replay_bgm_and_bgs
$game_message.add(sprintf(Vocab::Victory, $game_party.name))
display_exp
gain_gold
gain_drop_items
gain_exp
SceneManager.return
battle_end(0)
return true
end
#--------------------------------------------------------------------------
# * Escape Processing
#--------------------------------------------------------------------------
def self.process_escape
$game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
success = @preemptive ? true : (rand < @escape_ratio)
Sound.play_escape
if success
process_abort
else
@escape_ratio += 0.1
$game_message.add('\.' + Vocab::EscapeFailure)
$game_party.clear_actions
end
wait_for_message
return success
end
#--------------------------------------------------------------------------
# * Abort Processing
#--------------------------------------------------------------------------
def self.process_abort
replay_bgm_and_bgs
SceneManager.return
battle_end(1)
return true
end
#--------------------------------------------------------------------------
# * Defeat Processing
#--------------------------------------------------------------------------
def self.process_defeat
$game_message.add(sprintf(Vocab::Defeat, $game_party.name))
wait_for_message
if @can_lose
revive_battle_members
replay_bgm_and_bgs
SceneManager.return
else
SceneManager.goto(Scene_Gameover)
end
battle_end(2)
return true
end
#--------------------------------------------------------------------------
# * Revive Battle Members (When Defeated)
#--------------------------------------------------------------------------
def self.revive_battle_members
$game_party.battle_members.each do |actor|
actor.hp = 1 if actor.dead?
end
end
#--------------------------------------------------------------------------
# * End Battle
# result : Result (0: Win 1: Escape 2: Lose)
#--------------------------------------------------------------------------
def self.battle_end(result)
@phase = nil
@event_proc.call(result) if @event_proc
$game_party.on_battle_end
$game_troop.on_battle_end
SceneManager.exit if $BTEST
end
#--------------------------------------------------------------------------
# * Start Command Input
#--------------------------------------------------------------------------
def self.input_start
if @phase != :input
@phase = :input
$game_party.make_actions
$game_troop.make_actions
clear_actor
end
return !@surprise && $game_party.inputable?
end
#--------------------------------------------------------------------------
# * Start Turn
#--------------------------------------------------------------------------
def self.turn_start
@phase = :turn
clear_actor
$game_troop.increase_turn
make_action_orders
end
#--------------------------------------------------------------------------
# * End Turn
#--------------------------------------------------------------------------
def self.turn_end
@phase = :turn_end
@preemptive = false
@surprise = false
end
#--------------------------------------------------------------------------
# * Display EXP Earned
#--------------------------------------------------------------------------
def self.display_exp
if $game_troop.exp_total > 0
text = sprintf(Vocab::ObtainExp, $game_troop.exp_total)
$game_message.add('\.' + text)
end
end
#--------------------------------------------------------------------------
# * Gold Acquisition and Display
#--------------------------------------------------------------------------
def self.gain_gold
if $game_troop.gold_total > 0
text = sprintf(Vocab::ObtainGold, $game_troop.gold_total)
$game_message.add('\.' + text)
$game_party.gain_gold($game_troop.gold_total)
end
wait_for_message
end
#--------------------------------------------------------------------------
# * Dropped Item Acquisition and Display
#--------------------------------------------------------------------------
def self.gain_drop_items
$game_troop.make_drop_items.each do |item|
$game_party.gain_item(item, 1)
$game_message.add(sprintf(Vocab::ObtainItem, item.name))
end
wait_for_message
end
#--------------------------------------------------------------------------
# * EXP Acquisition and Level Up Display
#--------------------------------------------------------------------------
def self.gain_exp
$game_party.all_members.each do |actor|
actor.gain_exp($game_troop.exp_total)
end
wait_for_message
end
#--------------------------------------------------------------------------
# * Create Action Order
#--------------------------------------------------------------------------
def self.make_action_orders
@action_battlers = []
@action_battlers += $game_party.members unless @surprise
@action_battlers += $game_troop.members unless @preemptive
@action_battlers.each {|battler| battler.make_speed }
@action_battlers.sort! {|a,b| b.speed - a.speed }
end
#--------------------------------------------------------------------------
# * Force Action
#--------------------------------------------------------------------------
def self.force_action(battler)
@action_forced = battler
@action_battlers.delete(battler)
end
#--------------------------------------------------------------------------
# * Get Forced State of Battle Action
#--------------------------------------------------------------------------
def self.action_forced?
@action_forced != nil
end
#--------------------------------------------------------------------------
# * Get Battler Subjected to Forced Action
#--------------------------------------------------------------------------
def self.action_forced_battler
@action_forced
end
#--------------------------------------------------------------------------
# * Clear Forcing of Battle Action
#--------------------------------------------------------------------------
def self.clear_action_force
@action_forced = nil
end
#--------------------------------------------------------------------------
# * Get Next Action Subject
# Get the battler from the beginning of the action order list.
# If an actor not currently in the party is obtained (occurs when index
# is nil, immediately after escaping in battle events etc.), skip them.
#--------------------------------------------------------------------------
def self.next_subject
loop do
battler = @action_battlers.shift
return nil unless battler
next unless battler.index && battler.alive?
return battler
end
end
end