Remove all previous skills known when changing class

Hi there!

Right now, when I do a class change, the actor seem to keep access to skills of previous class. I do not wan that. Instead, I want them to forget the skills they had.

In my game, mages can follow ONE of the five magic schools (for simplicity's sake, let's say fire, water, earth, etc.)
Is there a way, plugin or otherwise, to easily do this:

1- Actor change class from Fire Mage to Water Mage
2- Unlock skills for Water Mage
3- Forget all skills for Fire Mage
$gameActors.actor(id).forgetSkill(skillId) is what you need
$gameActors.actor(id).forgetSkill(skillId) is what you need

Thank you! It's not going to be super fun to implement but I think I can manage.

Cheers!
What if the player decides "I don't like how water plays, i'm switching back to fire." and when they do that, all the fire skills they learned leveling up were gone?
@Oddball - then we can use opposite method:

$gameActors.actor(id).learnSkill(skillId)
@Oddball - then we can use opposite method:

$gameActors.actor(id).learnSkill(skillId)
Wouldn't that just teach the actor all the skills from the fire branch? How do you account for level?
With conditional branches or write whole method as JS code.

if (class==a && level > b){
$gameActors.actor(id).learnSkill(skillId);
}else{//Requirements are not met;}
So this is what I did:

Common Event: Forget All Skills
JavaScript:
for (var i = 44; i < 60; ++i) {
    $gameActors.actor(5).forgetSkill(i)
};

And then, one common event for each Magic School, when changing class:

Event: School Fire
Code:
for (var i = 44; i < 51; ++i) {
    $gameActors.actor(5).learnSkill(i)
};

Event: School Water
Code:
for (var i = 52; i < 60; ++i) {
    $gameActors.actor(5).learnSkill(i)
};


Not ideal, but seems to work just fine for now. I'll have to account for level when I get there.

Thanks for the help!
So this is what I did:

Common Event: Forget All Skills
JavaScript:
for (var i = 44; i < 51; ++i) {
    $gameActors.actor(5).forgetSkill(i)
};

And then, one common event for each Magic School, when changing class:

Event: School Fire
Code:
for (var i = 44; i < 51; ++i) {
    $gameActors.actor(5).forgetSkill(i)
};

Event: School Water
Code:
for (var i = 52; i < 60; ++i) {
    $gameActors.actor(5).forgetSkill(i)
};


Not ideal, but seems to work just fine for now. I'll have to account for level when I get there.

Thanks for the help!
I am unsure if this will work for you but this is what I use for something similar-ish.
I believe if you first change the class and then run this it should initialize the character.
1596495078792.png

1596495049357.png
As part of a Plugin I wrote for my project, I've got something like the following to handle transformation abilities that switch out skill sets while transformed:

Code:
Game_Actor.prototype.transformSkills = function(methodType) {
    $dataClasses[this._classId].learnings.forEach(learning => {
        if (this._level < learning.level) { return; }
        this[`${methodType}Skill`](learning.skillId);
    });
}

Game_Actor.prototype.completeTransform = function(classId) {
    this.transformSkills('forget');
    this.changeClass(classId);
    this.transformSkills('learn');
};

Loops through all the Skills for the actor's given class and, if they're high enough level to know them, forgets them. Then it changes their class. Then loops through all the Skills for the actor's given class (now that it's changed) and, if they're high enough level to know them, learns them.

So if you wanted to change from whatever their current class is to a class with Id 2, you could just have a Script call of:
Code:
$gameActors.actor(5).completeTransform(2);

Original thread: https://forums.rpgmakerweb.com/threads/remove-all-previous-skills-known-when-changing-class.124881/