I could add a condition to work only on mobs attacking the caster, but I want this spell to also work on, for example, enemies that are calmed or feared. They are not attacking the player while influenced, but they are enemies. I basically want to consider friendly and neutral targets the NPCs you can interact around the world.
Which condition or scripted variable can I use to filter that kind of targets?
EDIT: I think what I need is to find out what makes mobs to become hostile in the first place. For example, a Giant will always attack if you get close, so they always have to be considered enemies, even when calmed. But a city guard will not naturally attack, so they are neutral. Maybe anything to do with factions?