Guest User

SRD_StatDistribution modified

a guest
Jan 14th, 2025
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 59.52 KB | Source Code | 0 0
  1. /*:
  2.  * @plugindesc Allows players to distribute points to different stats of the Actors at his or her discretion.
  3.  * @author SumRndmDde
  4.  *
  5.  * @param Default Stats
  6.  * @desc A list of stats Actors can distribute to by default.
  7.  * All of the available stats can be found in HELP.
  8.  * @default mhp, mmp, atk, def, mat, mdf, agi, luk
  9.  *
  10.  * @param Default Formula
  11.  * @desc The default formula used for determining how many "stat points" an Actor gains by leveling up.
  12.  * @default Math.ceil(level / 10)
  13.  *
  14.  * @param Show on Menu
  15.  * @desc If 'true', this plugin will place the command in the menu.
  16.  * @default true
  17.  *
  18.  * @param == Stat Reset ==
  19.  * @default
  20.  *
  21.  * @param Allow Stat Resets
  22.  * @desc If 'true', then players will have the option to reset the distributed stats and return the used stat points.
  23.  * @default true
  24.  *
  25.  * @param Reset Gold Cost
  26.  * @desc The formula determining the amount of gold for resetting.
  27.  * Use "points" to reference the amount of points used.
  28.  * @default points * 100
  29.  *
  30.  * @param Reset Use Item
  31.  * @desc If 'true', then reseting will a specific item as currency (defined by Reset ItemID), else, gold is used.
  32.  * @default false
  33.  *
  34.  * @param Reset ItemID
  35.  * @desc Determine the id of the item that will be used instead of gold.
  36.  * @default 1
  37.  *
  38.  * @param == Custom Texts ==
  39.  * @default
  40.  *
  41.  * @param Level Up Message
  42.  * @desc This message is displayed when an actor levels up to show how many points were gained. %1 is the number of points.
  43.  * @default Got %1 stat points!
  44.  *
  45.  * @param Command Name
  46.  * @desc The is the name of the command for stat distribution in the menu.
  47.  * @default Stat Boost
  48.  *
  49.  * @param Points Text
  50.  * @desc The text used to display how much points an Actor has.
  51.  * @default Stat Points:
  52.  *
  53.  * @param Upgrade Text
  54.  * @desc The text used to display how much points an upgrade is worth.
  55.  * @default Upgrade Cost:
  56.  *
  57.  * @param Spend Text
  58.  * @desc The text used in the command window to begin spending.
  59.  * @default Spend
  60.  *
  61.  * @param Reset Text
  62.  * @desc The text used in the command window to reset stat points.
  63.  * @default Reset
  64.  *
  65.  * @param Finish Text
  66.  * @desc The text used in the command window to leave the scene.
  67.  * @default Finish
  68.  *
  69.  * @param == Gauge Options ==
  70.  * @default
  71.  *
  72.  * @param Use Gauges
  73.  * @desc If 'true', the stat distribution will have gauges representing how close the distributed stat is to reaching its max.
  74.  * @default true
  75.  *
  76.  * @param Gauge Height
  77.  * @desc The height of the gauges used in the stat distribution.
  78.  * @default 14
  79.  *
  80.  * @param == Points Label ==
  81.  * @default
  82.  *
  83.  * @param Point Icon
  84.  * @desc Input the icon index of the icon for stat points.
  85.  * Set to 0 to use text instead.
  86.  * @default 87
  87.  *
  88.  * @param Point Text
  89.  * @desc If "Point Icon" is set to 0, this will be used as the label for stat points.
  90.  * @default Points
  91.  *
  92.  * @param Point Color
  93.  * @desc If using text, this will be the color of the text.
  94.  * @default #66ff66
  95.  *
  96.  * @help
  97.  *
  98.  * Stat Distribution
  99.  * Version 1.07
  100.  * SumRndmDde
  101.  *
  102.  *
  103.  * This plugin allows players to distribute points to different stats of the
  104.  * Actors at his or her discretion. A command is added to the menu which allows
  105.  * access to a new menu for stat distribution!
  106.  *
  107.  *
  108.  * ==============================================================================
  109.  *  Plugin Commands
  110.  * ==============================================================================
  111.  *
  112.  * Use the following plugin commands to preform various actions.
  113.  *
  114.  *
  115.  *
  116.  *   OpenStatDistribution Actor [actorId]
  117.  *
  118.  * This opens the Stat Distribution Menu for the specified Actor ID.
  119.  *
  120.  *
  121.  *
  122.  *   OpenStatDistribution Party [memberIndex]
  123.  *
  124.  * This opens the Stat Distribution Menu for the specified Actor based on the
  125.  * index in which they are in the party. For example, setting "memberIndex"
  126.  * to 0 will open the menu for the party's leader.
  127.  *
  128.  *
  129.  *
  130.  *   AddStatPoints Actor [actorId] [points]
  131.  *   AddStatPoints Party [memberIndex] [points]
  132.  *
  133.  * This adds a specific amount points to a specific Actor.
  134.  *
  135.  *
  136.  * ==============================================================================
  137.  *  Upgradeable Stats
  138.  * ==============================================================================
  139.  *
  140.  * In order to determine what stats can be upgraded, use the "Default Stats"
  141.  * Parameter. Otherwise, notetags can be used to customize the stats
  142.  * per each individual Actor:
  143.  *
  144.  *
  145.  *   <Set Distribution Stats: [stats]>
  146.  *
  147.  * Sets the Actor's stats to this list.
  148.  *
  149.  *
  150.  *
  151.  *   <Add Distribution Stats: [stats]>
  152.  *
  153.  * Adds stats to the Actor's already existing upgradeable stats.
  154.  *
  155.  *
  156.  * ==============================================================================
  157.  *  How to Customize Stats
  158.  * ==============================================================================
  159.  *
  160.  * In order to customize the properties of stats, you must use the Database EX.
  161.  * Simply go to the customizable editors, and select "Stat Distribution Editor".
  162.  *
  163.  * Within here, a list of stats will be available and their variables can
  164.  * be changed to fit with your needs. Be sure to reload to see the changes!
  165.  *
  166.  *
  167.  * ==============================================================================
  168.  *  List of Upgradeable Stats
  169.  * ==============================================================================
  170.  *
  171.  * Here is a list of all the available stats and their three-letter codes.
  172.  *
  173.  *
  174.  * == Base Stats ==
  175.  * mhp - PV Max
  176.  * mmp - Max MP
  177.  * atk - Force
  178.  * def - Défense
  179.  * mat - Force.Mag
  180.  * mdf - Défense.Mag
  181.  * agi - Rapidité
  182.  * luk - Luck
  183.  *
  184.  * == Ex Stats ==
  185.  * hit - Hit Rate
  186.  * eva - Evasion Rate
  187.  * cri - Critical Rate
  188.  * cev - Critical Evasion Rate
  189.  * mev - Magic Evasion Rate
  190.  * mrf - Magic Reflection Rate
  191.  * cnt - Counter Attack Rate
  192.  * hrg - Hp Regeneration
  193.  * mrg - Mp Regeneration
  194.  * trg - Tp Regeneration
  195.  *
  196.  * == Sp Stats ==
  197.  * tgr - Target Rate
  198.  * grd - Guard Effect Rate
  199.  * rec - Recovery Effect Rate
  200.  * pha - Pharmacology
  201.  * mcr - Mp Cost Rate
  202.  * tcr - Tp Charge Rate
  203.  * pdr - Physical Damage Rate
  204.  * mdr - Magical Damage Rate
  205.  * fdr - Floor Damage Rate
  206.  * exr - Experience Rate
  207.  *
  208.  *
  209.  * ==============================================================================
  210.  *  Stat Points
  211.  * ==============================================================================
  212.  *
  213.  * Stat points can be gained by leveling up the Actors.
  214.  * The "Default Formula" Parameter can be used to set up a formula for how many
  215.  * stat points an Actor will gain upon level. Alternatively, the following
  216.  * notetags can be used to give Actors their own formulas:
  217.  *
  218.  *   <Stat Point Formula: [formula]>
  219.  *
  220.  * For example:
  221.  *
  222.  *   <Stat Point Formula: 5 * level>
  223.  *
  224.  *
  225.  * ==============================================================================
  226.  *  End of Help File
  227.  * ==============================================================================
  228.  *
  229.  * Welcome to the bottom of the Help file.
  230.  *
  231.  *
  232.  * Thanks for reading!
  233.  * If you have questions, or if you enjoyed this Plugin, please check
  234.  * out my YouTube channel!
  235.  *
  236.  * https://www.youtube.com/c/SumRndmDde
  237.  *
  238.  *
  239.  * Until next time,
  240.  *   ~ SumRndmDde
  241.  *
  242.  */
  243.  
  244. var SRD = SRD || {};
  245. SRD.StatDistribution = SRD.StatDistribution || {};
  246. SRD.PluginCommands = SRD.PluginCommands || {};
  247. SRD.NotetagGetters = SRD.NotetagGetters || [];
  248.  
  249. var Imported = Imported || {};
  250. Imported["SumRndmDde Stat Distribution"] = 1.07;
  251.  
  252. var $dataDistributeStats = {};
  253.  
  254. function Scene_Distribute() {
  255.         this.initialize.apply(this, arguments);
  256. }
  257.  
  258. function Window_DistributePoints() {
  259.         this.initialize.apply(this, arguments);
  260. }
  261.  
  262. function Window_DistributeStatus() {
  263.         this.initialize.apply(this, arguments);
  264. }
  265.  
  266. function Window_Distribute() {
  267.         this.initialize.apply(this, arguments);
  268. }
  269.  
  270. function Window_DistributeCommand() {
  271.         this.initialize.apply(this, arguments)
  272. }
  273.  
  274. (function(_) {
  275.  
  276. "use strict";
  277.  
  278. //-----------------------------------------------------------------------------
  279. // SRD.StatDistribution
  280. //-----------------------------------------------------------------------------
  281.  
  282. const params = PluginManager.parameters('SRD_StatDistribution');
  283.  
  284. _.stats = String(params['Default Stats']).split(/\s*,\s*/);
  285. _.formula = String(params['Default Formula']);
  286. _.show = String(params['Show on Menu']).trim().toLowerCase() === 'true';
  287.  
  288. _.reset = String(params['Allow Stat Resets']).trim().toLowerCase() === 'true';
  289. _.cost = String(params['Reset Gold Cost']);
  290. _.bUseItem = String(params['Reset Use Item']).trim().toLowerCase() === 'true';
  291. _.itemID = String(params['Reset ItemID']);
  292.  
  293. _.name = String(params['Command Name']);
  294. _.messsage = String(params['Level Up Message']);
  295. _.points = String(params['Points Text']);
  296. _.upgrade = String(params['Upgrade Text']);
  297. _.spendText = String(params['Spend Text']);
  298. _.resetText = String(params['Reset Text']);
  299. _.finishText = String(params['Finish Text']);
  300.  
  301. _.drawGauges = String(params['Use Gauges']).trim().toLowerCase() === 'true';
  302. _.gaugeHeight = parseInt(params['Gauge Height']);
  303. _.iconIndex = parseInt(params['Point Icon']);
  304. _.pointText = String(params['Point Text']);
  305. _.pointColor = String(params['Point Color']);
  306.  
  307. _.checkFileExists = function() {
  308.         FileManager.checkDataExists("DistributionStats.json", JsonEx.stringify({
  309.                 "mhp":{"name":"PV Max","description":"Augmente les Points de vie de 2.","cost":"1","gain":"2","max":"500","min_col":"#ffa655","max_col":"#ea7000"},
  310.                 "mmp":{"name":"Max MP","description":"The maximum amount of MP for the actor.","cost":"1","gain":"2","max":"200","min_col":"#6666ff","max_col":"#0000ff"},
  311.                 "atk":{"name":"Force","description":"Augmente la Force de 1.","cost":"1","gain":"1","max":"100","min_col":"#ff7777","max_col":"#f90000"},
  312.                 "def":{"name":"Défense","description":"Augmente la Défense de 1.","cost":"1","gain":"1","max":"100","min_col":"#52ff33","max_col":"#12b700"},
  313.                 "mat":{"name":"Force.Mag","description":"Augmente la Force des Runerrias de 1.","cost":"1","gain":"1","max":"100","min_col":"#b355ff","max_col":"#a300d9"},
  314.                 "mdf":{"name":"Déf.Mag","description":"Augmente la Défense aux Runerrias de 1.","cost":"1","gain":"1","max":"100","min_col":"#55ffe6","max_col":"#00d7b7"},
  315.                 "agi":{"name":"Rapidité","description":"Augmente la vitesse de la barre d'initiative.","cost":"1","gain":"2","max":"100","min_col":"#fbff55","max_col":"#d9d300"},      
  316.                 "luk":{"name":"Luck","description":"Influences various luck factors for the actor in \ntheir favor.","cost":"1","gain":"1","max":"100","min_col":"#ff55e6","max_col":"#cc00ad"},
  317.                 "hit":{"name":"Hit Rate","description":"Increases the chance of skills hitting their \ntarget.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  318.                 "eva":{"name":"Evasion Rate","description":"Increases the likely-hood of an actor evading\na physical skill.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  319.                 "cri":{"name":"Critical Rate","description":"Determines how likely an actor will preform \na critical hit.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  320.                 "cev":{"name":"Critical Evasion Rate","description":"Decreases the likely-hood of skills targeting \nthe actor being critical.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  321.                 "mev":{"name":"Magic Evasion Rate","description":"Increases the likely-hood of an actor evading \na magical skill.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  322.                 "mrf":{"name":"Magic Reflection Rate","description":"The higher the value, the more likely magical \nreflection will occur.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  323.                 "cnt":{"name":"Counter Attack Rate","description":"The higher the value, the more likely physical \nreflection will occur.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  324.                 "hrg":{"name":"Hp Regeneration","description":"The rate in which the actor gains HP each turn.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  325.                 "mrg":{"name":"Mp Regeneration","description":"The rate in which the actor gains MP each turn.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  326.                 "trg":{"name":"Tp Regeneration","description":"The rate in which the actor gains TP each turn.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  327.                 "tgr":{"name":"Target Rate","description":"Increases the chance of the actor being attacked.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  328.                 "grd":{"name":"Guard Effect Rate","description":"Increases the effectiveness of the actor's guard","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  329.                 "rec":{"name":"Recovery Effect Rate","description":"Determines the effectiveness of recovery skills.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  330.                 "pha":{"name":"Pharmacology","description":"Determines the effectiveness of recovery items.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  331.                 "mcr":{"name":"Mp Cost Rate","description":"The rate in which MP skills cost.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  332.                 "tcr":{"name":"Tp Charge Rate","description":"The rate in which TP skills cost.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  333.                 "pdr":{"name":"Physical Damage Rate","description":"The rate in which physical damage occurs.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  334.                 "mdr":{"name":"Magical Damage Rate","description":"The rate in which magical damage occurs.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  335.                 "fdr":{"name":"Floor Damage Rate","description":"The rate in which floor damage occurs.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"},
  336.                 "exr":{"name":"Experience Rate","description":"The rate in which the actor gains experience.","cost":"2","gain":"0.005","max":"0.5","min_col":"#aaaaaa","max_col":"#ffffff"}
  337.         }));
  338. };
  339.  
  340. _.loadNotetags = function() {
  341.         const data = $dataActors;
  342.         const regex1 = /<Set[ ]?Distribution[ ]?Stats[ ]?:\s*(.*)\s*>/im;
  343.         const regex2 = /<Add[ ]?Distribution[ ]?Stats[ ]?:\s*(.*)\s*>/im;
  344.         const regex3 = /<Stat[ ]?Point[ ]?Formula[ ]?:\s*(.*)\s*>/im;
  345.         for(let i = 1; i < data.length; i++) {
  346.                 const note = data[i].note;
  347.                 if(note.match(regex1)) {
  348.                         const stats = String(RegExp.$1).split(/\s*,\s*/);
  349.                         data[i]._sd_stats = stats;
  350.                 }
  351.                 if(note.match(regex2)) {
  352.                         const stats = String(RegExp.$1).split(/\s*,\s*/);
  353.                         if(data[i]._sd_stats === undefined) data[i]._sd_stats = _.stats.clone();
  354.                         data[i]._sd_stats = data[i]._sd_stats.concat(stats);
  355.                 }
  356.                 if(note.match(regex3)) {
  357.                         data[i]._sd_formula = String(RegExp.$1);
  358.                 }
  359.         }
  360. };
  361.  
  362. SRD.NotetagGetters.push(_.loadNotetags);
  363.  
  364. _.alertNeedSuperToolsEngine = function() {
  365.         alert("The 'SRD_SuperToolsEngine' plugin is required for using the 'SRD_StatDistribution' plugin.");
  366.         if(confirm("Do you want to open the download page to 'SRD_SuperToolsEngine'?")) {
  367.                 window.open('http://sumrndm.site/super-tools-engine/');
  368.         }
  369. };
  370.  
  371. if(!Imported["SumRndmDde Super Tools Engine"]) {
  372.         _.alertNeedSuperToolsEngine();
  373.         return;
  374. }
  375.  
  376. _.checkFileExists();
  377.  
  378. //-----------------------------------------------------------------------------
  379. // SRD.PluginCommands
  380. //-----------------------------------------------------------------------------
  381.  
  382. SRD.PluginCommands._sd_getActorType = function(args) {
  383.         const type = String(args[0]).toLowerCase();
  384.         const id = parseInt(args[1]);
  385.         let actor;
  386.         if(type === 'actor') {
  387.                 actor = $gameActors.actor(id);
  388.         } else {
  389.                 actor = $gameParty.members()[id];
  390.         }
  391.         return actor;
  392. };
  393.  
  394. SRD.PluginCommands['openstatdistribution'] = function(args) {
  395.         const actor = SRD.PluginCommands._sd_getActorType(args);
  396.         if(actor) {
  397.                 $gameParty.setMenuActor(actor);
  398.                 SceneManager.push(Scene_Distribute);
  399.         }
  400. };
  401.  
  402. SRD.PluginCommands['addstatpoints'] = function(args) {
  403.         const actor = SRD.PluginCommands._sd_getActorType(args);
  404.         if(actor) {
  405.                 const points = parseInt(args[2]);
  406.                 actor.addDistributePoints(points);
  407.         }
  408. };
  409.  
  410. //-----------------------------------------------------------------------------
  411. // DataManager
  412. //-----------------------------------------------------------------------------
  413.  
  414. DataManager._testExceptions.push("DistributionStats.json");
  415.  
  416. DataManager._databaseFiles.push({name: '$dataDistributeStats', src: "DistributionStats.json"});
  417.  
  418. if(!SRD.DataManager_isDatabaseLoaded) {
  419.  
  420. SRD.notetagsLoaded = false;
  421. SRD.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  422. DataManager.isDatabaseLoaded = function() {
  423.         if(!SRD.DataManager_isDatabaseLoaded.apply(this, arguments)) return false;
  424.         if(!SRD.notetagsLoaded) {
  425.                 SRD.NotetagGetters.forEach(function(func) {
  426.                         func.call(this);
  427.                 }, this);
  428.                 SRD.notetagsLoaded = true;
  429.         }
  430.         return true;
  431. };
  432.  
  433. }
  434.  
  435. //-----------------------------------------------------------------------------
  436. // DataManagerEX
  437. //-----------------------------------------------------------------------------
  438.  
  439. DataManagerEX._distributeStat = 'mhp';
  440.  
  441. _.DataManagerEX_getCustomInfo = DataManagerEX.getCustomInfo;
  442. DataManagerEX.getCustomInfo = function() {
  443.         const result = _.DataManagerEX_getCustomInfo.apply(this, arguments);
  444.         result.push(['Stat Distribution Editor', 'DataManagerEX.getStatDistributionHtml']);
  445.         return result;
  446. };
  447.  
  448. DataManagerEX.getStatDistributionHtml = function() {
  449.         const data = $dataDistributeStats['mhp'];
  450.         return `<p>
  451.                         <div id="main-wrap">
  452.                                 <div style="float: center; width: 100%; text-align:center;"><br>
  453.                                         <b>Stat:</b><br>
  454.                                         <select id="StatSelect" onchange="DataManagerEX.updateStatDistribution()">
  455.                                                 ${this.getStatDistributionHtmlOptions()}
  456.                                         </select>
  457.                                 </div>
  458.                         </div><br>
  459.                         <table id="PropertyList">
  460.                                 <tr>
  461.                                         <th>Parameter</th>
  462.                                         <th>Input</th>
  463.                                 </tr>
  464.                                 <tr>
  465.                                         <td style="text-align: center;">Name</td>
  466.                                         <td style="width: 60%; text-align: center;"><input type="text" size="45" id="name" value='${data.name}'
  467.                                         style="width: 200px" onchange="DataManagerEX.saveCurrentStatDistribution()"></td>
  468.                                 </tr>
  469.                                 <tr>
  470.                                         <td style="text-align: center;">Description</td>
  471.                                         <td style="width: 60%; text-align: center;"><textarea type="text" cols="52" rows="2" id="description"
  472.                                         style="font-size: 12px;" onchange="DataManagerEX.saveCurrentStatDistribution()">${data.description}</textarea></td>
  473.                                 </tr>
  474.                                 <tr>
  475.                                         <td style="text-align: center;">Cost</td>
  476.                                         <td style="width: 60%; text-align: center;"><input type="text" size="45" id="cost" value='${data.cost}'
  477.                                         style="width: 200px" onchange="DataManagerEX.saveCurrentStatDistribution()"></td>
  478.                                 </tr>
  479.                                 <tr>
  480.                                         <td style="text-align: center;">Gain</td>
  481.                                         <td style="width: 60%; text-align: center;"><input type="text" size="45" id="gain" value='${data.gain}'
  482.                                         style="width: 200px" onchange="DataManagerEX.saveCurrentStatDistribution()"></td>
  483.                                 </tr>
  484.                                 <tr>
  485.                                         <td style="text-align: center;">Max</td>
  486.                                         <td style="width: 60%; text-align: center;"><input type="text" size="45" id="max" value='${data.max}'
  487.                                         style="width: 200px" onchange="DataManagerEX.saveCurrentStatDistribution()"></td>
  488.                                 </tr>
  489.                                 <tr>
  490.                                         <td style="text-align: center;">Min Color</td>
  491.                                         <td style="width: 60%; text-align: center;"><input type="color" id="min_col" value="${data.min_col}"
  492.                                         style="width: 200px" onchange="DataManagerEX.saveCurrentStatDistribution()"></td>
  493.                                 </tr>
  494.                                 <tr>
  495.                                         <td style="text-align: center;">Max Color</td>
  496.                                         <td style="width: 60%; text-align: center;"><input type="color" id="max_col" value="${data.max_col}"
  497.                                         style="width: 200px" onchange="DataManagerEX.saveCurrentStatDistribution()"></td>
  498.                                 </tr>
  499.                         </table>
  500.                         </p>`;
  501. };
  502.  
  503. DataManagerEX.getStatDistributionHtmlOptions = function() {
  504.         return `<option value="mhp" selected>Pv Max</option>
  505.                         <option value="mmp">Max MP</option>
  506.                         <option value="atk">Force</option>
  507.                         <option value="def">Défense</option>
  508.                         <option value="mat">Force.Mag</option>
  509.                         <option value="mdf">Défense.Mag</option>
  510.                         <option value="agi">Rapidité</option>
  511.                         <option value="luk">Luck</option>
  512.                         <option value="frame">   </option>
  513.                         <option value="hit">Hit Rate</option>
  514.                         <option value="eva">Evasion Rate</option>
  515.                         <option value="cri">Critical Rate</option>
  516.                         <option value="cev">Critical Evasion Rate</option>
  517.                         <option value="mev">Magic Evasion Rate</option>
  518.                         <option value="mrf">Magic Reflection Rate</option>
  519.                         <option value="cnt">Counter Attack Rate</option>
  520.                         <option value="hrg">Hp Regeneration</option>
  521.                         <option value="mrg">Mp Regeneration</option>
  522.                         <option value="trg">Tp Regeneration</option>
  523.                         <option value="frame">   </option>
  524.                         <option value="tgr">Target Rate</option>
  525.                         <option value="grd">Guard Effect Rate</option>
  526.                         <option value="rec">Recovery Effect Rate</option>
  527.                         <option value="pha">Pharmacology</option>
  528.                         <option value="mcr">Mp Cost Rate</option>
  529.                         <option value="tcr">Tp Charge Rate</option>
  530.                         <option value="pdr">Physical Damage Rate</option>
  531.                         <option value="mdr">Magical Damage Rate</option>
  532.                         <option value="fdr">Floor Damage Rate</option>
  533.                         <option value="exr">Experience Rate</option>`;
  534. };
  535.  
  536. DataManagerEX.updateStatDistribution = function() {
  537.         const doc = MakerManager.document;
  538.         this._distributeStat = doc.getElementById('StatSelect').value;
  539.         const data = $dataDistributeStats[this._distributeStat];
  540.         if(data) {
  541.                 doc.getElementById('name').value = data.name;
  542.                 doc.getElementById('description').value = data.description;
  543.                 doc.getElementById('cost').value = data.cost;
  544.                 doc.getElementById('gain').value = data.gain;
  545.                 doc.getElementById('max').value = data.max;
  546.                 doc.getElementById('min_col').value = data.min_col;
  547.                 doc.getElementById('max_col').value = data.max_col;
  548.         } else {
  549.                 doc.getElementById('name').value = '';
  550.                 doc.getElementById('description').value = '';
  551.                 doc.getElementById('cost').value = '';
  552.                 doc.getElementById('gain').value = '';
  553.                 doc.getElementById('max').value = '';
  554.                 doc.getElementById('min_col').value = '';
  555.                 doc.getElementById('max_col').value = '';
  556.         }
  557. };
  558.  
  559. DataManagerEX.saveCurrentStatDistribution = function() {
  560.         const doc = MakerManager.document;
  561.         const data = $dataDistributeStats[this._distributeStat];
  562.         if(data) {
  563.                 data.name = doc.getElementById('name').value;
  564.                 data.description = doc.getElementById('description').value;
  565.                 data.cost = doc.getElementById('cost').value;
  566.                 data.gain = doc.getElementById('gain').value;
  567.                 data.max = doc.getElementById('max').value;
  568.                 data.min_col = doc.getElementById('min_col').value;
  569.                 data.max_col = doc.getElementById('max_col').value;
  570.                 FileManager.saveData($dataDistributeStats, "DistributionStats.json");
  571.         }
  572. };
  573.  
  574. _.DataManagerEX_initOldDatas = DataManagerEX.initOldDatas;
  575. DataManagerEX.initOldDatas = function() {
  576.         _.DataManagerEX_initOldDatas.apply(this, arguments);
  577.         this._oldStatDistribution = JsonEx.stringify($dataDistributeStats);
  578. };
  579.  
  580. _.DataManagerEX_requestRestartCondition = DataManagerEX.requestRestartCondition;
  581. DataManagerEX.requestRestartCondition = function() {
  582.         return _.DataManagerEX_requestRestartCondition.apply(this, arguments) ||
  583.                 this._oldStatDistribution !== JsonEx.stringify($dataDistributeStats);
  584. };
  585.  
  586. //-----------------------------------------------------------------------------
  587. // Game_Actor
  588. //-----------------------------------------------------------------------------
  589.  
  590. Game_Actor.bParams = ['mhp', 'mmp', 'atk', 'def', 'mat', 'mdf', 'agi', 'luk'];
  591. Game_Actor.xParams = ['hit', 'eva', 'cri', 'cev', 'mev', 'mrf', 'cnt', 'hrg', 'mrg', 'trg'];
  592. Game_Actor.sParams = ['tgr', 'grd', 'rec', 'pha', 'mcr', 'tcr', 'pdr', 'mdr', 'fdr', 'exr'];
  593.  
  594. _.Game_Actor_initMembers = Game_Actor.prototype.initMembers;
  595. Game_Actor.prototype.initMembers = function() {
  596.         _.Game_Actor_initMembers.apply(this, arguments);
  597.         this._distributePoints = 0;
  598.         this._pointsGained = 0;
  599.         this._pointsGainedTemp = 0;
  600.         this.clearDistributePointsSpent();
  601.         this.clearDistributeStats();
  602. };
  603.  
  604. _.Game_Actor_paramRate = Game_Actor.prototype.paramBase;
  605. Game_Actor.prototype.paramBase = function(paramId) {
  606.         return _.Game_Actor_paramRate.apply(this, arguments) + this._distributeParams[paramId];
  607. };
  608.  
  609. _.Game_Actor_xparam = Game_Actor.prototype.xparam;
  610. Game_Actor.prototype.xparam = function(xparamId) {
  611.         return _.Game_Actor_xparam.apply(this, arguments) + this._distributeXParams[xparamId];
  612. };
  613.  
  614. _.Game_Actor_sparam = Game_Actor.prototype.sparam;
  615. Game_Actor.prototype.sparam = function(sparamId) {
  616.         return _.Game_Actor_sparam.apply(this, arguments) + this._distributeSParams[sparamId];
  617. };
  618.  
  619. _.Game_Actor_levelUp = Game_Actor.prototype.levelUp;
  620. Game_Actor.prototype.levelUp = function() {
  621.         _.Game_Actor_levelUp.apply(this, arguments);
  622.         this.gainDistributePoints();
  623. };
  624.  
  625. _.Game_Actor_displayLevelUp = Game_Actor.prototype.displayLevelUp;
  626. Game_Actor.prototype.displayLevelUp = function(newSkills) {
  627.         _.Game_Actor_displayLevelUp.apply(this, arguments);
  628.         if(_.messsage && this._pointsGainedTemp) {
  629.                 $gameMessage.add(_.messsage.format(this._pointsGainedTemp));
  630.                 this._pointsGainedTemp = 0;
  631.         }
  632. };
  633.  
  634. Game_Actor.prototype.distributePoints = function() {
  635.         return this._distributePoints;
  636. };
  637.  
  638. Game_Actor.prototype.setDistributePoints = function(value) {
  639.         this._distributePoints = value;
  640. };
  641.  
  642. Game_Actor.prototype.addDistributePointsTemp = function(value) {
  643.         this.setDistributePoints(this._distributePoints + value);
  644. };
  645.  
  646. Game_Actor.prototype.addDistributePoints = function(value) {
  647.         this._pointsGained += value;
  648.         this._pointsGainedTemp += value;
  649.         this.addDistributePointsTemp(value);
  650. };
  651.  
  652. Game_Actor.prototype.gainDistributePoints = function() {
  653.         const formula = this.actor()._sd_formula || _.formula;
  654.         const level = this._level;
  655.         const actor = this;
  656.         const points = eval(formula);
  657.         this.addDistributePoints(points);
  658. };
  659.  
  660. Game_Actor.prototype.pointsUsed = function() {
  661.         return this._pointsGained - this._distributePoints;
  662. };
  663.  
  664. Game_Actor.prototype.setBaseDistribute = function(paramId, value) {
  665.         if(Imported.YEP_BaseParamControl) this._baseParamCache = [];
  666.         this._distributeParams[paramId] = value;
  667. };
  668.  
  669. Game_Actor.prototype.addDistributePointsSpent = function(value) {
  670.         this._distributePointsSpent += value;
  671. };
  672.  
  673. Game_Actor.prototype.clearDistributePointsSpent = function() {
  674.         this._distributePointsSpent = 0;
  675. };
  676.  
  677. Game_Actor.prototype.clearDistributeStats = function() {
  678.         this._distributeParams = [0, 0, 0, 0, 0, 0, 0, 0];
  679.         this._distributeXParams = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  680.         this._distributeSParams = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  681. };
  682.  
  683. Game_Actor.prototype.resetDistributeStats = function() {
  684.         this.addDistributePointsTemp(this._distributePointsSpent);
  685.         this.clearDistributePointsSpent();
  686.         this.clearDistributeStats();
  687. }
  688.  
  689. Game_Actor.prototype.addBaseDistribute = function(paramId, value) {
  690.         this.setBaseDistribute(paramId, this._distributeParams[paramId] + value);
  691. };
  692.  
  693. Game_Actor.prototype.setXDistribute = function(xparamId, value) {
  694.         this._distributeXParams[xparamId] = value;
  695. };
  696.  
  697. Game_Actor.prototype.addXDistribute = function(xparamId, value) {
  698.         this.setXDistribute(xparamId, this._distributeXParams[xparamId] + value);
  699. };
  700.  
  701. Game_Actor.prototype.setSDistribute = function(sparamId, value) {
  702.         this._distributeSParams[sparamId] = value;
  703. };
  704.  
  705. Game_Actor.prototype.addSDistribute = function(sparamId, value) {
  706.         this.setSDistribute(sparamId, this._distributeSParams[sparamId] + value);
  707. };
  708.  
  709. Game_Actor.prototype.getAbnormalParam = function(param) {
  710. };
  711.  
  712. Game_Actor.prototype.addAbnormalParam = function(param, value) {
  713. };
  714.  
  715. Game_Actor.prototype.getDistribute = function(param) {
  716.         const type = this.getParamType(param);
  717.         switch(type) {
  718.                 case 1:
  719.                         return this._distributeParams[Game_Actor.bParams.indexOf(param)];
  720.                         break;
  721.                 case 2:
  722.                         return this._distributeXParams[Game_Actor.xParams.indexOf(param)];
  723.                         break;
  724.                 case 3:
  725.                         return this._distributeSParams[Game_Actor.sParams.indexOf(param)];
  726.                         break;
  727.                 default:
  728.                         return this.getAbnormalParam(param);
  729.                         break;
  730.         }
  731. };
  732.  
  733. Game_Actor.prototype.addDistribute = function(param, value) {
  734.         const type = this.getParamType(param);
  735.         switch(type) {
  736.                 case 1:
  737.                         this.addBaseDistribute(Game_Actor.bParams.indexOf(param), value);
  738.                         break;
  739.                 case 2:
  740.                         this.addXDistribute(Game_Actor.xParams.indexOf(param), value);
  741.                         break;
  742.                 case 3:
  743.                         this.addSDistribute(Game_Actor.sParams.indexOf(param), value);
  744.                         break;
  745.                 default:
  746.                         this.addAbnormalParam(param, value);
  747.                         break;
  748.         }
  749. };
  750.  
  751. Game_Actor.prototype.getParamType = function(param) {
  752.         if(Game_Actor.bParams.contains(param)) {
  753.                 return 1;
  754.         } else if(Game_Actor.xParams.contains(param)) {
  755.                 return 2;
  756.         } else if(Game_Actor.sParams.contains(param)) {
  757.                 return 3;
  758.         }
  759.         return 0;
  760. };
  761.  
  762. //-----------------------------------------------------------------------------
  763. // Game_Interpreter
  764. //-----------------------------------------------------------------------------
  765.  
  766. if(!SRD.Game_Interpreter_pluginCommand) {
  767.  
  768. SRD.Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  769. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  770.         const com = command.trim().toLowerCase();
  771.         if(SRD.PluginCommands[com]) {
  772.                 SRD.PluginCommands[com].call(this, args);
  773.                 return;
  774.         }
  775.         SRD.Game_Interpreter_pluginCommand.apply(this, arguments);
  776. };
  777.  
  778. }
  779.  
  780. //-----------------------------------------------------------------------------
  781. // Scene_Menu
  782. //-----------------------------------------------------------------------------
  783.  
  784. _.Scene_Menu_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
  785. Scene_Menu.prototype.createCommandWindow = function() {
  786.         _.Scene_Menu_createCommandWindow.apply(this, arguments);
  787.         if(_.show) {
  788.                 this._commandWindow.setHandler('distribute', this.commandPersonal.bind(this));
  789.         }
  790. };
  791.  
  792. _.Scene_Menu_onPersonalOk = Scene_Menu.prototype.onPersonalOk;
  793. Scene_Menu.prototype.onPersonalOk = function() {
  794.         if(this._commandWindow.currentSymbol() === 'distribute') {
  795.                 this.openStatDistribution();
  796.                 return;
  797.         }
  798.         _.Scene_Menu_onPersonalOk.apply(this, arguments);
  799. };
  800.  
  801. Scene_Menu.prototype.openStatDistribution = function() {
  802.         SceneManager.push(Scene_Distribute);
  803. };
  804.  
  805. //-----------------------------------------------------------------------------
  806. // Scene_Distribute
  807. //-----------------------------------------------------------------------------
  808.  
  809. Scene_Distribute.prototype = Object.create(Scene_MenuBase.prototype);
  810. Scene_Distribute.prototype.constructor = Scene_Distribute;
  811.  
  812. Scene_Distribute.prototype.initialize = function() {
  813.         Scene_MenuBase.prototype.initialize.call(this);
  814.         ImageManager.loadFace($gameParty.menuActor().faceName());
  815. };
  816.  
  817. Scene_Distribute.prototype.create = function() {
  818.         Scene_MenuBase.prototype.create.call(this);
  819.         this.createHelpWindow();
  820.         this.createCommandWindow();
  821.         this.createStatusWindow();
  822.         this.createPointsWindow();
  823.         this.createDistributeWindow();
  824.         this.refreshActor();
  825. };
  826.  
  827. Scene_Distribute.prototype.createCommandWindow = function() {
  828.         const wy = this._helpWindow.height;
  829.         this._commandWindow = new Window_DistributeCommand(0, wy);
  830.         this._commandWindow.setHelpWindow(this._helpWindow);
  831.         this._commandWindow.setHandler('spend',    this.commandSpend.bind(this));
  832.         this._commandWindow.setHandler('clear',    this.commandClear.bind(this));
  833.         this._commandWindow.setHandler('cancel',   this.popScene.bind(this));
  834.         this._commandWindow.setHandler('pagedown', this.nextActor.bind(this));
  835.         this._commandWindow.setHandler('pageup',   this.previousActor.bind(this));
  836.         this.addWindow(this._commandWindow);
  837. };
  838.  
  839. Scene_Distribute.prototype.createStatusWindow = function() {
  840.         const wy = this._commandWindow.y + this._commandWindow.height;
  841.         this._statusWindow = new Window_DistributeStatus(0, wy);
  842.         this.addWindow(this._statusWindow);
  843. };
  844.  
  845. Scene_Distribute.prototype.createPointsWindow = function() {
  846.         const wy = this._statusWindow.y + this._statusWindow.height;
  847.         this._pointsWindow = new Window_DistributePoints(0, wy);
  848.         this.addWindow(this._pointsWindow);
  849.         this._commandWindow.setPointsWindow(this._pointsWindow);
  850. };
  851.  
  852. Scene_Distribute.prototype.createDistributeWindow = function() {
  853.         const wx = this._statusWindow.width;
  854.         const wy = this._commandWindow.y + this._commandWindow.height;
  855.         const ww = Graphics.boxWidth - wx;
  856.         this._distributeWindow = new Window_Distribute(wx, wy, ww);
  857.         this._distributeWindow.setHelpWindow(this._helpWindow);
  858.         this._distributeWindow.setStatusWindow(this._statusWindow);
  859.         this._distributeWindow.setPointsWindow(this._pointsWindow);
  860.         this._distributeWindow.setHandler('finish', this.distributeFinish.bind(this));
  861.         this._distributeWindow.setHandler('cancel', this.distributeCancel.bind(this));
  862.         this.addWindow(this._distributeWindow);
  863. };
  864.  
  865. Scene_Distribute.prototype.refreshActor = function() {
  866.         const actor = this.actor();
  867.         this._commandWindow.setActor(actor);
  868.         this._statusWindow.setActor(actor);
  869.         this._distributeWindow.setActor(actor);
  870. };
  871.  
  872. Scene_Distribute.prototype.commandSpend = function() {
  873.         this._distributeWindow.activate();
  874.         this._distributeWindow.select(0);
  875. };
  876.  
  877. Scene_Distribute.prototype.commandClear = function() {
  878.         this.actor().resetDistributeStats();
  879.         if (_.bUseItem) {
  880.             $gameParty.loseItem($dataItems[eval(_.itemID)],this._commandWindow.getCost());
  881.         }
  882.         else {
  883.             $gameParty.loseGold(this._commandWindow.getCost());
  884.         }
  885.         this._distributeWindow.refresh();
  886.         this._statusWindow.refresh();
  887.         this._commandWindow.refresh();
  888.         this._commandWindow.refreshCost();
  889.         this._commandWindow.activate();
  890. };
  891.  
  892. Scene_Distribute.prototype.distributeFinish = function() {
  893.         this._distributeWindow.applyBonuses();
  894.         this._distributeWindow.clearInfo();
  895.         this._statusWindow.refresh();
  896.         this.distributeEnd();
  897. };
  898.  
  899. Scene_Distribute.prototype.distributeCancel = function() {
  900.         this._distributeWindow.restartInfo();
  901.         this.distributeEnd();
  902. };
  903.  
  904. Scene_Distribute.prototype.distributeEnd = function() {
  905.         this._pointsWindow.clear();
  906.         this._distributeWindow.refresh();
  907.         this._distributeWindow.deselect();
  908.         this._commandWindow.activate();
  909.         this._commandWindow.refreshCost();
  910.         this._commandWindow.refresh();
  911. };
  912.  
  913. Scene_Distribute.prototype.onActorChange = function() {
  914.         this.refreshActor();
  915.         this._commandWindow.activate();
  916. };
  917.  
  918. //-----------------------------------------------------------------------------
  919. // Window_MenuCommand
  920. //-----------------------------------------------------------------------------
  921.  
  922. _.Window_MenuCommand_addOriginalCommands = Window_MenuCommand.prototype.addOriginalCommands;
  923. Window_MenuCommand.prototype.addOriginalCommands = function() {
  924.         _.Window_MenuCommand_addOriginalCommands.apply(this, arguments);
  925.         if(_.show) {
  926.                 this.addCommand(_.name, 'distribute', this.isDistributeEnabled());
  927.         }
  928. };
  929.  
  930. Window_MenuCommand.prototype.isDistributeEnabled = function() {
  931.         return true;
  932. };
  933.  
  934. //-----------------------------------------------------------------------------
  935. // Window_DistributeCommand
  936. //-----------------------------------------------------------------------------
  937.  
  938. Window_DistributeCommand.prototype = Object.create(Window_HorzCommand.prototype);
  939. Window_DistributeCommand.prototype.constructor = Window_DistributeCommand;
  940.  
  941. Window_DistributeCommand.prototype.initialize = function(x, y) {
  942.         Window_HorzCommand.prototype.initialize.call(this, x, y);
  943.         this._cost = 0;
  944.         this._actor = null;
  945.         this._pointsWindow = null;
  946. };
  947.  
  948. Window_DistributeCommand.prototype.playOkSound = function() {
  949.         const symbol = this.commandSymbol(this.index());
  950.         if(symbol === 'clear') {
  951.                 SoundManager.playUseItem();
  952.         } else {
  953.                 Window_HorzCommand.prototype.playOkSound.apply(this, arguments);
  954.         }
  955. };
  956.  
  957. Window_DistributeCommand.prototype.windowWidth = function() {
  958.         return Graphics.boxWidth;
  959. };
  960.  
  961. Window_DistributeCommand.prototype.maxCols = function() {
  962.         return this._list.length;
  963. };
  964.  
  965. Window_DistributeCommand.prototype.makeCommandList = function() {
  966.         this.addCommand(_.spendText, 'spend');
  967.         if(_.reset) {
  968.                 const actorReady = this._actor && this._actor.pointsUsed() > 0;
  969.                 this.addCommand(_.resetText, 'clear', actorReady && ((!(_.bUseItem) && this._cost <= $gameParty.gold()) || (_.bUseItem && this._cost <= $gameParty.numItems($dataItems[eval(_.itemID)]))));
  970.         }
  971.         this.addCommand(_.finishText, 'cancel');
  972. };
  973.  
  974. Window_DistributeCommand.prototype.setPointsWindow = function(window) {
  975.         this._pointsWindow = window;
  976. };
  977.  
  978. Window_DistributeCommand.prototype.setActor = function(actor) {
  979.         if(this._actor !== actor) {
  980.                 this._actor = actor;
  981.                 this.refreshCost();
  982.                 this.refresh();
  983.         }
  984. };
  985.  
  986. Window_DistributeCommand.prototype.getCost = function() {
  987.         return this._cost;
  988. };
  989.  
  990. Window_DistributeCommand.prototype.needsItem = function() {
  991.         return _.bUseItem;
  992. };
  993.  
  994. Window_DistributeCommand.prototype.getItemID = function() {
  995.         return eval(_.itemID);
  996. };
  997.  
  998. Window_DistributeCommand.prototype.refreshCost = function() {
  999.         const actor = this._actor;
  1000.         const level = this._actor.level;
  1001.         const points = this._actor.pointsUsed();
  1002.         this._cost = eval(_.cost);
  1003. };
  1004.  
  1005. Window_DistributeCommand.prototype.select = function(index) {
  1006.         Window_HorzCommand.prototype.select.apply(this, arguments);
  1007.         if(!this._pointsWindow) return;
  1008.         const symbol = this.commandSymbol(index);
  1009.         this._pointsWindow.clear();
  1010.         if(symbol === 'clear') {
  1011.                 this._pointsWindow.setGoldCost(this._cost);
  1012.         }
  1013. };
  1014.  
  1015. //-----------------------------------------------------------------------------
  1016. // Window_DistributePoints
  1017. //-----------------------------------------------------------------------------
  1018.  
  1019. Window_DistributePoints.prototype = Object.create(Window_Base.prototype);
  1020. Window_DistributePoints.prototype.constructor = Window_DistributePoints;
  1021.  
  1022. Window_DistributePoints.prototype.initialize = function(x, y) {
  1023.         const width = this.windowWidth();
  1024.         const height = this.windowHeight();
  1025.         Window_Base.prototype.initialize.call(this, x, y, width, height);
  1026.         this._actor = null;
  1027.         this._points = 0;
  1028. };
  1029.  
  1030. Window_DistributePoints.prototype.windowWidth = function() {
  1031.         return 408;
  1032. };
  1033.  
  1034. Window_DistributePoints.prototype.windowHeight = function() {
  1035.         return this.fittingHeight(1);
  1036. };
  1037.  
  1038. Window_DistributePoints.prototype.refresh = function() {
  1039.         const x = this.textPadding();
  1040.         const width = this.contentsWidth() - this.textPadding() * 2;
  1041.         const unitWidth = _.iconIndex ? Window_Base._iconWidth : this.textWidth(_.pointText);
  1042.         this.clear();
  1043.         this.resetTextColor();
  1044.         this.drawText(this.points(), x, 0, width - unitWidth - 12, 'right');
  1045.         if(_.iconIndex) {
  1046.                 this.drawIcon(_.iconIndex, this.windowWidth() - this.standardPadding() - Window_Base._iconWidth - 24, 2);
  1047.         } else {
  1048.                 this.changeTextColor(_.labelColor);
  1049.                 this.drawText(_.pointText, x, 0, width - 6, 'right');
  1050.         }
  1051.         this.changeTextColor(this.systemColor());
  1052.         this.contents.fontSize = 24;
  1053.         this.drawText(this.label(), 0, 0, width, 'left');
  1054.         this.resetFontSettings();
  1055. };
  1056.  
  1057. Window_DistributePoints.prototype.clear = function() {
  1058.         this.contents.clear();
  1059. };
  1060.  
  1061. Window_DistributePoints.prototype.points = function() {
  1062.         return this._points;
  1063. };
  1064.  
  1065. Window_DistributePoints.prototype.setValue = function(value) {
  1066.         this._points = value;
  1067.         this.refresh();
  1068. };
  1069.  
  1070. Window_DistributePoints.prototype.label = function() {
  1071.         return _.upgrade;
  1072. };
  1073.  
  1074. if(Imported.YEP_X_MoreCurrencies) alert("Please place YEP_X_MoreCurrencies below SRD_StatDistribution!");
  1075.  
  1076. _.Window_Gold_refresh = Window_Gold.prototype.refresh;
  1077.  
  1078. Window_DistributePoints.prototype.drawCost = function(value) {
  1079.     if (_.bUseItem){
  1080.         var x = this.textPadding();
  1081.         var y = 0
  1082.         var width = this.contents.width - this.textPadding() * 2;
  1083.         this.contents.clear();
  1084.        
  1085.         //this.drawItemName($dataItems[eval(_.itemID)], x, 0, width)
  1086.         const unitWidth = Window_Base._iconWidth
  1087.         this.resetTextColor();
  1088.         this.drawText(value, x, y, width - unitWidth - 6, 'right');
  1089.         var iconIndex = $dataItems[eval(_.itemID)].iconIndex
  1090.         this.drawIcon(iconIndex, this.width - this.standardPadding() - Window_Base._iconWidth - 24, y + 2);
  1091.         //this.changeTextColor(this.systemColor());
  1092.         //this.drawText(unit, x + width - unitWidth, y, unitWidth, 'right');
  1093.         //this.drawCurrencyValue(this.value(), this.currencyUnit(), x, 0, width);
  1094.     }
  1095.     else {
  1096.         _.Window_Gold_refresh.apply(this, arguments);
  1097.     }
  1098. };
  1099.  
  1100. Window_DistributePoints.prototype.setGoldCost = function(gold) {
  1101.         this._value = gold;
  1102.         this.drawCost(gold);
  1103.         //_.Window_Gold_refresh.apply(this, arguments);
  1104.         this.drawResetCost();
  1105. };
  1106.  
  1107. Window_DistributePoints.prototype.drawResetCost = function() {
  1108.         const width = this.contentsWidth() - this.textPadding() * 2;
  1109.         this.changeTextColor(this.systemColor());
  1110.         this.contents.fontSize = 24;
  1111.         this.drawText("Réinitialiser:", 0, 0, width, 'left');
  1112.         this.resetFontSettings();
  1113. };
  1114.  
  1115. Window_DistributePoints.prototype.currencyUnit = Window_Gold.prototype.currencyUnit;
  1116.  
  1117. Window_DistributePoints.prototype.value = function() {
  1118.         return this._value;
  1119. };
  1120.  
  1121. //-----------------------------------------------------------------------------
  1122. // Window_DistributeStatus
  1123. //-----------------------------------------------------------------------------
  1124.  
  1125. Window_DistributeStatus.prototype = Object.create(Window_Selectable.prototype);
  1126. Window_DistributeStatus.prototype.constructor = Window_DistributeStatus;
  1127.  
  1128. Window_DistributeStatus.prototype.initialize = function(x, y) {
  1129.         Window_Selectable.prototype.initialize.call(this, x, y, 408, this.fittingHeight(8));
  1130.         this._actor = null;
  1131.         this.refresh();
  1132.         this.activate();
  1133. };
  1134.  
  1135. Window_DistributeStatus.prototype.setActor = function(actor) {
  1136.         if(this._actor !== actor) {
  1137.                 this._actor = actor;
  1138.                 this.refresh();
  1139.         }
  1140. };
  1141.  
  1142. Window_DistributeStatus.prototype.refresh = function() {
  1143.         this.contents.clear();
  1144.         if(this._actor) {
  1145.                 const lineHeight = this.lineHeight();
  1146.                 //Line 1
  1147.                 this.drawActorName(this._actor, 6, 0);
  1148.                 this.drawActorClass(this._actor, 192, 0);
  1149.                 //Line 2
  1150.                 this.drawHorzLine(lineHeight);
  1151.                 //Line 3
  1152.                 this.drawActorFace(this._actor, 12, lineHeight * 2);
  1153.                 this.drawBasicInfo(180, lineHeight * 2, this.contentsWidth() - 180);
  1154.                 //Line 7
  1155.                 this.drawHorzLine(lineHeight * 6);
  1156.                 //Line 8
  1157.                 this.drawActorPoints(lineHeight * 7, this.contentsWidth() - this.textPadding() * 2);
  1158.         }
  1159. };
  1160.  
  1161. Window_DistributeStatus.prototype.drawBasicInfo = function(x, y, width) {
  1162.         const lineHeight = this.lineHeight();
  1163.         this.drawActorLevel(this._actor, x, y + lineHeight * 0);
  1164.         this.drawActorIcons(this._actor, x, y + lineHeight * 1);
  1165.         this.drawActorHp(this._actor, x, y + lineHeight * 2, width);
  1166.         this.drawActorMp(this._actor, x, y + lineHeight * 3, width);
  1167. };
  1168.  
  1169. Window_DistributeStatus.prototype.drawHorzLine = function(y) {
  1170.         const lineY = y + this.lineHeight() / 2 - 1;
  1171.         this.contents.paintOpacity = 48;
  1172.         this.contents.fillRect(0, lineY, this.contentsWidth(), 2, this.normalColor());
  1173.         this.contents.paintOpacity = 255;
  1174. };
  1175.  
  1176. Window_DistributeStatus.prototype.drawActorPoints = function(y, width) {
  1177.         const x = this.textPadding();
  1178.         const unitWidth = _.iconIndex ? Window_Base._iconWidth : this.textWidth(_.pointText);
  1179.         this.resetTextColor();
  1180.         this.drawText(this._actor.distributePoints(), x, y, width - unitWidth - 12, 'right');
  1181.         if(_.iconIndex) {
  1182.                 this.drawIcon(_.iconIndex, this.width - this.standardPadding() - Window_Base._iconWidth - 24, y + 2);
  1183.         } else {
  1184.                 this.changeTextColor(_.labelColor);
  1185.                 this.drawText(_.pointText, x, y, width - 6, 'right');
  1186.         }
  1187.         this.contents.fontSize = 24;
  1188.         this.drawText(_.points, 0, y, width, 'left');
  1189.         this.resetFontSettings();
  1190. };
  1191.  
  1192. Window_DistributeStatus.prototype.refreshPoints = function() {
  1193.         const lineHeight = this.lineHeight();
  1194.         const width = this.contentsWidth();
  1195.         this.contents.clearRect(0, lineHeight * 7, width, lineHeight);
  1196.         this.drawActorPoints(lineHeight * 7, width - this.textPadding() * 2);
  1197. };
  1198.  
  1199. //-----------------------------------------------------------------------------
  1200. // Window_Distribute
  1201. //-----------------------------------------------------------------------------
  1202.  
  1203. Window_Distribute.prototype = Object.create(Window_Command.prototype);
  1204. Window_Distribute.prototype.constructor = Window_Distribute;
  1205.  
  1206. Window_Distribute.prototype.initialize = function(x, y, width) {
  1207.         this._windowWidth = width;
  1208.         this._maxHeight = Graphics.boxHeight - y;
  1209.         this._statusWindow = null;
  1210.         this._pointsWindow = null;
  1211.         this.clearInfo();
  1212.         Window_Command.prototype.initialize.call(this, x, y);
  1213.         this.deselect();
  1214.         this.deactivate();
  1215. };
  1216.  
  1217. Window_Distribute.prototype.drawGauge = function(x, y, width, rate, color1, color2) {
  1218.         const fillW = Math.floor(width * rate);
  1219.         const gaugeY = y + this.lineHeight() - 2 - _.gaugeHeight;
  1220.         this.contents.fillRect(x - 1, gaugeY - 1, width + 2, _.gaugeHeight + 2, "#000");
  1221.         this.contents.fillRect(x, gaugeY, width, _.gaugeHeight, this.gaugeBackColor());
  1222.         this.contents.gradientFillRect(x, gaugeY, fillW, _.gaugeHeight, color1, color2);
  1223. };
  1224.  
  1225. Window_Distribute.prototype.playOkSound = function() {
  1226.         const symbol = this.commandSymbol(this.index());
  1227.         if(symbol === 'finish') {
  1228.                 SoundManager.playSave();
  1229.         } else {
  1230.                 Window_Command.prototype.playOkSound.apply(this, arguments);
  1231.         }
  1232. };
  1233.  
  1234. Window_Distribute.prototype.windowWidth = function() {
  1235.         return this._windowWidth;
  1236. };
  1237.  
  1238. Window_Distribute.prototype.windowHeight = function() {
  1239.         return Math.min(this.fittingHeight(this.numVisibleRows()), this._maxHeight);
  1240. };
  1241.  
  1242. Window_Distribute.prototype.setActor = function(actor) {
  1243.         if(this._actor !== actor) {
  1244.                 this._actor = actor;
  1245.                 this.clearInfo();
  1246.                 this.refresh();
  1247.         }
  1248. };
  1249.  
  1250. Window_Distribute.prototype.setStatusWindow = function(window) {
  1251.         this._statusWindow = window;
  1252. };
  1253.  
  1254. Window_Distribute.prototype.setPointsWindow = function(window) {
  1255.         this._pointsWindow = window;
  1256. };
  1257.  
  1258. Window_Distribute.prototype.restartInfo = function() {
  1259.         this._actor.addDistributePointsTemp(this._pointsSpent);
  1260.         this.refreshEverything();
  1261.         this.clearInfo();
  1262. };
  1263.  
  1264. Window_Distribute.prototype.clearInfo = function() {
  1265.         this._pointsSpent = 0;
  1266.         this._maxPoints = this._actor ? this._actor.distributePoints() : 0;
  1267.         this._bonuses = {};
  1268. };
  1269.  
  1270. Window_Distribute.prototype.applyBonuses = function() {
  1271.         if(this._actor) {
  1272.                 Object.keys(this._bonuses).forEach(function(key) {
  1273.                         this._actor.addDistribute(key, this._bonuses[key]);
  1274.                 }, this);
  1275.         }
  1276.         this._actor.addDistributePointsSpent(this._pointsSpent);
  1277.         this._pointsSpent = 0;
  1278. };
  1279.  
  1280. Window_Distribute.prototype.updateHelp = function() {
  1281.         const index = this.index();
  1282.         if(!this._list[index]) return;
  1283.         const symbol = this.commandSymbol(index);
  1284.         this._pointsWindow.clear();
  1285.         this._helpWindow.clear();
  1286.         if(symbol !== 'finish') {
  1287.                 const data = $dataDistributeStats[symbol];
  1288.                 const actor = this._actor;
  1289.                 this._pointsWindow.setValue(eval(data.cost));
  1290.                 this._helpWindow.setText(data.description);
  1291.         }
  1292. };
  1293.  
  1294. Window_Distribute.prototype.makeCommandList = function() {
  1295.         if(this._actor) {
  1296.                 const stats = this._actor.actor()._sd_stats || _.stats;
  1297.                 stats.forEach(function(stat) {
  1298.                         if($dataDistributeStats[stat]) {
  1299.                                 this.addCommand($dataDistributeStats[stat].name, stat);
  1300.                         }
  1301.                 }, this);
  1302.         }
  1303.         this.addCommand("Valider", 'finish');
  1304. };
  1305.  
  1306. Window_Distribute.prototype.drawItem = function(index) {
  1307.         const symbol = this.commandSymbol(index);
  1308.         if(symbol === 'finish') {
  1309.                 this.drawFinishItem(index);
  1310.         } else {
  1311.                 this.drawNormalItem(index, symbol);
  1312.         }
  1313. };
  1314.  
  1315. Window_Distribute.prototype.drawNormalItem = function(index, symbol) {
  1316.         const rect = this.itemRectForText(index);
  1317.         const name = this.commandName(index);
  1318.         const nameWidth = this.textWidth(name);
  1319.         const statWidth = rect.width - nameWidth;
  1320.         let stat = this._actor[symbol];
  1321.         this.changeTextColor(this.systemColor());
  1322.         const actor = this._actor;
  1323.         const data = $dataDistributeStats[symbol];
  1324.         const cost = eval(data.cost);
  1325.         let add = 0;
  1326.         if(this._bonuses[symbol] && this._bonuses[symbol] > 0) add = this._bonuses[symbol];
  1327.         const current = (actor.getDistribute(symbol) + add);
  1328.         const max = eval(data.max);
  1329.         this.changePaintOpacity((current < max && this.hasPoints(cost)) || (this._bonuses[symbol] && this._bonuses[symbol] > 0));
  1330.         if(_.drawGauges) {
  1331.                 let rate = 0;
  1332.                 rate = current / max;
  1333.                 this.drawGauge(rect.x, rect.y, rect.width, rate, data.min_col, data.max_col);
  1334.         }
  1335.         this.drawText(name, rect.x, rect.y, nameWidth, 'left');
  1336.         this.drawNormalItemNumbers(stat, symbol, nameWidth, statWidth, rect);
  1337. };
  1338.  
  1339. Window_Distribute.prototype.drawNormalItemNumbers = function(stat, symbol, nameWidth, statWidth, rect) {
  1340.         if(stat !== undefined) {
  1341.                 const percent = Game_Actor.xParams.contains(symbol) || Game_Actor.sParams.contains(symbol);
  1342.                 let bonusWidth = -12;
  1343.                 this.contents.fontSize = 22;
  1344.                 if(this._bonuses[symbol]) {
  1345.                         const bonusText = percent ? `(+${Math.round(this._bonuses[symbol]*1000) / 10}%)` : `(+${this._bonuses[symbol]})`;
  1346.                         bonusWidth = this.textWidth(bonusText);
  1347.                         this.changeTextColor("#66ff66");
  1348.                         this.drawText(bonusText, nameWidth, rect.y, statWidth, 'right');
  1349.                 }
  1350.                 this.resetTextColor();
  1351.                 if(percent) stat = `${Math.round(stat*1000) / 10}%`;
  1352.                 this.drawText(stat, nameWidth, rect.y, statWidth - bonusWidth - 12, 'right');
  1353.                 this.resetFontSettings();
  1354.         }
  1355. };
  1356.  
  1357. Window_Distribute.prototype.drawFinishItem = function(index) {
  1358.         const rect = this.itemRectForText(index);
  1359.         const isEnabled = this._pointsSpent > 0;
  1360.         this.changePaintOpacity(isEnabled);
  1361.         this._list[this._list.length - 1].enabled = isEnabled;
  1362.         this.contents.fontSize = 24;
  1363.         this.drawText(this.commandName(index), rect.x, rect.y, rect.width, 'center');
  1364.         this.resetFontSettings();
  1365. };
  1366.  
  1367. Window_Distribute.prototype.hasPoints = function(amount) {
  1368.         return this._actor.distributePoints() >= amount;
  1369. };
  1370.  
  1371. Window_Distribute.prototype.canReturnPoints = function(amount) {
  1372.         return this._pointsSpent >= amount;
  1373. };
  1374.  
  1375. Window_Distribute.prototype.removePoint = function(amount) {
  1376.         this._actor.addDistributePointsTemp(-amount);
  1377.         this._pointsSpent += amount;
  1378.         this.refreshEverything();
  1379. };
  1380.  
  1381. Window_Distribute.prototype.addPoint = function(amount) {
  1382.         this._actor.addDistributePointsTemp(amount);
  1383.         this._pointsSpent -= amount;
  1384.         this.refreshEverything();
  1385. };
  1386.  
  1387. Window_Distribute.prototype.refreshEverything = function() {
  1388.         this._pointsWindow.refresh();
  1389.         this._statusWindow.refreshPoints();
  1390.         this.refresh();
  1391. };
  1392.  
  1393. Window_Distribute.prototype.processOk = function() {
  1394.         const index = this.index();
  1395.         const symbol = this.commandSymbol(index);
  1396.         if(symbol === 'finish') {
  1397.                 Window_Command.prototype.processOk.apply(this, arguments);
  1398.         } else {
  1399.                 this.cursorRight();
  1400.         }
  1401. };
  1402.  
  1403. Window_Distribute.prototype.cursorRight = function(wrap) {
  1404.         const index = this.index();
  1405.         const symbol = this.commandSymbol(index);
  1406.         if(symbol === 'finish') return;
  1407.         const actor = this._actor;
  1408.         const current = actor.getDistribute(symbol);
  1409.         const data = $dataDistributeStats[symbol];
  1410.         const cost = eval(data.cost);
  1411.         if(!this.hasPoints(cost)) {
  1412.                 return;
  1413.         }
  1414.         if(this._bonuses[symbol] === undefined) this._bonuses[symbol] = 0;
  1415.         const prev = this._bonuses[symbol];
  1416.         this._bonuses[symbol] += eval(data.gain);
  1417.         this._bonuses[symbol] = this._bonuses[symbol].clamp(0, eval(data.max) - current);
  1418.         if(this._bonuses[symbol] !== prev) {
  1419.                 this.removePoint(cost);
  1420.                 this.refreshEverything();
  1421.                 SoundManager.playCursor();
  1422.         }
  1423. };
  1424.  
  1425. Window_Distribute.prototype.cursorLeft = function(wrap) {
  1426.         const index = this.index();
  1427.         const symbol = this.commandSymbol(index);
  1428.         if(symbol === 'finish') return;
  1429.         const actor = this._actor;
  1430.         const current = actor.getDistribute(symbol);
  1431.         const data = $dataDistributeStats[symbol];
  1432.         const cost = eval(data.cost);
  1433.         if(!this.canReturnPoints(cost)) {
  1434.                 return;
  1435.         }
  1436.         if(this._bonuses[symbol] === undefined) this._bonuses[symbol] = 0;
  1437.         const prev = this._bonuses[symbol];
  1438.         this._bonuses[symbol] -= eval(data.gain);
  1439.         this._bonuses[symbol] = this._bonuses[symbol].clamp(0, eval(data.max) - current);
  1440.         if(this._bonuses[symbol] !== prev) {
  1441.                 this.addPoint(cost);
  1442.                 this.refreshEverything();
  1443.                 SoundManager.playCursor();
  1444.         }
  1445. };
  1446.  
  1447. Window_Distribute.prototype.refresh = function() {
  1448.         this.clearCommandList();
  1449.         this.makeCommandList();
  1450.         this.height = this.windowHeight();
  1451.         this.createContents();
  1452.         Window_Selectable.prototype.refresh.call(this);
  1453. };
  1454.  
  1455. })(SRD.StatDistribution);
Tags: rpg maker mv
Advertisement
Add Comment
Please, Sign In to add comment