Save-Point
KTouchNewMapEvent MV - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Plugins and Mods (https://www.save-point.org/forum-74.html)
+---- Forum: RPGMaker MV/MZ Engines (https://www.save-point.org/forum-120.html)
+---- Thread: KTouchNewMapEvent MV (/thread-9011.html)



KTouchNewMapEvent MV - kyonides - 09-01-2024

KTouchNewMapEvent MV

by Kyonides


Introduction

Did you ever want that the engine would autorun events right after being touched by the player or another event?

Especially once it finishes transferring the player to a new map...

Now you can do that! Just copy and past the following snippet on your script editor!


Code:
//==================================
// * KTouchNewMapEventMV.js
//==================================
/*:
* @plugindesc This plugin will be triggered if any given event's coordinates
* match the player's and its trigger is either a Player or Event Touch.
* @author Kyonides Arkanthes
* @help Date: 2023-01-29
*
*/

const KTouchNewMap_event_setupPage = Game_Event.prototype.setupPage;

Game_Player.prototype.newMapX = function() {
  return this._newX;
}

Game_Player.prototype.newMapY = function() {
  return this._newY;
}

Game_Event.prototype.setupPage = function() {
  KTouchNewMap_event_setupPage.call(this);
  this.checkEventTriggerNewMapTouch();
};

Game_Event.prototype.checkEventTriggerNewMapTouch = function() {
  if (this._trigger == 1 || this._trigger == 2) {
    if ($gamePlayer.newMapX() == this.x && $gamePlayer.newMapY() == this.y) {
      this.start();
    }
  }
};

Notes

Honestly, there are other ways to trigger events without using scripts. Yet, you can still use my scriptlet to make it possible by setting its trigger as Player Touch or Event Touch.

Terms & Conditions

Free as in beer and as in speech.
Please include my nickname in your game credits.