document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. //=============================================================================
  2. // EventTouchRadius.js
  3. //=============================================================================
  4.  
  5. /*:
  6.  * @plugindesc Events can trigger an Event Touch at greater distances.
  7.  * @author whitesphere
  8.  *
  9.  * @param Default Event Radius
  10.  * @desc If set, any non-configured event in the game will use this for their Event Touch radius.
  11.  *
  12.  * @help If an event has an Event Radius, the "Event Touch" type will trigger
  13.  * when the player comes within that many tiles, in any direction, from the event\'s
  14.  * center.
  15.  *
  16.  * The event\'s center is normally the tile it\'s standing on.  However, if the event\'s
  17.  * Image is larger than 1 tile, the center is the tile that would be at the visual center
  18.  * of the event.  This is most useful for gigantic events like Dragons.
  19.  *
  20.  * If this radius is not set, the event functions normally.
  21.  *
  22.  * ============================================================================
  23.  * Notetags
  24.  * ============================================================================
  25.  *
  26.  * You can use this notetag inside of your events.
  27.  *
  28.  * Event Notetags:
  29.  *   <EventRadius: 3>
  30.  *   Sets the Event Touch radius for the particular Event.
  31.  *
  32.  * Map Notetags:
  33.  *   <EventRadius: 3>
  34.  *   Sets the Event Touch radius for the particular Event unless
  35.  *   the event already has its own EventRadius tag.
  36.  */
  37. (function() {
  38.  
  39. WS_EventTouchConfig = {};
  40.  
  41. WS_EventTouchConfig.Parameters = PluginManager.parameters(\'EventTouchRadius\');
  42. WS_EventTouchConfig.Param = {};
  43.  
  44. //=============================================================================
  45. // The plug-in parameters
  46. //=============================================================================
  47. WS_EventTouchConfig.Param.defaultEventRadius = parseInt(WS_EventTouchConfig.Parameters[\'Default Event Radius\']);
  48.  
  49.  
  50. //=============================================================================
  51. // Game_Event
  52. //=============================================================================
  53.  
  54.  
  55. var WS_GE_ET_init = Game_Event.prototype.initMembers;
  56. //=============================================================================
  57. // Add our own members
  58. //=============================================================================
  59. Game_Event.prototype.initMembers = function() {
  60.     WS_GE_ET_init.call(this, arguments);
  61.     this._playerRadius=0;
  62.     this._eventImageXOffset=0;
  63.     this._eventImageYOffset=0;
  64. }
  65.  
  66. //=============================================================================
  67. // Perform event touch initialization
  68. //=============================================================================
  69. Game_Event.prototype.initEventTouchRadius = function() {
  70.     if (this.event() === undefined)
  71.         return;
  72.     if (this._eventRadius !== undefined)
  73.         return;
  74.     if (ImageManager.isBigCharacter(this._characterName)) {
  75.         /* Need to figure out how big we are */
  76.         var tmpBitmap=ImageManager.loadCharacter(this._characterName);
  77.         var tw = $gameMap.tileWidth();
  78.         var th = $gameMap.tileHeight();
  79.         this._eventImageXOffset = bitmap.width / tw / 2;
  80.         this._eventImageYOffset = bitmap.height / th / 2;
  81.     }
  82.    
  83.     /* Load up the player and event radii */
  84.     if (this.event() !== undefined)
  85.     {
  86.         meta=this.event().meta;
  87.         if (meta) {
  88.             if (meta.EventTouchRadius) {
  89.                 this._eventRadius=parseInt(meta.EventTouchRadius);
  90.             }
  91.             if (!this._eventRadius)
  92.             {
  93.                 // Check for the Map
  94.                 if ($dataMap.meta && $dataMap.meta.EventTouchRadius) {
  95.                     this._eventRadius=parseInt($dataMap.meta.EventTouchRadius);
  96.                 }
  97.             }
  98.             if (!this._eventRadius) {
  99.                 this._eventRadius=WS_EventTouchConfig.Param.defaultEventRadius;
  100.             }
  101.             this._eventRadius *= this._eventRadius;
  102.         }
  103.     }
  104. }
  105.  
  106.  
  107.  
  108.  
  109. var WS_GE_ET_isCollided = Game_Event.prototype.isCollidedWithPlayerCharacters;
  110.  
  111. //=============================================================================
  112. // Perform the player touch check
  113. //=============================================================================
  114. Game_Event.prototype.isCollidedWithPlayerCharacters = function(x, y) {
  115.     if (!$gameMap.isEventRunning()) {
  116.         if (!this.isNormalPriority()) {
  117.             return false;
  118.         }
  119.         this.initEventTouchRadius();
  120.         if (this._eventRadius > 0) {
  121.            
  122.             /* Adjust for large sprites */
  123.             tmp_x = x + this._eventImageXOffset;
  124.             tmp_y = y + this._eventImageYOffset;
  125.            
  126.             /* See if we are in range */
  127.             distance=($gamePlayer.x-x)*($gamePlayer.x-x)+($gamePlayer.y-y)*($gamePlayer.y-y);
  128.             if (distance <= this._eventRadius)
  129.             {
  130.                 this.start();
  131.                 return true;
  132.             }
  133.             return false;
  134.         }
  135.         else
  136.         {
  137.             return WS_GE_ET_isCollided.call(this, x, y);
  138.         }
  139.     }
  140. }
  141.  
  142.  
  143. })();
  144. //=============================================================================
  145. // End of File
  146. //=============================================================================
');