Class depends on weapon

Script Title:
Class change
RMXP or RMVX:
RMXP
Detailed Description:
I need a simple script that alters a character's class when they equip a different weapon,
Eg. Wielding a sword makes you the swordsman class, giving you access to certain skills. You change to a halberd, and your class changes to Halberdier, which has a seperate set of skills.

So that'd work with about Nine different weapons.
Screen shots:
a picture is worth a hundred words (at least).
Other Scripts I am using (in order):
Content Hidden Spoiler
Letter by Letter Message system - Slipknot
Passability minimap - Selwyn/Squall
Time system with display - Brewmeister


I don't need this script right away, But I'll be awaiting it... Thanks to anyone who decides to have a go at it. I'll give you complete credit for it.
This will assign class[1] with weapon[1]. You'll need to make your weapons & classes line up.

Paste above Main

  1. #--------------------------------------------------------------------------
  2. # Change Class with Weapon
  3. # Class & Weapon ID must match in the database
  4. #--------------------------------------------------------------------------
  5. class Game_Actor
  6.   alias class_equip equip
  7.   def equip(equip_type, id)
  8.     class_equip(equip_type, id)
  9.     case equip_type
  10.     when 0  # Weapon
  11.       @class_id=(id)
  12.     end
  13.   end
  14. end
Expand to see the code.
That won't change the skills though brew.

  1. module WeaponClasses
  2.   #--------------------------------------------------------------------------
  3.   # * Assigns a class to each weapon
  4.   #     Syntax: Weapon[weapon_id] = class_id
  5.   #--------------------------------------------------------------------------
  6.   Weapons = []
  7.   Weapons[1] = 1
  8.   Weapons[2] = 1
  9.   Weapons[3] = 1
  10.   Weapons[4] = 1
  11.   Weapons[5] = 2
  12. end
  13.  
  14. class Game_Actor
  15.   alias old_equip equip
  16.   #--------------------------------------------------------------------------
  17.   # * Change Equipment
  18.   #     equip_type : type of equipment
  19.   #     id    : weapon or armor ID (If 0, remove equipment)
  20.   #--------------------------------------------------------------------------
  21.   def equip(equip_type, id)
  22.     old_equip(equip_type, id)
  23.     if equip_type == 0
  24.       newclass = WeaponClasses::Weapons[id]
  25.       if newclass != nil
  26.         @class_id = newclass
  27.         relearn_skills
  28.       end
  29.     end
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # * Removes all skills and relearns them based on class
  33.   #--------------------------------------------------------------------------
  34.   def relearn_skills
  35.     @skills = []
  36.     # Learn skill
  37.     for i in 1..@level
  38.       for j in $data_classes[@class_id].learnings
  39.         if j.level == i
  40.           learn_skill(j.skill_id)
  41.         end
  42.       end
  43.     end
  44.   end
  45. end
Expand to see the code.

You can edit the top bit to change which class each weapon changes the character into. If you leave a weapon blank, it won't change the class.
good catch. The project I tested it in already updated the skills in the "class_id=" method.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=66880