1 #include "particles.qh"
4 #include "bgmscript.qh"
6 #include "../common/stats.qh"
7 #include "../common/util.qh"
9 #include "../warpzonelib/common.qh"
11 void Draw_PointParticles()
18 sz = self.maxs - self.mins;
19 n = doBGMScript(self);
20 if(self.absolute == 2)
23 n = self.just_toggled ? self.impulse : 0;
25 n = self.impulse * drawframetime;
29 n *= self.impulse * drawframetime;
37 for(i = random(); i <= n && fail <= 64*n; ++i)
40 p.x += random() * sz.x;
41 p.y += random() * sz.y;
42 p.z += random() * sz.z;
43 if(WarpZoneLib_BoxTouchesBrush(p, p, self, world))
45 if(self.movedir != '0 0 0')
47 traceline(p, p + normalize(self.movedir) * 4096, 0, world);
49 pointparticles(self.cnt, p, trace_plane_normal * vlen(self.movedir) + self.velocity + randomvec() * self.waterlevel, self.count);
53 pointparticles(self.cnt, p, self.velocity + randomvec() * self.waterlevel, self.count);
58 sound(self, CH_AMBIENT, self.noise, VOL_BASE * self.volume, self.atten);
60 self.just_toggled = 0;
62 else if(self.absolute)
71 void Ent_PointParticles_Remove()
74 strunzone(self.noise);
75 self.noise = string_null;
77 strunzone(self.bgmscript);
78 self.bgmscript = string_null;
81 void Ent_PointParticles()
88 i = ReadCoord(); // density (<0: point, >0: volume)
89 if(i && !self.impulse && self.cnt) // self.cnt check is so it only happens if the ent already existed
90 self.just_toggled = 1;
95 self.origin_x = ReadCoord();
96 self.origin_y = ReadCoord();
97 self.origin_z = ReadCoord();
101 self.modelindex = ReadShort();
106 self.mins_x = ReadCoord();
107 self.mins_y = ReadCoord();
108 self.mins_z = ReadCoord();
109 self.maxs_x = ReadCoord();
110 self.maxs_y = ReadCoord();
111 self.maxs_z = ReadCoord();
116 self.maxs_x = ReadCoord();
117 self.maxs_y = ReadCoord();
118 self.maxs_z = ReadCoord();
123 self.mins = self.maxs = '0 0 0';
126 self.cnt = ReadShort(); // effect number
130 self.velocity = decompressShortVector(ReadShort());
131 self.movedir = decompressShortVector(ReadShort());
135 self.velocity = self.movedir = '0 0 0';
139 self.waterlevel = ReadShort() / 16.0;
140 self.count = ReadByte() / 16.0;
148 strunzone(self.noise);
150 strunzone(self.bgmscript);
151 self.noise = strzone(ReadString());
154 self.atten = ReadByte() / 64.0;
155 self.volume = ReadByte() / 255.0;
157 self.bgmscript = strzone(ReadString());
158 if(self.bgmscript != "")
160 self.bgmscriptattack = ReadByte() / 64.0;
161 self.bgmscriptdecay = ReadByte() / 64.0;
162 self.bgmscriptsustain = ReadByte() / 255.0;
163 self.bgmscriptrelease = ReadByte() / 64.0;
165 BGMScript_InitEntity(self);
170 self.absolute = (self.impulse >= 0);
173 v = self.maxs - self.mins;
174 self.impulse *= -v.x * v.y * v.z / 262144; // relative: particles per 64^3 cube
181 setorigin(self, self.origin);
182 setsize(self, self.mins, self.maxs);
183 self.solid = SOLID_NOT;
184 self.draw = Draw_PointParticles;
185 self.entremove = Ent_PointParticles_Remove;
190 te_particlerain(self.origin + self.mins, self.origin + self.maxs, self.velocity, floor(self.count * drawframetime + random()), self.glow_color);
195 te_particlesnow(self.origin + self.mins, self.origin + self.maxs, self.velocity, floor(self.count * drawframetime + random()), self.glow_color);
198 void Ent_RainOrSnow()
200 self.impulse = ReadByte(); // Rain, Snow, or Whatever
201 self.origin_x = ReadCoord();
202 self.origin_y = ReadCoord();
203 self.origin_z = ReadCoord();
204 self.maxs_x = ReadCoord();
205 self.maxs_y = ReadCoord();
206 self.maxs_z = ReadCoord();
207 self.velocity = decompressShortVector(ReadShort());
208 self.count = ReadShort() * 10;
209 self.glow_color = ReadByte(); // color
211 self.mins = -0.5 * self.maxs;
212 self.maxs = 0.5 * self.maxs;
213 self.origin = self.origin - self.mins;
215 setorigin(self, self.origin);
216 setsize(self, self.mins, self.maxs);
217 self.solid = SOLID_NOT;
219 self.draw = Draw_Rain;
221 self.draw = Draw_Snow;
224 void Net_ReadVortexBeamParticle()
226 vector shotorg, endpos;
228 shotorg.x = ReadCoord(); shotorg.y = ReadCoord(); shotorg.z = ReadCoord();
229 endpos.x = ReadCoord(); endpos.y = ReadCoord(); endpos.z = ReadCoord();
230 charge = ReadByte() / 255.0;
232 pointparticles(particleeffectnum("nex_muzzleflash"), shotorg, normalize(endpos - shotorg) * 1000, 1);
234 //draw either the old v2.3 beam or the new beam
235 charge = sqrt(charge); // divide evenly among trail spacing and alpha
236 particles_alphamin = particles_alphamax = particles_fade = charge;
238 if (autocvar_cl_particles_oldvortexbeam && (getstati(STAT_ALLOW_OLDVORTEXBEAM) || isdemo()))
239 WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum("TE_TEI_G3"), shotorg, endpos, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
241 WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum("nex_beam"), shotorg, endpos, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);