Con_Printf ("beam list overflow!\n");
}
+void R_BlastParticles(vec3_t org, vec_t radius, vec_t power);
void R_BloodShower (vec3_t mins, vec3_t maxs, float velspeed, int count);
void R_ParticleCube (vec3_t mins, vec3_t maxs, vec3_t dir, int count, int colorbase, int gravity, int randomvel);
void R_ParticleRain (vec3_t mins, vec3_t maxs, vec3_t dir, int count, int colorbase, int type);
pos[1] = MSG_ReadCoord ();
pos[2] = MSG_ReadCoord ();
R_ParticleExplosion (pos, false);
+ R_BlastParticles (pos, 120, 120);
dl = CL_AllocDlight (0);
VectorCopy (pos, dl->origin);
dl->radius = 350;
pos[1] = MSG_ReadCoord ();
pos[2] = MSG_ReadCoord ();
R_ParticleExplosion (pos, false);
+ R_BlastParticles (pos, 120, 480);
dl = CL_AllocDlight (0);
VectorCopy (pos, dl->origin);
dl->radius = 600;
pos[1] = MSG_ReadCoord ();
pos[2] = MSG_ReadCoord ();
R_ParticleExplosion (pos, false);
+ R_BlastParticles (pos, 120, 120);
dl = CL_AllocDlight (0);
VectorCopy (pos, dl->origin);
dl->radius = 350;
pos[1] = MSG_ReadCoord ();
pos[2] = MSG_ReadCoord ();
R_ParticleExplosion (pos, false);
+ R_BlastParticles (pos, 120, 120);
dl = CL_AllocDlight (0);
VectorCopy (pos, dl->origin);
dl->radius = 350;
pos[1] = MSG_ReadCoord ();
pos[2] = MSG_ReadCoord ();
R_BlobExplosion (pos);
+ R_BlastParticles (pos, 120, 120);
S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1);
dl = CL_AllocDlight (0);
break;
// PGM 01/21/97
-// LordHavoc: ONLY for compatibility with the Nehahra movie... hack hack hack
+// LordHavoc: for compatibility with the Nehahra movie...
case TE_LIGHTNING4NEH:
CL_ParseBeam (Mod_ForName(MSG_ReadString(), true));
break;
colorStart = MSG_ReadByte ();
colorLength = MSG_ReadByte ();
R_ParticleExplosion2 (pos, colorStart, colorLength);
+ R_BlastParticles (pos, 80, 80);
dl = CL_AllocDlight (0);
VectorCopy (pos, dl->origin);
dl->radius = 350;
vec3_t r_pright, r_pup, r_ppn;
+// LordHavoc: reduced duplicate code, and allow particle allocation system independence
+#define ALLOCPARTICLE \
+ if (!free_particles)\
+ return;\
+ p = free_particles;\
+ free_particles = p->next;\
+ p->next = active_particles;\
+ active_particles = p;
+
cvar_t r_particles = {"r_particles", "1"};
cvar_t r_dynamicparticles = {"r_dynamicparticles", "0", TRUE};
forward[1] = cp*sy;
forward[2] = -sp;
- if (!free_particles)
- return;
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = p->vel[0] = p->vel[1] = p->vel[2] = 0;
p->texnum = flareparticletexture;
p->scale = 2;
p->alpha = 255;
- p->die = cl.time + 0.01;
+ p->die = cl.time;
p->color = 0x6f;
p->type = pt_explode;
Con_Printf ("Not enough free particles\n");
break;
}
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
p->texnum = particletexture;
p->scale = 2;
p->die = 99999;
p->color = (-c)&15;
p->type = pt_static;
- VectorCopy (vec3_origin, p->vel);
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = p->vel[0] = p->vel[1] = p->vel[2] = 0;
VectorCopy (org, p->org);
}
Con_Printf ("%i points read\n", c);
}
+/*
+===============
+R_BlastParticles
+
+LordHavoc: blasts away particles in the area, used for explosions to disturb the smoke trail and such
+===============
+*/
+void R_BlastParticles(vec3_t org, vec_t radius, vec_t power)
+{
+ vec3_t v;
+ particle_t *p;
+ vec_t radius2 = radius * radius, speed, dist, scale = 2.5 * power / radius;
+ p = active_particles;
+ if (!p)
+ return;
+ while (p)
+ {
+ VectorSubtract(p->org, org, v);
+ dist = DotProduct(v,v);
+ if (dist < radius2)
+ {
+ speed = (radius - sqrt(dist)) * scale;
+ VectorNormalize(v);
+ VectorMA(p->pushvel, speed, v, p->pushvel);
+ }
+ p = p->next;
+ }
+}
+
/*
===============
R_ParseParticleEffect
for (i=0 ; i<1024 ; i++)
{
- if (!free_particles)
- return;
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = 0;
p->texnum = particletexture;
p->scale = lhrandom(1,3);
p->alpha = rand()&255;
p->type = pt_fallfadespark;
for (j=0 ; j<3 ; j++)
{
- p->org[j] = org[j] + ((rand()&15)-8);
+ p->org[j] = org[j] + lhrandom(-8,8);
p->vel[j] = lhrandom(-192, 192);
}
p->vel[2] += 160;
}
- if (smoke)
+ i = Mod_PointInLeaf(org, cl.worldmodel)->contents;
+ if (i == CONTENTS_SLIME || i == CONTENTS_WATER)
{
for (i=0 ; i<32 ; i++)
{
- if (!free_particles)
- return;
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
+
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = 0;
+ p->texnum = bubbleparticletexture;
+ p->scale = lhrandom(1,2);
+ p->alpha = 255;
+ p->color = (rand()&3)+12;
+ p->type = pt_bubble;
+ p->die = cl.time + 2;
+ for (j=0 ; j<3 ; j++)
+ {
+ p->org[j] = org[j] + lhrandom(-16,16);
+ p->vel[j] = lhrandom(-16,16);
+ }
+ }
+ }
+ else if (smoke)
+ {
+ for (i=0 ; i<32 ; i++)
+ {
+ ALLOCPARTICLE
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = 0;
p->texnum = smokeparticletexture[rand()&7];
p->scale = 12;
p->alpha = 80;
for (i=0; i<512; i++)
{
- if (!free_particles)
- return;
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = 0;
p->texnum = smokeparticletexture[rand()&7];
p->scale = 1.5;
p->alpha = 255;
for (i=0 ; i<1024 ; i++)
{
- if (!free_particles)
- return;
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = 0;
p->texnum = smokeparticletexture[rand()&7];
p->scale = 2;
p->alpha = 255;
}
while (count)
{
- if (!free_particles)
- return;
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
if (count & 7)
{
p->alpha = (count & 7) * 16 + (rand()&15);
count -= 8;
}
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = 0;
p->texnum = particletexture;
p->scale = 6;
p->die = cl.time + 1; //lhrandom(0.1, 0.5);
particle_t *p;
if (!r_particles.value) return; // LordHavoc: particles are optional
- if (!free_particles)
- return;
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = 0;
if (type == 0) // sparks
{
p->texnum = smokeparticletexture[rand()&7];
}
for (i=0 ; i<count ; i++)
{
- if (!free_particles)
- return;
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = 0;
p->texnum = flareparticletexture;
p->scale = 2;
p->alpha = 255;
for (i=0 ; i<count ; i++)
{
- if (!free_particles)
- return;
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = 0;
p->texnum = bloodcloudparticletexture;
p->scale = 12;
p->alpha = 96 + (rand()&63);
for (i=0 ; i<count ; i++)
{
- if (!free_particles)
- return;
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = 0;
p->texnum = flareparticletexture;
p->scale = 6;
p->alpha = 255;
for (i=0 ; i<count ; i++)
{
- if (!free_particles)
- return;
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
vel[0] = dir[0] + (rand()&31) - 16;
vel[1] = dir[1] + (rand()&31) - 16;
org[1] = diff[1] * (float) (rand()&1023) * (1.0 / 1024.0) + mins[1];
org[2] = z;
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = 0;
p->scale = 1.5;
p->alpha = 255;
p->die = t;
for (j=-16 ; j<16 ; j+=2)
for (k=0 ; k<1 ; k++)
{
- if (!free_particles)
- return;
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = 0;
p->texnum = flareparticletexture;
p->scale = 10;
p->alpha = 128;
for (j=-16 ; j<16 ; j+=4)
for (k=-24 ; k<32 ; k+=4)
{
- if (!free_particles)
- return;
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = 0;
p->contents = 0;
p->texnum = particletexture;
p->scale = 2;
for (j=-24 ; j<24 ; j+=8)
for (k=-24 ; k<32 ; k+=8)
{
- if (!free_particles)
- return;
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = 0;
p->texnum = flareparticletexture;
p->scale = 4;
p->alpha = lhrandom(32,256);
while (t < nt)
{
- if (!free_particles)
- return;
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
- p->vel[0] = p->vel[1] = p->vel[2] = 0;
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = p->vel[0] = p->vel[1] = p->vel[2] = 0;
p->die = cl.time + 2;
switch (type)
{
len -= 3;
- if (!free_particles)
- return;
- p = free_particles;
- free_particles = p->next;
- p->next = active_particles;
- active_particles = p;
+ ALLOCPARTICLE
- VectorCopy (vec3_origin, p->vel);
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = p->vel[0] = p->vel[1] = p->vel[2] = 0;
p->texnum = flareparticletexture;
p->scale = 8;
{
particle_t *p, *kill;
int i, r,g,b,a;
- float grav, grav1, time1, time2, time3, dvel, frametime, scale, scale2;
+ float grav, grav1, time1, time2, time3, dvel, frametime, scale, scale2, f1, f2;
byte *color24;
vec3_t up, right, uprightangles, forward2, up2, right2, v, tempcolor;
transpolyend();
}
- p->org[0] += p->vel[0]*frametime;
- p->org[1] += p->vel[1]*frametime;
- p->org[2] += p->vel[2]*frametime;
+ if (p->pushvel[0] || p->pushvel[1] || p->pushvel[2])
+ {
+ p->org[0] += (p->vel[0]+p->pushvel[0])*frametime;
+ p->org[1] += (p->vel[1]+p->pushvel[1])*frametime;
+ p->org[2] += (p->vel[2]+p->pushvel[2])*frametime;
+ f1 = sqrt(DotProduct(p->pushvel,p->pushvel));
+ f2 = f1 - frametime * 32;
+ if (f2 <= 0)
+ p->pushvel[0] = p->pushvel[1] = p->pushvel[2] = 0;
+ else
+ {
+ f2 /= f1;
+ p->pushvel[0] *= f2;
+ p->pushvel[1] *= f2;
+ p->pushvel[2] *= f2;
+ }
+ }
+ else
+ {
+ p->org[0] += p->vel[0]*frametime;
+ p->org[1] += p->vel[1]*frametime;
+ p->org[2] += p->vel[2]*frametime;
+ }
switch (p->type)
{
// LordHavoc: for smoke trails
case pt_smoke:
p->scale += frametime * 4;
- p->alpha -= frametime * 48;
+ p->alpha -= frametime * 128;
// p->vel[2] += grav;
if (p->alpha < 1)
p->die = -1;