/*
** Usage:
** inst = find_enemy(object);
**
** Arguments:
** object an object to look for
**
** Returns:
** inst nearest instance of given (object) where
** local variable "team" is different than
** the calling instance, or keyword "noone"
** if none found
**
** copyright (c) 2006, John Leffingwell
** www.planetxot.com
*/
var ds,selected;
ds = ds_priority_create();
ds_priority_add(ds,noone,100000);
with (argument0) if (team != other.team) ds_priority_add(ds,id,distance_to_object(other.id));
selected = ds_priority_find_min(ds);
ds_priority_destroy(ds);
return selected;