1. I would like to test for, or have an event that notifies me when a unit (player) is under a stun fear polymorph etc. The only thing I've found is the UNIT_FLAGS event, but couldn't find any info on how to use it.

    Events are a bit difficult. Have you run /eventrace to see if there is something else?