Class Change: Check if (sub)class is already unlocked

Hi guys, I hope you are all enjoying your summer.

I am using Yanflys Class Change Core to have my lead actor have multiple classes to choosefrom. Every class has its own level.

If I set the variable to Script: $gameParty.leader().level, I get the level of the class which is currently activated.

However, is there a way to save the current level of an inactive class of the same actor into a variable?
Oh, nevermind. It seems it was $gameParty.leader().classLevel(id).
You can use
Code:
$gameActors.actor(ID).classLevel(CLASS_ID)

EDIT: Oh, you figured it out yourself already.
Thank you anyways!

Now I'm stuck with another thing: I would like to check with a "Conditional Branch" Event whether actor 1 has already unlocked subclass x.
How can I do that?
Try
PHP:
$gameActors.actor(ID)._unlockedClasses.contains(CLASS_ID)
Thank you so much!

And one final issue:
How can I use a script to change a certain subclasses' level?
@jjleroy
To get the name you have to use $dataClasses.
So to get the name of class 16, you do
Code:
$dataClasses[16].name
@jjleroy
To get the name you have to use $dataClasses.
So to get the name of class 16, you do
Code:
$dataClasses[16].name

Thank you so much.
Is there also a way to show the class' icon in the text?
To get the icon you use
Code:
$dataClasses[ID].iconIndex
You would have to store that into a variable and then you use
Code:
\i[\v[VARIABLE_ID]]
inside the text box.
It works!!!! Great!!! Thank you 1000000000000000000 times!!!!

So now the very last thing I need, would be a script to uplevel a subclass.

I was trying to set class ID 16, to level 14, by using a script call:

$gameVariables.setValue($gameActors.actor(1).classLevel(16), 14);

But nothing happened....
To level up an actor, you can use
Code:
actor.levelUp(); // actor refers to an actual actor object, so $gameActors.actor(ID) e. g.
That would raise his level for that class, I think.
But is there a way to level up a subclass that's not currently activated? I would like to set an initial level whenever a new class is unlocked.

Could it have something to do with this?

Yanfly.Subclass.Game_Actor_gainExp = Game_Actor.prototype.gainExp;
Game_Actor.prototype.gainExp = function(exp) {
this.gainExpSubclass(exp);
Yanfly.Subclass.Game_Actor_gainExp.call(this, exp);
};

Game_Actor.prototype.gainExpSubclass = function(exp) {
if (!this.subclass()) return;
exp *= Yanfly.Param.SubclassExp;
var curExp = this._exp[this._subclassId] || 0;
var newExp = curExp + Math.round(exp * this.finalExpRate());
this._exp[this._subclassId] = Math.max(newExp, 0);
};
So it seems the experience is saved in $gameActors.actor(1)._exp[1]. This is the experience for class 1.

But how can I set this value = a number, like 10?
Try $gameActors.actor(1)._exp[1] = 10;
YES!!!!!!!!! It works!!!!!!!! Awesome. Amazing!

Is there also a way to do the same just with the class' level?
Maybe something in here?


Game_Actor.prototype.subclassParamBase = function(paramId) {
if (!this.subclass()) return 0;
var rate = Yanfly.Subclass.Param[paramId];
if (!rate) return 0;
if (this.subclass().baseParamFormula) {
var formula = this.subclass().baseParamFormula[paramId];
if (formula !== '') {
return this.classBaseParamFormula(formula, paramId) * rate;
}
}
var level = this.classLevel(this._subclassId);
if (level > 99) {
var i = this.subclass().params[paramId][99];
var j = this.subclass().params[paramId][98];
i += (i - j) * (level - 99);
var value = i;
} else {
var value = this.subclass().params[paramId][level];
}
return value * rate;
};
Nah, that's just for the base parameters.

Does this not work?
$gameActors.actor(ACTOR_ID)._exp[CLASS_ID] = 10;
Yes that one works!!! However I would need another one so I can set the level directly instead of the exp...
$gameActors.actor(ACTOR_ID).changeLevel(x);
It works, but not for the subclasses unfortunately, but I will find a way around it using the experience.
Thank you so much for your help!!! How can I ever thank you for this!

Original thread: https://forums.rpgmakerweb.com/threads/class-change-check-if-sub-class-is-already-unlocked.83354/