Map Transfer Auto Events

Map Transfer Auto Events 1.0
Shaz
​
Introduction
This script lets you set up event commands that should be run when entering or exiting a map, using two common events that handle ALL maps.
Using this script, you can dispose of all the autorun or parallel process events on individual maps for "setup" or "reset" tasks, like weather, map tinting, relocating events, etc.

Features
- No need for parallel process events on individual maps.
- No need to reset display (weather, tint) on multiple events or maps when exiting a map - if it's raining in a village, ONE common event will turn the rain off when you enter a building - no need to turn it off on every door or in every interior map
- Condition setup/exit tasks based on progress in game (switches/variables) just like you'd do with a map event

Screenshots
In the example used here, I have an outside map where it's raining and the screen tint is normal, and an inside map where it's not raining and the screen tint is sepia.

Spoiler
TransferAutoEvent_Map12Exterior_Test.png
TransferAutoEvent_Map13Interior_Test.png
How to Use
Copy and paste the script into a new slot in Materials. All methods are aliased, so it can go below all other scripts.

Create a parallel process common event for entering a map, and one for exiting a map.
Give each common event a unique switch, and change the ENTER_MAP_SWITCH and EXIT_MAP_SWITCH constants in this script to refer to the correct switch ids.
Add the following commands to each common event - they will be almost identical:




Code:
Script: jump_to_label($game_map.map_id)Comment: In case there isn't a label defined for the current map,       : jump to the end of the eventJump to Label: End<individual map commands go here>Comment: This should be run on all maps.  Turn off the switch that conditions this common eventLabel: EndControl Switches [0015: ENTER MAP] = OFF
Then, in the area indicated by <individual map commands go here> above, add the following block of code for every map where you want something to happen:
 
Code:
Comment: The label is the map number (no leading zeros)Label: 12<add commands to be run when entering or exiting this map here>Jump to Label: End
Here are the Enter Map and Exit Map common events for my sample.
For map 12 (exterior), it makes it rain when entering the map, and stops the rain when exiting the map.
For map 13 (interior), it changes the screen tone to sepia when entering the map, and changes it back to the default when exiting (note the longer change time when exiting - this is so it remains sepia while the screen is fading for the transfer).

Spoiler
TransferAutoEvent_EnterMapCommonEvent.png


TransferAutoEvent_ExitMapCommonEvent.png
Script
Spoiler
Code:
#============================================================================# TRANSFER AUTO EVENTS# v1.0 by Shaz#----------------------------------------------------------------------------# This script allows you to call a common event whenever you leave a map or# enter a map.  This can be used to run map setup or exit commands without# needing individual events on each map.  For example, screen tint and weather# changes, event location changes, etc.#----------------------------------------------------------------------------# To Install:# Copy and paste into a new script slot in Materials.  This script aliases# existing methods, so can go below all other custom scripts.#----------------------------------------------------------------------------# To Use:# Create a parallel process common event for entering a map, and one for# exiting a map.  Allocate a unique switch for each one.# ** Change the ENTER_MAP_SWITCH and EXIT_MAP_SWITCH constants below to refer#    to the switches you are using# Add a Call Script command to the top of each common event, with the following:#    jump_to_label($game_map.map_id)# Add a Jump to Label: End command# Add a Label: End command# Add a command to turn off the switch that conditions that common event# # Between the Jump to Label: End and Label: End command, add a label for# every map where you want this to run.  The label name will be the map# number (Map023 will be Label: 23)# Add any commands you want to run when entering or exiting that map.# Add a Jump to Label: End command after every map group#----------------------------------------------------------------------------# Sample Enter Map common event (conditioned by switch 15)## Script: jump_to_label($game_map.map_id)# Comment: add a jump to end label, in case the current map is not listed# Jump to Label: End# # Comment: Entering map 12 #        : This is an outside map, and it should be raining# Label: 12# Set Weather Effects: Rain, @0, Wait# Jump to Label: End## Comment: Entering map 13#        : This is an inside map, and the screen tone should be sepia# Label: 13# Tint Screen: (34, -34, -68, 170), @1# Jump to Label: End## Comment: This should get processed for every map# Label: End# Control Switches: [0015:ENTER MAP] = OFF#----------------------------------------------------------------------------# Sample Exit Map common event (conditioned by switch 16)## Script: jump_to_label($game_map.map_id)# Comment: add a jump to end label, in case the current map is not listed# Jump to Label: End# # Comment: Exiting map 12 #        : This is an outside map and it's raining - turn the rain off# Label: 12# Set Weather Effects: None, @0, Wait# Jump to Label: End## Comment: Exiting map 13#        : This is an inside map with a sepia tone - reset the tone#        : with a delay (don't wait) so it doesn't change while fading# Label: 13# Tint Screen: (0, 0, 0, 0), @60# Jump to Label: End## Comment: This should get processed for every map# Label: End# Control Switches: [0016:EXIT MAP] = OFF#----------------------------------------------------------------------------# Terms:# Use in free or commercial games# Credit Shaz#============================================================================ENTER_MAP_SWITCH = 15EXIT_MAP_SWITCH = 16class Game_Map  alias shaz_tae_setup_events setup_events  def setup_events    $game_switches[ENTER_MAP_SWITCH] = true    shaz_tae_setup_events  endendclass Game_Player  alias shaz_tae_reserve_transfer reserve_transfer  def reserve_transfer(map_id, x, y, d = 2)    $game_switches[EXIT_MAP_SWITCH] = true if map_id != $game_map.map_id    shaz_tae_reserve_transfer(map_id, x, y, d)  endendclass Game_Interpreter  def jump_to_label(value)    @list.size.times do |i|      if @list[i].code == 118 && @list[i].parameters[0] == value.to_s        @index = i        return      end    end  endend
Or download here

FAQ


Credit and Thanks
- Credit Shaz
- Okay to use in commercial games - no payment required

Author's Notes
I advise you to use this ONLY for things that need to be done every time you enter or leave a map. I recommend you don't use this for cutscenes that will only play once (you could, but I wouldn't).
very clever script, this is really nice. I'll have to implement it in my project
Incredible. Thank you Shaz!
Oh my. My computer just exploded from awesomness. At first I though it just tied a common event to a map, but now I see how wrong I was.
A bit late but thank you for this awesome script 🙂
two questions concerning the handling of this script and the events:


1)


In the case of multiple parallel processes, how is the priority handled?


lower ID common events first or higher ID first (like with the event pages)?


Just so that we know how to order events in case of other parallel processes (usually when those other processes are conditioned to other switches, not when they run every time like this one).


2)


If commands are placed between the label:end and the control switch off, they are executed on every map on enter/exit?


That would be usefull to setup (for example) temporary switches that are used on a map to be reset on every map, instead of using different switches per map - or for other things that run on every map.
I THINK parallel process common events MAY be processed in event id order.


Yes, if you place commands after the END label and before turning the switch off, those commands will be run on every map. You could also place them right at the beginning of the event if you wanted.
That is correct, common events is stored in an array ordered by ID and the map simply iterates over each common event.


It may be useful to find a way to control the order of execution rather than forcing the developer to keep in mind that lower ID's are executed first as this usually causes subtle bugs.
The EXIT code doesn't seem to activate unless the player transfer is given a fade. When the fade is set to 'Normal' it works fine, but when set to None it doesn't get called.

The ENTER map code works either way.

Is this just my setup, or do you see it as well?
mmm ... I'm at work and don't have access to Ace, but I'll definitely check this out when I get home.


It IS possible that I need to move that processing into a different method.
This is just what I need right now. Sadly, I'm using RPG MV...;_;
I hope it will work because the player transfer script won't working for me.

please drop a video link to do this
Double-post notice: Nayeem_FirstlineGames
I have merged your 2 posts for you this time. If you want to add something, please use the Edit button on your first post and add the additional comment/info there.
Thanks.
It looks like one of the forum upgrades removed all the formatting on the script. I will have to rewrite and repost it. If you use what's there now, you'll just get errors.

Please check back in a few days.

There will be no video. Screenshots are already provided.

Original thread: https://forums.rpgmakerweb.com/threads/map-transfer-auto-events.17401/