ezmash

Big Events (MV)

Jan 13th, 2018
1,848
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*:
  2.  * Big Events by Shaz
  3.  * Ver 1.00 2018.01.13
  4.  * Shaz_BigEvents.js
  5.  *
  6.  *
  7.  * @plugindesc Set an event's collision area to cover more than one tile.
  8.  * @author Shaz
  9.  *
  10.  * @help This plugin allows you to set an event to cover more than one tile
  11.  * for collision purposes.  You can specify the entire event (all pages) to
  12.  * have the large collision area, or just individual pages.
  13.  *
  14.  * USAGE:
  15.  * Place the event in the top left corner of the area to be covered.
  16.  * Enter <bigEvent:wxh> in the event's note box (affects all event pages),
  17.  * or as a comment on the event page (affects just that page), where w is
  18.  * the number of tiles across and h is the number of tiles down that the
  19.  * event will occupy.
  20.  * A <bigEvent:...> comment on an event page will override a <bigEvent...>
  21.  * tag in the note box.
  22.  *
  23.  * Example:
  24.  * <bigEvent:1x3> in the notebox of an event will expand the collision area
  25.  * of that event to cover the current tile plus two tiles below (total width
  26.  * is 1 and total height is 3).
  27.  * <bigEvent:4x4> in a comment on an event page will expand the collision
  28.  * area to a 4x4 square, just while that page is active.
  29.  *
  30.  * NOTE:
  31.  * This plugin has no plugin commands.
  32.  * This plugin is only to be used for events that will not move.
  33.  *
  34.  */
  35.  
  36. var Imported = Imported || {};
  37. Imported.Shaz_BigEvents = true;
  38.  
  39. var Shaz = Shaz || {};
  40. Shaz.BE = Shaz.BE || {};
  41. Shaz.BE.Version = 1.00;
  42.  
  43. (function() {
  44.     var _Shaz_BE_Game_Event_initMembers = Game_Event.prototype.initMembers;
  45.     Game_Event.prototype.initMembers = function() {
  46.         _Shaz_BE_Game_Event_initMembers.call(this);
  47.         this._xr = null;
  48.         this._yb = null;
  49.     };
  50.  
  51.     var _Shaz_BG_Game_Event_pos = Game_Event.prototype.pos
  52.     Game_Event.prototype.pos = function(x, y) {
  53.         if (this._xr) {
  54.             return this._x <= x && this._xr >= x && this._y <= y && this._yb >= y;
  55.         } else {
  56.             return _Shaz_BG_Game_Event_pos.call(this, x, y);
  57.         }
  58.     };
  59.  
  60.     var _Shaz_BE_Game_Event_clearPageSettings = Game_Event.prototype.clearPageSettings;
  61.     Game_Event.prototype.clearPageSettings = function() {
  62.         _Shaz_BE_Game_Event_clearPageSettings.call(this);
  63.         this._xr = null;
  64.         this._yb = null;
  65.     };
  66.  
  67.     var _Shaz_BE_Game_Event_setupPageSettings = Game_Event.prototype.setupPageSettings;
  68.     Game_Event.prototype.setupPageSettings = function() {
  69.         _Shaz_BE_Game_Event_setupPageSettings.call(this);
  70.         this._xr = null;
  71.         this._yb = null;
  72.         var param = null;
  73.         if (this.page() && this.list()) {
  74.             this.list().filter(function(cmd) {
  75.                 if ((cmd.code === 108 || cmd.code === 408) && cmd.parameters[0].match(/<bigEvent:\s*(\d+)x(\d+)>/)) {
  76.                     param = RegExp.$1 + 'x' + RegExp.$2;
  77.                     return true;
  78.                 } else {
  79.                     return false;
  80.                 }
  81.             });
  82.         }
  83.  
  84.         if (!param && this.event().meta.bigEvent) {
  85.             param = this.event().meta.bigEvent;
  86.         }
  87.  
  88.         if (param && param.match(/(\d+)x(\d+)/)) {
  89.             this._xr = this._x + parseInt(RegExp.$1) - 1;
  90.             this._yb = this._y + parseInt(RegExp.$2) - 1;
  91.         }
  92.     };
  93.  
  94. })();
Advertisement
Add Comment
Please, Sign In to add comment