How to make equipment better for some classes or actors?

Hi! I was wondering if there's a way that a piece of equipment could have an extra stat or parameter bonus if and only if it's equipped by a certain class or a certain actor, i.e. a sword that when equipped by a Knight Class gives +7 atk rather than the normal +5 atk it gives, or a piece of armor that when equipped by a certain actor gives +8 def while for everyone else it give +4.
Note: I have access to all of the Yanfly & Yanfly Olivia plugins, if there's a possibility I am able to do it with those, but I couldn't see a way how to myself.
If you have YEP_EquipCore, you can use its "Custom Parameters" Notetag with armors and weapons.



Here is an example of such a notetag:

<Custom Parameters>
atk_base = 8;
if (user._classId === 1) {atk = atk_base;} else {atk = Math.round(atk_base*0.75);}
</Custom Parameters>

Explaination:
#1 atk_base is a temporary variable (it can have any name you want) that stores the base attack value.
#2 We check if the character equipped with this armor/weapon has class 1.
#3 If the character is class 1, then we raise the atk of that character by 8.
#4 If the character is not class 1, then they only gain 75% of the original value.
#4.1 We need to use the Math.round() function to avoid fractions.

Note: You need to swap out the 1 with the ID of the class you desire.


You can construct these notetags however you want, I just went with a percentage-based loss of stats because that seems to be the most consistent.

If you want it to be strictly like your example, you can do something like this:

<Custom Parameters>
if (user._classId === 1) {atk = 7;} else {atk = 5;}
</Custom Parameters>

This approach is simpler, but also a lot more tedious to do with a lot of equipment.



Here is an example of multiple stats in one equipment with a more complex structure:

<Custom Parameters>
atk_base = 8; mat_base = 6; agi_base = 4; mod=0.75;

if (user._classId === 1) {
atk = atk_base;
mat = mat_base;
agi = agi_base;
} else {
atk = Math.round(atk_base*mod);
mat = Math.round(mat_base*mod);
agi = Math.round(agi_base*mod);
}
</Custom Parameters>



Lastly, if you want to check for actors instead of classes,
replace "user._classId" with "user._actorId".



If you have any questions, feel free to ask.
you could just use the traits system that MV has, add parameter rate traits to equipment instead of using the stat boxes in the equipment editor.

that way equipment multiplies your stats instead of adding to them, for example a sword with ATK*150% will increase a warrior's 20 base ATK by +10 while a mage with 5 base ATK will get +2.5 (rounded to +2).

do keep in mind that these stack multiplicatively which can skyrocket stats.
Another way (and ScorchedGround's is better, but just to illustrate you have a good number of options in the plugins you already own) is to use Passive States. Assign one to the weapon, and then inside of the state you can put a Custom Passive Condition with the same code already supplied.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-equipment-better-for-some-classes-or-actors.139560/