Code:
// --------------------------------------------------------------------------------------------
function find_nearest(ENTITY* ent)
{
 var you_handle; 
 var _dist=1000;
 var _ndist;
 var dist_to_nearest;
 for(you = ent_next(NULL); you; you = ent_next(you)) 
  {
    if(you.id == goblin) 
    {
    	_ndist = vec_dist(ent.x, you.x);
    	if (_ndist < _dist) { _dist = _ndist; you_handle = handle(you); }
    }
  }
  dist_to_nearest = _dist; //nearest entity to "ent"
  you = ptr_for_handle(you_handle); //you to nearest found
  if(you)
  {
   VECTOR temp;
   vec_set(temp.x,you.x);
   vec_sub(temp.x,my.x);
   vec_to_angle(my.pan,temp);
   if(vec_dist(ent.x, you.x) < 50) _goblin_loose_hp(); //maybe take some hp when close
  }
 }
// --------------------------------------------------------------------------------------------



Code:
..
find_nearest(me);
c_move(me, vector(50*time_step,0,0), nullvector, GLIDE);
..



I took my function find_nearest and modified it. I think it should find the nearest goblin, and looks into that direction. When close to a goblin (<50) hp are taken.

greets

Edit Reason: Added the TEMP vector declaration which was missing above.

Last edited by rayp; 08/27/12 14:50.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;