9 void CSQCModel_Hook_PreDraw(float isplayer)
11 // auto glowmod from colormap
15 self.glowmod = colormapPaletteColor(((self.colormap >= 1024) ? (self.colormap & 0xFF) : stof(getplayerkeyvalue(self.colormap - 1, "colors"))), TRUE) * 2;
17 self.glowmod = '1 1 1';
19 if(self.modelindex && self.model != "null")
22 if(self.lodmodelindex0 != self.modelindex)
24 string modelname = self.model;
28 self.lodmodelindex0 = self.modelindex;
29 self.lodmodelindex1 = self.modelindex;
30 self.lodmodelindex2 = self.modelindex;
32 // FIXME: this only supports 3-letter extensions
33 s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod1", substring(modelname, -4, 4));
39 self.lodmodelindex1 = self.modelindex;
42 s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod2", substring(modelname, -4, 4));
48 self.lodmodelindex2 = self.modelindex;
51 setmodel(self, modelname); // make everything normal again
54 if(autocvar_cl_playerdetailreduction <= 0)
56 if(autocvar_cl_playerdetailreduction <= -2)
57 self.modelindex = self.lodmodelindex2;
58 else if(autocvar_cl_playerdetailreduction <= -1)
59 self.modelindex = self.lodmodelindex1;
61 self.modelindex = self.lodmodelindex0;
65 float distance = vlen(self.origin - other.origin);
66 float f = (distance + 100.0) * autocvar_cl_playerdetailreduction;
67 f *= 1.0 / bound(0.01, view_quality, 1);
68 if(f > autocvar_cl_loddistance2)
69 self.modelindex = self.lodmodelindex2;
70 else if(f > autocvar_cl_loddistance1)
71 self.modelindex = self.lodmodelindex1;
73 self.modelindex = self.lodmodelindex0;
80 if(self.tag_entity && wasfreed(self.tag_entity))
81 self.tag_entity = world;
83 if(self.tag_networkentity)
86 if(self.tag_entity.entnum == self.tag_networkentity)
89 self.drawmask = MASK_NORMAL;
93 // to something NEW NEW NEW NEW!
94 self.tag_entity = findfloat(world, entnum, self.tag_networkentity);
97 // the best part is: IT EXISTS
98 self.drawmask = MASK_NORMAL;
100 if(substring(self.model, 0, 17) == "models/weapons/v_")
101 if(substring(self.tag_entity.model, 0, 17) == "models/weapons/h_")
103 self.tag_index = gettagindex(self.tag_entity, "weapon");
105 self.tag_index = gettagindex(self.tag_entity, "tag_weapon");
108 // we need to prevent this from 'appening
109 self.tag_entity = world;
111 dprint("h_ model lacks weapon attachment, but v_ model is attached to it\n");
115 if(substring(self.model, 0, 17) == "models/weapons/v_")
116 if(substring(self.tag_entity.model, 0, 14) == "models/player/")
118 self.tag_index = gettagindex(self.tag_entity, "tag_weapon");
120 self.tag_index = gettagindex(self.tag_entity, "bip01 r hand");
123 if(substring(self.tag_entity.model, 0, 17) == "models/weapons/v_")
125 self.tag_index = gettagindex(self.tag_entity, "shot");
127 self.tag_index = gettagindex(self.tag_entity, "tag_shot");
132 // damn, see you next frame
140 self.drawmask = MASK_NORMAL;
145 string forceplayermodels_model;
146 float forceplayermodels_modelindex;
147 float forceplayermodels_skin;
148 .string forceplayermodels_savemodel;
149 .float forceplayermodels_savemodelindex;
150 .float forceplayermodels_saveskin;
151 void CSQCModel_Hook_PreUpdate(float isplayer, float islocalplayer)
155 // revert to values from server
156 self.model = self.forceplayermodels_savemodel;
157 self.modelindex = self.forceplayermodels_savemodelindex;
158 self.skin = self.forceplayermodels_saveskin;
162 void CSQCModel_Hook_PostUpdate(float isplayer, float islocalplayer)
166 // save values set by server
167 self.forceplayermodels_savemodel = self.model;
168 self.forceplayermodels_savemodelindex = self.modelindex;
169 self.forceplayermodels_saveskin = self.skin;
171 if(autocvar_cl_forceplayermodels)
173 if(self.modelindex && self.model != "null")
177 // trust server's idea of "own player model"
178 forceplayermodels_model = self.model;
179 forceplayermodels_modelindex = self.modelindex;
180 forceplayermodels_skin = self.skin;
182 if(!forceplayermodels_modelindex)
184 // only if this failed, find it out on our own
185 setmodel(self, autocvar__cl_playermodel); // this is harmless, see below
186 forceplayermodels_model = self.model;
187 forceplayermodels_modelindex = self.modelindex;
188 forceplayermodels_skin = autocvar__cl_playerskin;
192 self.model = forceplayermodels_model;
193 self.modelindex = forceplayermodels_modelindex;
194 self.skin = forceplayermodels_skin;