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);
});
}
+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
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)
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;
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);
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);
+}
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);