1 #include "particles.qh"
3 #include "autocvars.qh"
4 #include "bgmscript.qh"
7 #include "../common/stats.qh"
8 #include "../common/util.qh"
10 #include "../warpzonelib/common.qh"
12 void Draw_PointParticles()
19 sz = self.maxs - self.mins;
21 if(self.absolute == 2)
24 n = self.just_toggled ? self.impulse : 0;
26 n = self.impulse * drawframetime;
30 n *= self.impulse * drawframetime;
38 for(i = random(); i <= n && fail <= 64*n; ++i)
41 p.x += random() * sz.x;
42 p.y += random() * sz.y;
43 p.z += random() * sz.z;
44 if(WarpZoneLib_BoxTouchesBrush(p, p, self, world))
46 if(self.movedir != '0 0 0')
48 traceline(p, p + normalize(self.movedir) * 4096, 0, world);
50 pointparticles(self.cnt, p, trace_plane_normal * vlen(self.movedir) + self.velocity + randomvec() * self.waterlevel, self.count);
54 pointparticles(self.cnt, p, self.velocity + randomvec() * self.waterlevel, self.count);
59 sound(self, CH_AMBIENT, self.noise, VOL_BASE * self.volume, self.atten);
61 self.just_toggled = 0;
63 else if(self.absolute)
72 void Ent_PointParticles_Remove()
75 strunzone(self.noise);
76 self.noise = string_null;
78 strunzone(self.bgmscript);
79 self.bgmscript = string_null;
82 void Ent_PointParticles()
89 i = ReadCoord(); // density (<0: point, >0: volume)
90 if(i && !self.impulse && self.cnt) // self.cnt check is so it only happens if the ent already existed
91 self.just_toggled = 1;
96 self.origin_x = ReadCoord();
97 self.origin_y = ReadCoord();
98 self.origin_z = ReadCoord();
102 self.modelindex = ReadShort();
107 self.mins_x = ReadCoord();
108 self.mins_y = ReadCoord();
109 self.mins_z = ReadCoord();
110 self.maxs_x = ReadCoord();
111 self.maxs_y = ReadCoord();
112 self.maxs_z = ReadCoord();
117 self.maxs_x = ReadCoord();
118 self.maxs_y = ReadCoord();
119 self.maxs_z = ReadCoord();
124 self.mins = self.maxs = '0 0 0';
127 self.cnt = ReadShort(); // effect number
131 self.velocity = decompressShortVector(ReadShort());
132 self.movedir = decompressShortVector(ReadShort());
136 self.velocity = self.movedir = '0 0 0';
140 self.waterlevel = ReadShort() / 16.0;
141 self.count = ReadByte() / 16.0;
149 strunzone(self.noise);
151 strunzone(self.bgmscript);
152 self.noise = strzone(ReadString());
155 self.atten = ReadByte() / 64.0;
156 self.volume = ReadByte() / 255.0;
158 self.bgmscript = strzone(ReadString());
159 if(self.bgmscript != "")
161 self.bgmscriptattack = ReadByte() / 64.0;
162 self.bgmscriptdecay = ReadByte() / 64.0;
163 self.bgmscriptsustain = ReadByte() / 255.0;
164 self.bgmscriptrelease = ReadByte() / 64.0;
166 BGMScript_InitEntity(self);
171 self.absolute = (self.impulse >= 0);
174 v = self.maxs - self.mins;
175 self.impulse *= -v.x * v.y * v.z / 262144; // relative: particles per 64^3 cube
182 setorigin(self, self.origin);
183 setsize(self, self.mins, self.maxs);
184 self.solid = SOLID_NOT;
185 self.draw = Draw_PointParticles;
186 self.entremove = Ent_PointParticles_Remove;
191 te_particlerain(self.origin + self.mins, self.origin + self.maxs, self.velocity, floor(self.count * drawframetime + random()), self.glow_color);
196 te_particlesnow(self.origin + self.mins, self.origin + self.maxs, self.velocity, floor(self.count * drawframetime + random()), self.glow_color);
199 void Ent_RainOrSnow()
201 self.impulse = ReadByte(); // Rain, Snow, or Whatever
202 self.origin_x = ReadCoord();
203 self.origin_y = ReadCoord();
204 self.origin_z = ReadCoord();
205 self.maxs_x = ReadCoord();
206 self.maxs_y = ReadCoord();
207 self.maxs_z = ReadCoord();
208 self.velocity = decompressShortVector(ReadShort());
209 self.count = ReadShort() * 10;
210 self.glow_color = ReadByte(); // color
212 self.mins = -0.5 * self.maxs;
213 self.maxs = 0.5 * self.maxs;
214 self.origin = self.origin - self.mins;
216 setorigin(self, self.origin);
217 setsize(self, self.mins, self.maxs);
218 self.solid = SOLID_NOT;
220 self.draw = Draw_Rain;
222 self.draw = Draw_Snow;
225 void Net_ReadVortexBeamParticle()
227 vector shotorg, endpos;
229 shotorg.x = ReadCoord(); shotorg.y = ReadCoord(); shotorg.z = ReadCoord();
230 endpos.x = ReadCoord(); endpos.y = ReadCoord(); endpos.z = ReadCoord();
231 charge = ReadByte() / 255.0;
233 pointparticles(particleeffectnum("nex_muzzleflash"), shotorg, normalize(endpos - shotorg) * 1000, 1);
235 //draw either the old v2.3 beam or the new beam
236 charge = sqrt(charge); // divide evenly among trail spacing and alpha
237 particles_alphamin = particles_alphamax = particles_fade = charge;
239 if (autocvar_cl_particles_oldvortexbeam && (getstati(STAT_ALLOW_OLDVORTEXBEAM) || isdemo()))
240 WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum("TE_TEI_G3"), shotorg, endpos, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
242 WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum("nex_beam"), shotorg, endpos, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);