#===============================================================================
#
# 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