DL: Class Armor

Discussion in 'RGSS3 Scripts (RMVX Ace)' started by Harosata, Sep 17, 2017.

  1. Harosata

    Harosata Dramatic Lightning's BFF Veteran

    Messages:
    240
    Likes Received:
    65
    First Language:
    English
    Primarily Uses:
    RMVXA
    CLASSARMOR.png

    Script: Class Armor
    Difficulty: Medium
    Short Version: Equipping Armor will change your Class.

    Code:
    #--------------------------------#
    # Dramatic Lightning Co Presents:
    # Class Armor
    #--------------------------------#
    # Feel like dressing up?  This script allows you to change classes when you
    # equip certain armors.  You could recreate Final Fantasy 14's Job System
    # or fake a sub class here.  You can still change your default class and
    # learn skills not related to a class.
    # Place a <DLArmorClass x> tag in your weapon/armor notebox,
    # x being the class id you want to change into.
    #--------------------------------#
    
    module DL
      module ARMORCLASS
    
        SLOTID = 3 #0-4 refers to equipment slot, 3 being Body Armor, 0 being Weapon.
        EXPKEEP = false #true keeps level on armor change, while false has individual class levels
        SKILLRESET = false #skills reset on equip.
        DEFSKILLLEARN = false #learn default class skills regardless of armor
        
      end
    end
    
    #--------------------------------#
    #Technical stuff below
    #--------------------------------#
    
    class RPG::BaseItem
     
      def armor_class
        aclass = 0
        regex = /<DLArmorClass\s*(\d+)\s*>/i
        res = self.note.match(regex)
        if res
          aclass = res[1].to_i
        end
        return aclass
      end
    
    end
    
    class Game_Actor < Game_Battler 
     
      alias dl_init_equips init_equips
      def init_equips(equips)
        dl_init_equips(equips)
        @default_class_id = @class_id
        @skills2 = []
        update_armor
        refresh
      end
    
      alias dl_change_equip change_equip
      def change_equip(slot_id, item)
        dl_change_equip(slot_id, item)
        update_armor
        refresh
      end
    
      def update_armor
        if @equips[DL::ARMORCLASS::SLOTID].object and $data_armors[@equips[DL::ARMORCLASS::SLOTID].object.id].armor_class > 0
          change_class($data_armors[@equips[DL::ARMORCLASS::SLOTID].object.id].armor_class, DL::ARMORCLASS::EXPKEEP)
        else
          change_class(@default_class_id, DL::ARMORCLASS::EXPKEEP)
        end
         update_skills
      end
     
      def change_default_class(new_class_id)
        @default_class_id = new_class_id if new_class_id > 0
      end
     
      def update_skills
        init_skills if DL::ARMORCLASS::SKILLRESET
        if DL::ARMORCLASS::DEFSKILLLEARN and @class_id != @default_class_id
          change_class(@default_class_id, DL::ARMORCLASS::EXPKEEP)
          self.class.learnings.each do |learning|
            learn_skill(learning.skill_id) if learning.level <= @level
          end
          if @equips[DL::ARMORCLASS::SLOTID].object and $data_armors[@equips[DL::ARMORCLASS::SLOTID].object.id].armor_class > 0
            change_class($data_armors[@equips[DL::ARMORCLASS::SLOTID].object.id].armor_class, DL::ARMORCLASS::EXPKEEP)
          end
        end
        @skills2.each do |skill_id|
          @skills.push(skill_id)
        end
      end
     
      alias dl_level_up level_up
      def level_up
        dl_level_up
        if DL::ARMORCLASS::DEFSKILLLEARN and @class_id != @default_class_id and DL::ARMORCLASS::EXPKEEP
          $data_classes[@default_class_id].learnings.each do |learning|
            learn_skill(learning.skill_id) if learning.level == @level
          end
        end
      end
     
      def learn_skill2(skill_id)
        unless skill_learn?($data_skills[skill_id])
          @skills2.push(skill_id)
          @skills.push(skill_id)
          @skills.sort!
        end
      end
     
      alias dl_forget_skill forget_skill
      def forget_skill(skill_id)
        dl_forget_skill(skill_id)
        @skills2.delete(skill_id)
      end
      
    end
    
    class Game_Interpreter #overwrite
      def command_321
        actor = $game_actors[@params[0]]
        actor.change_default_class(@params[1]) if actor && $data_classes[@params[1]]
        actor.update_armor
      end
     
      def command_318
        iterate_actor_var(@params[0], @params[1]) do |actor|
          if @params[2] == 0
            actor.learn_skill2(@params[3])
          else
            actor.forget_skill(@params[3])
          end
        end
      end
    end
    Version 1.1.0
    -Change Class in the Event page will change your default class.
    -Adding or Removing a Skill in the Event page adds a skill that isn't affected by SKILLRESET.

    I made this for a request. Anyway, if you equip a specific Armor with this script, you will gain the class assigned to that armor. Don't worry, you can return to your previous Class just by unequipping your Armor. In order to use this script, place this notetag in your Armor/Weapon notebox:

    <DLArmorClass x>

    And replace x with the Class ID (1,2,etc) you want to change to. Remember, the notebox is the white box in the lower-right corner.

    ---

    Now that you got that out of the way, the tricky part is how you want to further customize your Armor/Class interaction. In the Script, you'll find four variables:

    SLOTID
    EXPKEEP
    SKILLRESET
    DEFSKILLLEARN


    SLOTID is the Equipment Slot you want to restrict your Class mods to for simplicity sake. That means that if this slot is set to Body Armor, the notetags won't trigger on Helmets or Accessories. You can also set this to your mainhand Weapon.

    EXPKEEP will let you have one Level among all Classes if set to true. If false, each Class has its own level/exp; think Final Fantasy XIV's Job system.

    SKILLRESET will reset your Skills whenever you change class. If false, you could eventually learn skills from all Classes.

    DEFSKILL will allow you to learn Skills from your default and equipped class. If false, you only get skills from your current class.

    ---

    Next, here's some combinations:

    EXPKEEP = false
    SKILLRESET = false


    By default, all Classes other than your starting Class starts at Level 1. Thankfully, Level are saved for each level, meaning you can switch between a Level 15 Paladin and a Level 1 Thief with ease. Because of this, you can learn all the Skills if you level up every Class.

    EXPKEEP = false
    SKILLRESET = true


    When you change Class, you don't keep the skills from your previous class, but thankfully you'll regain the Skills you learned with your currect Class. If you set DEFSKILLLEARN to true, Skills from your Default Class can be used in other classes.

    EXPKEEP = true
    SKILLRESET = false


    You keep your Level regardless of Classes, but you will also skip out of gaining Skills from other classes when leveling up. The best suggestion is to have Skills share the same level requirement so that you can present a choice for players when they level up. Setting DEFSKILLLEARN to true will give you Default Class Skills when you level up regardless of equipped Class.

    EXPKEEP = true
    SKILLRESET = true


    If you equip an Armor, you also gain the Skills you'll have at that level. If you also use DEFSKILLLEARN and put it to true, equipping armor is like putting on a Subclass.
     
    #1
  2. .//SnowAlias

    .//SnowAlias Do'er of Things Veteran

    Messages:
    30
    Likes Received:
    38
    Location:
    New York, USA
    First Language:
    English
    Primarily Uses:
    RMMV
    This could actually be pretty useful for implementing a clever equipment system. Well done!
     
    #2

Share This Page