Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Custom Battle System (CTB) by Charlie Fleed
- #
- # Version: 3.2
- # Author: Charlie Fleed
- #==============================================================================
- #==============================================================================
- # ** Scene_Battle (part 1)
- #------------------------------------------------------------------------------
- # This class performs battle screen processing.
- #==============================================================================
- class Scene_Battle
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :action_times
- attr_reader :active_battler_copy
- attr_accessor :wait_count
- attr_reader :target_battlers
- #--------------------------------------------------------------------------
- # * 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
- @wait_count = 0
- @battlers_queue = []
- @battlers_array = []
- @action_times = []
- $game_temp.battle_time = 0
- @prev_actor_command = ""
- ## REFLECT SUPPORT ##
- @reflected_battler = nil
- @reflecters = []
- ## REACTION SUPPORT ##
- @target_of_reaction = nil
- @reacting_battler = nil
- @reacting = false
- ## AUTO PHOENIX SUPPORT ##
- @phoenix_users = []
- @using_phoenix = false
- @phoenix_targets = []
- ## AUTO LIFE SUPPORT ##
- @auto_life_targets = []
- @auto_life = false
- @using_auto_life = false
- ## FORCED ACTION SUPPORT
- @active_battler_saved_forced_action=Game_BattleAction.new
- ## Extended party support
- $game_party.update_size
- @switch_common_event = false
- @retire_common_event = false
- @new_battle_turn = true
- # @battle_event_to_setup is used as a flag when delaying the execution of
- # battle events when animating the hp/sp bars
- @battle_event_to_setup = false
- @old_party = []
- # 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)
- # Support for hp bars
- for enemy in $game_troop.enemies
- if $game_system.killed_enemies_ids.include?(enemy.id)
- enemy.show_hp_bar = true
- end
- end
- # 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_Plus.new(ACTOR_COMMAND_WINDOW_WIDTH,
- 112, [s1, s2, s3, s4, "Skip", "Status", "Escape"], 20)
- @actor_command_window.x = ACTOR_COMMAND_WINDOW_X
- @actor_command_window.target_x = ACTOR_COMMAND_WINDOW_X
- @actor_command_window.y = 368
- @actor_command_window.z = 200
- @actor_command_window.back_opacity = 255
- @actor_command_window.opacity = ACTOR_COMMAND_WINDOW_WINDOWSKIN_OPACITY
- @actor_command_window.active = false
- @actor_command_window.visible = false
- @actor_command_window.custom_normal_color = ACTOR_COMMAND_WINDOW_TEXT_COLOR
- @actor_command_window.custom_normal_b_color = ACTOR_COMMAND_WINDOW_TEXT_BG_COLOR
- @actor_command_window.set_font_size(20 + ACTOR_COMMAND_WINDOW_TEXT_SIZE_OFFSET)
- @actor_command_window.refresh
- # Make other windows
- @turn_window = Window_BattleTurns.new
- @turn_window.visible = false
- @turn_window.set_action_times(@action_times)
- @enemy_attacks_window = Window_Enemy_Attacks.new
- @all_enemies_window = Window_All_Enemies.new
- @all_allies_window = Window_All_Allies.new
- @battler_window = Window_Battler.new
- @escape_window = Window_Failed_Escape.new
- @reaction_window = Window_Reaction.new(nil)
- @auto_phoenix_window = Window_AutoPhoenix.new(nil)
- @actor_select_window = Window_Actor_Select.new
- @left_actor_command_window = Window_Command_Plus.new(ACTOR_COMMAND_WINDOW_WIDTH,
- 112, [s3, "Skip", "Status", "Escape"], 20)
- @left_actor_command_window.custom_normal_color=ACTOR_COMMAND_WINDOW_TEXT_COLOR
- @left_actor_command_window.custom_normal_b_color=ACTOR_COMMAND_WINDOW_TEXT_BG_COLOR
- begin
- if LEFT_ACTOR_COMMAND_WINDOWSKIN_NAME != ""
- @left_actor_command_window.windowskin =
- RPG::Cache.windowskin(LEFT_ACTOR_COMMAND_WINDOWSKIN_NAME)
- end
- rescue
- p LEFT_ACTOR_COMMAND_WINDOWSKIN_NAME + " not found."
- end
- @left_actor_command_window.opacity = LEFT_ACTOR_COMMAND_WINDOWSKIN_OPACITY
- @left_actor_command_window.set_font_size(20 + ACTOR_COMMAND_WINDOW_TEXT_SIZE_OFFSET)
- @left_actor_command_window.refresh
- @left_actor_command_window.visible = false
- @left_actor_command_window.active = false
- @left_actor_command_window.set_x(ACTOR_COMMAND_WINDOW_X)
- @left_actor_command_window.set_y(368)
- @left_actor_command_window.z = 204
- @battler_window.visible = false
- @battler_window.z = 200
- @status_on_battle_window = Window_Status_On_Battle.new
- @status_on_battle_window.visible = false
- @help_window = Window_Help_Tiny.new
- @help_window.back_opacity = 160
- @help_window.visible = false
- @help_window.back_opacity = 200 #255
- @help_window.z = 205
- battle_data_hard_reset
- @status_window = Window_BattleStatus.new
- @message_window = Window_Message.new
- # Make other windows
- @grandia_bar_window = Window_GrandiaBar.new if GRANDIA_MODE
- # Make sprite set
- @spriteset = Spriteset_Battle.new
- @actor_command_bg=Sprite.new(@spriteset.viewport2)
- begin
- @actor_command_bg.bitmap = RPG::Cache.picture(ACTOR_COMMAND_BG_PICTURE_NAME)
- rescue
- if ACTOR_COMMAND_BG_PICTURE_NAME != ""
- p ACTOR_COMMAND_BG_PICTURE_NAME + " not found."
- end
- end
- @actor_command_bg.x = ACTOR_COMMAND_WINDOW_X + ACTOR_COMMAND_BG_PICTURE_X
- @actor_command_bg.z = 2502
- @actor_command_bg.y = @actor_command_window.y + ACTOR_COMMAND_BG_PICTURE_Y
- @actor_command_bg.visible = false
- # 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
- @enemy_attacks_window.dispose
- @all_enemies_window.dispose
- @all_allies_window.dispose
- @escape_window.dispose
- @battler_window.dispose
- @reaction_window.dispose
- @auto_phoenix_window.dispose
- @turn_window.dispose
- @actor_select_window.dispose
- @status_on_battle_window.dispose
- @actor_command_bg.dispose if @actor_command_bg != nil
- @left_actor_command_window.dispose
- @grandia_bar_window.dispose if GRANDIA_MODE
- @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
- if @result_window2 != nil
- @result_window2.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
- # def battle_end(result) [unchanged]
- # def setup_battle_event [unchanged]
- #--------------------------------------------------------------------------
- # * Judge
- #--------------------------------------------------------------------------
- alias ctb_judge judge
- def judge
- # If all dead determinant is true, or number of members in party is 0
- if $game_party.all_dead? or $game_party.actors.size == 0
- for actor in $game_party.actors
- if actor.state?($auto_life_state_id)
- $outfile.write "judge: dead actor is in auto life\n" if $outfile
- return false
- end
- end
- end
- if ($charlie_fleed_summons!=nil) and
- $game_party.removed_actors.size == 0
- regular_actor_alive = false
- for actor in $game_party.actors
- if ($charlie_fleed_summons != nil) and
- not $game_party.aeons_ids.include?(actor.id) and
- ((not actor.dead?) or actor.state?($auto_life_state_id))
- regular_actor_alive = true
- end
- end
- unless regular_actor_alive
- # If possible to lose
- if $game_temp.battle_can_lose
- # Return to BGM before battle starts
- $game_system.bgm_play($game_temp.map_bgm)
- # Battle ends
- battle_end(2)
- # Return true
- $outfile.write "judge battle_end(2)\n" if $outfile
- return true
- end
- $game_temp.gameover = true
- end
- end
- return ctb_judge
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- $outfile.write "update\n" if $outfile
- if @battle_event_to_setup == true
- $outfile.write "update there is a @battle_event_to_setup\n" if $outfile
- if $game_temp.forcing_battler == nil
- if not @status_window.animate_bars and not @spriteset.effect?
- $outfile.write "@status_window.animate_bars = false\n" if $outfile
- # Rerun battle event set up if battle continues
- $outfile.write "executing judge\n" if $outfile
- if not judge
- $outfile.write "update setup_battle_event @battle_event_to_setup\n" if $outfile
- setup_battle_event
- @battle_event_to_setup = false
- else
- $outfile.write "judge! cancel @battle_event_to_setup\n" if $outfile
- @battle_event_to_setup = false
- end
- end
- end
- end
- # If battle event is running
- if $game_system.battle_interpreter.running?
- $outfile.write "update battle_interpreter.running\n" if $outfile
- # Update interpreter
- $outfile.write "$game_system.battle_interpreter.update\n" if $outfile
- $game_system.battle_interpreter.update
- $outfile.write "after battle_interpreter.update - gameover = " +
- $game_temp.gameover.to_s + "\n" if $outfile
- if not @status_window.animate_bars
- $outfile.write "set animate_bars\n" if $outfile
- @status_window.animate_bars = true
- end
- # If a battler which is forcing actions doesn't exist
- if $game_temp.forcing_battler == nil
- # If battle event has finished running
- unless $game_system.battle_interpreter.running?
- $outfile.write "battle event has finished running\n" if $outfile
- @status_window.refresh_hp
- @status_window.refresh_sp
- @status_window.update_animate_bars
- if not @status_window.animate_bars and not @spriteset.effect?
- # Rerun battle event set up if battle continues
- $outfile.write "executing judge\n" if $outfile
- unless judge
- $outfile.write "update setup_battle_event\n" if $outfile
- setup_battle_event
- end
- else
- $outfile.write "set @battle_event_to_setup\n" if $outfile
- @battle_event_to_setup = true
- end
- end
- end
- end
- # Update system (timer) and screen
- $game_system.update
- $game_screen.update
- # If timer has reached 0
- if $game_system.timer_working and $game_system.timer == 0
- # Abort battle
- $game_temp.battle_abort = true
- end
- # Update windows
- @turn_window.update if (@phase == 3 or @phase == 2)
- @battler_window.update if (@phase == 3 or @phase == 2)
- @help_window.update if (@phase != 4)
- if @message_window.visible
- @actor_command_window.update_xy if (@phase == 3)
- @left_actor_command_window.update_xy if (@phase == 3 and @left_actor_command_window.active)
- else
- @actor_command_window.update if (@phase == 3)
- @left_actor_command_window.update if (@phase == 3 and @left_actor_command_window.active)
- end
- @actor_command_bg.visible = (@actor_command_window.visible or @left_actor_command_window.visible)
- @status_window.update
- if @phase != 4 and @status_window.counter == 0
- for enemy in $game_troop.enemies
- enemy.toggle_shown_state()
- end
- end
- # Always refresh the status window upon party changes
- if @old_party != $game_party.actors
- # Set actor to non-selecting
- @status_window.index =- 1
- @status_window.refresh
- end
- @old_party = $game_party.actors.clone
- @status_window.refresh_hp if (@phase == 4 and @status_window.animate_bars)
- @status_window.refresh_sp if (@phase == 4 and @status_window.animate_bars)
- @result_window.update if @result_window != nil
- # Floating status on battle window
- if @help_window.visible or @message_window.visible
- @status_on_battle_window.target_y =- 80
- else
- @status_on_battle_window.target_y = 0
- end
- @status_on_battle_window.update
- #lo stato non si aggiorna finchè non termina l'animazione
- @message_window.update
- if @stolen_item_window != nil
- update_stolen_item_window
- @wait_count = 1
- end
- # Update sprite set
- @spriteset.update
- # If transition is processing
- if $game_temp.transition_processing
- # Clear transition processing flag
- $game_temp.transition_processing = false
- # Execute transition
- if $game_temp.transition_name == ""
- Graphics.transition(20)
- else
- Graphics.transition(40, "Graphics/Transitions/" +
- $game_temp.transition_name)
- end
- end
- # If message window is showing
- if $game_temp.message_window_showing
- $outfile.write "update message_window_showing\n" if $outfile
- return
- end
- # If effect is showing
- if @spriteset.effect?
- $outfile.write "update @spriteset.effect\n" if $outfile
- return
- end
- # If game over
- if $game_temp.command_353
- # Switch to game over screen
- $scene = Scene_Gameover.new
- $outfile.write "Gameover by command 353\n" if $outfile
- return
- elsif $game_temp.gameover
- if not @status_window.animate_bars and not @spriteset.effect?
- # If there are not removed actors
- if ($charlie_fleed_summons == nil) or $game_party.removed_actors.size == 0
- $outfile.write "phase " + @phase.to_s + " gameover\n" if $outfile
- # Switch to game over screen
- $scene = Scene_Gameover.new
- return
- end
- $outfile.write "no gameover, there are removed actors\n" if $outfile
- $game_temp.gameover = false
- else
- $outfile.write "update @status_window.animate_bars\n" if $outfile
- end
- end
- # If returning to title screen
- if $game_temp.to_title
- # Switch to title screen
- $scene = Scene_Title.new
- return
- end
- # If battle is aborted
- if $game_temp.battle_abort
- # Return to BGM used before battle started
- $game_system.bgm_play($game_temp.map_bgm)
- # Battle ends
- battle_end(1)
- $outfile.write "update battle_end(1)\n" if $outfile
- return
- end
- # If waiting
- if @wait_count > 0
- # Decrease wait count
- @wait_count -= 1
- $outfile.write "update @wait_count > 0\n" if $outfile
- return
- end
- # If battler forcing an action doesn't exist,
- # and battle event is running
- if $game_temp.forcing_battler == nil and
- $game_system.battle_interpreter.running?
- return
- end
- # Branch according to phase
- case @phase
- when 1 # pre-battle phase
- update_phase1
- when 2 # party command phase
- update_phase2
- when 3 # actor command phase
- update_phase3
- when 4 # main phase
- update_phase4
- when 5 # after battle phase
- update_phase5
- end
- end
- #--------------------------------------------------------------------------
- # * Start Pre-Battle Phase
- #--------------------------------------------------------------------------
- def start_phase1
- # Shift to phase 1
- @phase = 1
- # Clear all party member actions
- $game_party.clear_actions
- end
- # def update_phase1 [unchanged]
- #--------------------------------------------------------------------------
- # * Start Party Command Phase
- #--------------------------------------------------------------------------
- def start_phase2
- # print("start_phase2")
- $outfile.write "*** start_phase2 ***\n" if $outfile
- # This method now updates the queue and determines the new active battler
- # Shift to phase 2
- @phase = 2
- @reflected_battler = nil
- @reflecters= []
- @reacting = false
- @return_guarding = false
- @return_to_forced_action = false
- @using_phoenix = false
- @using_auto_life = false
- @hits_count = 0
- # Set actor to non-selecting
- @actor_index = -1
- @active_battler = nil
- # @end_turn == true is now used as the condition to end the turn
- # in update_phase4_step1 instead of @active_battler == nil
- @end_turn = false
- @status_window.refresh
- $outfile.write "start_phase2 animate bars\n" if $outfile
- @status_window.animate_bars = true
- @status_window.index = @actor_index
- # remove phoenix targets if not in the party
- # and reset phoenix data if no target is in the party
- @phoenix_targets = @phoenix_targets & $game_party.actors
- if @phoenix_targets.empty?
- # reset phoenix data
- @auto_phoenix = false
- @phoenix_users = []
- @phoenix_targets = []
- end
- # Reset casting for dead actors
- for actor in $game_party.actors
- if actor.dead?
- actor.randomize_next_action_time
- actor.cf_casting = false
- actor.casting_action.clear
- end
- end
- make_auto_life_targets
- # In case of not playable reaction the active battler is not selected as
- # the first of the queue, the queue and the battle time are not updated
- if $game_temp.reaction and not PLAYABLE_REACTION
- $outfile.write "start_phase2: not playable reaction\n" if $outfile
- @active_battler = @reacting_battler
- elsif @auto_life
- $outfile.write "start_phase2: auto life\n" if $outfile
- @active_battler = @auto_life_targets[0]
- elsif @auto_phoenix
- $outfile.write "start_phase2: auto phoenix\n" if $outfile
- @active_battler = @phoenix_users.pop
- @auto_phoenix_window.actor = @active_battler
- @auto_phoenix_window.refresh
- else
- # calculates the queue of actions so that it can be shown
- $outfile.write "start_phase2: regular turn\n" if $outfile
- update_battlers_queue(UPDATE_DELAYS)
- @active_battler = @battlers_queue.first
- @active_battler_copy = @active_battler
- # set the actor index
- for i in 0 ... $game_party.actors.size
- if @active_battler == $game_party.actors[i]
- @actor_index = i
- end
- end
- # regular_turn_ended is now used to make sure that
- # action_executed is executed just once
- @active_battler.regular_turn_ended = false
- @turn_window.set_active_battler(@active_battler)
- @turn_window.set_battlers_queue(@battlers_queue)
- @min_time_interval =
- (@active_battler.next_action_time - $game_temp.battle_time) / 40.0
- if ATB_MODE or GRANDIA_MODE
- @atb_grandia_wait = true
- else
- $game_temp.battle_time = @active_battler.next_action_time
- @atb_grandia_wait = false
- end
- #########################
- # SUPPORT FOR ALTRUISMO #
- #########################
- @active_battler.reset_altruismo
- # @new_battle_turn is set by end_regular_turn
- # the battle turn must be updated at the beginning of a regular turn
- # this excludes not-playable reaction, auto-life, auto-phoenix, switching
- if @new_battle_turn
- $game_temp.battle_turn += 1
- @new_battle_turn = false
- # 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
- end
- end
- # Disable actor command window
- @actor_command_window.active = false
- @actor_command_window.visible = false
- @actor_command_bg.visible = false
- # Disable left actor command window
- @left_actor_command_window.active = false
- @left_actor_command_window.visible = false
- @battler_window.visible = false
- @escape_window.visible = false
- # Clear main phase flag
- $game_temp.battle_main_phase = false
- # DON'T Clear all party member actions because it would cancel guarding
- # and forced actions
- # Clear action if not guarding or forced action
- for actor in $game_party.actors
- if not (actor.current_action.kind == 0 and actor.current_action.basic == 1) and
- not actor.current_action.forcing
- actor.current_action.clear
- end
- end
- # If impossible to input command
- unless (@active_battler.inputable? or @active_battler.is_a? Game_Enemy or
- @auto_life)
- if not GRANDIA_MODE and not ATB_MODE
- # Start main phase
- $outfile.write "start_phase2: impossible to input command, start_phase4\n" if $outfile
- start_phase4
- end
- end
- # set @enemy turn and manage windows
- if @active_battler.is_a? Game_Enemy
- @enemy_turn = true
- @enemy_attacks_window.boss = @battlers_queue.first.index
- @enemy_attacks_window.refresh
- # show the turn window until the enemy begins the attack
- @turn_window.visible = TURNS_WINDOW_VISIBLE
- @turn_window.refresh(@battlers_queue)
- else
- @enemy_turn = false
- if not @auto_life
- @status_on_battle_window.actor = @active_battler
- @status_on_battle_window.refresh
- @status_on_battle_window.visible = $game_system.status_on_battle unless
- (($game_temp.reaction and not PLAYABLE_REACTION) or @atb_grandia_wait)
- end
- end
- if $game_temp.reaction
- $game_temp.reaction = false
- @reacting = true
- $outfile.write "start_phase2: @reacting = true\n" if $outfile
- if @active_battler.movable?
- @reaction_window.visible = REACTION_WINDOW_VISIBLE
- @wait_count = REACTION_WINDOW_DURATION
- begin
- Audio.se_play(REACTION_SE)
- rescue
- if REACTION_SE != ""
- p REACTION_SE + " not found."
- end
- end
- end
- elsif @auto_life
- $outfile.write "start_phase2: @using_auto_life = true\n" if $outfile
- @using_auto_life = true
- elsif @auto_phoenix
- @using_phoenix = true
- $outfile.write "start_phase2: @using_phoenix = true\n" if $outfile
- if @active_battler.movable?
- @auto_phoenix_window.visible = AUTO_PHOENIX_WINDOW_VISIBLE
- @wait_count = AUTO_PHOENIX_WINDOW_DURATION
- end
- end
- if @phase != 2
- $outfile.write "start_phase2 setup_battle_event, turn = " + $game_temp.battle_turn.to_s + "\n" if $outfile
- $outfile.write "@active_battler_copy = " + @active_battler_copy.to_s + "\n" if $outfile
- # Setup a battle event only if update_phase2 is going to be skipped
- setup_battle_event
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (party command phase)
- #--------------------------------------------------------------------------
- def update_phase2
- $outfile.write "update_phase2\n" if $outfile
- # This method has been totally redefined because the escape option
- # is available in the actor command window now
- # Goes directly to start_phase3
- @reaction_window.visible = false
- @auto_phoenix_window.visible = false
- if ATB_MODE and not (@reacting or @using_auto_life or @using_phoenix)
- $game_temp.battle_time = [@active_battler.next_action_time,
- $game_temp.battle_time + [10, @min_time_interval].max].min
- return unless $game_temp.battle_time == @active_battler.next_action_time
- $game_system.se_play($data_system.decision_se) unless @active_battler.is_a?(Game_Enemy)
- end
- if GRANDIA_MODE and not (@reacting or @using_auto_life or @using_phoenix)
- $game_temp.battle_time = [@active_battler.next_action_time,
- $game_temp.battle_time + [10, @min_time_interval].max].min
- @grandia_bar_window.update(@battlers_array)
- return unless $game_temp.battle_time == @active_battler.next_action_time
- $game_system.se_play($data_system.decision_se) unless @active_battler.is_a?(Game_Enemy)
- end
- # Setup battle event skipped in start_phase2
- setup_battle_event
- @atb_grandia_wait = false
- unless @enemy_turn
- @status_on_battle_window.visible = $game_system.status_on_battle unless
- ((@reacting and not PLAYABLE_REACTION))
- end
- start_phase3
- end
- #--------------------------------------------------------------------------
- # * Frame Update (party command phase: escape)
- #--------------------------------------------------------------------------
- def update_phase2_escape
- # Calculate enemy agility average
- enemies_agi = 0
- enemies_number = 0
- for enemy in $game_troop.enemies
- if enemy.exist?
- enemies_agi += enemy.agi
- enemies_number += 1
- end
- end
- if enemies_number > 0
- enemies_agi /= enemies_number
- end
- # Calculate actor agility average
- actors_agi = 0
- actors_number = 0
- for actor in $game_party.actors
- if actor.exist?
- actors_agi += actor.agi
- actors_number += 1
- end
- end
- if actors_number > 0
- actors_agi /= actors_number
- end
- # Determine if escape is successful
- success = rand(100) < 50 * actors_agi / enemies_agi
- # If escape is successful
- if success
- # Play escape SE
- $game_system.se_play($data_system.escape_se)
- # Return to BGM before battle started
- $game_system.bgm_play($game_temp.map_bgm)
- # Battle ends
- battle_end(1)
- # If escape is failure
- else
- # escape failed
- @escape_window.visible = true
- @wait_count = 45
- #$game_party.clear_actions
- #clear action if not guarding
- for actor in $game_party.actors
- if !(actor.current_action.kind == 0 and actor.current_action.basic == 1) and
- !actor.current_action.forcing
- actor.current_action.clear
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Start After Battle Phase
- #--------------------------------------------------------------------------
- def start_phase5
- $outfile.write "start_phase5\n" if $outfile
- # Shift to phase 5
- @phase = 5
- if $game_temp.map_bgm != nil
- # Play battle end ME
- $game_system.me_play($game_system.battle_end_me)
- # Return to BGM before battle started
- $game_system.bgm_play($game_temp.map_bgm)
- end
- # Initialize EXP, amount of gold, and treasure
- exp = 0
- gold = 0
- treasures = []
- # Loop
- for enemy in $game_troop.enemies
- # If enemy is not hidden
- unless enemy.hidden
- # Add EXP and amount of gold obtained
- exp += enemy.exp
- gold += enemy.gold
- if ENEMY_TREASURES[enemy.id]
- for treasure in ENEMY_TREASURES[enemy.id]
- if rand(100) < treasure[2]
- case treasure[0]
- when 0 # item
- treasures.push($data_items[treasure[1]])
- when 1 # weapon
- treasures.push($data_weapons[treasure[1]])
- when 2 # armor
- treasures.push($data_armors[treasure[1]])
- end
- end
- end
- else
- # Determine if treasure appears
- if rand(100) < enemy.treasure_prob
- if enemy.item_id > 0
- treasures.push($data_items[enemy.item_id])
- end
- if enemy.weapon_id > 0
- treasures.push($data_weapons[enemy.weapon_id])
- end
- if enemy.armor_id > 0
- treasures.push($data_armors[enemy.armor_id])
- end
- end
- end
- end
- end
- # Treasure is limited to a maximum of 6 items (NOT ANYMORE)
- # treasures = treasures[0..5]
- # Obtaining EXP
- for i in 0...$game_party.actors.size
- actor = $game_party.actors[i]
- # Store current stats for the report screen
- actor.old_exp = actor.exp
- actor.old_maxhp = actor.maxhp
- actor.old_maxsp = actor.maxsp
- actor.old_str = actor.str
- actor.old_int = actor.int
- actor.old_agi = actor.agi
- actor.old_dex = actor.dex
- if actor.cant_get_exp? == false
- last_level = actor.level
- actor.exp += exp
- if (actor.state?($expx2_state_id))
- actor.exp += exp
- end
- if actor.level > last_level
- @status_window.level_up(i)
- end
- end
- end
- # Obtaining gold
- $game_party.gain_gold(gold)
- for i in 0 ... $game_party.actors.size
- actor = $game_party.actors[i]
- if (actor.state?($goldx2_state_id))
- $game_party.gain_gold(gold)
- break
- end
- end
- # Obtaining treasure
- for item in treasures
- case item
- when RPG::Item
- $game_party.gain_item(item.id, 1)
- when RPG::Weapon
- $game_party.gain_weapon(item.id, 1)
- when RPG::Armor
- $game_party.gain_armor(item.id, 1)
- end
- end
- # Make battle result window
- @result_window = Window_BattleReport.new
- @result_window.active = true
- @result_window.index = 0
- @result_window2 = Window_BattleResult.new(exp, gold, treasures)
- # Set wait count
- @phase5_wait_count = 100
- @status_on_battle_window.visible = false
- @status_window.visible = STATUS_WINDOW_VISIBLE_DURING_REPORT
- @grandia_bar_window.visible = false if GRANDIA_MODE
- end
- #--------------------------------------------------------------------------
- # * Frame Update (after battle phase)
- #--------------------------------------------------------------------------
- def update_phase5
- $outfile.write "update_phase5\n" if $outfile
- # If wait count is larger than 0
- if @phase5_wait_count > 0
- # Decrease wait count
- @phase5_wait_count -= 1
- # If wait count reaches 0
- if @phase5_wait_count == 0
- # Clear main phase flag
- $game_temp.battle_main_phase = false
- # Refresh status window
- @status_window.refresh
- end
- return
- end
- # If C button was pressed
- if Input.trigger?(Input::C)
- battle_end(0)
- end
- end
- # Added to speed up annoying phase 5
- alias fast_update_phase5 update_phase5
- def update_phase5
- if @phase5_wait_count > 0
- @phase5_wait_count -= 1
- end
- fast_update_phase5
- end
- #--------------------------------------------------------------------------
- # * Start Actor Command Phase
- #--------------------------------------------------------------------------
- def start_phase3
- $outfile.write "*** start_phase3 ***\n" if $outfile
- # This method launches the input command phase,
- # by calling phase3_setup_command_window, in case the active battler is
- # an actor.
- # It decides the action in case the active battler is an enemy
- # Shift to phase 3
- @phase = 3
- #######################
- # UNPLAYABLE REACTION #
- #######################
- if @reacting and not PLAYABLE_REACTION
- # print("start_phase3 UNPLAYABLE REACTION set current action")
- if @active_battler.guarding? and GUARD_AFTER_REACTION
- @return_guarding = true
- end
- if @active_battler.current_action.forcing
- @active_battler_saved_forced_action =
- @active_battler.current_action.dup
- @return_to_forced_action = true
- end
- # test if a reaction skill is configured
- reaction_skill_id = REACTION_SKILLS[@active_battler.id]
- if reaction_skill_id != nil and @active_battler.skill_learn?(reaction_skill_id)
- @active_battler.current_action.kind = 1
- @active_battler.current_action.skill_id = reaction_skill_id
- else
- @active_battler.current_action.kind = 0
- @active_battler.current_action.basic = 0
- end
- phase3_next_actor
- return
- elsif @using_auto_life
- #######################
- # AUTO LIFE #
- #######################
- # print("start_phase3 AUTO LIFE")
- # Set action
- @item = $data_items[AUTO_LIFE_ITEM_ID]
- phase3_next_actor
- return
- elsif @using_phoenix
- #######################
- # AUTO PHOENIX #
- #######################
- # print("start_phase3 AUTO PHOENIX set current action")
- if @active_battler.guarding?
- @return_guarding = true
- end
- if @active_battler.current_action.forcing
- @active_battler_saved_forced_action =
- @active_battler.current_action.dup
- @return_to_forced_action = true
- end
- # Set action
- @active_battler.current_action.kind = 2
- @active_battler.current_action.item_id = PHOENIX_ITEM_ID
- @item = $data_items[PHOENIX_ITEM_ID]
- phase3_next_actor
- return
- end
- #######################
- # NORMAL TURN #
- #######################
- # set row positions in the battle status window for the actors
- i = 0
- for actor in $game_party.actors
- actor.battle_status_row_pos = i
- i += 1
- end
- # Stop blinking the active battler
- @active_battler.blink = false
- # launch the input command phase for the actor
- # actor case
- if @active_battler.is_a? Game_Actor
- # Forced actions support
- if @active_battler.current_action.forcing
- @active_battler.action_decided($game_temp.battle_time,
- @active_battler.current_action)
- phase3_next_actor
- # Casting delay support
- elsif @active_battler.cf_casting
- @active_battler.current_action = @active_battler.casting_action.dup
- $game_temp.selecting_all_allies =
- @active_battler.current_action.selecting_all_allies
- $game_temp.selecting_all_enemies =
- @active_battler.current_action.selecting_all_enemies
- if ($game_temp.selecting_all_allies or $game_temp.selecting_all_enemies)
- @single_all_scope = true
- end
- @active_battler.action_decided($game_temp.battle_time,
- @active_battler.current_action)
- @active_battler.cf_casting = false
- @active_battler.casting_action.clear
- @active_battler.after_cast = true
- phase3_next_actor
- else
- if @active_battler.inputable?
- @active_battler.blink = true
- # set the index of the highlighted row in the status window
- @status_window.index = @active_battler.battle_status_row_pos
- @status_window.refresh
- phase3_setup_command_window
- else
- phase3_next_actor
- end
- end
- end
- # if the active battler is an enemy, decide its action
- # enemy case
- if @active_battler.is_a? Game_Enemy
- # Forced actions support
- if !@active_battler.current_action.forcing
- # Casting delay support
- if @active_battler.cf_casting
- @active_battler.current_action = @active_battler.casting_action.dup
- @active_battler.action_decided($game_temp.battle_time, @active_battler.current_action)
- @active_battler.cf_casting = false
- @active_battler.casting_action.clear
- @active_battler.after_cast = true
- phase3_next_actor
- return
- else
- @active_battler.make_action
- end
- end
- @active_battler.action_decided($game_temp.battle_time, @active_battler.current_action)
- phase3_next_actor
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias single_all_start_phase3 start_phase3
- def start_phase3
- @single_all_scope = false
- $game_temp.selecting_all_enemies = false
- $game_temp.selecting_all_allies = false
- single_all_start_phase3
- end
- #--------------------------------------------------------------------------
- # * The action has been decided, ACTION!!!
- #--------------------------------------------------------------------------
- def phase3_next_actor
- unless (@reacting and !PLAYABLE_REACTION)
- if @active_battler.cf_casting
- @active_battler.casting_action = @active_battler.current_action.dup
- @active_battler.casting_action.selecting_all_allies =
- $game_temp.selecting_all_allies
- @active_battler.casting_action.selecting_all_enemies =
- $game_temp.selecting_all_enemies
- @active_battler.current_action.clear
- end
- end
- if @enemy_turn and @active_battler.current_action.valid?
- @enemy_attacks_window.visible = ENEMY_ATTACKS_WINDOW_VISIBLE
- @wait_count = ENEMY_ATTACKS_WINDOW_DURATION
- @status_on_battle_window.visible = false
- $outfile.write "@enemy_attacks_window.visible = ENEMY_ATTACKS_WINDOW_VISIBLE\n" if $outfile
- end
- phase3_next_actor_step2
- end
- #--------------------------------------------------------------------------
- # * The action has been decided, ACTION!!!
- #--------------------------------------------------------------------------
- def phase3_next_actor_step2
- start_phase4
- end
- #--------------------------------------------------------------------------
- # * Actor Command Window Setup
- #--------------------------------------------------------------------------
- def phase3_setup_command_window
- s1 = $data_system.words.attack
- s2 = $data_system.words.skill
- s3 = $data_system.words.guard
- s4 = $data_system.words.item
- @active_battler.refresh_commands
- if SWITCHING and
- ( ($charlie_fleed_summons==nil) or (($charlie_fleed_summons!=nil) and
- not $game_party.aeons_ids.include?(@active_battler.id)) ) and
- ( ($charlie_fleed_party_change==nil) or (($charlie_fleed_party_change!=nil) and
- not $game_party.fixed_actors.include?(@active_battler.id)) ) and
- ( ($charlie_fleed_summons==nil) or (($charlie_fleed_summons!=nil) and
- ($charlie_fleed_party_change!=nil) and
- not $game_party.fixed_actors.include?(@active_battler.original_form_id)) )
- if CANNOT_USE_ITEMS.include?(@active_battler.id)
- @individual_battle_commands=[s1]+["Switch"]+@active_battler.individual_commands
- else
- @individual_battle_commands=[s1]+["Switch"]+@active_battler.individual_commands+[s4]
- end
- else
- if CANNOT_USE_ITEMS.include?(@active_battler.id)
- @individual_battle_commands=[s1]+@active_battler.individual_commands
- else
- @individual_battle_commands=[s1]+@active_battler.individual_commands+[s4]
- end
- end
- phase3_setup_command_window2
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def phase3_setup_command_window2
- @actor_command_window.dispose
- @actor_command_window = Window_Command_Plus.new(ACTOR_COMMAND_WINDOW_WIDTH,
- 112, @individual_battle_commands, 20)
- @actor_command_window.custom_normal_color=ACTOR_COMMAND_WINDOW_TEXT_COLOR
- @actor_command_window.custom_normal_b_color=ACTOR_COMMAND_WINDOW_TEXT_BG_COLOR
- @actor_command_window.set_font_size(20+ACTOR_COMMAND_WINDOW_TEXT_SIZE_OFFSET)
- @actor_command_window.refresh
- if ($charlie_fleed_party_change==nil) or $game_party.backup_actors.empty?
- index = @individual_battle_commands.index("Switch")
- if index!=nil
- @actor_command_window.disable_item(index)
- end
- end
- @actor_command_window.x = ACTOR_COMMAND_WINDOW_X
- @actor_command_window.target_x = ACTOR_COMMAND_WINDOW_X
- @actor_command_window.y = 480
- @actor_command_window.target_y = 368
- @actor_command_window.z = 200
- @actor_command_window.back_opacity = 255
- begin
- if ACTOR_COMMAND_WINDOWSKIN_NAME != ""
- @actor_command_window.windowskin =
- RPG::Cache.windowskin(ACTOR_COMMAND_WINDOWSKIN_NAME)
- end
- rescue
- p ACTOR_COMMAND_WINDOWSKIN_NAME + " not found."
- end
- @actor_command_window.opacity = ACTOR_COMMAND_WINDOW_WINDOWSKIN_OPACITY
- @actor_command_window.active = true
- @actor_command_window.visible = true
- @battler_window.visible = true
- @battler_window.battler = @active_battler
- @battler_window.refresh
- @actor_command_window.index = (ACTOR_COMMAND_CURSOR_MEMORY)?(@active_battler.last_command):(0)
- @left_actor_command_window.index = (ACTOR_COMMAND_CURSOR_MEMORY)?(@active_battler.last_left_command):(0)
- if ACTOR_COMMAND_CURSOR_MEMORY
- #The queue must be updated in case the last selected command was not attack
- #Set the action first
- set_initial_action
- update_battlers_queue
- @turn_window.set_battlers_queue(@battlers_queue)
- end
- # show the turn window (shown in start phase 2 only when the enemy attacks)
- @turn_window.visible = TURNS_WINDOW_VISIBLE
- # set the proper animation phase for the turn window
- @turn_window.enter()
- @prev_actor_command = @actor_command_window.commands[@actor_command_window.index]
- if BATTLE_CRIES.keys.include?(@active_battler.id)
- # Determine how many cries
- size = BATTLE_CRIES[@active_battler.id].size
- cry = RPG::AudioFile.new(BATTLE_CRIES[@active_battler.id][rand(size)])
- $game_system.se_play(cry)
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (actor command phase)
- #--------------------------------------------------------------------------
- def update_phase3
- $outfile.write "update_phase3\n" if $outfile
- # If enemy arrow is enabled
- if @enemy_arrow != nil
- update_phase3_enemy_select
- elsif $game_temp.selecting_all_enemies
- update_phase3_all_enemies_select
- elsif $game_temp.selecting_all_allies
- update_phase3_all_allies_select
- # If actor arrow is enabled
- elsif @actor_arrow != nil
- update_phase3_actor_select
- # If skill window is enabled
- elsif @skill_window != nil
- update_phase3_skill_select
- elsif @switch_window != nil
- update_phase3_switch_select
- # If item window is enabled
- elsif @item_window != nil
- update_phase3_item_select
- # If actor command window is enabled
- elsif @actor_command_window.active
- update_phase3_basic_command
- # If left actor command window is enabled
- elsif @left_actor_command_window.active
- update_phase3_left_command
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (actor command phase : basic command)
- #--------------------------------------------------------------------------
- def update_phase3_basic_command
- # LEFT
- if Input.trigger?(Input::LEFT)
- $game_system.se_play($data_system.decision_se)
- @left_actor_command_window.visible=true
- @left_actor_command_window.active=true
- @actor_command_window.active=false
- @actor_command_window.visible=false
- return
- end
- # B: cancel
- if Input.trigger?(Input::B)
- # cannot turn back
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # C: selection
- if Input.trigger?(Input::C)
- case @actor_command_window.commands[@actor_command_window.index]
- # attack
- when $data_system.words.attack
- $game_system.se_play($data_system.decision_se)
- @active_battler.current_action.kind = 0
- @active_battler.current_action.basic = 0
- start_enemy_select
- # item
- when $data_system.words.item
- $game_system.se_play($data_system.decision_se)
- @active_battler.current_action.kind = 2
- start_item_select
- when "Switch"
- if ($charlie_fleed_party_change==nil) or
- $game_party.backup_actors.empty?
- $game_system.se_play($data_system.buzzer_se)
- return
- else
- $game_system.se_play($data_system.decision_se)
- @active_battler.current_action.kind = 1
- start_switch_select
- end
- end
- # Retire
- if $charlie_fleed_summons != nil and
- @actor_command_window.commands[@actor_command_window.index]==RETIRE_NAME
- $game_system.se_play($data_system.decision_se)
- @active_battler.current_action.kind = 1
- @active_battler.current_action.skill_id = $retire_skill_id
- @retire_common_event=true
- phase3_next_actor
- return
- end
- ### SUPPORT FOR INDIVIDUAL BATTLE COMMANDS ###
- if @active_battler.individual_commands.
- include?(@actor_command_window.commands[@actor_command_window.index])
- $game_system.se_play($data_system.decision_se)
- @active_battler.current_action.kind = 1
- @individual_battle_commands_skill_category = @actor_command_window.commands[@actor_command_window.index]
- start_skill_select
- end
- # The action has been decided
- @active_battler.action_decided($game_temp.battle_time, @active_battler.current_action)
- return
- end
- # An action has not been decided
- # update the battle_turn window if the selection has changed
- if (@actor_command_window.commands[@actor_command_window.index] != @prev_actor_command)
- case @actor_command_window.commands[@actor_command_window.index]
- # attack
- when $data_system.words.attack
- @active_battler.current_action.kind = 0
- @active_battler.current_action.basic = 0
- # item
- when $data_system.words.item
- @active_battler.current_action.kind = 2
- end
- ### SUPPORT FOR INDIVIDUAL BATTLE COMMANDS ###
- if @active_battler.individual_commands.
- include?(@actor_command_window.commands[@actor_command_window.index]) and
- ($charlie_fleed_summons != nil and RETIRE_NAME != @actor_command_window.commands[@actor_command_window.index])
- @active_battler.current_action.kind = 1
- end
- # A different action has been selected
- @active_battler.action_selected(@active_battler.current_action)
- @active_battler.last_command = @actor_command_window.index
- # Update the queue and the turn window
- update_battlers_queue
- @turn_window.set_new_battlers_and_animate(@battlers_queue)
- # Memorize the current selection
- @prev_actor_command = @actor_command_window.commands[@actor_command_window.index]
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (actor command phase : left command)
- #--------------------------------------------------------------------------
- # seconda versione: individua il comando dalla stringa
- # kind -1 is used for skip
- # kind -2 is used for escape
- def update_phase3_left_command
- # RIGHT: cancel
- if Input.trigger?(Input::RIGHT)
- $game_system.se_play($data_system.decision_se)
- @left_actor_command_window.visible=false
- @left_actor_command_window.active=false
- @actor_command_window.active=true
- @actor_command_window.visible=true
- return
- end
- # B: cancel
- if Input.trigger?(Input::B)
- # cannot turn back
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # C: selection
- if Input.trigger?(Input::C)
- case @left_actor_command_window.commands[@left_actor_command_window.index]
- when $data_system.words.guard
- $game_system.se_play($data_system.decision_se)
- @active_battler.current_action.kind = 0
- @active_battler.current_action.basic = 1
- phase3_next_actor
- # skip
- when "Skip"
- $game_system.se_play($data_system.decision_se)
- @active_battler.current_action.kind = -1
- phase3_next_actor
- # escape
- when "Escape"
- if $game_temp.battle_can_escape == false
- # SE
- $game_system.se_play($data_system.buzzer_se)
- return
- else
- # SE
- $game_system.se_play($data_system.decision_se)
- escape_action = Game_BattleAction.new
- escape_action.kind =- 2
- @active_battler.action_decided($game_temp.battle_time,escape_action)
- update_phase2_escape
- end
- phase3_next_actor
- # status
- when "Status"
- $game_system.se_play($data_system.decision_se)
- @status_on_battle_window.actor = @active_battler
- @status_on_battle_window.refresh
- @status_on_battle_window.visible =! @status_on_battle_window.visible
- $game_system.status_on_battle = @status_on_battle_window.visible
- return
- end
- # The action has been decided
- @active_battler.action_decided($game_temp.battle_time, @active_battler.current_action)
- return
- end
- # An action has not been decided
- # update the battle_turn window if the selection has changed
- if (@left_actor_command_window.commands[@left_actor_command_window.index] != @prev_actor_command)
- case @left_actor_command_window.commands[@left_actor_command_window.index]
- # defend
- when $data_system.words.guard
- @active_battler.current_action.kind = 0
- @active_battler.current_action.basic = 1
- # skip
- when "Skip"
- @active_battler.current_action.kind = -1
- # escape
- when "Escape"
- @active_battler.current_action.kind = -2
- end
- # A different action has been selected
- @active_battler.action_selected(@active_battler.current_action)
- @active_battler.last_left_command = @left_actor_command_window.index
- # Update the queue and the turn window
- update_battlers_queue
- @turn_window.set_new_battlers_and_animate(@battlers_queue)
- # Memorize the current selection
- @prev_actor_command = @left_actor_command_window.commands[@left_actor_command_window.index]
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (actor command phase : skill selection)
- #--------------------------------------------------------------------------
- def update_phase3_skill_select
- # Make skill window visible
- @skill_window.visible = true
- # Update skill window
- @skill_window.update
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # Reset @active_battler.current_action.skill_id
- @active_battler.current_action.skill_id = 0
- # Update selected action
- @active_battler.action_selected(@active_battler.current_action)
- # Update the queue and the turn window
- update_battlers_queue
- @turn_window.set_new_battlers_and_animate(@battlers_queue)
- # End skill selection
- end_skill_select
- return
- end
- # Get currently selected data on the skill window
- @skill = @skill_window.skill
- # Update current action and call action_selected
- if @active_battler.current_action.skill_id != @skill.id
- # Set current_action.skill_id
- @active_battler.current_action.skill_id = @skill.id
- # Update selected action
- @active_battler.action_selected(@active_battler.current_action)
- # Update the queue and the turn window
- update_battlers_queue
- @turn_window.set_new_battlers_and_animate(@battlers_queue)
- end
- # If C button was pressed
- if Input.trigger?(Input::C)
- # Get currently selected data on the skill window
- @skill = @skill_window.skill
- # If it can't be used
- if @skill == nil or not @active_battler.skill_can_use?(@skill.id)
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Set action
- @active_battler.current_action.skill_id = @skill.id
- @active_battler.action_decided($game_temp.battle_time,
- @active_battler.current_action)
- # Make skill window invisible
- @skill_window.visible = false
- # determine if the skill can have special targets
- @any_scope = false
- @single_all_scope = false
- @random_single_target = false
- # scope is single or all enemies
- if @skill.is_random_single_target()
- @random_single_target = true
- # End skill selection
- end_skill_select
- # Charlie: action!!!
- phase3_next_actor
- elsif @skill.is_single_all()
- @single_all_scope = true
- # If effect scope is single enemy
- if @skill.scope == 1
- start_enemy_select
- elsif @skill.scope == 3 or @skill.scope == 5
- start_actor_select
- end
- # scope is single enemy or single ally
- elsif @skill.is_any_scope()
- @any_scope = true
- start_actor_select
- # If effect scope is single enemy
- elsif @skill.scope == 1
- # Start enemy selection
- start_enemy_select
- # If effect scope is single ally
- elsif @skill.scope == 3 or @skill.scope == 5
- # Start actor selection
- start_actor_select
- # If effect scope is not single
- else
- # End skill selection
- end_skill_select
- # Charlie: action!!!
- phase3_next_actor
- end
- return
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (actor command phase : switch selection)
- #--------------------------------------------------------------------------
- def update_phase3_switch_select
- # Make switch window visible
- @switch_window.visible = true
- @switch_window_help.visible = true
- # Update switch window
- @switch_window.update
- @switch_window_help.set_switch(@switch_window.switch)
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # End switch selection
- end_switch_select
- return
- end
- # If C button was pressed
- if Input.trigger?(Input::C)
- # Get currently selected data on the switch window
- switch = @switch_window.switch
- # If it can't be used
- if switch == nil or switch.hp==0
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- @switch_id=switch.id
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Set action
- @active_battler.current_action.skill_id = $switch_skill_id
- @switch_common_event=true
- # Make switch window invisible
- @switch_window.visible = false
- @switch_window_help.visible = false
- end_switch_select
- # Charlie: action!!!
- phase3_next_actor
- return
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (actor command phase : item selection)
- #--------------------------------------------------------------------------
- def update_phase3_item_select
- # Make item window visible
- @item_window.visible = true
- # Update item window
- @item_window.update
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # End item selection
- end_item_select
- return
- end
- # If C button was pressed
- if Input.trigger?(Input::C)
- # Get currently selected data on the item window
- @item = @item_window.item
- # If it can't be used
- unless $game_party.item_can_use?(@item.id)
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Set action
- @active_battler.current_action.item_id = @item.id
- # Make item window invisible
- @item_window.visible = false
- # If effect scope is single enemy
- if @item.scope == 1
- # Start enemy selection
- start_enemy_select
- # If effect scope is single ally
- elsif @item.scope == 3 or @item.scope == 5
- # Start actor selection
- start_actor_select
- # If effect scope is not single
- else
- # End item selection
- end_item_select
- # Charlie: ACTION!!!
- phase3_next_actor
- end
- return
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (actor command phase : enemy selection)
- #--------------------------------------------------------------------------
- def update_phase3_enemy_select
- if @any_scope == true
- if Input.trigger?(Input::RIGHT)
- end_enemy_select
- start_actor_select
- return
- end
- end
- if @single_all_scope == true
- if Input.trigger?(Input::SHIFT)
- end_enemy_select
- start_all_enemies_select
- return
- end
- end
- # Update targeted
- for i in 0 ... $game_troop.enemies.size
- $game_troop.enemies[i].targeted = (i == @enemy_arrow.index) ? true : false
- end
- @turn_window.update_indicators
- @grandia_bar_window.update(@battlers_array) if GRANDIA_MODE
- # Update enemy arrow
- @enemy_arrow.update
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # End enemy selection
- end_enemy_select
- @any_scope = false
- @single_all_scope = false
- return
- end
- # If C button was pressed
- if Input.trigger?(Input::C)
- # Support for flying enemies
- if @active_battler.current_action.kind == 0 and
- @active_battler.current_action.basic == 0
- if FLYING_ENEMIES.include?($game_troop.enemies[@enemy_arrow.index].id)
- unless (MNK_STATIONARY_WEAPONS.include?(@active_battler.weapon_id) or
- FLYING_ACTORS.include?(@active_battler.id)) or
- @active_battler.states.include?($flight_state_id)
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- end
- end
- if @active_battler.current_action.kind == 1
- if FLYING_ENEMIES.include?($game_troop.enemies[@enemy_arrow.index].id) and
- MNK_MOVING_SKILL.include?(@active_battler.current_action.skill_id)
- unless FLYING_ACTORS.include?(@active_battler.id)
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- end
- end
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Set action
- @active_battler.current_action.target_index = @enemy_arrow.index
- # End enemy selection
- end_enemy_select
- # If skill window is showing
- if @skill_window != nil
- # End skill selection
- end_skill_select
- end
- # If item window is showing
- if @item_window != nil
- # End item selection
- end_item_select
- end
- # Charlie: ACTION!!!
- phase3_next_actor
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (actor command phase : all enemy selection)
- #--------------------------------------------------------------------------
- def update_phase3_all_enemies_select
- # Update targeted
- for i in 0...$game_troop.enemies.size
- $game_troop.enemies[i].targeted=true
- end
- @turn_window.update_indicators
- @grandia_bar_window.update(@battlers_array) if GRANDIA_MODE
- if Input.trigger?(Input::SHIFT)
- end_all_enemies_select
- start_enemy_select
- return
- end
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # End enemy selection
- end_all_enemies_select
- @single_all_scope = false
- return
- end
- if Input.trigger?(Input::C)
- $game_system.se_play($data_system.decision_se)
- end_all_enemies_select
- # override instruction inside end_all_enemies_select
- $game_temp.selecting_all_enemies=true
- if @skill_window != nil
- end_skill_select
- end
- if @item_window != nil
- end_item_select
- end
- phase3_next_actor
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (actor command phase : actor selection)
- #--------------------------------------------------------------------------
- def update_phase3_actor_select
- if @any_scope == true
- if Input.trigger?(Input::LEFT)
- end_actor_select
- start_enemy_select
- return
- end
- end
- if @single_all_scope == true
- if Input.trigger?(Input::SHIFT)
- end_actor_select
- start_all_allies_select
- return
- end
- end
- # Update actor arrow
- @actor_arrow.update
- # Update targeted
- for i in 0 ... $game_party.actors.size
- $game_party.actors[i].targeted = (i == @actor_arrow.index) ? true : false
- end
- @turn_window.update_indicators
- @grandia_bar_window.update(@battlers_array) if GRANDIA_MODE
- @actor_select_window.index = @actor_arrow.get_index
- if @actor_arrow.get_index < 0
- @actor_select_window.set_index($game_party.actors.size - 1)
- end
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # End actor selection
- end_actor_select
- @any_scope = false
- return
- end
- update_phase3_actor_select2
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_phase3_actor_select2
- # If C button was pressed
- if Input.trigger?(Input::C)
- # Buzz if an item cannot be used
- if @active_battler.current_action.kind == 2
- item = $data_items[@active_battler.current_action.item_id]
- if ((item.scope == 3) and $game_party.actors[@actor_arrow.index].hp == 0) or
- ((item.scope == 5) and $game_party.actors[@actor_arrow.index].hp >= 1)
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- end
- # Buzz if a skill cannot be used
- if @active_battler.current_action.kind == 1
- skill = $data_skills[@active_battler.current_action.skill_id]
- if ((skill.scope == 3) and $game_party.actors[@actor_arrow.index].hp == 0) or
- ((skill.scope == 5) and $game_party.actors[@actor_arrow.index].hp >= 1)
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- # Support for Trincea and Altruismo
- if (skill.id == $altruismo_skill_id or
- skill.id == $trincea_skill_id) and
- @active_battler==$game_party.actors[@actor_arrow.index]
- # Play buzzer SE
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- end
- # Play decision SE
- $game_system.se_play($data_system.decision_se)
- # Set action
- @active_battler.current_action.target_index = @actor_arrow.index
- # End actor selection
- end_actor_select
- # If skill window is showing
- if @skill_window != nil
- # End skill selection
- end_skill_select
- end
- # If item window is showing
- if @item_window != nil
- # End item selection
- end_item_select
- end
- # Charlie: ACTION!!!
- phase3_next_actor
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (actor command phase : all allies selection)
- #--------------------------------------------------------------------------
- def update_phase3_all_allies_select
- # Update targeted
- for i in 0...$game_party.actors.size
- $game_party.actors[i].targeted=true
- end
- @turn_window.update_indicators
- @grandia_bar_window.update(@battlers_array) if GRANDIA_MODE
- if Input.trigger?(Input::SHIFT)
- end_all_allies_select
- start_actor_select
- return
- end
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # End enemy selection
- end_all_allies_select
- @single_all_scope = false
- return
- end
- if Input.trigger?(Input::C)
- $game_system.se_play($data_system.decision_se)
- end_all_allies_select
- # override instruction inside end_all_allies_select
- $game_temp.selecting_all_allies = true
- if @skill_window != nil
- end_skill_select
- end
- if @item_window != nil
- end_item_select
- end
- phase3_next_actor
- end
- end
- #--------------------------------------------------------------------------
- # * Start Enemy Selection
- #--------------------------------------------------------------------------
- def start_enemy_select
- $game_temp.selecting_all_enemies=false
- @selecting_ally=false
- # Make enemy arrow
- @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport1)
- # Associate help window
- @enemy_arrow.help_window = @help_window
- # Disable actor command window
- @actor_command_window.active = false
- # Charlie: don't want the commands to disappear
- end
- #--------------------------------------------------------------------------
- # * Start All Enemy Selection
- #--------------------------------------------------------------------------
- def start_all_enemies_select
- @help_window.set_text("Attacking all enemies", 1)
- @all_enemies_window.visible=true
- @selecting_ally=false
- $game_temp.selecting_all_enemies=true
- @actor_command_window.active = false
- end
- #--------------------------------------------------------------------------
- # * End All Enemy Selection
- #--------------------------------------------------------------------------
- def end_all_enemies_select
- # Update targeted
- for i in 0...$game_troop.enemies.size
- $game_troop.enemies[i].targeted=false
- end
- @turn_window.update_indicators
- @grandia_bar_window.update(@battlers_array) if GRANDIA_MODE
- $game_temp.selecting_all_enemies=false
- @all_enemies_window.visible=false
- @status_window.visible = true
- # If command is [fight]
- if @actor_command_window.index == 0
- @actor_command_window.active = true
- @actor_command_window.visible = true
- @battler_window.visible = true
- @help_window.visible = false
- end
- end
- #--------------------------------------------------------------------------
- # * End Enemy Selection
- #--------------------------------------------------------------------------
- def end_enemy_select
- @status_window.visible = true
- @enemy_arrow.dispose
- @enemy_arrow = nil
- # If command is [fight]
- if @actor_command_window.index == 0
- @actor_command_window.active = true
- @actor_command_window.visible = true
- @battler_window.visible = true
- @help_window.visible = false
- end
- # Update targeted
- for i in 0...$game_troop.enemies.size
- $game_troop.enemies[i].targeted=false
- end
- @turn_window.update_indicators
- @grandia_bar_window.update(@battlers_array) if GRANDIA_MODE
- 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
- # Disable actor command window
- @actor_command_window.active = false
- @selecting_ally = true
- $game_temp.selecting_all_allies = false
- @actor_select_window.visible = true
- @actor_select_window.active = true
- @actor_select_window.set_index(@actor_index)
- end
- #--------------------------------------------------------------------------
- # * Start All Actors Selection
- #--------------------------------------------------------------------------
- def start_all_allies_select
- @help_window.set_text("All allies", 1)
- @all_allies_window.visible=true
- @selecting_ally=true
- $game_temp.selecting_all_allies = true
- @actor_command_window.active = false
- @actor_select_window.visible = false
- @actor_select_window.active = false
- end
- #--------------------------------------------------------------------------
- # * End All Actors Selection
- #--------------------------------------------------------------------------
- def end_all_allies_select
- # Update targeted
- for i in 0...$game_party.actors.size
- $game_party.actors[i].targeted=false
- end
- @turn_window.update_indicators
- @grandia_bar_window.update(@battlers_array) if GRANDIA_MODE
- $game_temp.selecting_all_allies = false
- @all_allies_window.visible = false
- @status_window.visible = true
- @actor_select_window.visible = false
- end
- #--------------------------------------------------------------------------
- # * End Actor Selection
- #--------------------------------------------------------------------------
- def end_actor_select
- # Dispose of actor arrow
- @actor_arrow.dispose
- @actor_arrow = nil
- @actor_select_window.visible = false
- # Update targeted
- for i in 0...$game_party.actors.size
- $game_party.actors[i].targeted=false
- end
- @turn_window.update_indicators
- @grandia_bar_window.update(@battlers_array) if GRANDIA_MODE
- end
- #--------------------------------------------------------------------------
- # * Start Skill Selection
- #--------------------------------------------------------------------------
- def start_skill_select
- # Make skill window
- @skill_window = Window_BattleSkill.new(@active_battler, @individual_battle_commands_skill_category)
- # Associate help window
- @skill_window.help_window = @help_window
- # Disable actor command window
- @actor_command_window.active = false
- # Charlie: don't want the commands to disappear
- end
- #--------------------------------------------------------------------------
- # * Start Switch Selection
- #--------------------------------------------------------------------------
- def start_switch_select
- # Make switch windows
- @switch_window = Window_Switch.new()
- @switch_window_help = Window_Switch_Help.new
- # Disable actor command window
- @actor_command_window.active = false
- end
- #--------------------------------------------------------------------------
- # * End Skill Selection
- #--------------------------------------------------------------------------
- def end_skill_select
- @battler_window.visible = true
- # Dispose of skill window
- @skill_window.dispose
- @skill_window = nil
- # Hide help window
- @help_window.visible = false
- # Enable actor command window
- @actor_command_window.active = true
- @actor_command_window.visible = true
- end
- #--------------------------------------------------------------------------
- # * End Switch Selection
- #--------------------------------------------------------------------------
- def end_switch_select
- @battler_window.visible = true
- # Dispose of switch window
- @switch_window.dispose
- @switch_window_help.dispose
- @switch_window = nil
- # Hide help window
- @help_window.visible = false
- # Enable actor command window
- @actor_command_window.active = true
- @actor_command_window.visible = true
- end
- #--------------------------------------------------------------------------
- # * Start Item Selection
- #--------------------------------------------------------------------------
- def start_item_select
- # Make item window
- @item_window = Window_BattleItem.new
- # Associate help window
- @item_window.help_window = @help_window
- # Disable actor command window
- @actor_command_window.active = false
- @actor_command_window.visible = true
- 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
- # Enable actor command window
- @actor_command_window.active = true
- @actor_command_window.visible = true
- @battler_window.visible = true
- end
- #--------------------------------------------------------------------------
- # * Start Main Phase
- #--------------------------------------------------------------------------
- def start_phase4
- $outfile.write "*** start_phase4 ***\n" if $outfile
- # Shift to phase 4
- @phase = 4
- #######################
- # UNPLAYABLE REACTION #
- #######################
- if @reacting and !PLAYABLE_REACTION
- # print("start_phase4 UNPLAYABLE REACTION go to step 1")
- $game_temp.battle_main_phase = true
- @phase4_step = 1
- return
- elsif @using_auto_life
- #######################
- # AUTO LIFE #
- #######################
- # print("start_phase4 AUTO LIFE go to step 1")
- $game_temp.battle_main_phase = true
- @phase4_step = 1
- return
- elsif @using_phoenix
- #######################
- # AUTO PHOENIX #
- #######################
- # print("start_phase4 AUTO PHOENIX go to step 1")
- $game_temp.battle_main_phase = true
- @phase4_step = 1
- return
- end
- # Turn count- and Clear action completed flags-
- # controls put in end regular turn
- # Disable actor command window
- @actor_command_window.active = false
- @actor_command_window.visible = false
- @actor_command_bg.visible=false
- @left_actor_command_window.active = false
- @left_actor_command_window.visible = false
- @battler_window.visible = false
- # Make the turn window disappear
- @turn_window.visible=false unless @active_battler.is_a?(Game_Enemy)
- if @active_battler != nil
- @active_battler.blink = false
- end
- # Set main phase flag
- $game_temp.battle_main_phase = true
- # Shift to step 1
- @phase4_step = 1
- end
- #--------------------------------------------------------------------------
- # * Make Action Orders ELIMINATO
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- # * Frame Update (main phase)
- #--------------------------------------------------------------------------
- def update_phase4
- $outfile.write "update_phase4\n" if $outfile
- case @phase4_step
- when 1
- # print("step1")
- update_phase4_step1
- when 2
- # print("step2")
- update_phase4_step2
- when 3
- # print("step3")
- update_phase4_step3
- when 3.1
- # print("step3.1")
- update_phase4_step3_1
- when 4
- # print("step4")
- update_phase4_step4
- when 5
- # print("step5")
- update_phase4_step5
- when 5.1
- # print("step5.1")
- update_phase4_step5_1
- when 6
- # print("step6")
- update_phase4_step6
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (main phase step 1 : action preparation)
- #--------------------------------------------------------------------------
- def update_phase4_step1
- $outfile.write "update_phase4_step1\n" if $outfile
- # Hide help window
- @help_window.visible = false
- # Hide turn window
- @turn_window.visible = false
- # Hide enemy attacks window
- @enemy_attacks_window.visible = false
- # Determine win/loss
- if judge
- # If won, or if lost : end method
- $outfile.write "update_phase4_step1 judge\n" if $outfile
- return
- end
- # If an action forcing battler doesn't exist
- if $game_temp.forcing_battler == nil
- # Set up battle event
- # print "update_phase4_step1 setup_battle_event"
- setup_battle_event
- # If battle event is running
- if $game_system.battle_interpreter.running?
- return
- end
- end
- # Charlie: @action_battlers is no longer used
- if @end_turn == true
- start_phase2
- return
- end
- # Initialize animation ID and common event ID
- @animation1_id = 0
- @animation2_id = 0
- @common_event_id = 0
- #######################
- # UNPLAYABLE REACTION #
- #######################
- if @reacting and !PLAYABLE_REACTION
- # print("update_phase4_step1 UNPLAYABLE REACTION go to step 2")
- # skip slip damage and rigene effect
- @phase4_step = 2
- return
- elsif @using_auto_life
- #######################
- # AUTO LIFE #
- #######################
- # print("update_phase4_step1 AUTO LIFE go to step 2")
- # skip slip damage and rigene effect
- @phase4_step = 2
- return
- elsif @using_phoenix
- #######################
- # AUTO PHOENIX #
- #######################
- # print("update_phase4_step1 AUTO PHOENIX go to step 2")
- # skip slip damage and rigene effect
- @phase4_step = 2
- return
- end
- # If not switching
- unless (@active_battler.current_action.kind == 1 and
- @active_battler.current_action.skill_id == $switch_skill_id)
- # Slip damage moved at the end of the turn
- # Natural removal of states moved at the end of the turn
- end
- # Refresh status window
- @status_window.refresh
- # Shift to step 2
- @phase4_step = 2
- end
- #--------------------------------------------------------------------------
- # * Frame Update (main phase step 2 : start action)
- #--------------------------------------------------------------------------
- def update_phase4_step2
- # print ("update_phase4_step2")
- # AUTO LIFE
- if @using_auto_life
- @end_turn = true
- # Clear target battlers
- @target_battlers = []
- make_item_action_result
- # print("stop auto_life")
- @using_auto_life=false
- @phase4_step = 4 # skip user animation
- return
- end
- # If not a forcing action
- unless @active_battler.current_action.forcing
- # If restriction is [normal attack enemy] or [normal attack ally]
- if @active_battler.restriction == 2 or @active_battler.restriction == 3
- # Set attack as an action
- @active_battler.current_action.kind = 0
- @active_battler.current_action.basic = 0
- end
- # If restriction is [cannot perform action]
- if @active_battler.restriction == 4
- $outfile.write "update_phase4_step2: [cannot perform action] go to step 1\n" if $outfile
- # Clear battler being forced into action
- $game_temp.forcing_battler = nil unless $game_temp.forcing_battler != @active_battler
- # Shift to step 1
- @phase4_step = 1
- if !(@reacting or @using_phoenix)
- end_regular_turn
- else
- #############################
- # REACTION AND AUTO-PHOENIX #
- #############################
- if @return_guarding
- @active_battler.current_action.kind = 0
- @active_battler.current_action.basic = 1
- end
- if @return_to_forced_action
- @active_battler.current_action =
- @active_battler_saved_forced_action.dup
- end
- @end_turn = true
- $outfile.write "update_phase4_step2: restriction -> cancel reaction and auto-phoenix\n" if $outfile
- @reacting = false
- @using_phoenix = false
- end
- return
- end
- end
- # Clear target battlers
- @target_battlers = []
- # Branch according to each action
- case @active_battler.current_action.kind
- when 0 # basic
- make_basic_action_result
- when 1 # skill
- make_skill_action_result
- when 2 # item
- make_item_action_result
- end
- # Shift to step 3
- if @phase4_step == 2
- @phase4_step = 3
- end
- end
- #--------------------------------------------------------------------------
- # * Make Basic Action Results
- #--------------------------------------------------------------------------
- def make_basic_action_result
- $outfile.write "make_basic_action_result\n" if $outfile
- #######################
- # UNPLAYABLE REACTION #
- #######################
- if @reacting and !PLAYABLE_REACTION
- # print("make_basic_action_result UNPLAYABLE REACTION")
- @animation1_id = @active_battler.animation1_id
- @animation2_id = @active_battler.animation2_id
- # Apply normal attack results
- @target_battlers = [@target_of_reaction]
- for target in @target_battlers
- target.attack_effect(@active_battler)
- # No reactions to reactions
- if @reacting
- $game_temp.reaction = false
- end
- end
- return
- elsif @using_phoenix
- #######################
- # AUTO PHOENIX #
- #######################
- # print("make_basic_action_result AUTO PHOENIX")
- @animation1_id = @active_battler.animation1_id
- @animation2_id = @active_battler.animation2_id
- # Apply normal attack results
- @target_battlers = [@phoenix_targets.pop]
- for target in @target_battlers
- target.item_effect(@item)
- end
- return
- end
- # If attack
- if @active_battler.current_action.basic == 0
- # print("attack")
- # Set anaimation ID
- @animation1_id = @active_battler.animation1_id
- @animation2_id = @active_battler.animation2_id
- # If action battler is enemy
- if @active_battler.is_a?(Game_Enemy)
- if @active_battler.restriction == 3
- target = $game_troop.random_target_enemy
- elsif @active_battler.restriction == 2
- target = $game_party.random_target_actor
- else
- index = @active_battler.current_action.target_index
- target = $game_party.smooth_target_actor(index)
- end
- end
- # If action battler is actor
- if @active_battler.is_a?(Game_Actor)
- if @active_battler.restriction == 3
- target = $game_party.random_target_actor
- elsif @active_battler.restriction == 2
- target = $game_troop.random_target_enemy
- else
- index = @active_battler.current_action.target_index
- target = $game_troop.smooth_target_enemy(index)
- end
- end
- #########################
- # SUPPORT FOR ALTRUISMO #
- #########################
- if target!=nil
- if target.defender_char!=nil and
- ($game_party.actors.include?(target.defender_char) or
- $game_troop.enemies.include?(target.defender_char)) and
- target.defender_char.exist? and target.defender_char.movable?
- # print(target.name+ " is defended by "+target.defender_char.name)
- target=target.defender_char
- target.show_defending_position=true
- end
- end
- # Set array of targeted battlers
- @target_battlers = [target]
- # Apply normal attack results
- for target in @target_battlers
- target.attack_effect(@active_battler)
- if PLAYABLE_REACTION
- # can react only if not dead
- if $game_temp.reaction and !target.dead?
- @reaction_window.actor = target
- @reaction_window.refresh
- else
- $game_temp.reaction=false
- end
- else # NOT PLAYABLE REACTION
- # can react only if not dead and the attacker is not dead
- if $game_temp.reaction and !target.dead? and !@active_battler.dead?
- @reaction_window.actor = target
- @reaction_window.refresh
- @target_of_reaction = @active_battler
- @reacting_battler = target
- else
- $game_temp.reaction = false
- end
- end
- end
- return
- end
- # If guard
- if @active_battler.current_action.basic == 1
- # print("guard")
- # Display "Guard" in help window
- @help_window.set_text($data_system.words.guard, 1)
- return
- end
- # If escape
- if @active_battler.is_a?(Game_Enemy) and
- @active_battler.current_action.basic == 2
- # print("escape enemy")
- # Display "Escape" in help window
- @help_window.set_text("Escape", 1)
- # Escape
- @active_battler.escape
- return
- end
- # If doing nothing
- if @active_battler.current_action.basic == 3
- # print("doing nothing")
- # Clear battler being forced into action
- $game_temp.forcing_battler = nil unless $game_temp.forcing_battler != @active_battler
- # Shift to step 1
- @phase4_step = 1
- end_regular_turn
- return
- end
- end
- #--------------------------------------------------------------------------
- # * Set Targeted Battler for Skill or Item
- # scope : effect scope for skill or item
- #--------------------------------------------------------------------------
- def set_target_battlers(scope)
- # If battler performing action is enemy
- if @active_battler.is_a?(Game_Enemy)
- # Branch by effect scope
- case scope
- when 1 # single enemy
- index = @active_battler.current_action.target_index
- @target_battlers.push($game_party.smooth_target_actor(index))
- when 2 # all enemies
- for actor in $game_party.actors
- if actor.exist?
- @target_battlers.push(actor)
- end
- end
- when 3 # single ally
- index = @active_battler.current_action.target_index
- @target_battlers.push($game_troop.smooth_target_enemy(index))
- when 4 # all allies
- for enemy in $game_troop.enemies
- if enemy.exist?
- @target_battlers.push(enemy)
- end
- end
- when 5 # single ally (HP 0)
- index = @active_battler.current_action.target_index
- enemy = $game_troop.enemies[index]
- if enemy != nil and enemy.hp0?
- @target_battlers.push(enemy)
- end
- when 6 # all allies (HP 0)
- for enemy in $game_troop.enemies
- if enemy != nil and enemy.hp0?
- @target_battlers.push(enemy)
- end
- end
- when 7 # user
- @target_battlers.push(@active_battler)
- end
- end
- # If battler performing action is actor
- if @active_battler.is_a?(Game_Actor)
- #######################
- # UNPLAYABLE REACTION #
- #######################
- if @reacting
- # print ("not-playable reaction - setting target")
- @target_battlers = [@target_of_reaction]
- return
- end
- # support for random single target
- if @random_single_target
- @target_battlers.push($game_troop.random_target_enemy)
- @random_single_target = false
- return
- end
- # support for any scope
- if @any_scope == true
- if (@selecting_ally)
- index = @active_battler.current_action.target_index
- @target_battlers.push($game_party.smooth_target_actor(index))
- else
- index = @active_battler.current_action.target_index
- @target_battlers.push($game_troop.smooth_target_enemy(index))
- end
- @any_scope = false
- return
- end
- if @single_all_scope == true
- if ($game_temp.selecting_all_enemies)
- for enemy in $game_troop.enemies
- if enemy.exist?
- @target_battlers.push(enemy)
- end
- end
- return
- end
- if ($game_temp.selecting_all_allies)
- for actor in $game_party.actors
- if actor.exist?
- @target_battlers.push(actor)
- end
- end
- return
- end
- end
- # Branch by effect scope
- case scope
- when 1 # single enemy
- index = @active_battler.current_action.target_index
- @target_battlers.push($game_troop.smooth_target_enemy(index))
- when 2 # all enemies
- for enemy in $game_troop.enemies
- if enemy.exist?
- @target_battlers.push(enemy)
- end
- end
- when 3 # single ally
- index = @active_battler.current_action.target_index
- @target_battlers.push($game_party.smooth_target_actor(index))
- when 4 # all allies
- for actor in $game_party.actors
- if actor.exist?
- @target_battlers.push(actor)
- end
- end
- when 5 # single ally (HP 0)
- index = @active_battler.current_action.target_index
- actor = $game_party.actors[index]
- if actor != nil and actor.hp0?
- @target_battlers.push(actor)
- end
- when 6 # all allies (HP 0)
- for actor in $game_party.actors
- if actor != nil and actor.hp0?
- @target_battlers.push(actor)
- end
- end
- when 7 # user
- @target_battlers.push(@active_battler)
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Make Skill Action Results
- #--------------------------------------------------------------------------
- def make_skill_action_result
- $outfile.write "make_skill_action_result\n" if $outfile
- # Get skill
- @skill = $data_skills[@active_battler.current_action.skill_id]
- # If not a forcing action
- unless @active_battler.current_action.forcing
- # If unable to use due to SP running out
- unless @active_battler.skill_can_use?(@skill.id) or @skill.id == $switch_skill_id or @reacting or @hits_count > 0
- # Clear battler being forced into action
- $game_temp.forcing_battler = nil unless $game_temp.forcing_battler != @active_battler
- # Shift to step 1
- @phase4_step = 1
- end_regular_turn
- return
- end
- end
- #######################
- # UNPLAYABLE REACTION #
- #######################
- unless @reacting or (@hits_count > 0)
- # Use up SP
- if @active_battler.sp_override_cost
- sp_cost = @active_battler.sp_override_cost
- @active_battler.sp_override_cost = nil
- else
- sp_cost = @skill.sp_cost
- end
- if @active_battler.state?($mp1_state_id)
- @active_battler.sp -= 1
- elsif @active_battler.state?($half_mp_state_id)
- @active_battler.sp -= sp_cost / 2
- else
- @active_battler.sp -= sp_cost
- end
- end
- # Refresh status window
- @status_window.refresh
- # Show skill name on help window
- @help_window.set_text(@skill.name, 1)
- # Set animation ID
- @animation1_id = @skill.animation1_id
- @animation2_id = @skill.animation2_id
- # Set command event ID
- @common_event_id = @skill.common_event_id
- # Set target battlers
- set_target_battlers(@skill.scope)
- # Apply skill effect
- for target in @target_battlers
- $game_temp.skill_reflected = false
- # target.skill_effect will check if the target reflects
- # and set $game_temp.skill_reflected accordingly
- target.skill_effect(@active_battler, @skill)
- ###################
- # reflect support #
- ###################
- @reflected_battler = nil
- if $game_temp.skill_reflected
- if (target == @active_battler)
- @reflected_battler = $game_troop.random_target_enemy
- else
- @reflected_battler = @active_battler
- end
- @reflecters.push(target)
- end
- ###################
- end
- ###################
- # reflect support #
- ###################
- if @reflected_battler != nil
- @reflected_battler.skill_effect(@active_battler, @skill)
- end
- ###################
- end
- #--------------------------------------------------------------------------
- # * Make Item Action Results
- #--------------------------------------------------------------------------
- def make_item_action_result
- if @using_auto_life
- #######################
- # AUTO LIFE #
- #######################
- $outfile.write "make_item_action_result AUTO LIFE\n" if $outfile
- # Set animation ID
- @animation1_id = @item.animation1_id
- @animation2_id = @item.animation2_id
- # Apply item results
- @target_battlers = [@auto_life_targets.pop]
- for target in @target_battlers
- target.item_effect(@item)
- end
- return
- elsif @using_phoenix
- #######################
- # AUTO PHOENIX #
- #######################
- # print("make_item_action_result AUTO PHOENIX")
- # Set animation ID
- @animation1_id = @item.animation1_id
- @animation2_id = @item.animation2_id
- # Apply item results
- @target_battlers = [@phoenix_targets.pop]
- for target in @target_battlers
- target.item_effect(@item)
- end
- # If consumable
- if @item.consumable
- # Decrease used item by 1
- $game_party.lose_item(@item.id, 1)
- end
- # Display item name on help window
- @help_window.set_text(@item.name, 1)
- return
- end
- # Get item
- @item = $data_items[@active_battler.current_action.item_id]
- # If unable to use due to items running out
- unless $game_party.item_can_use?(@item.id)
- # Shift to step 1
- @phase4_step = 1
- end_regular_turn
- return
- end
- # If consumable
- if @item.consumable
- # Decrease used item by 1
- $game_party.lose_item(@item.id, 1)
- end
- # Display item name on help window
- @help_window.set_text(@item.name, 1)
- # Set animation ID
- @animation1_id = @item.animation1_id
- @animation2_id = @item.animation2_id
- # Set common event ID
- @common_event_id = @item.common_event_id
- # Decide on target
- index = @active_battler.current_action.target_index
- target = $game_party.smooth_target_actor(index)
- # Set targeted battlers
- set_target_battlers(@item.scope)
- # Apply item effect
- for target in @target_battlers
- target.item_effect(@item)
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (main phase step 3 : animation for action performer)
- #--------------------------------------------------------------------------
- def update_phase4_step3
- # Animation for action performer (if ID is 0, then white flash)
- if @animation1_id == 0
- @active_battler.white_flash = true
- else
- @active_battler.animation_id = @animation1_id
- @active_battler.animation_hit = true
- end
- # Shift to step 3.1
- @phase4_step = 3.1
- end
- #--------------------------------------------------------------------------
- # * Frame Update (main phase step 3.1 : animation for reflect)
- #--------------------------------------------------------------------------
- def update_phase4_step3_1
- for actor in @reflecters
- @wait_count = 8
- actor.animation_id = REFLECT_ANIMATION_ID unless REFLECT_ANIMATION_ID == nil
- end
- # Shift to step 4
- @phase4_step = 4
- end
- #--------------------------------------------------------------------------
- # * Frame Update (main phase step 4: animation for target)
- #--------------------------------------------------------------------------
- def update_phase4_step4
- # Animation for target
- for target in @target_battlers
- target.animation_id = @animation2_id unless target.cancel_animation
- target.animation_hit = (target.damage != "Miss")
- end
- ###################
- # REFLECT SUPPORT #
- ###################
- # cancel animation if the targets reflect the skill
- for target in @reflecters
- target.animation_id = 0
- end
- # set animation for char on which the skill is reflected
- # unless it's in reflex state too
- if @reflected_battler != nil
- if @reflected_battler.state?($reflect_state_id)
- @reflected_battler.animation_id = REFLECT_ANIMATION_ID unless REFLECT_ANIMATION_ID == nil
- else
- @reflected_battler.animation_id = @animation2_id
- @reflected_battler.animation_hit = (target.damage != "Miss")
- end
- end
- # Animation has at least 8 frames, regardless of its length
- @wait_count = 8
- # Shift to step 5
- @phase4_step = 5
- end
- #--------------------------------------------------------------------------
- # * Frame Update (main phase step 5 : damage display)
- #--------------------------------------------------------------------------
- def update_phase4_step5
- # Hide help window
- @help_window.visible = false
- # Refresh status window
- @status_window.refresh
- @status_window.animate_bars=true
- # Display damage
- for target in @target_battlers
- if target.damage != nil
- target.damage_pop = true
- end
- end
- # Support for Drain & Aspire & Drakoken
- if @active_battler.damage != nil
- @active_battler.damage_pop = true
- end
- # Support for Steal
- if $game_temp.stolen_item_id != nil
- @stolen_item_window = Window_StolenItem.new
- $game_temp.stolen_item_id = nil
- end
- # Support for changed state damage text
- for target in @target_battlers
- if target.changed_state_text != []
- target.changed_state_pop = true
- # Show changed state text
- @spriteset.battler(target).damage("", false, target.changed_state_text)
- target.changed_state_pop = false
- target.changed_state_text = []
- end
- end
- # Support for hp bars
- for enemy in $game_troop.enemies
- if $game_system.killed_enemies_ids.include?(enemy.id)
- enemy.show_hp_bar = true
- end
- end
- ###################
- # REFLECT SUPPORT #
- ###################
- if @reflected_battler != nil
- if @reflected_battler.damage != nil
- @reflected_battler.damage_pop = true
- end
- if @reflected_battler.changed_state_text != []
- @reflected_battler.changed_state_pop = true
- # Show changed state text
- @spriteset.battler(@reflected_battler).damage("", false, @reflected_battler.changed_state_text)
- @reflected_battler.changed_state_pop = false
- @reflected_battler.changed_state_text = []
- end
- end
- # Shift to step 5.1
- @phase4_step = 5.1
- end
- #--------------------------------------------------------------------------
- # * Frame Update (main phase step 5.1 : common events)
- #--------------------------------------------------------------------------
- def update_phase4_step5_1
- $outfile.write "update_phase4_step5_1" + "\n" if $outfile
- if @common_event_id > 0
- $outfile.write "setup common event" + "\n" if $outfile
- common_event = $data_common_events[@common_event_id]
- $game_system.battle_interpreter.setup(common_event.list, 0)
- @common_event_id = 0
- end
- if not $game_system.battle_interpreter.running?
- @phase4_step = 6
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (main phase step 6 : refresh)
- #--------------------------------------------------------------------------
- def update_phase4_step6
- $game_temp.forcing_battler = nil unless $game_temp.forcing_battler != @active_battler
- #if @common_event_id > 0
- # common_event = $data_common_events[@common_event_id]
- # $game_system.battle_interpreter.setup(common_event.list, 0)
- #end
- @phase4_step = 1
- #######################
- # SWITCH #
- #######################
- if @switch_common_event
- @switch_common_event = false
- $game_system.battle_interpreter.setup($switch_common_event.list, 0)
- end
- #######################
- # RETIRE #
- #######################
- if @retire_common_event
- @retire_common_event = false
- $game_system.battle_interpreter.setup($retire_common_event.list, 0)
- end
- #######################
- # UNPLAYABLE REACTION #
- #######################
- if @reacting and !PLAYABLE_REACTION
- if @return_guarding
- @active_battler.current_action.kind = 0
- @active_battler.current_action.basic = 1
- end
- if @return_to_forced_action
- @active_battler.current_action =
- @active_battler_saved_forced_action.dup
- end
- @end_turn = true
- @active_battler.active_in_this_battle = true if @active_battler.is_a?(Game_Actor)
- @reacting = false
- # print("stop reaction")
- return
- #######################
- # AUTO LIFE #
- #######################
- elsif @using_auto_life
- if @auto_life_targets.empty?
- @auto_life = false
- @auto_life_targets = []
- end
- return
- #######################
- # AUTO PHOENIX #
- #######################
- elsif @using_phoenix
- if @return_guarding
- @active_battler.current_action.kind = 0
- @active_battler.current_action.basic = 1
- end
- if @return_to_forced_action
- @active_battler.current_action =
- @active_battler_saved_forced_action.dup
- end
- @end_turn = true
- @using_phoenix = false
- # print("stop phoenix")
- if @phoenix_users.empty? or @phoenix_targets.empty? or $game_party.item_number(PHOENIX_ITEM_ID) == 0
- @auto_phoenix = false
- @phoenix_users = []
- @phoenix_targets = []
- end
- return
- end
- ########################
- # MULTIPLE HITS SKILLS #
- ########################
- if @active_battler.current_action.kind == 1 and
- MULTIPLE_HITS_SKILLS[@active_battler.current_action.skill_id] != nil
- @hits_count += 1
- target_alive = false
- for target in @target_battlers
- if not target.dead?
- target_alive = true
- end
- end
- $outfile.write "MULTIPLE_HITS_SKILLS - target alive: " + target_alive.to_s + "\n" if $outfile
- if @hits_count < MULTIPLE_HITS_SKILLS[@active_battler.current_action.skill_id] and
- target_alive
- return
- end
- end
- end_regular_turn # Not executed in case of not playable reaction, auto life
- # and auto phoenix
- end
- #============================================================================
- #================================= CTB ======================================
- #============================================================================
- def end_regular_turn
- $outfile.write "end regular turn\n" if $outfile
- after_cast = @active_battler.after_cast
- if not @active_battler.regular_turn_ended
- # print("end regular turn\nactive battler: " + @active_battler.name)
- $game_temp.battle_time = @active_battler.next_action_time
- @active_battler.action_executed($game_temp.battle_time)
- @active_battler.regular_turn_ended = true
- end
- @active_battler.current_action.forcing = false
- @active_battler_copy = @active_battler
- # end_turn is used to determine the end of a turn in update_phase4_step1
- @end_turn = true
- # Turn count (do not update if switch)
- @new_battle_turn = true unless (@active_battler.current_action.kind == 1 and
- @active_battler.current_action.skill_id == $switch_skill_id)
- # Support for the stop time state
- if @active_battler.state?($stop_time_state_id)
- @active_battler.get_next_turn
- end
- # Slip damage, skip if switch, transformation or summon type 2 (party replaced)
- unless (@active_battler.current_action.kind == 1 and @active_battler.current_action.skill_id == $switch_skill_id)
- # skip if after cast
- unless after_cast
- unless ($charlie_fleed_summons != nil and
- @active_battler.current_action.kind == 1 and
- ($data_skills[@active_battler.current_action.skill_id].is_summon_type?(2) or
- $data_skills[@active_battler.current_action.skill_id].is_summon_type?(3)))
- if @active_battler.exist? and @active_battler.slip_damage?
- # slip_damage_effect subtracts the damage from the HPs
- @active_battler.slip_damage_effect
- # Show damage
- @spriteset.battler(@active_battler).damage(@active_battler.damage, @active_battler.critical)
- @active_battler.damage = nil
- @active_battler.critical = false
- # Animate bars
- @status_window.animate_bars = true
- end
- end
- end
- end
- # REGEN SUPPORT
- for battler in @battlers_array
- if (battler == @active_battler) or REGEN_EVERY_TURN
- # Rigene, skip if switch, transformation or summon type 2 (party replaced)
- unless (@active_battler.current_action.kind == 1 and @active_battler.current_action.skill_id == $switch_skill_id)
- # skip if after cast
- unless after_cast
- unless ($charlie_fleed_summons != nil and
- @active_battler.current_action.kind == 1 and
- ($data_skills[@active_battler.current_action.skill_id].is_summon_type?(2) or
- $data_skills[@active_battler.current_action.skill_id].is_summon_type?(3)))
- if battler.hp > 0 and battler.state?($rigene_state_id)
- battler.rigene_effect
- # Show damage
- battler.damage_pop = true
- @spriteset.battler(battler).damage(battler.damage, battler.critical)
- battler.damage = nil
- battler.critical = false
- # Animate bars
- @status_window.animate_bars = true
- end
- end
- end
- end
- # MP Rigene, skip if switch, transformation or summon type 2 (party replaced)
- unless (@active_battler.current_action.kind == 1 and @active_battler.current_action.skill_id == $switch_skill_id)
- # skip if after cast
- unless after_cast
- unless ($charlie_fleed_summons != nil and
- @active_battler.current_action.kind == 1 and
- ($data_skills[@active_battler.current_action.skill_id].is_summon_type?(2) or
- $data_skills[@active_battler.current_action.skill_id].is_summon_type?(3)))
- if battler.hp > 0 and battler.state?($rigene_mp_state_id)
- battler.rigene_mp_effect
- # Show damage
- battler.sp_damage_pop = true
- @spriteset.battler(battler).damage(battler.damage, battler.critical)
- battler.damage = nil
- battler.critical = false
- # Animate bars
- @status_window.animate_bars = true
- end
- end
- end
- end
- end
- end
- # Natural removal of states
- @active_battler.remove_states_auto
- # HP RECOVERY
- if ((@active_battler.is_a?(Game_Actor) and HP_RECOVERY_ON_DEFEND > 0) or
- (@active_battler.is_a?(Game_Enemy) and E_HP_RECOVERY_ON_DEFEND > 0)) and
- (@active_battler.exist?) and @active_battler.guarding?
- # Add HP
- @active_battler.hp += Integer(@active_battler.maxhp*
- ((@active_battler.is_a?(Game_Actor))?(HP_RECOVERY_ON_DEFEND):(E_HP_RECOVERY_ON_DEFEND)))
- # Set damage
- @active_battler.damage = -Integer(@active_battler.maxhp*
- ((@active_battler.is_a?(Game_Actor))?(HP_RECOVERY_ON_DEFEND):(E_HP_RECOVERY_ON_DEFEND)))
- # Show damage
- @spriteset.battler(@active_battler).damage(@active_battler.damage, @active_battler.critical)
- @active_battler.damage = nil
- @active_battler.critical = false
- # Animate bars
- @status_window.animate_bars=true
- end
- # SP RECOVERY
- if ((@active_battler.is_a?(Game_Actor) and SP_RECOVERY_ON_DEFEND > 0) or
- (@active_battler.is_a?(Game_Enemy) and E_SP_RECOVERY_ON_DEFEND > 0)) and
- (@active_battler.exist?) and @active_battler.guarding?
- # Add SP
- @active_battler.sp += Integer(@active_battler.maxsp*
- ((@active_battler.is_a?(Game_Actor))?(SP_RECOVERY_ON_DEFEND):(E_SP_RECOVERY_ON_DEFEND)))
- # Set damage
- @active_battler.damage = -Integer(@active_battler.maxsp*
- ((@active_battler.is_a?(Game_Actor))?(SP_RECOVERY_ON_DEFEND):(E_SP_RECOVERY_ON_DEFEND)))
- # Show damage
- @active_battler.sp_damage_pop = true
- @spriteset.battler(@active_battler).damage(@active_battler.damage, @active_battler.critical)
- @active_battler.damage = nil
- @active_battler.critical = false
- # Animate bars
- @status_window.animate_bars=true
- end
- if ((@active_battler.is_a?(Game_Actor) and SP_RECOVERY_ON_ATTACK > 0) or
- (@active_battler.is_a?(Game_Enemy) and E_SP_RECOVERY_ON_ATTACK > 0)) and
- (@active_battler.exist?) and @active_battler.attacking?
- # Add SP
- @active_battler.sp += Integer(@active_battler.maxsp*
- ((@active_battler.is_a?(Game_Actor))?(SP_RECOVERY_ON_ATTACK):(E_SP_RECOVERY_ON_ATTACK)))
- # Set damage
- @active_battler.damage = -Integer(@active_battler.maxsp*
- ((@active_battler.is_a?(Game_Actor))?(SP_RECOVERY_ON_ATTACK):(E_SP_RECOVERY_ON_ATTACK)))
- # Show damage
- @active_battler.sp_damage_pop = true
- @spriteset.battler(@active_battler).damage(@active_battler.damage, @active_battler.critical)
- @active_battler.damage = nil
- @active_battler.critical = false
- # Animate bars
- @status_window.animate_bars=true
- end
- # Support for Doom
- if @active_battler.state?($doom_state_id)
- $outfile.write "@active_battler.doom_damage_effect\n" if $outfile
- @active_battler.doom_damage_effect
- end
- make_phoenix_users_and_targets
- $game_temp.reaction = false if (@active_battler.dead? and not PLAYABLE_REACTION)
- # set active_in_this_battle flag
- if @active_battler.is_a?(Game_Actor) and
- @active_battler.current_action.kind != -1 and
- not (@active_battler.current_action.kind == 1 and
- @active_battler.current_action.skill_id == $switch_skill_id)
- @active_battler.active_in_this_battle = true
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_battlers_array
- @battlers_array = []
- for enemy in $game_troop.enemies
- if not (enemy.dead? or enemy.hidden)
- @battlers_array.push(enemy)
- end
- end
- for actor in $game_party.actors
- if (not actor.dead?)
- @battlers_array.push(actor)
- end
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- UPDATE_DELAYS = true
- # update delays is true only at the beginning of the turn, when the agilities
- # may have changed from the previous turn
- def update_battlers_queue(update_delays = false)
- # print("update_battlers_queue("+update_delays.to_s+")")
- @action_times = []
- @battlers_queue = []
- @battlers_array = []
- # reset all data for order computing and build the battlers_array
- for enemy in $game_troop.enemies
- if not (enemy.dead? or enemy.hidden)
- enemy.reset_order_data
- enemy.update_delays unless not update_delays
- @battlers_array.push(enemy)
- else
- # for dead or hidden enemies
- enemy.randomize_next_action_time
- end
- # reset all data for order computing and build the battlers_array
- # also set the row position in the battle status window
- end
- i = 0
- for actor in $game_party.actors
- actor.battle_status_row_pos = i
- i += 1
- if (not actor.dead?)
- actor.reset_order_data
- actor.update_delays unless not update_delays
- @battlers_array.push(actor)
- else
- # for dead actors
- actor.randomize_next_action_time
- end
- end
- # insert the next battler in the queue till the queue is not full
- while(@battlers_queue.size < BATTLERS_QUEUE_SIZE)
- # update the order data at the beginning and
- # after every insertion
- for battler in @battlers_array
- battler.update_order_data(battler == @active_battler) # updates @currently_evaluated_action_time only
- end
- @battlers_array.sort! {|a,b|
- a.currently_evaluated_action_time - b.currently_evaluated_action_time }
- @battlers_queue.push(@battlers_array.first)
- # an action for this battler has been enqueed, update his last queued action time
- @action_times.push(@battlers_array.first.currently_evaluated_action_time)
- @battlers_array.first.enqueued_action() # updates @last_queued_action_time and @no_of_queued_actions
- end
- @turn_window.set_action_times(@action_times)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def battle_data_hard_reset
- for enemy in $game_troop.enemies
- enemy.battle_data_reset
- end
- for actor in $game_party.actors
- actor.battle_data_reset
- actor.active_in_this_battle=false
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def make_phoenix_users_and_targets
- @old_phoenix_targets = @phoenix_targets
- @phoenix_targets = []
- @phoenix_users = []
- for actor in $game_party.actors
- if actor.dead? and not actor.state?($auto_life_state_id)
- @phoenix_targets.push(actor)
- # print ("phoenix target: "+actor.name)
- end
- end
- make_phoenix_users_and_targets2
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def make_phoenix_users_and_targets2
- if PHOENIX_ON_NEWLY_KILLED
- @phoenix_targets = @phoenix_targets-@old_phoenix_targets
- end
- if !@phoenix_targets.empty? and $game_party.item_number(PHOENIX_ITEM_ID) > 0
- for actor in $game_party.actors
- if !actor.dead? and actor.movable? and
- actor.state?($auto_phoenix_state_id) and
- not CANNOT_USE_ITEMS.include?(actor.id)
- @phoenix_users.push(actor)
- # print ("phoenix user: "+actor.name)
- end
- end
- if !@phoenix_users.empty?
- @auto_phoenix = true
- end
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def make_auto_life_targets
- $outfile.write "make_auto_life_targets\n" if $outfile
- @auto_life_targets = []
- @auto_life = false
- for actor in $game_party.actors
- if actor.dead? and actor.state?($auto_life_state_id)
- @auto_life_targets.push(actor)
- @auto_life = true
- end
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update_stolen_item_window
- @stolen_item_window.update
- if Input.trigger?(Input::C)
- @stolen_item_window.dispose
- @stolen_item_window = nil
- end
- end
- #--------------------------------------------------------------------------
- # * Set initial action
- #--------------------------------------------------------------------------
- # identify the command based on the string
- def set_initial_action
- case @actor_command_window.commands[@actor_command_window.index]
- # attack
- when $data_system.words.attack
- @active_battler.current_action.kind = 0
- @active_battler.current_action.basic = 0
- # item
- when $data_system.words.item
- @active_battler.current_action.kind = 2
- # switch
- when "Switch"
- @active_battler.current_action.kind = 1
- end
- ### SUPPORT FOR INDIVIDUAL BATTLE COMMANDS ###
- if @active_battler.individual_commands.
- include?(@actor_command_window.commands[@actor_command_window.index])
- @active_battler.current_action.kind = 1
- end
- @active_battler.action_selected(@active_battler.current_action)
- # print("set_initial action " + @active_battler.current_action.kind.to_s + " " + @active_battler.current_action.basic.to_s)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def deal_damage(battler, damage)
- battler.hp -= damage
- battler.damage_pop = true
- @spriteset.battler(battler).damage(damage, battler.critical)
- battler.damage = nil
- battler.critical = false
- @status_window.animate_bars = true
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def states_plus(battler, states)
- battler.states_plus(states)
- battler.changed_state_pop = true
- @spriteset.battler(battler).damage("", false, battler.changed_state_text)
- battler.changed_state_pop = false
- battler.changed_state_text = []
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def show_text(battler, text)
- battler.damage_pop = true
- @spriteset.battler(battler).damage(text, battler.critical)
- battler.damage = nil
- battler.critical = false
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_position(battler, x, y)
- battler.screen_x_override = x
- battler.screen_y_override = y
- @spriteset.battler(battler).update_position
- end
- end
- #==============================================================================
- # ** Arrow_Enemy
- #------------------------------------------------------------------------------
- #==============================================================================
- class Arrow_Enemy < Arrow_Base
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- # Skip if indicating a nonexistant enemy
- $game_troop.enemies.size.times do
- break if self.enemy.exist?
- @index += 1
- @index %= $game_troop.enemies.size
- end
- # Cursor right
- if Input.repeat?(Input::DOWN)
- $game_system.se_play($data_system.cursor_se)
- $game_troop.enemies.size.times do
- @index += 1
- @index %= $game_troop.enemies.size
- break if self.enemy.exist?
- end
- end
- # Cursor left
- if Input.repeat?(Input::UP)
- $game_system.se_play($data_system.cursor_se)
- $game_troop.enemies.size.times do
- @index += $game_troop.enemies.size - 1
- @index %= $game_troop.enemies.size
- break if self.enemy.exist?
- end
- end
- # Set sprite coordinates
- if self.enemy != nil
- self.x = self.enemy.screen_x
- self.y = self.enemy.screen_y
- end
- end
- end
- #==============================================================================
- # ** Arrow_Actor
- #------------------------------------------------------------------------------
- #==============================================================================
- class Arrow_Actor < Arrow_Base
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- # Cursor right
- if Input.repeat?(Input::DOWN)
- $game_system.se_play($data_system.cursor_se)
- @index += 1
- @index %= $game_party.actors.size
- end
- # Cursor left
- if Input.repeat?(Input::UP)
- $game_system.se_play($data_system.cursor_se)
- @index += $game_party.actors.size - 1
- @index %= $game_party.actors.size
- end
- # Set sprite coordinates
- if self.actor != nil
- self.x = self.actor.screen_x
- self.y = self.actor.screen_y
- end
- end
- end
- #==============================================================================
- # ** Game_BattleAction
- #------------------------------------------------------------------------------
- # This class handles actions in battle. It's used within the Game_Battler
- # class.
- #==============================================================================
- class Game_BattleAction
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :selecting_all_allies
- attr_accessor :selecting_all_enemies
- #--------------------------------------------------------------------------
- # * Clear
- #--------------------------------------------------------------------------
- alias cf_clear clear
- def clear
- cf_clear
- @selecting_all_allies = false
- @selecting_all_enemies = false
- end
- end
Add Comment
Please, Sign In to add comment