Advertisement
Maliki79

Mal_classMaxLevel

Oct 23rd, 2016 (edited)
2,077
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Maliki's Class Max Levels
  3. // Mal_classMaxLevel.js
  4. // version 1.2
  5. //=============================================================================
  6. /*:  
  7. * @plugindesc This plugin gives users the ability to set an Actor's Max Level via thier current class.
  8.  * @author Maliki79
  9.  *
  10.  * @help Version 1.2
  11.  * In order to use this plugin, simply add the following tag to class notes:
  12.  * <maxLevel:x>
  13.  * with X being the whole number.
  14.  * (can also be any formula that returns a number higher than 1 allowing devs
  15.  * to potentially make class max levels editable in-game.)
  16.  * This will limit the max level of the actor to that number.
  17.  * Changing classes will also change the Max Level settings.
  18.  * Once at Max Level, the actor will no longer gain exp.
  19.  */
  20.  
  21.  Game_Actor.prototype.maxLevel = function() {
  22.     if (this.currentClass().meta.maxLevel) {
  23.         var cMaxLevel = Number(eval(this.currentClass().meta.maxLevel)) || 100;
  24.     return Math.min(cMaxLevel, this.actor().maxLevel);
  25.     };
  26.     return this.actor().maxLevel;
  27. };
  28.  
  29. Game_Actor.prototype.classLevel = function(classId) {
  30.     if (Yanfly.Param.CCCMaintainLv) return this.level;
  31.     if (this._exp[classId] === undefined) this._exp[classId] = 0;
  32.     var level = 1;
  33.     for (;;) {
  34.       if (level >= this.maxLevel()) break;
  35.       if (this.expForCLevel(classId, level + 1) > this._exp[classId]) break;
  36.       level++;
  37.     }
  38.     return level;
  39. };
  40. Game_Actor.prototype.expForCLevel = function(classID, level) {
  41.  
  42.     var c = $dataClasses[classID];
  43.     var basis = c.expParams[0];
  44.     var extra = c.expParams[1];
  45.     var acc_a = c.expParams[2];
  46.     var acc_b = c.expParams[3];
  47.     return Math.round(basis*(Math.pow(level-1, 0.9+acc_a/250))*level*
  48.             (level+1)/(6+Math.pow(level,2)/50/acc_b)+(level-1)*extra);
  49. };
  50.  
  51. var malFinalExpRate = Game_Actor.prototype.finalExpRate
  52. Game_Actor.prototype.finalExpRate = function() {
  53.     if (this.level == this.maxLevel()) return 0;
  54.     return malFinalExpRate.call(this);
  55. };
Advertisement
Comments
  • KeagoTV
    113 days
    # text 0.09 KB | 0 0
    1. my classId is Rockie and maxLevel is 15 can you do that for me?
    2. it doesn't work for me!
Add Comment
Please, Sign In to add comment
Advertisement