From 85b6389bf1d0268bd849c4087460f8f760ef99ae Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 30 Dec 2011 10:01:45 +0100 Subject: [PATCH] get rid of the svqc death anim hack against "popping in"; do the same in CSQC by playing the end of the anim instead --- qcsrc/client/csqcmodel_hooks.qc | 43 ++++++++++++++++++++++++--------- qcsrc/server/cl_client.qc | 2 -- qcsrc/server/cl_player.qc | 26 +++++--------------- qcsrc/server/defs.qh | 5 ++-- 4 files changed, 40 insertions(+), 36 deletions(-) diff --git a/qcsrc/client/csqcmodel_hooks.qc b/qcsrc/client/csqcmodel_hooks.qc index 1ce9a9663..e196396f0 100644 --- a/qcsrc/client/csqcmodel_hooks.qc +++ b/qcsrc/client/csqcmodel_hooks.qc @@ -1,4 +1,4 @@ - +.float isplayermodel; // FEATURE: LOD .float lodmodelindex0; @@ -148,12 +148,30 @@ void CSQCPlayer_FallbackFrame_PreUpdate(void) self.frame3 = self.csqcmodel_saveframe3; self.frame4 = self.csqcmodel_saveframe4; } -void CSQCPlayer_FallbackFrame_PostUpdate(void) +void CSQCPlayer_FallbackFrame_PostUpdate(float isnew) { self.csqcmodel_saveframe = self.frame; self.csqcmodel_saveframe2 = self.frame2; self.csqcmodel_saveframe3 = self.frame3; self.csqcmodel_saveframe4 = self.frame4; + + // hack for death animations: set their frametime to zero in case a + // player "pops in" + if(isnew) + { +#define FIX_FRAMETIME(f,ft) \ + switch(self.f) \ + { \ + case 0: // anim_die1 \ + case 1: // anim_die2 \ + self.ft = 0; \ + break; \ + } + FIX_FRAMETIME(frame, frame1time); + FIX_FRAMETIME(frame2, frame2time); + FIX_FRAMETIME(frame3, frame3time); + FIX_FRAMETIME(frame4, frame4time); + } } float CSQCPlayer_FallbackFrame(float f) { @@ -366,7 +384,7 @@ void CSQCModel_Hook_PreDraw(float isplayer, float islocalplayer) else self.drawmask = MASK_NORMAL; - if(isplayer) + if(self.isplayermodel) // this checks if it's a player MODEL! { CSQCPlayer_GlowMod_Apply(); CSQCPlayer_ForceModel_Apply(islocalplayer); @@ -374,30 +392,33 @@ void CSQCModel_Hook_PreDraw(float isplayer, float islocalplayer) CSQCPlayer_FallbackFrame_Apply(); } - if(!isplayer) + if(!isplayer) // this checks if it's a player SLOT! CSQCModel_AutoTagIndex_Apply(); CSQCModel_Effects_Apply(); } -void CSQCModel_Hook_PreUpdate(float isplayer, float islocalplayer) +void CSQCModel_Hook_PreUpdate(float isnew, float isplayer, float islocalplayer) { + // revert to values from server CSQCModel_Effects_PreUpdate(); - if(isplayer) + if(self.isplayermodel) { - // revert to values from server CSQCPlayer_FallbackFrame_PreUpdate(); CSQCPlayer_ForceModel_PreUpdate(); } } -void CSQCModel_Hook_PostUpdate(float isplayer, float islocalplayer) +void CSQCModel_Hook_PostUpdate(float isnew, float isplayer, float islocalplayer) { - if(isplayer) + // is it a player model? (shared state) + self.isplayermodel = (substring(self.model, 0, 14) == "models/player/"); + + // save values set by server + if(self.isplayermodel) { - // save values set by server CSQCPlayer_ForceModel_PostUpdate(); - CSQCPlayer_FallbackFrame_PostUpdate(); + CSQCPlayer_FallbackFrame_PostUpdate(isnew); } CSQCModel_Effects_PostUpdate(); } diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index c409b343a..e8ccc07d7 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -466,7 +466,6 @@ void PutObserverInServer (void) self.pauseregen_finished = 0; self.damageforcescale = 0; self.death_time = 0; - self.dead_frame = 0; self.alpha = 0; self.scale = 0; self.fade_time = 0; @@ -776,7 +775,6 @@ void PutClientInServer (void) } self.damageforcescale = 2; self.death_time = 0; - self.dead_frame = 0; self.alpha = 0; self.scale = 0; self.fade_time = 0; diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index 5b369c27c..deb08aa9c 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -167,7 +167,6 @@ void CopyBody(float keepvelocity) self.animstate_override = oldself.animstate_override; self.animstate_looping = oldself.animstate_looping; self.frame = oldself.frame; - self.dead_frame = oldself.dead_frame; self.pain_finished = oldself.pain_finished; self.health = oldself.health; self.armorvalue = oldself.armorvalue; @@ -239,8 +238,8 @@ void player_setupanimsformodel() self.anim_runbackwards = animfixfps(self, '14 1 1'); self.anim_strafeleft = animfixfps(self, '15 1 1'); self.anim_straferight = animfixfps(self, '16 1 1'); - self.anim_dead1 = animfixfps(self, '17 1 1'); - self.anim_dead2 = animfixfps(self, '18 1 1'); + //self.anim_dead1 = animfixfps(self, '17 1 1'); + //self.anim_dead2 = animfixfps(self, '18 1 1'); self.anim_forwardright = animfixfps(self, '19 1 1'); self.anim_forwardleft = animfixfps(self, '20 1 1'); self.anim_backright = animfixfps(self, '21 1 1'); @@ -265,18 +264,7 @@ void player_anim (void) updateanim(self.weaponentity); if (self.deadflag != DEAD_NO) - { - if (time > self.animstate_endtime) - { - if (self.maxs_z > 5) - { - self.maxs_z = 5; - setsize(self, self.mins, self.maxs); - } - self.frame = self.dead_frame; - } return; - } if (!self.animstate_override) { @@ -424,7 +412,6 @@ void PlayerCorpseDamage (entity inflictor, entity attacker, float damage, float { // don't use any animations as a gib self.frame = 0; - self.dead_frame = 0; // view just above the floor self.view_ofs = '0 0 4'; @@ -778,14 +765,13 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht else self.respawn_countdown = -1; // do not count down if (random() < 0.5) - { setanim(self, self.anim_die1, FALSE, TRUE, TRUE); - self.dead_frame = self.anim_dead1_x; - } else - { setanim(self, self.anim_die2, FALSE, TRUE, TRUE); - self.dead_frame = self.anim_dead2_x; + if (self.maxs_z > 5) + { + self.maxs_z = 5; + setsize(self, self.mins, self.maxs); } // set damage function to corpse damage self.event_damage = PlayerCorpseDamage; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 4b2684c51..c2b01a801 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -105,7 +105,6 @@ float maxclients; .float play_time; .float death_time; -.float dead_frame; .float fade_time; .float fade_rate; @@ -140,8 +139,8 @@ float maxclients; .vector anim_runbackwards; // player running backward .vector anim_strafeleft; // player shuffling left quickly .vector anim_straferight; // player shuffling right quickly -.vector anim_dead1; // player dead (must be identical to last frame of die1) -.vector anim_dead2; // player dead (must be identical to last frame of die2) +//.vector anim_dead1; // player dead (must be identical to last frame of die1) +//.vector anim_dead2; // player dead (must be identical to last frame of die2) .vector anim_forwardright; // player running forward and right .vector anim_forwardleft; // player running forward and left .vector anim_backright; // player running backward and right -- 2.39.2