YEP Class Change, unlocking via skills (job points).

So what I'm trying to do is to do is have classes be unlocked via skills granted by job points and level. I'd like a class to only be available once you are a certain level and have unlocked certain skills. So here is my example:

There are 2 classes, classA and classB.
To unlock classA you must unlock:
skillA
SkillB
SkillC
To unlock classB you must unlock:
skillD
skillE
skillF

Now, say you unlock classA, you should still be able to unlock skillD-F, but you can no longer unlock classB.

I've been wracking my brain over how to do this, and can't come up with anything > <
Do you guys have any ideas?
KawaiiKid,

From a programing point of view, this is quite doable as complicated if/else conditions.

However, I think first, the question to ask is why do you want to do this in-game?
  • If it is hard to understand as a programming (i.e.: "complicated if/else conditions") -- then it will be hard for the user of the game to understand.
Consider the following approach instead:
  • The user can unlock Class A & class B (based on the skills you specified) without an limits on unlock one class stops unlock another class.
  • However, the user can only switch to one of the two classes. Once they have switch to class A they can no longer switch to class B.
  • I believe this will be a lot easier for the user to understand when playing the game.
  • In fact, they might want to save the game, play as class A -- and then during a replay, play class B.
  • Letting them see they unlocked both classes will be easier for the user to understand & then also understand what they can do during a replay.
Sincerely,

Joy Diamond.
​
I'll give an example of something in game so that it might help make sense of this. In my game, your stats don't change as you level, instead you assign Job Points to change stats. For example, I have an unlockable skill called "Champion's Might I". When you choose this, it will give you +10 strength permanently. Another is "Champion's Resolve I". This will give you +10 health permanently, and so on. Each of these can only be unlocked once, and when you do you will unlock the next tier, such as "Champion's Might II".

Now what I'm trying to do, is have a skill in the same area that will be another class, such in this case, you can have "Paladin". To unlock this class you need to unlock "Champion's Might I" and "Champion's Resolve II". Once you have these, you can choose "Class: Paladin" under the same menu, and it will change your class into a Paladin. At the same time, there will also be other classes in there as well, such as "Dark Knight". This class needs different skills to be able to be chosen and change you to this class in the same way that Paladin was. However, I would like it so that when you change into one class, the other is unable to be chosen. I think this is the easy part, the part I'm having trouble with is making a skill that requires you to have other skills learned, that when used from the menu will change you into a new class.

I'm sorry if this didn't make sense or was run on, I'm just trying to clarify what I'm having trouble with her.

Thanks!

Btw, here is the plugin used in case anyone needs to look at it:
http://yanfly.moe/2015/11/27/yep-32-class-change-core/
KawaiiKid,

Thanks for your explanation it clarified to me what you want to do.

My confusion was over the word "Unlock":
  • Which I take to mean "Meet the Requirements for that Class".
  • I think you are using it to mean "Be able to change to that class".
  • (On further reading the plugin you mentioned below, I see the verb "Unlock" which confused me comes from that plugin)
Following the link to http://yanfly.moe/2015/11/27/yep-32-class-change-core/ that you posted, I think what you are asking is the following:
  • How do I use the tags in that plugin to implement it so that I can unlock a class based on multiple skills?
  • I.E.: There is a tag in that plugin like <Level Unlock Requirements>, but it only works on level requirements not on skill?
If that is the question you are asking, then I believe the answer is:
  • The tags do not support what you want in that plug-in;
However, there are commands you can call to implement this yourself.
  • Then you look at line 263-264 it reads:
* UnlockClass 5 6
* - This allows Actor 5 to unlock Class 6.​
  • So this documents a JavaScript function can call to unlock a class.
  • If you then read lines 855-866 it reads:
//=============================================================================
// Game_Interpreter
//=============================================================================

Yanfly.CCC.Game_Interpreter_pluginCommand =
Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
Yanfly.CCC.Game_Interpreter_pluginCommand.call(this, command, args)
if (command === 'OpenClass') {
this.gotoSceneClass();
} else if (command === 'ShowClass') {
$gameSystem._showClass = true;
} else if (command === 'HideClass') {
$gameSystem._showClass = false;
} else if (command === 'EnableClass') {
$gameSystem._enableClass = true;
} else if (command === 'DisableClass') {
$gameSystem._enableClass = false;
} else if (command === 'UnlockClass') {
this.unlockClass(args);

} else if (command === 'RemoveClass') {
this.removeClass(args);
} else if (command === 'UnlockClassAll') {
this.unlockClassAll(args);
} else if (command === 'RemoveClassAll') {
this.removeClassAll(args);
} else if (command === 'EnablePrimaryClassChange') {
this.setPrimaryClassChange(args, true);
} else if (command === 'DisablePrimaryClassChange') {
this.setPrimaryClassChange(args, false);
}
};​
  • I've highlighted in Orange the relevant parts, so you know know you are interested in a Game_Interpreter method call 'unlockClass'.
  • Now then, if you search for unlockClass (and we need to find the one that is part of the Game_Interpreter [psuedo] class.
  • NOTE: Since I use FireFox, I use <CTRL-F> to search. You will have to use whatever is appropriate for the browser you use to search.
  • We now search for the proper unlockClass-- we find one at lines 618-624:
Game_Actor.prototype.unlockClass = function(classId) {
if (this._unlockedClasses === undefined) this.initClasses();
if (this._unlockedClasses.contains(classId)) return;
this._unlockedClasses.push(classId);
this._unlockedClasses.sort(function(a, b) { return a - b });
this.refresh();
};​
  • BUT: we found the *wrong* unlockClass, as this one is part of the Game_Actor [pseudo] class.
  • This is why it was important above to figure out that we wanted the unlockClass method of Game_Interpreter.
  • So we *know* we are going to ignore this method as its part of the Game_Actor [psuedo] class. (i.e.: not the one we wanted)
  • Searching some more (again) for unlockClass we find at lines 840-845 the following:
Game_Party.prototype.unlockClass = function(classId) {
if (this._unlockedClasses === undefined) this.initClasses();
if (this._unlockedClasses.contains(classId)) return;
this._unlockedClasses.push(classId);
this._unlockedClasses.sort(function(a, b) { return a - b });
};​
  • Again, Game_Party is the wrong [psuedo] class. We are looking for Game_Interpreter. So we ignore this one also.
  • Searching yet again, at lines 895-902 we find the proper code:
Game_Interpreter.prototype.unlockClass = function(args) {
var actorId = parseInt(args[0]);
var actor = $gameActors.actor(actorId);
if (!actor) return;
var classId = parseInt(args[1]);
if (!$dataClasses[classId]) return;
actor.unlockClass(classId);
};​
  • At this point it becomes a lot more understandable. This function clearly takes two integers
  • the first one (named args[0]) is obviously the actor.
  • The second one (named args[1]) is obviously the class.
  • So now it is quite clear we need to call UnlockClass to the Game_Interpreter & pass it two integers 🙂
  • Going back, again, to the original documentation we found at lines 263-264:

    * UnlockClass 5 6
    * - This allows Actor 5 to unlock Class 6.​
  • Which gives us the verification that the documentation & the code implementation match 🙂
Hopefully that rather long explanation (and how to avoid errors in finding the wrong functions) will help you understand how to search plugins in the future.

Ok, so now your next step is to call this UnlockClass with the actor & the class you want to unlock from within your script.

What you can do is the following:
  • You can implement the testing of that the actor has the proper skills yourself within the IF/ELSE inside the of RPG Maker MV, and once you have verified them then you can call the command UnlockClass & pass it the actor & skill you want to unlock
  • I havn't done this part myself yet, as I am new to RPG Maker MV - and I'm hoping you know how to do this part
  • If you havn't done this either; then sometime today or tomorrow I can go download that plugin & play with it myself & explain how to call the UnlockClass function from within your script.
  • OR: Hopefully someone else in the community can build on my explanation & explain the next steps.
Sincerely,

Joy Diamond.

Edit History:

Original thread: https://forums.rpgmakerweb.com/threads/yep-class-change-unlocking-via-skills-job-points.87262/