RETRY BATTLE

RPG Maker VX Ace

This script allows you to restart battles exactly as they were when you started.

  • TDS
  • 06/18/2013 10:37 PM
  • 12438 views
Version:1.0

Introduction
This script allows you to restart battles exactly as they were when you started.

Features
- Restart battle from a command.
- Restart battle after defeat.

Screenshots





Instructions
Instructions are on the script.

Thanks
BanisherOfEden for testing.

Restrictions
Only for use in non-commercial games.

Posts

Pages: 1
THANK YOU

never need to deal with people moaning about not saving before battles now and having to watch cutscenes again
Exactly the same reason I had to create this script.

And you would think that saving would be a priority and if you fail you would accept your failure, but people are too used to hand holding nowadays and don't expect or want consequences for their actions or lack of actions (and of course they also don't want games to be "easy" or boring either).
author=TDS
Exactly the same reason I had to create this script.

And you would think that saving would be a priority and if you fail you would accept your failure, but people are too used to hand holding nowadays and don't expect or want consequences for their actions or lack of actions (and of course they also don't want games to be "easy" or boring either).


I want a bumper sticker with that on it.
What's the point to this script, I pasted it into the RPG maker scripts section and nothing happens

How about providing instructions for using this and giving an example of how once this is in the RPG maker how to access and use it
Umm..., I'm sorry to bother you, but every time I try to retry a battle, an error message pops up saying 'Disposed window.' Can you help me fix this? I'm using scripts, if that's any help...
author=Legomaster0911
Umm..., I'm sorry to bother you, but every time I try to retry a battle, an error message pops up saying 'Disposed window.' Can you help me fix this? I'm using scripts, if that's any help...

It's no bother, just let me know which window is the one with the dispose error and if you're using any other scripts which affect the Scene_Battle or Window classes in any way and I'll see what I can do to help you.
I'm sorry, could you explain that to me? I'm a script newbie. However, the scripts that affect battle for me are the Yanfly Battle Engine, the YSA ATB system, the Game over commands from soulpour, and your script.
author=TDS
author=Legomaster0911
Umm..., I'm sorry to bother you, but every time I try to retry a battle, an error message pops up saying 'Disposed window.' Can you help me fix this? I'm using scripts, if that's any help...
It's no bother, just let me know which window is the one with the dispose error and if you're using any other scripts which affect the Scene_Battle or Window classes in any way and I'll see what I can do to help you.


Please explain to me the 'which window' part. I can give the line of code that's causing me trouble. I tried deleting it and it crashed my game. Here's the line: 'item_rect_width = (status_window.width-24) / $game_party.max_battle_members' It's on the Yanfly Engine Ace - Ace Battle Engine v1.22 if that's any help...
iirc the script isn't compatible with Yanfly's battle script. If you open the battle retry and look for:
#--------------------------------------------------------------------------
  # * [Retry] Start Processing
  #--------------------------------------------------------------------------
  def retry_start
    create_spriteset
    create_all_windows  
  end


and swap the create_spriteset and create_all_windows to:
#--------------------------------------------------------------------------
  # * [Retry] Start Processing
  #--------------------------------------------------------------------------
  def retry_start
    create_all_windows  
    create_spriteset
  end

That will fix the issue with no detrimental effect on the script.
GreatRedSpirit, that solved the crash issue, but there's another problem. Every time I reset, it just puts me back to the 'Hero was defeated' message, and shows me the retry menu.. Any idea how to fix that?
Sounds like another script incompatibility. I'd turn off (cut+paste below the 'Main' script, I think somebody made a script that made this easier though) other scripts until you can narrow down what script exactly is causing the problem. I can look at it more from there.
Weird, I don't remember having that issue and I use this with Yanfly's battle script too. I'll take another poke at it later tonight and whip up a demo project to test / confirm that it works.


I know I changed the retry script so that when you don't retry a battle the player respawns at the last inn (aka a set of variables of mapID/X/Y), I wonder if I fixed my copy by adding that?
YSA Battle System: Classical ATB could also cause the problem. It affects the battle system in my game.
Oh god damnit, now I see what it is. TDS's script marshals the $game_temp instance as a quick and easy means of doing a deep copy on it for purposes of restoring the player's status. Yanfly's battle engine for some reason puts a reference to the iconset in the same $game_temp instance and bitmaps don't have a means to be marshaled.

On ~line 1094 of Yanfly's script there should be:
class Game_Temp
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :battle_aid
  attr_accessor :evaluating
  attr_accessor :iconset
  
  #--------------------------------------------------------------------------
  # alias method: initialize
  #--------------------------------------------------------------------------
  alias game_temp_initialize_abe initialize
  def initialize
    game_temp_initialize_abe
    @iconset = Cache.system("Iconset")
  end
  
end # Game_Temp

Remove all references to the iconset, so the attr_accessor :iconset and @iconset = Cache.system lines.

(you can probably remove the entire initialize method since it does nothing now)

Then ~line 971 there should be this line:
icon_bitmap = $game_temp.iconset

Replace it with:
icon_bitmap = Cache.system("Iconset")


This might have an effect on YF's other scripts if it decides to try and reuse the iconset reference. I have no idea why this was done unless the Cache call is more intensive than it should be which, with RPG Maker, you can never be sure of.

I can't test with the ATB script because it crashes the game when I use it and I don't feel like finding what I need to configure to make it work out of the box. This was without the retry script too. Here's my test project. The DOOM Slime will kill you on the second turn which triggers the retry correctly.
author=GreatRedSpirit
Oh god damnit, now I see what it is. TDS's script marshals the $game_temp instance as a quick and easy means of doing a deep copy on it for purposes of restoring the player's status. Yanfly's battle engine for some reason puts a reference to the iconset in the same $game_temp instance and bitmaps don't have a means to be marshaled.


First, thank you very much for all the help you've provided. You seem to understand the problem much better than myself so I just let it up to you and kept reading in case there was something I could do to help, also I doubt I could have been as helpful as you have been.

As for the problem of bitmaps and dumping them, if the dumping into game_temp is vital to the other script then this little snippet of code should allow the bitmap class to be dumped without need to change any other script.

#==============================================================================
# ** Font
#------------------------------------------------------------------------------
#  This class handles Font contents and properties
#==============================================================================
 
class Font
  #--------------------------------------------------------------------------
  # * Font Marshal Dump
  #--------------------------------------------------------------------------  
  def marshal_dump ; end
  #--------------------------------------------------------------------------
  # * Font Marshal Load
  #--------------------------------------------------------------------------      
  def marshal_load(obj) ; end
end


#==============================================================================
# ** Bitmap
#------------------------------------------------------------------------------
#  This class handles Bitmap contents and properties
#==============================================================================

class Bitmap 
  #--------------------------------------------------------------------------
  # * Constants (Win32Api)
  #--------------------------------------------------------------------------  
  RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
  #--------------------------------------------------------------------------
  # * Dump
  #--------------------------------------------------------------------------
  def _dump(limit)
    data = "rgba" * width * height
    RtlMoveMemory_pi.call(data, address, data.length)
    [width, height, Zlib::Deflate.deflate(data)].pack("LLa*")
  end
  #--------------------------------------------------------------------------
  # * Load
  #--------------------------------------------------------------------------
  def self._load(str)
    w, h, zdata = str.unpack("LLa*"); b = new(w, h)
    RtlMoveMemory_ip.call(b.address, Zlib::Inflate.inflate(zdata), w * h * 4); b
  end
  #--------------------------------------------------------------------------
  # * Address
  #--------------------------------------------------------------------------
  def address
    buffer, ad = "xxxx", object_id * 2 + 16
    RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 8
    RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 16
    RtlMoveMemory_pi.call(buffer, ad, 4); return buffer.unpack("L")[0]
  end
end
Glad to help :) I had the same problem as Legomaster three months ago and I spent some time finding out what it took to get the two scripts to work together. Helping others fix the problem is a lot easier when you already know the solution (just had to remember the iconset problem, I was trying to remember what changes I made to the battle retry script while forgetting that I had to change the battle script too!)
Pages: 1