rendered paste bodyentity Spawn_FilterOutBadSpots(entity firstspot, entity playerlist, float mindist, float teamcheck)
{
local entity spot, player, nextspot, previousspot, newfirstspot;
local float pcount;
spot = firstspot;
newfirstspot = world;
previousspot = world;
spawn_allgood = TRUE;
spawn_allbad = TRUE;
while (spot)
{
nextspot = spot.chain;
// count team mismatches as bad spots
local float spotactive;
spotactive = 1;
// filter out spots for assault
if(spot.target != "") {
local entity ent;
ent = find(world, targetname, spot.target);
while(ent) {
if(ent.health < 0 || ent.health >= ASSAULT_VALUE_INACTIVE)
spotactive = 0;
ent = find(ent, targetname, spot.target);
}
}
if (spot.team == teamcheck && spotactive > 0)
{
pcount = 0;
player = playerlist;
while (player)
{
if (player != self)
if (vlen(player.origin - spot.origin) < mindist)
pcount = pcount + 1;
player = player.chain;
}
if (!pcount)
{
spawn_allbad = FALSE;
if (newfirstspot)
previousspot.chain = spot;
else
newfirstspot = spot;
previousspot = spot;
spot.chain = world;
}
else
spawn_allgood = FALSE;
}
spot = nextspot;
}
// if we couldn't find ANY good points, return the original list
if (!newfirstspot)
newfirstspot = firstspot;
return newfirstspot;
}