Need a plugin that allows for changing Max Level in-game

Animebryan

Need more resources!
Veteran
Joined
Jul 31, 2012
Messages
444
Reaction score
226
First Language
English
Primarily Uses
RMMZ
What I need is a plugin that allows for changing a character's Max Level within the game. Like for example, a character's default max level is set to 30, but can either complete a quest or use an item on that character (both could utilize a Plugin/Script Call) that would increase their max level by a specified amount. In some games this is referred to as 'Ascension'.

However, I am using Yanfly's Core Engine (http://yanfly.moe/2015/10/09/yep-1-core-engine/) & it already has a parameter to control the max level so I would need this plugin to override the Core Engine's control of that function, if possible.
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
Easy workaround:

Create a duplicate class for the character
On notes (for the class) change the max level
* <Max Level: x>
* Changes the actor's max level to x. This allows you to bypass the editor's
* level 99 limit.

Just change Class for the hero (since it is a duplicate with just different "notes" it will be user unnoticable.


Edit:
@Animebryan does that solve your case or do you still need something more complex?
If so please provide us more information describing what your needs are. :)
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,091
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
@Dreadshadow unfortunately I think that notetag is only for Actors. :kaoswt:

Should be fairly easy to work around, but I'm going to get some lunch right now, be back in a bit~
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
Ok then, we create a duplicate actor, but if you can make an override please do! :D
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,091
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
[Edit: actually I re-read your request and now realise you want something more in-depth... :kaodes: Lookin' into it! See follow-up post below!]

Try saving this as a .js file and importing it as a plugin~
Code:
(function() {

'use strict';

  // Check for <Max Level: x> notetag on current class (case-sensitive!)
  let _Game_Actor_maxLevel = Game_Actor.prototype.maxLevel;
  Game_Actor.prototype.maxLevel = function() {
    return parseInt(this.currentClass().meta['Max Level']) || _Game_Actor_maxLevel.call(this);
  };

  // Clamp level to max after changing class
  let _Game_Actor_changeClass = Game_Actor.prototype.changeClass;
  Game_Actor.prototype.changeClass = function(classId, keepExp) {
    _Game_Actor_changeClass.call(this, classId, keepExp);
    this._level = this.level.clamp(0, this.maxLevel());
    this.refresh();
  };

})();
Basically, this will just let the game recognise <Max Level: x> notetags on classes. Then you can use the class change approach @Dreadshadow suggested. :kaothx:

(Note that the way I've implemented it means the class notetags are case-sensitive, i.e. it has to be <Max Level: 30>, not <Max level: 30> or something. :kaoswt:)
 
Last edited:

Animebryan

Need more resources!
Veteran
Joined
Jul 31, 2012
Messages
444
Reaction score
226
First Language
English
Primarily Uses
RMMZ
So would this be an add-on to Yanfly's Core Engine? Do I just place it underneath that plugin?
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,091
Reaction score
1,508
First Language
EN
Primarily Uses
RMMZ
So would this be an add-on to Yanfly's Core Engine? Do I just place it underneath that plugin?
Yes, load it after Yanfly's Core Engine. :)

Edit: currently trying to find a nice way to implement +/- max level stuff... It looks like it may be better to use several classes at fixed intervals. ._.

Edit2 @Animebryan: OK I think I have something, try the attached plugin (full code in spoiler below). It lets you put <Max Level Add: x> tags on states; the notetag values are included in the maxLevel calculation. It also includes the class notetag thing in case you wanted that in there too. As before, just load it after Core Engine and it should be OK~ :kaophew:
Code:
// ==================================================
// Cae_MaxLevelAdjust.js
// ==================================================

/*:
 * @plugindesc v1.0 - Adjust max actor level via notetags.
 * @author Caethyril
 *
 * @help Plugin Commands:
 *    None.
 *
 * Class notetag:
 *   <Max Level: x>
 *     - sets max level to x
 *     - overrides actor's original max level
 *
 * State notetag:
 *   <Max Level Add: x>
 *     - adds x to base max level (x can be negative)
 *     - multiple notetags add their values
 */

var Imported = Imported || {};			// Import namespace
Imported.Cae_MaxLevelAdjust = 1.0;		// Import declaration

var CAE = CAE || {};				// Author namespace
CAE.MaxLevelAdjust = CAE.MaxLevelAdjust || {};	// Plugin namespace

(function(_) {

'use strict';

	const TAG_ML    = 'Max Level';
	const TAG_MLADD = 'Max Level Add';

	// Notetag value getters
	_.getTag   = function(o, p) { let r = o.meta[p]; return isNaN(r) ? 0 : parseInt(r); };
	_.getTagML    = function(o) { return _.getTag(o, TAG_ML);    };
	_.getTagMLAdd = function(o) { return _.getTag(o, TAG_MLADD); };

	// For base max level (class tag or default)
	_.getMaxLevel = function(actor) {
		return _.getTagML(actor.currentClass()) || _.Game_Actor_maxLevel.call(actor);
	};

	// Returns sum of contributions from relevant state notetags
	_.getMaxLevelAdd = function(actor) {
		let s = actor.states();
		let v = 0;
		s.forEach(function(o) { v += _.getTagMLAdd(o) });
		return v;
	};

	// Refreshes input actor's level if appropriate
	_.refresh = function(actor) {
		let newML = actor.level.clamp(0, actor.maxLevel());
		if (actor._level !== newML) {
			actor._level = newML;
			actor.refresh();
		}
	};

	// Change of calculations! (The alias is called via getMaxLevel.)
	_.Game_Actor_maxLevel = Game_Actor.prototype.maxLevel;
	Game_Actor.prototype.maxLevel = function() {
		return _.getMaxLevel(this) + _.getMaxLevelAdd(this);
	};

	// Check/impose max level when changing class
	_.Game_Actor_changeClass = Game_Actor.prototype.changeClass;
	Game_Actor.prototype.changeClass = function(classId, keepExp) {
		_.Game_Actor_changeClass.call(this, classId, keepExp);
		_.refresh(this);
	};

	// Check/impose max level when adding states
	_.Game_Actor_addNewState = Game_Actor.prototype.addNewState;
	Game_Actor.prototype.addNewState = function(stateId) {
		_.Game_Actor_addNewState.call(this, stateId);
		_.refresh(this);
	};

})(CAE.MaxLevelAdjust);
Edit3: Never mind, BlackGoldSaw posted a much better alternative below (I really should have looked harder for existing plugins...).
 

Attachments

Last edited:

BlackGoldSaw

Veteran
Veteran
Joined
Oct 10, 2017
Messages
61
Reaction score
32
First Language
English
Primarily Uses
RMMV
If you still need it, Mr.Trivel has a plugin that does exactly what you need. (I use it myself.)

Max Level Restrictions

Link
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,083
Members
137,583
Latest member
write2dgray
Top