]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
test only 10 teammates
authorMartin Taibr <taibr.martin@gmail.com>
Thu, 3 Nov 2016 13:44:31 +0000 (14:44 +0100)
committerMartin Taibr <taibr.martin@gmail.com>
Thu, 3 Nov 2016 13:44:31 +0000 (14:44 +0100)
mutators.cfg
qcsrc/common/mutators/mutator/spawn_near_teammate/sv_spawn_near_teammate.qc

index 9ad8ceffd2272c320ffa71e778e1a529c1e68da3..b5e9b76df68c7dcc9a962a191b19fe54b63a997e 100644 (file)
@@ -125,6 +125,7 @@ seta cl_spawn_near_teammate 1 "toggle for spawning near teammates (only effectiv
 set g_spawn_near_teammate 0 "if set, players prefer spawns near a team mate"
 set g_spawn_near_teammate_distance 640 "max distance to consider a spawn to be near a team mate"
 set g_spawn_near_teammate_ignore_spawnpoint 0 "ignore spawnpoints and spawn right at team mates, if 2, clients can ignore this option"
+set g_spawn_near_teammate_ignore_spawnpoint_max 10 "if set, test at most this many of the available teammates"
 set g_spawn_near_teammate_ignore_spawnpoint_delay 2.5 "how long to wait before its OK to spawn at a player after someone just spawned at this player"
 set g_spawn_near_teammate_ignore_spawnpoint_delay_death 3 "how long to wait before its OK to spawn at a player after death"
 set g_spawn_near_teammate_ignore_spawnpoint_check_health 1 "only allow spawn at this player if their health is full"
index 0d71e59fff99dd1ab584506ffa0938aa916d33a8..e4b784371525776b05566d4cb521902701dcb8e0 100644 (file)
@@ -4,6 +4,7 @@ const float FLOAT_MAX = 340282346638528859811704183484516925440.0f;
 
 float autocvar_g_spawn_near_teammate_distance;
 int autocvar_g_spawn_near_teammate_ignore_spawnpoint;
+int autocvar_g_spawn_near_teammate_ignore_spawnpoint_max;
 float autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay;
 float autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay_death;
 bool autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health;
@@ -83,7 +84,9 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn)
                entity best_mate = NULL;
                vector best_pos = '0 0 0';
                float best_dist2 = FLOAT_MAX;
+               int tested = 0;
                FOREACH_CLIENT_RANDOM(IS_PLAYER(it), LAMBDA(
+                       if (autocvar_g_spawn_near_teammate_ignore_spawnpoint_max && tested >= autocvar_g_spawn_near_teammate_ignore_spawnpoint_max) break;
                        if (!SAME_TEAM(player, it)) continue;
                        if (autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health && it.health < autocvar_g_balance_health_regenstable) continue;
                        if (IS_DEAD(it)) continue;
@@ -92,6 +95,8 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn)
                        if (forbidWeaponUse(it)) continue;
                        if (it == player) continue;
 
+                       tested++; // i consider a teammate to be available when he passes the checks above
+
                        vector horiz_vel = vec2(it.velocity);
                        // when walking slowly sideways, we assume the player wants a clear shot ahead - spawn behind him according to where he's looking
                        // when running fast, spawn behind him according to his direction of movement to prevent colliding with the newly spawned player