From 56fdac71f46d6e4b9ec9979cace6f19a5c41e2d3 Mon Sep 17 00:00:00 2001 From: div0 Date: Wed, 11 Feb 2009 14:26:52 +0000 Subject: [PATCH] bullets with g_antilag_bullets now have some poor excuse of a trail. Warning, it crashes DP :P git-svn-id: svn://svn.icculus.org/nexuiz/trunk@5835 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/client/Main.qc | 4 +++ data/qcsrc/client/particles.qc | 45 ++++++++++++++++++++++++++++++ data/qcsrc/common/constants.qh | 1 + data/qcsrc/server/miscfunctions.qc | 32 +++++++++++++++++++++ data/qcsrc/server/w_common.qc | 24 ++++++++++++++++ data/scripts/shaderlist.txt | 2 ++ 6 files changed, 108 insertions(+) diff --git a/data/qcsrc/client/Main.qc b/data/qcsrc/client/Main.qc index 907c4775a..2dc85b0c9 100644 --- a/data/qcsrc/client/Main.qc +++ b/data/qcsrc/client/Main.qc @@ -998,6 +998,10 @@ float CSQC_Parse_TempEntity() Net_ReadSpawn(); bHandled = true; break; + case TE_CSQC_ZCURVEPARTICLES: + Net_ReadZCurveParticles(); + bHandled = true; + break; default: // No special logic for this temporary entity; return 0 so the engine can handle it bHandled = false; diff --git a/data/qcsrc/client/particles.qc b/data/qcsrc/client/particles.qc index 24956482a..f0793792d 100644 --- a/data/qcsrc/client/particles.qc +++ b/data/qcsrc/client/particles.qc @@ -189,3 +189,48 @@ void Ent_RainOrSnow() else self.draw = Draw_Snow; } + +void zcurveparticles(float effectnum, vector start, vector end, float end_dz, float depth) +{ + // end_dz: + // IF IT WERE A STRAIGHT LINE, it'd end end_dz above end + + vector mid; + mid = (start + end) * 0.5; + + end_dz *= 0.25; + mid_z += end_dz; + + --depth; + if(depth < 0 || normalize(mid - start) * normalize(end - start) > 0.999999) + // TODO make this a variable threshold + // currently: 0.081 degrees + // 0.99999 would be 0.256 degrees and is visible + { + trailparticles(world, effectnum, start, end); + } + else + { + zcurveparticles(effectnum, start, mid, end_dz, depth); + zcurveparticles(effectnum, mid, end, end_dz, depth); + } +} + +void Net_ReadZCurveParticles() +{ + vector start, end; + float end_dz; + float effectnum; + + effectnum = ReadShort(); + + start_x = ReadCoord(); + start_y = ReadCoord(); + start_z = ReadCoord(); + end_x = ReadCoord(); + end_y = ReadCoord(); + end_z = ReadCoord(); + end_dz = ReadCoord(); + + zcurveparticles(effectnum, start, end, end_dz, 5); // at most 32 segments +} diff --git a/data/qcsrc/common/constants.qh b/data/qcsrc/common/constants.qh index 624aaba91..0ab047045 100644 --- a/data/qcsrc/common/constants.qh +++ b/data/qcsrc/common/constants.qh @@ -45,6 +45,7 @@ const float AS_FLOAT = 8; const float TE_CSQC_PICTURE = 100; const float TE_CSQC_RACE = 101; const float TE_CSQC_SPAWN = 102; +const float TE_CSQC_ZCURVEPARTICLES = 103; const float RACE_NET_CHECKPOINT_HIT_QUALIFYING = 0; // byte checkpoint, short time, short recordtime, string recordholder const float RACE_NET_CHECKPOINT_CLEAR = 1; diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc index 2624150db..9489be88f 100644 --- a/data/qcsrc/server/miscfunctions.qc +++ b/data/qcsrc/server/miscfunctions.qc @@ -1967,3 +1967,35 @@ float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, f else return FALSE; } + +void zcurveparticles(float effectno, vector start, vector end, float end_dz) +{ + WriteByte(MSG_BROADCAST, SVC_TEMPENTITY); + WriteByte(MSG_BROADCAST, TE_CSQC_ZCURVEPARTICLES); + WriteShort(MSG_BROADCAST, effectno); + WriteCoord(MSG_BROADCAST, start_x); + WriteCoord(MSG_BROADCAST, start_y); + WriteCoord(MSG_BROADCAST, start_z); + WriteCoord(MSG_BROADCAST, end_x); + WriteCoord(MSG_BROADCAST, end_y); + WriteCoord(MSG_BROADCAST, end_z); + WriteCoord(MSG_BROADCAST, end_dz); +} + +void zcurveparticles_from_tracetoss(float effectno, vector start, vector end, vector vel) +{ + float end_dz; + vector vecxy, velxy; + + vecxy = end - start; vecxy_z = 0; + velxy = vel; velxy_z = 0; + + if(vlen(velxy) < 0.000001 * fabs(vel_z)) + { + trailparticles(world, effectno, start, end); + return; + } + + end_dz = vlen(vecxy) / vlen(velxy) * vel_z - (end_z - start_z); + zcurveparticles(effectno, start, end, end_dz); +} diff --git a/data/qcsrc/server/w_common.qc b/data/qcsrc/server/w_common.qc index 8a330fd45..9b401c829 100644 --- a/data/qcsrc/server/w_common.qc +++ b/data/qcsrc/server/w_common.qc @@ -192,6 +192,10 @@ float W_BallisticBullet_LeaveSolid(entity e, vector vel, float constant) float maxdist; float E0_m, Es_m; + // outside the world? forget it + if(self.origin_x > world.maxs_x || self.origin_y > world.maxs_y || self.origin_z > world.maxs_z || self.origin_x < world.mins_x || self.origin_y < world.mins_y || self.origin_z < world.mins_z) + return 0; + // E(s) = E0 - constant * s, constant = area of bullet circle * material constant / mass v0 = vlen(vel); @@ -315,7 +319,27 @@ void fireBallisticBullet(vector start, vector dir, float spread, float pSpeed, f for(;;) { + // DP tracetoss is stupid and always traces in 0.05s + // ticks. This makes it trace in 0.05*0.125s ticks + // instead. + vector v0; + float g0; + v0 = self.velocity; + g0 = self.gravity; + self.velocity = self.velocity * 0.125; + self.gravity *= 0.125 * 0.125; + trace_fraction = 0; tracetoss(self, oldself); + self.velocity = v0; + self.gravity = g0; + + zcurveparticles_from_tracetoss(particleeffectnum("TR_VORESPIKE"), self.origin, trace_endpos, self.velocity); + if(trace_fraction == 1) + break; + // won't hit anything anytime soon (DP's + // tracetoss does 200 tics of, here, + // 0.05*0.125s, that is, 1.25 seconds + other = trace_ent; dt = vlen(trace_endpos - self.origin) / vlen(self.velocity); // this is only approximate! setorigin(self, trace_endpos); diff --git a/data/scripts/shaderlist.txt b/data/scripts/shaderlist.txt index f5c3d6304..0296cddc5 100644 --- a/data/scripts/shaderlist.txt +++ b/data/scripts/shaderlist.txt @@ -52,3 +52,5 @@ tree turrets tznex01 water +caverna +hlac -- 2.39.2