MV Plug-In to Restrict Subclasses to Specific Classes

I need help making a YEP_Subclasses-Compatible Extension Plug-In. (And, by extension, compatible with YEP_Class_Change_Core.) Simply put, I need the extension to do two things, the first being of major importance:
  1. I need it to adjust the compatibility of certain Secondary Classes (Subclasses) so that they only are available if your Primary Class (Class) is a specific thing.
    1. There's already the <Require Class: x>, <Require Class: x, x, x>, and <Require Class: x to y> NoteTags for Items and Skills. The simplest way I can think of is to expand this to also affect Classes. I only plan on applying this for Classes that have the <Subclass Only> NoteTag, so there won't be any worries of the NoteTag getting put on a Primary Class.
      1. The best way to explain it is, as is, the system allows for 2 Primary Classes, the secondary modifying the first. This creates a weird situation where if the MC's Class is Hero and I want to unlock "Thief" as an option for if they change Class to Rogue, the problem is that they can still set their Class/Subclass to be "Hero/Thief". I can rename the combination to show as "Gentleman Thief", but it doesn't change the fact it's a behavior which, while I can circumvent and make seem like it was all according to plan, still is not wanted. What I would prefer is to have it work more like D&D or Pathfinder Subclasses where Cleric has the Subclasses of War, Forge, City, and Love while Rogue has its Subclasses of Thief, Phantom, Mastermind, and Arcane Trickster.
      2. While I could do some fun things with the default behavior, I am effectively bound to having to account for every Subclass interacting with every Primary Class whether it makes sense or not. At best, this is a lot of work I, frankly, don't want to do. At worst, this will worsen my game's quality.
  2. I need it to allow me to use a Plug-In Command to access the Class Change Screen for Party Members other than the Main Character when accessed through "OpenClass".
    1. Simply put, I plan on making Class Changes done through an Event and thanks to YEP_Party_System, the player character is locked as the first member of the party. Meaning "OpenClass" only opens it for the Player Character. I'd like it expanded so I can use "OpenClass 5" to open the Class Change menu for Party Member 5 (based on formation) or, if that's too much of a challenge to do, Actor 5.


I attempted to search the MV Master Plug-In List. The list appears to no longer work. (Specifically an issue of insecure connection... Mood. This issue exists on Chrome, Brave, Firefox, Opera GX, and Edge. None will open the page.)
I attempted to search the forums. I didn't find anything that helps.
I can, in theory, do a painstaking workaround through variables and events for this. The reason why I want a plug-in instead is mostly because a NoteTag limiting what Classes allow a Subclass to even appear for the Player to Select is way more convenient and, by extension, reduces the danger of something going horribly, game-breakingly wrong. If I were to do this via Event, I'd have to effectively make the entirety of the existing Menu's functionality in Choice commands while also storing what Classes have been unlocked in a Variable for the Choice Commands to consult. Ignoring the fact that would consume too many Variables for comfort, (unless I were to store Arrays into variables then find a way to get the Choice Commands to reference those Arrays for determining which options to show,) but it would also just look worse if I did it that way and be harder for the player to see the difference between each Subclass before choosing it. And, at present, I'm uncertain if I intend on making Subclass choices permanent for NPC party members or not. (Probably not because that could be frustrating for new players if they lock in the wrong thing. But it's an option I've been considering.)


TLDR: If you read the bolded text, that tells you all you need. I want an extension Plug-In for the Yanfly Subclass Plug-In that makes Subclasses work less like Final Fantasy and more like D&D. I also want it to allow me to use the OpenClass Plug-In Command as "OpenClass X" to open the Class Screen for Party Member X (based on formation) instead of defaulting to the party leader.

P.S. I'm also INCREDIBLY stupid. It's entirely possible that there is a way to do so natively (possibly using Lunatic Mode) that I am not seeing, am unaware of, and/or just do not know how to do. I ask that you'll be patient with me.
I just did the first part for someone a week or two ago. Give it a search, let me know if you can't find it.

Are you certain about the second one? OpenClass should open the same scene that you get to via the menu, it shouldn't have anything to do with specific actors or whether anyone's locked in the party.

You've double checked your Yanfly plugin order against the list on the Yanfly Engine Web site?
if you cannot find it, you can find it [here].
What I found was you explaining a code to automatically remove no longer valid Subclasses. I did not find you doing the first part, no. (Though, ngl, that also sounds useful.)
As for OpenClass, it opens right into whoever is in position one in the party. It does just open that same menu, but it defaults to the first person.
As for double-checking against the order, yep. Made that mistake once and while it wasn't seemingly in any way at fault for the issue I was having, it was still good to be made aware of.

Core Engine > Class Change > Subclass > Message > Item Core > Equip Core

To clarify: I have yet to implement the Party System Core. It's just on the docket to be added in. My phrasing there was poor though because I outright phrased it as already being applied. It isn't, yet.



ShadowDragon, oh, same thread. I'll try and find it in there. Thank you for linking the thread so I can see it is there I just saw the wrong comment it seems.

EDIT: I'm stupid. I read parts and not the whole. WIll read through that whole thread. Will comment later here if I need more help.
This post has how to do your original request (note there's a typo explained a few posts down, I can't edit the fix in because the thread is locked):

This post has the line to add so that the requirements are obeyed when changing classes:

As for OpenClass, it opens right into whoever is in position one in the party. It does just open that same menu, but it defaults to the first person.
Okay...so can you not just press Q/W/page up/page down like you can in every other menu screen to scroll between the actors?
This post has how to do your original request (note there's a typo explained a few posts down, I can't edit the fix in because the thread is locked):

This post has the line to add so that the requirements are obeyed when changing classes:
Currently implementing. Had to grab breakfast first.
Okay...so can you not just press Q/W/page up/page down like you can in every other menu screen to scroll between the actors?
I'm going to be 100%--I did not know that worked that way. I'm appreciative to know that now and just tested to show that works. I did not know that was a thing at all in any menu. I don't think that's something intuitive which most players would reasonably know about, but maybe I'm just coping? Either way, thank you for informing me about that.
------
EDIT TO UPDATE:
Okay, I am SO confused. I think I did everything right... but following the instructions of the thread did not work.
So, when I try to use the initial Plug-In you wrote: even before setting a Subclass it prevents me from choosing a new Primary Class. Likewise I am incapable of setting a Subclass at all.
HOWEVER, it works FINE once I remove the custom plug-in. The Script Changes that you offered to the original Subclass Plug-In give the functionality. I am very confused and don't know why it worked. To be clear: The initial Plug-In you wrote is no longer in my Plug-Ins folder at all (enabled nor disabled) and yet the function is working with just the addition of the line at 1025 and rewritten line 835. THAT works. I want to confirm if that sounds right to you because I am far too blue when it comes to JavaScript to know better.


(EDIT: Just realized one of your instructions is literally to delete that Plug-In. I swear English is my first language. I'm not sure why I'm struggling so much with it.)

But I did notice another secondary issue that I did not consider. It's not an error. Rather it's an unwanted behavior I erroneously presumed would have been covered by <Primary Only> and <Subclass Only>. When changing Class, it shows all Primary Classes that are unlocked as well as all Subclasses. When changing Subclass, it does the same.
  • Would there be a way to make it so that the Class list excludes any Class that is marked as <Subclass Only>?
  • Would there be a way to make it so that the Subclass list excludes any Class that is not marked to be a valid Subclass for the given Primary Class?
If that's too much to ask for, it's fine, no worries. What I did ask for is, technically, resolved. Thank you so much for this so far. 🙂
I'm going to be 100%--I did not know that worked that way...I don't think that's something intuitive which most players would reasonably know about, but maybe I'm just coping?
Well, I know it from reading the instructions that came with RPG Maker MV. The list of controls for how to play your own game is, as I recall, one of the first chapters.

As far as players, it's up to us as game makers to tell them how to play - I don't think anything should be considered just intuitive.

So we make manuals, tutorials, or keybinding menus.

But I did notice another secondary issue that I did not consider. It's not an error. Rather it's an unwanted behavior I erroneously presumed would have been covered by <Primary Only> and <Subclass Only>. When changing Class, it shows all Primary Classes that are unlocked as well as all Subclasses. When changing Subclass, it does the same.
Try this untested change. Go to the end of line 1089 in Class Change, hit Enter to make a new line. Paste in:
Code:
      if (SceneManager._scene._commandWindow.currentSymbol()=="class" && !$dataClasses[item].primaryAllowed || SceneManager._scene._commandWindow.currentSymbol()=="subclass" && !$dataClasses[item].subclassAllowed) continue;

That should make the list omit disallowed classes, rather than show them greyed out.
Well, I know it from reading the instructions that came with RPG Maker MV. The list of controls for how to play your own game is, as I recall, one of the first chapters.
I'm gonna be real, if I don't get a physical version of software, I have no clue how to find things. I've technically had MV for... 3 years? 4? Something like that. I only learned within this past week where the Base Resources folder is. (Let alone a manual which I didn't even know was available. I've basically learned everything for XP and MV from just doing it.) But I feel like something like that should be intuitive within the system. However, that's also just my perspective. (Worth noting, I got it through Steam not the RPGMaker site. Meaning I don't have some sort of ZIP that puts everything in front of me from day one.)
As far as players, it's up to us as game makers to tell them how to play - I don't think anything should be considered just intuitive.
Generally, I agree. But it's also one of those things where a simple display on the menu that shows

"Q/PgUp
↑
W/PgDn ↓"

being default with RMMV would have helped.
And I plan on adding that myself once I understand how to edit Screens... because basic functionality shouldn't be something obscure like that. But that's a Me project. I'll figure that out.
So we make manuals, tutorials, or keybinding menus.
Eh, as a game dev, the number one rule isn't to hide things in manuals. It's one of the things from my childhood I am glad most games stopped doing. The manuals should have critical info like hardware care (when relevant) or system reqs. I can generally agree on Tutorials and Keybind menus though, depending on how the tutorials are handled at least.
Try this untested change. Go to the end of line 1089 in Class Change, hit Enter to make a new line. Paste in:
Code:
      if (SceneManager._scene._commandWindow.currentSymbol()=="class" && !$dataClasses[item].primaryAllowed || SceneManager._scene._commandWindow.currentSymbol()=="subclass" && !$dataClasses[item].subclassAllowed) continue;

That should make the list omit disallowed classes, rather than show them greyed out.
Doing it as written (shown below):
1691769001433.png

Results in:
1691769067341.png

Spoiler: My attempt at seeing if I could figure it out, which did not work and is not your fault at all
Capitalizing "Class":
1691769132779.png


Still shows the Classes and shows them as Grey when entering the menu.:
1691769182308.png
1691769219976.png


However, when I click on Subclass:
1691769342148.png
TLDR: I get an error using the code as written. And even trying to troubleshoot what I thought might have been the issue results in an error which tells me I am probably wrong on the issue and have since undone it. (Back to the code as you wrote it, I mean.)

EDIT: Also, regarding the help you have provided so far, how should I credit you?
I'm gonna be real, if I don't get a physical version of software, I have no clue how to find things.
No offense, but...that's a little frightening. The Help menu that leads to the built-in instructions and manual is standard in basically every piece of software you use 😛

Eh, as a game dev, the number one rule isn't to hide things in manuals.
That...is really far from what I said. I listed manuals as one of three potential ways to teach players off the top of my head, a well-written document does not "hide" anything.

And it's one of the things from my childhood I wish games hadn't stopped doing. I would greatly prefer to skim a manual and establish "Okay, these movement and camera controls work like this," rather than have a three-minute tutorial in every game that I can't bypass because people can't be bothered to read instructions.

Doing it as written (shown below): Results in:
My bad. Replace all instances of "item" in the code I supplied above with "classId".

EDIT: Also, regarding the help you have provided so far, how should I credit you?
Not necessary. Put my forum name if you want to.
No offense, but...that's a little frightening. The Help menu that leads to the built-in instructions and manual is standard in basically every piece of software you use 😛
Help menu? Like I get I sound dumb, but that's because I am. I'm open about that.

That...is really far from what I said. I listed manuals as one of three potential ways to teach players off the top of my head, a well-written document does not "hide" anything.
I think I maybe spoke unclearly. But regardless, tangent. lol

And it's one of the things from my childhood I wish games hadn't stopped doing. I would greatly prefer to skim a manual and establish "Okay, these movement and camera controls work like this," rather than have a three-minute tutorial in every game that I can't bypass because people can't be bothered to read instructions.
Or, alternatively, make tutorials optional for the players who already know. It's just a QoL thing that makes replayability more replayable. But the reason they stopped doing it was, in part, if a player gets a game secondhand that doesn't have the manual--they might miss out on how to do things and get frustrated trying to figure it out. Also the presumption that the basics are already understood by most gamers. Also the presumption that if a newbie picks up a game, they have someone nearby they can ask for help from. Also, cost-cutting even if it's not much by way of savings. My complaint is more that manuals basically just don't exist anymore. I liked them because they helped provide extra background lore that wasn't necessary for the story but that players might like to know. Like how in Pokemon RGB, the player character (Red, because Green couldn't be added in Gen 1 like they wanted,) is 11, not 10 like in the anime. That's a neat detail many people didn't know until way later on because they just didn't read the manual.
My bad. Replace all instances of "item" in the code I supplied above with "classId".
if (SceneManager._scene._commandWindow.currentSymbol()=="class" && !$dataClasses[classId].primaryAllowed || SceneManager._scene._commandWindow.currentSymbol()=="subclass" && !$dataClasses[classId].subclassAllowed) continue;
1691774542164.png

Not necessary. Put my forum name if you want to.
It's only right, especially when this is at this point way more complicated than a 5 second line of code.
Help menu?
RPG Maker MV:
1691774819533.png

Firefox:
1691774863542.png

Microsoft Word:
1691774897022.png

😉

Okay, re-paste my code as this:
Code:
      if ($dataClasses[classId] && (SceneManager._scene._commandWindow.currentSymbol()=="class" && !$dataClasses[classId].primaryAllowed || SceneManager._scene._commandWindow.currentSymbol()=="subclass" && !$dataClasses[classId].subclassAllowed)) continue;
I repeat my comment about being dumb. I'm so used to hotkeys, I barely with those toolbars. lmao And even when I do, it's rarely beyond File and Edit. Oof. lol
Okay, re-paste my code as this:
Code:
      if ($dataClasses[classId] && (SceneManager._scene._commandWindow.currentSymbol()=="class" && !$dataClasses[classId].primaryAllowed || SceneManager._scene._commandWindow.currentSymbol()=="subclass" && !$dataClasses[classId].subclassAllowed)) continue;
That worked! <3 The Primary Class menu only shows the Primary Classes now and the Subclass menu only shows the Subclasses now! I'm still seeing Sorcerer Subclasses as a Rogue and vice versa, but like... That's progress. Thank you so much! <3 <3
Like how in Pokemon RGB, the player character (Red, because Green couldn't be added in Gen 1 like they wanted,)
Time for a Pokémon fun fact: Green was absolutely in Gen 1, just known as Blue in America. If you're speaking of the female player character, that would be Blue. Name got changed to Green out here, though I don't know if Leaf from FRLG is considered the same character or a different one entirely, much like how Kris and Lyra are two different characters.

This has been your Pokémon fun fact for the day.
Time for a Pokémon fun fact: Green was absolutely in Gen 1, just known as Blue in America. If you're speaking of the female player character, that would be Blue. Name got changed to Green out here, though I don't know if Leaf from FRLG is considered the same character or a different one entirely, much like how Kris and Lyra are two different characters.

This has been your Pokémon fun fact for the day.
I was using the American name since English speakers. If I was speaking to my friends over in Asia, I'd be using Blue. It's just a matter of audience.
Well, they're going through two different functions. One is just looking whether the class is tagged to be a primary/sub class at all, the other is comparing notetags to the player's current class.

It wouldn't be impossible to integrate them, but that "line" is already so long that I'd say it needs to be taken out into a separate function to do more.
I was using the American name since English speakers. If I was speaking to my friends over in Asia, I'd be using Blue. It's just a matter of audience.
I already knew that. I just went technical because it was an opportunity to do so.
Well, they're going through two different functions. One is just looking whether the class is tagged to be a primary/sub class at all, the other is comparing notetags to the player's current class.

It wouldn't be impossible to integrate them, but that "line" is already so long that I'd say it needs to be taken out into a separate function to do more.
Fair enough. I'll be honest, this is already a huge help. I'll see if I can toy around with it and get it to work out. 🙂 I do appreciate all the help you've given! <3

Original thread: https://forums.rpgmakerweb.com/threads/plug-in-to-restrict-subclasses-to-specific-classes.160205/