From 0df44001f558876364d8b41482b7ba7b98e0918a Mon Sep 17 00:00:00 2001 From: Martin Taibr Date: Thu, 3 Nov 2016 14:44:31 +0100 Subject: [PATCH] test only 10 teammates --- mutators.cfg | 1 + .../mutator/spawn_near_teammate/sv_spawn_near_teammate.qc | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/mutators.cfg b/mutators.cfg index 9ad8ceffd..b5e9b76df 100644 --- a/mutators.cfg +++ b/mutators.cfg @@ -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" diff --git a/qcsrc/common/mutators/mutator/spawn_near_teammate/sv_spawn_near_teammate.qc b/qcsrc/common/mutators/mutator/spawn_near_teammate/sv_spawn_near_teammate.qc index 0d71e59ff..e4b784371 100644 --- a/qcsrc/common/mutators/mutator/spawn_near_teammate/sv_spawn_near_teammate.qc +++ b/qcsrc/common/mutators/mutator/spawn_near_teammate/sv_spawn_near_teammate.qc @@ -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 -- 2.39.2