Stun Event not working properly working

Hello. I've been trying to create a map ability in my game that will shoot a projectile and stun an ennemy.
I managed to make most of it work, however the duration of the stun is a bit special. I don't want a duration in time but idealy in steps.

However if I store the steps in a variable it will be a global variable, meaning that if the player want to stun 2 ennemies they will share the same stun time. Is it possible to make some "independant" variable without having to create one for each ennemy ?

My B plan is to just have unlimited duration of stun on an ennemy, however player can only stun 1 ennemy at a time.
I managed to make it work, however some bugs still happen sometimes where I can stun two ennemies and I don't really understand why that is happening.

Here's a showcase of what is happening :
Stun480.gif

As you can see here, it worked fine the first 2 times but bugged on the third, and it's quite random.


Here are screens of the events I use :

1596563136507.png

This is basically the projectile and when my player fires the projectile (I use YEP_CommonEvents to activate the common event) the switch 08 : Stun turns off.

1596563244924.png

And the ennemy once the B self switch is on (I use Galv's map projectile and when a projectile touch an event, their self switch B turn ON).
look for a plugin that creates event-based self-variables.

I think there are a few, but the only one I know to exist is from Yanfly, and I don't know if it is one of his free plugins or if it has to be paid for.
Oh great, I do have all of Yanfly's plugins, could you give me the name of the plugin ?
Here you go:
Awesome, I'll look into it 🙂

Original thread: https://forums.rpgmakerweb.com/threads/stun-event-not-working-properly-working.124902/