From 23b3615b5281e9356692f79842ff662523184d10 Mon Sep 17 00:00:00 2001 From: div0 Date: Tue, 26 Aug 2008 11:25:05 +0000 Subject: [PATCH] (untested) make rain and snow client side entities git-svn-id: svn://svn.icculus.org/nexuiz/trunk@4190 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/client/particles.qc | 36 +++++++++++++++++ data/qcsrc/common/constants.qh | 1 + data/qcsrc/server/g_triggers.qc | 71 ++++++++++++++++----------------- 3 files changed, 72 insertions(+), 36 deletions(-) diff --git a/data/qcsrc/client/particles.qc b/data/qcsrc/client/particles.qc index ee2e1287f..03f295cf8 100644 --- a/data/qcsrc/client/particles.qc +++ b/data/qcsrc/client/particles.qc @@ -121,3 +121,39 @@ void Ent_PointParticles() self.solid = SOLID_NOT; self.draw = Draw_PointParticles; } + +void Draw_Rain() +{ + te_particlerain(self.origin + self.mins, self.origin + self.maxs, self.velocity, self.count * drawframetime, self.glow_color); +} + +void Draw_Snow() +{ + te_particlesnow(self.origin + self.mins, self.origin + self.maxs, self.velocity, self.count * drawframetime, self.glow_color); +} + +void Ent_RainOrSnow() +{ + self.impulse = ReadByte(); // Rain, Snow, or Whatever + self.origin_x = ReadCoord(); + self.origin_y = ReadCoord(); + self.origin_z = ReadCoord(); + self.maxs_x = ReadCoord(); + self.maxs_y = ReadCoord(); + self.maxs_z = ReadCoord(); + self.velocity = decompressShortVector(ReadShort()); + self.count = ReadShort() * 10; + self.glow_color = ReadByte(); // color + + self.mins = -0.5 * self.maxs; + self.maxs = 0.5 * self.maxs; + self.origin = self.origin - self.mins; + + setorigin(self, self.origin); + setsize(self, self.mins, self.maxs); + self.solid = SOLID_NOT; + if(self.impulse) + self.draw = Draw_Rain; + else + self.draw = Draw_Snow; +} diff --git a/data/qcsrc/common/constants.qh b/data/qcsrc/common/constants.qh index 7d8abc2ee..fbf1e3c28 100644 --- a/data/qcsrc/common/constants.qh +++ b/data/qcsrc/common/constants.qh @@ -40,6 +40,7 @@ const float ENT_CLIENT_SCORES_INFO = 3; const float ENT_CLIENT_SCORES = 4; const float ENT_CLIENT_TEAMSCORES = 5; const float ENT_CLIENT_POINTPARTICLES = 6; +const float ENT_CLIENT_RAINSNOW = 7; /////////////////////////// // key constants diff --git a/data/qcsrc/server/g_triggers.qc b/data/qcsrc/server/g_triggers.qc index f3158d6a8..80137992e 100644 --- a/data/qcsrc/server/g_triggers.qc +++ b/data/qcsrc/server/g_triggers.qc @@ -512,7 +512,7 @@ float pointparticles_SendEntity(entity to) return 1; } -float pointparticles_use() +void pointparticles_use() { if(self.wait && time < self.nextthink) { @@ -526,7 +526,7 @@ float pointparticles_use() self.Version += 1; } -float pointparticles_think() +void pointparticles_think() { self.state = !self.state; self.Version += 1; @@ -584,18 +584,20 @@ void spawnfunc_func_sparks() spawnfunc_func_pointparticles(); } -void rain_think() -{ - self.nextthink = time + 0.1; - te_particlerain(self.absmin, self.absmax, self.dest, self.count, self.cnt); -// te_particlesnow(self.absmin, self.absmax, self.dest * 0.25, self.count, self.cnt); -// WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); -// WriteByte (MSG_BROADCAST, TE_PARTICLERAIN); -// WriteVec (MSG_BROADCAST, self.absmin); -// WriteVec (MSG_BROADCAST, self.absmax); -// WriteVec (MSG_BROADCAST, self.dest); -// WriteShort (MSG_BROADCAST, self.count); -// WriteByte (MSG_BROADCAST, self.cnt); +float rainsnow_SendEntity(float to) +{ + WriteByte(MSG_ENTITY, ENT_CLIENT_RAINSNOW); + WriteByte(MSG_ENTITY, self.state); + WriteCoord(MSG_ENTITY, self.origin_x + self.mins_x); + WriteCoord(MSG_ENTITY, self.origin_y + self.mins_y); + WriteCoord(MSG_ENTITY, self.origin_z + self.mins_z); + WriteCoord(MSG_ENTITY, self.maxs_x - self.mins_x); + WriteCoord(MSG_ENTITY, self.maxs_y - self.mins_y); + WriteCoord(MSG_ENTITY, self.maxs_z - self.mins_z); + WriteShort(MSG_ENTITY, compressShortVector(self.dest)); + WriteShort(MSG_ENTITY, self.count); + WriteByte(MSG_ENTITY, self.cnt); + return 1; }; /*QUAKED spawnfunc_func_rain (0 .5 .8) ? @@ -630,26 +632,18 @@ void spawnfunc_func_rain() remove(self); return; } - // convert from per second to per 0.1 sec, - self.count = ceil(self.count * 0.1); - self.think = rain_think; - self.nextthink = time + 0.5; -}; - + if(self.count > 65535) + self.count = 65535; -void snow_think() -{ - self.nextthink = time + 0.1 + random() * 0.05; - te_particlesnow(self.absmin, self.absmax, self.dest, self.count, self.cnt); -// WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); -// WriteByte (MSG_BROADCAST, TE_PARTICLESNOW); -// WriteVec (MSG_BROADCAST, self.absmin); -// WriteVec (MSG_BROADCAST, self.absmax); -// WriteVec (MSG_BROADCAST, self.dest); -// WriteShort (MSG_BROADCAST, self.count); -// WriteByte (MSG_BROADCAST, self.cnt); + self.state = 1; // 1 is rain, 0 is snow + self.effects = EF_NODEPTHTEST; + self.SendEntity = rainsnow_SendEntity; + self.Version = 1; + self.modelindex = 1; + self.model = "net_entity"; }; + /*QUAKED spawnfunc_func_snow (0 .5 .8) ? This is an invisible area like a trigger, which snow falls inside of. @@ -676,16 +670,21 @@ void spawnfunc_func_snow() self.cnt = 12; if (!self.count) self.count = 2000; - self.count = 0.1 * self.count * (self.size_x / 1024) * (self.size_y / 1024); + self.count = 0.01 * self.count * (self.size_x / 1024) * (self.size_y / 1024); if (self.count < 1) { remove(self); return; } - // convert from per second to per 0.1 sec, - self.count = ceil(self.count * 0.1); - self.think = snow_think; - self.nextthink = time + 0.5; + if(self.count > 65535) + self.count = 65535; + + self.state = 0; // 1 is rain, 0 is snow + self.effects = EF_NODEPTHTEST; + self.SendEntity = rainsnow_SendEntity; + self.Version = 1; + self.modelindex = 1; + self.model = "net_entity"; }; -- 2.39.2