C:\Documents and Settings\keith\Desktop\common_enemy.c

/*
=================
findEnemyWithinRadius (origin, radius)

Returns entities that have origins within a spherical area
=================
*/
edict_t *findEnemyWithinRadius (edict_t *self, edict_t *from, vec3_t org, float rad)
{
    vec3_t  eorg;
    int     j;
    float   vecLength;
    float   radSquared = ((rad * g_radius->value )* (rad * g_radius->value));
    trace_t     tr;


    if (!from)
        from = world;
    else
        from++;
    for ( ; from < &game.edicts[game.numentities]; from++)
    {
        if (!from->r.inuse)
            continue;
        if (!trap_inPVS (self->s.origin, from->s.origin))
            continue;
//      if (strcmp(from->classname, "hook") == 0 )
//          continue;
        if (!from->r.client)
            continue;
        if (from->r.solid == SOLID_NOT)
            continue;
        if (from->wf_team == self->wf_team)
            continue;
        if (from->disguised)
            continue;
        if (!from->takedamage)
            continue;
        if (from->health <= 0)
            continue;
        if (!visible(self, from))
            continue;
        for (j=0 ; j<3 ; j++)
            eorg[j] = org[j] - (from->s.origin[j] + (from->r.mins[j] + from->r.maxs[j])*0.5);

        vecLength = 0;
        vecLength += eorg[0]*eorg[0];
        vecLength += eorg[1]*eorg[1];
        vecLength += eorg[2]*eorg[2];

        if (vecLength > radSquared)
            continue;
        
        trap_Trace (&tr, self->s.origin, NULL, NULL, from->s.origin, self, MASK_SOLID);
                
        if (tr.fraction != 1.0)
            continue;

        return from;
    }

    return NULL;
}