1 vector PointInBrush_vec;
2 entity PointInBrush_brush;
3 entity PointInBrush_allmask;
4 .float dphitcontentsmask;
5 float PointInBrush_Recurse()
11 traceline(PointInBrush_vec, PointInBrush_vec, 0, world);
14 if(trace_ent == PointInBrush_brush)
20 f = PointInBrush_Recurse();
25 float PointInBrush(entity brush, vector point)
29 if not(brush.modelindex)
33 brush.solid = SOLID_BSP;
34 PointInBrush_vec = point;
35 PointInBrush_brush = brush;
36 f = PointInBrush_Recurse();
42 .float cnt; // effect number
43 .vector velocity; // particle velocity
44 .float waterlevel; // direction jitter
45 .float count; // count multiplier
46 .float glow_color; // palette color
47 .float impulse; // density
48 .string noise; // sound
50 .vector movedir; // trace direction
52 void Draw_PointParticles()
59 sz = self.maxs - self.mins;
60 n = self.impulse * drawframetime;
64 for(i = random(); i <= n && fail <= 64*n; ++i)
67 p_x += random() * sz_x;
68 p_y += random() * sz_y;
69 p_z += random() * sz_z;
70 if(PointInBrush(self, p))
72 if(self.movedir != '0 0 0')
74 traceline(p, p + normalize(self.movedir) * 4096, 0, world);
76 pointparticles(self.cnt, p, trace_plane_normal * vlen(self.movedir) + self.velocity + randomvec() * self.waterlevel, self.count, self.glow_color);
79 pointparticles(self.cnt, p, self.velocity + randomvec() * self.waterlevel, self.count, self.glow_color);
83 sound(self, CHAN_AUTO, self.noise, 1, ATTN_NORM);
86 else if(self.absolute)
95 void Ent_PointParticles()
101 self.impulse = ReadCoord(); // density (<0: point, >0: volume)
102 self.absolute = (self.impulse >= 0);
104 self.impulse *= -self.maxs_x * self.maxs_y * self.maxs_z / 262144; // relative: particles per 64^3 cube
108 self.origin_x = ReadCoord();
109 self.origin_y = ReadCoord();
110 self.origin_z = ReadCoord();
114 self.modelindex = ReadShort();
117 self.mins_x = ReadCoord();
118 self.mins_y = ReadCoord();
119 self.mins_z = ReadCoord();
120 self.maxs_x = ReadCoord();
121 self.maxs_y = ReadCoord();
122 self.maxs_z = ReadCoord();
127 self.maxs_x = ReadCoord();
128 self.maxs_y = ReadCoord();
129 self.maxs_z = ReadCoord();
132 self.cnt = ReadShort(); // effect number
134 self.velocity = decompressShortVector(ReadShort());
135 self.movedir = decompressShortVector(ReadShort());
136 self.waterlevel = ReadCoord();
137 self.count = ReadCoord();
138 self.glow_color = ReadByte();
140 strunzone(self.noise);
141 self.noise = strzone(ReadString());
144 setorigin(self, self.origin);
145 setsize(self, self.mins, self.maxs);
146 self.solid = SOLID_NOT;
147 self.draw = Draw_PointParticles;
150 void Ent_PointParticles_Remove()
153 strunzone(self.noise);
154 self.noise = string_null;
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;