Max Level based on Leader Level (RPG Maker MV)

Hello, guys!

I'm trying to make the max level of my characters be based on leader's current level. The problem is: I have more than 100 actors, so I can't set one variable for each actor.

I tried to find a way to set party max level by script call, but I didn't found the right command. I already tried to set it by variables too, but I had no success.

Please, someone can help me?

I use RPG Maker MV.

(Sorry my bad english)
This is manageable through scripts but would be better handled by a dedicated plugin.

Is your parties leader fixed or changeable?
This is manageable through scripts but would be better handled by a dedicated plugin.

Is your parties leader fixed or changeable?

It is fixed. I mean: at the beginning the player will choose one of the six options of "party leaders", then it will be fixed.
Open a text document (Notepad should work) and paste the code below. Save it using any name you want with the file extension .js then add the file to your game as a plugin.

Code:
_ML_Game_Actor_maxLevel = Game_Actor.prototype.maxLevel;
Game_Actor.prototype.maxLevel = function() {
    if (this !== $gameParty.leader()) return $gameParty.leader().level;
    _ML_Game_Actor_maxLevel.call(this);
};

Note: This should actually work even if the party leader changes later.
Open a text document (Notepad should work) and paste the code below. Save it using any name you want with the file extension .js then add the file to your game as a plugin.

Code:
_ML_Game_Actor_maxLevel = Game_Actor.prototype.maxLevel;
Game_Actor.prototype.maxLevel = function() {
    if (this !== $gameParty.leader()) return $gameParty.leader().level;
    _ML_Game_Actor_maxLevel.call(this);
};

Note: This should actually work even if the party leader changes later.

Thank you!

But, it is having issues with other plugins =/

kB87gSN
Can you post an image of the console when this is happening?

To open the console press F8 while playtesting, this should open a new window, from here click the "console" tab.

EDIT: I presume this is happening because you're starting the game with no actors in the party. You can try adding an actor to the party and then when they choose which leader they want add the new one then remove the original one. Alternatively you can paste this over the original code I gave you:

Code:
Game_Actor.prototype.maxLevel = function() {
    if (!$gameParty.leader()) return this.actor().maxLevel;
    if (this !== $gameParty.leader()) return $gameParty.leader().level;
    return this.actor().maxLevel;
};

This should solve the issue as well, however, it removes the alias so it's position in the plugin manager might be more sensitive. Try it at the bottom first, if that doesn't work try it at the top.
Sure!

I tried to post on my last reply, but I think it didn't work...

Try this link:
The image loaded fine the first time, but it's not the console, it's just the playtest window.

I posted an edit to my previous post, if you read that first then if it doesn't help press F8 while you're on the black screen with yellow writing and a new window should open, I need the "Console" section from that new window.
Oooh, okay! I tried, but nothing happened at first time. Now I got that:
This is even with the updated code?
Yes... =/

I also added one actor to the party before start the game, but now this error occurs:

Strange. No errors from the script I gave you. If you disable the plugin you've added with my script does this still happen? If it does, try disabling all your plugins as well and let me know what happens.
I disabled the listed plugins and run the game, but that happens when I choose "Start":

Looks like there are still plugins enabled, double check they are all disabled and try again, please.
I created a new game without any plugins and it works perfectly!!! Thank you so much! :LZSjoy:

But... How can I make this work with my plugins too? I really need them ;_;
Honestly, it should be working with most, if not all, of the plugins that have been showing errors in your original game. I think the real problem lies in the rpg_objects.js file of your original game, but I can't be certain without it running with no plugins.

Just for your reference this is my plugin list, with that script added and I get no errors:

Spoiler
upload_2019-3-21_0-23-21.png

upload_2019-3-21_0-23-59.png

img.png


Note: The ones that are disabled aren't necessarily because they don't work with this script, I've just changed my mind about using them.
@Silva Maybe some of the issues were from starting with a saved game instead of starting a new game, in case that function is used in initialization.

One of the error messages "unexpected token u" means that it was trying to JSON.parse(undefined)

But hard to say after the fact whether that was actually the case or not
@Aloe Guvner That's useful to know. I only really playtest from old saves if I'm testing a save/load related method so hadn't considered that.
@Silva Maybe some of the issues were from starting with a saved game instead of starting a new game, in case that function is used in initialization.

One of the error messages "unexpected token u" means that it was trying to JSON.parse(undefined)

But hard to say after the fact whether that was actually the case or not


Yeeeeeeeeeeees!!! It worked!!! I deleted my saved games and removed the initial actor then it worked perfectly!

Thank you, guys for helping me! ☺️👍

Original thread: https://forums.rpgmakerweb.com/threads/max-level-based-on-leader-level-rpg-maker-mv.107039/