The first thing I wanna do is NOT use the Alliance line in mq2melee if there's only 1 of that class - it'd just be wasted endurance/mana.
I know it could be done for zerkers by ${SpawnCount[berserker PC radius 100 zradius 50]}, but I figured there were a better way to do it.
TLO:SpawnCount - MacroQuest Wiki
Spawn Search - MacroQuest Wiki
You could try guildname assuming your raid is limited to a single guild.
you could specify group
Also consider the use of multiline ;
Multiline - MacroQuest Wiki
I'm not sure of how the specifics of how alliance work. But if you're searching for group members you should be able to search ${SpawnCount[berserker group} as opposed to searching for a pc in a radius zradius. If it is a member of the group an you don't want mercenaries considered I suppose you could readd the check for it being a pc. I'm not in game and have uninstalled EQ until I can get around to moving it to my secondary drive as my m.2 is more power than I need to run EQ and also limited on space, however my Hybrid drive has plenty of space lol. But you'll likely want them within range of casting the spell/ability mentioned so the original method likely would be better than checking the entire zone.
If using it for a specific class you can use your previous line but changing out the radius and pc with a group option. However SpawnCount to my knowledge is limited to the zone. You holyshit is going to accept a single if command, but with the use of multiline you could do holyshit0=/if (${Group}) /multiline ; /if (${SpawnCount[berserker group} > 1) /dothethingiwanted ; /if (${SpawnCount[anotherclass group} > 1) /dothethingiwanted ;
etc until you've got each class listed as needed for this particular spell. Basically the holyshit will use some base case to check if it should run the multiline checks at all. IE: I never want to use this if I'm not in a group so I only want to check for group to not equal null or 0, but if it returns something other than null or 0 then try all these lines of code. Obviously this multiline is inherantly flawwed as if there is more than 2 berserker it will fire the command and then immediately check the next class for multiples and if that is also true it will try to fire it again. Worst case scenario would likely be it will attempt to fire something twice that may or may not be ready and tell you a 1 or 2 times that it isn't ready yet. Also, it will always fire it for the class that you list first if it returns true so you would have to prioritize the order you place them in that multiline setup. So if it is more important that the berserker get the buff then they would be listed first, and the second most important one be listed second etc. this would of course assume you're doing it with a holyshit.
Additional checks can be added to each one of course by putting more conditions in the checks with &&, also consider adding the && to check if the skill/ability/item/aa is ready as part of your base case, IE: If I'm in a group and the ability in question is ready then check all these classes for multiples.
For a check on each class you would probably want to know if they already have the buff or not. This would mean targeting them first unless you're using netbots (which I'm unfamilar with). This is clearly a complicated thing to do in a single holyshit and something this technical would require a macro to be effective. Which bring me to my next point. If you don't typically have a macro running at all times then consider making a macro that is fired by this holyshit that will in fact count the members of the group and check them for the buff and target and fire the buff if needed. The macro wouldn't run in a loop and thus just go to a /end once it reaches the end of the sub main()
There's honestly so many ways to handle things like this that sometimes it is hard to know the best way to do things. But as with most things with programming it all depends on individual circumstances and how it would best be handled for you.