Advertisement
dsiver144

DSI Limited Dashing [MV]

Jan 27th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.51 KB | None | 0 0
  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 hudFadeInSpeed
  54. * @text HUD Fade In Speed
  55. * @default 20
  56. * @type number
  57. * @parent HudMain
  58. *
  59. * @param hudFadeOutSpeed
  60. * @text HUD Fade Out Speed
  61. * @default 5
  62. * @type number
  63. * @parent HudMain
  64. *
  65. * @param MainSettings
  66. * @text Main Settings
  67. *
  68. * @param defaultMaxStamina
  69. * @text Set Default Max Stamina
  70. * @default 100
  71. * @parent MainSettings
  72. *
  73. * @param maxStaminaVariable
  74. * @text Set Max Stamina Variable ID
  75. * @type variable
  76. * @default 10
  77. * @parent MainSettings
  78. *
  79. * @param currentStaminaVariable
  80. * @text Set Current Stamina Variable ID
  81. * @type variable
  82. * @default 11
  83. * @parent MainSettings
  84. *
  85. * @param StaminaTimer
  86. * @text Set Stamina Timer
  87. * @default 10
  88. * @parent MainSettings
  89. *
  90. * @param BurnAmount
  91. * @text Set Burn Amount
  92. * @default 5
  93. * @parent MainSettings
  94. *
  95. * @param EnableDashAmount
  96. * @text Set Stamina Amount to enable Dash
  97. * @default 40
  98. * @parent MainSettings
  99. *
  100. * @param EnableDashSE
  101. * @text Set Enable Dash Sound Effect (SE)
  102. * @type @type struct<SFX>
  103. *
  104. * @param RunOutOfStaminaSE
  105. * @text Set Sound Effect (SE) when run out of stamina
  106. * @type @type struct<SFX>
  107. *
  108. * @param RecoverAmount
  109. * @text Set Recover Amount
  110. * @default 1
  111. * @parent MainSettings
  112. *
  113. * @param disableDashSwitchID
  114. * @text Set Switch for disable dash
  115. * @type switch
  116. * @default 10
  117. * @parent MainSettings
  118. */
  119.  
  120. /*~struct~SFX:
  121. * @param name
  122. * @text path
  123. * @type file
  124. * @dir audio/se
  125. * @require 1
  126. *
  127. * @param volume
  128. * @desc Max = 150 | Min = 0
  129. * @type number
  130. * @min 0
  131. * @max 100
  132. * @default 100
  133. *
  134. * @param pitch
  135. * @desc Max = 150 | Min = 0
  136. * @type number
  137. * @min 0
  138. * @max 150
  139. * @default 100
  140. *
  141. * @param pan
  142. * @desc Max = 100 | Min = 0
  143. * @type number
  144. * @min 0
  145. * @max 100
  146. * @default 100
  147. */
  148.  
  149. var DSIVER144 = DSIVER144 || {};
  150.  
  151. var params = $plugins.filter(function(p) { return p.description.contains('<DSI Limited Dash>'); })[0].parameters;
  152. DSIVER144.maxStamina = Number(params['defaultMaxStamina'] || 100);
  153. DSIVER144.maxStaminaVarID = Number(params['maxStaminaVariable'] || 10);
  154. DSIVER144.curStaminaVarID = Number(params['currentStaminaVariable'] || 11);
  155. DSIVER144.staminaTimer = Number(params['StaminaTimer'] || 10);
  156. DSIVER144.burnAmount = Number(params['BurnAmount'] || 5);
  157. DSIVER144.recoverAmount = Number(params['RecoverAmount'] || 1);
  158. DSIVER144.disableDashSwID = Number(params['disableDashSwitchID'] || 10);
  159. DSIVER144.hudX = Number(params['hudX']);
  160. DSIVER144.hudY = Number(params['hudY']);
  161. DSIVER144.hudText = params['hudText'];
  162. DSIVER144.hudColor1 = params['hudGaugeColor1'];
  163. DSIVER144.hudColor2 = params['hudGaugeColor2'];
  164. DSIVER144.hudDisable = params['HudDisable'];
  165. DSIVER144.hudDisableSwitch = Number(params['HudDisableSwitch']);
  166. DSIVER144.enableDashAmount = Number(params['EnableDashAmount']);
  167. DSIVER144.enableDashSE = JSON.parse(params['EnableDashSE']);
  168. DSIVER144.enableDashSE.volume = Number(DSIVER144.enableDashSE.volume);
  169. DSIVER144.enableDashSE.pitch = Number(DSIVER144.enableDashSE.pitch);
  170. DSIVER144.enableDashSE.pan = Number(DSIVER144.enableDashSE.pan);
  171. DSIVER144.outOfStaminaSE = JSON.parse(params['RunOutOfStaminaSE']);
  172. DSIVER144.outOfStaminaSE.volume = Number(DSIVER144.enableDashSE.volume);
  173. DSIVER144.outOfStaminaSE.pitch = Number(DSIVER144.enableDashSE.pitch);
  174. DSIVER144.outOfStaminaSE.pan = Number(DSIVER144.enableDashSE.pan);
  175. DSIVER144.fadeInSpeed = Number(params['hudFadeInSpeed'] || 20);
  176. DSIVER144.fadeOutSpeed = Number(params['hudFadeOutSpeed'] || 5);
  177. console.log(DSIVER144);
  178.  
  179. (function(dsi){
  180. //function Window_DashStamina
  181. var dashWindow;
  182.  
  183. function Window_DashStamina() {
  184. this.initialize.apply(this, arguments);
  185. }
  186.  
  187. Window_DashStamina.prototype = Object.create(Window_Base.prototype);
  188. Window_DashStamina.prototype.constructor = Window_DashStamina;
  189.  
  190. Window_DashStamina.prototype.initialize = function(x, y) {
  191. var width = this.windowWidth();
  192. var height = this.windowHeight();
  193.  
  194. Window_Base.prototype.initialize.call(this, x, y, width, height);
  195. this._sprite = new Sprite();
  196. this._sprite.x = this.x + this.padding;
  197. this._sprite.y = this.y + this.padding;
  198. this._sprite.bitmap = new Bitmap(this.contents.width, this.contents.height);
  199. this._sprite.opacity = 255;
  200. console.log(this._sprite);
  201. this.addChild(this._sprite);
  202. this.changeOpacity(0);
  203. this.refresh();
  204. };
  205.  
  206. Window_DashStamina.prototype.changeOpacity = function(opacity) {
  207. //this.backOpacity = opacity;
  208. this.opacity = opacity;
  209. this._sprite.opacity = opacity;
  210. }
  211.  
  212. Window_DashStamina.prototype.windowWidth = function() {
  213. return 300;
  214. };
  215.  
  216. Window_DashStamina.prototype.windowHeight = function() {
  217. return this.fittingHeight(1);
  218. };
  219.  
  220. Window_DashStamina.prototype.refresh = function() {
  221. var x = this.textPadding();
  222. var width = this.contents.width - this.textPadding() * 2;
  223. this.contents.clear();
  224. this.contents._canvas.opacity = 0;
  225. if ($gameSwitches.value(dsi.hudDisableSwitch) === true) {
  226. this.hide();
  227. return;
  228. } else {
  229. this.show();
  230. }
  231. var color1 = dsi.hudColor1;
  232. var color2 = dsi.hudColor2;
  233. this.contents.fontSize = 19;
  234. var rate = $gameVariables.value(dsi.curStaminaVarID) / $gameVariables.value(dsi.maxStaminaVarID);
  235. this.drawGauge(0,0,width,rate,color1,color2);
  236. this.drawText((rate * 100).toFixed(0) + '%',0,-7, width, 'right');
  237. this.drawText(dsi.hudText,0,-7,width, 'left');
  238. this._sprite.bitmap.clear();
  239. this._sprite.bitmap.blt(this.contents,0,0,this.contents.width, this.contents.height, 0, 0, 0, 0);
  240. this.contents.clear();
  241. };
  242.  
  243. var _alias_Scene_Map_createAllWindows = Scene_Map.prototype.createAllWindows;
  244. Scene_Map.prototype.createAllWindows = function() {
  245. _alias_Scene_Map_createAllWindows.call(this);
  246. if (dsi.hudDisable !== 'true')
  247. this.createDashStaminaWindow();
  248. };
  249.  
  250. Scene_Map.prototype.createDashStaminaWindow = function() {
  251. this._staminaWindow = new Window_DashStamina(dsi.hudX,dsi.hudY);
  252. dashWindow = this._staminaWindow;
  253. this.addChild(this._staminaWindow);
  254. };
  255.  
  256. var _alias_Game_Player_initMembers = Game_Player.prototype.initMembers;
  257. Game_Player.prototype.initMembers = function() {
  258. _alias_Game_Player_initMembers.call(this);
  259. $gameVariables.setValue(dsi.maxStaminaVarID, dsi.maxStamina);
  260. $gameVariables.setValue(dsi.curStaminaVarID, dsi.maxStamina);
  261. this._canDash = true;
  262. this._dashStaminaIncreaseFlag = false;
  263. this._dashDelayTime = dsi.staminaTimer;
  264. };
  265.  
  266. Game_Player.prototype.updateDashing = function() {
  267. if (this._dashing === true && this.isMoving()) {
  268. if (dashWindow && dashWindow.opacity < 255) {
  269. dashWindow.changeOpacity(dashWindow.opacity + dsi.fadeInSpeed);
  270. }
  271. if ($gameVariables.value(dsi.curStaminaVarID) > 0) {
  272. if (this._dashDelayTime === 0) {
  273. $gameVariables.setValue(dsi.curStaminaVarID, $gameVariables.value(dsi.curStaminaVarID) - dsi.burnAmount);
  274. this._dashDelayTime = dsi.staminaTimer;
  275. if ($gameVariables.value(dsi.curStaminaVarID) <= 0 && this._canDash) {
  276. $gameVariables.setValue(dsi.curStaminaVarID, 0);
  277. this._dashing = false;
  278. this._canDash = false;
  279. AudioManager.playStaticSe(dsi.outOfStaminaSE);
  280. }
  281. if (dashWindow) dashWindow.refresh();
  282. } else {
  283. this._dashDelayTime -= 1;
  284. }
  285. }
  286. }
  287. if (this._dashing && !this.isMoving()) {
  288. this._dashing = false;
  289. }
  290. if (this._dashing === false && $gameVariables.value(dsi.curStaminaVarID) < $gameVariables.value(dsi.maxStaminaVarID)) {
  291. if (dashWindow && dashWindow.opacity > 0) {
  292. dashWindow.changeOpacity(dashWindow.opacity - dsi.fadeOutSpeed);
  293. }
  294. if (this._dashDelayTime === 0) {
  295. $gameVariables.setValue(dsi.curStaminaVarID, $gameVariables.value(dsi.curStaminaVarID) + dsi.recoverAmount);
  296. this._dashDelayTime = dsi.staminaTimer;
  297. if ($gameVariables.value(dsi.curStaminaVarID) >= dsi.enableDashAmount && !this._canDash) {
  298. this._canDash = true;
  299. AudioManager.playStaticSe(dsi.enableDashSE);
  300. }
  301. if ($gameVariables.value(dsi.curStaminaVarID) >= $gameVariables.value(dsi.maxStaminaVarID)) {
  302. $gameVariables.setValue(dsi.curStaminaVarID, $gameVariables.value(dsi.maxStaminaVarID));
  303. }
  304. if (dashWindow) dashWindow.refresh();
  305. } else {
  306. this._dashDelayTime -= 1;
  307. }
  308. }
  309. if (this.isMoving()) {
  310. return;
  311. }
  312. if (this.canMove() && !this.isInVehicle() && !$gameMap.isDashDisabled() && this._canDash && !$gameSwitches.value(dsi.disableDashSwID)) {
  313. this._dashing = (this.isDashButtonPressed() || $gameTemp.isDestinationValid());
  314. } else {
  315. this._dashing = false;
  316. }
  317. };
  318. })(DSIVER144);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement