Save-Point
Battle Memory - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Archives (https://www.save-point.org/forum-105.html)
+--- Forum: Creation Asylum Archives (https://www.save-point.org/forum-90.html)
+---- Forum: Scripts & Code Snippets (https://www.save-point.org/forum-92.html)
+----- Forum: RPG Maker XP Code (https://www.save-point.org/forum-93.html)
+----- Thread: Battle Memory (/thread-6843.html)



Battle Memory - mudgolem - 06-21-2006

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


Credit sandgolem, aka me.

Just dump this in your game. Under the default scripts, SDK (optional) and above main.

Helps make those battles a little less irritating smile.gif No modifications necessary other than setting a switch # in the comments. Characters will auto-select their last selected things, if they can, instead of always "Attack" being the default option.

Enabled by turning the switch on, disabled whenever the switch is off.
Should be compatible with most battle systems but I haven't tested.

Code:
#=============================================================================
# ** SG Battle Command Memory
#=============================================================================
# sandgolem
# Version 1
# 20.06.06
#=============================================================================

Scene_Battle::SG_Command_Memory_Switch = 5
# When this switch is on, commands are remembered.

#=============================================================================
#
# To check for updates or find more scripts, visit:
# http://www.gamebaker.com/rmxp/scripts/
#
# To use this script, copy it and insert it in a new section above "Main",
# but under the default scripts and the SDK if you're using it.
#
# Have problems? You can leave me a message at:
# http://www.gamebaker.com/users/sandgolem
#
#=============================================================================

#--------------------------------------------------------------------------
# * SDK Log Script
#--------------------------------------------------------------------------
begin
  SDK.log("SG Battle Command Memory", "sandgolem", 1, "20.06.06")
  if SDK.state("SG Battle Command Memory") != true
    @sg_battlecmemory_disabled = true
  end
  rescue
end

#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if !@sg_battlecmemory_disabled
  
class Game_Actor < Game_Battler
  attr_accessor :sg_last_selected_action
  attr_accessor :sg_last_selected_actor
  attr_accessor :sg_last_selected_enemy
  attr_accessor :sg_last_selected_item
  attr_accessor :sg_last_selected_skill
end

class Scene_Battle
  
  alias sandgolem_battlememory_battle_main main
  def main
    sandgolem_battlememory_battle_main
    for i in $game_party.actors
      if i.sg_last_selected_action != 1
        i.sg_last_selected_action = nil
      end
      i.sg_last_selected_actor = nil
      i.sg_last_selected_enemy = nil
      i.sg_last_selected_item = nil
      i.sg_last_selected_skill = nil
    end
  end

  alias sandgolem_battlememory_battle_ph3setupcom phase3_setup_command_window
  def phase3_setup_command_window
    sandgolem_battlememory_battle_ph3setupcom
    if $game_switches[SG_Command_Memory_Switch]
      if @active_battler.sg_last_selected_action != nil
        @actor_command_window.index = @active_battler.sg_last_selected_action
      end
    end
  end
        
  alias sandgolem_battlememory_battle_startactorsel start_actor_select
  def start_actor_select
    sandgolem_battlememory_battle_startactorsel
    if $game_switches[SG_Command_Memory_Switch]
      if @active_battler.sg_last_selected_actor != nil
        @actor_arrow.index = @active_battler.sg_last_selected_actor
      end
    end
  end

  alias sandgolem_battlememory_battle_startenemysel start_enemy_select
  def start_enemy_select
    sandgolem_battlememory_battle_startenemysel
    if $game_switches[SG_Command_Memory_Switch]
      if @active_battler.sg_last_selected_enemy != nil
        @enemy_arrow.index = @active_battler.sg_last_selected_enemy
      end
    end
  end
  
  alias sandgolem_battlememory_battle_startitemsel start_item_select
  def start_item_select
    sandgolem_battlememory_battle_startitemsel
    if $game_switches[SG_Command_Memory_Switch]
      if @active_battler.sg_last_selected_item != nil
        @item_window.index = @active_battler.sg_last_selected_item
      end
    end
  end

  alias sandgolem_battlememory_battle_startskillsel start_skill_select
  def start_skill_select
    sandgolem_battlememory_battle_startskillsel
    if $game_switches[SG_Command_Memory_Switch]
      if @active_battler.sg_last_selected_skill != nil
        @skill_window.index = @active_battler.sg_last_selected_skill
      end
    end
  end
  
  alias sandgolem_battlememory_battle_uph3bc update_phase3_basic_command
  def update_phase3_basic_command
    if Input.trigger?(Input::B) or Input.trigger?(Input::C)
      @active_battler.sg_last_selected_action = @actor_command_window.index
    end
    sandgolem_battlememory_battle_uph3bc
  end

  alias sandgolem_battlememory_battle_enditemsel end_item_select
  def end_item_select
    @active_battler.sg_last_selected_item = @item_window.index
    sandgolem_battlememory_battle_enditemsel
  end  

  alias sandgolem_battlememory_battle_endskillsel end_skill_select
  def end_skill_select
    @active_battler.sg_last_selected_skill = @skill_window.index
    sandgolem_battlememory_battle_endskillsel
  end

  alias sandgolem_battlememory_battle_endactorsel end_actor_select
  def end_actor_select
    @active_battler.sg_last_selected_actor = @actor_arrow.index
    sandgolem_battlememory_battle_endactorsel
  end

  alias sandgolem_battlememory_battle_endenemysel end_enemy_select
  def end_enemy_select
    @active_battler.sg_last_selected_enemy = @enemy_arrow.index
    sandgolem_battlememory_battle_endenemysel
  end
  
  alias sandgolem_battlememory_battle_itemactres make_item_action_result
  def make_item_action_result
    sandgolem_battlememory_battle_itemactres
    if $game_party.item_number(@active_battler.current_action.item_id) == 0
      @active_battler.sg_last_selected_item = nil
    end
  end
end

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end