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()
100 self.impulse = ReadCoord(); // density (<0: point, >0: volume)
101 self.absolute = (self.impulse >= 0);
103 self.impulse *= -self.maxs_x * self.maxs_y * self.maxs_z / 262144; // relative: particles per 64^3 cube
107 self.origin_x = ReadCoord();
108 self.origin_y = ReadCoord();
109 self.origin_z = ReadCoord();
113 self.modelindex = ReadShort();
116 self.mins_x = ReadCoord();
117 self.mins_y = ReadCoord();
118 self.mins_z = ReadCoord();
119 self.maxs_x = ReadCoord();
120 self.maxs_y = ReadCoord();
121 self.maxs_z = ReadCoord();
126 self.maxs_x = ReadCoord();
127 self.maxs_y = ReadCoord();
128 self.maxs_z = ReadCoord();
131 self.cnt = ReadShort(); // effect number
133 self.velocity = decompressShortVector(ReadShort());
134 self.movedir = decompressShortVector(ReadShort());
135 self.waterlevel = ReadCoord();
136 self.count = ReadCoord();
137 self.glow_color = ReadByte();
139 strunzone(self.noise);
140 self.noise = strzone(ReadString());
143 setorigin(self, self.origin);
144 setsize(self, self.mins, self.maxs);
145 self.solid = SOLID_NOT;
146 self.draw = Draw_PointParticles;
149 void Ent_PointParticles_Remove()
152 strunzone(self.noise);
153 self.noise = string_null;
158 te_particlerain(self.origin + self.mins, self.origin + self.maxs, self.velocity, self.count * drawframetime, self.glow_color);
163 te_particlesnow(self.origin + self.mins, self.origin + self.maxs, self.velocity, self.count * drawframetime, self.glow_color);
166 void Ent_RainOrSnow()
168 self.impulse = ReadByte(); // Rain, Snow, or Whatever
169 self.origin_x = ReadCoord();
170 self.origin_y = ReadCoord();
171 self.origin_z = ReadCoord();
172 self.maxs_x = ReadCoord();
173 self.maxs_y = ReadCoord();
174 self.maxs_z = ReadCoord();
175 self.velocity = decompressShortVector(ReadShort());
176 self.count = ReadShort() * 10;
177 self.glow_color = ReadByte(); // color
179 self.mins = -0.5 * self.maxs;
180 self.maxs = 0.5 * self.maxs;
181 self.origin = self.origin - self.mins;
183 setorigin(self, self.origin);
184 setsize(self, self.mins, self.maxs);
185 self.solid = SOLID_NOT;
187 self.draw = Draw_Rain;
189 self.draw = Draw_Snow;