// 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
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;
- // TODO this is broken - see 637056bea7bf7f5c9c0fc6113e94731a2767476 for an attempted fix
- // which fixes issue #1957 but causes #2129
- vector dv = right * -vecs.y + up * vecs.z;
- w_shotorg = ent.origin + ent.view_ofs + dv;
+ 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)
+ tracebox_antilag(ent, w_shotorg, mi, ma, w_shotorg + dv, MOVE_NORMAL, ent, CS(ent).antilag_debug);
+ else
+ tracebox_antilag(ent, w_shotorg, mi, ma, w_shotorg + dv, MOVE_NORMAL, ent, ANTILAG_LATENCY(ent));
+ }
+ else
+ tracebox(w_shotorg, mi, ma, w_shotorg + dv, MOVE_NORMAL, ent);
+ w_shotorg = trace_endpos;
// now move the shotorg forward as much as requested if possible
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;
//vector prevend = w_shotend;
if (antilag)
- if (!CS(ent).cvar_cl_noantilag)
+ if (!CS_CVAR(ent).cvar_cl_noantilag)
{
if (autocvar_g_antilag == 1) // switch to "ghost" if not hitting original
{