Advertisement
ezmash

Map Edge Transfer (MV)

Oct 27th, 2015
2,681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Map Edge Transfer
  3. // by Shaz
  4. // Last Updated: 2015.10.30
  5. //
  6. // Revisions:
  7. // 2015.10.30 - Fix problem with player being temporarily invisible after transfer
  8. //=============================================================================
  9.  
  10. /*:
  11.  * @plugindesc Allows auto transfer from edge of map
  12.  * @author Shaz
  13.  *
  14.  * @help This plugin does not provide plugin commands.
  15.  *
  16.  * Add <tfrup: 1 2 3 4 5>
  17.  *     <tfrdown: 1 2 3 4 5>
  18.  *     <tfrleft: 1 2 3 4 5>
  19.  *     <tfrright: 1 2 3 4 5>
  20.  * to map notes to transfer to a new location when the player reaches the
  21.  * edge of the map
  22.  *
  23.  * 1 - map id
  24.  * 2 - x coordinate on new map
  25.  * 3 - y coordinate on new map
  26.  * 4 - facing direction (optional - if omitted, direction is retained)
  27.  * 5 - transfer type (0=black, 1=white, 2=none - optional - if omitted, 0)
  28.  *                   (if entered, facing direction is also required)
  29.  *
  30.  * Each value can be one of:
  31.  * a number
  32.  * $gameVariables.value(n) - to get map, x or y from variable n
  33.  * a formula - to calculate based on a formula (eg: $gamePlayer.y)
  34.  *
  35.  */
  36.  
  37. (function() {
  38.   var _Game_Player_update = Game_Player.prototype.update;
  39.   Game_Player.prototype.update = function(sceneActive) {
  40.     _Game_Player_update.call(this, sceneActive);
  41.     if (!this.isMoving()) {
  42.       this.mapEdgeTransferUpdate();
  43.     }
  44.   };
  45.  
  46.   Game_Player.prototype.mapEdgeTransferUpdate = function() {
  47.     if (this.x === 0 && this.direction() === 4 && $dataMap.meta.tfrleft) {
  48.       this.mapEdgeTransfer($dataMap.meta.tfrleft);
  49.     }
  50.     if (this.x === $dataMap.width - 1 && this.direction() === 6 && $dataMap.meta.tfrright) {
  51.       this.mapEdgeTransfer($dataMap.meta.tfrright);
  52.     }
  53.     if (this.y === 0 && this.direction() === 8 && $dataMap.meta.tfrup) {
  54.       this.mapEdgeTransfer($dataMap.meta.tfrup);
  55.     }
  56.     if (this.y === $dataMap.height - 1 && this.direction() === 2 && $dataMap.meta.tfrdown) {
  57.       this.mapEdgeTransfer($dataMap.meta.tfrdown);
  58.     }
  59.   };
  60.  
  61.   Game_Player.prototype.mapEdgeTransfer = function(tfrDetails) {
  62.     var tfrInfo = tfrDetails.trim().split(' ');
  63.     if (tfrDetails.length < 3) {
  64.       return;
  65.     };
  66.     var tfrMap = eval(tfrInfo[0]);
  67.     var tfrX = eval(tfrInfo[1]);
  68.     var tfrY = eval(tfrInfo[2]);
  69.     var tfrDir = tfrDetails.length < 4 ? this.direction() : parseInt(eval(tfrInfo[3]));
  70.     if (![2,4,6,8].contains(tfrDir)) {
  71.       tfrDir = this.direction();
  72.     }
  73.     var tfrType = tfrDetails.length < 5 ? 0 : parseInt(eval(tfrInfo[4]));
  74.     if (![0,1,2].contains(tfrType)) {
  75.       tfrType = 0;
  76.     }
  77.     this.reserveTransfer(tfrMap, tfrX, tfrY, tfrDir, tfrType);
  78.     $gameTemp.clearDestination();
  79.   };
  80. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement