3 #include "../common/triggers/subs.qh"
5 entityclass(BGMScript);
6 class(BGMScript) .string bgmscript;
7 class(BGMScript) .float bgmscriptattack;
8 class(BGMScript) .float bgmscriptdecay;
9 class(BGMScript) .float bgmscriptsustain;
10 class(BGMScript) .float bgmscriptrelease;
12 #include "../common/constants.qh"
13 #include "../csqcmodellib/sv_model.qh"
17 void g_model_setcolormaptoactivator (void)
22 self.colormap = (activator.team - 1) * 0x11;
27 self.colormap = floor(random() * 256);
28 self.colormap |= 1024; // RENDER_COLORMAPPED
31 void g_clientmodel_setcolormaptoactivator (void)
33 g_model_setcolormaptoactivator();
34 self.SendFlags |= (8 | 1);
37 void g_clientmodel_use(void)
39 if (self.antiwall_flag == 1)
42 self.solid = SOLID_NOT;
44 else if (self.antiwall_flag == 2)
47 self.solid = self.default_solid;
49 g_clientmodel_setcolormaptoactivator();
52 void g_model_dropbyspawnflags()
54 if((self.spawnflags & 3) == 1) // ALIGN_ORIGIN
56 traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
57 setorigin(self, trace_endpos);
59 else if((self.spawnflags & 3) == 2) // ALIGN_BOTTOM
61 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
62 setorigin(self, trace_endpos);
64 else if((self.spawnflags & 3) == 3) // ALIGN_ORIGIN | ALIGN_BOTTOM
66 traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
67 setorigin(self, trace_endpos - '0 0 1' * self.mins.z);
71 void g_clientmodel_dropbyspawnflags()
75 g_model_dropbyspawnflags();
80 bool g_clientmodel_genericsendentity(entity this, entity to, int sf)
83 if(self.angles != '0 0 0')
85 if(self.mins != '0 0 0' || self.maxs != '0 0 0')
87 if(self.colormap != 0)
89 if(self.lodmodelindex1)
92 WriteByte(MSG_ENTITY, ENT_CLIENT_WALL);
93 WriteByte(MSG_ENTITY, sf);
98 WriteShort(MSG_ENTITY, self.colormap);
103 WriteCoord(MSG_ENTITY, self.origin.x);
104 WriteCoord(MSG_ENTITY, self.origin.y);
105 WriteCoord(MSG_ENTITY, self.origin.z);
112 WriteAngle(MSG_ENTITY, self.angles.x);
113 WriteAngle(MSG_ENTITY, self.angles.y);
114 WriteAngle(MSG_ENTITY, self.angles.z);
122 WriteShort(MSG_ENTITY, self.lodmodelindex0);
123 WriteShort(MSG_ENTITY, bound(0, self.loddistance1, 65535));
124 WriteShort(MSG_ENTITY, self.lodmodelindex1);
125 WriteShort(MSG_ENTITY, bound(0, self.loddistance2, 65535));
126 WriteShort(MSG_ENTITY, self.lodmodelindex2);
129 WriteShort(MSG_ENTITY, self.modelindex);
130 WriteByte(MSG_ENTITY, self.solid);
131 WriteShort(MSG_ENTITY, floor(self.scale * 256));
134 WriteCoord(MSG_ENTITY, self.mins.x);
135 WriteCoord(MSG_ENTITY, self.mins.y);
136 WriteCoord(MSG_ENTITY, self.mins.z);
137 WriteCoord(MSG_ENTITY, self.maxs.x);
138 WriteCoord(MSG_ENTITY, self.maxs.y);
139 WriteCoord(MSG_ENTITY, self.maxs.z);
141 WriteString(MSG_ENTITY, self.bgmscript);
142 if(self.bgmscript != "")
144 WriteByte(MSG_ENTITY, floor(self.bgmscriptattack * 64));
145 WriteByte(MSG_ENTITY, floor(self.bgmscriptdecay * 64));
146 WriteByte(MSG_ENTITY, floor(self.bgmscriptsustain * 255));
147 WriteByte(MSG_ENTITY, floor(self.bgmscriptrelease * 64));
148 WriteCoord(MSG_ENTITY, self.movedir.x);
149 WriteCoord(MSG_ENTITY, self.movedir.y);
150 WriteCoord(MSG_ENTITY, self.movedir.z);
151 WriteByte(MSG_ENTITY, floor(self.lip * 255));
153 WriteShort(MSG_ENTITY, self.fade_start);
154 WriteShort(MSG_ENTITY, self.fade_end);
155 WriteShort(MSG_ENTITY, self.alpha_max);
156 WriteShort(MSG_ENTITY, self.alpha_min);
157 WriteShort(MSG_ENTITY, self.inactive);
158 WriteShort(MSG_ENTITY, self.fade_vertical_offset);
165 #define G_MODEL_INIT(sol) \
166 if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
167 if(!self.scale) self.scale = self.modelscale; \
168 SetBrushEntityModel(); \
169 self.use = g_model_setcolormaptoactivator; \
170 InitializeEntity(self, g_model_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
171 if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT;
173 #define G_CLIENTMODEL_INIT(sol) \
174 if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
175 if(!self.scale) self.scale = self.modelscale; \
176 SetBrushEntityModel(); \
177 self.use = g_clientmodel_use; \
178 InitializeEntity(self, g_clientmodel_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
179 if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT; \
180 if(!self.bgmscriptsustain) self.bgmscriptsustain = 1; else if(self.bgmscriptsustain < 0) self.bgmscriptsustain = 0; \
181 Net_LinkEntity(self, true, 0, g_clientmodel_genericsendentity); \
182 self.default_solid = sol;
184 // non-solid model entities:
185 spawnfunc(misc_gamemodel) { self.angles_x = -self.angles.x; G_MODEL_INIT (SOLID_NOT) } // model entity
186 spawnfunc(misc_clientmodel) { self.angles_x = -self.angles.x; G_CLIENTMODEL_INIT(SOLID_NOT) } // model entity
187 spawnfunc(misc_models) { self.angles_x = -self.angles.x; G_MODEL_INIT (SOLID_NOT) } // DEPRECATED old compat entity with confusing name, do not use
189 // non-solid brush entities:
190 spawnfunc(func_illusionary) { G_MODEL_INIT (SOLID_NOT) } // Q1 name (WARNING: MISPREDICTED)
191 spawnfunc(func_clientillusionary) { G_CLIENTMODEL_INIT(SOLID_NOT) } // brush entity
192 spawnfunc(func_static) { G_MODEL_INIT (SOLID_NOT) } // DEPRECATED old alias name from some other game
194 // solid brush entities
195 spawnfunc(func_wall) { G_MODEL_INIT (SOLID_BSP) } // Q1 name
196 spawnfunc(func_clientwall) { G_CLIENTMODEL_INIT(SOLID_BSP) } // brush entity (WARNING: MISPREDICTED)