diff options
Diffstat (limited to 'src/cl_newfx.c')
-rw-r--r-- | src/cl_newfx.c | 682 |
1 files changed, 314 insertions, 368 deletions
diff --git a/src/cl_newfx.c b/src/cl_newfx.c index 6b1974c..5397366 100644 --- a/src/cl_newfx.c +++ b/src/cl_newfx.c @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -28,22 +28,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. vectoangles2 - this is duplicated in the game DLL, but I need it heref. ====== */ -static void vectoangles2 (vec3_t value1, vec3_t angles) +static void vectoangles2(vec3_t value1, vec3_t angles) { float forward; float yaw, pitch; - - if (value1[1] == 0 && value1[0] == 0) - { + + if (value1[1] == 0 && value1[0] == 0) { yaw = 0; if (value1[2] > 0) pitch = 90; else pitch = 270; - } - else - { - // PMM - fixed to correct for pitch of 0 + } else { + // PMM - fixed to correct for pitch of 0 if (value1[0]) yaw = (atan2(value1[1], value1[0]) * 180 / M_PI); else if (value1[1] > 0) @@ -54,7 +51,7 @@ static void vectoangles2 (vec3_t value1, vec3_t angles) if (yaw < 0) yaw += 360; - forward = sqrt (value1[0]*value1[0] + value1[1]*value1[1]); + forward = sqrt(value1[0] * value1[0] + value1[1] * value1[1]); pitch = (atan2(value1[2], forward) * 180 / M_PI); if (pitch < 0) pitch += 360; @@ -68,12 +65,12 @@ static void vectoangles2 (vec3_t value1, vec3_t angles) //============= //============= #if USE_DLIGHTS -void CL_Flashlight (int ent, vec3_t pos) +void CL_Flashlight(int ent, vec3_t pos) { cdlight_t *dl; - dl = CL_AllocDlight (ent); - VectorCopy (pos, dl->origin); + dl = CL_AllocDlight(ent); + VectorCopy(pos, dl->origin); dl->radius = 400; //dl->minlight = 250; dl->die = cl.time + 100; @@ -87,12 +84,12 @@ void CL_Flashlight (int ent, vec3_t pos) CL_ColorFlash - flash of light ====== */ -void CL_ColorFlash (vec3_t pos, int ent, int intensity, float r, float g, float b) +void CL_ColorFlash(vec3_t pos, int ent, int intensity, float r, float g, float b) { cdlight_t *dl; - dl = CL_AllocDlight (ent); - VectorCopy (pos, dl->origin); + dl = CL_AllocDlight(ent); + VectorCopy(pos, dl->origin); dl->radius = intensity; //dl->minlight = 250; dl->die = cl.time + 100; @@ -108,7 +105,7 @@ void CL_ColorFlash (vec3_t pos, int ent, int intensity, float r, float g, float CL_DebugTrail ====== */ -void CL_DebugTrail (vec3_t start, vec3_t end) +void CL_DebugTrail(vec3_t start, vec3_t end) { vec3_t move; vec3_t vec; @@ -121,22 +118,21 @@ void CL_DebugTrail (vec3_t start, vec3_t end) // float d, c, s; // vec3_t dir; - VectorCopy (start, move); - VectorSubtract (end, start, vec); - len = VectorNormalize (vec); + VectorCopy(start, move); + VectorSubtract(end, start, vec); + len = VectorNormalize(vec); - MakeNormalVectors (vec, right, up); + MakeNormalVectors(vec, right, up); // VectorScale(vec, RT2_SKIP, vec); // dec = 1.0; // dec = 0.75; dec = 3; - VectorScale (vec, dec, vec); - VectorCopy (start, move); + VectorScale(vec, dec, vec); + VectorCopy(start, move); - while (len > 0) - { + while (len > 0) { len -= dec; p = CL_AllocParticle(); @@ -144,22 +140,22 @@ void CL_DebugTrail (vec3_t start, vec3_t end) return; p->time = cl.time; - VectorClear (p->accel); - VectorClear (p->vel); + VectorClear(p->accel); + VectorClear(p->vel); p->alpha = 1.0; p->alphavel = -0.1; // p->alphavel = 0; - p->color = 0x74 + (rand()&7); - VectorCopy (move, p->org); -/* - for (j=0 ; j<3 ; j++) - { - p->org[j] = move[j] + crand()*2; - p->vel[j] = crand()*3; - p->accel[j] = 0; - } -*/ - VectorAdd (move, vec, move); + p->color = 0x74 + (rand() & 7); + VectorCopy(move, p->org); + /* + for (j=0; j<3; j++) + { + p->org[j] = move[j] + crand()*2; + p->vel[j] = crand()*3; + p->accel[j] = 0; + } + */ + VectorAdd(move, vec, move); } } @@ -169,7 +165,7 @@ void CL_DebugTrail (vec3_t start, vec3_t end) CL_SmokeTrail =============== */ -void CL_SmokeTrail (vec3_t start, vec3_t end, int colorStart, int colorRun, int spacing) +void CL_SmokeTrail(vec3_t start, vec3_t end, int colorStart, int colorRun, int spacing) { vec3_t move; vec3_t vec; @@ -177,39 +173,37 @@ void CL_SmokeTrail (vec3_t start, vec3_t end, int colorStart, int colorRun, int int j; cparticle_t *p; - VectorCopy (start, move); - VectorSubtract (end, start, vec); - len = VectorNormalize (vec); + VectorCopy(start, move); + VectorSubtract(end, start, vec); + len = VectorNormalize(vec); - VectorScale (vec, spacing, vec); + VectorScale(vec, spacing, vec); // FIXME: this is a really silly way to have a loop - while (len > 0) - { + while (len > 0) { len -= spacing; p = CL_AllocParticle(); if (!p) return; - VectorClear (p->accel); - + VectorClear(p->accel); + p->time = cl.time; p->alpha = 1.0; - p->alphavel = -1.0 / (1+frand()*0.5); + p->alphavel = -1.0 / (1 + frand() * 0.5); p->color = colorStart + (rand() % colorRun); - for (j=0 ; j<3 ; j++) - { - p->org[j] = move[j] + crand()*3; + for (j = 0; j < 3; j++) { + p->org[j] = move[j] + crand() * 3; p->accel[j] = 0; } - p->vel[2] = 20 + crand()*5; + p->vel[2] = 20 + crand() * 5; - VectorAdd (move, vec, move); + VectorAdd(move, vec, move); } } -void CL_ForceWall (vec3_t start, vec3_t end, int color) +void CL_ForceWall(vec3_t start, vec3_t end, int color) { vec3_t move; vec3_t vec; @@ -217,40 +211,37 @@ void CL_ForceWall (vec3_t start, vec3_t end, int color) int j; cparticle_t *p; - VectorCopy (start, move); - VectorSubtract (end, start, vec); - len = VectorNormalize (vec); + VectorCopy(start, move); + VectorSubtract(end, start, vec); + len = VectorNormalize(vec); - VectorScale (vec, 4, vec); + VectorScale(vec, 4, vec); // FIXME: this is a really silly way to have a loop - while (len > 0) - { + while (len > 0) { len -= 4; - if (frand() > 0.3) - { + if (frand() > 0.3) { p = CL_AllocParticle(); if (!p) return; - VectorClear (p->accel); - + VectorClear(p->accel); + p->time = cl.time; p->alpha = 1.0; - p->alphavel = -1.0 / (3.0+frand()*0.5); + p->alphavel = -1.0 / (3.0 + frand() * 0.5); p->color = color; - for (j=0 ; j<3 ; j++) - { - p->org[j] = move[j] + crand()*3; + for (j = 0; j < 3; j++) { + p->org[j] = move[j] + crand() * 3; p->accel[j] = 0; } p->vel[0] = 0; p->vel[1] = 0; - p->vel[2] = -40 - (crand()*10); + p->vel[2] = -40 - (crand() * 10); } - VectorAdd (move, vec, move); + VectorAdd(move, vec, move); } } @@ -260,14 +251,13 @@ void CL_ForceWall (vec3_t start, vec3_t end, int color) CL_GenericParticleEffect =============== */ -void CL_GenericParticleEffect (vec3_t org, vec3_t dir, int color, int count, int numcolors, int dirspread, float alphavel) +void CL_GenericParticleEffect(vec3_t org, vec3_t dir, int color, int count, int numcolors, int dirspread, float alphavel) { int i, j; cparticle_t *p; float d; - for (i=0 ; i<count ; i++) - { + for (i = 0; i < count; i++) { p = CL_AllocParticle(); if (!p) return; @@ -279,10 +269,9 @@ void CL_GenericParticleEffect (vec3_t org, vec3_t dir, int color, int count, int p->color = color; d = rand() & dirspread; - for (j=0 ; j<3 ; j++) - { - p->org[j] = org[j] + ((rand()&7)-4) + d*dir[j]; - p->vel[j] = crand()*20; + for (j = 0; j < 3; j++) { + p->org[j] = org[j] + ((rand() & 7) - 4) + d * dir[j]; + p->vel[j] = crand() * 20; } p->accel[0] = p->accel[1] = 0; @@ -290,7 +279,7 @@ void CL_GenericParticleEffect (vec3_t org, vec3_t dir, int color, int count, int // VectorCopy (accel, p->accel); p->alpha = 1.0; - p->alphavel = -1.0 / (0.5 + frand()*alphavel); + p->alphavel = -1.0 / (0.5 + frand() * alphavel); // p->alphavel = alphavel; } } @@ -301,7 +290,7 @@ CL_BubbleTrail2 (lets you control the # of bubbles by setting the distance betwe =============== */ -void CL_BubbleTrail2 (vec3_t start, vec3_t end, int dist) +void CL_BubbleTrail2(vec3_t start, vec3_t end, int dist) { vec3_t move; vec3_t vec; @@ -310,39 +299,37 @@ void CL_BubbleTrail2 (vec3_t start, vec3_t end, int dist) cparticle_t *p; float dec; - VectorCopy (start, move); - VectorSubtract (end, start, vec); - len = VectorNormalize (vec); + VectorCopy(start, move); + VectorSubtract(end, start, vec); + len = VectorNormalize(vec); dec = dist; - VectorScale (vec, dec, vec); + VectorScale(vec, dec, vec); - for (i=0 ; i<len ; i+=dec) - { + for (i = 0; i < len; i += dec) { p = CL_AllocParticle(); if (!p) return; - VectorClear (p->accel); + VectorClear(p->accel); p->time = cl.time; p->alpha = 1.0; - p->alphavel = -1.0 / (1+frand()*0.1); - p->color = 4 + (rand()&7); - for (j=0 ; j<3 ; j++) - { - p->org[j] = move[j] + crand()*2; - p->vel[j] = crand()*10; + p->alphavel = -1.0 / (1 + frand() * 0.1); + p->color = 4 + (rand() & 7); + for (j = 0; j < 3; j++) { + p->org[j] = move[j] + crand() * 2; + p->vel[j] = crand() * 10; } p->org[2] -= 4; // p->vel[2] += 6; p->vel[2] += 20; - VectorAdd (move, vec, move); + VectorAdd(move, vec, move); } } -void CL_Heatbeam (vec3_t start, vec3_t forward) +void CL_Heatbeam(vec3_t start, vec3_t forward) { vec3_t move; vec3_t vec; @@ -360,79 +347,74 @@ void CL_Heatbeam (vec3_t start, vec3_t forward) float variance; vec3_t end; - VectorMA (start, 4096, forward, end); + VectorMA(start, 4096, forward, end); - VectorCopy (start, move); - VectorSubtract (end, start, vec); - len = VectorNormalize (vec); + VectorCopy(start, move); + VectorSubtract(end, start, vec); + len = VectorNormalize(vec); // FIXME - pmm - these might end up using old values? // MakeNormalVectors (vec, right, up); - VectorCopy (cl.v_right, right); - VectorCopy (cl.v_up, up); + VectorCopy(cl.v_right, right); + VectorCopy(cl.v_up, up); #if USE_REF == REF_GL - { // GL mode - VectorMA (move, -0.5, right, move); - VectorMA (move, -0.5, up, move); + { + // GL mode + VectorMA(move, -0.5, right, move); + VectorMA(move, -0.5, up, move); } #endif // otherwise assume SOFT - ltime = (float) cl.time/1000.0; - start_pt = fmod(ltime*96.0,step); - VectorMA (move, start_pt, vec, move); + ltime = (float) cl.time / 1000.0; + start_pt = fmod(ltime * 96.0, step); + VectorMA(move, start_pt, vec, move); - VectorScale (vec, step, vec); + VectorScale(vec, step, vec); // Com_Printf ("%f\n", ltime); - rstep = M_PI/10.0; - for (i=start_pt ; i<len ; i+=step) - { - if (i>step*5) // don't bother after the 5th ring + rstep = M_PI / 10.0; + for (i = start_pt; i < len; i += step) { + if (i > step * 5) // don't bother after the 5th ring break; - for (rot = 0; rot < M_PI*2; rot += rstep) - { + for (rot = 0; rot < M_PI * 2; rot += rstep) { p = CL_AllocParticle(); if (!p) return; - + p->time = cl.time; - VectorClear (p->accel); + VectorClear(p->accel); // rot+= fmod(ltime, 12.0)*M_PI; // c = cos(rot)/2.0; // s = sin(rot)/2.0; // variance = 0.4 + ((float)rand()/(float)RAND_MAX) *0.2; variance = 0.5; - c = cos(rot)*variance; - s = sin(rot)*variance; - + c = cos(rot) * variance; + s = sin(rot) * variance; + // trim it so it looks like it's starting at the origin - if (i < 10) - { - VectorScale (right, c*(i/10.0), dir); - VectorMA (dir, s*(i/10.0), up, dir); + if (i < 10) { + VectorScale(right, c * (i / 10.0), dir); + VectorMA(dir, s * (i / 10.0), up, dir); + } else { + VectorScale(right, c, dir); + VectorMA(dir, s, up, dir); } - else - { - VectorScale (right, c, dir); - VectorMA (dir, s, up, dir); - } - + p->alpha = 0.5; - // p->alphavel = -1.0 / (1+frand()*0.2); + // p->alphavel = -1.0 / (1+frand()*0.2); p->alphavel = -1000.0; - // p->color = 0x74 + (rand()&7); - p->color = 223 - (rand()&7); - for (j=0 ; j<3 ; j++) - { - p->org[j] = move[j] + dir[j]*3; - // p->vel[j] = dir[j]*6; + // p->color = 0x74 + (rand()&7); + p->color = 223 - (rand() & 7); + for (j = 0; j < 3; j++) { + p->org[j] = move[j] + dir[j] * 3; + // p->vel[j] = dir[j]*6; p->vel[j] = 0; } } - VectorAdd (move, vec, move); + VectorAdd(move, vec, move); } } @@ -444,7 +426,7 @@ CL_ParticleSteamEffect Puffs with velocity along direction, with some randomness thrown in =============== */ -void CL_ParticleSteamEffect (vec3_t org, vec3_t dir, int color, int count, int magnitude) +void CL_ParticleSteamEffect(vec3_t org, vec3_t dir, int color, int count, int magnitude) { int i, j; cparticle_t *p; @@ -454,37 +436,35 @@ void CL_ParticleSteamEffect (vec3_t org, vec3_t dir, int color, int count, int m // vectoangles2 (dir, angle_dir); // AngleVectors (angle_dir, f, r, u); - MakeNormalVectors (dir, r, u); + MakeNormalVectors(dir, r, u); - for (i=0 ; i<count ; i++) - { + for (i = 0; i < count; i++) { p = CL_AllocParticle(); if (!p) return; p->time = cl.time; - p->color = color + (rand()&7); + p->color = color + (rand() & 7); - for (j=0 ; j<3 ; j++) - { - p->org[j] = org[j] + magnitude*0.1*crand(); + for (j = 0; j < 3; j++) { + p->org[j] = org[j] + magnitude * 0.1 * crand(); // p->vel[j] = dir[j]*magnitude; } - VectorScale (dir, magnitude, p->vel); - d = crand()*magnitude/3; - VectorMA (p->vel, d, r, p->vel); - d = crand()*magnitude/3; - VectorMA (p->vel, d, u, p->vel); + VectorScale(dir, magnitude, p->vel); + d = crand() * magnitude / 3; + VectorMA(p->vel, d, r, p->vel); + d = crand() * magnitude / 3; + VectorMA(p->vel, d, u, p->vel); p->accel[0] = p->accel[1] = 0; - p->accel[2] = -PARTICLE_GRAVITY/2; + p->accel[2] = -PARTICLE_GRAVITY / 2; p->alpha = 1.0; - p->alphavel = -1.0 / (0.5 + frand()*0.3); + p->alphavel = -1.0 / (0.5 + frand() * 0.3); } } -void CL_ParticleSteamEffect2 (cl_sustain_t *self) +void CL_ParticleSteamEffect2(cl_sustain_t *self) //vec3_t org, vec3_t dir, int color, int count, int magnitude) { int i, j; @@ -496,34 +476,32 @@ void CL_ParticleSteamEffect2 (cl_sustain_t *self) // vectoangles2 (dir, angle_dir); // AngleVectors (angle_dir, f, r, u); - VectorCopy (self->dir, dir); - MakeNormalVectors (dir, r, u); + VectorCopy(self->dir, dir); + MakeNormalVectors(dir, r, u); - for (i=0 ; i<self->count ; i++) - { + for (i = 0; i < self->count; i++) { p = CL_AllocParticle(); if (!p) return; p->time = cl.time; - p->color = self->color + (rand()&7); + p->color = self->color + (rand() & 7); - for (j=0 ; j<3 ; j++) - { - p->org[j] = self->org[j] + self->magnitude*0.1*crand(); + for (j = 0; j < 3; j++) { + p->org[j] = self->org[j] + self->magnitude * 0.1 * crand(); // p->vel[j] = dir[j]*magnitude; } - VectorScale (dir, self->magnitude, p->vel); - d = crand()*self->magnitude/3; - VectorMA (p->vel, d, r, p->vel); - d = crand()*self->magnitude/3; - VectorMA (p->vel, d, u, p->vel); + VectorScale(dir, self->magnitude, p->vel); + d = crand() * self->magnitude / 3; + VectorMA(p->vel, d, r, p->vel); + d = crand() * self->magnitude / 3; + VectorMA(p->vel, d, u, p->vel); p->accel[0] = p->accel[1] = 0; - p->accel[2] = -PARTICLE_GRAVITY/2; + p->accel[2] = -PARTICLE_GRAVITY / 2; p->alpha = 1.0; - p->alphavel = -1.0 / (0.5 + frand()*0.3); + p->alphavel = -1.0 / (0.5 + frand() * 0.3); } self->nextthink += self->thinkinterval; } @@ -533,38 +511,37 @@ void CL_ParticleSteamEffect2 (cl_sustain_t *self) CL_TrackerTrail =============== */ -void CL_TrackerTrail (vec3_t start, vec3_t end, int particleColor) +void CL_TrackerTrail(vec3_t start, vec3_t end, int particleColor) { vec3_t move; vec3_t vec; - vec3_t forward,right,up,angle_dir; + vec3_t forward, right, up, angle_dir; float len; int j; cparticle_t *p; int dec; float dist; - VectorCopy (start, move); - VectorSubtract (end, start, vec); - len = VectorNormalize (vec); + VectorCopy(start, move); + VectorSubtract(end, start, vec); + len = VectorNormalize(vec); VectorCopy(vec, forward); - vectoangles2 (forward, angle_dir); - AngleVectors (angle_dir, forward, right, up); + vectoangles2(forward, angle_dir); + AngleVectors(angle_dir, forward, right, up); dec = 3; - VectorScale (vec, 3, vec); + VectorScale(vec, 3, vec); // FIXME: this is a really silly way to have a loop - while (len > 0) - { + while (len > 0) { len -= dec; p = CL_AllocParticle(); if (!p) return; - VectorClear (p->accel); - + VectorClear(p->accel); + p->time = cl.time; p->alpha = 1.0; @@ -572,15 +549,14 @@ void CL_TrackerTrail (vec3_t start, vec3_t end, int particleColor) p->color = particleColor; dist = DotProduct(move, forward); VectorMA(move, 8 * cos(dist), up, p->org); - for (j=0 ; j<3 ; j++) - { + for (j = 0; j < 3; j++) { // p->org[j] = move[j] + crand(); p->vel[j] = 0; p->accel[j] = 0; } p->vel[2] = 5; - VectorAdd (move, vec, move); + VectorAdd(move, vec, move); } } @@ -590,13 +566,12 @@ void CL_Tracker_Shell(vec3_t origin) int i; cparticle_t *p; - for(i=0;i<300;i++) - { + for (i = 0; i < 300; i++) { p = CL_AllocParticle(); if (!p) return; - VectorClear (p->accel); - + VectorClear(p->accel); + p->time = cl.time; p->alpha = 1.0; @@ -607,7 +582,7 @@ void CL_Tracker_Shell(vec3_t origin) dir[1] = crand(); dir[2] = crand(); VectorNormalize(dir); - + VectorMA(origin, 40, dir, p->org); } } @@ -618,13 +593,12 @@ void CL_MonsterPlasma_Shell(vec3_t origin) int i; cparticle_t *p; - for(i=0;i<40;i++) - { + for (i = 0; i < 40; i++) { p = CL_AllocParticle(); if (!p) return; - VectorClear (p->accel); - + VectorClear(p->accel); + p->time = cl.time; p->alpha = 1.0; @@ -635,46 +609,45 @@ void CL_MonsterPlasma_Shell(vec3_t origin) dir[1] = crand(); dir[2] = crand(); VectorNormalize(dir); - + VectorMA(origin, 10, dir, p->org); // VectorMA(origin, 10*(((rand () & 0x7fff) / ((float)0x7fff))), dir, p->org); } } -void CL_Widowbeamout (cl_sustain_t *self) +void CL_Widowbeamout(cl_sustain_t *self) { vec3_t dir; int i; cparticle_t *p; - static int colortable[4] = {2*8,13*8,21*8,18*8}; + static int colortable[4] = {2 * 8, 13 * 8, 21 * 8, 18 * 8}; float ratio; - ratio = 1.0 - (((float)self->endtime - (float)cl.time)/2100.0); + ratio = 1.0 - (((float)self->endtime - (float)cl.time) / 2100.0); - for(i=0;i<300;i++) - { + for (i = 0; i < 300; i++) { p = CL_AllocParticle(); if (!p) return; - VectorClear (p->accel); - + VectorClear(p->accel); + p->time = cl.time; p->alpha = 1.0; p->alphavel = INSTANT_PARTICLE; - p->color = colortable[rand()&3]; + p->color = colortable[rand() & 3]; dir[0] = crand(); dir[1] = crand(); dir[2] = crand(); VectorNormalize(dir); - + VectorMA(self->org, (45.0 * ratio), dir, p->org); // VectorMA(origin, 10*(((rand () & 0x7fff) / ((float)0x7fff))), dir, p->org); } } -void CL_Nukeblast (cl_sustain_t *self) +void CL_Nukeblast(cl_sustain_t *self) { vec3_t dir; int i; @@ -682,46 +655,44 @@ void CL_Nukeblast (cl_sustain_t *self) static int colortable[4] = {110, 112, 114, 116}; float ratio; - ratio = 1.0 - (((float)self->endtime - (float)cl.time)/1000.0); + ratio = 1.0 - (((float)self->endtime - (float)cl.time) / 1000.0); - for(i=0;i<700;i++) - { + for (i = 0; i < 700; i++) { p = CL_AllocParticle(); if (!p) return; - VectorClear (p->accel); - + VectorClear(p->accel); + p->time = cl.time; p->alpha = 1.0; p->alphavel = INSTANT_PARTICLE; - p->color = colortable[rand()&3]; + p->color = colortable[rand() & 3]; dir[0] = crand(); dir[1] = crand(); dir[2] = crand(); VectorNormalize(dir); - + VectorMA(self->org, (200.0 * ratio), dir, p->org); // VectorMA(origin, 10*(((rand () & 0x7fff) / ((float)0x7fff))), dir, p->org); } } -void CL_WidowSplash (void) +void CL_WidowSplash(void) { - static int colortable[4] = {2*8,13*8,21*8,18*8}; + static int colortable[4] = {2 * 8, 13 * 8, 21 * 8, 18 * 8}; int i; cparticle_t *p; vec3_t dir; - for (i=0 ; i<256 ; i++) - { + for (i = 0; i < 256; i++) { p = CL_AllocParticle(); if (!p) return; p->time = cl.time; - p->color = colortable[rand()&3]; + p->color = colortable[rand() & 3]; dir[0] = crand(); dir[1] = crand(); @@ -733,7 +704,7 @@ void CL_WidowSplash (void) p->accel[0] = p->accel[1] = 0; p->alpha = 1.0; - p->alphavel = -0.8 / (0.5 + frand()*0.3); + p->alphavel = -0.8 / (0.5 + frand() * 0.3); } } @@ -744,13 +715,12 @@ void CL_Tracker_Explode(vec3_t origin) int i; cparticle_t *p; - for(i=0;i<300;i++) - { + for (i = 0; i < 300; i++) { p = CL_AllocParticle(); if (!p) return; - VectorClear (p->accel); - + VectorClear(p->accel); + p->time = cl.time; p->alpha = 1.0; @@ -762,11 +732,11 @@ void CL_Tracker_Explode(vec3_t origin) dir[2] = crand(); VectorNormalize(dir); VectorScale(dir, -1, backdir); - + VectorMA(origin, 64, dir, p->org); VectorScale(backdir, 64, p->vel); } - + } /* @@ -775,7 +745,7 @@ CL_TagTrail =============== */ -void CL_TagTrail (vec3_t start, vec3_t end, int color) +void CL_TagTrail(vec3_t start, vec3_t end, int color) { vec3_t move; vec3_t vec; @@ -784,35 +754,33 @@ void CL_TagTrail (vec3_t start, vec3_t end, int color) cparticle_t *p; int dec; - VectorCopy (start, move); - VectorSubtract (end, start, vec); - len = VectorNormalize (vec); + VectorCopy(start, move); + VectorSubtract(end, start, vec); + len = VectorNormalize(vec); dec = 5; - VectorScale (vec, 5, vec); + VectorScale(vec, 5, vec); - while (len >= 0) - { + while (len >= 0) { len -= dec; p = CL_AllocParticle(); if (!p) return; - VectorClear (p->accel); - + VectorClear(p->accel); + p->time = cl.time; p->alpha = 1.0; - p->alphavel = -1.0 / (0.8+frand()*0.2); + p->alphavel = -1.0 / (0.8 + frand() * 0.2); p->color = color; - for (j=0 ; j<3 ; j++) - { - p->org[j] = move[j] + crand()*16; - p->vel[j] = crand()*5; + for (j = 0; j < 3; j++) { + p->org[j] = move[j] + crand() * 16; + p->vel[j] = crand() * 5; p->accel[j] = 0; } - VectorAdd (move, vec, move); + VectorAdd(move, vec, move); } } @@ -821,13 +789,12 @@ void CL_TagTrail (vec3_t start, vec3_t end, int color) CL_ColorExplosionParticles =============== */ -void CL_ColorExplosionParticles (vec3_t org, int color, int run) +void CL_ColorExplosionParticles(vec3_t org, int color, int run) { int i, j; cparticle_t *p; - for (i=0 ; i<128 ; i++) - { + for (i = 0; i < 128; i++) { p = CL_AllocParticle(); if (!p) return; @@ -835,17 +802,16 @@ void CL_ColorExplosionParticles (vec3_t org, int color, int run) p->time = cl.time; p->color = color + (rand() % run); - for (j=0 ; j<3 ; j++) - { - p->org[j] = org[j] + ((rand()%32)-16); - p->vel[j] = (rand()%256)-128; + for (j = 0; j < 3; j++) { + p->org[j] = org[j] + ((rand() % 32) - 16); + p->vel[j] = (rand() % 256) - 128; } p->accel[0] = p->accel[1] = 0; p->accel[2] = -PARTICLE_GRAVITY; p->alpha = 1.0; - p->alphavel = -0.4 / (0.6 + frand()*0.2); + p->alphavel = -0.4 / (0.6 + frand() * 0.2); } } @@ -854,39 +820,37 @@ void CL_ColorExplosionParticles (vec3_t org, int color, int run) CL_ParticleSmokeEffect - like the steam effect, but unaffected by gravity =============== */ -void CL_ParticleSmokeEffect (vec3_t org, vec3_t dir, int color, int count, int magnitude) +void CL_ParticleSmokeEffect(vec3_t org, vec3_t dir, int color, int count, int magnitude) { int i, j; cparticle_t *p; float d; vec3_t r, u; - MakeNormalVectors (dir, r, u); + MakeNormalVectors(dir, r, u); - for (i=0 ; i<count ; i++) - { + for (i = 0; i < count; i++) { p = CL_AllocParticle(); if (!p) return; p->time = cl.time; - p->color = color + (rand()&7); + p->color = color + (rand() & 7); - for (j=0 ; j<3 ; j++) - { - p->org[j] = org[j] + magnitude*0.1*crand(); + for (j = 0; j < 3; j++) { + p->org[j] = org[j] + magnitude * 0.1 * crand(); // p->vel[j] = dir[j]*magnitude; } - VectorScale (dir, magnitude, p->vel); - d = crand()*magnitude/3; - VectorMA (p->vel, d, r, p->vel); - d = crand()*magnitude/3; - VectorMA (p->vel, d, u, p->vel); + VectorScale(dir, magnitude, p->vel); + d = crand() * magnitude / 3; + VectorMA(p->vel, d, r, p->vel); + d = crand() * magnitude / 3; + VectorMA(p->vel, d, u, p->vel); p->accel[0] = p->accel[1] = p->accel[2] = 0; p->alpha = 1.0; - p->alphavel = -1.0 / (0.5 + frand()*0.3); + p->alphavel = -1.0 / (0.5 + frand() * 0.3); } } @@ -897,7 +861,7 @@ CL_BlasterParticles2 Wall impact puffs (Green) =============== */ -void CL_BlasterParticles2 (vec3_t org, vec3_t dir, unsigned int color) +void CL_BlasterParticles2(vec3_t org, vec3_t dir, unsigned int color) { int i, j; cparticle_t *p; @@ -905,27 +869,25 @@ void CL_BlasterParticles2 (vec3_t org, vec3_t dir, unsigned int color) int count; count = 40; - for (i=0 ; i<count ; i++) - { + for (i = 0; i < count; i++) { p = CL_AllocParticle(); if (!p) return; p->time = cl.time; - p->color = color + (rand()&7); + p->color = color + (rand() & 7); - d = rand()&15; - for (j=0 ; j<3 ; j++) - { - p->org[j] = org[j] + ((rand()&7)-4) + d*dir[j]; - p->vel[j] = dir[j] * 30 + crand()*40; + d = rand() & 15; + for (j = 0; j < 3; j++) { + p->org[j] = org[j] + ((rand() & 7) - 4) + d * dir[j]; + p->vel[j] = dir[j] * 30 + crand() * 40; } p->accel[0] = p->accel[1] = 0; p->accel[2] = -PARTICLE_GRAVITY; p->alpha = 1.0; - p->alphavel = -1.0 / (0.5 + frand()*0.3); + p->alphavel = -1.0 / (0.5 + frand() * 0.3); } } @@ -936,7 +898,7 @@ CL_BlasterTrail2 Green! =============== */ -void CL_BlasterTrail2 (vec3_t start, vec3_t end) +void CL_BlasterTrail2(vec3_t start, vec3_t end) { vec3_t move; vec3_t vec; @@ -945,36 +907,34 @@ void CL_BlasterTrail2 (vec3_t start, vec3_t end) cparticle_t *p; int dec; - VectorCopy (start, move); - VectorSubtract (end, start, vec); - len = VectorNormalize (vec); + VectorCopy(start, move); + VectorSubtract(end, start, vec); + len = VectorNormalize(vec); dec = 5; - VectorScale (vec, 5, vec); + VectorScale(vec, 5, vec); // FIXME: this is a really silly way to have a loop - while (len > 0) - { + while (len > 0) { len -= dec; p = CL_AllocParticle(); if (!p) return; - VectorClear (p->accel); - + VectorClear(p->accel); + p->time = cl.time; p->alpha = 1.0; - p->alphavel = -1.0 / (0.3+frand()*0.2); + p->alphavel = -1.0 / (0.3 + frand() * 0.2); p->color = 0xd0; - for (j=0 ; j<3 ; j++) - { + for (j = 0; j < 3; j++) { p->org[j] = move[j] + crand(); - p->vel[j] = crand()*5; + p->vel[j] = crand() * 5; p->accel[j] = 0; } - VectorAdd (move, vec, move); + VectorAdd(move, vec, move); } } @@ -984,7 +944,7 @@ void CL_BlasterTrail2 (vec3_t start, vec3_t end) CL_IonripperTrail =============== */ -void CL_IonripperTrail (vec3_t start, vec3_t ent) +void CL_IonripperTrail(vec3_t start, vec3_t ent) { vec3_t move; vec3_t vec; @@ -994,39 +954,34 @@ void CL_IonripperTrail (vec3_t start, vec3_t ent) int dec; int left = 0; - VectorCopy (start, move); - VectorSubtract (ent, start, vec); - len = VectorNormalize (vec); + VectorCopy(start, move); + VectorSubtract(ent, start, vec); + len = VectorNormalize(vec); dec = 5; - VectorScale (vec, 5, vec); + VectorScale(vec, 5, vec); - while (len > 0) - { + while (len > 0) { len -= dec; p = CL_AllocParticle(); if (!p) return; - VectorClear (p->accel); + VectorClear(p->accel); p->time = cl.time; p->alpha = 0.5; p->alphavel = -1.0 / (0.3 + frand() * 0.2); - p->color = 0xe4 + (rand()&3); + p->color = 0xe4 + (rand() & 3); - for (j=0; j<3; j++) - { + for (j = 0; j < 3; j++) { p->org[j] = move[j]; p->accel[j] = 0; } - if (left) - { + if (left) { left = 0; p->vel[0] = 10; - } - else - { + } else { left = 1; p->vel[0] = -10; } @@ -1034,7 +989,7 @@ void CL_IonripperTrail (vec3_t start, vec3_t ent) p->vel[1] = 0; p->vel[2] = 0; - VectorAdd (move, vec, move); + VectorAdd(move, vec, move); } } @@ -1044,7 +999,7 @@ CL_TrapParticles =============== */ // RAFAEL -void CL_TrapParticles (entity_t *ent) +void CL_TrapParticles(entity_t *ent) { vec3_t move; vec3_t vec; @@ -1054,87 +1009,80 @@ void CL_TrapParticles (entity_t *ent) cparticle_t *p; int dec; - ent->origin[2]-=14; - VectorCopy (ent->origin, start); - VectorCopy (ent->origin, end); - end[2]+=64; + ent->origin[2] -= 14; + VectorCopy(ent->origin, start); + VectorCopy(ent->origin, end); + end[2] += 64; - VectorCopy (start, move); - VectorSubtract (end, start, vec); - len = VectorNormalize (vec); + VectorCopy(start, move); + VectorSubtract(end, start, vec); + len = VectorNormalize(vec); dec = 5; - VectorScale (vec, 5, vec); + VectorScale(vec, 5, vec); // FIXME: this is a really silly way to have a loop - while (len > 0) - { + while (len > 0) { len -= dec; p = CL_AllocParticle(); if (!p) return; - VectorClear (p->accel); - + VectorClear(p->accel); + p->time = cl.time; p->alpha = 1.0; - p->alphavel = -1.0 / (0.3+frand()*0.2); + p->alphavel = -1.0 / (0.3 + frand() * 0.2); p->color = 0xe0; - for (j=0 ; j<3 ; j++) - { + for (j = 0; j < 3; j++) { p->org[j] = move[j] + crand(); - p->vel[j] = crand()*15; + p->vel[j] = crand() * 15; p->accel[j] = 0; } p->accel[2] = PARTICLE_GRAVITY; - VectorAdd (move, vec, move); + VectorAdd(move, vec, move); } { - - - int i, j, k; - cparticle_t *p; - float vel; - vec3_t dir; - vec3_t org; - - - ent->origin[2]+=14; - VectorCopy (ent->origin, org); - - - for (i=-2 ; i<=2 ; i+=4) - for (j=-2 ; j<=2 ; j+=4) - for (k=-2 ; k<=4 ; k+=4) - { - p = CL_AllocParticle(); - if (!p) - return; - - p->time = cl.time; - p->color = 0xe0 + (rand()&3); - - p->alpha = 1.0; - p->alphavel = -1.0 / (0.3 + (rand()&7) * 0.02); - - p->org[0] = org[0] + i + ((rand()&23) * crand()); - p->org[1] = org[1] + j + ((rand()&23) * crand()); - p->org[2] = org[2] + k + ((rand()&23) * crand()); - - dir[0] = j * 8; - dir[1] = i * 8; - dir[2] = k * 8; - - VectorNormalize (dir); - vel = 50 + (rand()&63); - VectorScale (dir, vel, p->vel); - - p->accel[0] = p->accel[1] = 0; - p->accel[2] = -PARTICLE_GRAVITY; - } + int i, j, k; + cparticle_t *p; + float vel; + vec3_t dir; + vec3_t org; + + ent->origin[2] += 14; + VectorCopy(ent->origin, org); + + for (i = -2; i <= 2; i += 4) + for (j = -2; j <= 2; j += 4) + for (k = -2; k <= 4; k += 4) { + p = CL_AllocParticle(); + if (!p) + return; + + p->time = cl.time; + p->color = 0xe0 + (rand() & 3); + + p->alpha = 1.0; + p->alphavel = -1.0 / (0.3 + (rand() & 7) * 0.02); + + p->org[0] = org[0] + i + ((rand() & 23) * crand()); + p->org[1] = org[1] + j + ((rand() & 23) * crand()); + p->org[2] = org[2] + k + ((rand() & 23) * crand()); + + dir[0] = j * 8; + dir[1] = i * 8; + dir[2] = k * 8; + + VectorNormalize(dir); + vel = 50 + (rand() & 63); + VectorScale(dir, vel, p->vel); + + p->accel[0] = p->accel[1] = 0; + p->accel[2] = -PARTICLE_GRAVITY; + } } } @@ -1144,14 +1092,13 @@ void CL_TrapParticles (entity_t *ent) CL_ParticleEffect3 =============== */ -void CL_ParticleEffect3 (vec3_t org, vec3_t dir, int color, int count) +void CL_ParticleEffect3(vec3_t org, vec3_t dir, int color, int count) { int i, j; cparticle_t *p; float d; - for (i=0 ; i<count ; i++) - { + for (i = 0; i < count; i++) { p = CL_AllocParticle(); if (!p) return; @@ -1159,18 +1106,17 @@ void CL_ParticleEffect3 (vec3_t org, vec3_t dir, int color, int count) p->time = cl.time; p->color = color; - d = rand()&7; - for (j=0 ; j<3 ; j++) - { - p->org[j] = org[j] + ((rand()&7)-4) + d*dir[j]; - p->vel[j] = crand()*20; + d = rand() & 7; + for (j = 0; j < 3; j++) { + p->org[j] = org[j] + ((rand() & 7) - 4) + d * dir[j]; + p->vel[j] = crand() * 20; } p->accel[0] = p->accel[1] = 0; p->accel[2] = PARTICLE_GRAVITY; p->alpha = 1.0; - p->alphavel = -1.0 / (0.5 + frand()*0.3); + p->alphavel = -1.0 / (0.5 + frand() * 0.3); } } |