[RMXP] Transition when Escape or win a Battle

Started by PrinceEndymion88, October 20, 2022, 04:01:52 am

Previous topic - Next topic

PrinceEndymion88

In the standard Battle System, when a battle end or when Escape there is a standard fade out transition. Is it possible to show the same transition specified in System -> Battle transition graphic ?

Thanks :)

KK20

The transition effect plays on the scene you're switching over to. So when leaving the battle scene, you're probably heading back to the map scene. Thus we need to introduce our code changes to Scene_Map.

You should already be aware that this is what we need to change in Scene_Map:
    # Transition run
    Graphics.transition

In Scene_Battle, it handles the transition like so
    # Execute transition
    if $data_system.battle_transition == ""
      Graphics.transition(20)
    else
      Graphics.transition(40, "Graphics/Transitions/" +
        $data_system.battle_transition)
    end

We need to copy some of this over, but we also need to make Scene_Map aware that we're coming from Scene_Battle.

I would suggest adding a new method to Scene_Map:
  def initialize(last_scene = nil)
    @_last_scene = last_scene
  end
Replace the Graphics.transition code called out above with this:
    # Transition run
    if @_last_scene == :battle
      if $data_system.battle_transition == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
          $data_system.battle_transition)
      end
    else
      Graphics.transition
    end
Then find "def battle_end" in Scene_Battle 1 and make the following change:
    # Switch to map screen
    $scene = Scene_Map.new(:battle)

All of this assumes you're using the default scripts, of course.

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!

PrinceEndymion88

Oh, thanks! I considered only scene_battle script and, obviously, it didn't work! 😅 Now it works properly 😊 again, thanks!