.float lodmodelindex1;
.float lodmodelindex2;
-void CSQCModel_Hook_PreDraw()
+.entity tag_entity;
+.float tag_index;
+
+void CSQCModel_Hook_PreDraw(float isplayer)
{
// auto glowmod from colormap
self.glowmod = colormapPaletteColor(((self.colormap >= 1024) ? (self.colormap & 0xFF) : stof(getplayerkeyvalue(self.entnum - 1, "colors"))), TRUE) * 2;
self.modelindex = self.lodmodelindex0;
}
}
-}
+ if(!isplayer)
+ {
+ if(self.tag_entity && wasfreed(self.tag_entity))
+ self.tag_entity = world;
+
+ if(self.tag_networkentity)
+ {
+ // we are ATTACHED!
+ if(self.tag_entity.entnum == self.tag_networkentity)
+ {
+ // already good
+ self.drawmask = MASK_NORMAL;
+ }
+ else
+ {
+ // to something NEW NEW NEW NEW!
+ self.tag_entity = findfloat(world, entnum, self.tag_networkentity);
+ if(self.tag_entity)
+ {
+ // the best part is: IT EXISTS
+ self.drawmask = MASK_NORMAL;
+
+ if(substring(self.model, 0, 17) == "models/weapons/v_")
+ if(substring(self.tag_entity.model, 0, 17) == "models/weapons/h_")
+ {
+ self.tag_index = gettagindex(self.tag_entity, "weapon");
+ if(!self.tag_index)
+ self.tag_index = gettagindex(self.tag_entity, "tag_weapon");
+ if(!self.tag_index)
+ {
+ // we need to prevent this from 'appening
+ self.tag_entity = world;
+ self.drawmask = 0;
+ dprint("h_ model lacks weapon attachment, but v_ model is attached to it\n");
+ }
+ }
+
+ if(substring(self.model, 0, 17) == "models/weapons/v_")
+ if(substring(self.tag_entity.model, 0, 14) == "models/player/")
+ {
+ self.tag_index = gettagindex(self.tag_entity, "tag_weapon");
+ if(!self.tag_index)
+ self.tag_index = gettagindex(self.tag_entity, "bip01 r hand");
+ }
+
+ if(substring(self.tag_entity.model, 0, 17) == "models/weapons/v_")
+ {
+ self.tag_index = gettagindex(self.tag_entity, "shot");
+ if(!self.tag_index)
+ self.tag_index = gettagindex(self.tag_entity, "tag_shot");
+ }
+ }
+ else
+ {
+ // damn, see you next frame
+ self.drawmask = 0;
+ }
+ }
+ }
+ else
+ {
+ // no brain no pain
+ self.drawmask = MASK_NORMAL;
+ }
+ }
+}
void CSQCModel_Draw()
{
+ // some nice flags for CSQCMODEL_IF and the hooks
+ float isplayer = (self.entnum >= 1 && self.entnum <= maxclients);
+ float islocalplayer = (self.entnum == player_localentnum);
+ float isnolocalplayer = (isplayer && (self.entnum != player_localentnum));
+
// we don't do this for the local player as that one is already handled
// by CSQCPlayer_SetCamera()
if(!CSQCPlayer_IsLocalPlayer())