Basically what I want is to cast a spell on mouseover if there is one, and if there isn't one, then cast it on my current target. Version for both enemy and ally if they are different

I've tried:
/cast [@mouseover,exists,harm,nodead] (only casts moseover, doesnt work on target)

and bunch of other, similar ones, with [target@mouseover] etc.

every single one of these just won't cast if i don't have mouseover