From 34a170e000dfee7b3e13de48f12e7f0d64cefbc8 Mon Sep 17 00:00:00 2001 From: div0 Date: Mon, 16 Mar 2009 09:53:02 +0000 Subject: [PATCH] simpler muzzle flash handling git-svn-id: svn://svn.icculus.org/nexuiz/trunk@6192 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/cl_weaponsystem.qc | 40 ++++++++++++++++++++++++++- data/qcsrc/server/w_rocketlauncher.qc | 21 ++------------ data/qcsrc/server/w_shotgun.qc | 16 ++--------- data/qcsrc/server/w_uzi.qc | 24 +++------------- 4 files changed, 48 insertions(+), 53 deletions(-) diff --git a/data/qcsrc/server/cl_weaponsystem.qc b/data/qcsrc/server/cl_weaponsystem.qc index f7e7acbef..02087e6ab 100644 --- a/data/qcsrc/server/cl_weaponsystem.qc +++ b/data/qcsrc/server/cl_weaponsystem.qc @@ -355,8 +355,9 @@ void CL_Weaponentity_Think() self.angles = '0 0 0'; makevectors(self.angles_x * '-1 0 0' + self.angles_y * '0 1 0' + self.angles_z * '0 0 1'); self.movedir = weapon_offset_x * v_forward - weapon_offset_y * v_right + weapon_offset_z * v_up + weapon_adjust; - self.movedir_x += 30; + self.movedir_x += 32; self.spawnorigin = self.movedir; + // oldorigin - not calculated here } else { @@ -388,6 +389,17 @@ void CL_Weaponentity_Think() self.spawnorigin = self.movedir; } + float idx; + idx = gettagindex(self, "weapon"); + if(idx) + { + self.oldorigin = self.movedir - gettaginfo(self, idx); + } + else + { + self.oldorigin = self.movedir; + } + self.viewmodelforclient = self.owner; } @@ -1084,3 +1096,29 @@ void W_SetupProjectileVelocity(entity missile) missile.velocity = W_CalculateProjectileVelocity(missile.owner.velocity, missile.velocity); } + +void W_AttachToShotorg(entity flash, vector offset) +{ + entity xflash; + flash.owner = self; + flash.angles_z = random() * 360; + if(qcweaponanimation) + { + setorigin(flash, w_shotorg + w_shotdir * 50); + flash.angles = vectoangles(w_shotdir); + flash.angles_z = random() * 360; + } + else + { + setattachment(flash, self.weaponentity, "shot"); + setorigin(flash, offset); + + xflash = spawn(); + copyentity(flash, xflash); + + flash.viewmodelforclient = self; + + setattachment(xflash, self.exteriorweaponentity, ""); + setorigin(xflash, self.weaponentity.oldorigin + offset); + } +} diff --git a/data/qcsrc/server/w_rocketlauncher.qc b/data/qcsrc/server/w_rocketlauncher.qc index d93316bc9..38fb00453 100644 --- a/data/qcsrc/server/w_rocketlauncher.qc +++ b/data/qcsrc/server/w_rocketlauncher.qc @@ -193,7 +193,7 @@ void W_Rocket_Damage (entity inflictor, entity attacker, float damage, float dea void W_Rocket_Attack (void) { local entity missile; - local entity flash, flash2; + local entity flash; if not(self.items & IT_UNLIMITED_WEAPON_AMMO) self.ammo_rockets = self.ammo_rockets - cvar("g_balance_rocketlauncher_ammo"); @@ -240,27 +240,12 @@ void W_Rocket_Attack (void) // muzzle flash for 1st person view flash = spawn (); - flash.angles_z = flash.v_angle_z + random() * 180; - flash.owner = self; - flash.viewmodelforclient = self; - flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient; - setorigin (flash, '5 0 0'); setmodel (flash, "models/flash.md3"); // precision set below - setattachment(flash, self.weaponentity, "shot"); SUB_SetFade (flash, time, 0.1); - - // muzzle flash for 3rd person view - flash2 = spawn (); - flash2.scale = 0.8; - flash2.angles_y = 180; - flash2.angles_z = 90; - setorigin (flash2, '42 0 5'); - setmodel (flash2, "models/flash.md3"); // precision set below - setattachment(flash2, self.exteriorweaponentity, ""); - SUB_SetFade (flash2, time, 0.4); + flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; + W_AttachToShotorg(flash, '5 0 0'); // common properties - flash.effects = flash2.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; } void spawnfunc_weapon_rocketlauncher (void); // defined in t_items.qc diff --git a/data/qcsrc/server/w_shotgun.qc b/data/qcsrc/server/w_shotgun.qc index 0643c99f6..fa11d59aa 100644 --- a/data/qcsrc/server/w_shotgun.qc +++ b/data/qcsrc/server/w_shotgun.qc @@ -34,17 +34,11 @@ void W_Shotgun_Attack (void) // muzzle flash for 1st person view flash = spawn(); - setorigin(flash, '5 0 0'); setmodel(flash, "models/uziflash.md3"); // precision set below - setattachment(flash, self.weaponentity, "shot"); - flash.owner = self; - flash.viewmodelforclient = self; - flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient; flash.think = SUB_Remove; flash.nextthink = time + 0.06; - flash.angles_z = flash.v_angle_z + random() * 180; - flash.alpha = 1; flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; + W_AttachToShotorg(flash, '5 0 0'); } @@ -82,18 +76,12 @@ void W_Shotgun_Attack2 (void) 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); flash = spawn(); - setorigin(flash, '5 0 0'); setmodel(flash, "models/uziflash.md3"); // precision set below - setattachment(flash, self.weaponentity, "shot"); - flash.owner = self; - flash.viewmodelforclient = self; - flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient; flash.scale = 1.2; flash.think = SUB_Remove; flash.nextthink = time + 0.06; - flash.angles_z = flash.v_angle_z + random() * 180; - flash.alpha = 1; flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; + W_AttachToShotorg(flash, '5 0 0'); } // weapon frames diff --git a/data/qcsrc/server/w_uzi.qc b/data/qcsrc/server/w_uzi.qc index b1ddefaee..1c8695a24 100644 --- a/data/qcsrc/server/w_uzi.qc +++ b/data/qcsrc/server/w_uzi.qc @@ -13,7 +13,7 @@ void W_Uzi_Flash_Go() { .float uzi_bulletcounter; void W_Uzi_Attack (float deathtype) { - local entity flash, flash2; + local entity flash; if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { @@ -41,30 +41,14 @@ void W_Uzi_Attack (float deathtype) // muzzle flash for 1st person view flash = spawn(); - setorigin(flash, '5 0 0'); setmodel(flash, "models/uziflash.md3"); // precision set below - setattachment(flash, self.weaponentity, "shot"); - flash.owner = self; - flash.viewmodelforclient = self; - flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient; //SUB_SetFade(flash, time + 0.06, 0); flash.think = W_Uzi_Flash_Go; flash.nextthink = time + 0.02; flash.frame = 2; - - // muzzle flash for 3rd person view - flash2 = spawn(); - setorigin(flash2, '43 1 8'); - setmodel(flash2, "models/uziflash.md3"); // precision set below - setattachment(flash2, self.exteriorweaponentity, ""); - //SUB_SetFade(flash2, time + 0.06, 0); - flash2.think = W_Uzi_Flash_Go; - flash2.nextthink = time + 0.02; - flash2.frame = 2; - // common properties - flash.angles_z = flash2.angles_z = flash.v_angle_z + random() * 180; - flash.alpha = flash2.alpha = 1; - flash.effects = flash2.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; + flash.alpha = 1; + flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; + W_AttachToShotorg(flash, '5 0 0'); // casing code if (cvar("g_casings") >= 2) -- 2.39.2