4 #include "../common/triggers/subs.qh"
5 #include "../common/triggers/triggers.qh"
7 entityclass(BGMScript);
8 class(BGMScript) .string bgmscript;
9 class(BGMScript) .float bgmscriptattack;
10 class(BGMScript) .float bgmscriptdecay;
11 class(BGMScript) .float bgmscriptsustain;
12 class(BGMScript) .float bgmscriptrelease;
14 #include "../common/constants.qh"
15 #include "../lib/csqcmodel/sv_model.qh"
19 void g_model_setcolormaptoactivator ()
24 self.colormap = (activator.team - 1) * 0x11;
29 self.colormap = floor(random() * 256);
30 self.colormap |= BIT(10); // RENDER_COLORMAPPED
33 void g_clientmodel_setcolormaptoactivator ()
35 g_model_setcolormaptoactivator();
36 self.SendFlags |= (BIT(3) | BIT(0));
39 void g_clientmodel_use()
41 if (self.antiwall_flag == 1)
44 self.solid = SOLID_NOT;
46 else if (self.antiwall_flag == 2)
49 self.solid = self.default_solid;
51 g_clientmodel_setcolormaptoactivator();
54 void g_model_dropbyspawnflags(entity this)
56 if((self.spawnflags & 3) == 1) // ALIGN_ORIGIN
58 traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
59 setorigin(self, trace_endpos);
61 else if((self.spawnflags & 3) == 2) // ALIGN_BOTTOM
63 tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
64 setorigin(self, trace_endpos);
66 else if((self.spawnflags & 3) == 3) // ALIGN_ORIGIN | ALIGN_BOTTOM
68 traceline(self.origin, self.origin - '0 0 4096', MOVE_NOMONSTERS, self);
69 setorigin(self, trace_endpos - '0 0 1' * self.mins.z);
73 void g_clientmodel_dropbyspawnflags(entity this)
77 g_model_dropbyspawnflags(self);
82 bool g_clientmodel_genericsendentity(entity this, entity to, int sf)
85 if(self.angles != '0 0 0')
87 if(self.mins != '0 0 0' || self.maxs != '0 0 0')
89 if(self.colormap != 0)
91 if(self.lodmodelindex1)
94 WriteHeader(MSG_ENTITY, ENT_CLIENT_WALL);
95 WriteByte(MSG_ENTITY, sf);
100 WriteShort(MSG_ENTITY, self.colormap);
105 WriteCoord(MSG_ENTITY, self.origin.x);
106 WriteCoord(MSG_ENTITY, self.origin.y);
107 WriteCoord(MSG_ENTITY, self.origin.z);
114 WriteAngle(MSG_ENTITY, self.angles.x);
115 WriteAngle(MSG_ENTITY, self.angles.y);
116 WriteAngle(MSG_ENTITY, self.angles.z);
124 WriteShort(MSG_ENTITY, self.lodmodelindex0);
125 WriteShort(MSG_ENTITY, bound(0, self.loddistance1, 65535));
126 WriteShort(MSG_ENTITY, self.lodmodelindex1);
127 WriteShort(MSG_ENTITY, bound(0, self.loddistance2, 65535));
128 WriteShort(MSG_ENTITY, self.lodmodelindex2);
131 WriteShort(MSG_ENTITY, self.modelindex);
132 WriteByte(MSG_ENTITY, self.solid);
133 WriteShort(MSG_ENTITY, floor(self.scale * 256));
136 WriteCoord(MSG_ENTITY, self.mins.x);
137 WriteCoord(MSG_ENTITY, self.mins.y);
138 WriteCoord(MSG_ENTITY, self.mins.z);
139 WriteCoord(MSG_ENTITY, self.maxs.x);
140 WriteCoord(MSG_ENTITY, self.maxs.y);
141 WriteCoord(MSG_ENTITY, self.maxs.z);
143 WriteString(MSG_ENTITY, self.bgmscript);
144 if(self.bgmscript != "")
146 WriteByte(MSG_ENTITY, floor(self.bgmscriptattack * 64));
147 WriteByte(MSG_ENTITY, floor(self.bgmscriptdecay * 64));
148 WriteByte(MSG_ENTITY, floor(self.bgmscriptsustain * 255));
149 WriteByte(MSG_ENTITY, floor(self.bgmscriptrelease * 64));
150 WriteCoord(MSG_ENTITY, self.movedir.x);
151 WriteCoord(MSG_ENTITY, self.movedir.y);
152 WriteCoord(MSG_ENTITY, self.movedir.z);
153 WriteByte(MSG_ENTITY, floor(self.lip * 255));
155 WriteShort(MSG_ENTITY, self.fade_start);
156 WriteShort(MSG_ENTITY, self.fade_end);
157 WriteShort(MSG_ENTITY, self.alpha_max);
158 WriteShort(MSG_ENTITY, self.alpha_min);
159 WriteShort(MSG_ENTITY, self.inactive);
160 WriteShort(MSG_ENTITY, self.fade_vertical_offset);
167 #define G_MODEL_INIT(sol) \
168 if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
169 if(!self.scale) self.scale = self.modelscale; \
170 SetBrushEntityModel(); \
171 self.use = g_model_setcolormaptoactivator; \
172 InitializeEntity(self, g_model_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
173 if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT;
175 #define G_CLIENTMODEL_INIT(sol) \
176 if(self.geomtype) if(autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) self.movetype = MOVETYPE_PHYSICS; \
177 if(!self.scale) self.scale = self.modelscale; \
178 SetBrushEntityModel(); \
179 self.use = g_clientmodel_use; \
180 InitializeEntity(self, g_clientmodel_dropbyspawnflags, INITPRIO_DROPTOFLOOR); \
181 if(!self.solid) self.solid = (sol); else if(self.solid < 0) self.solid = SOLID_NOT; \
182 if(!self.bgmscriptsustain) self.bgmscriptsustain = 1; else if(self.bgmscriptsustain < 0) self.bgmscriptsustain = 0; \
183 Net_LinkEntity(self, true, 0, g_clientmodel_genericsendentity); \
184 self.default_solid = sol;
186 // non-solid model entities:
187 spawnfunc(misc_gamemodel) { self.angles_x = -self.angles.x; G_MODEL_INIT (SOLID_NOT) } // model entity
188 spawnfunc(misc_clientmodel) { self.angles_x = -self.angles.x; G_CLIENTMODEL_INIT(SOLID_NOT) } // model entity
189 spawnfunc(misc_models) { self.angles_x = -self.angles.x; G_MODEL_INIT (SOLID_NOT) } // DEPRECATED old compat entity with confusing name, do not use
191 // non-solid brush entities:
192 spawnfunc(func_illusionary) { G_MODEL_INIT (SOLID_NOT) } // Q1 name (WARNING: MISPREDICTED)
193 spawnfunc(func_clientillusionary) { G_CLIENTMODEL_INIT(SOLID_NOT) } // brush entity
194 spawnfunc(func_static) { G_MODEL_INIT (SOLID_NOT) } // DEPRECATED old alias name from some other game
196 // solid brush entities
197 spawnfunc(func_wall) { G_MODEL_INIT (SOLID_BSP) } // Q1 name
198 spawnfunc(func_clientwall) { G_CLIENTMODEL_INIT(SOLID_BSP) } // brush entity (WARNING: MISPREDICTED)