/* ================ SelectFarthestDeathmatchSpawnPoint ================ */ edict_t *SelectFarthestDeathmatchSpawnPoint (void) { edict_t *bestspot; float bestdistance, bestplayerdistance; edict_t *spot; spot = NULL; bestspot = NULL; bestdistance = 0; while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) { bestplayerdistance = PlayersRangeFromSpot (spot); if (bestplayerdistance > bestdistance) { bestspot = spot; bestdistance = bestplayerdistance; } } if (bestspot) { return bestspot; } // if there is a player just spawned on each and every start spot // we have no choice to turn one into a telefrag meltdown spot = G_Find (NULL, FOFS(classname), "info_player_deathmatch"); return spot; }
void DBall_SelectSpawnPoint(edict_t *ent, vec3_t origin, vec3_t angles) { edict_t *bestspot; float bestdistance, bestplayerdistance; edict_t *spot; char *spottype; char skin[512]; if (!ent) { return; } strcpy(skin, Info_ValueForKey(ent->client->pers.userinfo, "skin")); if (!strcmp(dball_team1_skin->string, skin)) { spottype = "dm_dball_team1_start"; } else if (!strcmp(dball_team2_skin->string, skin)) { spottype = "dm_dball_team2_start"; } else { spottype = "info_player_deathmatch"; } spot = NULL; bestspot = NULL; bestdistance = 0; while ((spot = G_Find(spot, FOFS(classname), spottype)) != NULL) { bestplayerdistance = PlayersRangeFromSpot(spot); if (bestplayerdistance > bestdistance) { bestspot = spot; bestdistance = bestplayerdistance; } } if (bestspot) { VectorCopy(bestspot->s.origin, origin); origin[2] += 9; VectorCopy(bestspot->s.angles, angles); return; } /* if we didn't find an appropriate spawnpoint, just call the standard one. */ SelectSpawnPoint(ent, origin, angles); }
/* ================ SelectRandomDeathmatchSpawnPoint go to a random point, but NOT the two points closest to other players ================ */ edict_t *SelectRandomDeathmatchSpawnPoint (void) { edict_t *spot, *spot1, *spot2; int count = 0; int selection; float range, range1, range2; spot = NULL; range1 = range2 = 99999; spot1 = spot2 = NULL; while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) { count++; range = PlayersRangeFromSpot(spot); if (range < range1) { range1 = range; spot1 = spot; } else if (range < range2) { range2 = range; spot2 = spot; } } if (!count) return NULL; if (count <= 2) { spot1 = spot2 = NULL; } else count -= 2; selection = rand() % count; spot = NULL; do { spot = G_Find (spot, FOFS(classname), "info_player_deathmatch"); if (spot == spot1 || spot == spot2) selection++; } while(selection--); return spot; }
/* * SelectRandomDeathmatchSpawnPoint * * go to a random point, but NOT the two points closest * to other players */ static edict_t *SelectRandomDeathmatchSpawnPoint( edict_t *ent ) { edict_t *spot, *spot1, *spot2; int count = 0; int selection, ignore_team = 0; float range, range1, range2; spot = NULL; range1 = range2 = 99999; spot1 = spot2 = NULL; if( ent && GS_TeamBasedGametype() ) ignore_team = ent->s.team; while( ( spot = G_Find( spot, FOFS( classname ), "info_player_deathmatch" ) ) != NULL ) { count++; range = PlayersRangeFromSpot( spot, ignore_team ); if( range < range1 ) { if( range1 < range2 ) { range2 = range1; spot2 = spot1; } range1 = range; spot1 = spot; } else if( range < range2 ) { range2 = range; spot2 = spot; } } if( !count ) return NULL; if( count <= 2 ) { spot1 = spot2 = NULL; } else { if( spot1 ) count--; if( spot2 && spot2 != spot1 ) count--; } selection = rand() % count; spot = NULL; do { spot = G_Find( spot, FOFS( classname ), "info_player_deathmatch" ); if( spot == spot1 || spot == spot2 ) selection++; } while( selection-- ); return spot; }