r3496 - trunk/data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Mon Mar 10 14:22:18 EDT 2008
Author: lordhavoc
Date: 2008-03-10 14:22:17 -0400 (Mon, 10 Mar 2008)
New Revision: 3496
Modified:
trunk/data/qcsrc/server/cl_weaponsystem.qc
trunk/data/qcsrc/server/g_subs.qc
trunk/data/qcsrc/server/w_common.qc
trunk/data/qcsrc/server/w_crylink.qc
Log:
replaced traceline_hitcorpse with traceline_antilag, added an additional
parameter for this, does the same as traceline_hitcorpse if given 0 as
the lag parameter, OR if g_antilag is not 2
changed the aiming-based g_antilag check to use 1
Modified: trunk/data/qcsrc/server/cl_weaponsystem.qc
===================================================================
--- trunk/data/qcsrc/server/cl_weaponsystem.qc 2008-03-10 06:24:40 UTC (rev 3495)
+++ trunk/data/qcsrc/server/cl_weaponsystem.qc 2008-03-10 18:22:17 UTC (rev 3496)
@@ -26,7 +26,7 @@
{
float nudge = 1; // added to traceline target and subtracted from result
local vector trueaimpoint;
- traceline_hitcorpse(self, self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * MAX_SHOT_DISTANCE, MOVE_NOMONSTERS, self);
+ traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * MAX_SHOT_DISTANCE, MOVE_NOMONSTERS, self);
trueaimpoint = trace_endpos;
if (cvar("g_shootfromeye"))
@@ -36,7 +36,7 @@
else
w_shotorg = ent.origin + ent.view_ofs + v_right * vecs_y + v_up * vecs_z;
// now move the shotorg forward as much as requested if possible
- traceline_hitcorpse(self, w_shotorg, w_shotorg + v_forward * (vecs_x + nudge), MOVE_NORMAL, self);
+ traceline(w_shotorg, w_shotorg + v_forward * (vecs_x + nudge), MOVE_NORMAL, self);
w_shotorg = trace_endpos - v_forward * nudge;
// calculate the shotdir from the chosen shotorg
w_shotdir = normalize(trueaimpoint - w_shotorg);
@@ -55,15 +55,15 @@
if (self.cursor_trace_ent != self) // just to make sure
if (self.cursor_trace_ent.takedamage) // and that person is killable
if (self.cursor_trace_ent.classname == "player") // and actually a player
- if (cvar("g_antilag"))
+ if (cvar("g_antilag") == 1)
{
// verify that the shot would miss without antilag
// (avoids an issue where guns would always shoot at their origin)
- traceline_hitcorpse(self, w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, self);
+ traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, self);
if (!trace_ent.takedamage)
{
// verify that the shot would hit if altered
- traceline_hitcorpse(self, w_shotorg, self.cursor_trace_ent.origin, MOVE_NORMAL, self);
+ traceline(w_shotorg, self.cursor_trace_ent.origin, MOVE_NORMAL, self);
if (trace_ent == self.cursor_trace_ent)
{
// verify that the shot would hit in the past
@@ -72,7 +72,7 @@
else
antilag_takeback(self.cursor_trace_ent, time - self.ping * 0.001);
- traceline_hitcorpse(self, self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, self);
+ traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, self);
antilag_restore(self.cursor_trace_ent);
if(trace_ent == self.cursor_trace_ent)
Modified: trunk/data/qcsrc/server/g_subs.qc
===================================================================
--- trunk/data/qcsrc/server/g_subs.qc 2008-03-10 06:24:40 UTC (rev 3495)
+++ trunk/data/qcsrc/server/g_subs.qc 2008-03-10 18:22:17 UTC (rev 3496)
@@ -226,20 +226,54 @@
/*
==================
-traceline_hitcorpse
+traceline_antilag
A version of traceline that must be used by SOLID_SLIDEBOX things that want to hit SOLID_CORPSE things with a trace attack
+Additionally it moves players back into the past before the trace and restores them afterward.
==================
*/
-void traceline_hitcorpse (entity source, vector v1, vector v2, float nomonst, entity forent)
+void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag)
{
- float oldsolid;
+ local entity player;
+ local float oldsolid;
+ // check whether antilagged traces are enabled
+ if (lag < 0.001)
+ lag = 0;
+ if (lag)
+ if (cvar("g_antilag") != 2)
+ lag = 0;
+
+ // change shooter to SOLID_BBOX so the shot can hit corpses
oldsolid = source.solid;
source.solid = SOLID_BBOX;
+ if (lag)
+ {
+ // take players back into the past
+ player = player_list;
+ while (player)
+ {
+ antilag_takeback(player, time - lag);
+ player = player.nextplayer;
+ }
+ }
+
+ // do the trace
traceline (v1, v2, nomonst, forent);
+ // restore players to current positions
+ if (lag)
+ {
+ player = player_list;
+ while (player)
+ {
+ antilag_restore(player);
+ player = player.nextplayer;
+ }
+ }
+
+ // restore shooter solid type
source.solid = oldsolid;
}
Modified: trunk/data/qcsrc/server/w_common.qc
===================================================================
--- trunk/data/qcsrc/server/w_common.qc 2008-03-10 06:24:40 UTC (rev 3495)
+++ trunk/data/qcsrc/server/w_common.qc 2008-03-10 18:22:17 UTC (rev 3496)
@@ -39,7 +39,7 @@
// note down which entities were hit so we can damage them later
while (1)
{
- traceline_hitcorpse (self, start, end, FALSE, self);
+ traceline_antilag (self, start, end, FALSE, self, self.ping);
// if it is world we can't hurt it so stop now
if (trace_ent == world || trace_fraction == 1)
@@ -105,10 +105,9 @@
vector end;
local entity e;
- // use traceline_hitcorpse to make sure it can hit gibs and corpses too
dir = dir + randomvec() * spread;
end = start + dir * MAX_SHOT_DISTANCE;
- traceline_hitcorpse (self, start, end, FALSE, self);
+ traceline_antilag (self, start, end, FALSE, self, self.ping);
if (tracer)
{
Modified: trunk/data/qcsrc/server/w_crylink.qc
===================================================================
--- trunk/data/qcsrc/server/w_crylink.qc 2008-03-10 06:24:40 UTC (rev 3495)
+++ trunk/data/qcsrc/server/w_crylink.qc 2008-03-10 18:22:17 UTC (rev 3496)
@@ -126,8 +126,7 @@
self.ammo_cells = self.ammo_cells - cvar("g_balance_crylink_primary_ammo");
W_SetupShot (self, '25 8 -8', TRUE, 0, "weapons/crylink_fire.wav");
- // use traceline_hitcorpse to make sure it can hit gibs and corpses too
- traceline_hitcorpse(self, w_shotorg, w_shotorg + w_shotdir * 1000, FALSE, self);
+ traceline_antilag(self, w_shotorg, w_shotorg + w_shotdir * 1000, FALSE, self, self.ping);
pointparticles(particleeffectnum("lightning_muzzleflash", w_shotorg, w_shotdir * 1000, 1);
pointparticles(particleeffectnum("lightning_impact", trace_endpos, trace_plane_normal * 1000, 1);
More information about the nexuiz-commits
mailing list