Advertisement
dsiver144

DSI Limited Dashing [MV]

Jan 27th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*:
  2.  * @plugindesc Plugin used to disable dashing & stuff.
  3.  * <DSI Limited Dash>
  4.  * @author dsiver144
  5.  *
  6.  * @help Last Updated: 1/27/2018
  7.  * Maybe you don't need help for this plugin, lol. Just play around with those
  8.  * variables.
  9.  *
  10.  * @param HudMain
  11.  * @text HUD Settings
  12.  *
  13.  * @param HudDisable
  14.  * @text Disable HUD
  15.  * @type boolean
  16.  * @on Enable
  17.  * @off Disable
  18.  * @parent HudMain
  19.  *
  20.  * @param HudDisableSwitch
  21.  * @text HUD Disable Switch
  22.  * @type switch
  23.  * @default 9
  24.  * @parent HudMain
  25.  *
  26.  * @param hudX
  27.  * @text HUD X
  28.  * @type number
  29.  * @default 5
  30.  * @parent HudMain
  31.  *
  32.  * @param hudY
  33.  * @text HUD Y
  34.  * @type number
  35.  * @default 5
  36.  * @parent HudMain
  37.  *
  38.  * @param hudText
  39.  * @text HUD Text
  40.  * @default Stamina
  41.  * @parent HudMain
  42.  *
  43.  * @param hudGaugeColor1
  44.  * @text HUD Gauge Color 1
  45.  * @default #F7B646
  46.  * @parent HudMain
  47.  
  48.  * @param hudGaugeColor2
  49.  * @text HUD Gauge Color 2
  50.  * @default #DA8A3B
  51.  * @parent HudMain
  52.  *
  53.  * @param MainSettings
  54.  * @text Main Settings
  55.  *
  56.  * @param defaultMaxStamina
  57.  * @text Set Default Max Stamina
  58.  * @default 100
  59.  * @parent MainSettings
  60.  *
  61.  * @param maxStaminaVariable
  62.  * @text Set Max Stamina Variable ID
  63.  * @type variable
  64.  * @default 10
  65.  * @parent MainSettings
  66.  *
  67.  * @param currentStaminaVariable
  68.  * @text Set Current Stamina Variable ID
  69.  * @type variable
  70.  * @default 11
  71.  * @parent MainSettings
  72.  *
  73.  * @param StaminaTimer
  74.  * @text Set Stamina Timer
  75.  * @default 10
  76.  * @parent MainSettings
  77.  *
  78.  * @param BurnAmount
  79.  * @text Set Burn Amount
  80.  * @default 5
  81.  * @parent MainSettings
  82.  *
  83.  * @param RecoverAmount
  84.  * @text Set Recover Amount
  85.  * @default 1
  86.  * @parent MainSettings
  87.  *
  88.  * @param disableDashSwitchID
  89.  * @text Set Switch for disable dash
  90.  * @type switch
  91.  * @default 10
  92.  * @parent MainSettings
  93. */
  94.  
  95. var DSIVER144 = DSIVER144 || {};
  96.  
  97. var params = $plugins.filter(function(p) { return p.description.contains('<DSI Limited Dash>'); })[0].parameters;
  98.     DSIVER144.maxStamina = Number(params['defaultMaxStamina'] || 100);
  99.     DSIVER144.maxStaminaVarID = Number(params['maxStaminaVariable'] || 10);
  100.     DSIVER144.curStaminaVarID = Number(params['currentStaminaVariable'] || 11);
  101.     DSIVER144.staminaTimer = Number(params['StaminaTimer'] || 10);
  102.     DSIVER144.burnAmount = Number(params['BurnAmount'] || 5);
  103.     DSIVER144.recoverAmount = Number(params['RecoverAmount'] || 1);
  104.     DSIVER144.disableDashSwID = Number(params['disableDashSwitchID'] || 10);
  105.     DSIVER144.hudX = Number(params['hudX']);
  106.     DSIVER144.hudY = Number(params['hudY']);
  107.     DSIVER144.hudText = params['hudText'];
  108.     DSIVER144.hudColor1 = params['hudGaugeColor1'];
  109.     DSIVER144.hudColor2 = params['hudGaugeColor2'];
  110.     DSIVER144.hudDisable = params['HudDisable'];
  111.     DSIVER144.hudDisableSwitch = Number(params['HudDisableSwitch']);
  112.     console.log(DSIVER144);
  113.  
  114. (function(dsi){
  115.    
  116.     //function Window_DashStamina
  117.     var dashWindow;
  118.    
  119.     function Window_DashStamina() {
  120.         this.initialize.apply(this, arguments);
  121.     }
  122.  
  123.     Window_DashStamina.prototype = Object.create(Window_Base.prototype);
  124.     Window_DashStamina.prototype.constructor = Window_DashStamina;
  125.  
  126.     Window_DashStamina.prototype.initialize = function(x, y) {
  127.         var width = this.windowWidth();
  128.         var height = this.windowHeight();
  129.         Window_Base.prototype.initialize.call(this, x, y, width, height);
  130.         this.refresh();
  131.     };
  132.  
  133.     Window_DashStamina.prototype.windowWidth = function() {
  134.         return 300;
  135.     };
  136.  
  137.     Window_DashStamina.prototype.windowHeight = function() {
  138.         return this.fittingHeight(1);
  139.     };
  140.  
  141.     Window_DashStamina.prototype.refresh = function() {
  142.         var x = this.textPadding();
  143.         var width = this.contents.width - this.textPadding() * 2;
  144.         this.contents.clear();
  145.         if ($gameSwitches.value(dsi.hudDisableSwitch) === true) {
  146.             this.hide();
  147.             return;
  148.         } else {
  149.             this.show();
  150.         }
  151.         var color1 = dsi.hudColor1;
  152.         var color2 = dsi.hudColor2;
  153.         this.contents.fontSize = 19;
  154.         var rate = $gameVariables.value(dsi.curStaminaVarID) / $gameVariables.value(dsi.maxStaminaVarID);
  155.         this.drawGauge(0,0,width,rate,color1,color2);
  156.         this.drawText((rate * 100).toFixed(0) + '%',0,-7, width, 'right');
  157.         this.drawText(dsi.hudText,0,-7,width, 'left');
  158.     };
  159.    
  160.     var _alias_Scene_Map_createAllWindows = Scene_Map.prototype.createAllWindows;
  161.     Scene_Map.prototype.createAllWindows = function() {
  162.         _alias_Scene_Map_createAllWindows.call(this);
  163.         if (dsi.hudDisable !== 'true')
  164.             this.createDashStaminaWindow();
  165.     };
  166.  
  167.     Scene_Map.prototype.createDashStaminaWindow = function() {
  168.         this._staminaWindow = new Window_DashStamina(dsi.hudX,dsi.hudY);
  169.         dashWindow = this._staminaWindow;
  170.         this.addChild(this._staminaWindow);
  171.     };
  172.    
  173.     var _alias_Game_Player_initMembers = Game_Player.prototype.initMembers;
  174.     Game_Player.prototype.initMembers = function() {
  175.         _alias_Game_Player_initMembers.call(this);
  176.         $gameVariables.setValue(dsi.maxStaminaVarID, dsi.maxStamina);
  177.         $gameVariables.setValue(dsi.curStaminaVarID, dsi.maxStamina);
  178.         this._canDash = true;
  179.         this._dashDelayTime = dsi.staminaTimer;
  180.     };
  181.    
  182.     Game_Player.prototype.updateDashing = function() {
  183.         if (this._dashing === true && this.isMoving()) {
  184.             if ($gameVariables.value(dsi.curStaminaVarID) > 0) {
  185.                 if (this._dashDelayTime === 0) {
  186.                     $gameVariables.setValue(dsi.curStaminaVarID, $gameVariables.value(dsi.curStaminaVarID) - dsi.burnAmount);
  187.                     this._dashDelayTime = dsi.staminaTimer;
  188.                     console.log($gameVariables.value(dsi.curStaminaVarID));
  189.                     if ($gameVariables.value(dsi.curStaminaVarID) <= 0) {
  190.                         $gameVariables.setValue(dsi.curStaminaVarID, 0);
  191.                         this._dashing = false;
  192.                         this._canDash = false;
  193.                     }
  194.                     if (dashWindow) dashWindow.refresh();
  195.                 } else {
  196.                     this._dashDelayTime -= 1;
  197.                 }
  198.             }
  199.         } else {
  200.             if ($gameVariables.value(dsi.curStaminaVarID) < $gameVariables.value(dsi.maxStaminaVarID)) {
  201.                 if (this._dashDelayTime === 0) {
  202.                    $gameVariables.setValue(dsi.curStaminaVarID, $gameVariables.value(dsi.curStaminaVarID) + dsi.recoverAmount);
  203.                     this._dashDelayTime = dsi.staminaTimer;
  204.                     console.log($gameVariables.value(dsi.curStaminaVarID));
  205.                     if ($gameVariables.value(dsi.curStaminaVarID) >= 40) {
  206.                         this._canDash = true;
  207.                     }
  208.                     if ($gameVariables.value(dsi.curStaminaVarID) >= $gameVariables.value(dsi.maxStaminaVarID)) {
  209.                         $gameVariables.setValue(dsi.curStaminaVarID, $gameVariables.value(dsi.maxStaminaVarID));
  210.                     }
  211.                     if (dashWindow) dashWindow.refresh();
  212.                 } else {
  213.                     this._dashDelayTime -= 1;
  214.                 }
  215.             }
  216.         }
  217.         if (this.isMoving()) {
  218.             return;
  219.         }
  220.         if (this.canMove() && !this.isInVehicle() && !$gameMap.isDashDisabled() && this._canDash && !$gameSwitches.value(dsi.disableDashSwID)) {
  221.             this._dashing = this.isDashButtonPressed() || $gameTemp.isDestinationValid();
  222.         } else {
  223.             this._dashing = false;
  224.         }
  225.     };
  226. })(DSIVER144);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement