[RMXP] Restarting battles via an item/skill?

Started by Shrimpses, December 11, 2022, 07:49:28 pm

Previous topic - Next topic

Shrimpses

Hi there, I'm here with a request! (It's an add-on for the standard XP battle system, by the way).

So, I've been playing some Dragon Quest lately, and there's a recurring item in that series called the "Sands of Time." Using it in battle lets you "turn back time" and fully reset the battle back to the start, the way things were on Turn 1. I'd love to have something like that in my game as well!

I was able to find a simple "Retry Battle" script elsewhere, so it seems to be possible... but that version only triggers when you get a Game Over. I'd like for it to be an ability you can use on command, either via an item or skill, whichever is easier!

Thanks so much to anyone who can help!  :^_^': 



KK20

December 16, 2022, 01:25:49 am #1 Last Edit: December 16, 2022, 01:29:51 am by KK20
Paste this script below the defaults, above Main, as typical
class Scene_Battle
  alias main_after_cloning_globvars main
  def main
    @_cloned_global_vars = [
    Marshal.dump($game_system),
    Marshal.dump($game_switches),
    Marshal.dump($game_variables),
    Marshal.dump($game_self_switches),
    Marshal.dump($game_screen),
    Marshal.dump($game_actors),
    Marshal.dump($game_party),
    Marshal.dump($game_troop),
    Marshal.dump($game_map),
    Marshal.dump($game_player)]
   
    main_after_cloning_globvars
   
    if @_restart_battle
      $game_system = Marshal.load(@_cloned_global_vars.shift)
      $game_switches = Marshal.load(@_cloned_global_vars.shift)
      $game_variables = Marshal.load(@_cloned_global_vars.shift)
      $game_self_switches = Marshal.load(@_cloned_global_vars.shift)
      $game_screen = Marshal.load(@_cloned_global_vars.shift)
      $game_actors = Marshal.load(@_cloned_global_vars.shift)
      $game_party = Marshal.load(@_cloned_global_vars.shift)
      $game_troop = Marshal.load(@_cloned_global_vars.shift)
      $game_map = Marshal.load(@_cloned_global_vars.shift)
      $game_player = Marshal.load(@_cloned_global_vars.shift)
    end
  end
 
  def restart_battle
    @_restart_battle = true
    $scene = Scene_Battle.new
  end
 
end

Make a new Common Event, in which you just put a solitary script call:
$scene.restart_battle
As for configuring the skill/item, first make a dummy State. I gave it no name and checked "Nonresistance". Go to your skill/item and make it target the user, have 0 power, and apply that dummy state. This will effectively remove the "Miss!" pop-up. And then make it call the Common Event you just created.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Shrimpses

As always KK20, you are an absolute legend! It works perfectly, thank you so much! :clap: