Respawn script

Hello there, i'd like to use a script for my game that allows the actor to not die and just teleport to a specific point..
If that is not possible, i would like to just use a script that removes the GAME OVER screen.
Any help is appreciated!

EDIT: i'm using the random encounter for battles '^'
Here:
Code:
#===============================================================================
#
# Script Name: Checkpoint Respawn
# Author: vFoggy
# Description:
#   Simply respawns the player at the location where the $game_player.checkpoint
#   was called, instead of going to the Game Over screen. Revives all party
#   members upon respawning.
#
#===============================================================================

# if true then last checkpoint is removed when the player respawns and
# $game_player.checkpoint has to be called again
REMOVE_CHECKPOINT_ON_RESPAWN = true

module SceneManager
  class <<self
      def transfer_to_checkpoint
        check_point_data = $game_player.respawn_data
        map_id = check_point_data[0]
        x = check_point_data[1]
        y = check_point_data[2]
        direction = check_point_data[3]
        $game_player.reserve_transfer(map_id, x, y, direction)
        $game_temp.fade_type = 0
        $game_player.reset_checkpoint if REMOVE_CHECKPOINT_ON_RESPAWN
        $game_party.revive_all
      end
      
      alias fog_gt goto
      def goto(scene_class)
        if scene_class == Scene_Gameover && !$game_player.respawn_data.empty?
          transfer_to_checkpoint
        else
          fog_gt(scene_class)
        end
      end
  end 
end

class Game_Player < Game_Character
  attr_reader :respawn_data
  alias fog_init initialize
  def initialize
    fog_init
    @respawn_data = []
  end
 
  def checkpoint
    @respawn_data = [$game_map.map_id, x, y, direction]
  end
 
  def reset_checkpoint
    @respawn_data = []
  end
end

class Game_Party < Game_Unit
  def revive_all
    for actor_id in @actors
      $game_actors[actor_id].revive
      $game_actors[actor_id].refresh
    end
  end
end
Simply call
Code:
$game_player.checkpoint
where you want the player to respawn.
If you want any modifications let me know.
Uhm.. i dont think that i know how to call the code
"$game_player.checkpoint"
Tell me if i did something wrong:
- i copy/pasted the script in the main process section
- i created an event on a tile and i clicked on "script"
- then i wrote the code that you told me
--------------------------------------------------------
I did the actions above and it seems that the script doesn't work.. it just sends me in the game over screen

EDIT: no wait, now it works, i just had to set the event on "parallel process"
but i dont know how to set the coordinates..
i dont know how to set the coordinates.
That is all collected by the script. The position your player is in is the position you will be returned to.
@respawn_data = [$game_map.map_id, x, y, direction]

You may be able to use variables if you want the location to be a spot of your choosing.
@respawn_data = [$game_map.map_id, $game_variables[X], $game_variables[Y], direction]
put in the variable numbers you want to use in the X and Y .
Or you could just use specific numbers
@respawn_data = [$game_map.map_id, 5, 8, direction]

You could even use a local variable to specify which map if it was to change or put in a specific map number
mapnum = $game_map.map_id
or
mapnum = $game_variables[mapid]
@respawn_data = [mapnum, 7, 7, 2]

There are many options. How do you want it to work?
Uhm.. i dont think that i know how to call the code
"$game_player.checkpoint"
Tell me if i did something wrong:
- i copy/pasted the script in the main process section
- i created an event on a tile and i clicked on "script"
- then i wrote the code that you told me
--------------------------------------------------------
I did the actions above and it seems that the script doesn't work.. it just sends me in the game over screen

EDIT: no wait, now it works, i just had to set the event on "parallel process"
but i dont know how to set the coordinates..
Doesn't seem that you're doing something wrong/
If you want to set a specific location when calling $game_player.checkpoint, you can use this version of the script:
Code:
#===============================================================================
#
# Script Name: Checkpoint Respawn
# Author: vFoggy
# Description:
#   Simply respawns the player at the location where the $game_player.checkpoint
#   was called, instead of going to the Game Over screen. If you want a specific
#   location and map, you can call:
#           $game_player.checkpoint(map_id, x, y, direction)
#   where direction it's:
#       2 for down, 8 for up, 4 for left and 6 for right or skip to maintain
#
#   Revives all party members upon respawning.
# 
#
#===============================================================================

# if true then last checkpoint is removed when the player respawns and
# $game_player.checkpoint has to be called again
REMOVE_CHECKPOINT_ON_RESPAWN = true

module SceneManager
  class <<self
      def transfer_to_checkpoint
        check_point_data = $game_player.respawn_data
        map_id = check_point_data[0]
        x = check_point_data[1]
        y = check_point_data[2]
        direction = check_point_data[3]
        $game_player.reserve_transfer(map_id, x, y, direction)
        $game_temp.fade_type = 0
        $game_player.reset_checkpoint if REMOVE_CHECKPOINT_ON_RESPAWN
        $game_party.revive_all
      end
    
      alias fog_gt goto
      def goto(scene_class)
        if scene_class == Scene_Gameover && !$game_player.respawn_data.empty?
          transfer_to_checkpoint
        else
          fog_gt(scene_class)
        end
      end
  end
end

class Game_Player < Game_Character
  attr_reader :respawn_data
  alias fog_init initialize
  def initialize
    fog_init
    @respawn_data = []
  end
 
  def checkpoint
    @respawn_data = [$game_map.map_id, x, y, direction]
  end
 
  def checkpoint(map_id, x, y, direction=-1)
    d = direction == -1 ? self.direction : direction
    @respawn_data = [map_id, x, y, d]
  end
 
  def reset_checkpoint
    @respawn_data = []
  end
end

class Game_Party < Game_Unit
  def revive_all
    for actor_id in @actors
      $game_actors[actor_id].revive
      $game_actors[actor_id].refresh
    end
  end
end
The script call is:
Code:
$game_player.checkpoint(map_id, x, y)
If it still doesn't work then there seems to be a conflict with another script.
@Rorinator2, did it work for you?
@Rorinator2, did it work for you?
spelled my name wrong, didn't get a notification.
Actually haven't tried it. Wasn't something I will use at some point. I have a similar script that was made for me a year ago.
I wasn't allowed to share it, but I just realized that I shared it by accident with the script archive I uploaded to Archeia.
Let me throw it into a test project.

*EDIT - Doesn't seem to work for me. The battle just stops when you lose. The screen doesn't go back to the map.

*EDIT2 - Works fine if you call a game over.
spelled my name wrong, didn't get a notification.
Actually haven't tried it. Wasn't something I will use at some point. I have a similar script that was made for me a year ago.
I wasn't allowed to share it, but I just realized that I shared it by accident with the script archive I uploaded to Archeia.
Let me throw it into a test project.

*EDIT - Doesn't seem to work for me. The battle just stops when you lose. The screen doesn't go back to the map.

*EDIT2 - Works fine if you call a game over.
Oh, haha, I'm sorry.

Code:
#===============================================================================
#
# Script Name: Checkpoint Respawn
# Author: vFoggy
# Description:
#   Simply respawns the player at the location where the $game_player.checkpoint
#   was called, instead of going to the Game Over screen. If you want a specific
#   location and map, you can call:
#           $game_player.checkpoint(map_id, x, y, direction)
#   where direction it's:
#       2 for down, 8 for up, 4 for left and 6 for right
#
#   Revives all party members upon respawning.
#  
#
#===============================================================================

# if true then last checkpoint is removed when the player respawns and
# $game_player.checkpoint has to be called again
REMOVE_CHECKPOINT_ON_RESPAWN = true

module SceneManager
  class <<self
      def transfer_to_checkpoint
        check_point_data = $game_player.respawn_data
        map_id = check_point_data[0]
        x = check_point_data[1]
        y = check_point_data[2]
        direction = check_point_data[3]
        $game_player.reserve_transfer(map_id, x, y, direction)
        $game_temp.fade_type = 0
        $game_player.reset_checkpoint if REMOVE_CHECKPOINT_ON_RESPAWN
        $game_party.revive_all
      end
     
      alias fog_gt goto
      def goto(scene_class)
        if scene_class == Scene_Gameover && !$game_player.respawn_data.empty?
          self.return if self.scene_is?(Scene_Battle)
          transfer_to_checkpoint
        else
          fog_gt(scene_class)
        end
      end
  end
end

class Game_Player < Game_Character
  attr_reader :respawn_data
  alias fog_init initialize
  def initialize
    fog_init
    @respawn_data = []
  end
 
  def checkpoint
    @respawn_data = [$game_map.map_id, x, y, direction]
  end
 
  def checkpoint(map_id, x, y, direction=-1)
    d = direction == -1 ? self.direction : direction
    @respawn_data = [map_id, x, y, d]
  end
 
  def reset_checkpoint
    @respawn_data = []
  end
end

class Game_Party < Game_Unit
  def revive_all
    for actor_id in @actors
      $game_actors[actor_id].revive
      $game_actors[actor_id].refresh
    end
  end
end
This one should work.
This one should work.
yes it does.
The script works perfectly thank you so much @vFoggy and @Roninator2 !
How to download script properly
@EndriuHagrid mark it and copy&paste it to any text editor of your choice
@EndriuHagrid Are you using VX Ace?
@EndriuHagrid Are you using VX Ace?
I`m using MV. Even if I`m copy and pasting code it doesn`t working.
@EndriuHagrid This script is for VXAce only and does not work in MV, as that engine uses a completely different language.

I suggest you make a thread in Plugin Requests and tell us what you're looking for.

Closing as the OP's request was solved.

Original thread: https://forums.rpgmakerweb.com/threads/respawn-script.112761/