[SOLVED]Stat increase using a formula via Yanfly Base Param and Buff/States

I apologize for my inability to figure out Javascript. I can only figure out the "Lunatic" stuff of Yanfly mods when the instructions are made extremely clear. :hswt:

So, I'm trying to make a state that applies to all allies and increases their MAT by a flat amount that is determined by a formula. The "stat flat: +x" notetag of the Base Param plugin does not seem to accept formulas in its "x". So I'm trying to do so by way of making a custom tag from buff/states core.

This is the tag I'm putting on the state. It doesn't appear to do anything.

Code:
<Custom Apply Effect>
$gameActors.actor().addMat(5 + 2 * user.luk);
SceneManager._scene._statusWindow.refresh();>
</Custom Apply Effect>

I think I'm just not using the right wordage/syntax for adding a stat onto an actor. I've tried things like "user" and... I forget what else. Maybe I'm not supposed to use Buff/State custom tags for this?
I think the first problem is here: $gameActors.actor().addMat(5 + 2 * user.luk);
If you wanna give the user a MAT boost based on LUK, you can just type user.addMat(5 + 2 * user.luk);
But be aware that this bonus will not be removed even the state is gone. You will have to remove it manually.

Besides:
SceneManager._scene._statusWindow.refresh();> (Remove that >)
Also, actor expects an actor ID in its brackets, otherwise you're not referring to any actor. I'm not sure if the refresh is necessary, either? 😅

I'd suggest trying something like this:
Code:
<Custom Apply Effect>
user._bonusMat = 5 + 2 * origin.luk;
user.addMat(user._bonusMat);
</Custom Apply Effect>

<Custom Remove Effect>
user.minusMat(user._bonusMat);
user._bonusMat = undefined;
</Custom Remove Effect>
This will apply a mat bonus to the state bearer, equal to 5 plus twice the luk of the one who applied the state; swap origin for user if you want it based on the state bearer's luk instead. The "on remove" tag is necessary because addMat is otherwise permanent. 😤

I think this would be the equivalent without Yanfly's Base Parameter Control plugin:
Spoiler
Code:
<Custom Apply Effect>
user._bonusMat = 5 + 2 * origin.luk;
user.addParam(4, user._bonusMat);
</Custom Apply Effect>

<Custom Remove Effect>
user.addParam(4, -user._bonusMat);
user._bonusMat = undefined;
</Custom Remove Effect>
If you don't mind using another plugin, you can use my flat stat bonus states plugin for this.
Its notetags are evaled and you'd be able to do this with a simple:
<matkB: 5 + user.luk>

Otherwise caethryl's solution looks like it'd work.
If you don't mind using another plugin, you can use my flat stat bonus states plugin for this.
Its notetags are evaled and you'd be able to do this with a simple:
<matkB: 5 + user.luk>

Otherwise caethryl's solution looks like it'd work.
I'm really interested in your plugin. Still finding a way to work around with this thing, but so lazy to remove the stats manually. Does your plugin also remove the bonus stats when the state is gone?
Yes.

It works by altering the stat calculations by adding the state notetags to the value, so the base stats are never altered. If you have no state there is no notetag value to eval and add.

I wonder what would be the point if you'd keep modifications once the state wears out. You'd better just use the modify parameters function then.
@caethyril 's solution seems to work! Thanks! Yeah, I don't know when window refreshes are necessary or not. I have a plugin just for testing this to double check character stat's mid-fight, so I wanted to make absolutely sure those numbers were displaying correctly. Sometimes stuff doesn't look like it's working and it actually is, it just needs to refresh :hswt: I don't know. I've encountered that kind of situation once, and I've read some similar posts here where people were refreshing (or otherwise) in the middle of their code.

@Astfgl66 I appreciate the help! I am getting to the point where I just... have so many plugins, heh. So I try to get by with the ones I have before adding more.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/solved-stat-increase-using-a-formula-via-yanfly-base-param-and-buff-states.110471/