From bcd0d62dd89cef4d7a1420d4c29ddc8148ebd1ab Mon Sep 17 00:00:00 2001 From: lordhavoc Date: Thu, 12 Mar 2009 06:52:05 +0000 Subject: [PATCH] fixed muzzleflashes with sv_qcweaponanimation mode implemented support for models/weapons/h_name.dpm (and .animinfo) git-svn-id: svn://svn.icculus.org/nexuiz/trunk@6111 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/cl_client.qc | 1 + data/qcsrc/server/cl_weaponsystem.qc | 36 ++++++++++++++++++++++++--- data/qcsrc/server/g_world.qc | 4 +++ data/qcsrc/server/w_rocketlauncher.qc | 10 +++++++- data/qcsrc/server/w_shotgun.qc | 20 +++++++++++++-- data/qcsrc/server/w_uzi.qc | 10 +++++++- 6 files changed, 73 insertions(+), 8 deletions(-) diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index 52c9966d6..4e2825a23 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -556,6 +556,7 @@ void PutObserverInServer (void) self.weapon = 0; self.weaponmodel = ""; self.weaponentity = world; + self.exteriorweaponentity = world; self.killcount = -666; self.velocity = '0 0 0'; self.avelocity = '0 0 0'; diff --git a/data/qcsrc/server/cl_weaponsystem.qc b/data/qcsrc/server/cl_weaponsystem.qc index 9e80418ba..90c8735dc 100644 --- a/data/qcsrc/server/cl_weaponsystem.qc +++ b/data/qcsrc/server/cl_weaponsystem.qc @@ -280,12 +280,16 @@ void CL_Weaponentity_Think() self.frame = self.anim_idle_x; if (self.owner.weaponentity != self) { + if (self.weaponentity) + remove(self.weaponentity); remove(self); return; } if (self.owner.deadflag != DEAD_NO) { self.model = ""; + if (self.weaponentity) + self.weaponentity.model = ""; return; } if (self.cnt != self.owner.weapon || self.dmg != self.owner.modelindex || self.deadflag != self.owner.deadflag) @@ -298,13 +302,31 @@ void CL_Weaponentity_Think() float animfile; if (self.owner.weaponname != "") { + // if there is a child entity, hide it until we're sure we use it + if (self.weaponentity) + self.weaponentity.model = ""; if (qcweaponanimation) setmodel(self, strcat("models/weapons/v_", self.owner.weaponname, ".md3")); // precision set below else { - animfilename = strcat("models/weapons/w_", self.owner.weaponname, ".dpm.animinfo"); + animfilename = strcat("models/weapons/h_", self.owner.weaponname, ".dpm.animinfo"); animfile = fopen(animfilename, FILE_READ); if (animfile >= 0) + { + if (!self.weaponentity) + self.weaponentity = spawn(); + setmodel(self, strcat("models/weapons/h_", self.owner.weaponname, ".dpm")); // precision set below + setmodel(self.weaponentity, strcat("models/weapons/v_", self.owner.weaponname, ".md3")); // precision does not matter + setattachment(self.weaponentity, self, "weapon"); + } + else + { + animfilename = strcat("models/weapons/w_", self.owner.weaponname, ".dpm.animinfo"); + animfile = fopen(animfilename, FILE_READ); + if (animfile >= 0) + setmodel(self, strcat("models/weapons/w_", self.owner.weaponname, ".dpm")); // precision set below + } + if (animfile >= 0) { animparseerror = FALSE; self.anim_fire1 = animparseline(animfile); @@ -314,7 +336,6 @@ void CL_Weaponentity_Think() fclose(animfile); if (animparseerror) print("Parse error in ", animfilename, ", some player animations are broken\n"); - setmodel(self, strcat("models/weapons/w_", self.owner.weaponname, ".dpm")); // precision set below } else { @@ -340,7 +361,9 @@ void CL_Weaponentity_Think() e.modelindex = self.modelindex; float idx; vector v; - idx = gettagindex(e, "bone02"); + idx = gettagindex(e, "shot"); + if (!idx) + idx = gettagindex(e, "bone02"); if(idx) { v = gettaginfo(e, idx); @@ -366,6 +389,12 @@ void CL_Weaponentity_Think() self.alpha = 1; self.colormap = self.owner.colormap; + if (self.weaponentity) + { + self.weaponentity.effects = self.effects & EF_ADDITIVE; + self.weaponentity.alpha = self.alpha; + self.weaponentity.colormap = self.colormap; + } self.angles = '0 0 0'; local float f; @@ -567,7 +596,6 @@ void CL_SpawnWeaponentity() self.weaponentity.classname = "weaponentity"; self.weaponentity.solid = SOLID_NOT; self.weaponentity.owner = self; - self.weaponentity.weaponentity = self.weaponentity; setmodel(self.weaponentity, ""); // precision set when changed self.weaponentity.origin = '0 0 0'; self.weaponentity.angles = '0 0 0'; diff --git a/data/qcsrc/server/g_world.qc b/data/qcsrc/server/g_world.qc index aa20292dc..e668ce21c 100644 --- a/data/qcsrc/server/g_world.qc +++ b/data/qcsrc/server/g_world.qc @@ -1243,7 +1243,11 @@ void FixIntermissionClient(entity e) e.movetype = MOVETYPE_NONE; e.takedamage = DAMAGE_NO; if(e.weaponentity) + { e.weaponentity.effects = EF_NODRAW; + if (e.weaponentity.weaponentity) + e.weaponentity.weaponentity.effects = EF_NODRAW; + } if(clienttype(e) == CLIENTTYPE_REAL) { stuffcmd(e, "\nscr_printspeed 1000000\n"); diff --git a/data/qcsrc/server/w_rocketlauncher.qc b/data/qcsrc/server/w_rocketlauncher.qc index 546a9f65e..398bb5896 100644 --- a/data/qcsrc/server/w_rocketlauncher.qc +++ b/data/qcsrc/server/w_rocketlauncher.qc @@ -246,7 +246,15 @@ void W_Rocket_Attack (void) flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient; setorigin (flash, '5 0 0'); setmodel (flash, "models/flash.md3"); // precision set below - setattachment(flash, self.weaponentity, "bone02"); + if (gettagindex(self.weaponentity, "shot")) + setattachment(flash, self.weaponentity, "shot"); + else if (gettagindex(self.weaponentity, "bone02")) + setattachment(flash, self.weaponentity, "bone02"); + else + { + setorigin(flash, '27 0 5'); + setattachment(flash, self.weaponentity, ""); + } SUB_SetFade (flash, time, 0.1); // muzzle flash for 3rd person view diff --git a/data/qcsrc/server/w_shotgun.qc b/data/qcsrc/server/w_shotgun.qc index 75461ca0c..7abfcecb7 100644 --- a/data/qcsrc/server/w_shotgun.qc +++ b/data/qcsrc/server/w_shotgun.qc @@ -33,7 +33,15 @@ void W_Shotgun_Attack (void) flash = spawn(); setorigin(flash, '5 0 0'); setmodel(flash, "models/uziflash.md3"); // precision set below - setattachment(flash, self.weaponentity, "bone02"); + if (gettagindex(self.weaponentity, "shot")) + setattachment(flash, self.weaponentity, "shot"); + else if (gettagindex(self.weaponentity, "bone02")) + setattachment(flash, self.weaponentity, "bone02"); + else + { + setorigin(flash, '48 0 5'); + setattachment(flash, self.weaponentity, ""); + } flash.owner = self; flash.viewmodelforclient = self; flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient; @@ -78,7 +86,15 @@ void W_Shotgun_Attack2 (void) flash = spawn(); setorigin(flash, '53 5 0'); setmodel(flash, "models/uziflash.md3"); // precision set below - setattachment(flash, self.weaponentity, "bone01"); + if (gettagindex(self.weaponentity, "shot")) + setattachment(flash, self.weaponentity, "shot"); + else if (gettagindex(self.weaponentity, "bone01")) + setattachment(flash, self.weaponentity, "bone01"); + else + { + setorigin(flash, '48 0 5'); + setattachment(flash, self.weaponentity, ""); + } flash.owner = self; flash.viewmodelforclient = self; flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient; diff --git a/data/qcsrc/server/w_uzi.qc b/data/qcsrc/server/w_uzi.qc index aa6677c9c..8c1a47b37 100644 --- a/data/qcsrc/server/w_uzi.qc +++ b/data/qcsrc/server/w_uzi.qc @@ -44,7 +44,15 @@ void W_Uzi_Attack (float deathtype) flash = spawn(); setorigin(flash, '5 0 0'); setmodel(flash, "models/uziflash.md3"); // precision set below - setattachment(flash, self.weaponentity, "bone02"); + if (gettagindex(self.weaponentity, "shot")) + setattachment(flash, self.weaponentity, "shot"); + else if (gettagindex(self.weaponentity, "bone02")) + setattachment(flash, self.weaponentity, "bone02"); + else + { + setorigin(flash, '48 0 5'); + setattachment(flash, self.weaponentity, ""); + } flash.owner = self; flash.viewmodelforclient = self; flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient; -- 2.39.2