What you are trying to doesn't work, theren is no such method . if you click the portal and a brawler is in its way, we are still "attacking" the portal. We can only check if we are actually facing a npc or not. I could only test the distance between the altar and the player after clicking it. There would still be tons of cases where the bralwer could be positioned.
So your theory is already false for everything...
If i was really this simple I would have solved it a long time ago.
but I'll come up with a solution soon, trying to find something reliable.
Thx for the detailed post!