Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,281
Reaction score
1,167
First Language
English
Primarily Uses
RMVXA
Class Feature Modify 1.02
by Roninator2​

Introduction
Allows you to specify if features are to be given to a specific class or remove database features for specific classes.

Features
- Use note tags to specify what classes would not get any of the feature bonuses (block feature)
- Use note tags to specify what classes get bonus features (add features)
- If you block and allow bonuses to the same class, only Params are applied.
Sparams (e.g. PDR) and Xparams (e.g. HIT) are not.
Updated

How to Use
Insert below materials and above main
<class restrict: 1, 4, 5, 8>
Classes 1, 4, 5, & 8 will not get any of the features that have been added to the Weapon or Armour

Code:
<class bonus: 2, 5> Bonus will apply to class 2 & 5
:MHP 100   # increase max hp by 100
:ATK 5     # increase attack by 5
:HRG 15    # increase health regeneration by 15%
:PDR -10   # decrease physical damage rate by 10%
</class bonus>

Images
Default 1645129496874.png

Equipped 1645129562741.png

Armour 1645129653542.png

Script
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Class Feature Modify         ║  Version: 1.01     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║   Adjust features for equipment     ╠════════════════════╣
# ║   on class. Blocking or Adding      ║    16 Feb 2022     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions:   Block                                    ║
# ║   put note tag on weapon or armour that is blocked       ║
# ║   from a specific class                                  ║
# ║     <class restrict: x, x, x...>                         ║
# ║  The effect:                                             ║
# ║    All features on the weapon or armour will not work    ║
# ║    Only classes not in the notetag will get the features ║
# ║                                                          ║
# ║                 Add                                      ║
# ║    put note tag on weapon or armour that is to be        ║
# ║    given extra stat boost for specific classes           ║
# ║     <class bonus: class id, class id>                    ║
# ║       :stat bonus                                        ║
# ║       :stat bonus                                        ║
# ║     </class bonus>                                       ║
# ║    e.g.                                                  ║
# ║     <class bonus: 2, 5> Bonus will apply to class 2 & 5  ║
# ║     :MHP 100   # increase max hp by 100                  ║
# ║     :ATK 5     # increase attack by 5                    ║
# ║     :HRG 50    # increase health regeneration by 50%     ║
# ║     :PDR 80    # Sets Physical Damage Rate to 80%        ║
# ║     </class bonus>                                       ║
# ║                                                          ║
# ║  List of stats that can be assigned                      ║
# ║    Param                                                 ║
# ║      :MHP  :MMP  :ATK  :DEF  :MAT  :MDF  :AGI  :LUK      ║
# ║                                                          ║
# ║    XPARAM  Ratio -> e.g. :HIT 10  Adds 10% to hit        ║
# ║      :HIT  :EVA  :CRI  :CEV  :MEV                        ║
# ║      :MRF  :CNT  :HRG  :MRG  :TRG                        ║
# ║                                                          ║
# ║    SPARAM  Ratio -> e.g. :PHA 10  Overwrites pha to 10%  ║
# ║      :TGR  :GRD  :REC  :PHA  :MCR                        ║
# ║      :TCR  :PDR  :MDR  :FDR  :EXP                        ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Updates:     Last Update 17 Feb 2022                     ║
# ║ 1.01 - Script extended for bonus features                ║
# ║ 1.00 - Created script with help from Tsukihime code      ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝

module R2_Class_Feature_Adjust
  Bad_Class = /<class[ _-]restrict:[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  Class_Bonus = /<class[-_ ]bonus:[ ]*(\d+(?:\s*,\s*\d+)*)>(.*?)<\/class[-_ ]bonus>/im
end
  
module DataManager
  class <<self 
    alias load_database_original_r2_class_equip_adjust_param load_database
  end
  def self.load_database
    load_database_original_r2_class_equip_adjust_param
    load_class_adjust_param_equip
  end
  def self.load_class_adjust_param_equip
    groups = [$data_weapons, $data_armors]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_class_adjust_param_equip
      end
    end
  end
end

class RPG::EquipItem
  attr_accessor :class_equip_restrict
  attr_accessor :hidden_features
  attr_accessor :bonus_features
  attr_accessor :added_features
  attr_accessor :class_equip_bonus_id
  attr_accessor :class_equip_bonus_params
  def load_class_adjust_param_equip
    @hidden_features = []
    @bonus_features = []
    @added_features = []
    @class_equip_restrict = []
    @class_equip_bonus_id = []
    @class_equip_bonus_params = {}
    parameter_list = [:mhp, :mmp, :atk, :def, :mat, :mdf, :agi, :luk, :hit, :eva, :cri, :cev, :mev, :mrf, :cnt, :hrg, :mrg, :trg, :tgr, :grd, :rec, :pha, :mcr, :tcr, :pdr, :mdr, :fdr, :exr]
    results = self.note.scan(R2_Class_Feature_Adjust::Bad_Class)
    results.each do |res|
      data = res[0]
      data.strip.split("\r\n").each do |line|
        restrict = $1.split(",").map {|val| val.to_i }
        @class_equip_restrict << restrict
      end
    end
    results = self.note.scan(R2_Class_Feature_Adjust::Class_Bonus)
    results.each do |res|
      id = res[0]
      data = res[1]
      id.strip.split("\r\n").each do |line|
        bonus_class = $1.split(",").map {|val| val.to_i }
        @class_equip_bonus_id << bonus_class
      end
      key = nil
      dig = 0
      data.strip.split("\r\n").each do |line|
        num = line.split(" ").map {|val| 
          stat = val.to_i
          if stat == 0
            code = val.to_s.upcase
            parameter_list.each do |k|
              key = k if code.include?(k.to_s.upcase)
            end
          else
            dig = val.to_i
          end
          @class_equip_bonus_params[key] = 0 unless key.nil?
          @class_equip_bonus_params[key] = dig unless key.nil?
        }
      end
    end
  end
end

class Game_Actor
  alias r2_class_equip_restrict_param_plus param_plus
  def param_plus(param_id)
    check_class_restrict
    check_class_bonus
    r2_class_equip_restrict_param_plus(param_id)
  end
  
  def check_class_restrict
    equips.compact.each do |eq|
      eq.hidden_features = eq.features if eq.hidden_features == []
      next if eq.class_equip_restrict.empty?
      if eq.class_equip_restrict[0].include?(actor.class_id)
        eq.features = []
        eq.features = eq.added_features if eq.added_features != []
      else
        eq.features = eq.hidden_features if eq.features == []
      end
    end
  end
  def check_class_bonus
    equips.compact.each do |eq|
      next if eq.class_equip_bonus_id.empty?
      if eq.class_equip_bonus_id[0].include?(actor.class_id)
        data = eq.class_equip_bonus_params
        data.each_with_index do |stat, i|
          case stat[0]
          # params
          when :mhp, :mmp, :atk, :def, :mat, :mdf, :agi, :luk
            list = [:mhp, :mmp, :atk, :def, :mat, :mdf, :agi, :luk]
            list.each_with_index do |st, j|
              if stat[0] == st
                id = j 
                value = stat[1]
                eq.params[id] += value unless eq.bonus_features.include?(stat)
                eq.bonus_features << stat unless eq.bonus_features.include?(stat)
              end
            end
          # Xparams - add onto previous value
          when :hit, :eva, :cri, :cev, :mev, :mrf, :cnt, :hrg, :mrg, :trg
            list = [:hit, :eva, :cri, :cev, :mev, :mrf, :cnt, :hrg, :mrg, :trg]
            list.each_with_index do |st, j|
              if stat[0] == st
                id = j 
                value = stat[1]
                value = value.to_f / 100
                code = 22
                eq.features.push(RPG::BaseItem::Feature.new(code, id, value)) unless eq.bonus_features.include?(stat)
                eq.added_features = eq.features
                eq.bonus_features << stat unless eq.bonus_features.include?(stat)
              end
            end
          # Sparams - Overwrites previous value
          when :tgr, :grd, :rec, :pha, :mcr, :tcr, :pdr, :mdr, :fdr, :exr
            list = [:tgr, :grd, :rec, :pha, :mcr, :tcr, :pdr, :mdr, :fdr, :exr]
            list.each_with_index do |st, j|
              if stat[0] == st
                id = j 
                value = stat[1]
                value = value.to_f / 100 + 1
                code = 23
                eq.features.push(RPG::BaseItem::Feature.new(code, id, value)) unless eq.bonus_features.include?(stat)
                eq.added_features = eq.features
                eq.bonus_features << stat unless eq.bonus_features.include?(stat)
              end
            end
          end
        end
      else
        eq.bonus_features = []
      end
    end
  end
end

Credit and Thanks
- Roninator2

Terms of use
Free for all RPG Maker VX Ace uses.
 
Last edited:

jason1313

Villager
Member
Joined
Apr 22, 2021
Messages
15
Reaction score
2
First Language
English
Primarily Uses
RMVXA
Hey Ron, thanks for the great script!

I've been testing the "Class Feature Modify" script on a blank project and am having a bit of trouble getting this to work properly for some things. Maybe I'm doing something wrong.


1. A weapon/armor with a class bonus for only PARAM works great with no issues, awesome! Example:

<class bonus: 2, 5>
:MHP 50
:ATK 5
</class bonus>

2. A weapon/armor with a class bonus for only XPARAM gives me an error immediately when I try to equip the weapon/armor.

Error:
Script 'Class Feature Modify' line 179: NoMethodError occured. undefined method 'added_features='for #<RPG::Weapon:0x824d5a8>

Example:

<class bonus: 2, 5>
:HIT 5
:EVA 5
</class bonus>

I can get the error message to go away if I put the "Block all features on class" script below the "Class Feature Modify" script, but this doesn't seem to apply the bonuses.

Putting the "Block all features on class" script on top of the "Class Feature Modify" script gives me the same error as above when I try to equip the weapon/armor.


3. A weapon/armor with a class bonus for only SPARAM gives me an error immediately when I try to equip the weapon/armor.

Error: Script 'Class Feature Modify' line 193: NoMethodError occured. undefined method 'added_features='for #<RPG::Weapon:0x824abf0>

Example:

<class bonus: 2, 5>
:TGR 5
</class bonus>
 

jason1313

Villager
Member
Joined
Apr 22, 2021
Messages
15
Reaction score
2
First Language
English
Primarily Uses
RMVXA
Thanks Ron, the update fixed everything. :thumbsup-left:
 

Latest Threads

Latest Profile Posts

Every group of friends has that one "stupid friend". If you aren't sure who is the "stupid friend" in your group... it's most likely you.
Just spent 30 min growling at a mesh not importing properly to unity.
Then the programmer asked "Did you send me the updated texture?"
*Nervous laughter*
Well, that explain the transparent texture eh?
If you have ever played these games and miss them, please look forward to it.
Miss the old retro style? I'm a fan of it, especially these Famicom games.
"Dragon Ball Z from Nintendo Entertainment System"
dragonball-z.jpeg

Forum statistics

Threads
124,657
Messages
1,165,019
Members
163,473
Latest member
nie
Top