Forgetting spells with class switch

I am using yanfly class switch script. I want to make it so that when a character switches their class they “forget” all previous skills but when they switch back to the previous class they will have remembered them again.
Does this work. I wrote this a while ago. Maybe you have this in mind but slightly different?
It works by removing the skills and then adding skills for the new class.

It does not need to remember what you had before as skills are typically set in the class.
But if you are doing something different then this will need to be changed to fit your game.

I also had this for subclasses and estriole addon
Does this work. I wrote this a while ago. Maybe you have this in mind but slightly different?
It works by removing the skills and then adding skills for the new class.
This script works... but there are a few things
1) I am using falcao ABS so when the class switch happens, on the tool bar they are still available and can be used until you swap it out, then you cant use it. Is there a fix with this?
2) If I go to my menu and view skills; the skills are all still there just greyed out/cant use. I was hoping it would eliminate them completely.
Are you using Yanfly learn skills engine and yanfly class system?

What is the method of changing classes? event command?
I am using yanfly class system and yanfly learn skill engine.
To change class its through an event that calls the script.
I think this works.
Spoiler: swap class skills
Ruby:
# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Forget Class skills on class change    ║  Version: 1.01     ║
# ║ Author: Roninator2                            ║                    ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function:                                     ║   Date Created     ║
# ║                                               ╠════════════════════╣
# ║   Option to forget skills from class          ║    10 Jan 2025     ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires:                                                          ║
# ║           Yanfly Engine Ace - Class System v1.10                   ║
# ║           Yanfly Engine Ace - Learn Skill Engine v1.00             ║
# ║           This script                                              ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description:                                                 ║
# ║       Saves and loads skills from classes when changing classes    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions:                                                      ║
# ║   Specify if you want class changes to maintain                    ║
# ║   the skills they learned previously                               ║
# ║   do the class change from the event command or                    ║
# ║   other script                                                     ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates:                                                           ║
# ║ 1.00 - Original Script                                             ║
# ║ 1.01 - Adjusted for class change                                   ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Credits and Thanks:                                                ║
# ║   Roninator2                                                       ║
# ║                                                                    ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Terms of use:                                                      ║
# ║  Follow the original Authors terms of use where applicable         ║
# ║    - When not made by me (Roninator2)                              ║
# ║  Free for all uses in RPG Maker except nudity                      ║
# ║  Anyone using this script in their project before these terms      ║
# ║  were changed are allowed to use this script even if it conflicts  ║
# ║  with these new terms. New terms effective 03 Apr 2024             ║
# ║  No part of this code can be used with AI programs or tools        ║
# ║  Credit must be given                                              ║
# ╚════════════════════════════════════════════════════════════════════╝

module R2_yanfly_skills
  Forget_skills = true
  Maintain_Levels = true
end

# ╔════════════════════════════════════════════════════════════════════╗
# ║                      End of editable region                        ║
# ╚════════════════════════════════════════════════════════════════════╝

class Game_Actor < Game_Battler
  attr_accessor :class_skills
  alias :r2_init_actor_class_skills :initialize
  def initialize(actor_id)
    r2_init_actor_class_skills(actor_id)
    @class_skills = {}
  end
 
  def change_class(class_id, keep_exp = false)
    old_id = self.class_id
    @exp[class_id] = exp if keep_exp
    @exp[class_id] = exp if R2_yanfly_skills::Maintain_Levels
    @class_id = class_id
    forget_class_skills(old_id) if R2_yanfly_skills::Forget_skills
    change_exp(@exp[@class_id] || 0, false)
    learn_class_skills(class_id)
    refresh
  end
 
  def forget_class_skills(class_id)
    return if class_id <= 0
    return if $data_classes[class_id].nil?
    return if @class_id == class_id
    @class_skills[class_id] = []
    @skills.each { |cs|
      @class_skills[class_id].push(cs)
    }
    @skills = []
    remove_usability
  end

  def remove_usability
    if $game_player.actor == self
      $game_player.actor.assigned_skill = nil
      $game_player.actor.assigned_skill2 = nil
      $game_player.actor.assigned_skill3 = nil
      $game_player.actor.assigned_skill4 = nil
    end
  end

  def learn_class_skills(class_id)
    return if class_id <= 0
    return if $data_classes[class_id].nil?
    skills = @class_skills[class_id]
    return if skills.nil?
    skills.each { |sk|
      skl = $data_skills[sk]
      @skills.push(sk) if skl.learn_require_level <= class_level(class_id)
    }
  end
end

I was having trouble for a little while until I realized the skills shown was because the learn skills script has a method on line 620 - def make_unlocked_class_skills
It takes all the class skills that an actor can use for every class the actor can be and makes them available to learn.
If you want this to be only for the current class then...

Spoiler: learn only current class
Ruby:
class Window_LearnSkillList < Window_SkillList
  #--------------------------------------------------------------------------
  # make_unlocked_class_skills
  #--------------------------------------------------------------------------
  def make_unlocked_class_skills
    return unless $imported["YEA-ClassSystem"]
    for skill_id in $data_classes[@actor.class_id].learn_skills
      next if $data_skills[skill_id].nil?
      skill = $data_skills[skill_id]
      @learn_skills.push(skill) unless @learn_skills.include?(skill)
      @skill_classes[skill] = [] if @skill_classes[skill].nil?
      @skill_classes[skill] |= [@actor.class_id]
    end
  end
end

class Window_LearnSkillCommand < Window_Command
  #--------------------------------------------------------------------------
  # make_unlocked_class_skill_types
  #--------------------------------------------------------------------------
  def make_unlocked_class_skill_types
    return unless $imported["YEA-ClassSystem"]
    @unlocked_types = []
    for feature in $data_classes[@actor.class_id].features
      next unless feature.code == 41
      @unlocked_types.push(feature.data_id)
    end
  end
 
  #--------------------------------------------------------------------------
  # correct_unlocked_class_learned_skills
  #--------------------------------------------------------------------------
  def correct_unlocked_class_learned_skills
    return unless $imported["YEA-ClassSystem"]
    @actor.learn_class_skills(@actor.class_id)
  end
end

But I am still having one issue. when you learn a skill then change class and go to learn skills, the skills from the last class show up as learned skills available to use when you leave the learn skill scene.
Let me give this a try and see how it works. My current work around is that I have skills for each class assigned a current type. So when you switch from mage to spellblade; cant use mage skills although they are still present in the skill menu.

An update: my work around works in that on the menu, the new skills are there and the old ones are gone [after class switch]. Its when I open N with falcao abs that the old skills are still there and some still can be used
I changed the second script post above. Try it now.
I changed the second script post above. Try it now.
Thanks, will check it out
I changed the second script post above. Try it now.
I tried it. It eliminates the skills from the main menu however when I swap from the first class [mage] to new class, spellsword, I retain all the skills from mage and can use them even tho its a different type of magic however they do not appear on main menu but when I press N via falcao abs they are still present and I can equip and use. Now when I swap back to mage the spellsword skills are no longer present in both menu and falcao abs menu. Thoughts?
I tried it. It eliminates the skills from the main menu however when I swap from the first class [mage] to new class, spellsword, I retain all the skills from mage and can use them even tho its a different type of magic however they do not appear on main menu but when I press N via falcao abs they are still present and I can equip and use. Now when I swap back to mage the spellsword skills are no longer present in both menu and falcao abs menu. Thoughts?
I am literally testing exactly what you said and it does not have any of the problems you mention.
1736822843008.png

If you want more help you'll have to send me your project or scripts file.
Hopefully there won't be any images required to test play.
Or you can make a new demo and send that to me with the problem.
DM'd you script list
DM'd you script list
So the problem is you're not using the updated script.
You need both of these scripts. You have the older version of my script.
So the problem is you're not using the updated script.
You need both of these scripts. You have the older version of my script.
Works. What is interesting is that for new classes if I have them learn skills at level one, they dont however it is fine as I have them learn skills at level 2 and it all works!

Original thread: https://forums.rpgmakerweb.com/threads/forgetting-spells-with-class-switch.174542/