Advertisement
Guest User

RPG Maker MV plugin - Karberus - Simple Land Vehicle - v1.2

a guest
Sep 1st, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //============================================================================
  2. // Karberus - Simple Land Vehicle
  3. // SimpleLandVehicle.js
  4. // Version 1.2
  5. // No credit required. Can be used commercially or non commercially
  6. //============================================================================
  7. //============================================================================
  8. var Imported = Imported || {};
  9. Imported.SimpleLandVehicle = true;
  10.  
  11. var Karberus = Karberus || {};
  12. Karberus.LandBoat = Karberus.LandBoat || {};
  13. //============================================================================
  14. //============================================================================
  15. /*:
  16.  * @plugindesc v1.2 Allows you to drive/ride a vehicle on land.
  17.  * @author Karberus
  18.  * @version 1.2
  19.  *
  20.  *
  21.  *
  22.  * @param Vehicle Speed
  23.  * @desc Change the movement speed of your land vehicle
  24.  * Default: 5
  25.  * @default 5
  26.  *
  27.  * @param Encounters
  28.  * @desc Whether encounters are enabled while on the land vehicle
  29.  * false = off / true = on
  30.  * @default false
  31.  *
  32.  *
  33.  * @param Touch Events
  34.  * @desc Whether touch events will be triggered while on land vehicle
  35.  * false = off / true = on
  36.  * @default false
  37.  *
  38.  *
  39.  * @param Action Button Events
  40.  * @desc Whether action button events will trigger while on land vehicle
  41.  * false = off / true = on
  42.  * @default false
  43.  *
  44.  *
  45.  * @param Forbid Region ID
  46.  * @desc Set which Region ID forbids land vehicle to pass through.
  47.  *Set to 0 if you don't wish to use this feature.
  48.  * @default 0
  49.  *
  50.  *
  51.  *@help Change the boat's graphic in the database to fit a land vehicle.
  52.  *
  53.  *This plugin changes how the boat functions, and makes it into a land vehicle.
  54.  *
  55.  *
  56.  */
  57.  
  58. (function() {
  59.  
  60. //Initialize parameter values
  61. Karberus.Parameters = PluginManager.parameters("SimpleLandVehicle");
  62.  
  63. Karberus.LandBoat.Speed = Number(Karberus.Parameters["Vehicle Speed"]) ||  5;
  64. Karberus.LandBoat.Encounters = String(Karberus.Parameters["Encounters"]);
  65. Karberus.LandBoat.TouchEvents = String(Karberus.Parameters["Touch Events"]);
  66. Karberus.LandBoat.ActionEvents = String(Karberus.Parameters["Action Button Events"]);
  67. Karberus.LandBoat.ForbidRegionID = Number(Karberus.Parameters["Forbid Region ID"]);
  68.  
  69. //=========================================================================
  70. // Passability / Overwrite
  71. //=========================================================================
  72. Game_Player.prototype.isMapPassable = function(x, y, d) {
  73.  
  74.   var vehicle = this.vehicle();
  75.     if (vehicle)
  76.     {
  77.       if(this._vehicleType !== 'boat') return vehicle.isMapPassable(x, y, d);
  78.       if(this._vehicleType === 'boat')
  79.       {
  80.         if(this.noLandVehicleRegion(x, y, d)) return false;
  81.         return Game_Character.prototype.isMapPassable.call(this, x, y, d);
  82.       }
  83.  
  84.     }
  85.     else
  86.     {
  87. return Game_Character.prototype.isMapPassable.call(this, x, y, d);
  88.     }
  89. };
  90.  
  91. //==========================================================================
  92. // Check
  93. //==========================================================================
  94.  
  95. Game_Player.prototype.noLandVehicleRegion = function(x, y, d) {
  96.     var regionId = this.checkNoLandVehicleRegionID(x, y, d);
  97.     if (regionId === 0) return false;
  98.     if (regionId === Karberus.LandBoat.ForbidRegionID) return true;
  99.     return regionId === Karberus.LandBoat.ForbidRegionID;
  100. };
  101.  
  102. //========================================================================
  103. // Get Region ID
  104. //========================================================================
  105.  
  106. Game_Player.prototype.checkNoLandVehicleRegionID = function(x, y, d) {
  107.     switch (d) {
  108.     case 1:
  109.       return $gameMap.regionId(x - 1, y + 1);
  110.       break;
  111.     case 2:
  112.       return $gameMap.regionId(x + 0, y + 1);
  113.       break;
  114.     case 3:
  115.       return $gameMap.regionId(x + 1, y + 1);
  116.       break;
  117.     case 4:
  118.       return $gameMap.regionId(x - 1, y + 0);
  119.       break;
  120.     case 5:
  121.       return $gameMap.regionId(x + 0, y + 0);
  122.       break;
  123.     case 6:
  124.       return $gameMap.regionId(x + 1, y + 0);
  125.       break;
  126.     case 7:
  127.       return $gameMap.regionId(x - 1, y - 1);
  128.       break;
  129.     case 8:
  130.       return $gameMap.regionId(x + 0, y - 1);
  131.       break;
  132.     case 9:
  133.       return $gameMap.regionId(x + 1, y - 1);
  134.       break;
  135.     }
  136.     return 0;
  137. };
  138.  
  139. //=============================================================================
  140. // Determine whether to have encounters while on the land vehicle / Overwrite
  141. //=============================================================================
  142.  
  143. Game_Player.prototype.canEncounter = function() {
  144.  
  145.     if (eval(Karberus.LandBoat.Encounters) === false) {
  146.     return (!$gameParty.hasEncounterNone() && $gameSystem.isEncounterEnabled() &&
  147.             !this.isInAirship() && !this.isInBoat() && !this.isMoveRouteForcing() && !this.isDebugThrough());
  148.           } else {
  149.             return (!$gameParty.hasEncounterNone() && $gameSystem.isEncounterEnabled() &&
  150.                     !this.isInAirship() && !this.isMoveRouteForcing() && !this.isDebugThrough());
  151.           }
  152. };
  153.  
  154. //=============================================================================
  155. // Check whether events can be triggered / Overwrite
  156. //=============================================================================
  157.  
  158.  
  159.  
  160. Game_Player.prototype.checkEventTriggerHere = function(triggers) {
  161.   if (eval(Karberus.LandBoat.TouchEvents) === false) {
  162.     if (!this.isInBoat() && this.canStartLocalEvents()) {
  163.         this.startMapEvent(this.x, this.y, triggers, false);
  164.     }
  165.   } else {  if (this.canStartLocalEvents()) {
  166.         this.startMapEvent(this.x, this.y, triggers, false);
  167.     }
  168.   }
  169. };
  170.  
  171. Game_Player.prototype.checkEventTriggerThere = function(triggers) {
  172.   if (eval(Karberus.LandBoat.ActionEvents) === false) {
  173.     if (!this.isInBoat() && this.canStartLocalEvents()) {
  174.         var direction = this.direction();
  175.         var x1 = this.x;
  176.         var y1 = this.y;
  177.         var x2 = $gameMap.roundXWithDirection(x1, direction);
  178.         var y2 = $gameMap.roundYWithDirection(y1, direction);
  179.         this.startMapEvent(x2, y2, triggers, true);
  180.         if (!$gameMap.isAnyEventStarting() && $gameMap.isCounter(x2, y2)) {
  181.             var x3 = $gameMap.roundXWithDirection(x2, direction);
  182.             var y3 = $gameMap.roundYWithDirection(y2, direction);
  183.             this.startMapEvent(x3, y3, triggers, true);
  184.         }
  185.     }
  186.   } else {
  187.     if (this.canStartLocalEvents()) {
  188.         var direction = this.direction();
  189.         var x1 = this.x;
  190.         var y1 = this.y;
  191.         var x2 = $gameMap.roundXWithDirection(x1, direction);
  192.         var y2 = $gameMap.roundYWithDirection(y1, direction);
  193.         this.startMapEvent(x2, y2, triggers, true);
  194.         if (!$gameMap.isAnyEventStarting() && $gameMap.isCounter(x2, y2)) {
  195.             var x3 = $gameMap.roundXWithDirection(x2, direction);
  196.             var y3 = $gameMap.roundYWithDirection(y2, direction);
  197.             this.startMapEvent(x3, y3, triggers, true);
  198.         }
  199.     }
  200.  
  201.   }
  202. };
  203.  
  204. //=============================================================================
  205. //=============================================================================
  206. // Change move speed when on the vehicle / Overwrite
  207. //=============================================================================
  208. Game_Vehicle.prototype.initMoveSpeed = function() {
  209.  
  210.   if (this.isBoat()) {
  211.       this.setMoveSpeed(Karberus.LandBoat.Speed);
  212.   } else if (this.isShip()) {
  213.       this.setMoveSpeed(5);
  214.   } else if (this.isAirship()) {
  215.       this.setMoveSpeed(6);
  216.   }
  217. };
  218. //=============================================================================
  219. //=============================================================================
  220. })();
  221. //=============================================================================
  222. //===================================END FILE==================================
  223. //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement