daily pastebin goal
55%
SHARE
TWEET

Clone Events (MV)

ezmash Jan 12th, 2018 (edited) 118 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*:
  2.  * Clone Events by Shaz
  3.  * Ver 1.00 2018.01.13
  4.  * Shaz_CloneEvents.js
  5.  *
  6.  *
  7.  * @plugindesc Clone events from a 'base' map to the current map.
  8.  * @author Shaz
  9.  *
  10.  * @param Base Map ID
  11.  * @desc Cloned events will be copied from this map.  No leading zeros.
  12.  * @type number
  13.  * @min 1
  14.  * @default 1
  15.  *
  16.  * @help This plugin allows you to clone events from a 'base' map onto the
  17.  * current map.  When the map is loaded, any events identified as clones will
  18.  * be replaced by the source event from the 'base' map.  Only the location of
  19.  * the original event will be used.  It allows you to define an event once,
  20.  * but to use it many times on many maps.  If you want to make changes, you
  21.  * only have to change it in one location - on the 'base' map.
  22.  *
  23.  * It is NOT an event spawning plugin - it replaces one event with another,
  24.  * allowing you to specify the location for each event, but pulling the
  25.  * remaining event settings (pages, triggers, sprites, commands, metadata)
  26.  * from the cloned event.
  27.  *
  28.  * USAGE:
  29.  * Create a map that will hold all your events to be cloned.  Enter this map ID
  30.  * into the Base Map ID parameter.
  31.  * Create events on this map and give them all unique names (in the event Name
  32.  * box).
  33.  * Add your event pages, conditions, sprites and commands.
  34.  *
  35.  * On your game maps, create a new event wherever you want to make a clone.
  36.  * Enter <clone:eventName> in the event's note box, replacing eventName with
  37.  * the actual name you gave to the event on the 'base' map.
  38.  *
  39.  * Example:
  40.  * On the 'base' map, there is an event called Fishing (in the event name box).
  41.  * Tab 1 just shows "This would be a good spot to fish, if you had a line."
  42.  * Tab 2 is conditioned by the item Fishing Line in inventory, and has commands
  43.  * for a fishing system.
  44.  * On any map where fishing is allowed, there is an event at each fishing
  45.  * location that simply has <clone:Fishing> in the notebox.
  46.  * When that map is loaded, the 'placeholder' event on the map is replaced with
  47.  * the Fishing event from the 'base' map.
  48.  *
  49.  * NOTE:
  50.  * This plugin has no plugin commands.
  51.  * This plugin will not be active in Battle Test.
  52.  *
  53.  */
  54.  
  55. var Imported = Imported || {};
  56. Imported.Shaz_CloneEvents = true;
  57.  
  58. var Shaz = Shaz || {};
  59. Shaz.CE = Shaz.CE || {};
  60. Shaz.CE.Version = 1.00;
  61.  
  62. Shaz.Parameters = PluginManager.parameters('Shaz_CloneEvents');
  63. Shaz.Param = Shaz.Param || {};
  64. Shaz.Param.CE = Shaz.Param.CE || {};
  65.  
  66. Shaz.Param.CE.CloneMap = eval(Shaz.Parameters['Base Map ID']);
  67.  
  68. (function() {
  69.     var $dataClonesMap = null;
  70.     var $dataClones = {};
  71.  
  72.     if (!DataManager.isBattleTest()) {
  73.         DataManager._databaseFiles.push({ name: '$dataCloneMap', src: 'Map%1.json'.format(Shaz.Param.CE.CloneMap.padZero(3)) });
  74.     };
  75.  
  76.     var _Shaz_CE_DataManager_onLoad = DataManager.onLoad;
  77.  
  78.     DataManager.onLoad = function(object) {
  79.         if (object === $dataCloneMap) {
  80.             for (var i = 0; i < object.events.length; i++) {
  81.                 var evt = object.events[i];
  82.                 if (evt) {
  83.                     $dataClones[evt.name] = evt;
  84.                     this.extractMetadata($dataClones[evt.name]);
  85.                 }
  86.             }
  87.         } else {
  88.             _Shaz_CE_DataManager_onLoad.call(this, object);
  89.         }
  90.     };
  91.  
  92.     var _Shaz_CE_Game_Event_initialize = Game_Event.prototype.initialize;
  93.     Game_Event.prototype.initialize = function(mapId, eventId) {
  94.         this._clone = null;
  95.         if ($dataMap.events[eventId].meta.clone) {
  96.             this._clone = JsonEx.makeDeepCopy($dataClones[$dataMap.events[eventId].meta.clone]);
  97.             this._clone.id = eventId;
  98.             this._clone.x = $dataMap.events[eventId].x;
  99.             this._clone.y = $dataMap.events[eventId].y;
  100.         };
  101.         _Shaz_CE_Game_Event_initialize.call(this, mapId, eventId);
  102.     };
  103.  
  104.     var _Shaz_CE_Game_Event_event = Game_Event.prototype.event;
  105.     Game_Event.prototype.event = function() {
  106.         if (this._clone) {
  107.             return this._clone;
  108.         } else {
  109.             return _Shaz_CE_Game_Event_event.call(this);
  110.         }
  111.     };
  112.  
  113. })();
RAW Paste Data
Top