Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // Maliki's Class Max Levels
- // Mal_classMaxLevel.js
- // version 1.3
- //=============================================================================
- /*:
- * @plugindesc This plugin gives users the ability to set an Actor's Max Level via thier current class.
- * @author Maliki79
- *
- * @param generalMaxLevel
- * @desc This will be the maximum level each class is initially set to. You can set it to a number higher then 99, but make sure you have a plugin
- * that can handle those levels, as the game will crash without one. Obviously, this cannot be less than 1.
- * @type number
- * @min 1
- * Default: 99
- * @default 99
- *
- * @param storeExp
- * @desc If this is set to 1, once an actor reaches Max Level, excess exp will be stored and will be applied once the level is extended.
- * This is the engine's default behavior. If the level is then raised and the surplus experience pushes past the raised level, the actor will instantly level up.
- * If 0, all experience points gained after reaching the actor's current max level will be lost.
- * Default: 0
- * @type number
- * @min 0
- * @max 1
- * @default 0
- *
- * @help Version 1.3
- * In order to use this plugin, simply add the following tag to class notes:
- * <maxLevel:x>
- * with X being the whole number.
- * This will limit the max level of the actor to that number.
- * Changing classes will also change the Max Level settings.
- * Once at Max Level, the actor will no longer gain exp if the plugin param storeExp is set to 0.
- * (The lowest of the current class' Max and the default max set here will be reflected at the start of a game.)
- *
- * CHANGING MAX Level
- * Max levels can be changed in two main ways.
- * Using the script call
- *
- * actor.changeMaxLevel(classId, amount);
- *
- * where actor is the specific actor you wish to change, classId is the class Id as found in the database, and amount is the amount of levels to raise or lower the Max Level to.
- * If you set the classId to -1, it will affect ALL classes of the current Actor.
- * If classId is set to -2, it will only affect the currect class, regardless of it's ID.
- * (The immidiate intended use I had was to use this with items from the inventory and making the actor b.)
- * Max levels can be reduced but cannot go below 1.
- * Remember also that the storeExp param, if set to 0 will remove all XP gained if the amount is beyond the current Max Level.
- *
- * $gameActors.changeMaxLevelAll(classId, amount);
- *
- * Using this call will change ALL Actor Levels regardless of them being in the party.
- * This can be used for inital setting or resetting of class Max Levels.
- * Note that initiallizing an Actor when adding them will apply all default Max Level values.
- */
- var Mal = Mal || {};
- Mal.ClassMxLvlParameters = PluginManager.parameters('Mal_classMaxLevel');
- Mal.classDefaultMaxLevel = Number(Mal.ClassMxLvlParameters['generalMaxLevel']);
- Mal.classStoreExp = Number(Mal.ClassMxLvlParameters['storeExp']);
- //begin database setup
- var MalCMLDatabaseLoad = DataManager.isDatabaseLoaded;
- DataManager.isDatabaseLoaded = function() {
- if (!MalCMLDatabaseLoad.call(this)) return false;
- if (!DataManager._MalCML_DatabaseLoaded) {
- this.processCMLNotetags($dataClasses);
- this.processCMLNotetags2($dataActors);
- DataManager._MalCML_DatabaseLoaded = true;
- }
- return true;
- };
- DataManager.processCMLNotetags = function (object) {
- for (var n = 1; n < object.length; n++) {
- var obj = object[n];
- obj.baseMaxLevel = obj.meta.maxLevel ? Number(obj.meta.maxLevel) : 99;
- obj.baseMaxLevel = Math.min(obj.baseMaxLevel, Mal.classDefaultMaxLevel, 99);
- };
- };
- DataManager.processCMLNotetags2 = function (object) {
- var size = $dataClasses.length;
- for (var n = 1; n < object.length; n++) {
- var obj = object[n];
- obj._classMaxLevel = new Array(size).fill(Mal.classDefaultMaxLevel);
- for (var i = 1; i < obj._classMaxLevel.length; i++) {
- obj._classMaxLevel[i] = $dataClasses[i].baseMaxLevel;
- };
- };
- };
- //end database setup
- var malCML_GA_Setup = Game_Actor.prototype.setup;
- Game_Actor.prototype.setup = function(actorId) {
- malCML_GA_Setup.call(this, actorId);
- this._classMaxLevel = $dataActors[actorId]._classMaxLevel;
- };
- Game_Actor.prototype.maxLevel = function() {
- var id = this.currentClass().id;
- return this._classMaxLevel[id];
- //return this.actor().maxLevel;
- };
- Game_Actor.prototype.classLevel = function(classId) {
- if (Yanfly.Param.CCCMaintainLv) return this.level;
- if (this._exp[classId] === undefined) this._exp[classId] = 0;
- var level = 1;
- for (;;) {
- if (level >= this.maxLevel()) break;
- if (this.expForCLevel(classId, level + 1) > this._exp[classId]) break;
- level++;
- }
- return level;
- };
- Game_Actor.prototype.expForCLevel = function(classID, level) {
- var c = $dataClasses[classID];
- var basis = c.expParams[0];
- var extra = c.expParams[1];
- var acc_a = c.expParams[2];
- var acc_b = c.expParams[3];
- return Math.round(basis*(Math.pow(level-1, 0.9+acc_a/250))*level*
- (level+1)/(6+Math.pow(level,2)/50/acc_b)+(level-1)*extra);
- };
- Game_Actor.prototype.changeMaxLevel = function(classId, amount) {
- var id = Number(classId) || 0;
- if (id == 0) return;
- if (id < -2) return;
- if (id == -2) id = this.currentClass().id;
- var amount = amount;
- if (id == -1) {
- for (var n = 1; n < this._classMaxLevel.length; n++) {
- this._classMaxLevel[n] += amount;
- if (this._classMaxLevel[n] < 1) this._classMaxLevel[n] = 1;
- }
- } else {
- this._classMaxLevel[id] += amount;
- if (this._classMaxLevel[id] < 1) this._classMaxLevel[n] = 1;
- }
- this.changeExp(this.currentExp(), this.shouldDisplayLevelUp());
- this.refresh();
- if(this._level > this.maxLevel()) this.changeLevel(this.maxLevel(), false);
- if(this._level >= this.maxLevel() && this.nextLevelExp() < this.currentExp() && Mal.classStoreExp == 0) this.changeExp(this.expForLevel(this.maxLevel()), false);
- this.refresh();
- };
- Game_Actors.prototype.changeMaxLevelAll = function(classId, amount) {
- for (var n = 1; n < this._data.length; n++) {
- this.actor(n).changeMaxLevel(classId, amount);
- };
- };
- var malCML_GAChangeLevel = Game_Actor.prototype.changeLevel
- Game_Actor.prototype.changeLevel = function(level, show) {
- malCML_GAChangeLevel.call(this, level, show);
- console.log(this);
- if (this._level == this.maxLevel() && Mal.classStoreExp == 0) this.changeExp(this.expForLevel(this.maxLevel()), false);
- };
- var malCML_GAChangeXP = Game_Actor.prototype.changeExp
- Game_Actor.prototype.changeExp = function(exp, show) {
- malCML_GAChangeXP.call(this, exp, show);
- console.log(this.isMaxLevel());
- console.log(this.currentExp());
- console.log(this.nextLevelExp());
- if(this.isMaxLevel() && this.currentExp() >= this.nextLevelExp() && Mal.classStoreExp == 0) this._exp[this._classId] = this.expForLevel(this.maxLevel());
- this.refresh();
- console.log(this);
- };
Advertisement
Comments
-
- my classId is Rockie and maxLevel is 15 can you do that for me?
- it doesn't work for me!
Add Comment
Please, Sign In to add comment