Vampyre,
It should be done exatly the same way that it is for the player object.
Let's say you use a simple distance check between enemy and player to see if the enemy should attack or not, and if you're close enough, it may even become more accurate etc.
Well, what you then do, is extend that so that the enemy checks to see who is closer regardless if it is enemy or player. Then, they attack that object.
If you want more intelligent attacks, simply develop the more advanced stuff for the player first, then expand it to encompass a check for all enemies and player alike
Jess.

Team EOD :: Programmer/All-Round Nice Guy
Aust. Convention!