#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This class is for all in-game windows.
#==============================================================================
class Window_Base < Window
attr_accessor :bg_sprite
#--------------------------------------------------------------------------
# * Object Initialization
# x : window x-coordinate
# y : window y-coordinate
# width : window width
# height : window height
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super()
@windowskin_name = $game_system.windowskin_name
self.windowskin = RPG::Cache.windowskin(@windowskin_name)
self.x = x
self.y = y
self.width = width
self.height = height
self.z = 100
@bg_sprite = Sprite.new(self.viewport)
@bg_sprite.x = x
@bg_sprite.y = y
@bg_sprite.z = self.z + 1
@bg_sprite.bitmap = Bitmap.new(width, height)
end
#--------------------------------------------------------------------------
# * bg_bitmap =
#--------------------------------------------------------------------------
def bg_bitmap=(bitmap_name)
@bg_sprite.bitmap = Bitmap.new(bitmap_name)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# Reset if windowskin was changed
if $game_system.windowskin_name != @windowskin_name
@windowskin_name = $game_system.windowskin_name
self.windowskin = RPG::Cache.windowskin(@windowskin_name)
end
@bg_sprite.x = x
@bg_sprite.y = y
end
end
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Initialize each kind of temporary battle data
$game_temp.in_battle = true
$game_temp.battle_turn = 0
$game_temp.battle_event_flags.clear
$game_temp.battle_abort = false
$game_temp.battle_main_phase = false
$game_temp.battleback_name = $game_map.battleback_name
$game_temp.forcing_battler = nil
# Initialize battle event interpreter
$game_system.battle_interpreter.setup(nil, 0)
# Prepare troop
@troop_id = $game_temp.battle_troop_id
$game_troop.setup(@troop_id)
# Make actor command window
s1 = $data_system.words.attack
s2 = $data_system.words.skill
s3 = $data_system.words.guard
s4 = $data_system.words.item
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
@actor_command_window.y = 160
@actor_command_window.back_opacity = 160
# @actor_command_window.bg_sprite.opacity = 160
@actor_command_window.active = false
@actor_command_window.visible = false
blank_skin = RPG::Cache.windowskin("battle_skin")
@actor_command_window.windowskin = blank_skin
@actor_command_window.bg_bitmap = "Graphics/Windowskins/battle_actor_command"
@actor_command_window.bg_sprite.visible = false
# Make other windows
@party_command_window = Window_PartyCommand.new
@party_command_window.windowskin = blank_skin
@party_command_window.bg_bitmap = "Graphics/Windowskins/battle_help"
# @party_command_window.bg_sprite.opacity = 160
@help_window = Window_Help.new
@help_window.back_opacity = 160
# @help_window.bg_sprite.opacity = 160
@help_window.visible = false
@help_window.windowskin = blank_skin
@help_window.bg_bitmap = "Graphics/Windowskins/battle_help"
@help_window.bg_sprite.visible = false
@status_window = Window_BattleStatus.new
@status_window.windowskin = blank_skin
@status_window.bg_bitmap = "Graphics/Windowskins/battle_status"
# @status_window.bg_sprite.opacity = 160
@message_window = Window_Message.new
# Make sprite set
@spriteset = Spriteset_Battle.new
# Initialize wait count
@wait_count = 0
# Execute transition
if $data_system.battle_transition == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$data_system.battle_transition)
end
# Start pre-battle phase
start_phase1
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Refresh map
$game_map.refresh
# Prepare for transition
Graphics.freeze
# Dispose of windows
@actor_command_window.dispose
@party_command_window.dispose
@help_window.dispose
@status_window.dispose
@message_window.dispose
if @skill_window != nil
@skill_window.dispose
end
if @item_window != nil
@item_window.dispose
end
if @result_window != nil
@result_window.dispose
end
# Dispose of sprite set
@spriteset.dispose
# If switching to title screen
if $scene.is_a?(Scene_Title)
# Fade out screen
Graphics.transition
Graphics.freeze
end
# If switching from battle test to any screen other than game over screen
if $BTEST and not $scene.is_a?(Scene_Gameover)
$scene = nil
end
end
#--------------------------------------------------------------------------
# * Start Party Command Phase
#--------------------------------------------------------------------------
def start_phase2
# Shift to phase 2
@phase = 2
# Set actor to non-selecting
@actor_index = -1
@active_battler = nil
# Enable party command window
@party_command_window.active = true
@party_command_window.visible = true
@party_command_window.bg_sprite.visible = true
# Disable actor command window
@actor_command_window.active = false
@actor_command_window.visible = false
@actor_command_window.bg_sprite.visible = false
# Clear main phase flag
$game_temp.battle_main_phase = false
# Clear all party member actions
$game_party.clear_actions
# If impossible to input command
unless $game_party.inputable?
# Start main phase
start_phase4
end
end
#--------------------------------------------------------------------------
# * Actor Command Window Setup
#--------------------------------------------------------------------------
def phase3_setup_command_window
# Disable party command window
@party_command_window.active = false
@party_command_window.visible = false
@party_command_window.bg_sprite.visible = false
# Enable actor command window
@actor_command_window.active = true
@actor_command_window.visible = true
@actor_command_window.bg_sprite.visible = true
# Set actor command window position
@actor_command_window.x = @actor_index * 160
# Set index to 0
@actor_command_window.index = 0
end
#--------------------------------------------------------------------------
# * Start Enemy Selection
#--------------------------------------------------------------------------
def start_enemy_select
# Make enemy arrow
@enemy_arrow = Arrow_Enemy.new(@spriteset.viewport1)
# Associate help window
@enemy_arrow.help_window = @help_window
@help_window.bg_sprite.visible = true
# Disable actor command window
@actor_command_window.active = false
@actor_command_window.visible = false
@actor_command_window.bg_sprite.visible = false
end
#--------------------------------------------------------------------------
# * End Enemy Selection
#--------------------------------------------------------------------------
def end_enemy_select
# Dispose of enemy arrow
@enemy_arrow.dispose
@enemy_arrow = nil
# If command is [fight]
if @actor_command_window.index == 0
# Enable actor command window
@actor_command_window.active = true
@actor_command_window.visible = true
@actor_command_window.bg_sprite.visible = true
# Hide help window
@help_window.visible = false
@help_window.bg_sprite.visible = false
end
end
#--------------------------------------------------------------------------
# * Start Actor Selection
#--------------------------------------------------------------------------
def start_actor_select
# Make actor arrow
@actor_arrow = Arrow_Actor.new(@spriteset.viewport2)
@actor_arrow.index = @actor_index
# Associate help window
@actor_arrow.help_window = @help_window
@help_window.bg_sprite.visible = true
# Disable actor command window
@actor_command_window.active = false
@actor_command_window.visible = false
@actor_command_window.bg_sprite.visible = false
end
#--------------------------------------------------------------------------
# * End Actor Selection
#--------------------------------------------------------------------------
def end_actor_select
# Dispose of actor arrow
@actor_arrow.dispose
@actor_arrow = nil
end
#--------------------------------------------------------------------------
# * Start Skill Selection
#--------------------------------------------------------------------------
def start_skill_select
# Make skill window
@skill_window = Window_Skill.new(@active_battler)
# Associate help window
@skill_window.help_window = @help_window
@help_window.bg_sprite.visible = true
# Disable actor command window
@actor_command_window.active = false
@actor_command_window.visible = false
@actor_command_window.bg_sprite.visible = false
end
#--------------------------------------------------------------------------
# * End Skill Selection
#--------------------------------------------------------------------------
def end_skill_select
# Dispose of skill window
@skill_window.dispose
@skill_window = nil
# Hide help window
@help_window.visible = false
@help_window.bg_sprite.visible = false
# Enable actor command window
@actor_command_window.active = true
@actor_command_window.visible = true
@actor_command_window.bg_sprite.visible = true
end
#--------------------------------------------------------------------------
# * Start Item Selection
#--------------------------------------------------------------------------
def start_item_select
# Make item window
@item_window = Window_Item.new
# Associate help window
@item_window.help_window = @help_window
@help_window.bg_sprite.visible = true
# Disable actor command window
@actor_command_window.active = false
@actor_command_window.visible = false
@actor_command_window.bg_sprite.visible = false
end
#--------------------------------------------------------------------------
# * End Item Selection
#--------------------------------------------------------------------------
def end_item_select
# Dispose of item window
@item_window.dispose
@item_window = nil
# Hide help window
@help_window.visible = false
@help_window.bg_sprite.visible = false
# Enable actor command window
@actor_command_window.active = true
@actor_command_window.visible = true
@actor_command_window.bg_sprite.visible = true
end
#--------------------------------------------------------------------------
# * Start Main Phase
#--------------------------------------------------------------------------
def start_phase4
# Shift to phase 4
@phase = 4
# Turn count
$game_temp.battle_turn += 1
# Search all battle event pages
for index in 0...$data_troops[@troop_id].pages.size
# Get event page
page = $data_troops[@troop_id].pages[index]
# If this page span is [turn]
if page.span == 1
# Clear action completed flags
$game_temp.battle_event_flags[index] = false
end
end
# Set actor as unselectable
@actor_index = -1
@active_battler = nil
# Enable party command window
@party_command_window.active = false
@party_command_window.visible = false
@party_command_window.bg_sprite.visible = false
# Disable actor command window
@actor_command_window.active = false
@actor_command_window.visible = false
@actor_command_window.bg_sprite.visible = false
# Set main phase flag
$game_temp.battle_main_phase = true
# Make enemy action
for enemy in $game_troop.enemies
enemy.make_action
end
# Make action orders
make_action_orders
# Shift to step 1
@phase4_step = 1
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 1 : action preparation)
#--------------------------------------------------------------------------
def update_phase4_step1
# Hide help window
@help_window.visible = false
@help_window.bg_sprite.visible = false
# Determine win/loss
if judge
# If won, or if lost : end method
return
end
# If an action forcing battler doesn't exist
if $game_temp.forcing_battler == nil
# Set up battle event
setup_battle_event
# If battle event is running
if $game_system.battle_interpreter.running?
return
end
end
# If an action forcing battler exists
if $game_temp.forcing_battler != nil
# Add to head, or move
@action_battlers.delete($game_temp.forcing_battler)
@action_battlers.unshift($game_temp.forcing_battler)
end
# If no actionless battlers exist (all have performed an action)
if @action_battlers.size == 0
# Start party command phase
start_phase2
return
end
# Initialize animation ID and common event ID
@animation1_id = 0
@animation2_id = 0
@common_event_id = 0
# Shift from head of actionless battlers
@active_battler = @action_battlers.shift
# If already removed from battle
if @active_battler.index == nil
return
end
# Slip damage
if @active_battler.hp > 0 and @active_battler.slip_damage?
@active_battler.slip_damage_effect
@active_battler.damage_pop = true
end
# Natural removal of states
@active_battler.remove_states_auto
# Refresh status window
@status_window.refresh
# Shift to step 2
@phase4_step = 2
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 5 : damage display)
#--------------------------------------------------------------------------
def update_phase4_step5
# Hide help window
@help_window.visible = false
@help_window.bg_sprite.visible = false
# Refresh status window
@status_window.refresh
# Display damage
for target in @target_battlers
if target.damage != nil
target.damage_pop = true
end
end
# Shift to step 6
@phase4_step = 6
end
end