MV Stacking a State with Yanfly's Buffs and States Core

Hello! I'm currently working on a game that allows a player to level up "skills" in a way similar to Fallout (for example a One-Handed Weapon skill that the player can invest skill points into with every level up, up to 100 points). The idea is that at 0 points in the level, the player has only 50% Hit Rate, 0% Crit Rate, and 120% Critical Damage. With every 2 points invested into the skill, the player gains a "stack" of the One-Handed Weapon Skill state, which increases the Hit and Crit Rates by +1% and adds 5% to their Critical Damage when they wield a one-handed weapon such as a Sword, Dagger, or Mace. I have it mostly working how I want using Yanfly's Buffs and States core, Critical Control, Auto Passive States, and Passive State Cases, but I'm not certain how to get the increases to the parameters to work exactly.

I feel I need to perform these actions in the note tag, but I don't know what script to use to call the player's Hit Rate and Crit Rate to change them. On top of that, I'm also not certain how to achieve what I want with the Critical Multiplier. I assume on some level it would be along the lines of:
player Hit Rate += number of stacks
player Crit Rate += number of stacks
player Crit Dmg += (5 * number of stacks)
I just don't know what scripts to call or where to put them. I'll add images from the database below for you to see, as well as paste the code in the note tag below as well.

NOTE TAG CODE:
<Critical Multiplier: +5%>
<Custom Battle Effect>
var stacks = Math.floor($gameVariables.value(1) / 2);
target.setStateCounter(18, stacks);
</Custom Battle Effect>

<Passive Condition Cases>
if ($gameActors.actor(1).isWtypeEquipped(2)) {
condition = true;
}
else if ($gameActors.actor(1).isWtypeEquipped(3)) {
condition = true;
}
else if ($gameActors.actor(1).isWtypeEquipped(4)) {
condition = true;
}
else if ($gameActors.actor(1).isWtypeEquipped(5)) {
condition = true;
}
else {
condition = false;
}
</Passive Condition Cases>
Your passive condition cases notetag is entirely incorrect. Reading the instructions for that plugin, the whole purpose is it provides a list of cases that are in English - you can't put JavaScript in there. If you know how to reference these things via code, you don't need that plugin extension installed at all, just put it into a Custom Passive Condition.

Some notes about your code (I don't know how much of it is you're learning some JavaScript vs. you just copied stuff from someplace). For one thing, in each one you're referencing $gameActors.actor(1) which seems like the completely wrong thing to do.

That means whether this passive state is active on any actor in your party will be determined by what kind of weapon actor ID 1 is wielding. You should be looking at what weapon that actor the state is on is wielding, which is why Yanfly provides the reference user.

There are a number of ways to streamline the code you have there.
- If you're only doing one thing after a conditional, you don't need braces. e.g.:
Code:
if (user.isWtypeEquipped(2))
    condition = true;

- If you have multiple things to check that have the exact same result (condition is true), instead of spending a page to list them all separately you can just use the OR operator.
Code:
if (user.isWtypeEquipped(2) || user.isWtypeEquipped(3) || user.isWtypeEquipped...etc.)
    condition = true;

- If the only thing you do after checking a conditional is to set a boolean value, you can always skip that extra command and just directly set it equal to the result of the conditional.
Code:
condition = user.isWtypeEquipped(2) || user.isWtypeEquipped(3) || user.isWtypeEquipped(4) || user.isWtypeEquipped(5);

That already brings all the code you had there down to a single line. If we use one of JavaScript's built in array methods, we can make it much more readable:
Code:
condition = [2, 3, 4, 5].some(type => user.isWtypeEquipped(type));

As far as the parameters, you can't really do what you're describing using just Yanfly. You would need a plugin that lets you dynamically recalculate the bonus that the state is giving you. Examples are Quasi's Params Plus or Hakuen's Dynamic Parameters.

The critical rate is doable, you just need to look in the instructions and see the Critical Multiplier Formula. So you'd do something like:
Code:
<Critical Multiplier Formula>
value = Math.round(value * 3+user.getStateCounter(18)*.05);
</Critical Multiplier Formula>
Thank you! I've gotten it working now! The most Javascript experience I have is a web design class I took last fall, so I'm still figuring things out it! The reason I was checking actor(1) is because the skills only affect that actor as its the player's created character, which I'm using Yanfly's party system to lock them into the party leader spot. Other party members are not affected by the player's skills that they invest into.
Fair enough, but that means those actors won't have the passive state at all - it's still less typing to just use user 😉

Good luck!

Original thread: https://forums.rpgmakerweb.com/threads/stacking-a-state-with-yanflys-buffs-and-states-core.160281/