VITA/NX: Add support for QMB trails

This commit is contained in:
Ian 2023-09-09 11:40:16 -04:00
parent fe51a22d77
commit 4b983470bc
4 changed files with 188 additions and 32 deletions

View File

@ -727,7 +727,7 @@ void CL_RelinkEntities (void)
if (ent->effects & EF_RAYGREEN) if (ent->effects & EF_RAYGREEN)
{ {
R_RocketTrail (oldorg, ent->origin, 12); QMB_RocketTrail(oldorg, ent->origin, RAYGREEN_TRAIL);
dl = CL_AllocDlight (i); dl = CL_AllocDlight (i);
VectorCopy (ent->origin, dl->origin); VectorCopy (ent->origin, dl->origin);
dl->radius = 25; dl->radius = 25;
@ -740,7 +740,7 @@ void CL_RelinkEntities (void)
if (ent->effects & EF_RAYRED) if (ent->effects & EF_RAYRED)
{ {
R_RocketTrail (oldorg, ent->origin, 13); QMB_RocketTrail(oldorg, ent->origin, RAYRED_TRAIL);
dl = CL_AllocDlight (i); dl = CL_AllocDlight (i);
VectorCopy (ent->origin, dl->origin); VectorCopy (ent->origin, dl->origin);
dl->radius = 25; dl->radius = 25;

View File

@ -972,6 +972,163 @@ void AddParticle (part_type_t type, vec3_t org, int count, float size, double ti
} }
} }
void AddParticleTrail (part_type_t type, vec3_t start, vec3_t end, float size, float time, col_t col)
{
byte *color;
int i, j, num_particles;
float count, length;
vec3_t point, delta;
particle_t *p;
particle_type_t *pt;
static float rotangle = 0;
count = 0;
if (!qmb_initialized)
Sys_Error ("QMB particle added without initialization");
//assert (size > 0 && time > 0);
if (type < 0 || type >= num_particletypes)
Sys_Error ("AddParticle: Invalid type (%d)", type);
pt = &particle_types[particle_type_index[type]];
VectorCopy(start, point);
VectorSubtract(end, start, delta);
if (!(length = VectorLength(delta)))
return;
switch (type)
{
case p_q3blood_trail:
case p_q3rocketsmoke:
count = length / 40.0;
break;
case p_q3grenadesmoke:
count = length / 12.0;
break;
case p_alphatrail:
case p_trailpart:
case p_lavatrail:
count = length / 1.1;
break;
case p_blood3:
count = length / 8;
break;
case p_smoke:
count = length / 3.8;
break;
case p_dpsmoke:
count = length / 2.5;
break;
case p_dpfire:
count = length / 2.8;
break;
default:
//assert (!"AddParticleTrail: unexpected type");
break;
}
if (!(num_particles = (int)count))
num_particles = 1;
VectorScale(delta, 1.0 / num_particles, delta);
for (i=0 ; i < num_particles && free_particles ; i++)
{
color = col ? col : ColorForParticle (type);
INIT_NEW_PARTICLE(pt, p, color, size, time);
switch (type)
{
case p_alphatrail:
case p_trailpart:
VectorCopy (point, p->org);
VectorClear (p->vel);
p->growth = -size / time;
break;
case p_blood3:
VectorCopy (point, p->org);
for (j=0 ; j<3 ; j++)
p->org[j] += ((rand() & 15) - 8) / 8.0;
for (j=0 ; j<3 ; j++)
p->vel[j] = ((rand() & 15) - 8) / 2.0;
p->size = size * (rand() % 20) / 10.0;
p->growth = 6;
break;
case p_q3blood_trail:
VectorCopy (point, p->org);
for (j=0 ; j<3 ; j++)
p->org[j] += ((rand() & 15) - 8) / 8.0;
for (j=0 ; j<3 ; j++)
p->vel[j] = ((rand() & 15) - 8) / 2.0;
p->growth = 6;
break;
case p_smoke:
VectorCopy (point, p->org);
for (j=0 ; j<3 ; j++)
p->org[j] += ((rand() & 7) - 4) / 8.0;
p->vel[0] = p->vel[1] = 0;
p->vel[2] = rand() & 3;
p->growth = 4.5;
p->rotspeed = (rand() & 63) + 96;
break;
case p_q3rocketsmoke:
case p_q3grenadesmoke:
VectorCopy (point, p->org);
for (j=0 ; j<3 ; j++)
p->org[j] += ((rand() & 7) - 4) / 8.0;
VectorClear (p->vel);
p->growth = 30;
if (rotangle >= 360)
rotangle = 0;
p->rotangle = rotangle;
rotangle += 30;
break;
case p_dpsmoke:
VectorCopy (point, p->org);
for (j=0 ; j<3 ; j++)
p->vel[j] = (rand() % 10) - 5;
p->growth = 3;
p->rotspeed = (rand() & 63) + 96;
break;
case p_dpfire:
VectorCopy (point, p->org);
for (j=0 ; j<3 ; j++)
p->vel[j] = (rand() % 40) - 20;
break;
case p_lavatrail:
VectorCopy (point, p->org);
for (j=0 ; j<3 ; j++)
p->org[j] += ((rand() & 7) - 4);
p->vel[0] = p->vel[1] = 0;
p->vel[2] = rand() & 3;
break;
default:
//assert (!"AddParticleTrail: unexpected type");
break;
}
VectorAdd(point, delta, point);
}
}
void QMB_ParticleExplosion(vec3_t org) void QMB_ParticleExplosion(vec3_t org)
{ {
//shpuld //shpuld
@ -1360,14 +1517,16 @@ void QMB_RunParticleEffect (vec3_t org, vec3_t dir, int col, int count)
} }
break; break;
case 256: case 256:
color[2] = 1.0f; color[0] = 0;
color[1] = 255;
color[2] = 0;
AddParticle (p_raysmoke, org, 3, 25, 1.225f + ((rand() % 10) - 2) / 40.0, color, zerodir); AddParticle (p_raysmoke, org, 3, 25, 1.225f + ((rand() % 10) - 2) / 40.0, color, zerodir);
AddParticle (p_rayspark, org, 12, 75, 0.6f, color, zerodir); AddParticle (p_rayspark, org, 12, 75, 0.6f, color, zerodir);
break; break;
case 512: case 512:
color[1] = 1.0f; color[0] = 255;
color[1] = 0;
color[2] = 0; color[2] = 0;
color[3] = 0;
AddParticle (p_raysmoke, org, 3, 25, 1.225f + ((rand() % 10) - 2) / 40.0, color, zerodir); AddParticle (p_raysmoke, org, 3, 25, 1.225f + ((rand() % 10) - 2) / 40.0, color, zerodir);
AddParticle (p_rayspark, org, 12, 75, 0.6f, color, zerodir); AddParticle (p_rayspark, org, 12, 75, 0.6f, color, zerodir);
break; break;
@ -2231,31 +2390,28 @@ void QMB_MuzzleFlash(vec3_t org)
} }
} }
/* void QMB_RocketTrail (vec3_t start, vec3_t end, trail_type_t type)
===============
R_ToggleParticles_f
function that toggles between classic and QMB particles
===============
*/
/*
void R_ToggleParticles_f (void)
{ {
if (cmd_source != src_command) col_t color;
return;
if (particle_mode == pm_classic) switch (type)
R_SetParticleMode (pm_qmb); {
else if (particle_mode == pm_qmb) case RAYGREEN_TRAIL:
R_SetParticleMode (pm_quake3); color[0] = 0;
else color[1] = 255;
R_SetParticleMode (pm_classic); color[2] = 0;
AddParticleTrail (p_alphatrail, start, end, 8, 0.6, color);
if (key_dest != key_menu && key_dest != key_menu_pause) break;
Con_Printf ("Using %s particles\n", R_NameForParticleMode()); case RAYRED_TRAIL:
color[0] = 255;
color[1] = 0;
color[2] = 0;
AddParticleTrail (p_alphatrail, start, end, 8, 0.6, color);
break;
default:
break;
}
} }
*/
void CheckDecals (void) void CheckDecals (void)
{ {

View File

@ -571,11 +571,6 @@ void R_RocketTrail (vec3_t start, vec3_t end, int type)
int dec; int dec;
static int tracercount; static int tracercount;
// Don't draw broken trails with the Ray Gun
// TODO: QMB Trails
if (type == 12 || type == 13)
return;
VectorSubtract (end, start, vec); VectorSubtract (end, start, vec);
len = VectorNormalize (vec); len = VectorNormalize (vec);
if (type < 128) if (type < 128)

View File

@ -153,10 +153,15 @@ void R_AddEfrags (entity_t *ent);
void R_NewMap (void); void R_NewMap (void);
typedef enum trail_type_s
{
RAYGREEN_TRAIL, RAYRED_TRAIL
} trail_type_t;
void R_ParseParticleEffect (void); void R_ParseParticleEffect (void);
void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count); void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
void R_RocketTrail (vec3_t start, vec3_t end, int type); void R_RocketTrail (vec3_t start, vec3_t end, int type);
void QMB_RocketTrail (vec3_t start, vec3_t end, trail_type_t type);
void R_EntityParticles (entity_t *ent); void R_EntityParticles (entity_t *ent);
void R_BlobExplosion (vec3_t org); void R_BlobExplosion (vec3_t org);
void R_ParticleExplosion (vec3_t org); void R_ParticleExplosion (vec3_t org);