From 34a8160e06783826845d6dcd2a32f9a1f99d0816 Mon Sep 17 00:00:00 2001 From: Martin Taibr Date: Sun, 2 Oct 2016 13:06:31 +0200 Subject: [PATCH] idk how i forgot this remember kids: sleep is important --- .../sv_spawn_near_teammate.qc | 121 +++++++++--------- 1 file changed, 58 insertions(+), 63 deletions(-) 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 b5019841d..0c0df63c8 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 @@ -103,75 +103,70 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn) // TODO all tracing: proper dphitcontentsmask??? // TODO check for nades - pc = pointcontents(trace_endpos + '0 0 1'); - LOG_INFOF(" pointcontents %f\n", pc); - if(pc == CONTENT_EMPTY) - { - // TODO ignore vertical velocity - // TODO higher limit - don't spawn in front of player when strafing slowly - or detect where he's looking? + // TODO ignore vertical velocity + // TODO higher limit - don't spawn in front of player when strafing slowly - or detect where he's looking? - if(vdist(it.velocity, >, 5)) { - fixedmakevectors(vectoangles(vec2(it.velocity))); - LOG_INFOF(" using velocity\n"); - } - else - fixedmakevectors(it.angles); + if(vdist(it.velocity, >, 5)) { + fixedmakevectors(vectoangles(vec2(it.velocity))); + LOG_INFOF(" using velocity\n"); + } + else + fixedmakevectors(it.angles); - // TODO go up - fix uneven surfaces - for(pc = 0; pc < 4; ++pc) // test 4 diffrent spots close to mate + // TODO go up - fix uneven surfaces + for(pc = 0; pc < 4; ++pc) // test 4 diffrent spots close to mate + { + switch(pc) { - switch(pc) - { - case 0: - tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin + v_right * 128, MOVE_NOMONSTERS, it); - break; - case 1: - tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_right * 128 , MOVE_NOMONSTERS, it); - break; - case 2: - tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin + v_right * 128 - v_forward * 64, MOVE_NOMONSTERS, it); - break; - case 3: - tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_right * 128 - v_forward * 64, MOVE_NOMONSTERS, it); - break; - //case 4: - //tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 128, MOVE_NOMONSTERS, it); - //break; - } - vector prev_endpos = trace_endpos; - te_lightning1(NULL, it.origin, trace_endpos); - LOG_INFOF(" pc: %d trace_fraction %f\n", pc, trace_fraction); - if(trace_fraction != 1.0) continue; - - tracebox(trace_endpos + '0 0 4', STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), trace_endpos - '0 0 400', MOVE_NORMAL, it); - te_lightning2(NULL, prev_endpos, trace_endpos); - LOG_INFOF(" trace_fraction2 %f\n", trace_fraction); - if (trace_startsolid) continue; // inside another player - if (trace_fraction == 1.0) continue; // above void or too high - // TODO not skybox or hurttriggers - if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath) - { - dist = vlen(trace_endpos - player.msnt_deathloc); - LOG_INFOF(" dist: %f, best_dist %f\n", dist, best_dist); - if(dist < best_dist || best_dist == 0) - { - LOG_INFOF(" new best dist - pos: %v\n", trace_endpos); - best_dist = dist; - best_pos = trace_endpos; - best_mate = it; - } - } - else // TODO random to avoid favoring players who joined early + case 0: + tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin + v_right * 128, MOVE_NOMONSTERS, it); + break; + case 1: + tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_right * 128 , MOVE_NOMONSTERS, it); + break; + case 2: + tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin + v_right * 128 - v_forward * 64, MOVE_NOMONSTERS, it); + break; + case 3: + tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_right * 128 - v_forward * 64, MOVE_NOMONSTERS, it); + break; + //case 4: + //tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 128, MOVE_NOMONSTERS, it); + //break; + } + vector prev_endpos = trace_endpos; + te_lightning1(NULL, it.origin, trace_endpos); + LOG_INFOF(" pc: %d trace_fraction %f\n", pc, trace_fraction); + if(trace_fraction != 1.0) continue; + + tracebox(trace_endpos + '0 0 4', STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), trace_endpos - '0 0 400', MOVE_NORMAL, it); + te_lightning2(NULL, prev_endpos, trace_endpos); + LOG_INFOF(" trace_fraction2 %f\n", trace_fraction); + if (trace_startsolid) continue; // inside another player + if (trace_fraction == 1.0) continue; // above void or too high + // TODO not skybox or hurttriggers + if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath) + { + dist = vlen(trace_endpos - player.msnt_deathloc); + LOG_INFOF(" dist: %f, best_dist %f\n", dist, best_dist); + if(dist < best_dist || best_dist == 0) { - setorigin(player, trace_endpos); - player.angles = it.angles; - player.angles_z = 0; // never spawn tilted even if the spot says to - it.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay; - LOG_INFOF(" PlayerSpawn return %v\n", player.origin); - if (player.origin != trace_endpos) LOG_WARNF("wrong origin\n"); - return; + LOG_INFOF(" new best dist - pos: %v\n", trace_endpos); + best_dist = dist; + best_pos = trace_endpos; + best_mate = it; } } + else // TODO random to avoid favoring players who joined early + { + setorigin(player, trace_endpos); + player.angles = it.angles; + player.angles_z = 0; // never spawn tilted even if the spot says to + it.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay; + LOG_INFOF(" PlayerSpawn return %v\n", player.origin); + if (player.origin != trace_endpos) LOG_WARNF("wrong origin\n"); + return; + } } )); -- 2.39.2