Make a skill usable only if the target is has no buff/debuff on a certain stat

The Rpg maker vx ace AI makes enemies that have buff/debuff skills use them randomly, and this makes the battle awkward because they keep just wasting turns buffing themselves when they already are. Same thing with the debuff skill (towards the actors).
I'd like to have a check condition that prevents the enemy using a buff/debuff skill if the target already has the buff/debuff RELATIVE TO ONLY a certain stat.
Ex.
TURN 1
[Enemy wants to use buff skill for ATK on itself]
[Checks if already has]
* Enemy uses buff skill for ATK
TURN 2
[Enemy wants to use buff skill for ATK on itself]
[Checks if already has] => [Enemy doesn't use that skill]
* Enemy uses another X action


I don't know if scripts for this have already been made (if so thats perfect).
I don't know either if it's possible by events, but I would like to avoid that.
Thanks 🙂
there are a few problems with that idea, and if you want to implement it exactly as described you'll have to look for a script that rewrites part of the skill handling.

but why don't you go the other way and prevent the critical skills from being randomly cast and only cast them if they are usefull?
The enemy action pattern actually contains several ways to make that happen.

the simplest solution would be to have that skill only used every n turns
another option is to use states instead of bufs and change the skill pattern on state condition
third option would be to make the skill conditional on a switch and have a troop event check at the end of every turn if the switch should be ON or OFF
and several other options depending on how much into the action pattern you want to go...

Original thread: https://forums.rpgmakerweb.com/threads/make-a-skill-usable-only-if-the-target-is-has-no-buff-debuff-on-a-certain-stat.146742/