]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
msnt: better way to determine forward direction, tracebox up first
authorMartin Taibr <taibr.martin@gmail.com>
Sun, 2 Oct 2016 15:01:43 +0000 (17:01 +0200)
committerMartin Taibr <taibr.martin@gmail.com>
Sun, 2 Oct 2016 15:13:59 +0000 (17:13 +0200)
qcsrc/common/mutators/mutator/spawn_near_teammate/sv_spawn_near_teammate.qc

index 0c0df63c8f96d6dccc2af54848c2b069c82f65b5..d699ebd552e31a2decbf2bcf42e735ebb9ee323c 100644 (file)
@@ -57,7 +57,7 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, Spawn_Score)
 
 MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn)
 {
-       if(!teamplay) { return; }
+       //if(!teamplay) { return; } // TODO DEBUGGING
        entity player = M_ARGV(0, entity);
        entity spawn_spot = M_ARGV(1, entity);
 
@@ -100,39 +100,34 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn)
                        if (STAT(FROZEN, it)) continue;
                        if (it == player) continue;
 
-                       // TODO all tracing: proper dphitcontentsmask???
                        // TODO check for nades
 
-                       // 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");
+                       vector horiz_vel = vec2(it.velocity);
+                       if(vdist(horiz_vel, >, 450)) {
+                               fixedmakevectors(vectoangles(horiz_vel));
+                               LOG_INFOF("    using velocity -> forward: %v\n", v_forward);
+                       } else {
+                               fixedmakevectors(it.angles); // .angles is the angle of the model - usually/always 0 pitch
+                               LOG_INFOF("    using angles -> forward: %v\n", v_forward);
                        }
-                       else
-                               fixedmakevectors(it.angles);
 
-                       // TODO go up - fix uneven surfaces
-                       for(pc = 0; pc < 4; ++pc) // test 4 diffrent spots close to mate
+                       // test diffrent spots close to mate - trace upwards so it works on uneven surfaces
+                       for(pc = 0; pc < 4; ++pc)
                        {
                                switch(pc)
                                {
                                        case 0:
-                                               tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin + v_right * 128, MOVE_NOMONSTERS, it);
+                                               tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin + v_right * 128 + v_up * 64, 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);
+                                               tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_right * 128 + v_up * 64, 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);
+                                               tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin + v_right * 128 - v_forward * 64 + v_up * 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);
+                                               tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_right * 128 - v_forward * 64 + v_up * 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);