MV Items that add or remove the "steps" in states that autoremove after a number of steps.

I was thinking of simple ways to implement survival needs and it occurred to me that states can have a number of steps after which the state autoremoves. I'm hoping to have items that interact with this step value, then use one of the Yanfly plugins to add a different state based on the step value. For example, the Full state would be set to be replaced with Hunger after a number of steps, and this would be delayed by eating food.

It would also help if, when hungry, a certain step value needs to be reached before food replaces hungry with full. I don't know how the actual values work in engine, though. Do steps tick up when walking or tick down?
Using Yanfly's Skill Core plugin(YEP_SkillCore) you could add the following notetag in the note box of an item in order to modify the step counter:

Spoiler: Examples
JavaScript:
// Example 1 - Decrease the amount of steps for state id 1 by 10.

<After Eval>
const stateId = 1; // Make sure to replace this number
const value = 10; // Make sure to replace this number
const minValue = 0;

if (target._stateSteps[stateId] > 0) {
    const newValue = target._stateSteps[stateId] - value;
    target._stateSteps[stateId] = Math.max(newValue, minValue);
}

if (target._stateSteps[stateId] <= 0) {
    target.removeState(stateId);
}
</After Eval>

// Example 2 - Increase the amount of steps for state id 1 by 10,
// but prevent values over 100.

<After Eval>
const stateId = 1; // Make sure to replace this number
const value = 10; // Make sure to replace this number
const maxValue = 100; // Make sure to replace this number

if (target._stateSteps[stateId] > 0) {
    const newValue = target._stateSteps[stateId] + value;
    target._stateSteps[stateId] = Math.min(newValue, maxValue);
}
</After Eval>

As for your question "Do steps tick up when walking or tick down?"
The answer is that the steps go down.

EDIT:
I also took a look at YEP_BuffsStatesCore to check if it would be possible to use one of the notetags to trigger on-map effects, but it seems like the 'Custom Regenerate Effect' and 'Custom Turn End Effect' are strictly fot battle.
I altered Tea's Easy Steps Counts for MZ to MV which uses
a variable (you can add many variables here and add or remove
the steps from the variable.

so you have control how steps works, by dynamicly from default
may not always work the way you want because of conflicts.

using a variable for the steps is easier.

​

EDIT:
I also took a look at YEP_BuffsStatesCore to check if it would be possible to use one of the notetags to trigger on-map effects, but it seems like the 'Custom Regenerate Effect' and 'Custom Turn End Effect' are strictly fot battle.
In that case, I'd likely need to have some other system checking the steps left on a state. I'd need to have it check every tick, wouldn't I? Unless the engine still keeps track of "steps" even if a state doesn't have "remove by walking" checked. Because otherwise, all it would take to break the system is for the state to run out of steps and be removed before the system can check.

I suppose I could have it be purely binary, either Hungryor Full. Then the system need only check if the Fullstate is active and add Hungryif not. But then it has no way to distinguish ifFullorHungryhas expired, only that neither are currently active. Which means I can't apply a different penulty forHungryexpiring.
I altered Tea's Easy Steps Counts for MZ to MV which uses
a variable (you can add many variables here and add or remove
the steps from the variable.

so you have control how steps works, by dynamicly from default
may not always work the way you want because of conflicts.

using a variable for the steps is easier.
Adding universal variables for this would mean four whole sets of variables. And if we're tracking them with variables, steps would be redundant.

Original thread: https://forums.rpgmakerweb.com/threads/items-that-add-or-remove-the-steps-in-states-that-autoremove-after-a-number-of-steps.182086/