]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move muzzle flash model handling to the client side
authorMario <mario.mario@y7mail.com>
Fri, 10 Jul 2020 16:05:41 +0000 (02:05 +1000)
committerMario <mario.mario@y7mail.com>
Fri, 10 Jul 2020 16:05:41 +0000 (02:05 +1000)
24 files changed:
qcsrc/common/mutators/mutator/overkill/okhmg.qc
qcsrc/common/mutators/mutator/overkill/okmachinegun.qc
qcsrc/common/mutators/mutator/overkill/okrpc.qc
qcsrc/common/turrets/turret/machinegun_weapon.qc
qcsrc/common/weapons/all.qc
qcsrc/common/weapons/all.qh
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/blaster.qc
qcsrc/common/weapons/weapon/crylink.qc
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/electro.qc
qcsrc/common/weapons/weapon/fireball.qc
qcsrc/common/weapons/weapon/hagar.qc
qcsrc/common/weapons/weapon/hlac.qc
qcsrc/common/weapons/weapon/machinegun.qc
qcsrc/common/weapons/weapon/minelayer.qc
qcsrc/common/weapons/weapon/mortar.qc
qcsrc/common/weapons/weapon/rifle.qc
qcsrc/common/weapons/weapon/seeker.qc
qcsrc/common/weapons/weapon/shotgun.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/common/weapons/weapon/vortex.qc
qcsrc/server/defs.qh
qcsrc/server/g_hook.qc

index 818b333597233066cc0c7702688dda2c37dbcad0..2f8a651c4759d8278597f7578d742cee041a8b2a 100644 (file)
@@ -40,10 +40,7 @@ void W_OverkillHeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity
 
        actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
-
-       W_MachineGun_MuzzleFlash(actor, weaponentity);
-       W_AttachToShotorg(actor, weaponentity, actor.(weaponentity).muzzle_flash, '5 0 0');
+       W_MuzzleFlash(actor, weaponentity, EFFECT_MACHINEGUN_MUZZLEFLASH, MDL_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
 
        if (autocvar_g_casings >= 2) // casing code
        {
index f689e4aa02628c1db014963a059746b733ca9106..a1add71a847138ab1413c1386c2cb75a2221a91e 100644 (file)
@@ -34,10 +34,7 @@ void W_OverkillMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weap
 
        actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
-
-       W_MachineGun_MuzzleFlash(actor, weaponentity);
-       W_AttachToShotorg(actor, weaponentity, actor.(weaponentity).muzzle_flash, '5 0 0');
+       W_MuzzleFlash(actor, weaponentity, EFFECT_MACHINEGUN_MUZZLEFLASH, MDL_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
 
        if(autocvar_g_casings >= 2) // casing code
        {
index db2803cee70e3d4975bfd372d426061fea0515ba..57d5947ae46500ebd5c7565cacace20ab0612f86 100644 (file)
@@ -87,11 +87,10 @@ void W_OverkillRocketPropelledChainsaw_Think(entity this)
 void W_OverkillRocketPropelledChainsaw_Attack(Weapon thiswep, entity actor, .entity weaponentity)
 {
        entity missile = spawn(); //WarpZone_RefSys_SpawnSameRefSys(actor);
-       entity flash = spawn ();
 
        W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(okrpc, ammo), weaponentity);
        W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(okrpc, damage), thiswep.m_id);
-       W_MuzzleFlash(actor, weaponentity, EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_ROCKET_MUZZLEFLASH, MDL_RPC_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
        PROJECTILE_MAKETRIGGER(missile);
 
        missile.owner = missile.realowner = actor;
@@ -124,11 +123,6 @@ void W_OverkillRocketPropelledChainsaw_Attack(Weapon thiswep, entity actor, .ent
 
        CSQCProjectile(missile, true, PROJECTILE_RPC, false);
 
-       // TODO: move to client
-       setmodel(flash, MDL_RPC_MUZZLEFLASH); // precision set below
-       SUB_SetFade (flash, time, 0.1);
-       flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
-       W_AttachToShotorg(actor, weaponentity, flash, '5 0 0');
        missile.m_chainsaw_damage = 0;
 
        MUTATOR_CALLHOOK(EditProjectile, actor, missile);
index a56e7de3833a6fe4d997cda5fa4081de332c95c8..38a74c8e9481f0e84e70f5dff0575703367f371a 100644 (file)
@@ -2,7 +2,7 @@
 
 #ifdef SVQC
 
-void W_MachineGun_MuzzleFlash(entity actor, .entity weaponentity);
+void W_MuzzleFlash_Model(entity wepent, entity muzzlemodel);
 SOUND(MachineGunTurretAttack_FIRE, W_Sound("electro_fire"));
 METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
@@ -18,7 +18,7 @@ METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, .ent
             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready);
         }
         fireBullet(actor, weaponentity, actor.tur_shotorg, actor.tur_shotdir_updated, actor.shot_spread, 0, actor.shot_dmg, actor.shot_force, DEATH_TURRET_MACHINEGUN.m_id, EFFECT_BULLET);
-        W_MachineGun_MuzzleFlash(actor, weaponentity);
+        W_MuzzleFlash_Model(actor.(weaponentity), MDL_MACHINEGUN_MUZZLEFLASH);
         setattachment(actor.(weaponentity).muzzle_flash, actor.tur_head, "tag_fire");
     }
 }
index abc4bab552cf9d70ca57bc98eb96657cd6ee230a..ad0e0cae3a676cae90d1f50120ce03110bb87000 100644 (file)
@@ -673,12 +673,93 @@ CLIENT_COMMAND(weapon_find, "Show spawn locations of a weapon")
 }
 #endif
 
+#ifdef SVQC
+void W_MuzzleFlash_Model_AttachToShotorg(entity actor, .entity weaponentity, entity flash, vector offset)
+{
+       flash.owner = actor;
+       flash.angles_z = random() * 360;
+
+       entity view = actor.(weaponentity);
+       entity exterior = actor.exteriorweaponentity;
+
+       if (view.oldorigin.x > 0)
+       {
+               setattachment(flash, exterior, "");
+               setorigin(flash, view.oldorigin + offset);
+       }
+       else
+       {
+               if (gettagindex(exterior, "shot")) setattachment(flash, exterior, "shot");
+               else setattachment(flash, exterior, "tag_shot");
+               setorigin(flash, offset);
+       }
+}
+#elif defined(CSQC)
+void W_MuzzleFlash_Model_AttachToShotorg(entity wepent, entity flash, vector offset)
+{
+       flash.owner = wepent;
+       flash.angles_z = random() * 360;
+
+       if (gettagindex(wepent, "shot")) setattachment(flash, wepent, "shot");
+       else setattachment(flash, wepent, "tag_shot");
+       setorigin(flash, offset);
+}
+#endif
+
+void W_MuzzleFlash_Model_Think(entity this)
+{
+       this.frame += 2;
+       this.scale *= 0.5;
+       this.alpha -= 0.25;
+       this.nextthink = time + 0.05;
+
+       if(this.alpha <= 0)
+       {
+               setthink(this, SUB_Remove);
+               this.nextthink = time;
+               this.realowner.muzzle_flash = NULL;
+               return;
+       }
+}
+
+void W_MuzzleFlash_Model(entity wepent, entity muzzlemodel)
+{
+       if(wepent.muzzle_flash == NULL)
+               wepent.muzzle_flash = spawn();
+
+       entity flash = wepent.muzzle_flash;
+       setmodel(flash, muzzlemodel); // precision set below
+
+       flash.scale = 0.75;
+       setthink(flash, W_MuzzleFlash_Model_Think);
+       flash.nextthink = time + 0.02;
+       flash.frame = 2;
+       flash.alpha = 0.75;
+       flash.angles_z = random() * 180;
+       flash.effects = EF_ADDITIVE | EF_FULLBRIGHT;
+       flash.owner = flash.realowner = wepent;
+
+#ifdef CSQC
+       flash.drawmask = MASK_NORMAL;
+#endif
+}
+
 REGISTER_NET_TEMP(w_muzzleflash)
 
 #ifdef SVQC
-void W_MuzzleFlash(entity actor, .entity weaponentity, entity eff, vector shotorg, vector shotdir)
+void W_MuzzleFlash(entity actor, .entity weaponentity, entity eff, entity muzzlemodel, vector shotorg, vector shotdir)
 {
-       Send_Effect_Except(eff, shotorg, shotdir * 1000, 1, actor);
+       // don't show an exterior muzzle effect for the off-hand
+       if(weaponslot(weaponentity) == 0)
+       {
+               Send_Effect_Except(eff, shotorg, shotdir * 1000, 1, actor);
+
+               if(muzzlemodel != MDL_Null)
+               {
+                       W_MuzzleFlash_Model(actor.exteriorweaponentity, muzzlemodel);
+                       W_MuzzleFlash_Model_AttachToShotorg(actor, weaponentity, actor.exteriorweaponentity.muzzle_flash, '5 0 0');
+               }
+       }
 
        FOREACH_CLIENT(it == actor || (IS_SPEC(it) && it.enemy == actor),
        {
@@ -691,6 +772,9 @@ void W_MuzzleFlash(entity actor, .entity weaponentity, entity eff, vector shotor
                (Effects_COUNT >= 255)
                ? WriteShort(channel, eff.m_id)
                : WriteByte(channel, eff.m_id);
+               (Models_COUNT >= 255)
+               ? WriteShort(channel, muzzlemodel.m_id)
+               : WriteByte(channel, muzzlemodel.m_id);
                WriteVector(channel, shotorg);
        });
 }
@@ -700,6 +784,7 @@ NET_HANDLE(w_muzzleflash, bool isNew)
        return = true;
     int slot = ReadByte();
     int net_name = (Effects_COUNT >= 255) ? ReadShort() : ReadByte();
+    int net_modelname = (Models_COUNT >= 255) ? ReadShort() : ReadByte();
     vector sv_shotorg = ReadVector();
 
     entity eff = Effects_from(net_name);
@@ -716,6 +801,7 @@ NET_HANDLE(w_muzzleflash, bool isNew)
        }
     if(!autocvar_r_drawviewmodel) return;
 
+    entity muzzlemodel = Models_from(net_modelname);
        entity wepent = viewmodels[slot];
        // get the local player entity to calculate shot origin
        entity rlplayer = CSQCModel_server2csqc(player_localentnum - 1);
@@ -730,6 +816,12 @@ NET_HANDLE(w_muzzleflash, bool isNew)
        org = trace_endpos - forward * 1;
 
        pointparticles(eff, org, forward * 1000, 1);
+
+       if(muzzlemodel != MDL_Null)
+       {
+               W_MuzzleFlash_Model(wepent, muzzlemodel);
+               W_MuzzleFlash_Model_AttachToShotorg(wepent, wepent.muzzle_flash, '5 0 0');
+       }
 }
 #endif
 
index 14134e5e287b5c4ce2967cd80b7c11576413d06c..bc6ff5cb7e82232bb7432f14fa6279b88c63b480 100644 (file)
@@ -364,6 +364,8 @@ vector weaponentity_glowmod(Weapon wep, entity actor, int c, entity wepent)
 .vector anim_idle;
 .vector anim_reload;
 
+.entity muzzle_flash;
+
 // static frame globals
 
 ENUMCLASS(WFRAME)
@@ -398,6 +400,6 @@ void wframe_send(entity actor, entity weaponentity, int wepframe, float attackra
 #endif
 
 #ifdef SVQC
-void W_MuzzleFlash(entity actor, .entity weaponentity, entity eff, vector shotorg, vector shotdir);
+void W_MuzzleFlash(entity actor, .entity weaponentity, entity eff, entity muzzlemodel, vector shotorg, vector shotdir);
 #endif
 #endif
index 1090ce81d6c6cfc9639588d04131db5b594a4d13..986d016b1a69d04c6183dea76584f16eaac61e1a 100644 (file)
@@ -131,7 +131,7 @@ void W_Arc_Attack_Bolt(Weapon thiswep, entity actor, .entity weaponentity)
 
        W_SetupShot(actor, weaponentity, false, 2, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR(arc, bolt_damage), WEP_ARC.m_id | HITTYPE_SECONDARY);
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_ARC_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_ARC_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 
        missile = new(missile);
        missile.owner = missile.realowner = actor;
index 350268efccaac1878f17dd12a81b188a2f933ece..00919e68f8c0875357dd04cdd8d76264b46fc440 100644 (file)
@@ -55,7 +55,7 @@ void W_Blaster_Attack(
        vector s_forward = v_forward * cos(atk_shotangle * DEG2RAD) + v_up * sin(atk_shotangle * DEG2RAD);
 
        W_SetupShot_Dir(actor, weaponentity, s_forward, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_B, atk_damage, atk_deathtype);
-       W_MuzzleFlash(actor, weaponentity, EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_BLASTER_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 
        entity missile = new(blasterbolt);
        missile.owner = missile.realowner = actor;
index 680d961ca7b131a4b0132cdfad1fa64cd508e5a3..bfb9499f493ac88537288bb55d984250a20624e8 100644 (file)
@@ -307,7 +307,7 @@ void W_Crylink_Attack(Weapon thiswep, entity actor, .entity weaponentity)
        up = v_up;
 
        shots = WEP_CVAR_PRI(crylink, shots);
-       W_MuzzleFlash(actor, weaponentity, EFFECT_CRYLINK_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_CRYLINK_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
        proj = prevproj = firstproj = NULL;
        for(counter = 0; counter < shots; ++counter)
        {
@@ -420,7 +420,7 @@ void W_Crylink_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
        up = v_up;
 
        shots = WEP_CVAR_SEC(crylink, shots);
-       W_MuzzleFlash(actor, weaponentity, EFFECT_CRYLINK_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_CRYLINK_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
        proj = prevproj = firstproj = NULL;
        for(counter = 0; counter < shots; ++counter)
        {
index 4a622275bc06accad1122bac1e17361f930212c4..5a1d56e39aa19b35dc7909236cb578b7f1e85769 100644 (file)
@@ -308,7 +308,7 @@ void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity, int
        W_DecreaseAmmo(thiswep, actor, WEP_CVAR(devastator, ammo), weaponentity);
 
        W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(devastator, damage), thiswep.m_id);
-       W_MuzzleFlash(actor, weaponentity, EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_ROCKET_MUZZLEFLASH, MDL_DEVASTATOR_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
 
        entity missile = WarpZone_RefSys_SpawnSameRefSys(actor);
        missile.weaponentity_fld = weaponentity;
@@ -351,14 +351,6 @@ void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity, int
 
        CSQCProjectile(missile, WEP_CVAR(devastator, guiderate) == 0 && WEP_CVAR(devastator, speedaccel) == 0, PROJECTILE_ROCKET, false); // because of fly sound
 
-       // muzzle flash for 1st person view
-       // TODO: handle on the client side
-       entity flash = spawn();
-       setmodel(flash, MDL_DEVASTATOR_MUZZLEFLASH); // precision set below
-       SUB_SetFade(flash, time, 0.1);
-       flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
-       W_AttachToShotorg(actor, weaponentity, flash, '5 0 0');
-
        // common properties
        MUTATOR_CALLHOOK(EditProjectile, actor, missile);
 
index f2bcc6013aa91ef9d8567e7e7101327fe64c529a..369267ad16c1299b804be520001c22ee961dd72f 100644 (file)
@@ -227,7 +227,7 @@ void W_Electro_Attack_Bolt(Weapon thiswep, entity actor, .entity weaponentity)
                thiswep.m_id
        );
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_ELECTRO_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 
        proj = new(electro_bolt);
        proj.owner = proj.realowner = actor;
@@ -378,7 +378,7 @@ void W_Electro_Attack_Orb(Weapon thiswep, entity actor, .entity weaponentity)
 
        w_shotdir = v_forward; // no TrueAim for grenades please
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_ELECTRO_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 
        entity proj = new(electro_orb);
        proj.owner = proj.realowner = actor;
index 3e36d7e69b74e157e1e16c6b80b7ddbefbd0e30a..d658c8b8049efecc6f756594f4ab13f946e76742 100644 (file)
@@ -137,7 +137,7 @@ void W_Fireball_Attack1(entity actor, .entity weaponentity)
 {
        W_SetupShot_ProjectileSize(actor, weaponentity, '-16 -16 -16', '16 16 16', false, 2, SND_FIREBALL_FIRE2, CH_WEAPON_A, WEP_CVAR_PRI(fireball, damage) + WEP_CVAR_PRI(fireball, bfgdamage), WEP_FIREBALL.m_id);
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_FIREBALL_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_FIREBALL_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 
        entity proj = new(plasma_prim);
        proj.owner = proj.realowner = actor;
@@ -176,7 +176,7 @@ void W_Fireball_AttackEffect(entity actor, .entity weaponentity, float i, vector
 {
        W_SetupShot_ProjectileSize(actor, weaponentity, '-16 -16 -16', '16 16 16', false, 0, SND_Null, 0, 0, WEP_FIREBALL.m_id); // TODO: probably doesn't need deathtype, just a prefire effect
        w_shotorg += f_diff.x * v_up + f_diff.y * v_right;
-       W_MuzzleFlash(actor, weaponentity, EFFECT_FIREBALL_PRE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_FIREBALL_PRE_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 }
 
 void W_Fireball_Attack1_Frame4(Weapon thiswep, entity actor, .entity weaponentity, int fire)
@@ -275,7 +275,7 @@ void W_Fireball_Attack2(entity actor, .entity weaponentity)
        traceline(w_shotorg, w_shotorg + f_diff_x * v_up + f_diff_y * v_right, MOVE_NORMAL, actor);
        w_shotorg = trace_endpos;
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_FIREBALL_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_FIREBALL_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 
        proj = new(grenade);
        proj.owner = proj.realowner = actor;
index 260f3425f773278c5cd3e1880e4f358b09ee5557..2f7c9912c67e8187029381df39383859c3f1c39d 100644 (file)
@@ -83,7 +83,7 @@ void W_Hagar_Attack(Weapon thiswep, entity actor, .entity weaponentity)
 
        W_SetupShot(actor, weaponentity, false, 2, SND_HAGAR_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(hagar, damage), thiswep.m_id);
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_HAGAR_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_HAGAR_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 
        missile = new(missile);
        missile.owner = missile.realowner = actor;
@@ -129,7 +129,7 @@ void W_Hagar_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
 
        W_SetupShot(actor, weaponentity, false, 2, SND_HAGAR_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage), thiswep.m_id | HITTYPE_SECONDARY);
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_HAGAR_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_HAGAR_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 
        missile = new(missile);
        missile.owner = missile.realowner = actor;
@@ -185,7 +185,7 @@ void W_Hagar_Attack2_Load_Release(Weapon thiswep, entity actor, .entity weaponen
 
        shots = actor.(weaponentity).hagar_load;
        W_SetupShot(actor, weaponentity, false, 2, SND_HAGAR_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage) * shots, thiswep.m_id | HITTYPE_SECONDARY);
-       W_MuzzleFlash(actor, weaponentity, EFFECT_HAGAR_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_HAGAR_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 
        forward = v_forward;
        right = v_right;
index 71c2c73202bf10a65bbd2a02967a4ab20269ccb1..949b1760265c4bb0bb4c26eb2c3c3efb1da5ecb5 100644 (file)
@@ -31,7 +31,7 @@ void W_HLAC_Attack(Weapon thiswep, entity actor, .entity weaponentity)
         spread = spread * WEP_CVAR_PRI(hlac, spread_crouchmod);
 
        W_SetupShot(actor, weaponentity, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(hlac, damage), thiswep.m_id);
-       W_MuzzleFlash(actor, weaponentity, EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_BLASTER_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
        if(!autocvar_g_norecoil)
        {
                actor.punchangle_x = random() - 0.5;
@@ -81,7 +81,7 @@ void W_HLAC_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
         spread = spread * WEP_CVAR_SEC(hlac, spread_crouchmod);
 
        W_SetupShot(actor, weaponentity, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hlac, damage), thiswep.m_id | HITTYPE_SECONDARY);
-       W_MuzzleFlash(actor, weaponentity, EFFECT_BLASTER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_BLASTER_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 
        missile = new(hlacbolt);
        missile.owner = missile.realowner = actor;
index 94128ea44d17c52b0ef472a71c8d9bbef655cc94..8e203d41c80377b788ba463266c0c9c64f262251 100644 (file)
@@ -2,43 +2,6 @@
 
 #ifdef SVQC
 
-void W_MachineGun_MuzzleFlash_Think(entity this)
-{
-       this.frame += 2;
-       this.scale *= 0.5;
-       this.alpha -= 0.25;
-       this.nextthink = time + 0.05;
-
-       if(this.alpha <= 0)
-       {
-               setthink(this, SUB_Remove);
-               this.nextthink = time;
-               this.realowner.muzzle_flash = NULL;
-               return;
-       }
-
-}
-
-void W_MachineGun_MuzzleFlash(entity actor, .entity weaponentity)
-{
-       entity wepent = actor.(weaponentity);
-
-       if(wepent.muzzle_flash == NULL)
-               wepent.muzzle_flash = spawn();
-
-       // muzzle flash for 1st person view
-       setmodel(wepent.muzzle_flash, MDL_MACHINEGUN_MUZZLEFLASH); // precision set below
-
-       wepent.muzzle_flash.scale = 0.75;
-       setthink(wepent.muzzle_flash, W_MachineGun_MuzzleFlash_Think);
-       wepent.muzzle_flash.nextthink = time + 0.02;
-       wepent.muzzle_flash.frame = 2;
-       wepent.muzzle_flash.alpha = 0.75;
-       wepent.muzzle_flash.angles_z = random() * 180;
-       wepent.muzzle_flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
-       wepent.muzzle_flash.owner = wepent.muzzle_flash.realowner = wepent;
-}
-
 void W_MachineGun_Attack(Weapon thiswep, int deathtype, entity actor, .entity weaponentity)
 {
        W_SetupShot(actor, weaponentity, true, 0, SND_UZI_FIRE, CH_WEAPON_A, ((actor.(weaponentity).misc_bulletcounter == 1) ? WEP_CVAR(machinegun, first_damage) : WEP_CVAR(machinegun, sustained_damage)), deathtype);
@@ -55,10 +18,7 @@ void W_MachineGun_Attack(Weapon thiswep, int deathtype, entity actor, .entity we
        else
                fireBullet(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, sustained_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), WEP_CVAR(machinegun, sustained_force), deathtype, EFFECT_BULLET);
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
-
-       W_MachineGun_MuzzleFlash(actor, weaponentity);
-       W_AttachToShotorg(actor, weaponentity, actor.(weaponentity).muzzle_flash, '5 0 0');
+       W_MuzzleFlash(actor, weaponentity, EFFECT_MACHINEGUN_MUZZLEFLASH, MDL_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
 
        // casing code
        if(autocvar_g_casings >= 2)
@@ -131,10 +91,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity
 
        actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
-
-       W_MachineGun_MuzzleFlash(actor, weaponentity);
-       W_AttachToShotorg(actor, weaponentity, actor.(weaponentity).muzzle_flash, '5 0 0');
+       W_MuzzleFlash(actor, weaponentity, EFFECT_MACHINEGUN_MUZZLEFLASH, MDL_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
 
        if(autocvar_g_casings >= 2) // casing code
        {
@@ -157,10 +114,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit
 
        fireBullet(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, burst_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), WEP_CVAR(machinegun, sustained_force), thiswep.m_id, EFFECT_BULLET);
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
-
-       W_MachineGun_MuzzleFlash(actor, weaponentity);
-       W_AttachToShotorg(actor, weaponentity, actor.(weaponentity).muzzle_flash, '5 0 0');
+       W_MuzzleFlash(actor, weaponentity, EFFECT_MACHINEGUN_MUZZLEFLASH, MDL_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
 
        if(autocvar_g_casings >= 2) // casing code
        {
index 9c13df3c6eafe6ab4eb99611e5bc89fa5f62005d..bf676e0eca114208446cd8f323756acb4f084dfe 100644 (file)
@@ -254,9 +254,6 @@ void W_MineLayer_Damage(entity this, entity inflictor, entity attacker, float da
 
 void W_MineLayer_Attack(Weapon thiswep, entity actor, .entity weaponentity)
 {
-       entity mine;
-       entity flash;
-
        // scan how many mines we placed, and return if we reached our limit
        if(WEP_CVAR(minelayer, limit))
        {
@@ -273,9 +270,9 @@ void W_MineLayer_Attack(Weapon thiswep, entity actor, .entity weaponentity)
        W_DecreaseAmmo(thiswep, actor, WEP_CVAR(minelayer, ammo), weaponentity);
 
        W_SetupShot_ProjectileSize(actor, weaponentity, '-4 -4 -4', '4 4 4', false, 5, SND_MINE_FIRE, CH_WEAPON_A, WEP_CVAR(minelayer, damage), thiswep.m_id);
-       W_MuzzleFlash(actor, weaponentity, EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_ROCKET_MUZZLEFLASH, MDL_MINELAYER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
 
-       mine = WarpZone_RefSys_SpawnSameRefSys(actor);
+       entity mine = WarpZone_RefSys_SpawnSameRefSys(actor);
        mine.weaponentity_fld = weaponentity;
        IL_PUSH(g_mines, mine);
        mine.owner = mine.realowner = actor;
@@ -317,14 +314,6 @@ void W_MineLayer_Attack(Weapon thiswep, entity actor, .entity weaponentity)
 
        CSQCProjectile(mine, true, PROJECTILE_MINE, true);
 
-       // muzzle flash for 1st person view
-       // TODO: handle on the client
-       flash = spawn();
-       setmodel(flash, MDL_MINELAYER_MUZZLEFLASH); // precision set below
-       SUB_SetFade(flash, time, 0.1);
-       flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
-       W_AttachToShotorg(actor, weaponentity, flash, '5 0 0');
-
        // common properties
 
        MUTATOR_CALLHOOK(EditProjectile, actor, mine);
index 089075ee20a4bdece42ef01796afba3f7ce60fbe..0db0414122390ccff71fed3c591258a6fb3895c8 100644 (file)
@@ -154,7 +154,7 @@ void W_Mortar_Attack(Weapon thiswep, entity actor, .entity weaponentity)
        W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 4, SND_GRENADE_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(mortar, damage), thiswep.m_id);
        w_shotdir = v_forward; // no TrueAim for grenades please
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_GRENADE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_GRENADE_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 
        entity gren = new(grenade);
        gren.owner = gren.realowner = actor;
@@ -206,7 +206,7 @@ void W_Mortar_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
        W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 4, SND_GRENADE_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(mortar, damage), thiswep.m_id | HITTYPE_SECONDARY);
        w_shotdir = v_forward; // no TrueAim for grenades please
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_GRENADE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_GRENADE_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 
        gren = new(grenade);
        gren.owner = gren.realowner = actor;
index f5c8b7f001e0a51ff37d61a4f9a05655ce44f635..273d820c3057ada6aec3bf5e894f2421aab0eeac 100644 (file)
@@ -10,7 +10,7 @@ void W_Rifle_FireBullet(Weapon thiswep, .entity weaponentity, float pSpread, flo
 
        W_SetupShot(actor, weaponentity, true, 2, pSound, CH_WEAPON_A, pDamage * pShots, deathtype);
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_RIFLE_MUZZLEFLASH, w_shotorg, w_shotdir * 2000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_RIFLE_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 2000);
 
        if(PHYS_INPUT_BUTTON_ZOOM(actor) | PHYS_INPUT_BUTTON_ZOOMSCRIPT(actor)) // if zoomed, shoot from the eye
        {
index a82762fa4009213b8cedc901288a91b26cc80a56..de50dd7713d927ddc177acbe7fa593e1db93392a 100644 (file)
@@ -171,7 +171,7 @@ void W_Seeker_Fire_Missile(Weapon thiswep, entity actor, .entity weaponentity, v
        makevectors(actor.v_angle);
        W_SetupShot_ProjectileSize(actor, weaponentity, '-2 -2 -2', '2 2 2', false, 2, SND_SEEKER_FIRE, CH_WEAPON_A, 0, ((m_target != NULL) ? thiswep.m_id | HITTYPE_SECONDARY : thiswep.m_id));
        w_shotorg += f_diff;
-       W_MuzzleFlash(actor, weaponentity, EFFECT_SEEKER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_SEEKER_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 
        //actor.detornator         = false;
 
@@ -269,7 +269,7 @@ void W_Seeker_Fire_Flac(Weapon thiswep, entity actor, .entity weaponentity)
        W_SetupShot_ProjectileSize(actor, weaponentity, '-2 -2 -2', '2 2 2', false, 2, SND_FLAC_FIRE, CH_WEAPON_A, WEP_CVAR(seeker, flac_damage), thiswep.m_id | HITTYPE_SECONDARY);
        w_shotorg += f_diff;
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_HAGAR_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_HAGAR_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 
        missile                                 = new(missile);
        missile.owner                   = missile.realowner = actor;
index 0fdb620b288bb2087d491f6144d2e541f5022044..30643a8aaa2991f2ce69ec93910edb3e1f109bf6 100644 (file)
@@ -31,7 +31,7 @@ void W_Shotgun_Attack(Weapon thiswep, entity actor, .entity weaponentity, float
        if(lag && bullets > 0)
                antilag_restore_all(actor);
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_SHOTGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_SHOTGUN_MUZZLEFLASH, MDL_SHOTGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
 
        // casing code
        if(autocvar_g_casings >= 1)
@@ -40,15 +40,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
-       // TODO: handle on the client
-       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;
index 15b50f8ca456ef85b8bd87f4f2562cd034d44f7b..171f922cf329dadf8618a62bd05aed9e0e7dcd1f 100644 (file)
@@ -127,7 +127,7 @@ void W_Vaporizer_Attack(Weapon thiswep, entity actor, .entity weaponentity)
        FireRailgunBullet(actor, weaponentity, w_shotorg, w_shotorg + w_shotdir * max_shot_distance, vaporizer_damage, WEP_CVAR_PRI(vaporizer, force), 0, 0, 0, 0, thiswep.m_id);
 
        // do this now, as goodhits is disabled below
-       W_MuzzleFlash(actor, weaponentity, EFFECT_VORTEX_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_VORTEX_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
        SendCSQCVaporizerBeamParticle(actor, damage_goodhits);
 
        if(yoda && flying)
@@ -187,7 +187,7 @@ void W_RocketMinsta_Attack2(entity actor, .entity weaponentity)
 
        W_SetupShot_ProjectileSize (actor, weaponentity, '0 0 -3', '0 0 -3', false, 2, SND_CRYLINK_FIRE, CH_WEAPON_A, autocvar_g_rm_laser_damage, WEP_ELECTRO.m_id);
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_ELECTRO_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 
     while(counter < total)
        {
@@ -239,7 +239,7 @@ void W_RocketMinsta_Attack3 (entity actor, .entity weaponentity)
 
        W_SetupShot_ProjectileSize (actor, weaponentity, '0 0 -3', '0 0 -3', false, 2, SND_ELECTRO_FIRE2, CH_WEAPON_A, autocvar_g_rm_laser_damage, WEP_ELECTRO.m_id);
 
-       W_MuzzleFlash(actor, weaponentity, EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+       W_MuzzleFlash(actor, weaponentity, EFFECT_ELECTRO_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
 
     while(counter < total)
        {
index 12fb5bde276e54a75d4a3bc421a402eb3e6e35c9..4e10a5839b9f4c318a49d32899b103f3437dfbbf 100644 (file)
@@ -152,7 +152,7 @@ void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float i
        actor.vortex_lasthit = damage_goodhits;
 
        //beam and muzzle flash done on client
-    W_MuzzleFlash(actor, weaponentity, EFFECT_VORTEX_MUZZLEFLASH, w_shotorg, w_shotdir * 1000);
+    W_MuzzleFlash(actor, weaponentity, EFFECT_VORTEX_MUZZLEFLASH, MDL_Null, w_shotorg, w_shotdir * 1000);
        SendCSQCVortexBeamParticle(charge);
 
        W_DecreaseAmmo(thiswep, actor, myammo, weaponentity);
index e12970a9c63d3d912c881170a7c94ddd6a9cfab0..1e50f3edb224936e5d0047e68c801b12e4c08e8b 100644 (file)
@@ -357,7 +357,6 @@ const int ACTIVE_TOGGLE     = 3;
 .entity iceblock;
 .entity frozen_by; // for ice fields
 
-.entity muzzle_flash;
 .float misc_bulletcounter;     // replaces uzi & hlac bullet counter.
 
 void PlayerUseKey(entity this);
index 72d1467411ece1957d11bd00556c94c1fb84c86c..48d02d57b57d8017105521971fa632118b055282 100644 (file)
@@ -364,7 +364,7 @@ void FireGrapplingHook(entity actor, .entity weaponentity)
        vector oldmovedir = actor.(weaponentity).movedir;
        actor.(weaponentity).movedir = vs;
        W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', true, 0, SND_HOOK_FIRE, CH_WEAPON_B, 0, WEP_HOOK.m_id);
-       W_MuzzleFlash(actor, weaponentity, EFFECT_HOOK_MUZZLEFLASH, w_shotorg, '0 0 0');
+       W_MuzzleFlash(actor, weaponentity, EFFECT_HOOK_MUZZLEFLASH, MDL_Null, w_shotorg, '0 0 0');
        actor.(weaponentity).movedir = oldmovedir;
 
        entity missile = WarpZone_RefSys_SpawnSameRefSys(actor);