Trigger an event on map exit?

greay

Veteran
Veteran
Joined
Dec 19, 2015
Messages
23
Reaction score
2
First Language
English
Primarily Uses
Is there a way to trigger an event on map exit? Ideally this would be universal – there's a little thing I'd like to do every time a player switches to a new area.
 

Idril

Widdershins Games
Veteran
Joined
Dec 1, 2014
Messages
230
Reaction score
169
First Language
English
Does MV have common events? Then you won't need a plugin. Just make a common event that does whatever you'd like to happen on map change, and Call Common Event after the transfer command in each map transfer event.
 

greay

Veteran
Veteran
Joined
Dec 19, 2015
Messages
23
Reaction score
2
First Language
English
Primarily Uses
Does MV have common events? Then you won't need a plugin. Just make a common event that does whatever you'd like to happen on map change, and Call Common Event after the transfer command in each map transfer event.
That's a lot of extra work to have to add that to every single place there's a map transfer event which makes my programmer brain cry. It violates the DRY principle ("Don't Repeat Yourself").


Sure, it would work (but begging for potentially sneaky bugs if I happen to miss an event somewhere). There Has To Be A Better Way.
 

DreamX

Veteran
Veteran
Joined
May 30, 2015
Messages
816
Reaction score
826
First Language
English
Primarily Uses
How about this?


alias_Game_Interpreter_command201 = Game_Interpreter.prototype.command201;
Game_Interpreter.prototype.command201 = function () {
$gameTemp.reserveCommonEvent(1);
alias_Game_Interpreter_command201.call(this);
};


Runs whenever you use the Transfer Player event command. Change 1 to the id of the common event.


Edit: Here's a version where it the common event is only called when the next map is not the same:

Code:
    alias_Game_Interpreter_command201 = Game_Interpreter.prototype.command201;
    Game_Interpreter.prototype.command201 = function () {
        if (this._params[1] !== $gameMap.mapId()) {
            $gameTemp.reserveCommonEvent(1);
        }

        alias_Game_Interpreter_command201.call(this);
    };
 
Last edited by a moderator:

greay

Veteran
Veteran
Joined
Dec 19, 2015
Messages
23
Reaction score
2
First Language
English
Primarily Uses
How about this?



alias_Game_Interpreter_command201 = Game_Interpreter.prototype.command201;
Game_Interpreter.prototype.command201 = function () {
$gameTemp.reserveCommonEvent(1);
alias_Game_Interpreter_command201.call(this);
};


Runs whenever you use the Transfer Player event command. Change 1 to the id of the common event.
command ... 201?  :unsure:


that certainly looks like exactly what I need, thank you, there is no way I would have ever found that on my own. It's getting late, so I'm probably not going to get this working tomorrow, but I'm gonna trust you & call this solved.
 

DreamX

Veteran
Veteran
Joined
May 30, 2015
Messages
816
Reaction score
826
First Language
English
Primarily Uses
command ... 201?  :unsure:


that certainly looks like exactly what I need, thank you, there is no way I would have ever found that on my own. It's getting late, so I'm probably not going to get this working tomorrow, but I'm gonna trust you & call this solved.
It's just the transfer player command. I edited my post but here's a better solution for you again so you see it, it checks if the command is transferring the player to a new map instead of just another location in the current


alias_Game_Interpreter_command201 = Game_Interpreter.prototype.command201;
Game_Interpreter.prototype.command201 = function () {
if (this._params[1] !== $gameMap.mapId()) {
$gameTemp.reserveCommonEvent(1);
}

alias_Game_Interpreter_command201.call(this);
};



I've tested it and it works.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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,040
Messages
1,018,476
Members
137,824
Latest member
dobratemporal
Top