1 vector PointInBrush_vec;
2 entity PointInBrush_brush;
3 .float dphitcontentsmask;
4 float PointInBrush_Recurse()
10 traceline(PointInBrush_vec, PointInBrush_vec, 0, world);
13 if(trace_ent == PointInBrush_brush)
19 f = PointInBrush_Recurse();
24 float PointInBrush(entity brush, vector point)
28 if not(brush.modelindex)
32 brush.solid = SOLID_BSP;
33 PointInBrush_vec = point;
34 PointInBrush_brush = brush;
35 f = PointInBrush_Recurse();
41 .float cnt; // effect number
42 .vector velocity; // particle velocity
43 .float waterlevel; // direction jitter
44 .float count; // count multiplier
45 .float glow_color; // palette color
46 .float impulse; // density
47 .string noise; // sound
49 .vector movedir; // trace direction
51 void Draw_PointParticles()
58 sz = self.maxs - self.mins;
59 n = self.impulse * drawframetime;
63 for(i = random(); i <= n && fail <= 64*n; ++i)
66 p_x += random() * sz_x;
67 p_y += random() * sz_y;
68 p_z += random() * sz_z;
69 if(PointInBrush(self, p))
71 if(self.movedir != '0 0 0')
73 traceline(p, p + normalize(self.movedir) * 4096, 0, world);
75 pointparticles(self.cnt, p, trace_plane_normal * vlen(self.movedir) + self.velocity + randomvec() * self.waterlevel, self.count, self.glow_color);
78 pointparticles(self.cnt, p, self.velocity + randomvec() * self.waterlevel, self.count, self.glow_color);
82 sound(self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
85 else if(self.absolute)
94 void Ent_PointParticles_Remove()
97 strunzone(self.noise);
98 self.noise = string_null;
101 void Ent_PointParticles()
107 self.impulse = ReadCoord(); // density (<0: point, >0: volume)
108 self.absolute = (self.impulse >= 0);
110 self.impulse *= -self.maxs_x * self.maxs_y * self.maxs_z / 262144; // relative: particles per 64^3 cube
114 self.origin_x = ReadCoord();
115 self.origin_y = ReadCoord();
116 self.origin_z = ReadCoord();
120 self.modelindex = ReadShort();
123 self.mins_x = ReadCoord();
124 self.mins_y = ReadCoord();
125 self.mins_z = ReadCoord();
126 self.maxs_x = ReadCoord();
127 self.maxs_y = ReadCoord();
128 self.maxs_z = ReadCoord();
133 self.maxs_x = ReadCoord();
134 self.maxs_y = ReadCoord();
135 self.maxs_z = ReadCoord();
138 self.cnt = ReadShort(); // effect number
140 self.velocity = decompressShortVector(ReadShort());
141 self.movedir = decompressShortVector(ReadShort());
142 self.waterlevel = ReadCoord();
143 self.count = ReadCoord();
144 self.glow_color = ReadByte();
146 strunzone(self.noise);
147 self.noise = strzone(ReadString());
150 setorigin(self, self.origin);
151 setsize(self, self.mins, self.maxs);
152 self.solid = SOLID_NOT;
153 self.draw = Draw_PointParticles;
154 self.entremove = Ent_PointParticles_Remove;
159 te_particlerain(self.origin + self.mins, self.origin + self.maxs, self.velocity, self.count * drawframetime, self.glow_color);
164 te_particlesnow(self.origin + self.mins, self.origin + self.maxs, self.velocity, self.count * drawframetime, self.glow_color);
167 void Ent_RainOrSnow()
169 self.impulse = ReadByte(); // Rain, Snow, or Whatever
170 self.origin_x = ReadCoord();
171 self.origin_y = ReadCoord();
172 self.origin_z = ReadCoord();
173 self.maxs_x = ReadCoord();
174 self.maxs_y = ReadCoord();
175 self.maxs_z = ReadCoord();
176 self.velocity = decompressShortVector(ReadShort());
177 self.count = ReadShort() * 10;
178 self.glow_color = ReadByte(); // color
180 self.mins = -0.5 * self.maxs;
181 self.maxs = 0.5 * self.maxs;
182 self.origin = self.origin - self.mins;
184 setorigin(self, self.origin);
185 setsize(self, self.mins, self.maxs);
186 self.solid = SOLID_NOT;
188 self.draw = Draw_Rain;
190 self.draw = Draw_Snow;