Item - Script that debuffs stat by 1 each turn.

I'm intending on making an item which is intended to give a temporary stat boost, but in a way for the item to debuff the stat boost by 1 each turn, until back to normal.

To be more clear
--------------------
-Actor 1 has 50 in Resistance (MDF).
-Actor 1 uses Pure Water.
-Actor 1 gains a boost in Resistance (MDF) by 50.
-Actor 1's Resistance in total is 100.
-When the actor(s)'s turn is over, Resistance boosts from Pure Water effect drops down by 1.
-Actor 1's Resistance is now 99.
-The turn passes and Actor 1's Resistance is now 98.
-And so on, until the boost is completely gone, resulting back at a stat of 50 Resistance.

Is there a script I can use for an item to achieve this effect?
@RK DracoRoy
Setup a basic state. Give the state the following notetags:

Code:
<Custom Apply Effect>
// Add bonus to the user, when state is applied
// user.addParam(paramId, value)
user.addParam(5, 100);
</Custom Apply Effect>

<Custom Turn End Effect>
// When turn ends, we just add -1, which results in decreasing it by 1
user.addParam(5, -1);

// After the decrease, check if the bonus is 0 now
if (user.paramPlus(5) == 0) {
// If it is 0, remove this state
user.removeState(stateId);
}
</Custom Turn End Effect>

This requires YEP_BuffStatesCore http://yanfly.moe/2015/12/25/yep-50-buffs-states-core/
@waynee95

Thanks to the script provided, it's working as I intended. but without any restrictions, the Pure Water item can be abused for high resistance stats.

There's Yanfly's Item Requirements: http://yanfly.moe/2017/05/12/yep-136-item-requirements-rpg-maker-mv/

But unfortunately, I don't know why this doesn't fade / disable the item. Though I prefer it to fade instead of hiding the item off the window (perhaps find some way or code inside the file to edit it to make it fade away)
------------------------------------
<Enable Requirements>
Not State: x
</Enable Requirements>
------------------------------------
I'm not in the state so that means I can use the Pure Water. And when I use the item, the actor is going through the state and yet can still use the item for stat abuse.

Either I'm doing something wrong or perhaps there's an alternative somewhere that can fade the item if I'm in the state.
@RK DracoRoy
I just tested that and you are right. The item appears to be still useable. It took really long to find the root of that issue. I already spoke to Yanfly about that issue.

To fix it, just copy this code into a new .js file and import it as a plugin. Place it BELOW YEP_ItemCore.
PHP:
Window_ItemActionCommand.prototype.isEnabled = function(item) {
    if (!item) return false;
    return $gameParty.menuActor().canUse(item);
};
@RK DracoRoy
I just tested that and you are right. The item appears to be still useable. It took really long to find the root of that issue. I already spoke to Yanfly about that issue.

To fix it, just copy this code into a new .js file and import it as a plugin. Place it BELOW YEP_ItemCore.
PHP:
Window_ItemActionCommand.prototype.isEnabled = function(item) {
    if (!item) return false;
    return $gameParty.menuActor().canUse(item);
};
Just had the same problem, got lucky that I came across a solution. Will YF fix that in his batch updates?
I haven't heard back from him. He is probably busy with the updates.

Just use my fix above for now.
@waynee95

I apologize for saying this, but I followed the exact thing you told me to do. Yes, make a blank new .js file and just copy this code to that newly created .js, and have it below ItemCore, but it's not doing a thing for me somehow.
Are there any errors on the console?
And if you place it below all plugins?
@waynee95
Never mind, I somehow managed to get it working and placed below Item Core.

If you don't mind, do you know some way to edit his Item Requirements plug-in to like grey out items instead of hiding? Look at Weapon Requirements for example, it greys out weapons that certain actors can't use, based on condition notetags.
For me it does grey the "Use" command put.
I meant in the battle scene, not on the maps. But now that you mentioned it, either it's me or the "Use" command is greyed out when you use the item on the 1st Actor, to either cure a state or power up a stat. I just did a play test on a map, starting two actors with poison state.

If you use the antitoxin item (or any item you have), to cure the 1st actor, the "Use" command is greyed out preventing you from using it on other actors in the map. Another problem Yanfly has to resolve in the Item Requirements plug-in.

Original thread: https://forums.rpgmakerweb.com/threads/item-script-that-debuffs-stat-by-1-each-turn.82891/