Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

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):
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

Code:
#--------------------------------------------------------------------------

# Change Class with Weapon 

# Class & Weapon ID must match in the database

#--------------------------------------------------------------------------

class Game_Actor

  alias class_equip equip

  def equip(equip_type, id)

    class_equip(equip_type, id)

    case equip_type

    when 0  # Weapon

      @class_id=(id)

    end

  end

end
 
That won't change the skills though brew.

Code:
module WeaponClasses

  #--------------------------------------------------------------------------

  # * Assigns a class to each weapon

  #     Syntax: Weapon[weapon_id] = class_id

  #--------------------------------------------------------------------------

  Weapons = []

  Weapons[1] = 1

  Weapons[2] = 1

  Weapons[3] = 1

  Weapons[4] = 1

  Weapons[5] = 2

end

 

class Game_Actor

  alias old_equip equip

  #--------------------------------------------------------------------------

  # * Change Equipment

  #     equip_type : type of equipment

  #     id    : weapon or armor ID (If 0, remove equipment)

  #--------------------------------------------------------------------------

  def equip(equip_type, id)

    old_equip(equip_type, id)

    if equip_type == 0

      newclass = WeaponClasses::Weapons[id]

      if newclass != nil

        @class_id = newclass

        relearn_skills

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Removes all skills and relearns them based on class

  #--------------------------------------------------------------------------

  def relearn_skills

    @skills = []

    # Learn skill

    for i in 1..@level

      for j in $data_classes[@class_id].learnings

        if j.level == i

          learn_skill(j.skill_id)

        end

      end

    end

  end

end
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.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top