function spawnhumans( var num )
{
STRING* s = "";
STRING* s1 = "humanspawn"; // this is the name of a model already in the compiled level
var i;
var found;
VECTOR* loc = vector(0,0,0);
ENTITY* spawnpoint;
spawnpoint = ent_next (NULL);
if ( spawnpoint == NULL ) spawnpoint = ent_next (NULL);
str_for_entname ( s, spawnpoint); // get the name of the entity whe just set spawnpoint to
while( !(str_cmpni (s, s1)) ); // if the name of the ent is not "humanspawn" then its the wrong one and keep looking
{
spawnpoint = ent_next (spawnpoint);
if ( spawnpoint == NULL ) spawnpoint = ent_next (NULL);
str_for_entname ( s, spawnpoint);
wait(1);
}
spawnpoint.group = 1; //
//c_ignore( 1 );
loc.x = spawnpoint.x;
loc.y = spawnpoint.y;
loc.z = spawnpoint.z;
for( i = 1; i <= num; i++ )
{
c_ignore( 1 );
found = c_scan (loc, vector(0,0,1), vector(360,0,500), SCAN_ENTS | IGNORE_WORLD | IGNORE_MAPS );
while ( found > 0 )
{
loc.x = loc.x+(-100+random(200));
loc.y = loc.y+(-100+random(200));
c_ignore( 1 );
found = c_scan (loc, vector(0,0,1), vector(360,0,500), SCAN_ENTS | IGNORE_WORLD | IGNORE_MAPS );
wait(1);
}
if ( i == num )
{
player = ent_create("guy5.mdl", vector(loc.x,loc.y,loc.z), updatecharacter);
}else{
ent_create("guy5.mdl", vector(loc.x,loc.y,loc.z), updatecharacter);
}
wait(1);
}
}