MV Subclass Set

So I am using Yanfly's subclass plugin and am trying to figure out something. Is there a way to put subclasses only available with certain main classes like it was for vx ace?

Plugin: http://www.yanfly.moe/wiki/Subclass_(YEP)
Try this.

Code:
var subEnabledOld = Window_ClassList.prototype.checkSubclassEnabled;
Window_ClassList.prototype.checkSubclassEnabled = function(item)
{
    let enabled = subEnabledOld.call(this, item);
    if (enabled && $dataClasses[item].meta.classRequired)
        return $dataClasses[item].meta.classRequired.includes(this._actor.currentClass.name);
};

I haven't tested this, but it should allow you to put the class notetag:
Code:
<classRequired: mage warrior thief>
and you can only choose it as a subclass if your main class matches one of those that you listed.

Copy and paste the above into a text editor, save as a *.js file, include as a plugin.
Try this.

Code:
var subEnabledOld = Window_ClassList.prototype.checkSubclassEnabled;
Window_ClassList.prototype.checkSubclassEnabled = function(item)
{
    let enabled = subEnabledOld.call(this, item);
    if (enabled && $dataClasses[item].meta.classRequired)
        return $dataClasses[item].meta.classRequired.includes(this._actor.currentClass.name);
};

I haven't tested this, but it should allow you to put the class notetag:
Code:
<classRequired: mage warrior thief>
and you can only choose it as a subclass if your main class matches one of those that you listed.

Copy and paste the above into a text editor, save as a *.js file, include as a plugin.
Well, it worked to Set the subclasses, but unfortunately made it so now my characters can't change their main class at all and can't learn skills for those classes either.
That's weird. So we'll try this. Delete that first plugin, we're going to paste its code into a specific place in the original.

So open up the Subclass plugin in a text editor. Go to line 1024, hit Enter to make a new line, and put:
Code:
if ($dataClasses[item].meta.classRequired && !$dataClasses[item].meta.classRequired.includes(this._actor.currentClass.name)) return false;

Save the file, refresh the plugin in your plugin manager, see how that goes.
That's weird. So we'll try this. Delete that first plugin, we're going to paste its code into a specific place in the original.

So open up the Subclass plugin in a text editor. Go to line 1024, hit Enter to make a new line, and put:
Code:
if ($dataClasses[item].meta.classRequired && !$dataClasses[item].meta.classRequired.includes(this._actor.currentClass.name)) return false;

Save the file, refresh the plugin in your plugin manager, see how that goes.
Ok, That fixed the main class issue, but now my main classes still get all subclasses and not just ones specified by the note tag. For example if I pick ranger for the main class, it still gives all subclasses when it should only be monk and thief.
1690478069560.png
So you're saying Paladin, Priestess and Witch all have the classRequired notetag that doesn't list Ranger?

Also, quick little error I just thought of, make sure your name list in the notetag matches the capitalization in your database. Ranger won't be the same as ranger.

Please show screenshots of the class entries in your database with their notetags.
So you're saying Paladin, Priestess and Witch all have the classRequired notetag that doesn't list Ranger?

Also, quick little error I just thought of, make sure your name list in the notetag matches the capitalization in your database. Ranger won't be the same as ranger.

Please show screenshots of the class entries in your database with their notetags.
So Ranger only has a need for Monk and Thief Subclasses.
1690478712942.png

1690478735116.png

1690478762796.png

1690478792469.png

1690478849169.png
And to confirm, your modified plugin looks like this?
1690479070939.png
And to confirm, your modified plugin looks like this?
View attachment 270973
1690479275026.png

Yep.
lol, currentClass is a method, not a property 🤣

Put parentheses after it, so it says currentClass().name
lol, currentClass is a method, not a property 🤣

Put parentheses after it, so it says currentClass().name
1690493043807.png

Should look like this, right? So when I do that, it takes away the subclass part and there is no more subclass options.
1690493209112.png
not currentClass.name() but currentClass().name

I see that the code @ATT_Turan said made that misstake which you took over, is kinda funny 😀

so it looks like this:
thiss.png
not currentClass.name() but currentClass().name

I see that the code @ATT_Turan said made that misstake which you took over, is kinda funny 😀

so it looks like this:
View attachment 271010
That fixed it. Got it working now. Thanks for the help.
This thread is being closed due to being closed. If you need it reopened, report it to let us know why. Thank you!
This thread is reopened due to an emerging issue.
That fixed it. Got it working now. Thanks for the help.
Ok. So I know we fixed that part, but now I have another issue I am running into. When I equip the character with a subclass, the subclass is still on even if I change to a main class that doesn't have that subclass. How would I go at fixing this?
Example: I equip Ranger and monk, but switch the main class to Hunter. Monk is still equipped even though it is not a Hunter subclass.
Go to line 835 and make it the following:
Code:
    if (this._subclassId === classId || this._subclassId>0 && $dataClasses[this._subclassId].meta.classRequired && !$dataClasses[this._subclassId].meta.classRequired.includes($dataClasses[classId].name)) this._subclassId = 0;

Should strip your subclass off when you change classes if it no longer meets the requirement.
Go to line 835 and make it the following:
Code:
    if (this._subclassId === classId || this._subclassId>0 && $dataClasses[this._subclassId].meta.classRequired && !$dataClasses[this._subclassId].meta.classRequired.includes($dataClasses[classId].name)) this._subclassId = 0;

Should strip your subclass off when you change classes if it no longer meets the requirement.
I edited the plugin and put that part in the line we added, but it gave this error when trying to edit the subclass:
1690546172492.png

Edit: Nevermind, didn't see the top comment of where to put it. Lol. Put it in and it works! Thanks again for the help.
This thread is being closed due to being solved. Fingers crossed this time! 🙂

Original thread: https://forums.rpgmakerweb.com/threads/subclass-set.159764/