]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/particles.qc
Merge branch 'master' into samual/weapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / particles.qc
index d502bcd8e7653ee91510e8bb670d70a78c342151..857e182f6604c4aeb5f13df02dae2df954211c0d 100644 (file)
@@ -57,7 +57,7 @@ void Draw_PointParticles()
                        }
                        if(self.noise != "")
                        {
-                               self.origin = p;
+                               setorigin(self, p);
                                sound(self, CH_AMBIENT, self.noise, VOL_BASE * self.volume, self.atten);
                        }
                        self.just_toggled = 0;
@@ -68,7 +68,7 @@ void Draw_PointParticles()
                        --i;
                }
        }
-       self.origin = o;
+       setorigin(self, o);
 }
 
 void Ent_PointParticles_Remove()
@@ -225,133 +225,140 @@ void Ent_RainOrSnow()
                self.draw = Draw_Snow;
 }
 
-entity zcurve;
-void zcurveparticles(float effectnum, vector start, vector end, float end_dz, float speed, 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
-       {
-               zcurve.velocity = speed * normalize(end - start);
-               trailparticles(zcurve, effectnum, start, end);
-       }
-       else
-       {
-               zcurveparticles(effectnum, start, mid, end_dz, speed, depth);
-               zcurveparticles(effectnum, mid, end, end_dz, speed, depth);
-       }
-}
-
-void Net_ReadZCurveParticles()
-{
-       vector start, end;
-       float end_dz;
-       float effectnum, speed;
-
-       if(!zcurve)
-       {
-               zcurve = spawn();
-               zcurve.classname = "zcurve";
-       }
-
-       effectnum = ReadShort();
-
-       start_x = ReadCoord();
-       start_y = ReadCoord();
-       start_z = ReadCoord();
-
-       do
-       {
-               end_x = ReadCoord();
-               end_y = ReadCoord();
-               end_z = ReadCoord();
-               end_dz = ReadCoord();
-               speed = ReadShort();
-               zcurveparticles(effectnum, start, end, end_dz, 16 * (speed & 0x7FFF), 5); // at most 32 segments
-       }
-       while(!(speed & 0x8000));
-}
-
-void Net_ReadNexgunBeamParticle()
+void Net_ReadVortexBeamParticle()
 {
        vector shotorg, endpos;
        float charge;
        shotorg_x = ReadCoord(); shotorg_y = ReadCoord(); shotorg_z = ReadCoord();
        endpos_x = ReadCoord(); endpos_y = ReadCoord(); endpos_z = ReadCoord();
        charge = ReadByte() / 255.0;
-       
+
        pointparticles(particleeffectnum("nex_muzzleflash"), shotorg, normalize(endpos - shotorg) * 1000, 1);
-       
+
        //draw either the old v2.3 beam or the new beam
        charge = sqrt(charge); // divide evenly among trail spacing and alpha
-       particles_alphamin = particles_alphamax = charge;
+       particles_alphamin = particles_alphamax = particles_fade = charge;
+
        if (autocvar_cl_particles_oldnexbeam && (getstati(STAT_ALLOW_OLDNEXBEAM) || isdemo()))
-               WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum("TE_TEI_G3"), shotorg, endpos, charge, 1);
+               WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum("TE_TEI_G3"), shotorg, endpos, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
        else
-               WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum("nex_beam"), shotorg, endpos, charge, 1);
+               WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum("nex_beam"), shotorg, endpos, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
 }
 
-void Net_ReadShockwaveParticle()
+.vector sw_shotorg;
+.vector sw_endpos;
+.float sw_spread_max;
+.float sw_spread_min;
+.float sw_time;
+
+void Draw_Shockwave()
 {
-       vector shotorg, endpos, deviation;
-       shotorg_x = ReadCoord(); shotorg_y = ReadCoord(); shotorg_z = ReadCoord();
-       endpos_x = ReadCoord(); endpos_y = ReadCoord(); endpos_z = ReadCoord();
-       float spread = ReadByte() / 255.0;
+       float a = bound(0, (0.5 - ((time - self.sw_time) / 0.4)), 0.5);
+
+       if(!a) { remove(self); }
        
-       float counter, shots;
+       vector deviation, angle;
 
-       shots = 10;
+       vector sw_color = getcsqcplayercolor(self.sv_entnum); // GetTeamRGB(GetPlayerColor(self.sv_entnum));
+
+       vector first_min_end = '0 0 0', prev_min_end = '0 0 0', new_min_end = '0 0 0';
+       vector first_max_end = '0 0 0', prev_max_end = '0 0 0', new_max_end = '0 0 0';
+
+       float new_max_dist, new_min_dist;
        
-       vector shotdir = normalize(endpos - shotorg);
-       makevectors(shotdir);
+       vector shotdir = normalize(self.sw_endpos - self.sw_shotorg);
+       vectorvectors(shotdir);
        vector right = v_right;
        vector up = v_up;
        
-       for(counter = 0; counter < shots; ++counter)
-       {
-               deviation = '0 0 0';
-               makevectors('0 360 0' * (0.75 + (counter - 0.5) / shots));
-               deviation_y = v_forward_x;
-               deviation_z = v_forward_y;
-               deviation = deviation * spread;
-               print("v_forward = ", vtos(deviation), ".\n");
-               deviation = ((shotdir + (right * deviation_y) + (up * deviation_z)) * 1000);
-               
-               //deviation = W_CalculateSpread(shotdir, spread, 1, cvar("g_projectiles_spread_style"));
-               //print("deviation = ", vtos(deviation), ".\n");
-               
-               pointparticles(particleeffectnum("laser_shockwave_attack"), shotorg, deviation, 1);
-       }
+       float counter, dist_before_normal = 200, shots = 20;
+       
+       vector min_end = ((self.sw_shotorg + (shotdir * dist_before_normal)) + (up * self.sw_spread_min));
+       vector max_end = (self.sw_endpos + (up * self.sw_spread_max));
+       
+       float spread_to_min = vlen(normalize(min_end - self.sw_shotorg) - shotdir);
+       float spread_to_max = vlen(normalize(max_end - min_end) - shotdir);
        
        for(counter = 0; counter < shots; ++counter)
        {
-               //deviation = '0 0 0';
-               //makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
-               //deviation_y = v_forward_x;
-               //deviation_z = v_forward_y;
-               //deviation = deviation * spread;
-               //print("v_forward = ", vtos(deviation), ".\n");
-               //deviation = ((shotdir + (right * deviation_y) + (up * deviation_z)) * 1000);
-               
-               deviation = W_CalculateSpread(shotdir, spread, 1, cvar("g_projectiles_spread_style"));
-               //print("deviation = ", vtos(deviation), ".\n");
+               // perfect circle effect lines
+               angle = '0 0 0';
+               makevectors('0 360 0' * (0.75 + (counter - 0.5) / shots));
+               angle_y = v_forward_x;
+               angle_z = v_forward_y;
+
+               // first do the spread_to_min effect
+               deviation = angle * spread_to_min;
+               deviation = ((shotdir + (right * deviation_y) + (up * deviation_z)));
+               new_min_dist = dist_before_normal;
+               new_min_end = (self.sw_shotorg + (deviation * new_min_dist));
+               //te_lightning2(world, new_min_end, self.sw_shotorg);
+
+               // then calculate spread_to_max effect
+               deviation = angle * spread_to_max;
+               deviation = ((shotdir + (right * deviation_y) + (up * deviation_z)));
+               new_max_dist = vlen(new_min_end - self.sw_endpos);
+               new_max_end = (new_min_end + (deviation * new_max_dist));
+               //te_lightning2(world, new_end, prev_min_end);
                
-               pointparticles(particleeffectnum("laser_shockwave_attack"), shotorg, deviation * 1000, 1);
+
+               if(counter == 0)
+               {
+                       first_min_end = new_min_end;
+                       first_max_end = new_max_end;
+               }
+
+               if(counter >= 1)
+               {
+                       R_BeginPolygon("", DRAWFLAG_NORMAL);
+                       R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
+                       R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
+                       R_PolygonVertex(self.sw_shotorg, '0 0 0', sw_color, a);
+                       R_EndPolygon();
+
+                       R_BeginPolygon("", DRAWFLAG_NORMAL);
+                       R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
+                       R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
+                       R_PolygonVertex(prev_max_end, '0 0 0', sw_color, a);
+                       R_PolygonVertex(new_max_end, '0 0 0', sw_color, a);
+                       R_EndPolygon();
+               }
+
+               prev_min_end = new_min_end;
+               prev_max_end = new_max_end;
+
+               if((counter + 1) == shots)
+               {
+                       R_BeginPolygon("", DRAWFLAG_NORMAL);
+                       R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
+                       R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
+                       R_PolygonVertex(self.sw_shotorg, '0 0 0', sw_color, a);
+                       R_EndPolygon();
+
+                       R_BeginPolygon("", DRAWFLAG_NORMAL);
+                       R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
+                       R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
+                       R_PolygonVertex(prev_max_end, '0 0 0', sw_color, a);
+                       R_PolygonVertex(first_max_end, '0 0 0', sw_color, a);
+                       R_EndPolygon();
+               }
        }
+}
+
+void Net_ReadShockwaveParticle()
+{
+       entity shockwave;
+       shockwave = spawn();
+       shockwave.draw = Draw_Shockwave;
        
-       //print("definitely doing the effect.\n");
+       shockwave.sw_shotorg_x = ReadCoord(); shockwave.sw_shotorg_y = ReadCoord(); shockwave.sw_shotorg_z = ReadCoord();
+       shockwave.sw_endpos_x  = ReadCoord(); shockwave.sw_endpos_y  = ReadCoord(); shockwave.sw_endpos_z  = ReadCoord();
        
-       //WarpZone_TrailParticles(world, particleeffectnum("nex_beam"), shotorg, endpos);
+       shockwave.sw_spread_max = ReadByte();
+       shockwave.sw_spread_min = ReadByte();
+
+       shockwave.sv_entnum = ReadByte();
+
+       shockwave.sw_time = time;
 }