#============================================================================
# ** Repeat Battle Actions
#------------------------------------------------------------------------------------------------------------------------
# by Fantasist
# Version 1.1
# 17-Apr-2008
#------------------------------------------------------------------------------------------------------------------------
# Version History:
#
# 0.1 - First alpha version
# 0.2 - Added support for default action
# 0.3 - Added Status Window Mod (for default status screen)
# 0.4 - Added fail-safe actions
# 1.0 - Optimized code and added some options
# 1.1 - Fixed a bug in Status Config
#------------------------------------------------------------------------------------------------------------------------
# Description:
# Adds Repeat, Attack and Defend functions to Party Command Window.
# Repeat - Repeats previous actions
# Attack - All actors attack
# Defend - All actors defend
#
# Features:
# - Make actors Repeat their previous actions, or make them all attack or defend
# - Config addon for default status screen
# - Memorize option in the status config saves the last action with the savefile, and is
# globally remembered
# - Fail-safe actions - performs default action if previous action can't be performed
#------------------------------------------------------------------------------------------------------------------------
# Compatibility:
#
# Might not be compatible with other battle systems.
#------------------------------------------------------------------------------------------------------------------------
# Installation: Place this script anywhere above main and below Scene_Battle.
#
# Configuration:
#
# Fail_Safe_Action: When using 'Repeat', if the action fails (not enough SP or no item to use),
# default action is performed.
# Memorize_Atk_Dfn: Whether to remember 'Attack' or 'Defend' used from the auto-battle options.
#
class Scene_Battle
Fail_Safe_Action = true
Memorize_Atk_Dfn = false
end
#------------------------------------------------------------------------------------------------------------------------
# Issues: None
#------------------------------------------------------------------------------------------------------------------------
# Credits: Fantasist for making this
#------------------------------------------------------------------------------------------------------------------------
# Notes:
# If you have any questions, problems or suggestions, you can find me at:
# - www.chaos-project.com
# - www.quantumcore.forumotion.com
#
# Enjoy ^_^
#============================================================================
#==============================================================================
# ** Game_Battler
#==============================================================================
class Game_Battler
attr_accessor :prior_action, :default_action, :memorize_action
alias fant_auto_battle_game_battler_init initialize
def initialize
fant_auto_battle_game_battler_init
@prior_action, @default_action = Game_BattleAction.new, Game_BattleAction.new
@default_action.kind, @default_action.basic, @memorize_action = 0, 1, false
end
def current_action=(action)
@current_action = action if action.is_a?(Game_BattleAction)
end
end
#==============================================================================
# ** Scene_Battle
#==============================================================================
class Scene_Battle
alias fant_auto_battle_scene_battle_main main
def main
$game_party.actors.each {|actor| actor.prior_action = actor.default_action.clone}
fant_auto_battle_scene_battle_main
end
alias fant_auto_battle_scene_battle_upd_phase2 update_phase2
def update_phase2
if Input.trigger?(Input::C) && @party_command_window.index == 2
case @party_command_window.auto_index
when 0
$game_party.actors.each {|actor| actor.current_action = actor.prior_action.clone}
when 1
$game_party.actors.each {|actor| actor.current_action.kind = actor.current_action.basic = 0}
when 2
$game_party.actors.each {|actor| actor.current_action.kind, actor.current_action.basic = 0, 1}
when 3
if $easy_party_switcher && $easy_party_switcher >= 2.4 && BlizzCFG::BATTLE_SWITCH
$game_system.se_play($data_system.decision_se)
@spriteset.dispose
$scene = Scene_PartySwitcher.new
$scene.main
$scene = self
@spriteset = Spriteset_Battle.new
15.times {@spriteset.update}
@status_window.refresh
Graphics.transition(0)
end
end
start_phase4
end
fant_auto_battle_scene_battle_upd_phase2
end
alias fant_auto_battle_scene_battle_start_phase4 start_phase4
def start_phase4
fant_auto_battle_scene_battle_start_phase4
$game_party.actors.each {|actor| prepare_action(actor)}
end
def prepare_action(actor)
if @party_command_window.auto_index == 0 && !Memorize_Atk_Dfn
actor.prior_action = actor.current_action.clone
actor.default_action = actor.current_action.clone if actor.memorize_action
end
action = actor.current_action
if Fail_Safe_Action && ((action.kind == 1 && !actor.skill_can_use?(action.skill_id)) ||
(action.kind == 2 && !$game_party.item_can_use?(action.item_id)))
actor.current_action = actor.default_action.clone
end
end
end
#==============================================================================
# ** Window_PartyCommand
#==============================================================================
class Window_PartyCommand < Window_Selectable
attr_reader :auto_index, :auto_cmds
def initialize
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.active = self.visible = false
self.back_opacity, self.index = 160, 0
@commands = ['Fight', 'Escape', 'Auto']
@item_max = @column_max = 3
@auto_index, @auto_cmds = 0, ['Repeat', 'Attack', 'Defend']
if $easy_party_switcher && $easy_party_switcher >= 2.4 && BlizzCFG::BATTLE_SWITCH
@auto_cmds.push('Switch')
end
draw_item(0, normal_color)
draw_item(1, $game_temp.battle_can_escape ? normal_color : disabled_color)
draw_item(2, normal_color)
end
def update
super
draw_item(2, normal_color) if Input.repeat?(Input::RIGHT) || Input.repeat?(Input::LEFT)
if @index == 2
if Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@auto_index = (@auto_index - 1) % @auto_cmds.size
draw_item(2, normal_color)
elsif Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@auto_index = (@auto_index + 1) % @auto_cmds.size
draw_item(2, normal_color)
end
end
end
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(index * 608 / @column_max, 0, 608 / @column_max, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
font = self.contents.font.name.clone
self.contents.font.name = 'Arial'
self.contents.draw_text(rect, '↑ ↓', 1) if index == 2 && @index == 2 # ˄˅↑↓
self.contents.font.name = font
txt = index == 2 ? @auto_cmds[@auto_index] : @commands[index]
self.contents.draw_text(rect, txt, 1)
end
def update_cursor_rect
self.cursor_rect.set(index * 608 / @column_max, 0, 608 / @column_max, 32)
end
end
#==============================================================================
# ** Window_Status
#==============================================================================
class Window_Status < Window_Selectable
X, Y, W, W2 = 320, 118, 128, 96
def initialize(actor)
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
@cmds = ['Attack', 'Defend', 'Memorize']
if @actor.default_action.kind == 0 && @actor.default_action.basic == 0
self.index = 0
elsif @actor.default_action.kind == 0 && @actor.default_action.basic == 1
self.index = 1
end
self.index = 2 if @actor.memorize_action
refresh
end
def update_cursor_rect
self.cursor_rect.set(X+W, Y, W2, 32)
end
def update
super
update_cursor_rect
return if @index < 0
if Input.repeat?(Input::RIGHT) || Input::repeat?(Input::C)
$game_system.se_play($data_system.cursor_se)
@index = (@index + 1) % @cmds.size
self.contents.font.color = normal_color
self.contents.fill_rect(X+W, Y, W2, 32, Color.new(0, 0, 0, 0))
self.contents.font.color = crisis_color
self.contents.draw_text(X+W, Y, W2, 32, @cmds[@index], 1)
case @index
when 0
@actor.default_action.kind = @actor.default_action.basic = 0
@actor.memorize_action = false
when 1
@actor.default_action.kind, @actor.default_action.basic = 0, 1
@actor.memorize_action = false
when 2
@actor.memorize_action = true
end
end
if Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
@index = (@index - 1) % @cmds.size
self.contents.font.color = normal_color
self.contents.fill_rect(X+W, Y, W2, 32, Color.new(0, 0, 0, 0))
self.contents.font.color = crisis_color
self.contents.draw_text(X+W, Y, W2, 32, @cmds[@index], 1)
case @index
when 0
@actor.default_action.kind = @actor.default_action.basic = 0
@actor.memorize_action = false
when 1
@actor.default_action.kind, @actor.default_action.basic = 0, 1
@actor.memorize_action = false
when 2
@actor.memorize_action = true
end
end
if self.active and @help_window != nil
update_help
end
end
def refresh
self.contents.clear
draw_actor_graphic(@actor, 40, 112)
draw_actor_name(@actor, 4, 0)
draw_actor_class(@actor, 4 + 144, 0)
draw_actor_level(@actor, 96, 32)
draw_actor_state(@actor, 96, 64)
draw_actor_hp(@actor, 96, 112, 172)
draw_actor_sp(@actor, 96, 144, 172)
draw_actor_parameter(@actor, 96, 192, 0)
draw_actor_parameter(@actor, 96, 224, 1)
draw_actor_parameter(@actor, 96, 256, 2)
draw_actor_parameter(@actor, 96, 304, 3)
draw_actor_parameter(@actor, 96, 336, 4)
draw_actor_parameter(@actor, 96, 368, 5)
draw_actor_parameter(@actor, 96, 400, 6)
self.contents.font.color = system_color
self.contents.draw_text(320, 48, 80, 32, "EXP")
self.contents.draw_text(320, 80, 80, 32, "NEXT")
self.contents.font.color = normal_color
self.contents.draw_text(320 + 80, 48, 84, 32, @actor.exp_s, 2)
self.contents.draw_text(320 + 80, 80, 84, 32, @actor.next_rest_exp_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(320, 160, 96, 32, "equipment")
draw_item_name($data_weapons[@actor.weapon_id], 320 + 16, 208)
draw_item_name($data_armors[@actor.armor1_id], 320 + 16, 256)
draw_item_name($data_armors[@actor.armor2_id], 320 + 16, 304)
draw_item_name($data_armors[@actor.armor3_id], 320 + 16, 352)
draw_item_name($data_armors[@actor.armor4_id], 320 + 16, 400)
self.contents.font.color = normal_color
self.contents.draw_text(X, Y, W, 32, 'Battle Action:')
self.contents.font.color = crisis_color
self.contents.draw_text(X+W, Y, W2, 32, @cmds[@index], 1)
end
def dummy
self.contents.font.color = system_color
self.contents.draw_text(320, 112, 96, 32, $data_system.words.weapon)
self.contents.draw_text(320, 176, 96, 32, $data_system.words.armor1)
self.contents.draw_text(320, 240, 96, 32, $data_system.words.armor2)
self.contents.draw_text(320, 304, 96, 32, $data_system.words.armor3)
self.contents.draw_text(320, 368, 96, 32, $data_system.words.armor4)
draw_item_name($data_weapons[@actor.weapon_id], 320 + 24, 144)
draw_item_name($data_armors[@actor.armor1_id], 320 + 24, 208)
draw_item_name($data_armors[@actor.armor2_id], 320 + 24, 272)
draw_item_name($data_armors[@actor.armor3_id], 320 + 24, 336)
draw_item_name($data_armors[@actor.armor4_id], 320 + 24, 400)
end
end
#==============================================================================
# ** Scene_Status
#==============================================================================
class Scene_Status
alias fant_auto_battle_scene_status_upd update
def update
@status_window.update
fant_auto_battle_scene_status_upd
end
end