Problem with Common Event

Not sure if this is the right place to put this, but I seem to be having some trouble with a Common Event not playing when in Battle.

I've set up both a Skill and an Item to play through a common event. The main idea is to check if the target has a specific state, and if it does, run through a quick event removing specific state and creating an item. Neither of them seem to actually run the common event though, and it just automatically goes to the next actor's turn. Also sorry if the formatting is weird, figured Spoilers were better than just a bunch of stuff right in everyone's face.
Spoiler: Skill
Illustration2.png

I'm also having trouble with custom skill costs, but that's a plugin issue that I'm no worried about right now

Spoiler: Item
Illustration3.png

Tried altering the state rate to see if that would do anything, but no.

Spoiler: Common Event
Illustration.png

I was wondering if the Trigger was causing the issue, but I couldn't find a way to make a skill change a Switch to trigger the event. I tried placing it in the Troop as well, but it didn't do anything. There are 8 of these sections total, for enemies 1-8 as I was unable to find a way to get it to specifically look at the enemy targeted by the skill/item

Spoiler: I am using some plugins, which I've included here
Illustration4.png
So you are not getting any text displayed when you use this skill or item? Are you sure the enemies are affected by those states?

Throw a Show Text command right at the top of the common event, just to confirm that it actually IS running it.

I wonder if the state is added AFTER the common event is run.
I think that might actually be the issue. I stupidly had the state give state resist to the state, thinking it would stop it from being applied again. Looks like it might just be adding and instantly removing it.
Can’t test it quite yet, but will do that asap
Removing that seems to have helped, now I just have an issue of the animation playing on the wrong target. I think I might be able to solve that by putting the animation on the item/skill rather than in the common event though.

That being said, now the change item + doesn't seem to be adding the item to inventory.
So after a little more testing, the second If statement doesn't seem to be recognizing the passive state I made with the plugin, not sure how to go about fixing that though. I tried using the script from the help file ( a.states().includes($dataStates[10]) ) but it keeps giving the error of "a is not defined" in the dev tools thing.
Double-post notice: @4nzkiwi

a and b are only available in the damage formula. I think there IS something you can use in a common event (Control Variables, script box) to get the id or the position of the last target, but I'm sorry I don't know what that is off the top of my head, and don't have time to look for it. If you search for something like "last target" you might be able to find it.
My mistake sorry! I must have totally missed the edit button. I'll be sure to see what I can find on that last target thing, Thanks 😀

I actually found a workaround to what I was trying to achieve, much simply. Each troop will have an event per enemy check if the actor is wearing a specific item, then have a chance to provide essence. Completely bypasses the need to find the target ID. Might be a bit more complicated in the long run with having to add it to every troop, but for someone like me who knows nothing of coding it works 👍

Original thread: https://forums.rpgmakerweb.com/threads/problem-with-common-event.134949/