Advertisement
dsiver144

DSI Limited Dashing [MV]

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