From: Mario Date: Wed, 4 Sep 2019 13:09:20 +0000 (+1000) Subject: Don't perform antilag takeback on every single bullet in the Shotgun attack X-Git-Tag: xonotic-v0.8.5~1319 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=c5c00b94c2ed0fa30521939728f6ae1c99d9dc2f Don't perform antilag takeback on every single bullet in the Shotgun attack --- diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 22c928841..18e75fad2 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -16,8 +16,17 @@ void W_Shotgun_Attack(Weapon thiswep, entity actor, .entity weaponentity, float W_DecreaseAmmo(thiswep, actor, ammocount, weaponentity); W_SetupShot(actor, weaponentity, true, 5, SND_SHOTGUN_FIRE, ((isprimary) ? CH_WEAPON_A : CH_WEAPON_SINGLE), damage * bullets, thiswep.m_id); + + // TRICK: do the antilag outside the regular fireBullet function, so it isn't performed unnecessarily on every single bullet! + float lag = antilag_getlag(actor); + if(lag && bullets > 0) + antilag_takeback_all(actor, lag); + for(int sc = 0;sc < bullets;sc = sc + 1) - fireBullet(actor, weaponentity, w_shotorg, w_shotdir, spread, solidpenetration, damage, force, thiswep.m_id, bullet_trail_effect); + fireBullet_antilag(actor, weaponentity, w_shotorg, w_shotdir, spread, solidpenetration, damage, force, thiswep.m_id, bullet_trail_effect, false); + + if(lag && bullets > 0) + antilag_restore_all(actor); Send_Effect(EFFECT_SHOTGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, ammocount); diff --git a/qcsrc/server/antilag.qc b/qcsrc/server/antilag.qc index c6e26e09e..93ca6acf9 100644 --- a/qcsrc/server/antilag.qc +++ b/qcsrc/server/antilag.qc @@ -148,6 +148,16 @@ void antilag_restore_all(entity ignore) }); } +float antilag_getlag(entity e) +{ + float lag = ((IS_REAL_CLIENT(e)) ? ANTILAG_LATENCY(e) : 0); + bool noantilag = ((IS_CLIENT(e)) ? CS(e).cvar_cl_noantilag : false); + if(autocvar_g_antilag == 0 || noantilag || lag < 0.001) + lag = 0; + + return lag; +} + /* ================== traceline_antilag diff --git a/qcsrc/server/antilag.qh b/qcsrc/server/antilag.qh index c3be5553a..f02803387 100644 --- a/qcsrc/server/antilag.qh +++ b/qcsrc/server/antilag.qh @@ -9,6 +9,8 @@ void antilag_clear(entity e, entity store); void antilag_takeback_all(entity ignore, float lag); void antilag_restore_all(entity ignore); +float antilag_getlag(entity e); // returns antilag latency for clients, plus any modifiers (such as noantilag) + .float antilag_debug; #define ANTILAG_LATENCY(e) min(0.4, CS(e).ping * 0.001) diff --git a/qcsrc/server/weapons/tracing.qc b/qcsrc/server/weapons/tracing.qc index 99fa2df74..91c23563f 100644 --- a/qcsrc/server/weapons/tracing.qc +++ b/qcsrc/server/weapons/tracing.qc @@ -330,7 +330,7 @@ void fireBullet_trace_callback(vector start, vector hit, vector end) fireBullet_last_hit = NULL; } -void fireBullet(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float force, float dtype, entity tracer_effect) +void fireBullet_antilag(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float force, float dtype, entity tracer_effect, bool do_antilag) { vector end; @@ -343,12 +343,7 @@ void fireBullet(entity this, .entity weaponentity, vector start, vector dir, flo float solid_penetration_left = 1; float total_damage = 0; - float lag = ((IS_REAL_CLIENT(this)) ? ANTILAG_LATENCY(this) : 0); - if(lag < 0.001) - lag = 0; - bool noantilag = ((IS_CLIENT(this)) ? CS(this).cvar_cl_noantilag : false); - if(autocvar_g_antilag == 0 || noantilag) - lag = 0; // only do hitscan, but no antilag + float lag = ((do_antilag) ? antilag_getlag(this) : 0); if(lag) antilag_takeback_all(this, lag); @@ -473,3 +468,8 @@ void fireBullet(entity this, .entity weaponentity, vector start, vector dir, flo if(this) this.dphitcontentsmask = oldsolid; } + +void fireBullet(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float force, float dtype, entity tracer_effect) +{ + fireBullet_antilag(this, weaponentity, start, dir, spread, max_solid_penetration, damage, force, dtype, tracer_effect, true); +} diff --git a/qcsrc/server/weapons/tracing.qh b/qcsrc/server/weapons/tracing.qh index 9e39ecc35..5acbda9a5 100644 --- a/qcsrc/server/weapons/tracing.qh +++ b/qcsrc/server/weapons/tracing.qh @@ -57,4 +57,5 @@ void FireRailgunBullet (entity this, .entity weaponentity, vector start, vector entity fireBullet_trace_callback_eff; entity fireBullet_last_hit; void fireBullet_trace_callback(vector start, vector hit, vector end); +void fireBullet_antilag(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float force, float dtype, entity tracer_effect, bool do_antilag); void fireBullet(entity this, .entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float force, float dtype, entity tracer_effect);