Advertisement
ICF-Soft

ICFSoft_SRD_Distribution

Dec 19th, 2018
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // ICF-Soft Plugins - Patch to use params core stats in srd stat distribution plugin
  3. // ICFSoft_SRD_Distribution.js
  4. //=============================================================================
  5.  
  6. var Imported = Imported || {};
  7. Imported.ICFSoft_SRD_Distribution = true;
  8.  
  9. var ICF = ICF || {};
  10. ICF.SRD_Distribution = ICF.SRD_Distribution || {};
  11.  
  12. ICF.SRD_Distribution.Version = 101; // 1.01
  13.  
  14. //=============================================================================
  15.  /*:
  16.  * @plugindesc v1.01 This plugin allows you to increase params created with
  17.  * ICFSoft's Params Core througth srd stat distribution plugin.
  18.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  19.  *
  20.  * @help
  21.  * ============================================================================
  22.  * Introduction
  23.  * ============================================================================
  24.  *
  25.  * This plugin allows you to increase params created with ICFSoft's Params Core
  26.  * througth srd stat distribution plugin. Also works with max tp.
  27.  *
  28.  * It is based on Stat Distribution v1.07 and must be placed before them.
  29.  *
  30.  * ============================================================================
  31.  * How to use
  32.  * ============================================================================
  33.  *
  34.  * Just use mtp and created params as upgradeable stats.
  35.  *
  36.  * ============================================================================
  37.  * Incompatibilities
  38.  * ============================================================================
  39.  *
  40.  * There's no known incompatible plugins yet.
  41.  *
  42.  * ============================================================================
  43.  * Known isues
  44.  * ============================================================================
  45.  *
  46.  * Not yet.
  47.  *
  48.  * ============================================================================
  49.  * Changelog
  50.  * ============================================================================
  51.  *
  52.  * Version 1.01:
  53.  * - Added use of ICF-Soft Params Core CParams.
  54.  *
  55.  * Version 1.00:
  56.  * - Finished plugin!
  57.  *
  58.  * ============================================================================
  59.  *
  60.  * For commercial and non-commercial games.
  61.  * Credit to ICF-Soft.
  62.  * This entire header must be included with plugin.
  63.  *
  64.  * ============================================================================
  65. */
  66. //=============================================================================
  67.  /*:es
  68.  * @plugindesc v1.01 Permite incrementar los parámetros creados con ICFSoft's
  69.  * Params Core mediante el complemento de srd stat distribution.
  70.  * @author ICF-Soft [http://icfsoft.blogspot.com.es/]
  71.  *
  72.  * @help
  73.  * ============================================================================
  74.  * Introducción
  75.  * ============================================================================
  76.  *
  77.  * Este plugin permite incrementar los parámetros creados con ICF-Soft Params
  78.  * Core mediante el complemento de SumRndmDde stat distribution así como el tp
  79.  * máximo.
  80.  *
  81.  * Basado en Stat Distribution v1.07 de SumRndmDde.
  82.  * Debe estar colocado debajo de ambos.
  83.  *
  84.  * ============================================================================
  85.  * Uso
  86.  * ============================================================================
  87.  *
  88.  * Utiliza mtp y parámetros creados como parámetros que se pueden mejorar.
  89.  *
  90.  * ============================================================================
  91.  * Incompatibilidades
  92.  * ============================================================================
  93.  *
  94.  * No se conocen complementos que sean incompatibles hasta la fecha.
  95.  *
  96.  * ============================================================================
  97.  * Problemas conocidos
  98.  * ============================================================================
  99.  *
  100.  * De momento ninguno.
  101.  *
  102.  * ============================================================================
  103.  * Historial de versiones
  104.  * ============================================================================
  105.  *
  106.  * Versión 1.01:
  107.  * - Se ha añadido el uso de los CParams.
  108.  *
  109.  * Versión 1.00:
  110.  * - Complemento terminado.
  111.  *
  112.  * ============================================================================
  113.  *
  114.  * Para juegos comerciales y no comerciales.
  115.  * Se debe incluir a ICF-Soft en los créditos.
  116.  * Esta cabecera debe incluirse íntegramente con el plugin.
  117.  *
  118.  * ============================================================================
  119. */
  120. //=============================================================================
  121.  
  122. //=============================================================================
  123. // DataManagerEX
  124. //=============================================================================
  125.  
  126. DataManagerEX.getStatDistributionHtmlOptions = function() {
  127.     var options = `<option value="mhp" selected>Max HP</option>
  128.             <option value="mmp">Max MP</option>
  129.             <option value="mtp">Max TP</option>
  130.             <option value="atk">Attack</option>
  131.             <option value="def">Defense</option>
  132.             <option value="mat">Magical Attack</option>
  133.             <option value="mdf">Magical Defense</option>
  134.             <option value="agi">Agility</option>
  135.             <option value="luk">Luck</option>
  136.             <option value="frame">   </option>
  137.             <option value="hit">Hit Rate</option>
  138.             <option value="eva">Evasion Rate</option>
  139.             <option value="cri">Critical Rate</option>
  140.             <option value="cev">Critical Evasion Rate</option>
  141.             <option value="mev">Magic Evasion Rate</option>
  142.             <option value="mrf">Magic Reflection Rate</option>
  143.             <option value="cnt">Counter Attack Rate</option>
  144.             <option value="hrg">Hp Regeneration</option>
  145.             <option value="mrg">Mp Regeneration</option>
  146.             <option value="trg">Tp Regeneration</option>
  147.             <option value="frame">   </option>
  148.             <option value="tgr">Target Rate</option>
  149.             <option value="grd">Guard Effect Rate</option>
  150.             <option value="rec">Recovery Effect Rate</option>
  151.             <option value="pha">Pharmacology</option>
  152.             <option value="mcr">Mp Cost Rate</option>
  153.             <option value="tcr">Tp Charge Rate</option>
  154.             <option value="pdr">Physical Damage Rate</option>
  155.             <option value="mdr">Magical Damage Rate</option>
  156.             <option value="fdr">Floor Damage Rate</option>
  157.             <option value="exr">Experience Rate</option>
  158.             <option value="frame">   </option>`;
  159.     for (var i = 0; i < ICF.Param.NParams.length; i++) {
  160.         if (ICF.Param.NParams[i]) {
  161.             options = options + '<option value="' + ICF.Param.NParams[i] + '">' + ICF.Param.NParamsFullName[i] + '</option>';
  162.         }
  163.     }
  164.     for (var i = 0; i < ICF.Param.PParams.length; i++) {
  165.         if (ICF.Param.PParams[i]) {
  166.             options = options + '<option value="' + ICF.Param.PParams[i] + '">' + ICF.Param.PParamsFullName[i] + '</option>';
  167.         }
  168.     }
  169.     for (var i = 0; i < ICF.Param.CParamsMax.length; i++) {
  170.         if (ICF.Param.CParamsMax[i]) {
  171.             options = options + '<option value="' + ICF.Param.CParamsMax[i] + '">' + ICF.Param.CParamsMaxFullName[i] + '</option>';
  172.         }
  173.     }
  174.     return options;
  175. };
  176.  
  177. DataManagerEX.updateStatDistribution = function() {
  178.     const doc = MakerManager.document;
  179.     this._distributeStat = doc.getElementById('StatSelect').value;
  180.     const data = $dataDistributeStats[this._distributeStat];
  181.     if(data) {
  182.         doc.getElementById('name').value = data.name;
  183.         doc.getElementById('description').value = data.description;
  184.         doc.getElementById('cost').value = data.cost;
  185.         doc.getElementById('gain').value = data.gain;
  186.         doc.getElementById('max').value = data.max;
  187.         doc.getElementById('min_col').value = data.min_col;
  188.         doc.getElementById('max_col').value = data.max_col;
  189.     } else if (this._distributeStat == "mtp") {
  190.         $dataDistributeStats[this._distributeStat] = {};
  191.         $dataDistributeStats[this._distributeStat].name = "Max TP";
  192.         $dataDistributeStats[this._distributeStat].description = "The maximum amount of TP for the actor.";
  193.         $dataDistributeStats[this._distributeStat].cost = 1;
  194.         $dataDistributeStats[this._distributeStat].gain = 2;
  195.         $dataDistributeStats[this._distributeStat].max = 200;
  196.         $dataDistributeStats[this._distributeStat].min_col = "#6666ff";
  197.         $dataDistributeStats[this._distributeStat].max_col = "#0000ff";
  198.         DataManagerEX.updateStatDistribution();
  199.         FileManager.saveData($dataDistributeStats, "DistributionStats.json");
  200.     } else if (ICF.Param.NParams.indexOf(this._distributeStat) > -1) {
  201.         var paramId = ICF.Param.NParams.indexOf(this._distributeStat);
  202.         $dataDistributeStats[this._distributeStat] = {};
  203.         $dataDistributeStats[this._distributeStat].name = ICF.Param.NParamsFullName[paramId];
  204.         $dataDistributeStats[this._distributeStat].description = "Actor's " + ICF.Param.NParamsFullName[paramId] + ".";
  205.         $dataDistributeStats[this._distributeStat].cost = 1;
  206.         $dataDistributeStats[this._distributeStat].gain = 1;
  207.         $dataDistributeStats[this._distributeStat].max = 100;
  208.         $dataDistributeStats[this._distributeStat].min_col = "#ff7777";
  209.         $dataDistributeStats[this._distributeStat].max_col = "#f90000";
  210.         DataManagerEX.updateStatDistribution();
  211.         FileManager.saveData($dataDistributeStats, "DistributionStats.json");
  212.     } else if (ICF.Param.PParams.indexOf(this._distributeStat) > -1) {
  213.         var paramId = ICF.Param.PParams.indexOf(this._distributeStat);
  214.         $dataDistributeStats[this._distributeStat] = {};
  215.         $dataDistributeStats[this._distributeStat].name = ICF.Param.PParamsFullName[paramId];
  216.         $dataDistributeStats[this._distributeStat].description = "Actor's " + ICF.Param.PParamsFullName[paramId] + ".";
  217.         $dataDistributeStats[this._distributeStat].cost = 1;
  218.         $dataDistributeStats[this._distributeStat].gain = 1;
  219.         $dataDistributeStats[this._distributeStat].max = 100;
  220.         $dataDistributeStats[this._distributeStat].min_col = "#aaaaaa";
  221.         $dataDistributeStats[this._distributeStat].max_col = "#ffffff";
  222.         DataManagerEX.updateStatDistribution();
  223.         FileManager.saveData($dataDistributeStats, "DistributionStats.json");
  224.     } else if (ICF.Param.CParamsMax.indexOf(this._distributeStat) > -1) {
  225.         var paramId = ICF.Param.CParamsMax.indexOf(this._distributeStat);
  226.         $dataDistributeStats[this._distributeStat] = {};
  227.         $dataDistributeStats[this._distributeStat].name = ICF.Param.CParamsMaxFullName[paramId];
  228.         $dataDistributeStats[this._distributeStat].description = "Actor's " + ICF.Param.CParamsMaxFullName[paramId] + ".";
  229.         $dataDistributeStats[this._distributeStat].cost = 1;
  230.         $dataDistributeStats[this._distributeStat].gain = 5;
  231.         $dataDistributeStats[this._distributeStat].max = 100;
  232.         $dataDistributeStats[this._distributeStat].min_col = "#bb1111";
  233.         $dataDistributeStats[this._distributeStat].max_col = "#ee1111";
  234.         DataManagerEX.updateStatDistribution();
  235.         FileManager.saveData($dataDistributeStats, "DistributionStats.json");
  236.     } else {
  237.         doc.getElementById('name').value = '';
  238.         doc.getElementById('description').value = '';
  239.         doc.getElementById('cost').value = '';
  240.         doc.getElementById('gain').value = '';
  241.         doc.getElementById('max').value = '';
  242.         doc.getElementById('min_col').value = '';
  243.         doc.getElementById('max_col').value = '';
  244.     }
  245. };
  246.  
  247. //=============================================================================
  248. // Game_BattlerBase
  249. //=============================================================================
  250.  
  251. Object.defineProperties(Game_BattlerBase.prototype, {
  252.     // Max TP
  253.     mtp: { get: function() { return this.maxTp(); }, configurable: true },
  254. });
  255.  
  256.  
  257. //=============================================================================
  258. // Game_Actor
  259. //=============================================================================
  260.  
  261. ICF.SRD_Distribution.actorNParamBase = Game_Actor.prototype.NParamBase;
  262. Game_Actor.prototype.NParamBase = function(paramId) {
  263.     if (!this._distributeNParams) this._distributeNParams = [];
  264.     return ICF.SRD_Distribution.actorNParamBase.apply(this, arguments) + (this._distributeNParams[paramId] || 0);
  265. };
  266.  
  267. ICF.SRD_Distribution.actorPParamBase = Game_Actor.prototype.PParamBase;
  268. Game_Actor.prototype.PParamBase = function(pparamId) {
  269.     if (!this._distributePParams) this._distributePParams = [];
  270.     return ICF.SRD_Distribution.actorPParamBase.apply(this, arguments) + (this._distributePParams[pparamId] || 0);
  271. };
  272.  
  273. ICF.SRD_Distribution.actorCParamBase = Game_Actor.prototype.CParamBase;
  274. Game_Actor.prototype.CParamBase = function(cparamId) {
  275.     if (!this._distributeCParams) this._distributeCParams = [];
  276.     return ICF.SRD_Distribution.actorCParamBase.apply(this, arguments) + (this._distributeCParams[cparamId] || 0);
  277. };
  278.  
  279. ICF.SRD_Distribution.maxTp = Game_Actor.prototype.maxTp;
  280. Game_Actor.prototype.maxTp = function() {
  281.     if (!this._distributeTP) this._distributeTP = 0;
  282.     return ICF.SRD_Distribution.maxTp.apply(this, arguments) + this._distributeTP;
  283. };
  284.  
  285. ICF.SRD_Distribution.clearDistributeStats = Game_Actor.prototype.clearDistributeStats;
  286. Game_Actor.prototype.clearDistributeStats = function() {
  287.     ICF.SRD_Distribution.clearDistributeStats.call(this);
  288.     this._distributeTP = 0;
  289.     this._distributeNParams = [];
  290.     this._distributePParams = [];
  291.     this._distributeCParams = [];
  292. };
  293.  
  294. ICF.SRD_Distribution.getAbnormalParam = Game_Actor.prototype.getAbnormalParam;
  295. Game_Actor.prototype.getAbnormalParam = function(param) {
  296.     if (param == "mtp") return this._distributeTP || 0;
  297.     if (ICF.Param.NParams.indexOf(param) > -1) {
  298.         var paramId = ICF.Param.NParams.indexOf(param);
  299.         if (!this._distributeNParams) this._distributeNParams = [];
  300.         return this._distributeNParams[paramId] || 0;
  301.     } else if (ICF.Param.PParams.indexOf(param) > -1) {
  302.         var paramId = ICF.Param.PParams.indexOf(param);
  303.         if (!this._distributePParams) this._distributePParams = [];
  304.         return this._distributePParams[paramId] || 0;
  305.     } else if (ICF.Param.CParamsMax.indexOf(param) > -1) {
  306.         var paramId = ICF.Param.CParamsMax.indexOf(param);
  307.         if (!this._distributeCParams) this._distributeCParams = [];
  308.         return this._distributeCParams[paramId] || 0;
  309.     }
  310.     return ICF.SRD_Distribution.getAbnormalParam.apply(this, arguments);
  311. };
  312.  
  313. ICF.SRD_Distribution.addAbnormalParam = Game_Actor.prototype.addAbnormalParam;
  314. Game_Actor.prototype.addAbnormalParam = function(param, value) {
  315.     ICF.SRD_Distribution.addAbnormalParam.apply(this, arguments);
  316.     if (param == "mtp") {
  317.         this._distributeTP = this._distributeTP || 0;
  318.         this._distributeTP += value;
  319.     } else if (ICF.Param.NParams.indexOf(param) > -1) {
  320.         var paramId = ICF.Param.NParams.indexOf(param);
  321.         if (!this._distributeNParams) this._distributeNParams = [];
  322.         this._distributeNParams[paramId] = this._distributeNParams[paramId] || 0;
  323.         this._distributeNParams[paramId] += value;
  324.     } else if (ICF.Param.PParams.indexOf(param) > -1) {
  325.         var paramId = ICF.Param.PParams.indexOf(param);
  326.         if (!this._distributePParams) this._distributePParams = [];
  327.         this._distributePParams[paramId] = this._distributePParams[paramId] || 0;
  328.         this._distributePParams[paramId] += value;
  329.     } else if (ICF.Param.CParamsMax.indexOf(param) > -1) {
  330.         var paramId = ICF.Param.CParamsMax.indexOf(param);
  331.         if (!this._distributeCParams) this._distributeCParams = [];
  332.         this._distributeCParams[paramId] = this._distributeCParams[paramId] || 0;
  333.         this._distributeCParams[paramId] += value;
  334.     }
  335. };
  336.  
  337. //=============================================================================
  338. // Window_Distribute
  339. //=============================================================================
  340.  
  341. Window_Distribute.prototype.makeCommandList = function() {
  342.     if(this._actor) {
  343.         const stats = this._actor.actor()._sd_stats || SRD.StatDistribution.stats;
  344.         stats.forEach(function(stat) {
  345.             if($dataDistributeStats[stat]) {
  346.                 this.addCommand($dataDistributeStats[stat].name, stat);
  347.             } else if (stat == "mtp") {
  348.                 $dataDistributeStats[stat] = {};
  349.                 $dataDistributeStats[stat].name = "Max TP";
  350.                 $dataDistributeStats[stat].description = "The maximum amount of TP for the actor.";
  351.                 $dataDistributeStats[stat].cost = 1;
  352.                 $dataDistributeStats[stat].gain = 2;
  353.                 $dataDistributeStats[stat].max = 200;
  354.                 $dataDistributeStats[stat].min_col = "#6666ff";
  355.                 $dataDistributeStats[stat].max_col = "#0000ff";
  356.                 FileManager.saveData($dataDistributeStats, "DistributionStats.json");
  357.                 this.addCommand($dataDistributeStats[stat].name, stat);
  358.             } else if (ICF.Param.NParams.indexOf(stat) > -1) {
  359.                 var paramId = ICF.Param.NParams.indexOf(stat);
  360.                 $dataDistributeStats[stat] = {};
  361.                 $dataDistributeStats[stat].name = ICF.Param.NParamsFullName[paramId];
  362.                 $dataDistributeStats[stat].description = "Actor's " + ICF.Param.NParamsFullName[paramId] + ".";
  363.                 $dataDistributeStats[stat].cost = 1;
  364.                 $dataDistributeStats[stat].gain = 1;
  365.                 $dataDistributeStats[stat].max = 100;
  366.                 $dataDistributeStats[stat].min_col = "#ff7777";
  367.                 $dataDistributeStats[stat].max_col = "#f90000";
  368.                 FileManager.saveData($dataDistributeStats, "DistributionStats.json");
  369.                 this.addCommand($dataDistributeStats[stat].name, stat);
  370.             } else if (ICF.Param.PParams.indexOf(stat) > -1) {
  371.                 var paramId = ICF.Param.PParams.indexOf(stat);
  372.                 $dataDistributeStats[stat] = {};
  373.                 $dataDistributeStats[stat].name = ICF.Param.PParamsFullName[paramId];
  374.                 $dataDistributeStats[stat].description = "Actor's " + ICF.Param.PParamsFullName[paramId] + ".";
  375.                 $dataDistributeStats[stat].cost = 1;
  376.                 $dataDistributeStats[stat].gain = 1;
  377.                 $dataDistributeStats[stat].max = 100;
  378.                 $dataDistributeStats[stat].min_col = "#aaaaaa";
  379.                 $dataDistributeStats[stat].max_col = "#ffffff";
  380.                 FileManager.saveData($dataDistributeStats, "DistributionStats.json");
  381.                 this.addCommand($dataDistributeStats[stat].name, stat);
  382.             } else if (ICF.Param.CParamsMax.indexOf(stat) > -1) {
  383.                 var paramId = ICF.Param.CParamsMax.indexOf(stat);
  384.                 $dataDistributeStats[stat] = {};
  385.                 $dataDistributeStats[stat].name = ICF.Param.CParamsMaxFullName[paramId];
  386.                 $dataDistributeStats[stat].description = "Actor's " + ICF.Param.CParamsMaxFullName[paramId] + ".";
  387.                 $dataDistributeStats[stat].cost = 1;
  388.                 $dataDistributeStats[stat].gain = 5;
  389.                 $dataDistributeStats[stat].max = 100;
  390.                 $dataDistributeStats[stat].min_col = "#bb1111";
  391.                 $dataDistributeStats[stat].max_col = "#ee1111";
  392.                 FileManager.saveData($dataDistributeStats, "DistributionStats.json");
  393.                 this.addCommand($dataDistributeStats[stat].name, stat);
  394.             }
  395.         }, this);
  396.     }
  397.     this.addCommand("Finish", 'finish');
  398. };
  399.  
  400. //=============================================================================
  401. // End of File
  402. //=============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement