Categorizing enemies and then using that to check for immunities to spells

Basically what I am looking for is a way to add a category to aa monster/enemy to group similar ones:

Undead
  1. Zombie
  2. Skeleton
  3. Wraith
Giants
  1. Ogres
  2. Trolls
  3. Cyclops
Now say I want a cleric to have a spell called "Turn Undead" that they cast at a troop made up of a skeleton, a zombie, a troll , and an ogre, the only the creatures categorized as undead would receive damage.

I've tried searching but most solutions are for an MV version and not MZ. I'm open to either a plugin or scripting/notetags, etc. But think this would make it easier than having to add each troup id in a damage check equation.
you didn't find any plugin or script because this is usually done by default engine without anything else.

you define damage elements in your database, like "holy" or "Acid" or whatever.
then you give all enemies fitting damage rates, with the Ogre getting 0% Holy and the undeads getting 100% damage from holy.
third step is to make the skill do holy damage, and all enemies will get no, partial, full or greater damage based on their damage rate to that element.
Damage rates lower than 100% stand for resistances (reduced damage), and rates greater than 100% will be weaknesses (increased damage from that).
Thanks, I'll give that a try.
I used the element system, but I also just used the enemy types as elements. I made the zombies weak against the 'undead'. element A sword that deals more damage to undead deals "undead" damage. I just didn't visually display those elements in status screens and such, and use plug-ins for multiple elements.
Edit: Visustella's Free ElementStatus Core can do what you are asking with traits if you think about it. Use states that assign weaknesses.

Original thread: https://forums.rpgmakerweb.com/threads/categorizing-enemies-and-then-using-that-to-check-for-immunities-to-spells.143327/