From f14d58771eb48d884fad331c4a067c8c020a5191 Mon Sep 17 00:00:00 2001 From: div0 Date: Sun, 5 Apr 2009 18:17:13 +0000 Subject: [PATCH] support settable attenuation for pointparticles git-svn-id: svn://svn.icculus.org/nexuiz/trunk@6435 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/client/particles.qc | 9 ++++++++- data/qcsrc/server/g_triggers.qc | 12 ++++++++++++ data/qcsrc/server/miscfunctions.qc | 2 +- data/scripts/entities.def | 2 ++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/data/qcsrc/client/particles.qc b/data/qcsrc/client/particles.qc index 9fc687d7c..1a629bb27 100644 --- a/data/qcsrc/client/particles.qc +++ b/data/qcsrc/client/particles.qc @@ -45,6 +45,8 @@ float PointInBrush(entity brush, vector point) .float glow_color; // palette color .float impulse; // density .string noise; // sound +.float atten; +.float volume; .float absolute; .vector movedir; // trace direction @@ -79,7 +81,7 @@ void Draw_PointParticles() if(self.noise != "") { self.origin = p; - sound(self, CHAN_AUTO, self.noise, 1, ATTN_NORM); + sound(self, CHAN_AUTO, self.noise, VOL_BASE * self.volume, self.atten); } } else if(self.absolute) @@ -143,6 +145,11 @@ void Ent_PointParticles() if(self.noise) strunzone(self.noise); self.noise = strzone(ReadString()); + if(self.noise != "") + { + self.atten = ReadByte() / 64.0; + self.volume = ReadByte() / 255.0; + } } if(f & 2) diff --git a/data/qcsrc/server/g_triggers.qc b/data/qcsrc/server/g_triggers.qc index 51a1fe5e6..fd6217346 100644 --- a/data/qcsrc/server/g_triggers.qc +++ b/data/qcsrc/server/g_triggers.qc @@ -597,6 +597,11 @@ float pointparticles_SendEntity(entity to, float fl) WriteCoord(MSG_ENTITY, self.count); WriteByte(MSG_ENTITY, self.glow_color); WriteString(MSG_ENTITY, self.noise); + if(self.noise != "") + { + WriteByte(MSG_ENTITY, floor(self.atten * 64)); + WriteByte(MSG_ENTITY, floor(self.volume * 255)); + } } return 1; } @@ -632,6 +637,13 @@ void spawnfunc_func_pointparticles() if(self.noise != "") precache_sound (self.noise); + if(!self.atten) + self.atten = ATTN_NORM; + else if(self.atten < 0) + self.atten = 0; + if(!self.volume) + self.volume = 1; + if(!self.modelindex) { setorigin(self, self.origin + self.mins); diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc index 1ab406dbe..27dc28947 100644 --- a/data/qcsrc/server/miscfunctions.qc +++ b/data/qcsrc/server/miscfunctions.qc @@ -1175,7 +1175,7 @@ void soundtoat(float dest, entity e, vector o, float chan, string samp, float vo WriteByte(dest, SVC_SOUND); WriteByte(dest, sflags); if(sflags & SND_VOLUME) - WriteByte(dest, vol * 255); + WriteByte(dest, vol); if(sflags & SND_ATTENUATION) WriteByte(dest, atten); if(sflags & SND_LARGEENTITY) diff --git a/data/scripts/entities.def b/data/scripts/entities.def index 6b842096b..2f916151f 100644 --- a/data/scripts/entities.def +++ b/data/scripts/entities.def @@ -1144,6 +1144,8 @@ count: particle count multiplier (per spawned particle) movedir: when set, trace direction (particles will then be emitted from the surface the trace hits); the length of the vector is used as strength of taking the normal of the trace into account glow_color: particle palette color noise: sound to play when the particle is emitted +atten: distance attenuation of the sound (a value from 0.1 to 3.9), default is 0.5; set to -1 for no attenuation (global sound) +volume: volume of the sound targetname: name to target this (then its state is toggled) -------- SPAWNFLAGS -------- START_ON: when targeted, the particle emitter will start switched on -- 2.39.2