X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ffunc%2Fpointparticles.qc;h=62b4d5a3629e846bc063e1368f55c189e890df50;hp=058f1199f405189a11e4026c43464c6535109a4d;hb=f72821fdcebe3ca01181a99727a06198de65ea08;hpb=96e1acc3050bcb718e2f06702e5b88a60459a015 diff --git a/qcsrc/common/triggers/func/pointparticles.qc b/qcsrc/common/triggers/func/pointparticles.qc index 058f1199f..62b4d5a36 100644 --- a/qcsrc/common/triggers/func/pointparticles.qc +++ b/qcsrc/common/triggers/func/pointparticles.qc @@ -1,13 +1,11 @@ -#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; @@ -60,6 +58,7 @@ float pointparticles_SendEntity(entity to, float fl) } } WriteShort(MSG_ENTITY, self.cnt); + WriteString(MSG_ENTITY, self.mdl); if(fl & 0x20) { WriteShort(MSG_ENTITY, compressShortVector(self.velocity)); @@ -104,61 +103,52 @@ void pointparticles_think() 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 @@ -179,12 +169,27 @@ void spawnfunc_func_sparks() 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; @@ -221,11 +226,21 @@ void Draw_PointParticles() { 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 != "") { @@ -243,25 +258,28 @@ void Draw_PointParticles() 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; } @@ -299,6 +317,7 @@ void Ent_PointParticles() } self.cnt = ReadShort(); // effect number + self.mdl = strzone(ReadString()); // effect string if(f & 0x20) { @@ -340,6 +359,8 @@ void Ent_PointParticles() BGMScript_InitEntity(self); } + return = true; + if(f & 2) { self.absolute = (self.impulse >= 0);