X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fcsqcmodel_hooks.qc;h=a3e612062f903abd4de191b5e70d38b612c503e3;hb=51086b4545acc961d03eb8091669d9963fa6bf00;hp=109b83d166f11a8efe597f1173c76c5cda1aef59;hpb=dd70edcca2f19a7b95b1f0441db75c154bf10606;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/csqcmodel_hooks.qc b/qcsrc/client/csqcmodel_hooks.qc index 109b83d16..a3e612062 100644 --- a/qcsrc/client/csqcmodel_hooks.qc +++ b/qcsrc/client/csqcmodel_hooks.qc @@ -69,7 +69,7 @@ void CSQCPlayer_LOD_Apply(void) } } -// FEATURE: forcemodel (MUST be called BEFORE LOD!) +// FEATURE: forcemodel and model color selection (MUST be called BEFORE LOD!) string forceplayermodels_model; float forceplayermodels_modelisgoodmodel; float forceplayermodels_modelindex; @@ -92,14 +92,17 @@ float forceplayermodels_attempted; string forceplayermodels_goodmodel; float forceplayermodels_goodmodelindex; -void CSQCPlayer_ForceModel_PreUpdate(void) +.vector glowmod; +.vector old_glowmod; + +void CSQCPlayer_ModelAppearance_PreUpdate(void) { self.model = self.forceplayermodels_savemodel; self.modelindex = self.forceplayermodels_savemodelindex; self.skin = self.forceplayermodels_saveskin; self.colormap = self.forceplayermodels_savecolormap; } -void CSQCPlayer_ForceModel_PostUpdate(void) +void CSQCPlayer_ModelAppearance_PostUpdate(void) { self.forceplayermodels_savemodel = self.model; self.forceplayermodels_savemodelindex = self.modelindex; @@ -114,7 +117,7 @@ void CSQCPlayer_ForceModel_PostUpdate(void) print(sprintf("Warning: missing model %s has been used\n", self.forceplayermodels_savemodel)); } } -void CSQCPlayer_ForceModel_Apply(float islocalplayer) +void CSQCPlayer_ModelAppearance_Apply(float islocalplayer) { // which one is ALWAYS good? if not(forceplayermodels_goodmodel) @@ -208,6 +211,7 @@ void CSQCPlayer_ForceModel_Apply(float islocalplayer) self.skin = self.forceplayermodels_saveskin; } + //float selected_colormap = cm; // forceplayercolors too if(teamplay) { @@ -265,8 +269,64 @@ void CSQCPlayer_ForceModel_Apply(float islocalplayer) else if(autocvar_cl_forceplayercolors) self.colormap = player_localnum + 1; } + + 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) + { + // Fade out to black now... + if(self.old_glowmod == '0 0 0') { self.old_glowmod = self.glowmod; } + self.colormap = 0; + + self.glowmod = self.old_glowmod * bound(0, 1 - (time - self.death_time) / autocvar_cl_deathglow, 1); + self.glowmod_x = max(self.glowmod_x, 0.0001); + self.glowmod_y = max(self.glowmod_y, 0.0001); + self.glowmod_z = max(self.glowmod_z, 0.0001); + } + else if(self.old_glowmod != '0 0 0') { self.old_glowmod = '0 0 0'; } + } + + //print(sprintf("CSQCPlayer_ModelAppearance_Apply(): state = %s, colormap = %f, glowmod = %s\n", (self.csqcmodel_isdead ? "DEAD" : "ALIVE"), self.colormap, vtos(self.glowmod))); } +/*// 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(self.colormod != '0 0 0') { self.colormod = '0 0 0'; } + + if(autocvar_cl_deathglow > 0) + { + if(self.csqcmodel_isdead) + { + self.colormap = 0; + self.glowmod = self.glowmod * bound(0, 1 - (time - self.death_time) / autocvar_cl_deathglow, 1); + // prevent the zero vector + self.glowmod_x = max(self.glowmod_x, 0.0001); + self.glowmod_y = max(self.glowmod_y, 0.0001); + self.glowmod_z = max(self.glowmod_z, 0.0001); + } + + } + + print(sprintf("CSQCPlayer_GlowMod_Apply(): state = %s, colormap = %f, colormod = %s, glowmod = %s\n", (self.csqcmodel_isdead ? "DEAD" : "ALIVE"), cm, vtos(self.colormod), vtos(self.glowmod))); +}*/ + // FEATURE: fallback frames .float csqcmodel_saveframe; .float csqcmodel_saveframe2; @@ -552,31 +612,6 @@ void CSQCPlayer_Precache() precache_sound("misc/jetpack_fly.wav"); } -// 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 - self.glowmod_x = max(self.glowmod_x, 0.0001); - self.glowmod_y = max(self.glowmod_y, 0.0001); - self.glowmod_z = max(self.glowmod_z, 0.0001); - } -} - // general functions .float csqcmodel_predraw_run; .float anim_frame; @@ -604,8 +639,8 @@ void CSQCModel_Hook_PreDraw(float isplayer) if(self.isplayermodel) // this checks if it's a player MODEL! { - CSQCPlayer_ForceModel_Apply(self.entnum == player_localnum + 1); - CSQCPlayer_GlowMod_Apply(); + float islocalplayer = (self.entnum == player_localnum + 1); + CSQCPlayer_ModelAppearance_Apply(islocalplayer); CSQCPlayer_LOD_Apply(); if(!isplayer) CSQCPlayer_FallbackFrame_Apply(); @@ -683,7 +718,7 @@ void CSQCModel_Hook_PreUpdate(float isnew, float isplayer, float islocalplayer) { if(!isplayer) CSQCPlayer_FallbackFrame_PreUpdate(); - CSQCPlayer_ForceModel_PreUpdate(); + CSQCPlayer_ModelAppearance_PreUpdate(); } } @@ -695,7 +730,7 @@ void CSQCModel_Hook_PostUpdate(float isnew, float isplayer, float islocalplayer) // save values set by server if(self.isplayermodel) { - CSQCPlayer_ForceModel_PostUpdate(); + CSQCPlayer_ModelAppearance_PostUpdate(); if(isplayer) CSQCPlayer_AnimDecide_PostUpdate(isnew); else