Respawn script

Jacoh

Villager
Member
Joined
Dec 14, 2017
Messages
8
Reaction score
3
First Language
Italian
Primarily Uses
RMVXA
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 '^'
 
Last edited:

vFoggy

Veteran
Veteran
Joined
Nov 3, 2012
Messages
71
Reaction score
31
Primarily Uses
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.
 

Jacoh

Villager
Member
Joined
Dec 14, 2017
Messages
8
Reaction score
3
First Language
Italian
Primarily Uses
RMVXA
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..
 
Last edited:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,661
Reaction score
563
First Language
English
Primarily Uses
RMVXA
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?
 

vFoggy

Veteran
Veteran
Joined
Nov 3, 2012
Messages
71
Reaction score
31
Primarily Uses
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?
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,661
Reaction score
563
First Language
English
Primarily Uses
RMVXA
@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.
 
Last edited:

vFoggy

Veteran
Veteran
Joined
Nov 3, 2012
Messages
71
Reaction score
31
Primarily Uses
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

"You can thank my later", "But you haven't done anything", "Well, that's why ..."
Are we allowed to post about non-RPG Maker games?
I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

Forum statistics

Threads
105,884
Messages
1,017,243
Members
137,609
Latest member
shododdydoddy
Top