How To Lower Parameters Through Yanfly Notetags? (Stockpile)

Hi, so I'm currently trying to make a Frost effect for my game, and what I want it to do is reduce agility and the overall damage dealt with each stack. I'm currently testing it by having it apply to the current actor I'm using and replacing Agility with Defense so that I can visibly see if the change in damage. The damage-reducing effect works fine, but the lowering Defense part is not working and will prevent the state from stacking occasionally. Here's the code any help?

Code:
<Custom Apply Effect>
// Default the stockpile stacks to 0.
user._frost = user._frost || 0;
// Increase the stockpile stack by 1
user._frost += 1;
user.addDef(-0.15 * user._frost);
// Cap the stockpile stack at 4
user._frost = Math.min(user._frost, 4);
// Update the state counter for the stockpile stack
user.setStateCounter(stateId, user._frost);
</Custom Apply Effect>

<Custom Remove Effect>
// Set the user's stockpile stack to 0
user._frost = 0;
// Update the state counter for the stockpile stack
user.setStateCounter(stateId, user._frost);
</Custom Remove Effect>

<Custom Confirm Effect>

// Check if the user is delivering physical damage.

if (this.isPhysical() && value > 0 ) {

// Get the current number of stacks. Min 0, Max 4.
var stacks = user._frost;

// Calculate the extra damage rate from stacks.
var rate = 1.00 + stacks * -0.10;

// Round the damage upward.

value = Math.ceil(value * rate);

}

</Custom Confirm Effect>
1 - where did you get addDef() from? There's no such function.

2 - if it worked, your state would permanently screw up the target. You're trying to lower defense by increasing amounts, not keeping track of how much you've lowered it, and you don't undo it when the state goes away.
1 - where did you get addDef() from? There's no such function.

2 - if it worked, your state would permanently screw up the target. You're trying to lower defense by increasing amounts, not keeping track of how much you've lowered it, and you don't undo it when the state goes away.
I made another state that sticks Critical using a similar state and it seems to work, but wasn't aware it was permanently increasing the character's critical rate. Since I presumed that Critical version worked, it would work the same since I'm just changing the affected stat. The one that works looks like this
Code:
user.addCri(0.15 * user._critstack);
. But what would the appropriate code to use since I just want the buff to last while the state is applied?
I made another state that sticks Critical using a similar state and it seems to work, but wasn't aware it was permanently increasing the character's critical rate
how did you test that? addCri() isnt a a function in the base engine either. are you using a plugin that adds that? cause otherwise, that state isnt doing anything
I made another state that sticks Critical using a similar state and it seems to work...The one that works looks like this
That also doesn't exist. So it either doesn't work or it's coming from a plugin. If the latter, you need to know what plugins you're using code from in order to know what it does and tell us that you're using the plugin.

Either way, for sure it has the same logical problem - you're adding to critical and never resetting it.

But what would the appropriate code to use since I just want the buff to last while the state is applied?
Yanfly's plugins don't do that. You'd either have to do repeated addParam(), keep track of how much you're taking, then reverse it with another addParam() when the state leaves; or use a plugin like Hakuen Studio's Dynamic Parameters.
how did you test that? addCri() isnt a a function in the base engine either. are you using a plugin that adds that? cause otherwise, that state isnt doing anything
I'm using multiple Yanfly Plugins, I haven't been able to find the plugin with the code I use for the Critical stack effect, but the effect has definitely been working whenever I test it.
That also doesn't exist. So it either doesn't work or it's coming from a plugin. If the latter, you need to know what plugins you're using code from in order to know what it does and tell us that you're using the plugin.

Either way, for sure it has the same logical problem - you're adding to critical and never resetting it.


Yanfly's plugins don't do that. You'd either have to do repeated addParam(), keep track of how much you're taking, then reverse it with another addParam() when the state leaves; or use a plugin like Hakuen Studio's Dynamic Parameters.
So would it be something like this?

Code:
<Custom Apply Effect>
// Default the stockpile stacks to 0.
user._frost = user._frost || 0;
// Increase the stockpile stack by 1
user._frost += 1;
user.addParam(4)(0.15 * user._frost);
// Cap the stockpile stack at 4
user._frost = Math.min(user._frost, 4);
// Update the state counter for the stockpile stack
user.setStateCounter(stateId, user._frost);
</Custom Apply Effect>

<Custom Remove Effect>
// Set the user's stockpile stack to 0
user.minusParam(4)(0.15 * user._frost);
user._frost = 0;
// Update the state counter for the stockpile stack
user.setStateCounter(stateId, user._frost);
</Custom Remove Effect>

<Custom Confirm Effect>

// Check if the user is delivering physical damage.

if (this.isPhysical() && value > 0 ) {

// Get the current number of stacks. Min 0, Max 4.
var stacks = user._frost;

// Calculate the extra damage rate from stacks.
var rate = 1.00 + stacks * -0.10;

// Round the damage upward.

value = Math.ceil(value * rate);

}

</Custom Confirm Effect>
No.

It's never helpful to guess at code syntax - if you just Googled it, you would find threads with examples as well as the pinned thread of MV script calls. All guessing does is waste your time.

There's no such function as minusParam, and no functions take arguments in two sets of parentheses like that.

From the aforementioned pinned thread of script calls:
1723639753127.png


Also, the math itself is still wrong.

You're making the target gain a different amount each time the state is applied, but only removing one amount when it ends. Do the math out, it won't be equal.

The dynamic parameters plugin I suggested to you previously is a much better solution for what you're trying to do. It will do all the math on its own and it won't require you to guess at code.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-lower-parameters-through-yanfly-notetags-stockpile.171089/