Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*:
- * Clone Events by Shaz
- * Ver 1.00 2018.01.13
- * Shaz_CloneEvents.js
- *
- *
- * @plugindesc Clone events from a 'base' map to the current map.
- * @author Shaz
- *
- * @param Base Map ID
- * @desc Cloned events will be copied from this map. No leading zeros.
- * @type number
- * @min 1
- * @default 1
- *
- * @help This plugin allows you to clone events from a 'base' map onto the
- * current map. When the map is loaded, any events identified as clones will
- * be replaced by the source event from the 'base' map. Only the location of
- * the original event will be used. It allows you to define an event once,
- * but to use it many times on many maps. If you want to make changes, you
- * only have to change it in one location - on the 'base' map.
- *
- * It is NOT an event spawning plugin - it replaces one event with another,
- * allowing you to specify the location for each event, but pulling the
- * remaining event settings (pages, triggers, sprites, commands, metadata)
- * from the cloned event.
- *
- * USAGE:
- * Create a map that will hold all your events to be cloned. Enter this map ID
- * into the Base Map ID parameter.
- * Create events on this map and give them all unique names (in the event Name
- * box).
- * Add your event pages, conditions, sprites and commands.
- *
- * On your game maps, create a new event wherever you want to make a clone.
- * Enter <clone:eventName> in the event's note box, replacing eventName with
- * the actual name you gave to the event on the 'base' map.
- *
- * Example:
- * On the 'base' map, there is an event called Fishing (in the event name box).
- * Tab 1 just shows "This would be a good spot to fish, if you had a line."
- * Tab 2 is conditioned by the item Fishing Line in inventory, and has commands
- * for a fishing system.
- * On any map where fishing is allowed, there is an event at each fishing
- * location that simply has <clone:Fishing> in the notebox.
- * When that map is loaded, the 'placeholder' event on the map is replaced with
- * the Fishing event from the 'base' map.
- *
- * NOTE:
- * This plugin has no plugin commands.
- * This plugin will not be active in Battle Test.
- *
- */
- var Imported = Imported || {};
- Imported.Shaz_CloneEvents = true;
- var Shaz = Shaz || {};
- Shaz.CE = Shaz.CE || {};
- Shaz.CE.Version = 1.00;
- Shaz.Parameters = PluginManager.parameters('Shaz_CloneEvents');
- Shaz.Param = Shaz.Param || {};
- Shaz.Param.CE = Shaz.Param.CE || {};
- Shaz.Param.CE.CloneMap = eval(Shaz.Parameters['Base Map ID']);
- (function() {
- var $dataClonesMap = null;
- var $dataClones = {};
- if (!DataManager.isBattleTest()) {
- DataManager._databaseFiles.push({ name: '$dataCloneMap', src: 'Map%1.json'.format(Shaz.Param.CE.CloneMap.padZero(3)) });
- };
- var _Shaz_CE_DataManager_onLoad = DataManager.onLoad;
- DataManager.onLoad = function(object) {
- if (object === $dataCloneMap) {
- for (var i = 0; i < object.events.length; i++) {
- var evt = object.events[i];
- if (evt) {
- $dataClones[evt.name] = evt;
- this.extractMetadata($dataClones[evt.name]);
- }
- }
- } else {
- _Shaz_CE_DataManager_onLoad.call(this, object);
- }
- };
- var _Shaz_CE_Game_Event_initialize = Game_Event.prototype.initialize;
- Game_Event.prototype.initialize = function(mapId, eventId) {
- this._clone = null;
- if ($dataMap.events[eventId].meta.clone) {
- this._clone = JsonEx.makeDeepCopy($dataClones[$dataMap.events[eventId].meta.clone]);
- this._clone.id = eventId;
- this._clone.x = $dataMap.events[eventId].x;
- this._clone.y = $dataMap.events[eventId].y;
- };
- _Shaz_CE_Game_Event_initialize.call(this, mapId, eventId);
- };
- var _Shaz_CE_Game_Event_event = Game_Event.prototype.event;
- Game_Event.prototype.event = function() {
- if (this._clone) {
- return this._clone;
- } else {
- return _Shaz_CE_Game_Event_event.call(this);
- }
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement