#==========================================================================
# ** SG Auto Battle
#==========================================================================
# by sandgolem
# Version 2
# January 15th, 2008
#==========================================================================
module SG
AutoBattleBase = ['Automatic','Command','Run Away','Navi(Gator)']
AutoBattleCommands = ['Attack','Repeat','Wait']
NaviCommands = ['Analyze']
AutoBattleOpac = 160
AutoBattleSwitch = 0
AutoBattleX = 64
AutoBattleY = 59
NaviBattleSwitch = 0
NaviBattleOpac = 160
NaviBattleX = 364
NaviBattleY = 59
end
#==========================================================================
#
# To check for updates or find more scripts, visit:
# http://www.gamebaker.com/rmxp/scripts/
# Our RMVX scripts: http://www.gamebaker.com/rmvx/scripts/
#
# Instructions: http://www.gamebaker.com/rmxp/scripts/e/auto-battle.php
# Discussion/Help: http://forums.gamebaker.com/showthread.php?t=9
#
#==========================================================================
if Object.const_defined?('SDK')
SDK.log('SG Auto Battle', 'sandgolem', 2, '15.01.08')
@sg_autobattle_disabled = true if !SDK.enabled?('SG Auto Battle')
end
if !@sg_autobattle_disabled
#--------------------------------------------------------------------------
begin
SDK.log_overwrite(:Window_PartyCommand, :draw_item)
SDK.log_overwrite(:Window_PartyCommand, :initialize)
SDK.log_overwrite(:Window_PartyCommand, :update_cursor_rect)
rescue
end
class Window_PartyCommand < Window_Selectable
def initialize
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 160
@commands = SG::AutoBattleBase
@item_max = 4
@column_max = 4
if !$game_switches[SG::AutoBattleSwitch]
draw_item(0, normal_color)
else
draw_item(0, disabled_color)
end
draw_item(1, normal_color)
draw_item(2, $game_temp.battle_can_escape ? normal_color : disabled_color)
draw_item(3, normal_color)
self.index = 1
self.visible = false
self.active = false
end
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(35 + index * 140, 0, 150, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index], 1)
end
def update_cursor_rect
self.cursor_rect.set(35 + index * 140, 0, 150, 32)
end
end
class Game_Actor < Game_Battler
attr_accessor :sg_autoaction, :sg_autosecondary, :sg_autotargets
end
class Window_SG_Autobattle < Window_Selectable
def initialize
super(SG::AutoBattleX,SG::AutoBattleY,182,128)
@item_max = 3
@commands = SG::AutoBattleCommands
self.contents = Bitmap.new(150,96)
self.visible = false
self.back_opacity = SG::AutoBattleOpac
self.index = 0
redraw
end
def redraw
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(4,32*index,self.contents.width-8,32)
self.contents.fill_rect(rect,Color.new(0, 0, 0, 0))
self.contents.draw_text(rect,@commands[index],1)
end
def disable_item(index)
draw_item(index, disabled_color)
end
end
class Window_SG_Navibattle < Window_Selectable
def initialize
super(SG::NaviBattleX,SG::NaviBattleY,182,60)
@item_max = 1
@commands = SG::NaviCommands
self.contents = Bitmap.new(150,96)
self.visible = false
self.back_opacity = SG::NaviBattleOpac
self.index = 0
redraw
end
def redraw
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(4,32*index,self.contents.width-8,32)
self.contents.fill_rect(rect,Color.new(0, 0, 0, 0))
self.contents.draw_text(rect,@commands[index],1)
end
def disable_item(index)
draw_item(index, disabled_color)
end
end
class Scene_Battle
alias_method :sg_autobattle_main, :main
def main
@sg_autowindow = Window_SG_Autobattle.new
@sg_autowindow.active = false
@sg_autowindow.visible = false
@sg_naviwindow = Window_SG_Navibattle.new
@sg_naviwindow.active = false
@sg_naviwindow.visible = false
sg_autobattle_main
@sg_autowindow.dispose
@sg_naviwindow.dispose
end
alias_method :sg_autobattle_update, :update
def update
sg_autobattle_update
if @sg_autowindow.active
if @sg_autowindow.visible
sg_update_autowindow
@sg_autowindow.update
else
@sg_autowindow.visible = true
end
end
if @sg_naviwindow.active
if @sg_naviwindow.visible
sg_update_naviwindow
@sg_naviwindow.update
else
@sg_naviwindow.visible = true
end
end
end
def sg_update_autowindow
if Input.trigger?(Input::B)
$game_system.se_play($data_system.buzzer_se)
@sg_autowindow.active = false
@sg_autowindow.visible = false
@party_command_window.active = true
@party_command_window.index = 1
@phase = 2
end
if Input.trigger?(Input::C)
case @sg_autowindow.index
when 0
sg_phase2_allbasic(0)
when 1
if $game_temp.battle_turn != 0
sg_phase2_lastaction
else
$game_system.se_play($data_system.buzzer_se)
end
when 2
sg_phase2_allbasic(1)
end
end
end
def sg_update_naviwindow
if Input.trigger?(Input::B)
$game_system.se_play($data_system.buzzer_se)
@sg_naviwindow.active = false
@sg_naviwindow.visible = false
@party_command_window.active = true
@party_command_window.index = 1
@phase = 2
end
if Input.trigger?(Input::C)
case @sg_naviwindow.index
when 0
sg_phase2_navi
end
end
end
def sg_autowindow_setup
if $game_switches[SG::AutoBattleSwitch]
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@party_command_window.active = false
@sg_autowindow.active = true
@phase = 1337
if $game_temp.battle_turn != 0
@sg_autowindow.redraw
@sg_autowindow.index = 1
else
@sg_autowindow.disable_item(1)
end
end
def sg_naviwindow_setup
if $game_switches[SG::NaviBattleSwitch]
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@party_command_window.active = false
@sg_naviwindow.active = true
end
def update_phase2
if Input.trigger?(Input::L)
@party_command_window.index = 0
sg_autowindow_setup
end
@party_command_window.index = 2 if Input.trigger?(Input::B)
if Input.trigger?(Input::C)
case @party_command_window.index
when 0
sg_autowindow_setup
when 1
$game_system.se_play($data_system.decision_se)
start_phase3
when 2
sg_update2_escape_check
when 3
sg_naviwindow_setup
end
return
end
end
def sg_update2_escape_check
if !$game_temp.battle_can_escape
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
update_phase2_escape
end
alias_method :sg_autobattle_start4, :start_phase4
def start_phase4
@sg_autowindow.active = false
@sg_autowindow.visible = false
for i in $game_party.actors
i.sg_autoaction = i.current_action.kind
i.sg_autosecondary = i.current_action.basic if i.sg_autoaction == 0
i.sg_autosecondary = i.current_action.skill_id if i.sg_autoaction == 1
i.sg_autosecondary = i.current_action.item_id if i.sg_autoaction == 2
i.sg_autotargets = i.current_action.target_index
end
sg_autobattle_start4
end
def sg_phase2_allbasic(type)
$game_system.se_play($data_system.decision_se)
for i in $game_party.actors
i.current_action.kind = 0
i.current_action.basic = type
end
start_phase4
end
def sg_phase2_navi
$game_system.se_play($data_system.decision_se)
@party_command_window.active = false
@sg_naviwindow.active = false
@sg_naviwindow.visible = false
end
def sg_phase2_lastaction
$game_system.se_play($data_system.decision_se)
for i in $game_party.actors
if i.sg_autoaction != nil
i.current_action.kind = i.sg_autoaction
i.current_action.basic = i.sg_autosecondary if i.sg_autoaction == 0
i.current_action.skill_id = i.sg_autosecondary if i.sg_autoaction == 1
i.current_action.item_id = i.sg_autosecondary if i.sg_autoaction == 2
i.current_action.target_index = i.sg_autotargets
else
i.current_action.kind = 0
i.current_action.basic = 0
end
end
start_phase4
end
end
#--------------------------------------------------------------------------
end
#==========================================================================
# End of file! You can find more of my scripts at http://www.gamebaker.com
#==========================================================================