• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Staff applications for our PokéCommunity Daily and Social Media team are now open! Interested in joining staff? Then click here for more info!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Transport player using Key item

  • 65
    Posts
    11
    Years
    • Seen Jan 4, 2022
    I have already defined the item and assigned an image.

    What I am trying to do now is figure out how to make it so that using the item transports me to a certain map coordinate, in this case "Base" for all intensive purposes.

    I have seen some explanations in a few places but they are too confusing for me. Can someone dumb it down? =)
     
    I haven't tested this, but you could try calling a common event with pbCommonEvent(id of the common event) from Item_Effects in the script section
     
    Last edited:
    I was trying to do something like mimicing the Escape rode script:

    ItemHandlers::UseInField.add(:ESCAPEROPE,proc { |item|
    escape = ($PokemonGlobal.escapePoint rescue nil)
    if !escape || escape==[]
    pbMessage(_INTL("Can't use that here."))
    next 0
    end
    if $game_player.pbHasDependentEvents?
    pbMessage(_INTL("It can't be used when you have someone with you."))
    next 0
    end
    pbUseItemMessage(item)
    pbFadeOutIn {
    $game_temp.player_new_map_id = escape[0]
    $game_temp.player_new_x = escape[1]
    $game_temp.player_new_y = escape[2]
    $game_temp.player_new_direction = escape[3]
    pbCancelVehicles
    $scene.transfer_player
    $game_map.autoplay
    $game_map.refresh
    }
    pbEraseEscapePoint
    next 3
    })




    I tried doing a few tweaks to it but it keep getting errors from improper inputs when I add the coordinates to the item. Not really sure what to do to make it work. And I don't really understand the method you described either. I have a non existent knowledge of coding XD
     
    This should allow you to use an item to warp the player where ever they have their base set.
    Code:
    up    = 0
    right = 1
    down  = 2
    left  = 3
    
    ItemHandlers::UseInField.add(TRANSPORTER,proc { |item|
      if $game_player.pbHasDependentEvents?
        pbMessage(_INTL("It can't be used when you have someone with you."))
        next 0
      end
      pbUseItemMessage(item)
      player_base = $game_variables[100]
      $game_temp.player_new_map_id    = player_base[0]
      $game_temp.player_new_x         = player_base[1]
      $game_temp.player_new_y         = player_base[2]
      $game_temp.player_new_direction = player_base[3]
      pbCancelVehicles
      $scene.transfer_player
      next 2
    })

    When the player selects/obtains a base make sure you store the following information as an array (inside square brackets) in a game variable of your choosing.
    [Map_id, Cord_X, Cord_Y , Direction]
    For this example I will use game variable 100. I will warp the player to the right side of the top row of flowers in Lappet Town, and I will have the player face down.
    Code:
    $game_variables[100] = [2, 11, 12, down]
    Lappet Town is map number 2
    The X and Y coordinates to get me where I want to be placed (next to the flowers) is 11 and 12
    Now I want the player to be facing down, I can accomplish this by using the number that corresponds to the player looking down which is 2, but as an extra bonus I will make this easier. Instead of trying to remember which number means which direction all you need to do is type the direction you want.

    Hope this helps!
     
    Awesome, I definitely want to give that a try, However, im kind of stuck. How do i predetermine where the base is. For my specific situation. I am making a game where the player is a part of a Team that requires them to participate in missions. When the misisons are complete the will be returning back to their Team's base alot. I basically need the item to bring them there. If this code makes that a simple fix, how do I first establish where the base is? Thanks in advance =)
     
    Or could I reword this to bring the player to what is set as their "Home" cuz I already have that set to the team base. Would that work? Sorry I'm just not too good with coding.
     
    Ideally you would have a script right after giving the player the Transporter.
    Code:
    $game_variables[100]=[Map_id, Cord_X, Cord_Y, Direction]

    However if you are going to use only 1 spot to transport the player to for the whole duration of your game then you could just add the information directly into the script like this to avoid having to deal with variable manipulation.

    Code:
    ItemHandlers::UseInField.add(TRANSPORTER,proc { |item|
      if $game_player.pbHasDependentEvents?
        pbMessage(_INTL("It can't be used when you have someone with you."))
        next 0
      end
      pbUseItemMessage(item)
      $game_temp.player_new_map_id    = Map_id
      $game_temp.player_new_x         = Cord_X
      $game_temp.player_new_y         = Cord_Y
      $game_temp.player_new_direction = Direction
      pbCancelVehicles
      $scene.transfer_player
      next 2
    })

    If you're wondering how to determine what your transport information is, then the first step would be to make the map that you want to warp the player to at the end of each mission. Doing so will give you your Map_id, once you are done with the layout of the map you can use the coordinates in the lower right section of RPG Maker XP to see the Cord_X and Cord_Y of spot you want the player to appear. The direction the player is facing is entirely up to you.

    If you still need further help then feel free to send me a DM and I can try to provide images or a short video of how to set it up.

    Notes:
    While the script I gave in this post makes setting the warp point easier, the one from my earlier post is much more flex able allowing the transport location to be changed mid-game for such events like the base has been burned down and the team has to move to a new location, the base could be upgraded and the player warp point be changed to a nicer room. The player could take on a mission that is so far away from the base that the transporter is out of range so you have to set up a temporary camp... So on and so forth.

    The transporter item is a very interesting concept. You could also make it not work on certain maps like being on the ocean floor or deep in a cavern where the signal isn't strong enough to warp the player from those locations, or add a game switch to the transporter to disable it to create an event where a spy/member of a different team sets up a jammer disabling the player from using the transporter on maps that they could previously.
     
    Wow, thanks so much! I really appreciate the time you took to explain that to me! I'll give that a shot!
     
    OK I have one last question for you if you wouldn't mind. Is there a way to tie in an animation to this script? For instance I created an animation that I would use during cut scenes to represent a teleportation. Could I tie that animation in with the script to play over the player when the item is used and as the player arrives to their destination?
     
    Back
    Top