Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ╒══════════════════════════════════════════════════════════════════════════════════╕
- // █▐▐ Map Transfer Common Event
- // ╞══════════════════════════════════════════════════════════════════════════════════╡
- // █▐▐ Alias(s) and/or Addition(s)
- // ├──────────────────────────────────────────────────────────────────────────────────┤
- // ├── Game_Map
- // │ ├ [ALIAS] initialize
- // │ ├ [ALIAS] setup
- // │ └ [NEW] mtceRunCommonEvent
- // ╞══════════════════════════════════════════════════════════════════════════════════╡
- /*:
- * @plugindesc Run a specified common event when entering or exiting a map.
- * @author Exhydra
- *
- * @help
- * ▄ Plugin ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄
- *
- * ┌─ Version : 1.0
- * ├─ Release : 6th July 2016
- * ├─ Updated : 6th July 2016
- * └─ License : Free for Commercial and Non-Commercial Usage
- *
- * ▄ Usage ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄
- *
- * Place the following tag(s) into the 'note' box of the map you wish to
- * use the 'Map Transfer Common Event' plugin on.
- *
- * <mtceEn:commonEventId>
- * ├─Run specified common event when entering the map.
- * │
- * ├─commonEventId
- * ├ Value ► Numeric
- * └ The ID of the common event.
- *
- * <mtceEx:commonEventId>
- * ├─Run specified common event when exiting the map.
- * │
- * ├─commonEventId
- * ├ Value ► Numeric
- * └ The ID of the common event.
- *
- * ▄ Example(s) ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄
- *
- * <mtceEn:3>
- * └─Run common event with the ID of 3 when entering the map.
- *
- * <mtceEx:11>
- * └─Run common event with the ID of 11 when exiting the map.
- *
- */
- // ╘══════════════════════════════════════════════════════════════════════════════════╛
- // ╒══════════════════════════════════════════════════════════════════════════════════╕
- // ■ [Object] Plugin
- // ╘══════════════════════════════════════════════════════════════════════════════════╛
- var Imported = Imported || {};
- Imported.EXA_MapTransferCommonEvent = true;
- var EXA = EXA || {};
- EXA.MTCE = EXA.MTCE || {};
- // ╒══════════════════════════════════════════════════════════════════════════════════╕
- // ■ [Object] Game_Map
- // ╘══════════════════════════════════════════════════════════════════════════════════╛
- // ALIAS ─────────────────────────────────────────────────────────────────────────────┐
- // □ [Function] initialize
- // └──────────────────────────────────────────────────────────────────────────────────┘
- EXA.MTCE.Game_Map_initialize = Game_Map.prototype.initialize;
- Game_Map.prototype.initialize = function() {
- this._mtceInterpreter = new Game_Interpreter();
- this._mtceEnterEvent = 0;
- this._mtceExitEvent = 0;
- EXA.MTCE.Game_Map_initialize.call(this)
- }; // Game_Map ‹‹ initialize
- // ALIAS ─────────────────────────────────────────────────────────────────────────────┐
- // □ [Function] setup
- // └──────────────────────────────────────────────────────────────────────────────────┘
- EXA.MTCE.Game_Map_setup = Game_Map.prototype.setup;
- Game_Map.prototype.setup = function(mapId) {
- if ($gamePlayer.newMapId() != $gameMap.mapId()) {
- $gameMap.mtceRunCommonEvent(this._mtceExitEvent);
- }
- EXA.MTCE.Game_Map_setup.call(this, mapId);
- this._mtceEnterEvent = $dataMap.meta.mtceEn || 0;
- this._mtceExitEvent = $dataMap.meta.mtceEx || 0;
- if ($gamePlayer.newMapId() == $gameMap.mapId()) {
- $gameMap.mtceRunCommonEvent(this._mtceEnterEvent);
- }
- }; // Game_Map ‹‹ setup
- // NEW ───────────────────────────────────────────────────────────────────────────────┐
- // □ [Function] mtceCommonEvent
- // └──────────────────────────────────────────────────────────────────────────────────┘
- Game_Map.prototype.mtceRunCommonEvent = function(cevId) {
- if (cevId <= 0) return;
- var mtceEvent = $dataCommonEvents[cevId];
- this._mtceInterpreter.setup(mtceEvent.list);
- for (var i = 0; i < mtceEvent.list.length; i++) {
- this._mtceInterpreter.executeCommand();
- }
- this._mtceInterpreter.clear;
- }; // Game_Map ‹‹ mtceCommonEvent
- // ▌▌██████████████████████████████████████ EOF █████████████████████████████████████▐▐
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement