查看: 2171|回复: 2

[已经解决] 属性点分配插件无法使用

[复制链接]
梦石
0
星屑
163
在线时间
73 小时
注册时间
2014-4-10
回帖
96
发表于 2016-5-20 11:56:35 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
如题,找到个很好用的升级分配属性插件但总报错,新人表示灰常无奈。。哪位大大给指点一下。{:2_281:}
附代码:

  1. //=============================================================================
  2. // StatDistribution.js
  3. //=============================================================================

  4. /*:
  5. @author Icaro10100 / FrozenPhoenix
  6. @plugindesc Get stat points on level up, those points can be spent to increase stat value
  7. @help

  8. *********************************************************************************

  9. Actors will gain stat points whenever they level up or when you want to give
  10. them via script call: $gameActors.actor(id).gainStats(amount)

  11. Those points can be used to increase the actor's stats via a custom scene.
  12. To call the scene use the call: SceneManager.sceneDistribution(actor)

  13. Example: SceneManager.sceneDistribution($gameParty.members()[0])
  14. Learn the basic script calls

  15. To call the scene for the entire party use SceneManager.partyDistribution()
  16. Press Q/W to swap the party members. You can use SceneManager.partyDistribution(id)
  17. to have the scene start with the actor in position "id" in the party, example:
  18. SceneManager.partyDistribution(2) will start the scene with the third actor in the
  19. party.

  20. Holding shift while increasing the attributes will increase them faster.

  21. Press "x" to toggle between decrease/increase option

  22. Put the following tags to determine how much the param/stat will increase per
  23. stat point spent:

  24. <ihp: amount>
  25. <imp: amount>
  26. <iatk: amount>
  27. <idef: amount>
  28. <imat: amount>
  29. <imdf: amount>
  30. <iagi: amount>
  31. <iluk: amount>

  32. For extra parameters:

  33. <ihit: amount>
  34. <ieva: amount>
  35. <icri: amount>
  36. <icev: amount>
  37. <imev: amount>
  38. <imrf: amount>
  39. <icnt: amount>
  40. <ihrg: amount>
  41. <imrg: amount>
  42. <itrg: amount>

  43. The tags should be put in the class notebox OR in the actor notebox

  44. To have custom parameter limits for each actor/class put those tags in the notebox:

  45. <hplimit: >
  46. <mplimit: >
  47. <atklimit: >
  48. <deflimit: >
  49. <matlimit: >
  50. <mdflimit: >
  51. <agilimit: >
  52. <luklimit: >



  53. Feel free to use for free/comercial games, just give credit.
  54. Enjoy

  55. ChangeLog:

  56. --1.2
  57. -Fixed bug of max hp value displaying 999 on screen even when the actual value was higher
  58. -Added option to add custom limits for parameters, those can be different for each actor
  59. -Added option to limit how much points you can spend on the same parameter each level
  60. -Added party option, press Q/W to swap between party members
  61. -Can now put tags in the actor's note box as well

  62. --1.1
  63. -Added names for some stuff
  64. -Added option to decrease stat
  65. -Added support for extra parameters (crit/evasion etc)

  66. *********************************************************************************

  67. @param PointsName
  68. @desc The name given to stat points
  69. @default Points

  70. @param ActorName
  71. @desc The word before the actor's name
  72. @default Name

  73. @param ClassName
  74. @desc The word before the actor's class
  75. @default Class

  76. @param ExpName
  77. @desc The word before the actor's experience
  78. @default EXP

  79. @param IncreaseName
  80. @desc The word that means increase duhhh (if doing game on another language)
  81. @default Increase

  82. @param DecreaseName
  83. @desc Same thing as before
  84. @default Decrease

  85. @param StatNameColor
  86. @desc The color the stat's name appears, select a number from the windowskin
  87. @default 1

  88. @param StatValueColor
  89. @desc The color the stat's value appears, select a number from the windowskin
  90. @default 0

  91. @param ShiftIncrease
  92. @desc When holding shift, the amount increased will be multiplicated by this parameter
  93. @default 5

  94. @param LevelUpPoints
  95. @desc Points gained on level up, can be any number or formula that returns a number
  96. @default 10

  97. @param UsedStats
  98. @desc The basic stats that will be available to increase, put the id separated by a comma Example: 0,3,4,5
  99. @default 0,1,2,3,4,5,6,7

  100. @param UsedXStats
  101. @desc Same as before, but for extra parameters (crit/evasion etc)
  102. @default

  103. @param ExtraParamNames
  104. @desc Names for the extra stats (crit/evasion etc), just modify the strings in the default.
  105. @default ["Hit rate", "Evasion", "Crit chance", "Crit Evasion", "Magic Evasion", "Magic Reflect", "Counter", "HP Regen", "MP Regen", "TP Regen"]

  106. @param DefaultLimits
  107. @desc Highest possible value for the parameter
  108. Just change the values, in order: hp/mp/atk/def/mat/mdf/agi/luk
  109. @default [99999, 9999, 999, 999, 999, 999, 999, 999]

  110. @param DefaultxParamLimits
  111. @desc Highest possible value for special parameters
  112. Just change the values, in order: hit/eva/crit/criteva etc.
  113. @default [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

  114. @param MaxPointsPerLevel
  115. @desc How much points you can spend per level on a single parameter
  116. use any formula that returns a number, leave 0 for no limits
  117. @default 0




  118. */



  119. (function() {
  120.    
  121. //Parameters   
  122. var parameters = PluginManager.parameters('StatDistribution');
  123. var pointsName = String(parameters["PointsName"]);
  124. var actorName = String(parameters["ActorName"]);
  125. var className = String(parameters["ClassName"]);
  126. var expName = String(parameters["ExpName"]);
  127. var increaseName = String(parameters["IncreaseName"]);
  128. var decreaseName = String(parameters["DecreaseName"]);
  129. var statNameColor = Number(parameters["StatNameColor"]);
  130. var statValueColor = Number(parameters["StatValueColor"]);
  131. var shiftIncrease = Number(parameters["ShiftIncrease"]);
  132. var levelUpPoints = String(parameters["LevelUpPoints"]);
  133. var usedStats = String(parameters["UsedStats"]);
  134. var usedXStats = String(parameters["UsedXStats"]);
  135. var xParamNames = String(parameters["ExtraParamNames"]);
  136. var defaultLimits = String(parameters['DefaultLimits']);
  137. var defaultxLimits = String(parameters['DefaultxParamLimits']);
  138. var maxPointsPerLevel = String(parameters['MaxPointsPerLevel']);

  139. getLimit = function(id) {
  140.     limits = eval(defaultLimits);
  141.     return limits[id];
  142. }

  143. getTag = function(id) {
  144.     switch(id) {
  145.         case 0:
  146.             return "hplimit";
  147.         case 1:
  148.             return "mplimit";
  149.         case 2:
  150.             return "atklimit";
  151.         case 3:
  152.             return "deflimit";
  153.         case 4:
  154.             return "matlimit";
  155.         case 5:
  156.             return "mdflimit";
  157.         case 6:
  158.             return "agilimit";
  159.         case 7:
  160.             return "luklimit";                 
  161.     }
  162. }


  163. //This function will return an array with the ids of the used stats
  164. getUsedStats = function() {
  165.     var re = /\d+/g;
  166.     return usedStats.match(re) || [];  
  167. }

  168. //This function will return an array with the ids of the used extra stats
  169. getUsedXStats = function() {
  170.     var re = /\d+/g;
  171.     return usedXStats.match(re) || [];
  172. }

  173. //This function will return the name of the extra param with given index
  174. getXParamName = function(id) {
  175.     var names = eval(xParamNames);
  176.     return names[id];
  177. }

  178. //Game batlerbase

  179. Game_BattlerBase.prototype.xparam = function(xparamId) {
  180.     var value = this.traitsSum(Game_BattlerBase.TRAIT_XPARAM, xparamId) + this._gainedxparams[xparamId];
  181.     return value;
  182. };

  183. _GameBattlerBaseInitialize = Game_BattlerBase.prototype.initialize;
  184. Game_BattlerBase.prototype.initialize = function() {
  185.     _GameBattlerBaseInitialize.call(this);
  186.     this._gainedxparams = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
  187. };


  188. Game_BattlerBase.prototype.paramMax = function(paramId) {
  189.     if (paramId == 0) {
  190.         return 999999;  // MHP
  191.     } else if (paramId == 1) {
  192.         return 9999;    // MMP
  193.     } else {
  194.         return 999;
  195.     }
  196. };

  197.    
  198. //---Game Actor

  199. _GameActorInitialize = Game_Actor.prototype.initialize;
  200. Game_Actor.prototype.initialize = function(actorId) {
  201.     _GameActorInitialize.call(this, actorId);
  202.     this._statPoints = 0;
  203.     this.resetUsedPoints();
  204. };

  205. Game_Actor.prototype.resetUsedPoints = function() {
  206.     this._usedPoints = [0, 0, 0, 0, 0, 0, 0, 0];
  207.     this._usedxPoints = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  208. }

  209. Game_Actor.prototype.increasePointLimit = function() {
  210.     for (i=0; i<this._usedxPoints.length; i++) {
  211.         if (i<this._usedPoints.length) {
  212.             this._usedPoints[i] -= this.maxPerLevel();
  213.         }
  214.         this._usedxPoints[i] -= this.maxPerLevel();
  215.     }
  216. }

  217. Game_Actor.prototype.usePoints = function(paramid, points) {
  218.     this._usedPoints[paramid] += points;
  219. }

  220. Game_Actor.prototype.usexPoints = function(paramid, points) {
  221.     this._usedxPoints[paramid] += points;
  222. }

  223. Game_Actor.prototype.canIncrease = function(paramid, points, alreadyUsed) {
  224.     var result = true;
  225.     if (((this._usedPoints[paramid] + points) > this.maxPerLevel()) && (this.maxPerLevel() != 0)) {
  226.         result = false;
  227.     }
  228.     if ((this.param(paramid) + alreadyUsed + points*this.statPerPoint(paramid)) > this.paramMax(paramid)) {
  229.         result =false;
  230.     }
  231.     return result;
  232. }

  233. Game_Actor.prototype.canIncreasex = function(paramid, points, alreadyUsed) {
  234.     var result = true;
  235.     if (((this._usedxPoints[paramid] + points) > this.maxPerLevel()) && (this.maxPerLevel() != 0)) {
  236.         result = false;
  237.     }
  238.     if ((this.xparam(paramid) + alreadyUsed + points*this.xstatPerPoint(paramid)) > this.xparamMax(paramid)) {
  239.         result =false;
  240.     }
  241.     return result;
  242. }

  243. Game_Actor.prototype.paramMax = function(paramId) {
  244.     var limit;
  245.     var meta = "this.actor().meta." + getTag(paramId);
  246.     meta = eval(meta);
  247.     meta = meta ? meta : "$dataClasses[this.actor().id].meta." + getTag(paramId);
  248.     meta = eval(meta);
  249.     if (meta) {
  250.         limit = Number(meta);
  251.     } else {
  252.         limit = getLimit(paramId);
  253.     }
  254.     return limit;
  255. };

  256. Game_Actor.prototype.xparamMax = function(paramId) {
  257.     var limit = eval(defaultxLimits);
  258.     return limit[paramId];
  259. };

  260. Game_Actor.prototype.maxPerLevel = function() {
  261.     return eval(this.actor().meta.maxPerLevel) || Number(maxPointsPerLevel);
  262. }

  263. //Stat increase per stat point
  264. Game_Actor.prototype.statPerPoint = function(id) {
  265.     var str;
  266.     switch(id) {
  267.         case 0:
  268.             str = "ihp";
  269.             break;
  270.         case 1:
  271.             str = "imp";
  272.             break;
  273.         case 2:
  274.             str = "iatk";
  275.             break;
  276.         case 3:
  277.             str = "idef";
  278.             break;
  279.         case 4:
  280.             str = "imat";
  281.             break;
  282.         case 5:
  283.             str = "imdf";
  284.             break;
  285.         case 6:
  286.             str = "iagi";
  287.             break;
  288.         case 7:
  289.             str = "iluk";
  290.             break;         
  291.     }
  292.     var met = "$dataClasses[this._classId].meta." + str;
  293.     met = eval(met);
  294.     met = met ? met : "this.actor().meta." + str;
  295.     met = eval(met);
  296.     return met ? eval(met) : 1;
  297. }

  298. //Xstat increase per stat point
  299. Game_Actor.prototype.xstatPerPoint = function(id) {
  300.     var str;
  301.     switch(id) {
  302.         case 0:
  303.             str = "ihit";
  304.             break;
  305.         case 1:
  306.             str = "ieva";
  307.             break;
  308.         case 2:
  309.             str = "icri";
  310.             break;
  311.         case 3:
  312.             str = "icev";
  313.             break;
  314.         case 4:
  315.             str = "imev";
  316.             break;
  317.         case 5:
  318.             str = "imrf";
  319.             break;
  320.         case 6:
  321.             str = "icnt";
  322.             break;
  323.         case 7:
  324.             str = "ihrg";
  325.             break;
  326.         case 8:
  327.             str = "imrg";
  328.             break;
  329.         case 9:
  330.             str = "itrg";
  331.     }
  332.     var met = "$dataClasses[this._classId].meta." + str;
  333.     met = eval(met);
  334.     met = met ? met : "this.actor().meta." + str;
  335.     met = eval(met);
  336.     return eval(met) ? eval(met) : 1;
  337. }

  338. //-New function gainStats to call on level ups etc
  339. Game_Actor.prototype.gainStats = function(amount) {
  340.     this._statPoints += amount;
  341. }

  342. //-Gain stats on level up
  343. _GameActorLevelUp = Game_Actor.prototype.levelUp;
  344. Game_Actor.prototype.levelUp = function() {
  345.     _GameActorLevelUp.call(this);
  346.     this.gainStats(eval(levelUpPoints));
  347.     this.increasePointLimit();
  348. };

  349. //-Actor current stats
  350. Game_Actor.prototype.statPoints = function() {
  351.     return this._statPoints;
  352. }  
  353.    
  354. //-----New windows

  355. //****************************************************
  356. //
  357. //---Window Points, to display stat points.
  358. //
  359. //****************************************************


  360. function Window_Points() {
  361.     this.initialize.apply(this, arguments);
  362. }

  363. Window_Points.prototype = Object.create(Window_Base.prototype);
  364. Window_Points.prototype.constructor = Window_Points;

  365. Window_Points.prototype.initialize = function(x, y, actor) {
  366.     var width = this.windowWidth();
  367.     var height = this.windowHeight();
  368.     this._actor = actor;
  369.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  370.     this.refresh();
  371. };

  372. Window_Points.prototype.windowWidth = function() {
  373.     return 300;
  374. };

  375. Window_Points.prototype.actor = function () {
  376.     return this._actor;
  377. }

  378. Window_Points.prototype.windowHeight = function() {
  379.     return this.fittingHeight(1);
  380. };

  381. Window_Points.prototype.refresh = function(newActor) {
  382.     if (!newActor) {
  383.         newActor = this.actor();
  384.     }
  385.     this._actor = newActor;
  386.     var x = this.textPadding();
  387.     var width = this.contents.width - this.textPadding() * 2;
  388.     this.contents.clear();
  389.     this.drawThings();
  390. };

  391. Window_Points.prototype.drawThings = function() {
  392.     var x = 1;
  393.     var y = 1;
  394.     var mWidth = Math.round(this.windowWidth()/2.5);
  395.     var value = this._actor.statPoints();
  396.     this.changeTextColor(this.textColor(statNameColor));
  397.     this.drawText(pointsName, x, y, mWidth);
  398.     this.changeTextColor(this.textColor(statValueColor));
  399.     this.drawText(value, x + mWidth + 10, y, mWidth);  
  400. }

  401. Window_Points.prototype.open = function() {
  402.     this.refresh();
  403.     Window_Base.prototype.open.call(this);
  404. };


  405. //****************************************************
  406. //
  407. //---Window Selecting, to increase stats or leave scene
  408. //
  409. //****************************************************


  410. Window_Selecting.prototype = Object.create(Window_Command.prototype);
  411. Window_Selecting.prototype.constructor = Window_Selecting;

  412. function Window_Selecting() {
  413.     this.initialize.apply(this, arguments);
  414. }

  415. Window_Selecting.prototype.initialize = function (x, y, mode) {
  416.     this._mode = mode;
  417.     Window_Command.prototype.initialize.call(this, x, y);
  418. }

  419. Window_Selecting.prototype.windowWidth = function() {
  420.     return 350;
  421. };

  422. Window_Selecting.prototype.numVisibleRows = function() {
  423.     return 9;
  424. };

  425. Window_Selecting.prototype.processOk = function() {
  426.     if (this.isCurrentItemEnabled()) {
  427.         this.updateInputData();
  428.         this.deactivate();
  429.         this.callOkHandler();
  430.     }
  431. };

  432. Window_Selecting.prototype.activate = function(index) {
  433.     Window_Base.prototype.activate.call(this);
  434.     index2 = index ? index : this._index;
  435.     this.select(index2);
  436. };

  437. Window_Selecting.prototype.makeCommandList = function() {
  438.     var name;
  439.     var used = getUsedStats();
  440.     var usedx = getUsedXStats();
  441.     var k;
  442.     var mode = this._mode;
  443.     for(i=0;i<used.length;i++) {
  444.         k = Number(used[i]);
  445.         name = mode + " " + TextManager.param(k);
  446.         this.addCommand(name, 'param' + k.toString());
  447.     }
  448.     for(i=0;i<usedx.length;i++) {
  449.         k = Number(usedx[i]);
  450.         y = k + 10;
  451.         name = mode + " " + getXParamName(k);
  452.         this.addCommand(name, 'param' + y.toString());
  453.     }
  454.     this.addCommand("Exit", 'exit');
  455. }


  456. //****************************************************
  457. //
  458. //---Window xParams, display character especial parameters
  459. //
  460. //****************************************************

  461. function Window_xParams() {
  462.     this.initialize.apply(this, arguments);
  463. }

  464. Window_xParams.prototype = Object.create(Window_Base.prototype);
  465. Window_xParams.prototype.constructor = Window_xParams;

  466. Window_xParams.prototype.initialize = function (x, y, actor, increased) {
  467.     this._increased = increased;
  468.     this._width = Graphics.boxWidth - x;
  469.     var height = Graphics.boxHeight - y;
  470.     Window_Base.prototype.initialize.call(this, x, y, this._width, height);
  471.     this._actor = actor;
  472.     this.refresh();
  473. };

  474. Window_xParams.prototype.actor = function() {
  475.     return this._actor;
  476. };

  477. Window_xParams.prototype.baseDraw = function(name, value, x, y) {
  478.     var mWidth = Math.round(this._width/1.5);
  479.     var x2 = x + mWidth + 5;
  480.     this.changeTextColor(this.textColor(statNameColor));
  481.     this.drawText(name, x, y, mWidth);
  482.     this.changeTextColor(this.textColor(statValueColor));
  483.     this.drawText(value, x2, y, mWidth);
  484. }

  485. Window_xParams.prototype.drawActorStat = function(x, y, id) {
  486.     var pName = getXParamName(id);
  487.     var pValue = this.actor().xparam(id) + this._increased[id];
  488.     this.baseDraw(pName, pValue.toFixed(2), x, y);
  489. };

  490. Window_xParams.prototype.drawParameters = function() {
  491.     var x = 1;
  492.     var y = 1;
  493.     var usedx = getUsedXStats();
  494.     var lineHeight = this.lineHeight();
  495.     for(i=0;i<usedx.length;i++) {
  496.         this.drawActorStat(x, y + lineHeight * i, Number(usedx[i]));      
  497.     }
  498. }

  499. Window_xParams.prototype.refresh = function(newActor) {
  500.     if (!newActor) {
  501.         newActor = this.actor();
  502.     }
  503.     this._actor = newActor;
  504.     if (this.contents) {
  505.         this.contents.clear();
  506.         this.drawParameters();
  507.     }
  508. }


  509. //****************************************************
  510. //
  511. //---Window Char, display character image and current stats
  512. //
  513. //****************************************************


  514. function Window_Char() {
  515.     this.initialize.apply(this, arguments);
  516. }

  517. Window_Char.prototype = Object.create(Window_Base.prototype);
  518. Window_Char.prototype.constructor = Window_Char;


  519. Window_Char.prototype.initialize = function (x, y, actor, increased) {
  520.     var width = this.windowWidth();
  521.     var height = this.windowHeight();
  522.     this._increased = increased;
  523.     this._actor = actor;
  524.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  525.     this.loadImages();
  526.     this.refresh();
  527. };

  528. Window_Char.prototype.actor = function() {
  529.     return this._actor;
  530. };

  531. Window_Char.prototype.windowWidth = function() {
  532.     return Graphics.boxWidth;
  533. };

  534. Window_Char.prototype.windowHeight = function() {
  535.     return Math.round(Graphics.boxHeight / 3) - 20;
  536. };

  537. Window_Char.prototype.loadImages = function() {
  538.     for (i=0; i<$gameParty.members().length;i++){
  539.         ImageManager.loadFace($gameParty.members()[i].faceName());
  540.     }
  541. };

  542. Window_Char.prototype.drawItem = function() {
  543.     this.drawItemImage();
  544.     this.drawItemStatus();
  545.     this.drawParameters();
  546. };

  547. Window_Char.prototype.drawItemImage = function() {
  548.     this.drawActorFace(this.actor(), 1, 1, 144, 144);
  549. };

  550. Window_Char.prototype.drawItemStatus = function() {
  551.     var x = 160;
  552.     var actor = this.actor();
  553.     var y = 1;
  554.     var lineHeight = this.lineHeight();
  555.     this.drawActorName(actor, x, y);
  556.     this.drawActorLevel(actor, x, y + lineHeight * 1);
  557.     this.drawActorClass(actor, x, y + lineHeight * 2);
  558.     this.drawActorExp(actor, x, y + lineHeight * 3);
  559. };

  560. Window_Char.prototype.drawParameters = function() {
  561.     var x = 390;
  562.     var y = 1;
  563.     var used = getUsedStats();
  564.     var lineHeight = this.lineHeight();
  565.     var k;
  566.     for(i=0;i<used.length;i++) {
  567.         if (i < 4) {
  568.             this.drawActorStat(x, y + lineHeight * i, used[i]);
  569.         } else {
  570.             k = i-4;   
  571.             this.drawActorStat(x + 220, y + lineHeight * k, used[i]);
  572.         }  
  573.     }
  574. }

  575. Window_Char.prototype.baseDraw = function(name, value, x, y) {
  576.     var mWidth = Math.round(this.windowWidth()/8);
  577.     var x2 = x + mWidth + 10;
  578.     this.changeTextColor(this.textColor(statNameColor));
  579.     this.drawText(name, x, y, mWidth);
  580.     this.changeTextColor(this.textColor(statValueColor));
  581.     this.drawText(value, x2, y, mWidth);
  582. }

  583. Window_Char.prototype.drawActorExp = function(actor, x, y) {
  584.     this.baseDraw(expName, actor.currentExp(), x, y);
  585. }

  586. Window_Char.prototype.drawActorClass = function(actor, x, y) {
  587.     this.baseDraw(className, actor.currentClass().name, x, y);
  588. }

  589. Window_Char.prototype.drawActorName = function(actor, x, y) {
  590.     this.baseDraw(actorName, actor.name(), x, y);
  591. };

  592. Window_Char.prototype.drawActorLevel = function(actor, x, y) {
  593.     this.baseDraw(TextManager.level, actor.level, x, y);
  594. };


  595. Window_Char.prototype.drawActorStat = function(x, y, id) {
  596.     var pName = TextManager.param(id);
  597.     var pValue = this.actor().param(id) + this._increased[id];
  598.     this.baseDraw(pName, pValue.toFixed(0), x, y);
  599. };

  600. Window_Char.prototype.refresh = function(newActor) {
  601.     if (!newActor) {
  602.         newActor = this.actor();
  603.     }
  604.     this._actor = newActor;
  605.     if (this.contents) {
  606.         this.contents.clear();
  607.         this.drawItem();
  608.     }
  609. }



  610. //****************************************************
  611. //
  612. //---Scene Distribution, the main scene
  613. //
  614. //****************************************************


  615. function Scene_Distribution() {
  616.     this.initialize.apply(this, arguments);
  617. }

  618. Scene_Distribution.prototype = Object.create(Scene_MenuBase.prototype);
  619. Scene_Distribution.prototype.constructor = Scene_Distribution;


  620. Scene_Distribution.prototype.initialize = function(actor, party) {
  621.     this._actorr = actor;
  622.     this._party = party;
  623.     this._params = [0,0,0,0,0,0,0,0,0,0,0,0,0];
  624.     this._xparams = [0,0,0,0,0,0,0,0,0,0,0,0,0];
  625.     this._usedStats = 0;
  626.     Scene_MenuBase.prototype.initialize.call(this);
  627. };

  628. Scene_Distribution.prototype.actor = function() {
  629.     return this._actorr;
  630. }

  631. Scene_Distribution.prototype.inPartyMode = function() {
  632.     return this._party;
  633. }

  634. Scene_Distribution.prototype.create = function() {
  635.     Scene_MenuBase.prototype.create.call(this);
  636.     this.createCharWindow(this.actor());
  637.     this.createXParamWindow(this.actor());
  638.     this.createDecreaseWindow();
  639.     this.createSelectingWindow();
  640.     this.createPointWindow(this.actor());
  641. }


  642. Scene_Distribution.prototype.start = function() {
  643.     Scene_MenuBase.prototype.start.call(this);
  644.     this._charWindow.refresh();
  645. };


  646. Scene_Distribution.prototype.createCharWindow = function(actor) {
  647.     this._charWindow = new Window_Char(0, 0, actor, this._params);
  648.     this.addWindow(this._charWindow);
  649. }

  650. Scene_Distribution.prototype.createXParamWindow = function(actor) {
  651.     var usedx = getUsedXStats();
  652.     if (usedx) {
  653.         if (usedx.length >= 1) {
  654.             this._xParamWindow = new Window_xParams(500, this._charWindow.windowHeight(), actor, this._xparams);
  655.             this.addWindow(this._xParamWindow);
  656.         }      
  657.     }  
  658. }

  659. Scene_Distribution.prototype.createSelectingWindow = function() {
  660.     this._selectingWindow = new Window_Selecting(0, this._charWindow.windowHeight(), increaseName);
  661.     var used = getUsedStats();
  662.     var usedx = getUsedXStats();
  663.     var k;
  664.     for(i=0;i<used.length;i++) {
  665.         k = Number(used[i]);
  666.         this._selectingWindow.setHandler('param' + k.toString(), this.increaseParam.bind(this, k));
  667.     }
  668.     for(i=0;i<usedx.length;i++) {
  669.         k = Number(usedx[i]);
  670.         y = k + 10;
  671.         this._selectingWindow.setHandler('param' + y.toString(), this.increaseExParam.bind(this, k));
  672.     }
  673.     if (this.inPartyMode()) {
  674.         this._selectingWindow.setHandler('pageup', this.nextActor.bind(this, false));
  675.         this._selectingWindow.setHandler('pagedown', this.nextActor.bind(this, true));
  676.     }
  677.     this._selectingWindow.setHandler('exit', this.exit.bind(this));
  678.     this._selectingWindow.setHandler('cancel', this.swapWindows.bind(this, "decrease"));
  679.     this.addWindow(this._selectingWindow);
  680.     this._selectingWindow.activate();
  681. }

  682. Scene_Distribution.prototype.createDecreaseWindow = function() {
  683.     this._decreaseWindow = new Window_Selecting(0, this._charWindow.windowHeight(), decreaseName);
  684.     var used = getUsedStats();
  685.     var usedx = getUsedXStats();
  686.     var k;
  687.     for(i=0;i<used.length;i++) {
  688.         k = Number(used[i]);
  689.         this._decreaseWindow.setHandler('param' + k.toString(), this.decreaseParam.bind(this, k));
  690.     }
  691.     for(i=0;i<usedx.length;i++) {
  692.         k = Number(usedx[i]);
  693.         y = k + 10;
  694.         this._decreaseWindow.setHandler('param' + y.toString(), this.decreaseExParam.bind(this, k));
  695.     }
  696.     if (this.inPartyMode()) {
  697.         this._decreaseWindow.setHandler('pageup', this.nextActor.bind(this, false));
  698.         this._decreaseWindow.setHandler('pagedown', this.nextActor.bind(this, true));
  699.     }
  700.     this._decreaseWindow.setHandler('exit', this.exit.bind(this));
  701.     this._decreaseWindow.setHandler('cancel', this.swapWindows.bind(this, "increase"));
  702.     this.addWindow(this._decreaseWindow);
  703.     this._decreaseWindow.hide();
  704.     this._decreaseWindow.deactivate();
  705. }

  706. Scene_Distribution.prototype.nextActor = function(mode) {
  707.     SoundManager.playEvasion;
  708.     var j = $gameParty.members().indexOf(this.actor());
  709.     var l = $gameParty.members().length;
  710.     if (mode) {
  711.         j = (j+1)==l ? 0 : (j+1);
  712.     } else {
  713.         j = (j-1)<0 ? (l-1) : (j-1);
  714.     }
  715.     this.addParameters();
  716.     this._actorr = $gameParty.members()[j];
  717.     this._charWindow.refresh(this.actor());
  718.     if (this._xParamWindow) {
  719.         this._xParamWindow.refresh(this.actor());
  720.     }
  721.     this._pointWindow.refresh(this.actor());
  722.     this.swapWindows("increase");
  723. }

  724. Scene_Distribution.prototype.swapWindows = function(mode) {
  725.     SoundManager.playEvasion;
  726.     switch (mode) {
  727.         case "increase":
  728.             this._decreaseWindow.deactivate();
  729.             this._decreaseWindow.hide();
  730.             this._selectingWindow.show();
  731.             this._selectingWindow.activate(this._decreaseWindow._index);
  732.             break;
  733.         case "decrease":
  734.             this._selectingWindow.deactivate();
  735.             this._selectingWindow.hide();
  736.             this._decreaseWindow.show();
  737.             this._decreaseWindow.activate(this._selectingWindow._index);
  738.             break;         
  739.     }
  740. }

  741. Scene_Distribution.prototype.addParameters = function() {
  742.     for (i=0;i<8;i++) {
  743.         this.actor().addParam(i, Number(this._params[i].toFixed()));
  744.     }
  745.     for (i=0;i<10;i++) {
  746.         this.actor()._gainedxparams[i] += Number(this._xparams[i].toFixed(2));
  747.     }
  748.     for (i=0;i<13;i++){
  749.         this._params[i] = 0;
  750.         this._xparams[i] = 0;
  751.     }
  752.     this._usedStats = 0;
  753. }

  754. Scene_Distribution.prototype.exit = function() {
  755.     SoundManager.playCancel();
  756.     this.addParameters();
  757.     SceneManager.pop();
  758. }

  759. Scene_Distribution.prototype.createPointWindow = function(actor) {
  760.     var y = this._charWindow.windowHeight() + this._selectingWindow.windowHeight();
  761.     this._pointWindow = new Window_Points(0, y, actor);
  762.     this.addWindow(this._pointWindow);
  763. }

  764. Scene_Distribution.prototype.increaseParam = function(id) {
  765.     var x = Input.isPressed('shift') ? shiftIncrease : 1;
  766.     var amount;
  767.     var condition = this.actor().canIncrease(id, x, this._params[id]);
  768.     if ((this.actor().statPoints() >= x) && condition) {
  769.         amount = this.actor().statPerPoint(id)*x;
  770.         this._params[id] += amount;
  771.         this._selectingWindow.playOkSound();
  772.         this._usedStats += x;
  773.         this.actor().gainStats(-x);
  774.         this.actor().usePoints(id, x);
  775.     } else {
  776.         this._selectingWindow.playBuzzerSound();
  777.     }
  778.     this._charWindow.refresh();
  779.     this._pointWindow.refresh();
  780.     if (this._xParamWindow) {
  781.         this._xParamWindow.refresh();
  782.     }
  783.     this._selectingWindow.activate();
  784. }

  785. Scene_Distribution.prototype.increaseExParam = function(id) {
  786.     var x = Input.isPressed('shift') ? shiftIncrease : 1;
  787.     var amount;
  788.     var condition = this.actor().canIncreasex(id, x, this._xparams[id]);
  789.     if ((this.actor().statPoints() >= x) && condition) {
  790.         amount = this.actor().xstatPerPoint(id)*x;
  791.         this._xparams[id] += amount;
  792.         this._selectingWindow.playOkSound();
  793.         this._usedStats += x;
  794.         this.actor().gainStats(-x);
  795.         this.actor().usexPoints(id, x);
  796.     } else {
  797.         this._selectingWindow.playBuzzerSound();
  798.     }
  799.     this._charWindow.refresh();
  800.     this._pointWindow.refresh();
  801.     if (this._xParamWindow) {
  802.         this._xParamWindow.refresh();
  803.     }
  804.     this._selectingWindow.activate();
  805. }

  806. Scene_Distribution.prototype.decreaseParam = function(id) {
  807.     var x = Input.isPressed('shift') ? shiftIncrease : 1;
  808.     var amount = this.actor().statPerPoint(id)*x;;
  809.     if ((this._usedStats >= x) && (this._params[id] >= amount)) {
  810.         this._params[id] -= amount;
  811.         SceneManager.playCancel;
  812.         this._usedStats -= x;
  813.         this.actor().gainStats(x);
  814.         this.actor().usePoints(id, -x);
  815.     } else {
  816.         this._decreaseWindow.playBuzzerSound();
  817.     }
  818.     this._charWindow.refresh();
  819.     this._pointWindow.refresh();
  820.     if (this._xParamWindow) {
  821.         this._xParamWindow.refresh();
  822.     }
  823.     this._decreaseWindow.activate();
  824. }

  825. Scene_Distribution.prototype.decreaseExParam = function(id) {
  826.     var x = Input.isPressed('shift') ? shiftIncrease : 1;
  827.     var amount = this.actor().xstatPerPoint(id)*x;;
  828.     if ((this._usedStats >= x) && (this._xparams[id] >= amount)) {
  829.         this._xparams[id] -= amount;
  830.         SceneManager.playCancel;
  831.         this._usedStats -= x;
  832.         this.actor().gainStats(x);
  833.         this.actor().usePoints(id, -x);
  834.     } else {
  835.         this._decreaseWindow.playBuzzerSound();
  836.     }
  837.     this._charWindow.refresh();
  838.     this._pointWindow.refresh();
  839.     if (this._xParamWindow) {
  840.         this._xParamWindow.refresh();
  841.     }
  842.     this._decreaseWindow.activate();
  843. }



  844. SceneManager.sceneDistribution = function(actor, party) {
  845.     if (typeof(party) === 'undefined') {
  846.         party = false;
  847.     }
  848.     this._stack.push(this._scene.constructor);
  849.     if (Scene_Distribution) {
  850.         this._nextScene = new Scene_Distribution(actor, party);
  851.     }
  852.     if (this._scene) {
  853.         this._scene.stop();
  854.     }
  855. }

  856. SceneManager.partyDistribution = function(index) {
  857.     if (typeof(index) === 'undefined') {
  858.         index = 0;
  859.     }
  860.     var actor = $gameParty.members()[index];
  861.     this.sceneDistribution(actor, true);
  862. }
  863.    
  864. })();
复制代码
梦石
0
星屑
163
在线时间
73 小时
注册时间
2014-4-10
回帖
96
 楼主| 发表于 2016-5-20 11:58:46 | 显示全部楼层
报错截图:
QQ截图20160520115839.png
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部