X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fshotgun.qc;h=f7c29a26e4e8cdd0b188c199d1ef80e771acd44c;hb=8e7d21da2c1a5f8701f3abde89c8dc4fa7da5100;hp=1eee25a05cc1d0992a587d6304856f327f7f6f26;hpb=590a5297bd4ad3b00dde7efc20d6cc860be4f853;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 1eee25a05..f7c29a26e 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -2,24 +2,27 @@ #ifdef SVQC -METHOD(Shotgun, m_spawnfunc_hookreplace, Weapon(Shotgun this, entity e)) -{ - if (autocvar_sv_q3acompat_machineshotgunswap && !Item_IsLoot(e)) - { - return WEP_MACHINEGUN; - } - return this; -} +// enable to debug melee range +//#define SHOTGUN_MELEEDEBUG void W_Shotgun_Attack(Weapon thiswep, entity actor, .entity weaponentity, float isprimary, float ammocount, float damage, float bullets, float spread, float solidpenetration, float force, entity bullet_trail_effect) { 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); + W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir); // casing code if(autocvar_g_casings >= 1) @@ -28,14 +31,6 @@ void W_Shotgun_Attack(Weapon thiswep, entity actor, .entity weaponentity, float //for(int sc = 0;sc < WEP_CVAR_PRI(shotgun, ammo);sc = sc + 1) SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1, actor, weaponentity); } - - // muzzle flash for 1st person view - entity flash = spawn(); - setmodel(flash, MDL_SHOTGUN_MUZZLEFLASH); // precision set below - setthink(flash, SUB_Remove); - flash.nextthink = time + 0.06; - flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; - W_AttachToShotorg(actor, weaponentity, flash, '5 0 0'); } .float swing_prev; @@ -80,8 +75,10 @@ void W_Shotgun_Melee_Think(entity this) WarpZone_traceline_antilag(this.realowner, this.realowner.origin + this.realowner.view_ofs, targpos, false, this.realowner, ((IS_CLIENT(this.realowner)) ? ANTILAG_LATENCY(this.realowner) : 0)); // draw lightning beams for debugging - //te_lightning2(NULL, targpos, this.realowner.origin + this.realowner.view_ofs + v_forward * 5 - v_up * 5); - //te_customflash(targpos, 40, 2, '1 1 1'); + #ifdef SHOTGUN_MELEEDEBUG + te_lightning2(NULL, targpos, this.realowner.origin + this.realowner.view_ofs + v_forward * 5 - v_up * 5); + te_customflash(targpos, 40, 2, '1 1 1'); + #endif is_player = (IS_PLAYER(trace_ent) || trace_ent.classname == "body" || IS_MONSTER(trace_ent)); @@ -107,7 +104,9 @@ void W_Shotgun_Melee_Think(entity this) if(accuracy_isgooddamage(this.realowner, target_victim)) { accuracy_add(this.realowner, WEP_SHOTGUN, 0, swing_damage); } // draw large red flash for debugging - //te_customflash(targpos, 200, 2, '15 0 0'); + #ifdef SHOTGUN_MELEEDEBUG + te_customflash(targpos, 200, 2, '15 0 0'); + #endif if(WEP_CVAR_SEC(shotgun, melee_multihit)) // allow multiple hits with one swing, but not against the same player twice. {