]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/tracing.qc
Fix current custom gametype not being kept if gametype vote ends without votes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / tracing.qc
index 686634c7acfdadae38a1a19e29d521643b78ebe5..a8385b686aa87f3b456c9b25bc81bcea467bd7a6 100644 (file)
@@ -37,7 +37,7 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, .entity weaponentity, vect
                // TODO for fireBullet, find how far the shot will penetrate and aim at that
                //      for fireRailgunbullet, find the farthest target and aim at that
                //      this will avoid issues when another player is passing in front of you when you shoot
-               //      (currently such a shot will hit him but then miss the original target)
+               //      (currently such a shot will hit them but then miss the original target)
                ent.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_CORPSE;
        }
        else
@@ -69,11 +69,15 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, .entity weaponentity, vect
        if(IS_PLAYER(ent))
                W_HitPlotAnalysis(ent, wep, forward, right, up);
 
+       // read shot origin offset, like g_shootfromcenter
+       // set in CL_WeaponEntity_SetModel (not a CSQC exclusive function...)
        vector md = ent.(weaponentity).movedir;
-       vector vecs = ((md.x > 0) ? md : '0 0 0');
+       //print(sprintf("offset of %s: %v\n", ent.(weaponentity).m_weapon.netname, md));
+       vector dv = right * -md.y + up * md.z;
 
-       vector dv = right * -vecs.y + up * vecs.z;
        w_shotorg = ent.origin + ent.view_ofs;
+
+       // move the shotorg sideways and vertically as much as requested if possible
        if(antilag)
        {
                if(CS(ent).antilag_debug)
@@ -89,13 +93,16 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, .entity weaponentity, vect
        if(antilag)
        {
                if(CS(ent).antilag_debug)
-                       tracebox_antilag(ent, w_shotorg, mi, ma, w_shotorg + forward * (vecs.x + nudge), MOVE_NORMAL, ent, CS(ent).antilag_debug);
+                       tracebox_antilag(ent, w_shotorg, mi, ma, w_shotorg + forward * (md.x + nudge), MOVE_NORMAL, ent, CS(ent).antilag_debug);
                else
-                       tracebox_antilag(ent, w_shotorg, mi, ma, w_shotorg + forward * (vecs.x + nudge), MOVE_NORMAL, ent, ANTILAG_LATENCY(ent));
+                       tracebox_antilag(ent, w_shotorg, mi, ma, w_shotorg + forward * (md.x + nudge), MOVE_NORMAL, ent, ANTILAG_LATENCY(ent));
        }
        else
-               tracebox(w_shotorg, mi, ma, w_shotorg + forward * (vecs.x + nudge), MOVE_NORMAL, ent);
+               tracebox(w_shotorg, mi, ma, w_shotorg + forward * (md.x + nudge), MOVE_NORMAL, ent);
        w_shotorg = trace_endpos - forward * nudge;
+
+       //print(sprintf("w_shotorg %v\n\n", w_shotorg - (ent.origin + ent.view_ofs)));
+
        // calculate the shotdir from the chosen shotorg
        if(W_DualWielding(ent))
                w_shotdir = s_forward;