RPG Maker Forums

Hi, been toying around with using event names to have events - and one thing I've been using that to develop is a Game_Event script where the player touching an Event called WarpA - would warp the player to point WarpB, and vice-versa.

I'm having trouble though with getting the player to warp to B, and then instantly warp back to A.
The confusing part is the Warp from B to A works like it should, but the warp from A to B does not.

I don't know how smart it is to just dump code, but this it in it's entirety.
Code:
#==============================================================================
# * 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

So what's supposed to happen is when the player touches the tile, it warps the player and sets some variables related to that warp points position. If the players x and y matches those two variables warping won't work until he's not aligned with either one or both of the coordinate variables.

It works perfectly for the B warp, but just not the A warp and its driving me nuts.

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,036
Messages
1,018,461
Members
137,821
Latest member
Capterson
Top