-#ifdef CSQC
- #include "../../../client/particles.qh"
-#endif
+REGISTER_NET_LINKED(ENT_CLIENT_POINTPARTICLES)
#ifdef SVQC
// NOTE: also contains func_sparks
-float pointparticles_SendEntity(entity to, float fl)
-{SELFPARAM();
- WriteByte(MSG_ENTITY, ENT_CLIENT_POINTPARTICLES);
+bool pointparticles_SendEntity(entity this, entity to, float fl)
+{
+ WriteHeader(MSG_ENTITY, ENT_CLIENT_POINTPARTICLES);
// optional features to save space
fl = fl & 0x0F;
}
}
WriteShort(MSG_ENTITY, self.cnt);
+ WriteString(MSG_ENTITY, self.mdl);
if(fl & 0x20)
{
WriteShort(MSG_ENTITY, compressShortVector(self.velocity));
self.nextthink = time;
}
-void pointparticles_reset()
-{SELFPARAM();
- if(self.spawnflags & 1)
- self.state = 1;
+void pointparticles_reset(entity this)
+{
+ if(this.spawnflags & 1)
+ this.state = 1;
else
- self.state = 0;
+ this.state = 0;
}
-void spawnfunc_func_pointparticles()
-{SELFPARAM();
- if(self.model != "")
- _setmodel(self, self.model);
- if(self.noise != "")
- precache_sound (self.noise);
+spawnfunc(func_pointparticles)
+{
+ if(this.model != "") { precache_model(this.model); _setmodel(this, this.model); }
+ if(this.noise != "") precache_sound(this.noise);
+ if(this.mdl != "") this.cnt = 0; // use a good handler
- if(!self.bgmscriptsustain)
- self.bgmscriptsustain = 1;
- else if(self.bgmscriptsustain < 0)
- self.bgmscriptsustain = 0;
+ if(!this.bgmscriptsustain) this.bgmscriptsustain = 1;
+ else if(this.bgmscriptsustain < 0) this.bgmscriptsustain = 0;
- if(!self.atten)
- self.atten = ATTEN_NORM;
- else if(self.atten < 0)
- self.atten = 0;
- if(!self.volume)
- self.volume = 1;
- if(!self.count)
- self.count = 1;
- if(!self.impulse)
- self.impulse = 1;
+ if(!this.atten) this.atten = ATTEN_NORM;
+ else if(this.atten < 0) this.atten = 0;
+ if(!this.volume) this.volume = 1;
+ if(!this.count) this.count = 1;
+ if(!this.impulse) this.impulse = 1;
- if(!self.modelindex)
+ if(!this.modelindex)
{
- setorigin(self, self.origin + self.mins);
- setsize(self, '0 0 0', self.maxs - self.mins);
+ setorigin(this, this.origin + this.mins);
+ setsize(this, '0 0 0', this.maxs - this.mins);
}
- if(!self.cnt)
- self.cnt = _particleeffectnum(self.mdl);
+ //if(!this.cnt) this.cnt = _particleeffectnum(this.mdl);
- Net_LinkEntity(self, (self.spawnflags & 4), 0, pointparticles_SendEntity);
+ Net_LinkEntity(this, (this.spawnflags & 4), 0, pointparticles_SendEntity);
IFTARGETED
{
- self.use = pointparticles_use;
- self.reset = pointparticles_reset;
- self.reset();
+ this.use = pointparticles_use;
+ this.reset = pointparticles_reset;
+ this.reset(this);
}
else
- self.state = 1;
- self.think = pointparticles_think;
- self.nextthink = time;
+ this.state = 1;
+ this.think = pointparticles_think;
+ this.nextthink = time;
}
-void spawnfunc_func_sparks()
-{SELFPARAM();
+spawnfunc(func_sparks)
+{
// self.cnt is the amount of sparks that one burst will spawn
if(self.cnt < 1) {
self.cnt = 25.0; // nice default value
self.wait = 0;
self.cnt = 0; // use mdl
- spawnfunc_func_pointparticles();
+ spawnfunc_func_pointparticles(this);
}
#elif defined(CSQC)
-void Draw_PointParticles()
-{SELFPARAM();
+.int dphitcontentsmask;
+
+entityclass(PointParticles);
+class(PointParticles) .int cnt; // effect number
+class(PointParticles) .vector velocity; // particle velocity
+class(PointParticles) .float waterlevel; // direction jitter
+class(PointParticles) .int count; // count multiplier
+class(PointParticles) .int impulse; // density
+class(PointParticles) .string noise; // sound
+class(PointParticles) .float atten;
+class(PointParticles) .float volume;
+class(PointParticles) .float absolute; // 1 = count per second is absolute, 2 = only spawn at toggle
+class(PointParticles) .vector movedir; // trace direction
+class(PointParticles) .float glow_color; // palette index
+
+void Draw_PointParticles(entity this)
+{
float n, i, fail;
vector p;
vector sz;
{
traceline(p, p + normalize(self.movedir) * 4096, 0, world);
p = trace_endpos;
- pointparticles(self.cnt, p, trace_plane_normal * vlen(self.movedir) + self.velocity + randomvec() * self.waterlevel, self.count);
+ int eff_num;
+ if(self.cnt)
+ eff_num = self.cnt;
+ else
+ eff_num = _particleeffectnum(self.mdl);
+ __pointparticles(eff_num, p, trace_plane_normal * vlen(self.movedir) + self.velocity + randomvec() * self.waterlevel, self.count);
}
else
{
- pointparticles(self.cnt, p, self.velocity + randomvec() * self.waterlevel, self.count);
+ int eff_num;
+ if(self.cnt)
+ eff_num = self.cnt;
+ else
+ eff_num = _particleeffectnum(self.mdl);
+ __pointparticles(eff_num, p, self.velocity + randomvec() * self.waterlevel, self.count);
}
if(self.noise != "")
{
setorigin(self, o);
}
-void Ent_PointParticles_Remove()
-{SELFPARAM();
- if(self.noise)
- strunzone(self.noise);
- self.noise = string_null;
- if(self.bgmscript)
- strunzone(self.bgmscript);
- self.bgmscript = string_null;
+void Ent_PointParticles_Remove(entity this)
+{
+ if(this.noise)
+ strunzone(this.noise);
+ this.noise = string_null;
+ if(this.bgmscript)
+ strunzone(this.bgmscript);
+ this.bgmscript = string_null;
+ if(this.mdl)
+ strunzone(this.mdl);
+ this.mdl = string_null;
}
-void Ent_PointParticles()
-{SELFPARAM();
+NET_HANDLE(ENT_CLIENT_POINTPARTICLES, bool isnew)
+{
float i;
vector v;
int f = ReadByte();
if(f & 2)
{
i = ReadCoord(); // density (<0: point, >0: volume)
- if(i && !self.impulse && self.cnt) // self.cnt check is so it only happens if the ent already existed
+ if(i && !self.impulse && (self.cnt || self.mdl)) // self.cnt check is so it only happens if the ent already existed
self.just_toggled = 1;
self.impulse = i;
}
}
self.cnt = ReadShort(); // effect number
+ self.mdl = strzone(ReadString()); // effect string
if(f & 0x20)
{
BGMScript_InitEntity(self);
}
+ return = true;
+
if(f & 2)
{
self.absolute = (self.impulse >= 0);