2 // NOTE: also contains func_sparks
4 float pointparticles_SendEntity(entity to, float fl)
6 WriteByte(MSG_ENTITY, ENT_CLIENT_POINTPARTICLES);
8 // optional features to save space
10 if(self.spawnflags & 2)
11 fl |= 0x10; // absolute count on toggle-on
12 if(self.movedir != '0 0 0' || self.velocity != '0 0 0')
13 fl |= 0x20; // 4 bytes - saves CPU
14 if(self.waterlevel || self.count != 1)
15 fl |= 0x40; // 4 bytes - obscure features almost never used
16 if(self.mins != '0 0 0' || self.maxs != '0 0 0')
17 fl |= 0x80; // 14 bytes - saves lots of space
19 WriteByte(MSG_ENTITY, fl);
23 WriteCoord(MSG_ENTITY, self.impulse);
25 WriteCoord(MSG_ENTITY, 0); // off
29 WriteCoord(MSG_ENTITY, self.origin_x);
30 WriteCoord(MSG_ENTITY, self.origin_y);
31 WriteCoord(MSG_ENTITY, self.origin_z);
35 if(self.model != "null")
37 WriteShort(MSG_ENTITY, self.modelindex);
40 WriteCoord(MSG_ENTITY, self.mins_x);
41 WriteCoord(MSG_ENTITY, self.mins_y);
42 WriteCoord(MSG_ENTITY, self.mins_z);
43 WriteCoord(MSG_ENTITY, self.maxs_x);
44 WriteCoord(MSG_ENTITY, self.maxs_y);
45 WriteCoord(MSG_ENTITY, self.maxs_z);
50 WriteShort(MSG_ENTITY, 0);
53 WriteCoord(MSG_ENTITY, self.maxs_x);
54 WriteCoord(MSG_ENTITY, self.maxs_y);
55 WriteCoord(MSG_ENTITY, self.maxs_z);
58 WriteShort(MSG_ENTITY, self.cnt);
61 WriteShort(MSG_ENTITY, compressShortVector(self.velocity));
62 WriteShort(MSG_ENTITY, compressShortVector(self.movedir));
66 WriteShort(MSG_ENTITY, self.waterlevel * 16.0);
67 WriteByte(MSG_ENTITY, self.count * 16.0);
69 WriteString(MSG_ENTITY, self.noise);
72 WriteByte(MSG_ENTITY, floor(self.atten * 64));
73 WriteByte(MSG_ENTITY, floor(self.volume * 255));
75 WriteString(MSG_ENTITY, self.bgmscript);
76 if(self.bgmscript != "")
78 WriteByte(MSG_ENTITY, floor(self.bgmscriptattack * 64));
79 WriteByte(MSG_ENTITY, floor(self.bgmscriptdecay * 64));
80 WriteByte(MSG_ENTITY, floor(self.bgmscriptsustain * 255));
81 WriteByte(MSG_ENTITY, floor(self.bgmscriptrelease * 64));
87 void pointparticles_use()
89 self.state = !self.state;
93 void pointparticles_think()
95 if(self.origin != self.oldorigin)
98 self.oldorigin = self.origin;
100 self.nextthink = time;
103 void pointparticles_reset()
105 if(self.spawnflags & 1)
111 void spawnfunc_func_pointparticles()
114 setmodel(self, self.model);
116 precache_sound (self.noise);
118 if(!self.bgmscriptsustain)
119 self.bgmscriptsustain = 1;
120 else if(self.bgmscriptsustain < 0)
121 self.bgmscriptsustain = 0;
124 self.atten = ATTEN_NORM;
125 else if(self.atten < 0)
136 setorigin(self, self.origin + self.mins);
137 setsize(self, '0 0 0', self.maxs - self.mins);
140 self.cnt = particleeffectnum(self.mdl);
142 Net_LinkEntity(self, (self.spawnflags & 4), 0, pointparticles_SendEntity);
146 self.use = pointparticles_use;
147 self.reset = pointparticles_reset;
152 self.think = pointparticles_think;
153 self.nextthink = time;
156 void spawnfunc_func_sparks()
158 // self.cnt is the amount of sparks that one burst will spawn
160 self.cnt = 25.0; // nice default value
163 // self.wait is the probability that a sparkthink will spawn a spark shower
164 // range: 0 - 1, but 0 makes little sense, so...
165 if(self.wait < 0.05) {
166 self.wait = 0.25; // nice default value
169 self.count = self.cnt;
172 self.velocity = '0 0 -1';
173 self.mdl = "TE_SPARK";
174 self.impulse = 10 * self.wait; // by default 2.5/sec
176 self.cnt = 0; // use mdl
178 spawnfunc_func_pointparticles();