Off the top of my head, the closest script that performs that function is YEZ Enemy Scan Query. Though this could be evented (quite tediously so), some minor edits to that could be sufficient to what you want.
However, I'm busy with other requests so I won't be able to do it anytime today. I hope someone else helps you out.