Jump to content
MasterMoes

Need help with a pre-battle saving system

Recommended Posts

Hello yall.

I'm trying to create a system in my VX Ace game that allows a player to save their game before entering a battle. My current method involves a script that calls a common event before a battle, which gives the player the option to open the save screen before fighting. There's another script involved that calls a common event to check if every party member is dead, and if this is the case, the player is given the option to select one of their save files (using Yanfly's save script) or give up and get the game over screen.

The problem with this method though is that the player might get themselves stuck by saving before a battle they're not ready to fight, meaning it's possible for the player to overwrite their last chance to turn around and prepare. This is especially a problem for inexperienced players.

What I'm looking for is a script that creates a save point, when called through a script call, that can be called on demand. Imagine a normal save slot that can be created and called upon by a script call, but can't be overwritten or used through the regular saving screen. When the "dead party members" script call happens, when the player chooses the "retry" option, the invisible save slot will activate as if loaded through the save screen.

I tried looking EVERYWHERE for a script like this, but the closest thing I found was Bravo2Kilo's checkpoint script, but that just causes the game to skip the battle as if the player won.

Please help...

Share this post


Link to post
Share on other sites
14 hours ago, MasterMoes said:

I tried looking EVERYWHERE for a script like this,

So what you want is different than Theoallen gameover + battle retry script, or TDS battle retry script?

Share this post


Link to post
Share on other sites

I tried the TDS script long ago, but it never actually works. When I select the "yes" option after dying it continues the battle processing like normal, the character still dead and the enemies the same as they were. I also tried Regendo's gameover choices script with the retry battle add-on. The gameover choices script works fine on its own, but the add-on causes this error to appear upon launching the game (line 214 causes the problem, but 213 doesn't even though they're basically the same?):

1600550434_help1.PNG.fe27d0883dd8e715d16c60f3181ad154.PNG

947124536_help2.PNG.955634548ad3ba68a3103d63975941dc.PNG

But what is this script of Theoallen's you speak of? I couldn't find anything like that from him. In fact, I couldn't find most of his scripts even though I've located them somewhere before. Do you have the link to Theo's script or know why Regendo's script isn't working? And yes, I did place the add-on script below the base script and above MAIN, and I tried placing both scripts above and below other possibly troublesome scripts.

Share this post


Link to post
Share on other sites

I was using v3.0 of Regendo's script, received from the same link you have.

So I tried using Theo's script, and the retry battle command works great for what I'm looking for (although there isn't any transition effect after selecting the command). However, I can't get the checkpoint system to work in or out of battle. I get the classic "line 1411" message, and it doesn't tell me where the error is located.

843781312_help3.PNG.426f72ab70a5fe425d75c2c7c78c8769.PNG

I tried putting the checkpoint script call in a comment but it just did nothing.

Even though the retry battle command does what I want it to, I still want to use the checkpoint system for future use. Have any idea what's wrong with it? Also, what would I do if I wanted to add a simple fade-to-black or fade-to-white transition once the "retry battle" command is selected? Maybe a sound effect along with it too?

Share this post


Link to post
Share on other sites

If you were using a backtracer you would probably know more about where the error is.

Where are you using the script call command?

are you starting a new game or a save file? Normally a save file will not work when adding new scripts.

Share this post


Link to post
Share on other sites
9 hours ago, roninator2 said:

If you were using a backtracer you would probably know more about where the error is.

Where are you using the script call command?

are you starting a new game or a save file? Normally a save file will not work when adding new scripts.

I was using the script call in a common event, but even when I put it into an event on the map it still didn't work. The script call doesn't work in a new game or a save file either. I also tried placing the script on the top and bottom of all my other scripts, but nothing changed.

Share this post


Link to post
Share on other sites

You must have something conflicting. In my tests on a blank system is works fine.

I did not get any error

Share this post


Link to post
Share on other sites

Perhaps a autosave script would work, I normally wouldn't post script code.

Just edit the battle end to battle start & it should work, it's my personal edit.

#Basic Autosave v1.1 Script by: V.M of D.T (email): sumptuaryspade@live.ca
#   facebook: http://www.facebook.com/DaimoniousTailsGames
#   Other Scripts http://daimonioustails.weebly.com/
#   Free to use in any project with credit given, donations always welcome!
NAME_AUTOSAVE_FILE = true
AUTOSAVE_FILE_NAME = "Autosave"
AUTOSAVE_ON_MAP = false
AUTOSAVE_AFTER_BATTLE = true
$auto_save = true
class Scene_Map
  alias auto_post_transfer post_transfer
  def post_transfer
    auto_post_transfer
    return unless AUTOSAVE_ON_MAP
    if Module.const_defined?(:Game_Options)
      DataManager.save_game(3) if $game_options.auto_save
    else
      DataManager.save_game(3) if $auto_save
    end
  end
end
module BattleManager
  def self.battle_end(result)
    @phase = nil
    @event_proc.call(result) if @event_proc
    $game_party.on_battle_end
    $game_troop.on_battle_end
      DataManager.save_game(3) if $auto_save
    end
end
class Window_SaveFile
  alias auto_refresh refresh
  def refresh
    if NAME_AUTOSAVE_FILE
      contents.clear
      change_color(normal_color)
      if @file_index == 3
        name = AUTOSAVE_FILE_NAME
      else
        name = Vocab::File + " #{@file_index}"
      end
      draw_text(4, 0, 200, line_height, name)
      @name_width = text_size(name).width
      draw_party_characters(152, 58)
      draw_playtime(0, contents.height - line_height, contents.width - 4, 2)
    else
      auto_refresh
    end
  end
end

Share this post


Link to post
Share on other sites
On 8/25/2022 at 4:41 AM, EXVA said:

Perhaps a autosave script would work, I normally wouldn't post script code.

Just edit the battle end to battle start & it should work, it's my personal edit.

#Basic Autosave v1.1 Script by: V.M of D.T (email): sumptuaryspade@live.ca
#   facebook: http://www.facebook.com/DaimoniousTailsGames
#   Other Scripts http://daimonioustails.weebly.com/
#   Free to use in any project with credit given, donations always welcome!
NAME_AUTOSAVE_FILE = true
AUTOSAVE_FILE_NAME = "Autosave"
AUTOSAVE_ON_MAP = false
AUTOSAVE_AFTER_BATTLE = true
$auto_save = true
class Scene_Map
  alias auto_post_transfer post_transfer
  def post_transfer
    auto_post_transfer
    return unless AUTOSAVE_ON_MAP
    if Module.const_defined?(:Game_Options)
      DataManager.save_game(3) if $game_options.auto_save
    else
      DataManager.save_game(3) if $auto_save
    end
  end
end
module BattleManager
  def self.battle_end(result)
    @phase = nil
    @event_proc.call(result) if @event_proc
    $game_party.on_battle_end
    $game_troop.on_battle_end
      DataManager.save_game(3) if $auto_save
    end
end
class Window_SaveFile
  alias auto_refresh refresh
  def refresh
    if NAME_AUTOSAVE_FILE
      contents.clear
      change_color(normal_color)
      if @file_index == 3
        name = AUTOSAVE_FILE_NAME
      else
        name = Vocab::File + " #{@file_index}"
      end
      draw_text(4, 0, 200, line_height, name)
      @name_width = text_size(name).width
      draw_party_characters(152, 58)
      draw_playtime(0, contents.height - line_height, contents.width - 4, 2)
    else
      auto_refresh
    end
  end
end

This looks promising. But how do I make an autosave happen? Does it do it automatically before battle or do I need a script call?

Share this post


Link to post
Share on other sites

Either, you can turn it off by making true into false, if I'm not mistaken.

$auto_save = true

then make manual saves in a script call with

  DataManager.save_game(3)

But I haven't tested it.

Edited by EXVA

Share this post


Link to post
Share on other sites
On 9/6/2022 at 4:34 PM, EXVA said:

Either, you can turn it off by making true into false, if I'm not mistaken.

$auto_save = true

then make manual saves in a script call with

  DataManager.save_game(3)

But I haven't tested it.

So I tested both Theo's script and the auto-save script separately in a new blank project, and both of them have their problems. Theo's script doesn't actually work; when you try and go to your checkpoint, it skips the battle and continues the event processing as if you won the battle. The autosave script does the same exact thing.

I think the built-in "retry battle" options should work fine, but it needs a transition or something instead of instantly bringing the player back into battle. Even just a 1-second simple black fade would be fine. How would I implement this into the script?

Share this post


Link to post
Share on other sites
6 hours ago, MasterMoes said:

The autosave script

That script by vlue saves after battle. Doctor Todd's Auto save can save before the battle. Tested and looks to working fine.

This is not the original site but it has the code in it.

Then you can use my script to block the save slot. So the player can't select it.

# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Block Save Slots             ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║     Block player from saving        ╠════════════════════╣
# ║     into specific save slots        ║    18 Sep 2021     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions:                                            ║
# ║   Specify the slots to block in the array                ║
# ║     Blocked = [1,4]                                      ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝
module R2_Save_Block
  Blocked = [0,1]
end

class Scene_Save < Scene_File
  def on_savefile_ok
    super
    if R2_Save_Block::Blocked.include?(@index)
      Sound.play_buzzer
    else
      if DataManager.save_game(@index)
        on_save_success
      else
        Sound.play_buzzer
      end
    end
  end
end

does this work for you?

  • Thanks 1

Share this post


Link to post
Share on other sites
17 hours ago, roninator2 said:

does this work for you?

I don't get it. Each one of these scripts keeps malfunctioning, even in a new project. Just like the other scripts, Todd's script overwrote the save data I was testing on, and when I loaded the save data, it continued the event processing as if the player won the battle. I know this because there's a switch that activates after the battle.

Quote

Then you can use my script to block the save slot. So the player can't select it.

This script doesn't seem to do anything. It doesn't block any of the save slots I set in the array. Doesn't grey them out, doesn't stop the player from saving into the slot.

I think I should have mentioned this before, but I'm using Yanfly's Ace Save Engine, which may be affecting these scripts somehow, although most of them don't function properly in a blank project. I think these scripts are made for overworld encounters, which my game barely uses. One thing's for sure, these don't work for battles processed from a map event.

What I could really use though is, in TheoAllen's script, a simple fade-to-black transition when using the retry battle command. That will do exactly what I'm looking for, just a simple way to start the battle over from where you began so the player doesn't have to rewatch every pre-battle monolog.

Share this post


Link to post
Share on other sites
17 hours ago, MasterMoes said:

I think these scripts are made for overworld encounters

So you want this for random encounters?

Add this to the bottom of my script. It will work with yanfly's save engine.

class Scene_File < Scene_MenuBase
  def on_file_ok
    if R2_Save_Block::Blocked.include?(@file_window.index) && SceneManager.scene_is?(Scene_Save)
      Sound.play_buzzer
      @file_window.activate
    else
      @action_window.activate
      index = SceneManager.scene_is?(Scene_Load) ? 0 : 1
      @action_window.select(index)
    end
  end
end

 

Edited by roninator2

Share this post


Link to post
Share on other sites

I'm saying I think these scripts only work properly when it's a random encounter battle. That extra chunk of script didn't change anything sadly.

Look, if you really want to help me, tell me how to add a simple fade-to-black transition after using the "Battle Retry" option in Theo's script:

# =============================================================================
# TheoAllen - Gameover Choice + Battle Retry
# Version : 2.1
# Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
# Requester : Darken (RMID) / Agus Widhiantara (FB)
# (This script documentation is written in informal indonesian language)
# =============================================================================
($imported ||= {})[:Theo_GChoice] = true
# =============================================================================
# Change Logs:
# -----------------------------------------------------------------------------
# 2014.02.11 - Compatibility with TSBS
# 2013.11.29 - Finished version 2.0
# 2013.02.26 - Finished version 1.0
# =============================================================================
=begin

  Perkenalan :
  This script adds options during gameover in the form of Battle Retry and
  returns to the game last checkpoint
  
  Cara penggunaan :
  Put this script under material but above main.
  To use checkpoint, use script call:
  
  $game_system.save_checkpoint
  $game_system.load_checkpoint
  
  From the name, you can see which one to save the checkpoint and which one to
  load.
  
  Terms of use :
  Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  dipake buat komersil, jangan lupa, gw dibagi gratisannya.        

=end
# =============================================================================
# Konfigurasi
# =============================================================================
module Theo
  module GC
  # ---------------------------------------------------------------------------
  # Vocab untuk command di dalam window
  # ---------------------------------------------------------------------------
    VocabRetry  = "Battle Retry"      # Untuk battle retry
    VocabCP     = "Last Checkpoint"   # Untuk checkpoint
    VocabTitle  = "To title"          # Untuk ke title
  # ---------------------------------------------------------------------------
    Width       = 200  # Lebar window gameover choice
  # ---------------------------------------------------------------------------
  end
end
# =============================================================================
# Akhir dari konfigurasi
# =============================================================================
class Game_System
  class CheckPoint
    attr_accessor :x
    attr_accessor :y
    attr_accessor :map_id
    attr_accessor :d
    attr_accessor :dumped_party
    attr_accessor :dumped_actors
    
    def initialize
      @x = $data_system.start_x
      @y = $data_system.start_y
      @map_id = $data_system.start_map_id
      @d = 2
      @dumped_party = nil
      @dumped_actors = []
    end
  end
  
  attr_reader :checkpoint
  
  alias theo_gchoice_init initialize
  def initialize
    theo_gchoice_init
    @checkpoint = CheckPoint.new
  end
  
  def save_checkpoint
    if $game_party.in_battle
      return 
    end
    checkpoint.x = $game_player.x
    checkpoint.y = $game_player.y
    checkpoint.map_id = $game_map.map_id
    checkpoint.d = $game_player.direction
    checkpoint.dumped_party = copy($game_party) 
    $game_party.members.each do |member|
      checkpoint.dumped_actors[member.id] = copy(member)
    end
  end
  
  def load_checkpoint
    $game_map.setup(checkpoint.map_id)
    $game_player.moveto(checkpoint.x, checkpoint.y)
    $game_player.set_direction(checkpoint.d)
    $game_party = checkpoint.dumped_party if checkpoint.dumped_party
    checkpoint.dumped_actors.each_with_index do |dump_actor, id|
      next if dump_actor.nil?
      $game_actors[id] = dump_actor
    end
    SceneManager.clear
    SceneManager.goto(Scene_Map)
  end
  
end

class Game_Temp
  class Last_Troop
    attr_accessor :id
    attr_accessor :can_lose
    attr_accessor :can_escape
    def initialize
      @id = 0
      @can_lose = false
      @can_escape = true
    end
  end
  
  attr_accessor :dumped_party
  attr_accessor :battle_retry
  attr_accessor :actor_fibers
  attr_reader :dumped_actors
  attr_reader :last_troop
  
  alias theo_gchoice_init initialize
  def initialize
    theo_gchoice_init
    @battle_retry = false
    @last_troop = Last_Troop.new
    @dumped_actors = []
    @dumped_party = nil
  end
end

class Game_Actor < Game_Battler
  
  def save_actor
    $game_temp.dumped_actors[id] = copy(self)
  end
  
  def load_actor
    $game_actors[id] = copy($game_temp.dumped_actors[id])
  end
  
  alias theo_gchoice_bstart on_battle_start
  def on_battle_start
    theo_gchoice_bstart
    $game_temp.battle_retry ? load_actor : save_actor
  end
  
end

class Game_Actors
  
  def []=(id, actor)
    @data[id] = actor
  end
  
end

class Game_Party < Game_Unit
  
  def save_party
    $game_temp.dumped_party = copy(self)
  end
  
  def load_party
    $game_party = copy($game_temp.dumped_party)
  end
  
  alias theo_gchoice_bstart on_battle_start
  def on_battle_start
    theo_gchoice_bstart
    $game_temp.battle_retry ? load_party : save_party
  end
  
end

class << BattleManager
  
  alias theo_gchoice_setup setup
  def setup(troop_id, can_escape = true, can_lose = false)
    theo_gchoice_setup(troop_id, can_escape, can_lose)
    $game_temp.last_troop.id = troop_id
    $game_temp.last_troop.can_escape = can_escape
    $game_temp.last_troop.can_lose = can_lose
  end
  
  def battle_retry
    troop_id = $game_temp.last_troop.id
    can_escape = $game_temp.last_troop.can_escape
    can_lose = $game_temp.last_troop.can_lose
    theo_gchoice_setup(troop_id, can_escape, can_lose)
    Sound.play_battle_start
    play_battle_bgm
  end
  
  alias theo_gchoice_replay_music replay_bgm_and_bgs
  def replay_bgm_and_bgs
    begin
      theo_gchoice_replay_music
    rescue
      $game_map.autoplay
    end
  end
  
end

class Window_GOChoice < Window_Command
  
  def initialize
    super(0,0)
    update_placement
    self.openness = 0
    activate
  end
  
  def make_command_list
    add_command(Theo::GC::VocabRetry, :retry)
    add_command(Theo::GC::VocabCP, :checkpoint, $game_system.checkpoint)
    add_command(Theo::GC::VocabTitle, :title)
  end
  
  def update_placement
    self.x = (Graphics.width - width)/2
    self.y = (Graphics.height * 1.6 - height) / 2
  end
  
  def window_width
    Theo::GC::Width
  end
  
end

class Scene_Gameover < Scene_Base
  
  alias theo_gchoice_start start
  def start
    theo_gchoice_start
    @command_window = Window_GOChoice.new
    @command_window.set_handler(:retry, method(:battle_retry))
    @command_window.set_handler(:checkpoint, method(:goto_checkpoint))
    @command_window.set_handler(:title, method(:goto_title))
    @command_window.open
  end
  
  def battle_retry
    RPG::ME.stop
    BattleManager.battle_retry
    $game_temp.battle_retry = true
    SceneManager.goto(Scene_Battle)
    close_command
  end
  
  def goto_checkpoint
    RPG::ME.stop
    $game_system.load_checkpoint
    $game_map.autoplay
    close_command
  end
  
  def close_command
    @command_window.close
    update_basic until @command_window.close?
  end
  # ----------------------------------------
  # Overwrites
  # ----------------------------------------
  def update
    super
  end
  
end

class Scene_Battle
  
  alias theo_gchoice_bt_start battle_start
  def battle_start
    theo_gchoice_bt_start
    if $game_temp.battle_retry && $imported[:TSBS]
      recreate_spriteset
    else
      $game_temp.battle_retry = false
    end
  end
  
  def recreate_spriteset
    @spriteset.dispose
    create_spriteset
    $game_temp.battle_retry = false
  end
  
end

def copy(object)
  Marshal.load(Marshal.dump(object))
end

EDIT: I think a transition should go in between lines 254 and 255?

Edited by MasterMoes

Share this post


Link to post
Share on other sites
8 hours ago, MasterMoes said:

I'm saying I think these scripts only work properly when it's a random encounter battle.

Then you are doing evented battles?

If you are using the battle processing command, then the script I posted work fine. If it doesn't for you then you have something blocking it or you are doing a full evented battle, not the normal battle.

I'll look at the script since you seem to be focused on only using that one.

MasterMoes said:

I think a transition should go in between lines 254 and 255?

 

You seem to have figured it out already.

So are you just not sure what command to put in there to do a fade?

just add fadeout_all

Edited by roninator2

Share this post


Link to post
Share on other sites
Quote

just add fadeout_all

Ohhh THAT'S what I needed! I didn't even know a "fade all" command existed. Thanks a lot for your help, the retry battle scene looks smooth!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted