9 void CSQCModel_Hook_PreDraw(float isplayer)
11 // auto glowmod from colormap
12 self.glowmod = colormapPaletteColor(((self.colormap >= 1024) ? (self.colormap & 0xFF) : stof(getplayerkeyvalue(self.entnum - 1, "colors"))), TRUE) * 2;
14 if(self.modelindex != 0)
17 if(self.lodmodelindex0 != self.modelindex)
19 string modelname = self.model;
23 self.lodmodelindex0 = self.modelindex;
24 self.lodmodelindex1 = self.modelindex;
25 self.lodmodelindex2 = self.modelindex;
27 // FIXME: this only supports 3-letter extensions
28 s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod1", substring(modelname, -4, 4));
33 if(self.modelindex > 0)
34 self.lodmodelindex1 = self.modelindex;
37 s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod2", substring(modelname, -4, 4));
42 if(self.modelindex > 0)
43 self.lodmodelindex2 = self.modelindex;
46 setmodel(self, modelname); // make everything normal again
49 if(autocvar_cl_playerdetailreduction <= 0)
51 if(autocvar_cl_playerdetailreduction <= -2)
52 self.modelindex = self.lodmodelindex2;
53 else if(autocvar_cl_playerdetailreduction <= -1)
54 self.modelindex = self.lodmodelindex1;
56 self.modelindex = self.lodmodelindex0;
60 float distance = vlen(self.origin - other.origin);
61 float f = (distance + 100.0) * autocvar_cl_playerdetailreduction;
62 f *= 1.0 / bound(0.01, view_quality, 1);
63 if(f > autocvar_cl_loddistance2)
64 self.modelindex = self.lodmodelindex2;
65 else if(f > autocvar_cl_loddistance1)
66 self.modelindex = self.lodmodelindex1;
68 self.modelindex = self.lodmodelindex0;
74 if(self.tag_entity && wasfreed(self.tag_entity))
75 self.tag_entity = world;
77 if(self.tag_networkentity)
80 if(self.tag_entity.entnum == self.tag_networkentity)
83 self.drawmask = MASK_NORMAL;
87 // to something NEW NEW NEW NEW!
88 self.tag_entity = findfloat(world, entnum, self.tag_networkentity);
91 // the best part is: IT EXISTS
92 self.drawmask = MASK_NORMAL;
94 if(substring(self.model, 0, 17) == "models/weapons/v_")
95 if(substring(self.tag_entity.model, 0, 17) == "models/weapons/h_")
97 self.tag_index = gettagindex(self.tag_entity, "weapon");
99 self.tag_index = gettagindex(self.tag_entity, "tag_weapon");
102 // we need to prevent this from 'appening
103 self.tag_entity = world;
105 dprint("h_ model lacks weapon attachment, but v_ model is attached to it\n");
109 if(substring(self.model, 0, 17) == "models/weapons/v_")
110 if(substring(self.tag_entity.model, 0, 14) == "models/player/")
112 self.tag_index = gettagindex(self.tag_entity, "tag_weapon");
114 self.tag_index = gettagindex(self.tag_entity, "bip01 r hand");
117 if(substring(self.tag_entity.model, 0, 17) == "models/weapons/v_")
119 self.tag_index = gettagindex(self.tag_entity, "shot");
121 self.tag_index = gettagindex(self.tag_entity, "tag_shot");
126 // damn, see you next frame
134 self.drawmask = MASK_NORMAL;