4 #include "../dpdefs/progsdefs.qh"
5 #include "../dpdefs/dpextensions.qh"
6 #include "../common/constants.qh"
7 #include "autocvars.qh"
8 #include "constants.qh"
10 #include "../csqcmodellib/sv_model.qh"
15 void g_model_setcolormaptoactivator (void)
20 self.colormap = (activator.team - 1) * 0x11;
25 self.colormap = floor(random() * 256);
26 self.colormap |= 1024; // RENDER_COLORMAPPED
29 void g_clientmodel_setcolormaptoactivator (void)
31 g_model_setcolormaptoactivator();
35 void g_clientmodel_use(void)
37 if (self.antiwall_flag == 1)
41 else if (self.antiwall_flag == 2)
47 self.solid = SOLID_NOT;
51 self.solid = self.default_solid;
53 g_clientmodel_setcolormaptoactivator();
56 void g_model_dropbyspawnflags()
58 if((self.spawnflags & 3) == 1) // ALIGN_ORIGIN
60 traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
61 setorigin(self, trace_endpos);
63 else if((self.spawnflags & 3) == 2) // ALIGN_BOTTOM
65 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
66 setorigin(self, trace_endpos);
68 else if((self.spawnflags & 3) == 3) // ALIGN_ORIGIN | ALIGN_BOTTOM
70 traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
71 setorigin(self, trace_endpos - '0 0 1' * self.mins.z);
75 void g_clientmodel_dropbyspawnflags()
79 g_model_dropbyspawnflags();
84 float g_clientmodel_genericsendentity (entity to, float sf)
87 if(self.angles != '0 0 0')
89 if(self.mins != '0 0 0' || self.maxs != '0 0 0')
91 if(self.colormap != 0)
93 if(self.lodmodelindex1)
96 WriteByte(MSG_ENTITY, ENT_CLIENT_WALL);
97 WriteByte(MSG_ENTITY, sf);
102 WriteShort(MSG_ENTITY, self.colormap);
107 WriteCoord(MSG_ENTITY, self.origin.x);
108 WriteCoord(MSG_ENTITY, self.origin.y);
109 WriteCoord(MSG_ENTITY, self.origin.z);
116 WriteAngle(MSG_ENTITY, self.angles.x);
117 WriteAngle(MSG_ENTITY, self.angles.y);
118 WriteAngle(MSG_ENTITY, self.angles.z);
126 WriteShort(MSG_ENTITY, self.lodmodelindex0);
127 WriteShort(MSG_ENTITY, bound(0, self.loddistance1, 65535));
128 WriteShort(MSG_ENTITY, self.lodmodelindex1);
129 WriteShort(MSG_ENTITY, bound(0, self.loddistance2, 65535));
130 WriteShort(MSG_ENTITY, self.lodmodelindex2);
133 WriteShort(MSG_ENTITY, self.modelindex);
134 WriteByte(MSG_ENTITY, self.solid);
135 WriteShort(MSG_ENTITY, floor(self.scale * 256));
138 WriteCoord(MSG_ENTITY, self.mins.x);
139 WriteCoord(MSG_ENTITY, self.mins.y);
140 WriteCoord(MSG_ENTITY, self.mins.z);
141 WriteCoord(MSG_ENTITY, self.maxs.x);
142 WriteCoord(MSG_ENTITY, self.maxs.y);
143 WriteCoord(MSG_ENTITY, self.maxs.z);
145 WriteString(MSG_ENTITY, self.bgmscript);
146 if(self.bgmscript != "")
148 WriteByte(MSG_ENTITY, floor(self.bgmscriptattack * 64));
149 WriteByte(MSG_ENTITY, floor(self.bgmscriptdecay * 64));
150 WriteByte(MSG_ENTITY, floor(self.bgmscriptsustain * 255));
151 WriteByte(MSG_ENTITY, floor(self.bgmscriptrelease * 64));
152 WriteCoord(MSG_ENTITY, self.movedir.x);
153 WriteCoord(MSG_ENTITY, self.movedir.y);
154 WriteCoord(MSG_ENTITY, self.movedir.z);
155 WriteByte(MSG_ENTITY, floor(self.lip * 255));
157 WriteShort(MSG_ENTITY, self.fade_start);
158 WriteShort(MSG_ENTITY, self.fade_end);
159 WriteShort(MSG_ENTITY, self.alpha_max);
160 WriteShort(MSG_ENTITY, self.alpha_min);
161 WriteShort(MSG_ENTITY, self.inactive);
168 #define G_MODEL_INIT(sol) \
169 if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
170 if(!self.scale) self.scale = self.modelscale; \
171 SetBrushEntityModel(); \
172 self.use = g_model_setcolormaptoactivator; \
173 InitializeEntity(self, g_model_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
174 if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT;
176 #define G_CLIENTMODEL_INIT(sol) \
177 if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
178 if(!self.scale) self.scale = self.modelscale; \
179 SetBrushEntityModel(); \
180 self.use = g_clientmodel_use; \
181 InitializeEntity(self, g_clientmodel_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
182 if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT; \
183 if(!self.bgmscriptsustain) self.bgmscriptsustain = 1; else if(self.bgmscriptsustain < 0) self.bgmscriptsustain = 0; \
184 Net_LinkEntity(self, true, 0, g_clientmodel_genericsendentity); \
185 self.default_solid = sol;
187 // non-solid model entities:
188 void spawnfunc_misc_gamemodel() { self.angles_x = -self.angles.x; G_MODEL_INIT (SOLID_NOT) } // model entity
189 void spawnfunc_misc_clientmodel() { self.angles_x = -self.angles.x; G_CLIENTMODEL_INIT(SOLID_NOT) } // model entity
190 void spawnfunc_misc_models() { self.angles_x = -self.angles.x; G_MODEL_INIT (SOLID_NOT) } // DEPRECATED old compat entity with confusing name, do not use
192 // non-solid brush entities:
193 void spawnfunc_func_illusionary() { G_MODEL_INIT (SOLID_NOT) } // Q1 name (WARNING: MISPREDICTED)
194 void spawnfunc_func_clientillusionary() { G_CLIENTMODEL_INIT(SOLID_NOT) } // brush entity
195 void spawnfunc_func_static() { G_MODEL_INIT (SOLID_NOT) } // DEPRECATED old alias name from some other game
197 // solid brush entities
198 void spawnfunc_func_wall() { G_MODEL_INIT (SOLID_BSP) } // Q1 name
199 void spawnfunc_func_clientwall() { G_CLIENTMODEL_INIT(SOLID_BSP) } // brush entity (WARNING: MISPREDICTED)