Kain Nobel
Member
Actors : Change Class Skills
Version: 3.0
By: Kain Nobel
Introduction
Ever go to change your class, either through script or perhaps event, and notice that you still have all the skills you had in the previous class? This script fixes that, so anytime you change an actor's class his/her skills will change respectively with that class. Other features have been included as well to further control this...
Features
Script
Instructions
Place below 'Scene_Debug' (and SDK if using) and above 'main' in your script listings. If you do not use SDK then simply delete the SDK.log, SDK.enabled?() test and the last end in the script because this doesn't really require SDK to run.
FAQ
Compatibility
Place this script below any custom scripts that overwrite the following methods...
Game_Actor.class_id=
Terms and Conditions
Free for commercial and non-commercial use, please credit me if you release a game with this script in it.
Version: 3.0
By: Kain Nobel
Introduction
Ever go to change your class, either through script or perhaps event, and notice that you still have all the skills you had in the previous class? This script fixes that, so anytime you change an actor's class his/her skills will change respectively with that class. Other features have been included as well to further control this...
Features
- Ability to set (locally and globally) which classes won't lose their skills.
- Ability to set (locally and globally) which skills can't be lost during class change.
- You can also set it so that skills learned that weren't class based will be saved or not.
Script
Code:
#===============================================================================
# ** Actors : Change Class Skills
#===============================================================================
Â
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
SDK.log('Actors.ChangeClassSkills', 'Kain Nobel', 0, '04.05.2009')
#-------------------------------------------------------------------------------
# * SDK Enabled Test : BEGIN
#-------------------------------------------------------------------------------
if SDK.enabled?('Actors.ChangeClassSkills')
Â
#===============================================================================
# ** ClassChangeSkills
#===============================================================================
Â
module ClassChangeSkills
 #-----------------------------------------------------------------------------
 # * Won't remove skills belonging to these classes.
 #   Syntax : {actor id => [class id, ...], ...}
 #-----------------------------------------------------------------------------
 Exempt_Class_IDs  = {}
 #-----------------------------------------------------------------------------
 # * Won't remove these skills reguardless of class.
 #   Syntax : {actor id => [skill id, ...], ...}
 #-----------------------------------------------------------------------------
 Exempt_Skill_IDs  = {}
 #-----------------------------------------------------------------------------
 # * These actors save learned skills that weren't class based.
 #   Syntax : {actor id => boolean, ...], ...}
 #-----------------------------------------------------------------------------
 KeepLearnedSkills = {}
 #-----------------------------------------------------------------------------
 # * Default Settings (Will affect all actors globally.)
 #-----------------------------------------------------------------------------
 KeepLearnedSkills.default  = true
 Exempt_Class_IDs.default  = []
 Exempt_Skill_IDs.default  = []
end
Â
#===============================================================================
# ** Game_Actor
#===============================================================================
Â
class Game_Actor < Game_Battler
 #-----------------------------------------------------------------------------
 # * Alias Listings
 #-----------------------------------------------------------------------------
 alias_method :classchangeskills_gmactor_classid,  :class_id=
 alias_method :classchangeskills_gmactor_lrnskill, :learn_skill
 alias_method :classchangeskills_gmactor_frgskill, :forget_skill
 #-----------------------------------------------------------------------------
 # * Class ID = (n)
 #-----------------------------------------------------------------------------
 def class_id=(class_id)
  old_class = self.class_id
  classchangeskills_gmactor_classid(class_id)
  new_class = self.class_id
  class_change_skills(old_class, new_class)
 end
 #-----------------------------------------------------------------------------
 # * Learn Skill
 #-----------------------------------------------------------------------------
 def learn_skill(skill_id)
  @non_class_change_skills ||= Array.new
  unless class_change_get_skills(self.class_id).include?(skill_id)
   @non_class_change_skills << skill_id
  end
  classchangeskills_gmactor_lrnskill(skill_id)
 end
 #-----------------------------------------------------------------------------
 # * Forget Skill
 #-----------------------------------------------------------------------------
 def forget_skill(skill_id)
  @non_class_change_skills ||= Array.new
  unless class_change_get_skills(self.class_id).include?(skill_id)
   @non_class_change_skills.delete(skill_id)
  end
  classchangeskills_gmactor_frgskill(skill_id)
 end
 #-----------------------------------------------------------------------------
 # * Class Change Skills
 #-----------------------------------------------------------------------------
 def class_change_skills(old_class, new_class)
  return if old_class == new_class
  old_skills = class_change_get_skills(old_class)
  new_skills = class_change_get_skills(new_class)
  class_change_forget_skills(old_skills, old_class)
  class_change_learn_skills(new_skills)
 end
 #-----------------------------------------------------------------------------
 # * Class Change Keep Acquired Skills?
 #-----------------------------------------------------------------------------
 def class_change_keep_acquired_skills?
  return ClassChangeSkills::KeepLearnedSkills[id]
 end
 #-----------------------------------------------------------------------------
 # * Class Change Learn Skills
 #-----------------------------------------------------------------------------
 def class_change_learn_skills(skills)
  if class_change_keep_acquired_skills?
   skills += @non_class_change_skills.dup
  end
  skills.compact!
  skills.each {|skill| learn_skill(skill)}
 end
 #-----------------------------------------------------------------------------
 # * Class Change Forget Skills
 #-----------------------------------------------------------------------------
 def class_change_forget_skills(skills, old_class)
  return if class_change_exempt_class?(old_class)
  skills.each do |skill|
   unless class_change_exempt_skill?(skill)
    forget_skill(skill)
   end
  end
 end
 #-----------------------------------------------------------------------------
 # * Class Change Get Old Skills
 #-----------------------------------------------------------------------------
 def class_change_get_skills(class_id)
  skills = Array.new
  for level in 1..@level
   for learn in $data_classes[class_id].learnings
    if learn.level == level
     skills << learn.skill_id
    end
   end
  end
  return skills
 end
 #-----------------------------------------------------------------------------
 # * Class Change Exempt Class?
 #-----------------------------------------------------------------------------
 def class_change_exempt_class?(n)
  return true if ClassChangeSkills::Exempt_Class_IDs[self.id].include?(n)
  return true if ClassChangeSkills::Exempt_Class_IDs.default.include?(n)
  return false
 end
 #-----------------------------------------------------------------------------
 # * Class Change Exempt Skill?
 #-----------------------------------------------------------------------------
 def class_change_exempt_skill?(n)
  return true if ClassChangeSkills::Exempt_Skill_IDs[self.id].include?(n)
  return true if ClassChangeSkills::Exempt_Skill_IDs.default.include?(n)
  return false
 end
end
Â
#-------------------------------------------------------------------------------
# * SDK Enabled Test : END
#-------------------------------------------------------------------------------
end
Instructions
Place below 'Scene_Debug' (and SDK if using) and above 'main' in your script listings. If you do not use SDK then simply delete the SDK.log, SDK.enabled?() test and the last end in the script because this doesn't really require SDK to run.
FAQ
Simply set up the hash like so...
Exempt_Class_IDs = {1 => [1, 2, 3...]}
...or...
Exempt_Class_IDs[1] = [1, 2, 3...]
...In default terms, this means that the first actor (Aluxes) won't lose skills when changing from a Fighter, Lancer or Warrior. However if he changes to a different class which ID isn't included in the array, he is going to lose skills from the class he was previously.
If you use 0 as your actor ID, these settings will be applied to all actors along with their personal settings. Otherwise, for actors which aren't predefined, you can set Exempt_Class_IDs.default which must always be an array (a [])
Exempt_Class_IDs = {1 => [1, 2, 3...]}
...or...
Exempt_Class_IDs[1] = [1, 2, 3...]
...In default terms, this means that the first actor (Aluxes) won't lose skills when changing from a Fighter, Lancer or Warrior. However if he changes to a different class which ID isn't included in the array, he is going to lose skills from the class he was previously.
If you use 0 as your actor ID, these settings will be applied to all actors along with their personal settings. Otherwise, for actors which aren't predefined, you can set Exempt_Class_IDs.default which must always be an array (a [])
You'll have to set the hash similiar to the example above...
Exempt_Skill_IDs = {1 => [1, 2, 3...]}
...or...
Exempt_Skill_IDs[1] = [1, 2, 3...]
...in default terms, this means Aluxes won't ever lose "Heal", "Greater Heal" or "Mass Heal" if he ever learned it.
If you use 0 as your actor ID, these settings will be applied to all actors along with their personal settings. Otherwise, for actors which aren't predefined, you can set Exempt_Skill_IDs.default which must always be an array (a [])
Exempt_Skill_IDs = {1 => [1, 2, 3...]}
...or...
Exempt_Skill_IDs[1] = [1, 2, 3...]
...in default terms, this means Aluxes won't ever lose "Heal", "Greater Heal" or "Mass Heal" if he ever learned it.
If you use 0 as your actor ID, these settings will be applied to all actors along with their personal settings. Otherwise, for actors which aren't predefined, you can set Exempt_Skill_IDs.default which must always be an array (a [])
If your characters learn skills not assigned to be learned by class, and you don't want them to lose these special skills, then you can set...
KeepLearnedSkills[id] = true
Whichever actor ID used, they will never forget a skill they learned outside of their class. Unlike the other 2 constants 0 is not used to determine this as a global setting, however setting default to true/false will affect all actors who aren't defined in the hash
KeepLearnedSkills[id] = true
Whichever actor ID used, they will never forget a skill they learned outside of their class. Unlike the other 2 constants 0 is not used to determine this as a global setting, however setting default to true/false will affect all actors who aren't defined in the hash
You probably already know if you read one of the first two FAQ spoilers, but say you want to apply certain Exempt Classes/Skills for ALL actors, then still have them use their own special set of exempts, you can either do this...
Exempt_Class_IDs[1] = [1, 2, 3, 4]
Exempt_Class_IDs[2] = [1, 2, 3, 4]
Exempt_Class_IDs[3] = [1, 2, 3, 4, 5, 6]
Exempt_Class_IDs[4] = [1, 2, 3, 4]
Exempt_Class_IDs[5] = [1, 2, 3, 4]
Exempt_Class_IDs[6] = [1, 2, 3, 4, 7, 8]
Exempt_Class_IDs[7] = [1, 2, 3, 4]
Exempt_Class_IDs[8] = [1, 2, 3, 4, 9, 10]
...but doing this is alot easier and cleaner, it'll do the same exact thing.
Exempt_Class_IDs[0] = [1, 2, 3, 4]
Exempt_Class_IDs[3] = [5, 6]
Exempt_Class_IDs[6] = [7, 8]
Exempt_Class_IDs[8] = [9, 10]
...When defined as [0] = [...] then these settings apply to EVERY actor, along with their custom settings, respectively.
Exempt_Class_IDs[1] = [1, 2, 3, 4]
Exempt_Class_IDs[2] = [1, 2, 3, 4]
Exempt_Class_IDs[3] = [1, 2, 3, 4, 5, 6]
Exempt_Class_IDs[4] = [1, 2, 3, 4]
Exempt_Class_IDs[5] = [1, 2, 3, 4]
Exempt_Class_IDs[6] = [1, 2, 3, 4, 7, 8]
Exempt_Class_IDs[7] = [1, 2, 3, 4]
Exempt_Class_IDs[8] = [1, 2, 3, 4, 9, 10]
...but doing this is alot easier and cleaner, it'll do the same exact thing.
Exempt_Class_IDs[0] = [1, 2, 3, 4]
Exempt_Class_IDs[3] = [5, 6]
Exempt_Class_IDs[6] = [7, 8]
Exempt_Class_IDs[8] = [9, 10]
...When defined as [0] = [...] then these settings apply to EVERY actor, along with their custom settings, respectively.
Default settings are similiar but different than the above, as in anything not defined is going to inherit these settings (as well as the global settings, obviously). So, for instance...
Exempt_Skill_IDs[1] = [1, 2, 3]
Exempt_Skill_IDs[2] = [1, 2, 3]
Exempt_Skill_IDs[3] = [1, 2, 3, 4, 5]
Exempt_Skill_IDs[4] = [1, 2, 3]
Exempt_Skill_IDs[5] = [1, 2, 3]
Exempt_Skill_IDs[6] = [1, 2, 3]
Exempt_Skill_IDs[7] = [1, 2, 3]
Exempt_Skill_IDs[8] = [1, 2, 3]
...is a waste of time, when you can just do this...
Exempt_Skill_IDs[3] = [1, 2, 3, 4, 5]
Exempt_Skill_IDs.default = [1, 2, 3]
...Say you have a bunch of actors you don't want to define (yet you don't want to make this a global setting), just set the default. If you don't want anything set for the defaults, at least make sure its an array (a [])
Exempt_Skill_IDs[1] = [1, 2, 3]
Exempt_Skill_IDs[2] = [1, 2, 3]
Exempt_Skill_IDs[3] = [1, 2, 3, 4, 5]
Exempt_Skill_IDs[4] = [1, 2, 3]
Exempt_Skill_IDs[5] = [1, 2, 3]
Exempt_Skill_IDs[6] = [1, 2, 3]
Exempt_Skill_IDs[7] = [1, 2, 3]
Exempt_Skill_IDs[8] = [1, 2, 3]
...is a waste of time, when you can just do this...
Exempt_Skill_IDs[3] = [1, 2, 3, 4, 5]
Exempt_Skill_IDs.default = [1, 2, 3]
...Say you have a bunch of actors you don't want to define (yet you don't want to make this a global setting), just set the default. If you don't want anything set for the defaults, at least make sure its an array (a [])
Compatibility
Place this script below any custom scripts that overwrite the following methods...
Game_Actor.class_id=
Terms and Conditions
Free for commercial and non-commercial use, please credit me if you release a game with this script in it.