SERVER: Smarter Co-Op Spawn Picking

This commit is contained in:
Steam Deck User 2023-01-31 16:12:06 -05:00
parent 549df8f7e0
commit 19e119945c

View file

@ -557,10 +557,26 @@ void() PlayerSpawn =
pl1 = self; pl1 = self;
} }
// Solo Play, pick any Spot. float viable_spawnpoint = false;
if (player_count == 0) {
// if the mapper doesn't have the co-op ents set up, just plop everyone at the
// normal start.
if (find(world, classname, "info_player_tank") == world &&
find(world, classname, "info_player_nikolai") == world &&
find(world, classname, "info_player_takeo") == world &&
find(world, classname, "info_player_doctor") == world) {
spawnpoint = find(world, classname, "info_player_start");
viable_spawnpoint = true;
}
//
// pick a random spawn point regardless of solo or co-op
//
while(!viable_spawnpoint) {
float number = random(); float number = random();
// assign one of the spawnpoints
if (number < 0.25) if (number < 0.25)
spawnpoint = find(world, classname, "info_player_tank"); spawnpoint = find(world, classname, "info_player_tank");
else if (number < 0.50) else if (number < 0.50)
@ -569,17 +585,25 @@ void() PlayerSpawn =
spawnpoint = find(world, classname, "info_player_takeo"); spawnpoint = find(world, classname, "info_player_takeo");
else else
spawnpoint = find(world, classname, "info_player_doctor"); spawnpoint = find(world, classname, "info_player_doctor");
} else {
switch(self.playernum) { float found_player_here = false;
case 1: spawnpoint = find(world, classname, "info_player_tank"); break;
case 2: spawnpoint = find(world, classname, "info_player_nikolai"); break; entity ents_in_spawn_range = findradius(spawnpoint.origin, 32);
case 3: spawnpoint = find(world, classname, "info_player_takeo"); break;
case 4: spawnpoint = find(world, classname, "info_player_doctor"); break; // check if there's a player in the way
default: break; while(ents_in_spawn_range != world) {
} if (ents_in_spawn_range.classname == "player")
found_player_here = true;
ents_in_spawn_range = ents_in_spawn_range.chain;
} }
// Mapper doesn't have our co-op spawn set up.. // no player in the way, this spawn is good.
if (found_player_here == false)
viable_spawnpoint = true;
}
// Mapper doesn't have our specific co-op spawn set up..
if (spawnpoint == world) if (spawnpoint == world)
spawnpoint = find(world, classname, "info_player_start"); spawnpoint = find(world, classname, "info_player_start");