3 #include "../common/triggers/subs.qh"
4 #include "../common/triggers/triggers.qh"
6 entityclass(BGMScript);
7 class(BGMScript) .string bgmscript;
8 class(BGMScript) .float bgmscriptattack;
9 class(BGMScript) .float bgmscriptdecay;
10 class(BGMScript) .float bgmscriptsustain;
11 class(BGMScript) .float bgmscriptrelease;
13 #include "../common/constants.qh"
14 #include "../lib/csqcmodel/sv_model.qh"
18 void g_model_setcolormaptoactivator ()
23 self.colormap = (activator.team - 1) * 0x11;
28 self.colormap = floor(random() * 256);
29 self.colormap |= BIT(10); // RENDER_COLORMAPPED
32 void g_clientmodel_setcolormaptoactivator ()
34 g_model_setcolormaptoactivator();
35 self.SendFlags |= (BIT(3) | BIT(0));
38 void g_clientmodel_use()
40 if (self.antiwall_flag == 1)
43 self.solid = SOLID_NOT;
45 else if (self.antiwall_flag == 2)
48 self.solid = self.default_solid;
50 g_clientmodel_setcolormaptoactivator();
53 void g_model_dropbyspawnflags()
55 if((self.spawnflags & 3) == 1) // ALIGN_ORIGIN
57 traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
58 setorigin(self, trace_endpos);
60 else if((self.spawnflags & 3) == 2) // ALIGN_BOTTOM
62 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
63 setorigin(self, trace_endpos);
65 else if((self.spawnflags & 3) == 3) // ALIGN_ORIGIN | ALIGN_BOTTOM
67 traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
68 setorigin(self, trace_endpos - '0 0 1' * self.mins.z);
72 void g_clientmodel_dropbyspawnflags()
76 g_model_dropbyspawnflags();
81 bool g_clientmodel_genericsendentity(entity this, entity to, int sf)
84 if(self.angles != '0 0 0')
86 if(self.mins != '0 0 0' || self.maxs != '0 0 0')
88 if(self.colormap != 0)
90 if(self.lodmodelindex1)
93 WriteHeader(MSG_ENTITY, ENT_CLIENT_WALL);
94 WriteByte(MSG_ENTITY, sf);
99 WriteShort(MSG_ENTITY, self.colormap);
104 WriteCoord(MSG_ENTITY, self.origin.x);
105 WriteCoord(MSG_ENTITY, self.origin.y);
106 WriteCoord(MSG_ENTITY, self.origin.z);
113 WriteAngle(MSG_ENTITY, self.angles.x);
114 WriteAngle(MSG_ENTITY, self.angles.y);
115 WriteAngle(MSG_ENTITY, self.angles.z);
123 WriteShort(MSG_ENTITY, self.lodmodelindex0);
124 WriteShort(MSG_ENTITY, bound(0, self.loddistance1, 65535));
125 WriteShort(MSG_ENTITY, self.lodmodelindex1);
126 WriteShort(MSG_ENTITY, bound(0, self.loddistance2, 65535));
127 WriteShort(MSG_ENTITY, self.lodmodelindex2);
130 WriteShort(MSG_ENTITY, self.modelindex);
131 WriteByte(MSG_ENTITY, self.solid);
132 WriteShort(MSG_ENTITY, floor(self.scale * 256));
135 WriteCoord(MSG_ENTITY, self.mins.x);
136 WriteCoord(MSG_ENTITY, self.mins.y);
137 WriteCoord(MSG_ENTITY, self.mins.z);
138 WriteCoord(MSG_ENTITY, self.maxs.x);
139 WriteCoord(MSG_ENTITY, self.maxs.y);
140 WriteCoord(MSG_ENTITY, self.maxs.z);
142 WriteString(MSG_ENTITY, self.bgmscript);
143 if(self.bgmscript != "")
145 WriteByte(MSG_ENTITY, floor(self.bgmscriptattack * 64));
146 WriteByte(MSG_ENTITY, floor(self.bgmscriptdecay * 64));
147 WriteByte(MSG_ENTITY, floor(self.bgmscriptsustain * 255));
148 WriteByte(MSG_ENTITY, floor(self.bgmscriptrelease * 64));
149 WriteCoord(MSG_ENTITY, self.movedir.x);
150 WriteCoord(MSG_ENTITY, self.movedir.y);
151 WriteCoord(MSG_ENTITY, self.movedir.z);
152 WriteByte(MSG_ENTITY, floor(self.lip * 255));
154 WriteShort(MSG_ENTITY, self.fade_start);
155 WriteShort(MSG_ENTITY, self.fade_end);
156 WriteShort(MSG_ENTITY, self.alpha_max);
157 WriteShort(MSG_ENTITY, self.alpha_min);
158 WriteShort(MSG_ENTITY, self.inactive);
159 WriteShort(MSG_ENTITY, self.fade_vertical_offset);
166 #define G_MODEL_INIT(sol) \
167 if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
168 if(!self.scale) self.scale = self.modelscale; \
169 SetBrushEntityModel(); \
170 self.use = g_model_setcolormaptoactivator; \
171 InitializeEntity(self, g_model_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
172 if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT;
174 #define G_CLIENTMODEL_INIT(sol) \
175 if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
176 if(!self.scale) self.scale = self.modelscale; \
177 SetBrushEntityModel(); \
178 self.use = g_clientmodel_use; \
179 InitializeEntity(self, g_clientmodel_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
180 if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT; \
181 if(!self.bgmscriptsustain) self.bgmscriptsustain = 1; else if(self.bgmscriptsustain < 0) self.bgmscriptsustain = 0; \
182 Net_LinkEntity(self, true, 0, g_clientmodel_genericsendentity); \
183 self.default_solid = sol;
185 // non-solid model entities:
186 spawnfunc(misc_gamemodel) { self.angles_x = -self.angles.x; G_MODEL_INIT (SOLID_NOT) } // model entity
187 spawnfunc(misc_clientmodel) { self.angles_x = -self.angles.x; G_CLIENTMODEL_INIT(SOLID_NOT) } // model entity
188 spawnfunc(misc_models) { self.angles_x = -self.angles.x; G_MODEL_INIT (SOLID_NOT) } // DEPRECATED old compat entity with confusing name, do not use
190 // non-solid brush entities:
191 spawnfunc(func_illusionary) { G_MODEL_INIT (SOLID_NOT) } // Q1 name (WARNING: MISPREDICTED)
192 spawnfunc(func_clientillusionary) { G_CLIENTMODEL_INIT(SOLID_NOT) } // brush entity
193 spawnfunc(func_static) { G_MODEL_INIT (SOLID_NOT) } // DEPRECATED old alias name from some other game
195 // solid brush entities
196 spawnfunc(func_wall) { G_MODEL_INIT (SOLID_BSP) } // Q1 name
197 spawnfunc(func_clientwall) { G_CLIENTMODEL_INIT(SOLID_BSP) } // brush entity (WARNING: MISPREDICTED)