Making a state that only reduced its duration by specific skill

Hello everyone, let's say I want to make gun mechanic like this:
  • I made a state called "Ammo", and its duration is the amount of ammo.
  • Using a skill "Shoot" reduce the duration by one, per skill.
The closest thing is the "action end" on state's removal condition, but unfortunately it affect anything the actor do unless they're unable to do action (getting stunned/sleep for example). Is there a way to do this?
I feel like Yanfly's Buff States and Core can do what you want.

I feel like Yanfly's Buff States and Core can do what you want.
Partway at least. One part would be not giving the state a duration and having that plugin to give the state a counter to display the rounds left.

The other part...
Using a skill "Shoot" reduce the duration by one, per skill.
Is best done with Yanfly's Skill Core or Action Sequences and having the gun skills written to deduct from the state IMO.
Partway at least. One part would be not giving the state a duration and having that plugin to give the state a counter to display the rounds left.
I'm familiar with Yanfly's Buff & State Core, but idk how to give a state counter that is just number and not tied to turn/duration. And yes if i can get it, everything else should be easy enough to figure out by myself.
I'm familiar with Yanfly's Buff & State Core, but idk how to give a state counter that is just number and not tied to turn/duration.
if youre familiar with the js tags, you only need to use user.setStateCounter(stateId, x)in an apply effect or on the reload skill to set the counter to x shots.
then all your skills that uses the ammo just has to check if user.getStateCounter(stateId) is greater than 0 to determine if you can use it and then deduct one or remove the state if it was the last bullet
if youre familiar with the js tags, you only need to use user.setStateCounter(stateId, x)in an apply effect or on the reload skill to set the counter to x shots.
then all your skills that uses the ammo just has to check if user.getStateCounter(stateId) is greater than 0 to determine if you can use it and then deduct one or remove the state if it was the last bullet
Thank you! It took a while to figure out how to reduce the counter via action sequence, but I get it working perfectly!

For anyone who want to try it, I use eval: user.addStateCounter(stateId, -1) to reduce the counter by 1. Then put this on the ammo state:

<Custom Action End Effect>

if (user.getStateCounter(stateId) <= 0) {

target.removeState(stateId);

}

</Custom Action End Effect>

Original thread: https://forums.rpgmakerweb.com/threads/making-a-state-that-only-reduced-its-duration-by-specific-skill.183286/