MV Skill applying state when it shouldn't be

So I've been doing some light plugin development within the last few months and recently I've been trying to make a plugin that allows for the modification of a state's infliction chance with note tags

I'm getting into a semi-usable state however I'm encountering an issue where a skill's state will be inflicted regardless of the if it passed the check to do so.


Spoiler: Images
1772053403479.png

1772053433312.png

1772053480011.png

1772054428335.png

^ - Ignore the "normal chance: 1", that was for the enemy using the guard command.
^ - the 'normal math.random' is only visible because I setup the math.random to a variable and had the log appear before it so I could see with my eyes that chance was NOT greater than math.random
If you look at my attached plugin with the pictures, the state is applied without ever sending the chance variable to the console using console.log which means it failed the check and the state shouldn't have been added, but it was anyway. The skill itself doesn't use any action sequence or evals or anything else that would apply the state and bypass the check, and the equipment doesn't have a chance to apply the state so nothing else should be impacting this.

I assumed it must have been another plugin causing a conflict but there was only one plugin (yanfly battle engine core) which did use it, but even after I commented out the potentially offending code from that plugin it still happened. I went back to the 'rpg_' js files to see if anything else used the addstate function but there was nothing else that I could find that I think would be causing this issue. I went over my code and my plugin list again but again there was nothing, I carried my plugin over to a default project and it still happened.

This issue has left me stumped, so I'm putting this here before I go to work in case someone else can see the issue.
Maybe I'm wrong, but from what I can see you are appending "Game_Action.prototype.itemEffectAddAttackState" and "Game_Action.prototype.itemEffectAddNormalState".

So there's now two rolls giving each state two chances to be applied. By the defaut system, and then by your new code.

What is happening if you comment the lines 96 and 121?
Maybe I'm wrong, but from what I can see you are appending "Game_Action.prototype.itemEffectAddAttackState" and "Game_Action.prototype.itemEffectAddNormalState".

So there's now two rolls giving each state two chances to be applied. By the defaut system, and then by your new code.

What is happening if you comment the lines 96 and 121?
I don't know how that worked at first but you were right because commenting that out seemed to fix it.
I assumed that append thing was semi-mandatory/recommended practice, but I'll keep this experience in mind going forward.
thanks for the help!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/skill-applying-state-when-it-shouldnt-be.182627/