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)
40 self.solid = SOLID_NOT;
42 else if (self.antiwall_flag == 2)
45 self.solid = self.default_solid;
47 g_clientmodel_setcolormaptoactivator();
50 void g_model_dropbyspawnflags()
52 if((self.spawnflags & 3) == 1) // ALIGN_ORIGIN
54 traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
55 setorigin(self, trace_endpos);
57 else if((self.spawnflags & 3) == 2) // ALIGN_BOTTOM
59 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
60 setorigin(self, trace_endpos);
62 else if((self.spawnflags & 3) == 3) // ALIGN_ORIGIN | ALIGN_BOTTOM
64 traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
65 setorigin(self, trace_endpos - '0 0 1' * self.mins.z);
69 void g_clientmodel_dropbyspawnflags()
73 g_model_dropbyspawnflags();
78 float g_clientmodel_genericsendentity (entity to, float sf)
81 if(self.angles != '0 0 0')
83 if(self.mins != '0 0 0' || self.maxs != '0 0 0')
85 if(self.colormap != 0)
87 if(self.lodmodelindex1)
90 WriteByte(MSG_ENTITY, ENT_CLIENT_WALL);
91 WriteByte(MSG_ENTITY, sf);
96 WriteShort(MSG_ENTITY, self.colormap);
101 WriteCoord(MSG_ENTITY, self.origin.x);
102 WriteCoord(MSG_ENTITY, self.origin.y);
103 WriteCoord(MSG_ENTITY, self.origin.z);
110 WriteAngle(MSG_ENTITY, self.angles.x);
111 WriteAngle(MSG_ENTITY, self.angles.y);
112 WriteAngle(MSG_ENTITY, self.angles.z);
120 WriteShort(MSG_ENTITY, self.lodmodelindex0);
121 WriteShort(MSG_ENTITY, bound(0, self.loddistance1, 65535));
122 WriteShort(MSG_ENTITY, self.lodmodelindex1);
123 WriteShort(MSG_ENTITY, bound(0, self.loddistance2, 65535));
124 WriteShort(MSG_ENTITY, self.lodmodelindex2);
127 WriteShort(MSG_ENTITY, self.modelindex);
128 WriteByte(MSG_ENTITY, self.solid);
129 WriteShort(MSG_ENTITY, floor(self.scale * 256));
132 WriteCoord(MSG_ENTITY, self.mins.x);
133 WriteCoord(MSG_ENTITY, self.mins.y);
134 WriteCoord(MSG_ENTITY, self.mins.z);
135 WriteCoord(MSG_ENTITY, self.maxs.x);
136 WriteCoord(MSG_ENTITY, self.maxs.y);
137 WriteCoord(MSG_ENTITY, self.maxs.z);
139 WriteString(MSG_ENTITY, self.bgmscript);
140 if(self.bgmscript != "")
142 WriteByte(MSG_ENTITY, floor(self.bgmscriptattack * 64));
143 WriteByte(MSG_ENTITY, floor(self.bgmscriptdecay * 64));
144 WriteByte(MSG_ENTITY, floor(self.bgmscriptsustain * 255));
145 WriteByte(MSG_ENTITY, floor(self.bgmscriptrelease * 64));
146 WriteCoord(MSG_ENTITY, self.movedir.x);
147 WriteCoord(MSG_ENTITY, self.movedir.y);
148 WriteCoord(MSG_ENTITY, self.movedir.z);
149 WriteByte(MSG_ENTITY, floor(self.lip * 255));
151 WriteShort(MSG_ENTITY, self.fade_start);
152 WriteShort(MSG_ENTITY, self.fade_end);
153 WriteShort(MSG_ENTITY, self.alpha_max);
154 WriteShort(MSG_ENTITY, self.alpha_min);
155 WriteShort(MSG_ENTITY, self.inactive);
162 #define G_MODEL_INIT(sol) \
163 if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
164 if(!self.scale) self.scale = self.modelscale; \
165 SetBrushEntityModel(); \
166 self.use = g_model_setcolormaptoactivator; \
167 InitializeEntity(self, g_model_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
168 if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT;
170 #define G_CLIENTMODEL_INIT(sol) \
171 if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
172 if(!self.scale) self.scale = self.modelscale; \
173 SetBrushEntityModel(); \
174 self.use = g_clientmodel_use; \
175 InitializeEntity(self, g_clientmodel_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
176 if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT; \
177 if(!self.bgmscriptsustain) self.bgmscriptsustain = 1; else if(self.bgmscriptsustain < 0) self.bgmscriptsustain = 0; \
178 Net_LinkEntity(self, true, 0, g_clientmodel_genericsendentity); \
179 self.default_solid = sol;
181 // non-solid model entities:
182 void spawnfunc_misc_gamemodel() { self.angles_x = -self.angles.x; G_MODEL_INIT (SOLID_NOT) } // model entity
183 void spawnfunc_misc_clientmodel() { self.angles_x = -self.angles.x; G_CLIENTMODEL_INIT(SOLID_NOT) } // model entity
184 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
186 // non-solid brush entities:
187 void spawnfunc_func_illusionary() { G_MODEL_INIT (SOLID_NOT) } // Q1 name (WARNING: MISPREDICTED)
188 void spawnfunc_func_clientillusionary() { G_CLIENTMODEL_INIT(SOLID_NOT) } // brush entity
189 void spawnfunc_func_static() { G_MODEL_INIT (SOLID_NOT) } // DEPRECATED old alias name from some other game
191 // solid brush entities
192 void spawnfunc_func_wall() { G_MODEL_INIT (SOLID_BSP) } // Q1 name
193 void spawnfunc_func_clientwall() { G_CLIENTMODEL_INIT(SOLID_BSP) } // brush entity (WARNING: MISPREDICTED)