Transfer player instantly right after map-transfer?

I am trying to relocate the player to another location on the same map right after the player entered the map and before the screen fades in. This is what I got:

note: use map-notetag like: <auto-loc: 10,10>

#===============================================================================# Module Nap::Transfer#===============================================================================module Nap module Transfer module Conf MAP_AUTO_LOC_REGEX = /<auto-loc🙁(.*?))>/ix end endend#===============================================================================# Class Game Map#===============================================================================class Game_Map alias nap_transfer_auto setup def setup(nid) nap_transfer_auto(nid) # Analyse the map-notetag and find out where the player needs to be # transferred to as well as his (new) facing direction. note_lines = note.split(/\n/) new_location = nil note_lines.each { |l| if l.delete(' ') =~ Nap::Transfer::Conf::MAP_AUTO_LOC_REGEX new_location = $1.split(',') new_location[0] = new_location[0].to_i new_location[1] = new_location[1].to_i if new_location.length == 3 new_location[2] = new_location[2].to_i else new_location[2] = $game_player.direction end break end } # Perform the transfer if !new_location.nil? $game_player.moveto(new_location[0], new_location[1]) # printing player location here shows that the player has indeed been moved. # <<<<<<<<<<<<<<<<<< $game_player.set_direction(new_location[2]) # printing player location here shows that the player has indeed been moved. # <<<<<<<<<<<<<<<<<< end endendThe problem is that he is moved back by the original code after I put him on the correct location... But I could not find the proper method to alias. If I alias too early then I can't get the map-notetag (couldn't find it through data_system or daa_mapinfos) and if I do it too late then the screen faded in. And when I do it here... it's too early again.
Isn't it easier to place a transfer player command before the screen fades in?
That's what I currently use. I use parallel processes that transfer the player right away (no fade). But I want to automate it because there are too many maps that used it + too many that will follow.

Besides, this is not gonna have any performance impact at all I believe.
What happens if you can transfer to the same map from two different places?


You should change the player's reserved transfer data instead and let the engine figure out how to perform the transfer.
I'm a little bit confused at what you're trying to do. If you want the player to go to a specific location right away, isn't it just easier to make the transfer from the first map directly to the place you want him to be on the second map?

But maybe I'm just misunderstanding this. ; o ;
Go to Game_Player.

#-------------------------------------------------------------------------- # * Execute Player Transfer #-------------------------------------------------------------------------- def perform_transfer if transfer? set_direction(@new_direction) if @new_map_id != $game_map.map_id $game_map.setup(@new_map_id) $game_map.autoplay end # here check if there is a designated standard position # (designated by you) for the curretn map id and change # move_to(x, y) accordingly moveto(@new_x, @new_y) clear_transfer_info end endCheers.
I found another method to alias. It works but parallel events still execute before the player is being moved... I used Game_Map.setup_events.

Yes I tried altering the transfer data as well (before I tried this actually). The problem is that the transfer is done BEFORE the map is loaded into memory (via Scene_Map > Player.perform...). So basically I have no map-notetag with this approach.

I'm kinda out of ideas... Maybe I misunderstood something but I don't know why the player is transferred to the map before the map itself is loaded into memory...

I could always resort to parallel events for setting the player location again. But.. A script would be a cleaner solution for me.

@TeaPatti:

- I have map x.

- Then I have map y.

- I want to transfer from map x to map y.

- I copy map y 20 times for cut-scenes (with different starting locations). Because RM does not have 'derived maps' and putting all your cut-scenes into the same map can create one huge mess once multiple events need to cover the same square (loads of even pages)...

- I now have to change the transfer event in map x with 20 if-conditions.

- It get's worse when you don't have 1 map x but 10 maps. Especially if I add another map y... Then I have to backtrack them all and change them all.

- And the above can be multiplied again and again in certain other scenarios as you can imagine, creating enormous if-conditionals and such.

Yes I do need if-conditionals to find out what cut-scene to send the player too. Those are scripted... Maybe I could add the starting location there...

In my game the same map can have many cut-scenes with many different starting locations.

@breaking_owl

Doesn't work because the map-notetag is unknown at that point.

Update:

Maybe I need a different approach. Currently handling a load of cut-scenes and to maintain the changes made in the original map is such a pain.
In your first post, you aliased setup method from Game_Map, and that method is called before the comment I did to point out where you should write your code. You should be able to get the map notetag there. Try it.
Ah I see the problem:

p "new: #{@new_map_id} old: #{$game_map.map_id}" p "current: #{$game_map.map_id}"So the new map is loaded into memory. But the $game_map is still the old map. So I was retrieving the wrong map-note resulting in a nil value as if the map was never loaded.

But where is the reference to the new map at this stage?

Maybe I should just commission this stuff. I'm not as good as I used to be anymore... Not even close...
Put this code and playtest a player transfer to any map.

def perform_transfer if transfer? set_direction(@new_direction) p $game_map.map_id if @new_map_id != $game_map.map_id $game_map.setup(@new_map_id) $game_map.autoplay end p $game_map.map_id moveto(@new_x, @new_y) clear_transfer_info end endThe setup method from game map was already executed before moveto(@new_x, @new_y)

So why don't you do something like...

#-------------------------------------------------------------------------- # * Execute Player Transfer #-------------------------------------------------------------------------- def perform_transfer if transfer? set_direction(@new_direction) p $game_map.map_id if @new_map_id != $game_map.map_id $game_map.setup(@new_map_id) $game_map.autoplay end p $game_map.map_id # Analyse the map-notetag and find out where the player needs to be # transferred to as well as his (new) facing direction. note_lines = note.split(/\n/) new_location = nil note_lines.each { |l| if l.delete(' ') =~ Nap::Transfer::Conf::MAP_AUTO_LOC_REGEX new_location = $1.split(',') new_location[0] = new_location[0].to_i new_location[1] = new_location[1].to_i if new_location.length == 3 new_location[2] = new_location[2].to_i else new_location[2] = $game_player.direction end break end } # Perform the transfer if !new_location.nil? moveto(new_location[0], new_location[1]) # printing player location here shows that the player has indeed been moved. # <<<<<<<<<<<<<<<<<< set_direction(new_location[2]) # printing player location here shows that the player has indeed been moved. # <<<<<<<<<<<<<<<<<< else moveto(@new_x, @new_y) end clear_transfer_info end endWhat are you using to get the note?
$game_map.setup(@new_map_id) .. of course there it is being set.. I'm so blind! That will update the data in the game_map class.

Sadly the code has to be inserted in the middle of perform_transfer. Because I don't want to overwrite anything and want an alias instead I went for this (which seems to work but sadly the player is moved twice):

Spoiler
Code:
#===============================================================================# Module Nap::Transfer#===============================================================================module Nap  module Transfer    module Conf      MAP_AUTO_LOC_REGEX = /<auto-loc:((.*?))>/ix    end  endendclass Game_Player < Game_Character  alias nap_transfer_auto_loc_perform_transfer perform_transfer  def perform_transfer    return if !transfer?    nap_transfer_auto_loc_perform_transfer        if @new_map_id != $game_map.map_id      new_location = $game_map.get_transfer_auto_loc_note      return if new_location.nil?      moveto(new_location[0], new_location[1])      set_direction(new_location[2])    end  end  end#===============================================================================# Class Game Map#===============================================================================class Game_Map  def get_transfer_auto_loc_note    # Analyse the map-notetag and find out where the player needs to be    # transferred to as well as his (new) facing direction.    note_lines = note.split(/\n/)    new_location = nil    note_lines.each { |l|      if l.delete(' ') =~ Nap::Transfer::Conf::MAP_AUTO_LOC_REGEX        new_location = $1.split(',')        new_location[0] = new_location[0].to_i        new_location[1] = new_location[1].to_i        if new_location.length == 3          new_location[2] = new_location[2].to_i        else          new_location[2] = $game_player.direction        end        break      end    }    return new_location  endend

Original thread: https://forums.rpgmakerweb.com/threads/transfer-player-instantly-right-after-map-transfer.25705/