ezmash

Elevation Fix (MV)

Jul 14th, 2016
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // ElevationFix.js
  3. //=============================================================================
  4.  
  5. /*:
  6.  * @plugindesc Allow interaction with events only on same level
  7.  * @author Shaz
  8.  *
  9.  * @help This plugin has no plugin commands
  10.  *
  11.  * Add <elevation> as a comment to an event page, and you will only be
  12.  * able to interact with that event when you are at the same height
  13.  * (you will not be able to interact with it if there is a cliff edge
  14.  * between you and the event, for example).
  15.  */
  16.  
  17.  
  18. (function() {
  19.  
  20.   var _Game_Event_start = Game_Event.prototype.start;
  21.   Game_Event.prototype.start = function() {
  22.     var list = this.list();
  23.     if (list && list.length > 1) {
  24.       if (list.filter(function(cmd) {
  25.         return (cmd.code === 108 || cmd.code === 408) && cmd.parameters[0].match(/<elevation>/);
  26.       }).length > 0) {
  27.         var px = $gamePlayer.x;
  28.         var py = $gamePlayer.y;
  29.         var x = this.x;
  30.         var y = this.y;
  31.         var d = px < x ? 4 : px > x ? 6 : py < y ? 8 : py > y ? 2 : px === x && py === y ? 10 : 0;
  32.         if (!this.isMapPassable(x, y, d)) { return; }
  33.       }
  34.       _Game_Event_start.call(this);
  35.     }
  36.   }
  37. })();
Add Comment
Please, Sign In to add comment