08-03-2021, 07:15 AM
KRandomTeleport XP
by Kyonides
Introduction


Well, now you can just use some useful script calls to let it handle the teleportation for you!


The Script
Code:
# * KRandomTeleport XP
# Scripter : Kyonides Arkanthes
# v0.2.0 - 2022-11-13
# v0.1.0 - 2021-08-22
# This scriptlet allows you to transfer a player to a random location on a given
# map. The condition is that you need to define a rectangular area first.
# You would no longer need to setup several event commands in a row there.
# * Script Calls * #
# - Send to Same Map -
# $game_player.random_transfer(MIN_X, MAX_X, MIN_Y, MAX_Y)
# - Send to Another Map -
# $game_player.random_transfer(MIN_X, MAX_X, MIN_Y, MAX_Y, MAPID)
# - Undo Random Transfer (Clears Transfer Data)
# $game_player.undo_random_transfer
# - Clear Random Transfer Data Manually!
# $game_player.clear_pre_teleport_coords
class Game_Player
def clear_pre_teleport_coords
@tp_x = nil
@tp_y = nil
@tp_map_id = nil
end
def save_last_xy_map
@tp_x = @x
@tp_y = @y
@tp_map_id = $game_map.map_id
end
def random_transfer(min_x, max_x, min_y, max_y, map_id=$game_map.map_id)
save_last_xy_map
$game_temp.player_transferring = true
$game_temp.player_new_x = rand(max_x + 1 - min_x) + min_x
$game_temp.player_new_y = rand(max_y + 1 - min_y) + min_y
$game_temp.player_new_map_id = map_id
end
def undo_random_transfer
return unless @tp_x
$game_temp.player_transferring = true
$game_temp.player_new_x = @tp_x
$game_temp.player_new_y = @tp_y
$game_temp.player_new_map_id = @tp_map_id
clear_pre_teleport_coords
end
end
Terms & Conditions
You can freely use this script, even if you are called Silly or Joe Biden, a werewolf or even Count Dracula.
Nope, Jack Dorsey, Miguel Díaz-Canel, Xi Jinping and Kim Jong-un are not allowed to even take a look at it.

I just can't bear those guys.

Include me in your game credits!
