Weapon & Armor Class Bonus

Hello,

I'm looking for a script that would give certain classes bonus stats when equipped with a certain weapon and/or armor.

Example:

A White Mage equips a Healing Staff. That White Mage should receive a +10 MP and +1 MP Regen bonus, every other class that can equip this weapon should not get the bonus.

Or is there a manual way of doing this?

Thanks for your help!
If that is all you are doing then you can just put that into the weapon itself.
Features.
If you new to rpg maker then go through some of Andar's tutorials. Links in my signature block
here
↓
Hey Ron,

Thanks for response. I guess I wasn't clear enough on my original post. So here's another example of what I'm looking for.

Healing Staff, Base Stats: +100 MAT, +100 HP
Equippable by White Mage and Wizard
If equipped by White Mage, +100 MP and +1 MP Regen
If equipped by Wizard, no bonus, only base stats
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Block all features on class  ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║    Prevent features from applying   ╠════════════════════╣
# ║    to classes you want to block     ║    16 Feb 2022     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions:                                            ║
# ║   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 ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Updates:                                                 ║
# ║ 1.00 - Created script with help from Tsukihime           ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝

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

class RPG::EquipItem
  attr_accessor :class_equip_restrict
  attr_accessor :hidden_features
  def load_class_restrict_equip
    @hidden_features = []
    @class_equip_restrict = []
    results = self.note.scan(R2_Class_Feature_Restrict::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
  end
end

class Game_Actor
  def param_plus(param_id)
    check_class
    equips.compact.inject(super) {|r, item| r += item.params[param_id] }
  end
  def check_class
    equips.compact.each do |eq|
      next if eq.class_equip_restrict.empty?
      eq.hidden_features = eq.features if eq.hidden_features == []
      if eq.class_equip_restrict[0].include?(actor.class_id)
        eq.features = []
      else
        eq.features = eq.hidden_features if eq.features == []
      end
      p(eq)
    end
  end
end
Hi Ron,

I tried the script on a blank project and I'm getting the following error when the game loads up:

Script "line 75: NoMethodError occured.
undefined method 'include?' for nil:NilClass
Fixed. You didn't have any note tags on any armours or weapons.
Thanks Ron! It works in my project for the features now.

I can work around the script but it's not quite 100% what I'm looking for. Would you be able to modify it so that the note tags could look something like this:

<class bonus: 1, 3, 5>
10 MP
10 HP
10 Accuracy
</class bonus>

Where class 1 (Soldier), class 3 (Paladin), class 5 (Samurai) would all get +10 MP, HP and Accuracy if they have this weapon or armor equipped.
So your wanting to have an armour or weapon usable by multiple classes, features blocked for some, features applied to the rest and features added for others?

As soon as it's approved.
Thanks for helping out with this Ron, I really appreciate it.

I want to try and explain it a different way.

Say the game has three classes:

1. Gladiator
2. Lancer
3. Samurai

There's a weapon in the database called "Lancer's Spear" that gives a base +10 ATK.

All three classes are able to equip this weapon, but I want the Lancer to gain an additional +5 Attack and +5 Accuracy on top of the base stats.

The note tags for this could be something like:

<class bonus: 2>
5 Attack
5 Accuracy
</class bonus>

So in the end the total stats would look like this with the Lancer's Spear equipped:

Gladiator: +10 Attack
Lancer: +15 Attack, +5 Accuracy
Samurai: +10 Attack

I hope that makes sense.
And the script I made will do all of that.
If you do not use the class restrict option, then it should be fine.
It's when you combine them that only params will work. (atk, accuracy (or hit) is an xparam)

Updated. Still waiting for approval though.

Original thread: https://forums.rpgmakerweb.com/threads/weapon-armor-class-bonus.144972/