#==============================================================================
# * Warp Event Script
#-------------------------------------------------------------------------------
# Test: Name events to take on warp tile properties.
#==============================================================================
$player_lastwarp_x = 0
$player_lastwarp_y = 0
$player_can_warp = true
$WarpA_x = 0
$WarpA_y = 0
$WarpB_x = 0
$WarpB_y = 0
#-------------------------------------------------------------------------------
# * Game Event Class
#-------------------------------------------------------------------------------
class Game_Event < Game_Character
#----------------------------------------------------------------------------
# * Initialize
#----------------------------------------------------------------------------
alias init_warp_variables initialize
def initialize(map_id, event)
init_warp_variables(map_id, event)
create_warp_coordinates
end
#---------------------------------------------------------------------------
# * Create Warp Coordiantes
#---------------------------------------------------------------------------
def create_warp_coordinates
if @event.name == "WarpA"
$WarpA_x = @event.x
$WarpA_y = @event.y
end
if @event.name == "WarpB"
$WarpB_x = @event.x
$WarpB_y = @event.y
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias up_warp_tiles update
def update
up_warp_tiles
super()
warp_event
end
#-----------------------------------------------------------------------------
# * Touch Event Call
#-----------------------------------------------------------------------------
def warp_event
#----------------------------------------------------------------------------
# * If the players coordinates are not equal to the coordinates entered from
# warp, allow the player to warp again.
#----------------------------------------------------------------------------
if ($game_player.x != $player_lastwarp_x || $game_player.y != $player_lastwarp_y) && !$game_player.moving?
$player_can_warp = true
$player_lastwarp_x = -1
$player_lastwarp_y = -1
end
#----------------------------------------------------------------------------
# * If the players coordinates are equal to the coordinates entered from
# warp, stop the player from warping again.
#----------------------------------------------------------------------------
if ($game_player.x == $player_lastwarp_x && $game_player.y == $player_lastwarp_y)
$player_can_warp = false
end
#---------------------------------------------------------------------------
# * Warp_Obj
#---------------------------------------------------------------------------
if @event.x == $game_player.x && @event.y == $game_player.y && $player_can_warp && $game_player.stopping?
if @event.name == "WarpA"
$player_lastwarp_x = $WarpB_x
$player_lastwarp_y = $WarpB_y
$game_player.reserve_transfer(@map_id, $WarpB_x, $WarpB_y, $game_player.direction)
end
if @event.name == "WarpB"
$player_lastwarp_x = $WarpA_x
$player_lastwarp_y = $WarpA_y
$game_player.reserve_transfer(@map_id, $WarpA_x, $WarpA_y, $game_player.direction)
end
end
end
end