From 6c9afd07ee6674fb287574d238dd0fb3043259da Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Mon, 9 Jan 2012 19:44:18 +0100 Subject: [PATCH] bring death glow back, fix issues with respawning --- defaultXonotic.cfg | 1 + qcsrc/client/autocvars.qh | 1 + qcsrc/client/csqcmodel_hooks.qc | 39 ++++++++++++++++++++++-------- qcsrc/common/csqcmodel_settings.qh | 2 +- qcsrc/common/util.qc | 4 +-- qcsrc/server/cl_client.qc | 2 +- qcsrc/server/cl_player.qc | 1 + 7 files changed, 36 insertions(+), 14 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 7f85e4d04..eadb6a16f 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -324,6 +324,7 @@ set g_teleport_maxspeed 0 "maximum speed that a player can keep when going throu set g_respawn_ghosts 1 "if 1 dead bodies become ghosts and float away when the player respawns" set g_respawn_ghosts_speed 5 "the speed with which respawn ghosts float and rotate" set g_respawn_ghosts_maxtime 6 "maximum amount of time a respawn ghost can last, minimum time is half this value. 0 disables and ghosts fade when the body would" +set cl_deathglow 0.8 "number of seconds during which dead bodies glow out" set sv_gibhealth 100 "Minus health a dead body must have in order to get gibbed" diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 31fe31845..705e2c519 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -384,3 +384,4 @@ float autocvar_cl_forcemyplayercolors; float autocvar__cl_playerskin; string autocvar__cl_playermodel; float autocvar_cl_precacheplayermodels; +float autocvar_cl_deathglow; diff --git a/qcsrc/client/csqcmodel_hooks.qc b/qcsrc/client/csqcmodel_hooks.qc index c4767c63e..7204981bd 100644 --- a/qcsrc/client/csqcmodel_hooks.qc +++ b/qcsrc/client/csqcmodel_hooks.qc @@ -266,16 +266,6 @@ void CSQCPlayer_FallbackFrame_Apply(void) self.frame4 = CSQCPlayer_FallbackFrame(self.frame4); } -// FEATURE: auto glowmod -.vector glowmod; -void CSQCPlayer_GlowMod_Apply(void) -{ - if(self.colormap > 0) - self.glowmod = colormapPaletteColor(((self.colormap >= 1024) ? self.colormap : stof(getplayerkeyvalue(self.colormap - 1, "colors"))) & 0x0F, TRUE) * 2; - else - self.glowmod = '1 1 1'; -} - // FEATURE: auto tag_index .entity tag_entity; .float tag_entity_lastmodelindex; @@ -386,6 +376,7 @@ void CSQCModel_Effects_PostUpdate(void) void CSQCModel_Effects_Apply(void) { float eff = self.csqcmodel_effects; + eff &~= CSQCMODEL_EF_RESPAWNGHOST; self.renderflags &~= (RF_DEPTHHACK | RF_ADDITIVE | RF_FULLBRIGHT | EF_NOSHADOW | RF_USEAXIS); self.effects = 0; @@ -449,6 +440,34 @@ void CSQCModel_Effects_Apply(void) Projectile_DrawTrail(self.origin); else Projectile_ResetTrail(self.origin); + + if(self.csqcmodel_effects & CSQCMODEL_EF_RESPAWNGHOST) + self.renderflags |= RF_ADDITIVE; + // also special in CSQCPlayer_GlowMod_Apply +} + +// FEATURE: auto glowmod +.vector glowmod; +void CSQCPlayer_GlowMod_Apply(void) +{ + float cm = self.colormap; + + if(self.csqcmodel_effects & CSQCMODEL_EF_RESPAWNGHOST) + cm = 1024; + + if(self.colormap > 0) + self.glowmod = colormapPaletteColor(((self.colormap >= 1024) ? self.colormap : stof(getplayerkeyvalue(self.colormap - 1, "colors"))) & 0x0F, TRUE) * 2; + else + self.glowmod = '1 1 1'; + + if(autocvar_cl_deathglow > 0) + if(self.csqcmodel_isdead) + { + self.glowmod = self.glowmod * bound(0, 1 - (time - self.death_time) / autocvar_cl_deathglow, 1); + // prevent the zero vector + if(self.glowmod_x == 0) + self.glowmod_x = -1; + } } // general functions diff --git a/qcsrc/common/csqcmodel_settings.qh b/qcsrc/common/csqcmodel_settings.qh index 5a05a6788..bdeab298e 100644 --- a/qcsrc/common/csqcmodel_settings.qh +++ b/qcsrc/common/csqcmodel_settings.qh @@ -81,4 +81,4 @@ float autocvar_sv_use_csqc_players; # endif #endif -#define CSQCMODEL_EF_INVISIBLE EF_SELECTABLE +#define CSQCMODEL_EF_RESPAWNGHOST EF_SELECTABLE diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index 356f5b3e7..57e653113 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -2186,7 +2186,7 @@ void m_shutdown() #ifdef SVQC void WriteApproxPastTime(float dst, float t) { - float dt = t - time; + float dt = time - t; // warning: this is approximate; do not resend when you don't have to! // be careful with sendflags here! @@ -2209,6 +2209,6 @@ float ReadApproxPastTime() // map from range...PPROXPASTTIME_MAX / 256 dt = (APPROXPASTTIME_MAX / 256) * (dt / (256 - dt)); - return servertime + dt; + return servertime - dt; } #endif diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index e5f6a7b36..298fd47e3 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1761,7 +1761,7 @@ void respawn(void) self.movetype = MOVETYPE_FLY; self.velocity = '0 0 1' * autocvar_g_respawn_ghosts_speed; self.avelocity = randomvec() * autocvar_g_respawn_ghosts_speed * 3 - randomvec() * autocvar_g_respawn_ghosts_speed * 3; - self.effects |= EF_ADDITIVE; + self.effects |= CSQCMODEL_EF_RESPAWNGHOST; pointparticles(particleeffectnum("respawn_ghost"), self.origin, '0 0 0', 1); if(autocvar_g_respawn_ghosts_maxtime) SUB_SetFade (self, time + autocvar_g_respawn_ghosts_maxtime / 2 + random () * (autocvar_g_respawn_ghosts_maxtime - autocvar_g_respawn_ghosts_maxtime / 2), 1.5); diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index 5de1be4bc..75f1c076b 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -166,6 +166,7 @@ void CopyBody(float keepvelocity) self.animstate_endtime = oldself.animstate_endtime; self.animstate_override = oldself.animstate_override; self.animstate_looping = oldself.animstate_looping; + self.death_time = oldself.death_time; self.frame = oldself.frame; self.pain_finished = oldself.pain_finished; self.health = oldself.health; -- 2.39.2