How do you create a battle item that only works on specific troop types?

In my current project, I've created an item called "rat deterrent". I'd like it to allow the party to instantly flee battles against rat troops.

The thing is, I'm not sure how to make sure an item only works against specific types of troops (aka, rats). I assumed I could make a common event with a conditional but it doesn't seem like conditionals have the proper options to allow something like that.
several ways

you can make a damage element "rat deterrent" and make all other enemies immune to it but give the rat a weakness against that element. Then simply have the item do damage to kill the rats.

you can give each troop with rats a troop event that triggers on turn 0 and activates a switch "rat".
then in the common event with the item check if the switch is ON, if yes escape all rats and turn the switch off

There are a few other methods especially with scripts, but I think those two are the easiest to implement.
several ways

you can make a damage element "rat deterrent" and make all other enemies immune to it but give the rat a weakness against that element. Then simply have the item do damage to kill the rats.

you can give each troop with rats a troop event that triggers on turn 0 and activates a switch "rat".
then in the common event with the item check if the switch is ON, if yes escape all rats and turn the switch off

There are a few other methods especially with scripts, but I think those two are the easiest to implement.
Thanks! I tried the second option with the troop event, it worked perfectly.
it worked perfectly.
no, it doesn't - because I forgot a case.

If you have a rat troop but the player doesn't use the rat deterrent, the switch will stay on and the rat deterrent would be usable on a non-rat-troop next.

you'll need the switch turned off before next battle if there is no rat in that troop.

again there are several ways to do that, but most probably the best for you is to have a turn 0 event everywhere and turn the rat switch off where it won't work.

the additional advantage for this method is that each turn 0 event can handle multiple turn 0 functions, like additionally insect repellant or anti-whatever.
no, it doesn't - because I forgot a case.

If you have a rat troop but the player doesn't use the rat deterrent, the switch will stay on and the rat deterrent would be usable on a non-rat-troop next.

you'll need the switch turned off before next battle if there is no rat in that troop.

again there are several ways to do that, but most probably the best for you is to have a turn 0 event everywhere and turn the rat switch off where it won't work.

the additional advantage for this method is that each turn 0 event can handle multiple turn 0 functions, like additionally insect repellant or anti-whatever.
I actually already figured that, so I just set the enemy events to manually turn off the switch after every rat encounter. Tested it a few times and it didn't seem to detect any other troops as rats, so that seems to have done the trick.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-you-create-a-battle-item-that-only-works-on-specific-troop-types.145705/