]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/tracing.qc
cleanup and a few comments
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / tracing.qc
index dbd3d5b27e6573b4d4125ff653daf3c3ff51f6e3..a8385b686aa87f3b456c9b25bc81bcea467bd7a6 100644 (file)
@@ -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;