X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fantilag.qc;h=c6e26e09e8fdbf77e641a6f9937e1ade5e60ac24;hb=d7005dc6d583c2d2467ce52050e1d932db162b9c;hp=4062f7f660df2d15dfb01ea48bdf822a81599995;hpb=9e113dae328809b5e7432f434649a35ebb185a52;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/antilag.qc b/qcsrc/server/antilag.qc index 4062f7f66..c6e26e09e 100644 --- a/qcsrc/server/antilag.qc +++ b/qcsrc/server/antilag.qc @@ -5,6 +5,7 @@ #include #include #include + #include #include "antilag.qh" #endif @@ -146,3 +147,78 @@ void antilag_restore_all(entity ignore) antilag_restore(it, it); }); } + +/* +================== +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 tracebox_antilag_force_wz (entity source, vector v1, vector mi, vector ma, vector v2, float nomonst, entity forent, float lag, float wz) +{ + // check whether antilagged traces are enabled + if (lag < 0.001) + lag = 0; + if (!IS_REAL_CLIENT(forent)) + lag = 0; // only antilag for clients + + // change shooter to SOLID_BBOX so the shot can hit corpses + int oldsolid = source.dphitcontentsmask; + if(source) + source.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE; + + if (lag) + antilag_takeback_all(forent, lag); + + // do the trace + if(wz) + WarpZone_TraceBox (v1, mi, ma, v2, nomonst, forent); + else + tracebox (v1, mi, ma, v2, nomonst, forent); + + // restore players to current positions + if (lag) + antilag_restore_all(forent); + + // restore shooter solid type + if(source) + source.dphitcontentsmask = oldsolid; +} +void traceline_antilag_force (entity source, vector v1, vector v2, float nomonst, entity forent, float lag) +{ + tracebox_antilag_force_wz(source, v1, '0 0 0', '0 0 0', v2, nomonst, forent, lag, false); +} +void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag) +{ + bool noantilag = ((IS_CLIENT(source)) ? CS(source).cvar_cl_noantilag : false); + if (autocvar_g_antilag != 2 || noantilag) + lag = 0; + traceline_antilag_force(source, v1, v2, nomonst, forent, lag); +} +void tracebox_antilag (entity source, vector v1, vector mi, vector ma, vector v2, float nomonst, entity forent, float lag) +{ + bool noantilag = ((IS_CLIENT(source)) ? CS(source).cvar_cl_noantilag : false); + if (autocvar_g_antilag != 2 || noantilag) + lag = 0; + tracebox_antilag_force_wz(source, v1, mi, ma, v2, nomonst, forent, lag, false); +} +void WarpZone_traceline_antilag_force (entity source, vector v1, vector v2, float nomonst, entity forent, float lag) +{ + tracebox_antilag_force_wz(source, v1, '0 0 0', '0 0 0', v2, nomonst, forent, lag, true); +} +void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag) +{ + bool noantilag = ((IS_CLIENT(source)) ? CS(source).cvar_cl_noantilag : false); + if (autocvar_g_antilag != 2 || noantilag) + lag = 0; + WarpZone_traceline_antilag_force(source, v1, v2, nomonst, forent, lag); +} +void WarpZone_tracebox_antilag (entity source, vector v1, vector mi, vector ma, vector v2, float nomonst, entity forent, float lag) +{ + bool noantilag = ((IS_CLIENT(source)) ? CS(source).cvar_cl_noantilag : false); + if (autocvar_g_antilag != 2 || noantilag) + lag = 0; + tracebox_antilag_force_wz(source, v1, mi, ma, v2, nomonst, forent, lag, true); +}