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 g_clientmodel_setcolormaptoactivator();
40 void g_model_dropbyspawnflags()
42 if((self.spawnflags & 3) == 1) // ALIGN_ORIGIN
44 traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
45 setorigin(self, trace_endpos);
47 else if((self.spawnflags & 3) == 2) // ALIGN_BOTTOM
49 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
50 setorigin(self, trace_endpos);
52 else if((self.spawnflags & 3) == 3) // ALIGN_ORIGIN | ALIGN_BOTTOM
54 traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
55 setorigin(self, trace_endpos - '0 0 1' * self.mins.z);
59 void g_clientmodel_dropbyspawnflags()
63 g_model_dropbyspawnflags();
68 float g_clientmodel_genericsendentity (entity to, float sf)
71 if(self.angles != '0 0 0')
73 if(self.mins != '0 0 0' || self.maxs != '0 0 0')
75 if(self.colormap != 0)
77 if(self.lodmodelindex1)
80 WriteByte(MSG_ENTITY, ENT_CLIENT_WALL);
81 WriteByte(MSG_ENTITY, sf);
86 WriteShort(MSG_ENTITY, self.colormap);
91 WriteCoord(MSG_ENTITY, self.origin.x);
92 WriteCoord(MSG_ENTITY, self.origin.y);
93 WriteCoord(MSG_ENTITY, self.origin.z);
100 WriteAngle(MSG_ENTITY, self.angles.x);
101 WriteAngle(MSG_ENTITY, self.angles.y);
102 WriteAngle(MSG_ENTITY, self.angles.z);
110 WriteShort(MSG_ENTITY, self.lodmodelindex0);
111 WriteShort(MSG_ENTITY, bound(0, self.loddistance1, 65535));
112 WriteShort(MSG_ENTITY, self.lodmodelindex1);
113 WriteShort(MSG_ENTITY, bound(0, self.loddistance2, 65535));
114 WriteShort(MSG_ENTITY, self.lodmodelindex2);
117 WriteShort(MSG_ENTITY, self.modelindex);
118 WriteByte(MSG_ENTITY, self.solid);
119 WriteShort(MSG_ENTITY, floor(self.scale * 256));
122 WriteCoord(MSG_ENTITY, self.mins.x);
123 WriteCoord(MSG_ENTITY, self.mins.y);
124 WriteCoord(MSG_ENTITY, self.mins.z);
125 WriteCoord(MSG_ENTITY, self.maxs.x);
126 WriteCoord(MSG_ENTITY, self.maxs.y);
127 WriteCoord(MSG_ENTITY, self.maxs.z);
129 WriteString(MSG_ENTITY, self.bgmscript);
130 if(self.bgmscript != "")
132 WriteByte(MSG_ENTITY, floor(self.bgmscriptattack * 64));
133 WriteByte(MSG_ENTITY, floor(self.bgmscriptdecay * 64));
134 WriteByte(MSG_ENTITY, floor(self.bgmscriptsustain * 255));
135 WriteByte(MSG_ENTITY, floor(self.bgmscriptrelease * 64));
136 WriteCoord(MSG_ENTITY, self.movedir.x);
137 WriteCoord(MSG_ENTITY, self.movedir.y);
138 WriteCoord(MSG_ENTITY, self.movedir.z);
139 WriteByte(MSG_ENTITY, floor(self.lip * 255));
141 WriteShort(MSG_ENTITY, self.fade_start);
142 WriteShort(MSG_ENTITY, self.fade_end);
143 WriteShort(MSG_ENTITY, self.alpha_max);
144 WriteShort(MSG_ENTITY, self.alpha_min);
145 WriteShort(MSG_ENTITY, self.inactive);
152 #define G_MODEL_INIT(sol) \
153 if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
154 if(!self.scale) self.scale = self.modelscale; \
155 SetBrushEntityModel(); \
156 self.use = g_model_setcolormaptoactivator; \
157 InitializeEntity(self, g_model_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
158 if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT;
160 #define G_CLIENTMODEL_INIT(sol) \
161 if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
162 if(!self.scale) self.scale = self.modelscale; \
163 SetBrushEntityModel(); \
164 self.use = g_clientmodel_use; \
165 InitializeEntity(self, g_clientmodel_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
166 if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT; \
167 if(!self.bgmscriptsustain) self.bgmscriptsustain = 1; else if(self.bgmscriptsustain < 0) self.bgmscriptsustain = 0; \
168 Net_LinkEntity(self, true, 0, g_clientmodel_genericsendentity); \
169 self.default_solid = sol;
171 // non-solid model entities:
172 void spawnfunc_misc_gamemodel() { self.angles_x = -self.angles.x; G_MODEL_INIT (SOLID_NOT) } // model entity
173 void spawnfunc_misc_clientmodel() { self.angles_x = -self.angles.x; G_CLIENTMODEL_INIT(SOLID_NOT) } // model entity
174 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
176 // non-solid brush entities:
177 void spawnfunc_func_illusionary() { G_MODEL_INIT (SOLID_NOT) } // Q1 name (WARNING: MISPREDICTED)
178 void spawnfunc_func_clientillusionary() { G_CLIENTMODEL_INIT(SOLID_NOT) } // brush entity
179 void spawnfunc_func_static() { G_MODEL_INIT (SOLID_NOT) } // DEPRECATED old alias name from some other game
181 // solid brush entities
182 void spawnfunc_func_wall() { G_MODEL_INIT (SOLID_BSP) } // Q1 name
183 void spawnfunc_func_clientwall() { G_CLIENTMODEL_INIT(SOLID_BSP) } // brush entity (WARNING: MISPREDICTED)