Icaro_10_100

Ultimate Stat Distribution 1.1

Mar 31st, 2016
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // StatDistribution.js
  3. //=============================================================================
  4.  
  5. /*:
  6. @author Icaro10100 / FrozenPhoenix
  7. @plugindesc Get stat points on level up, those points can be spent to increase stat value
  8. @help
  9.  
  10. *********************************************************************************
  11.  
  12. Actors will gain stat points whenever they level up or when you want to give
  13. them via script call: $gameActors[id].gainStats(amount)
  14.  
  15. Those points can be used to increase the actor's stats via a custom scene.
  16. To call the scene use the call: SceneManager.sceneDistribution(actor)
  17.  
  18. Example: SceneManager.sceneDistribution($gameParty.members()[0])
  19. Learn the basic script calls
  20.  
  21. Holding shift while increasing the attributes will increase them faster.
  22.  
  23. Press "x" to toggle between decrease/increase option
  24.  
  25. Put the following tags to determine how much the param/stat will increase per
  26. stat point spent:
  27.  
  28. <ihp: amount>
  29. <imp: amount>
  30. <iatk: amount>
  31. <idef: amount>
  32. <imat: amount>
  33. <imdf: amount>
  34. <iagi: amount>
  35. <iluk: amount>
  36.  
  37. For extra parameters:
  38.  
  39. <ihit: amount>
  40. <ieva: amount>
  41. <icri: amount>
  42. <icev: amount>
  43. <imev: amount>
  44. <imrf: amount>
  45. <icnt: amount>
  46. <ihrg: amount>
  47. <imrg: amount>
  48. <itrg: amount>
  49.  
  50. The tags should be put in the class notebox
  51.  
  52. Feel free to use for free/comercial games, just give credit.
  53. Enjoy
  54.  
  55. ChangeLog:
  56.  
  57. --1.1
  58. -Added names for some stuff
  59. -Added option to decrease stat
  60. -Added support for extra parameters (crit/evasion etc)
  61.  
  62. *********************************************************************************
  63.  
  64. @param PointsName
  65. @desc The name given to stat points
  66. @default Points
  67.  
  68. @param ActorName
  69. @desc The word before the actor's name
  70. @default Name
  71.  
  72. @param ClassName
  73. @desc The word before the actor's class
  74. @default Class
  75.  
  76. @param ExpName
  77. @desc The word before the actor's experience
  78. @default EXP
  79.  
  80. @param IncreaseName
  81. @desc The word that means increase duhhh (if doing game on another language)
  82. @default Increase
  83.  
  84. @param DecreaseName
  85. @desc Same thing as before
  86. @default Decrease
  87.  
  88. @param StatNameColor
  89. @desc The color the stat's name appears, select a number from the windowskin
  90. @default 1
  91.  
  92. @param StatValueColor
  93. @desc The color the stat's value appears, select a number from the windowskin
  94. @default 0
  95.  
  96. @param ShiftIncrease
  97. @desc When holding shift, the amount increased will be multiplicated by this parameter
  98. @default 5
  99.  
  100. @param LevelUpPoints
  101. @desc Points gained on level up, can be any number or formula that returns a number
  102. @default 10
  103.  
  104. @param UsedStats
  105. @desc The basic stats that will be available to increase, put the id separated by a comma Example: 0,3,4,5
  106. @default 0,1,2,3,4,5,6,7
  107.  
  108. @param UsedXStats
  109. @desc Same as before, but for extra parameters (crit/evasion etc)
  110. @default
  111.  
  112. @param ExtraParamNames
  113. @desc Names for the extra stats (crit/evasion etc), just modify the strings in the default.
  114. @default ["Hit rate", "Evasion", "Crit chance", "Crit Evasion", "Magic Evasion", "Magic Reflect", "Counter", "HP Regen", "MP Regen", "TP Regen"]
  115.  
  116.  
  117. */
  118.  
  119.  
  120.  
  121. (function() {
  122.    
  123. //Parameters   
  124. var parameters = PluginManager.parameters('StatDistribution');
  125. var pointsName = String(parameters["PointsName"]);
  126. var actorName = String(parameters["ActorName"]);
  127. var className = String(parameters["ClassName"]);
  128. var expName = String(parameters["ExpName"]);
  129. var increaseName = String(parameters["IncreaseName"]);
  130. var decreaseName = String(parameters["DecreaseName"]);
  131. var statNameColor = Number(parameters["StatNameColor"]);
  132. var statValueColor = Number(parameters["StatValueColor"]);
  133. var shiftIncrease = Number(parameters["ShiftIncrease"]);
  134. var levelUpPoints = String(parameters["LevelUpPoints"]);
  135. var usedStats = String(parameters["UsedStats"]);
  136. var usedXStats = String(parameters["UsedXStats"]);
  137. var xParamNames = String(parameters["ExtraParamNames"]);
  138.  
  139.  
  140. //This function will return an array with the ids of the used stats
  141. getUsedStats = function() {
  142.     var re = /\d+/g;
  143.     return usedStats.match(re) || [];  
  144. }
  145.  
  146. //This function will return an array with the ids of the used extra stats
  147. getUsedXStats = function() {
  148.     var re = /\d+/g;
  149.     return usedXStats.match(re) || []; 
  150. }
  151.  
  152. //This function will return the name of the extra param with given index
  153. getXParamName = function(id) {
  154.     var names = eval(xParamNames);
  155.     return names[id];
  156. }
  157.  
  158. //Game batlerbase
  159.  
  160. Game_BattlerBase.prototype.xparam = function(xparamId) {
  161.     var value = this.traitsSum(Game_BattlerBase.TRAIT_XPARAM, xparamId) + this._gainedxparams[xparamId];
  162.     return value;
  163. };
  164.  
  165. _GameBattlerBaseInitialize = Game_BattlerBase.prototype.initialize;
  166. Game_BattlerBase.prototype.initialize = function() {
  167.     _GameBattlerBaseInitialize.call(this);
  168.     this._gainedxparams = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  169. };
  170.  
  171.  
  172.    
  173. //---Game Actor
  174.  
  175. _GameActorInitialize = Game_Actor.prototype.initialize;
  176. Game_Actor.prototype.initialize = function(actorId) {
  177.     _GameActorInitialize.call(this, actorId);
  178.     this._statPoints = 0;
  179. };
  180.  
  181. //Stat increase per stat point
  182. Game_Actor.prototype.statPerPoint = function(id) {
  183.     var str;
  184.     switch(id) {
  185.         case 0:
  186.             str = "ihp";
  187.             break;
  188.         case 1:
  189.             str = "imp";
  190.             break;
  191.         case 2:
  192.             str = "iatk";
  193.             break;
  194.         case 3:
  195.             str = "idef";
  196.             break;
  197.         case 4:
  198.             str = "imat";
  199.             break;
  200.         case 5:
  201.             str = "imdf";
  202.             break;
  203.         case 6:
  204.             str = "iagi";
  205.             break;
  206.         case 7:
  207.             str = "iluk";
  208.             break;         
  209.     }
  210.     var met = "$dataClasses[this._classId].meta." + str;
  211.     met = eval(met);
  212.     return eval(met);// ? eval(met) : 1;
  213. }
  214.  
  215. //Xstat increase per stat point
  216. Game_Actor.prototype.xstatPerPoint = function(id) {
  217.     var str;
  218.     switch(id) {
  219.         case 0:
  220.             str = "ihit";
  221.             break;
  222.         case 1:
  223.             str = "ieva";
  224.             break;
  225.         case 2:
  226.             str = "icri";
  227.             break;
  228.         case 3:
  229.             str = "icev";
  230.             break;
  231.         case 4:
  232.             str = "imev";
  233.             break;
  234.         case 5:
  235.             str = "imrf";
  236.             break;
  237.         case 6:
  238.             str = "icnt";
  239.             break;
  240.         case 7:
  241.             str = "ihrg";
  242.             break;
  243.         case 8:
  244.             str = "imrg";
  245.             break;
  246.         case 9:
  247.             str = "itrg";
  248.     }
  249.     var met = "$dataClasses[this._classId].meta." + str;
  250.     met = eval(met);
  251.     return eval(met) ? eval(met) : 1;
  252. }
  253.  
  254. //-New function gainStats to call on level ups etc
  255. Game_Actor.prototype.gainStats = function(amount) {
  256.     this._statPoints += amount;
  257. }
  258.  
  259. //-Gain stats on level up
  260. _GameActorLevelUp = Game_Actor.prototype.levelUp;
  261. Game_Actor.prototype.levelUp = function() {
  262.     _GameActorLevelUp.call(this);
  263.     this.gainStats(eval(levelUpPoints));
  264. };
  265.  
  266. //-Actor current stats 
  267. Game_Actor.prototype.statPoints = function() {
  268.     return this._statPoints;
  269. }  
  270.    
  271. //-----New windows
  272.  
  273. //****************************************************
  274. //
  275. //---Window Points, to display stat points.
  276. //
  277. //****************************************************
  278.  
  279.  
  280. function Window_Points() {
  281.     this.initialize.apply(this, arguments);
  282. }
  283.  
  284. Window_Points.prototype = Object.create(Window_Base.prototype);
  285. Window_Points.prototype.constructor = Window_Points;
  286.  
  287. Window_Points.prototype.initialize = function(x, y, actor) {
  288.     var width = this.windowWidth();
  289.     var height = this.windowHeight();
  290.     this._actor = actor;
  291.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  292.     this.refresh();
  293. };
  294.  
  295. Window_Points.prototype.windowWidth = function() {
  296.     return 300;
  297. };
  298.  
  299. Window_Points.prototype.windowHeight = function() {
  300.     return this.fittingHeight(1);
  301. };
  302.  
  303. Window_Points.prototype.refresh = function() {
  304.     var x = this.textPadding();
  305.     var width = this.contents.width - this.textPadding() * 2;
  306.     this.contents.clear();
  307.     this.drawThings();
  308. };
  309.  
  310. Window_Points.prototype.drawThings = function() {
  311.     var x = 1;
  312.     var y = 1;
  313.     var mWidth = Math.round(this.windowWidth()/2.5);
  314.     var value = this._actor.statPoints();
  315.     this.changeTextColor(this.textColor(statNameColor));
  316.     this.drawText(pointsName, x, y, mWidth);
  317.     this.changeTextColor(this.textColor(statValueColor));
  318.     this.drawText(value, x + mWidth + 10, y, mWidth);  
  319. }
  320.  
  321. Window_Points.prototype.open = function() {
  322.     this.refresh();
  323.     Window_Base.prototype.open.call(this);
  324. };
  325.  
  326.  
  327. //****************************************************
  328. //
  329. //---Window Selecting, to increase stats or leave scene
  330. //
  331. //****************************************************
  332.  
  333.  
  334. Window_Selecting.prototype = Object.create(Window_Command.prototype);
  335. Window_Selecting.prototype.constructor = Window_Selecting;
  336.  
  337. function Window_Selecting() {
  338.     this.initialize.apply(this, arguments);
  339. }
  340.  
  341. Window_Selecting.prototype.initialize = function (x, y, mode) {
  342.     this._mode = mode;
  343.     Window_Command.prototype.initialize.call(this, x, y);
  344. }
  345.  
  346. Window_Selecting.prototype.windowWidth = function() {
  347.     return 350;
  348. };
  349.  
  350. Window_Selecting.prototype.numVisibleRows = function() {
  351.     return 9;
  352. };
  353.  
  354. Window_Selecting.prototype.processOk = function() {
  355.     if (this.isCurrentItemEnabled()) {
  356.         this.updateInputData();
  357.         this.deactivate();
  358.         this.callOkHandler();
  359.     }
  360. };
  361.  
  362. Window_Selecting.prototype.activate = function(index) {
  363.     Window_Base.prototype.activate.call(this);
  364.     index2 = index ? index : this._index;
  365.     this.select(index2);
  366. };
  367.  
  368. Window_Selecting.prototype.makeCommandList = function() {
  369.     var name;
  370.     var used = getUsedStats();
  371.     var usedx = getUsedXStats();
  372.     var k;
  373.     var mode = this._mode;
  374.     for(i=0;i<used.length;i++) {
  375.         k = Number(used[i]);
  376.         name = mode + " " + TextManager.param(k);
  377.         this.addCommand(name, 'param' + k.toString());
  378.     }
  379.     for(i=0;i<usedx.length;i++) {
  380.         k = Number(usedx[i]);
  381.         y = k + 10;
  382.         name = mode + " " + getXParamName(k);
  383.         this.addCommand(name, 'param' + y.toString());
  384.     }
  385.     this.addCommand("Exit", 'exit');
  386. }
  387.  
  388.  
  389. //****************************************************
  390. //
  391. //---Window Char, display character image and current stats
  392. //
  393. //****************************************************
  394.  
  395. function Window_xParams() {
  396.     this.initialize.apply(this, arguments);
  397. }
  398.  
  399. Window_xParams.prototype = Object.create(Window_Base.prototype);
  400. Window_xParams.prototype.constructor = Window_xParams;
  401.  
  402. Window_xParams.prototype.initialize = function (x, y, actor, increased) {
  403.     this._increased = increased;
  404.     this._width = Graphics.boxWidth - x;
  405.     var height = Graphics.boxHeight - y;
  406.     Window_Base.prototype.initialize.call(this, x, y, this._width, height);
  407.     this._actor = actor;
  408.     this.refresh();
  409. };
  410.  
  411. Window_xParams.prototype.actor = function() {
  412.     return this._actor;
  413. };
  414.  
  415. Window_xParams.prototype.baseDraw = function(name, value, x, y) {
  416.     var mWidth = Math.round(this._width/1.5);
  417.     var x2 = x + mWidth + 5;
  418.     this.changeTextColor(this.textColor(statNameColor));
  419.     this.drawText(name, x, y, mWidth);
  420.     this.changeTextColor(this.textColor(statValueColor));
  421.     this.drawText(value, x2, y, mWidth);
  422. }
  423.  
  424. Window_xParams.prototype.drawActorStat = function(x, y, id) {
  425.     var pName = getXParamName(id);
  426.     var pValue = this.actor().xparam(id) + this._increased[id];
  427.     this.baseDraw(pName, pValue.toFixed(2), x, y);
  428. };
  429.  
  430. Window_xParams.prototype.drawParameters = function() {
  431.     var x = 1;
  432.     var y = 1;
  433.     var usedx = getUsedXStats();
  434.     var lineHeight = this.lineHeight();
  435.     for(i=0;i<usedx.length;i++) {
  436.         this.drawActorStat(x, y + lineHeight * i, Number(usedx[i]));       
  437.     }
  438. }
  439.  
  440. Window_xParams.prototype.refresh = function() {
  441.     if (this.contents) {
  442.         this.contents.clear();
  443.         this.drawParameters();
  444.     }
  445. }
  446.  
  447.  
  448. //****************************************************
  449. //
  450. //---Window Char, display character image and current stats
  451. //
  452. //****************************************************
  453.  
  454.  
  455. function Window_Char() {
  456.     this.initialize.apply(this, arguments);
  457. }
  458.  
  459. Window_Char.prototype = Object.create(Window_Base.prototype);
  460. Window_Char.prototype.constructor = Window_Char;
  461.  
  462.  
  463. Window_Char.prototype.initialize = function (x, y, actor, increased) {
  464.     var width = this.windowWidth();
  465.     var height = this.windowHeight();
  466.     this._increased = increased;
  467.     this._actor = actor;
  468.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  469.     this.loadImages();
  470.     this.refresh();
  471. };
  472.  
  473. Window_Char.prototype.actor = function() {
  474.     return this._actor;
  475. };
  476.  
  477. Window_Char.prototype.windowWidth = function() {
  478.     return Graphics.boxWidth;
  479. };
  480.  
  481. Window_Char.prototype.windowHeight = function() {
  482.     return Math.round(Graphics.boxHeight / 3) - 20;
  483. };
  484.  
  485. Window_Char.prototype.loadImages = function() {
  486.     ImageManager.loadFace(this.actor().faceName());
  487. };
  488.  
  489. Window_Char.prototype.drawItem = function() {
  490.     this.drawItemImage();
  491.     this.drawItemStatus();
  492.     this.drawParameters();
  493. };
  494.  
  495. Window_Char.prototype.drawItemImage = function() {
  496.     this.drawActorFace(this.actor(), 1, 1, 144, 144);
  497. };
  498.  
  499. Window_Char.prototype.drawItemStatus = function() {
  500.     var x = 160;
  501.     var actor = this.actor();
  502.     var y = 1;
  503.     var lineHeight = this.lineHeight();
  504.     this.drawActorName(actor, x, y);
  505.     this.drawActorLevel(actor, x, y + lineHeight * 1);
  506.     this.drawActorClass(actor, x, y + lineHeight * 2);
  507.     this.drawActorExp(actor, x, y + lineHeight * 3);
  508. };
  509.  
  510. Window_Char.prototype.drawParameters = function() {
  511.     var x = 390;
  512.     var y = 1;
  513.     var used = getUsedStats();
  514.     var lineHeight = this.lineHeight();
  515.     var k;
  516.     for(i=0;i<used.length;i++) {
  517.         if (i < 4) {
  518.             this.drawActorStat(x, y + lineHeight * i, used[i]);
  519.         } else {
  520.             k = i-4;   
  521.             this.drawActorStat(x + 220, y + lineHeight * k, used[i]);
  522.         }  
  523.     }
  524. }
  525.  
  526. Window_Char.prototype.baseDraw = function(name, value, x, y) {
  527.     var mWidth = Math.round(this.windowWidth()/8);
  528.     var x2 = x + mWidth + 10;
  529.     this.changeTextColor(this.textColor(statNameColor));
  530.     this.drawText(name, x, y, mWidth);
  531.     this.changeTextColor(this.textColor(statValueColor));
  532.     this.drawText(value, x2, y, mWidth);
  533. }
  534.  
  535. Window_Char.prototype.drawActorExp = function(actor, x, y) {
  536.     this.baseDraw(expName, actor.currentExp(), x, y);
  537. }
  538.  
  539. Window_Char.prototype.drawActorClass = function(actor, x, y) {
  540.     this.baseDraw(className, actor.currentClass().name, x, y);
  541. }
  542.  
  543. Window_Char.prototype.drawActorName = function(actor, x, y) {
  544.     this.baseDraw(actorName, actor.name(), x, y);
  545. };
  546.  
  547. Window_Char.prototype.drawActorLevel = function(actor, x, y) {
  548.     this.baseDraw(TextManager.level, actor.level, x, y);
  549. };
  550.  
  551. Window_Char.prototype.drawActorStat = function(x, y, id) {
  552.     var pName = TextManager.param(id);
  553.     var pValue = this.actor().param(id) + this._increased[id];
  554.     this.baseDraw(pName, pValue.toFixed(0), x, y);
  555. };
  556.  
  557. Window_Char.prototype.refresh = function() {
  558.     if (this.contents) {
  559.         this.contents.clear();
  560.         this.drawItem();
  561.     }
  562. }
  563.  
  564.  
  565.  
  566. //****************************************************
  567. //
  568. //---Scene Distribution, duhh
  569. //
  570. //****************************************************
  571.  
  572.  
  573. function Scene_Distribution() {
  574.     this.initialize.apply(this, arguments);
  575. }
  576.  
  577. Scene_Distribution.prototype = Object.create(Scene_MenuBase.prototype);
  578. Scene_Distribution.prototype.constructor = Scene_Distribution;
  579.  
  580.  
  581. Scene_Distribution.prototype.initialize = function(actor) {
  582.     this._actorr = actor;
  583.     this._params = [0,0,0,0,0,0,0,0,0,0,0,0,0];
  584.     this._xparams = [0,0,0,0,0,0,0,0,0,0,0,0,0];
  585.     this._usedStats = 0;
  586.     Scene_MenuBase.prototype.initialize.call(this);
  587. };
  588.  
  589. Scene_Distribution.prototype.actor = function() {
  590.     return this._actorr;
  591. }
  592.  
  593. Scene_Distribution.prototype.create = function() {
  594.     Scene_MenuBase.prototype.create.call(this);
  595.     this.createCharWindow(this.actor());
  596.     this.createXParamWindow(this.actor());
  597.     this.createDecreaseWindow();
  598.     this.createSelectingWindow();
  599.     this.createPointWindow(this.actor());
  600. }
  601.  
  602.  
  603. Scene_Distribution.prototype.start = function() {
  604.     Scene_MenuBase.prototype.start.call(this);
  605.     this._charWindow.refresh();
  606. };
  607.  
  608.  
  609. Scene_Distribution.prototype.createCharWindow = function(actor) {
  610.     this._charWindow = new Window_Char(0, 0, actor, this._params);
  611.     this.addWindow(this._charWindow);
  612. }
  613.  
  614. Scene_Distribution.prototype.createXParamWindow = function(actor) {
  615.     var usedx = getUsedXStats();
  616.     if (usedx) {
  617.         if (usedx.length >= 1) {
  618.             this._xParamWindow = new Window_xParams(500, this._charWindow.windowHeight(), actor, this._xparams);
  619.             this.addWindow(this._xParamWindow);
  620.         }      
  621.     }  
  622. }
  623.  
  624. Scene_Distribution.prototype.createSelectingWindow = function() {
  625.     this._selectingWindow = new Window_Selecting(0, this._charWindow.windowHeight(), increaseName);
  626.     var used = getUsedStats();
  627.     var usedx = getUsedXStats();
  628.     var k;
  629.     for(i=0;i<used.length;i++) {
  630.         k = Number(used[i]);
  631.         this._selectingWindow.setHandler('param' + k.toString(), this.increaseParam.bind(this, k));
  632.     }
  633.     for(i=0;i<usedx.length;i++) {
  634.         k = Number(usedx[i]);
  635.         y = k + 10;
  636.         this._selectingWindow.setHandler('param' + y.toString(), this.increaseExParam.bind(this, k));
  637.     }
  638.     this._selectingWindow.setHandler('exit', this.exit.bind(this));
  639.     this._selectingWindow.setHandler('cancel', this.swapWindows.bind(this, "decrease"));
  640.     this.addWindow(this._selectingWindow);
  641.     this._selectingWindow.activate();
  642. }
  643.  
  644. Scene_Distribution.prototype.createDecreaseWindow = function() {
  645.     this._decreaseWindow = new Window_Selecting(0, this._charWindow.windowHeight(), decreaseName);
  646.     var used = getUsedStats();
  647.     var usedx = getUsedXStats();
  648.     var k;
  649.     for(i=0;i<used.length;i++) {
  650.         k = Number(used[i]);
  651.         this._decreaseWindow.setHandler('param' + k.toString(), this.decreaseParam.bind(this, k));
  652.     }
  653.     for(i=0;i<usedx.length;i++) {
  654.         k = Number(usedx[i]);
  655.         y = k + 10;
  656.         this._decreaseWindow.setHandler('param' + y.toString(), this.decreaseExParam.bind(this, k));
  657.     }
  658.     this._decreaseWindow.setHandler('exit', this.exit.bind(this));
  659.     this._decreaseWindow.setHandler('cancel', this.swapWindows.bind(this, "increase"));
  660.     this.addWindow(this._decreaseWindow);
  661.     this._decreaseWindow.hide();
  662.     this._decreaseWindow.deactivate();
  663. }
  664.  
  665. Scene_Distribution.prototype.swapWindows = function(mode) {
  666.     SoundManager.playEvasion;
  667.     switch (mode) {
  668.         case "increase":
  669.             this._decreaseWindow.deactivate();
  670.             this._decreaseWindow.hide();
  671.             this._selectingWindow.show();
  672.             this._selectingWindow.activate(this._decreaseWindow._index);
  673.             break;
  674.         case "decrease":
  675.             this._selectingWindow.deactivate();
  676.             this._selectingWindow.hide();
  677.             this._decreaseWindow.show();
  678.             this._decreaseWindow.activate(this._selectingWindow._index);
  679.             break;         
  680.     }
  681. }
  682.  
  683. Scene_Distribution.prototype.exit = function() {
  684.     SoundManager.playCancel();
  685.     for (i=0;i<8;i++) {
  686.         this.actor().addParam(i, Number(this._params[i].toFixed()));
  687.     }
  688.     for (i=0;i<10;i++) {
  689.         this.actor()._gainedxparams[i] += Number(this._xparams[i].toFixed(2));
  690.     }
  691.     this.popScene();
  692. }
  693.  
  694. Scene_Distribution.prototype.createPointWindow = function(actor) {
  695.     var y = this._charWindow.windowHeight() + this._selectingWindow.windowHeight();
  696.     this._pointWindow = new Window_Points(0, y, actor);
  697.     this.addWindow(this._pointWindow);
  698. }
  699.  
  700. Scene_Distribution.prototype.increaseParam = function(id) {
  701.     var x = Input.isPressed('shift') ? shiftIncrease : 1;
  702.     var amount;
  703.     if (this.actor().statPoints() >= x) {
  704.         amount = this.actor().statPerPoint(id)*x;
  705.         this._params[id] += amount;
  706.         this._selectingWindow.playOkSound();
  707.         this._usedStats += x;
  708.         this.actor().gainStats(-x);
  709.     } else {
  710.         this._selectingWindow.playBuzzerSound();
  711.     }
  712.     this._charWindow.refresh();
  713.     this._pointWindow.refresh();
  714.     if (this._xParamWindow) {
  715.         this._xParamWindow.refresh();
  716.     }
  717.     this._selectingWindow.activate();
  718. }
  719.  
  720. Scene_Distribution.prototype.increaseExParam = function(id) {
  721.     var x = Input.isPressed('shift') ? shiftIncrease : 1;
  722.     var amount;
  723.     if (this.actor().statPoints() >= x) {
  724.         amount = this.actor().xstatPerPoint(id)*x;
  725.         this._xparams[id] += amount;
  726.         this._selectingWindow.playOkSound();
  727.         this._usedStats += x;
  728.         this.actor().gainStats(-x);
  729.     } else {
  730.         this._selectingWindow.playBuzzerSound();
  731.     }
  732.     this._charWindow.refresh();
  733.     this._pointWindow.refresh();
  734.     if (this._xParamWindow) {
  735.         this._xParamWindow.refresh();
  736.     }
  737.     this._selectingWindow.activate();
  738. }
  739.  
  740. Scene_Distribution.prototype.decreaseParam = function(id) {
  741.     var x = Input.isPressed('shift') ? shiftIncrease : 1;
  742.     var amount = this.actor().statPerPoint(id)*x;;
  743.     if ((this._usedStats >= x) && (this._params[id] >= amount)) {
  744.         this._params[id] -= amount;
  745.         SceneManager.playCancel;
  746.         this._usedStats -= x;
  747.         this.actor().gainStats(x);
  748.     } else {
  749.         this._decreaseWindow.playBuzzerSound();
  750.     }
  751.     this._charWindow.refresh();
  752.     this._pointWindow.refresh();
  753.     if (this._xParamWindow) {
  754.         this._xParamWindow.refresh();
  755.     }
  756.     this._decreaseWindow.activate();
  757. }
  758.  
  759. Scene_Distribution.prototype.decreaseExParam = function(id) {
  760.     var x = Input.isPressed('shift') ? shiftIncrease : 1;
  761.     var amount = this.actor().xstatPerPoint(id)*x;;
  762.     if ((this._usedStats >= x) && (this._xparams[id] >= amount)) {
  763.         this._xparams[id] -= amount;
  764.         SceneManager.playCancel;
  765.         this._usedStats -= x;
  766.         this.actor().gainStats(x);
  767.     } else {
  768.         this._decreaseWindow.playBuzzerSound();
  769.     }
  770.     this._charWindow.refresh();
  771.     this._pointWindow.refresh();
  772.     if (this._xParamWindow) {
  773.         this._xParamWindow.refresh();
  774.     }
  775.     this._decreaseWindow.activate();
  776. }
  777.  
  778. SceneManager.sceneDistribution = function(actor) {
  779.     this._stack.push(this._scene.constructor);
  780.     if (Scene_Distribution) {
  781.         this._nextScene = new Scene_Distribution(actor);
  782.     }
  783.     if (this._scene) {
  784.         this._scene.stop();
  785.     }
  786. }
  787.    
  788. })();
Advertisement
Add Comment
Please, Sign In to add comment