Maliki79

MalExpControl

May 29th, 2021 (edited)
1,491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Maliki's Experience Control MZ
  3. // MalExpControl.js
  4. // version 1.0a
  5. //=============================================================================
  6. /*:  
  7. * @plugindesc ver1.0a - Allows Devs to set specific experience point totals needed for Actors to level up.  
  8.  * @author Maliki79
  9.  *
  10.  * @help To use this plugin, you must first set a set of experience point totals.
  11.  * You must use the notetag <expset: x,y,z>
  12.  * The first number is not used.
  13.  * The second is used to set starting exp points.
  14.  * Each following number will set the TOTAL amount of points needed to reach that level.
  15.  * For example, tag <expset: 0,100,205,210> will set the starting exp point at
  16.  * 100, the next nevel will require 105 points to level up and the next level
  17.  * afterwards will need only 5 points.
  18.  * (If you set a point value that is smaller than the previous number, the game
  19.  * will skip that level and the player will level up multiple times.)
  20.  *
  21.  * 1: (Optional) You do not need to set numbers to level 99.  If you do not,
  22.  *    the functional max level for that class will be whatever number you set.
  23.  *    So for the example above, the player using that class will only be able
  24.  *    to reach level 3 max. (This plugin does not allow levels to go beyond 99
  25.  *    due to the database setup of params.)
  26.  * 2: (Optional) You can add point values to classes to increase the max level.  
  27.  *    Using the script call
  28.  *    DataManager.expandExpSet(class, points needed to lvl up);
  29.  *    For example, the call DataManager.expandExpSet($gameParty.members()[0].currentClass(), 200);
  30.  *    Will add 200 to the noted actor's class.  If added to the class tagged above,
  31.  *    it would add a 410 to the end.
  32.  * 3: (Optional) You can also redo the entire point set.  Using script call
  33.  *    DataManager.resetCustomExp(class, [array of values]);
  34.  *    This will NOT reset the amount of point the actor has.
  35.  *
  36.  * Note that if you do not use a exp set for a class, it will utilize the default
  37.  * numbers.
  38. */
  39.  
  40. var MalExpContDatabaseLoad = DataManager.isDatabaseLoaded;
  41. DataManager.isDatabaseLoaded = function() {
  42.   if (!MalExpContDatabaseLoad.call(this)) return false;
  43.   if (!DataManager._malExCont_DatabaseLoaded) {
  44.     this.processExpCNotetags($dataClasses);
  45.     DataManager._malExCont_DatabaseLoaded = true;
  46.   }
  47.   return true;
  48. };
  49.  
  50. DataManager.processExpCNotetags = function(group) {
  51.     for (var n = 1; n < group.length; n++) {
  52.         var obj = group[n];
  53.         this.createCustomExp(obj);
  54.     }
  55. };
  56.  
  57. DataManager.createCustomExp = function(obj) {
  58.  
  59. var expset = [];
  60. obj.expSet = [];
  61. var noteread = obj.note;
  62. while(noteread.indexOf("expset") > -1)
  63. {
  64.     var notereg = noteread.split("<expset: ");
  65.     var match = notereg[1].split(">");
  66.     var match2 = match[0];
  67.     expset = match2.split(",");
  68.     noteread = noteread.replace("<expset: ", " ");
  69.     for (var x = 0; x < expset.length; x++) obj.expSet.push(Number(expset[x]));
  70. }
  71. };
  72.  
  73. var MalExpControlSetupNewGame = DataManager.setupNewGame;
  74. DataManager.setupNewGame = function() {
  75.     MalExpControlSetupNewGame.call(this);
  76.     this.processExpCNotetags($dataClasses);
  77.     $gameSystem.setExpData();
  78. };
  79.  
  80. DataManager.expandExpSet = function(chosenClass, value) {
  81.     var c = chosenClass;
  82.     c.expSet.push(c.expSet[c.expSet.length-1] + Number(value));
  83.     $gameSystem.setExpData();
  84. };
  85.  
  86. DataManager.resetCustomExp = function(dClass, values) {
  87.     var expset = values;
  88.     dClass.expSet = [];
  89.     for (var x = 0; x < expset.length; x++) dClass.expSet.push(Number(expset[x]));
  90.     $gameSystem.setExpData();
  91. };
  92.  
  93. var malExpControlExtractsvCont = DataManager.extractSaveContents;
  94. DataManager.extractSaveContents = function(contents) {
  95.     malExpControlExtractsvCont.call(this, contents);
  96.     this.loadExpSets();
  97. };
  98.  
  99. DataManager.loadExpSets = function() {
  100.     for(var x = 1; x < $dataClasses.length; x++){
  101.     $dataClasses[x].expSet = $gameSystem.expData[x];
  102.     }
  103. };
  104.  
  105. Game_System.prototype.setExpData = function() {
  106. this.expData = [];
  107. for(var x = 1; x < $dataClasses.length; x++){
  108.     this.expData[x] = $dataClasses[x].expSet;
  109. }
  110. };
  111.  
  112. Game_Actor.prototype.expForLevel = function(level) {
  113.     const c = this.currentClass();
  114.     if (c.expSet.length != 0) {
  115.     var expset = c.expSet;
  116.     return expset[level];
  117.     }
  118.     const basis = c.expParams[0];
  119.     const extra = c.expParams[1];
  120.     const acc_a = c.expParams[2];
  121.     const acc_b = c.expParams[3];
  122.     return Math.round(
  123.         (basis * Math.pow(level - 1, 0.9 + acc_a / 250) * level * (level + 1)) /
  124.             (6 + Math.pow(level, 2) / 50 / acc_b) +
  125.             (level - 1) * extra
  126.     );
  127. };
  128.  
  129. Window_Status.prototype.expNextValue = function() {
  130.     if (this._actor.isMaxLevel() || isNaN(this._actor.nextRequiredExp())) {
  131.         return "-------";
  132.     } else {
  133.         return this._actor.nextRequiredExp();
  134.     }
  135. };
Add Comment
Please, Sign In to add comment