Take a look at this: https://github.com/TrinityCore/TrinityCore/blob/a56a402190c885e51038df55654875cc9e875c03/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp#L491-L515
and here are some variants of the same functionality that allow more different kinds of checks on targets: https://github.com/TrinityCore/TrinityCore/blob/6.x/src/server/game/Spells/SpellScript.h#L319-L332
ps. Im not sure if these are what you are looking for, but they looked like it.