Slam is a neutral hostile spell like Thunder Clap.
Then, I think you need to pick every units within X range of casting unit matching belongs to an enemy, store these units in a Unit Group variable and use the for each integer A, create a dummy and order last created unit to cast hex....!
If u don't know how to do, I can explain step by step to you.