Skip to content

Commit

Permalink
cgame: Tweak the movements of bubble particles and use antigrav rock …
Browse files Browse the repository at this point in the history
…particles only when the player isn't moving
  • Loading branch information
LegendaryGuard committed Mar 28, 2024
1 parent 747d05c commit 9f3c681
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 36 deletions.
10 changes: 5 additions & 5 deletions source/cgame/cg_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,11 +593,11 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
vec3_t end = {0, 0, 1};

// Blub, blub, blub...
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, cent->lerpOrigin, end, 1, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, cent->lerpOrigin, end, 1, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, cent->lerpOrigin, end, 1, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, cent->lerpOrigin, end, 1, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, cent->lerpOrigin, end, 1, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, cent->lerpOrigin, end, 700, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, cent->lerpOrigin, end, 700, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, cent->lerpOrigin, end, 700, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, cent->lerpOrigin, end, 700, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, cent->lerpOrigin, end, 700, 20, 0 );
}
break;
case EV_WATER_CLEAR:
Expand Down
2 changes: 1 addition & 1 deletion source/cgame/cg_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ void CG_ParticleDust (centity_t *cent, vec3_t origin, vec3_t dir);
void CG_ParticleMisc (qhandle_t pshader, vec3_t origin, int size, int duration, float alpha);
void CG_ParticleExplosion (char *animStr, vec3_t origin, vec3_t vel, int duration, int sizeStart, int sizeEnd);
// BFP - Bubble particle
void CG_ParticleBubble (centity_t *cent, qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum);
void CG_ParticleBubble (centity_t *cent, qhandle_t pshader, vec3_t origin, vec3_t origin2, int turbtime, float range, int snum);
// BFP - Dash smoke particle for ki boost when moving in the ground
void CG_ParticleDashSmoke (centity_t *cent, qhandle_t pshader, vec3_t origin);
// BFP - Antigrav rock particles for charging
Expand Down
53 changes: 32 additions & 21 deletions source/cgame/cg_particles.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,6 @@ void CG_AddParticleToScene (cparticle_t *p, vec3_t org, float alpha)
p->endtime = timenonscaled + 2500 + (crandom() * 150);
p->link = qtrue;
}
} else {
if ( !p->link )
{
p->endtime = timenonscaled + 500 + (crandom() * 150);
p->link = qtrue;
}
}
}

Expand Down Expand Up @@ -940,7 +934,7 @@ void CG_AddParticles (void)
active_particles = active;
}

void CG_ParticleBubble (centity_t *cent, qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum)
void CG_ParticleBubble (centity_t *cent, qhandle_t pshader, vec3_t origin, vec3_t origin2, int turbtime, float range, int snum)
{
cparticle_t *p;

Expand All @@ -955,7 +949,7 @@ void CG_ParticleBubble (centity_t *cent, qhandle_t pshader, vec3_t origin, vec3_
p->time = timenonscaled;

// BFP - Add end time to remove particles, if there's no end time the particles will remain there
p->endtime = timenonscaled + 400;
p->endtime = timenonscaled + 600;
p->startfade = timenonscaled + 200;

p->color = 0;
Expand All @@ -965,13 +959,20 @@ void CG_ParticleBubble (centity_t *cent, qhandle_t pshader, vec3_t origin, vec3_
p->start = cent->currentState.origin[2];
p->end = cent->currentState.origin2[2];
p->pshader = pshader;
p->height = p->width = 2 + (crandom() * 0.5);
p->height = p->width = (rand() % 2) + 1;

if (turb)
VectorCopy(origin, p->org);

if (turbtime)
{
p->type = P_BUBBLE_TURBULENT;
// BFP - Apply end time to remove particles in that case, if there's no end time the particles will remain there
p->endtime = timenonscaled + 700;
p->endtime = timenonscaled + turbtime;
p->height = p->width = (rand() % 1) + 2;

p->org[0] += (rand() % (int)range) + (crandom() * range);
p->org[1] += (rand() % (int)range) + (crandom() * range);
p->org[2] += (rand() % (int)20);

VectorSet( p->vel,
(rand() % 401) - 200,
Expand All @@ -980,13 +981,18 @@ void CG_ParticleBubble (centity_t *cent, qhandle_t pshader, vec3_t origin, vec3_

// dispersion
VectorSet( p->accel,
crandom() * 20,
crandom() * 20,
crandom() * 10,
crandom() * 10,
300 );
}
else
{
p->type = P_BUBBLE;

p->org[0] += (crandom() * range);
p->org[1] += (crandom() * range);
p->org[2] += (crandom() * 5);

VectorSet( p->vel,
(rand() % 521) - 250,
(rand() % 521) - 250,
Expand All @@ -999,12 +1005,6 @@ void CG_ParticleBubble (centity_t *cent, qhandle_t pshader, vec3_t origin, vec3_
900 );
}

VectorCopy(origin, p->org);

p->org[0] += (crandom() * range);
p->org[1] += (crandom() * range);
p->org[2] += (crandom() * 5);

p->snum = 3 - (crandom() * 6); // used to randomize where the bubbles stop when these touches the surface
p->link = qfalse;
}
Expand All @@ -1021,6 +1021,15 @@ void CG_BubblesWaterHandling( cparticle_t *p, vec3_t org ) {
VectorCopy( org, start );
start[2] += 10;

// BFP - Make move less
if ( p->vel[0] > -0.9 && p->vel[0] < 0.9 ) p->vel[0] = 0;
if ( p->vel[1] > -0.9 && p->vel[1] < 0.9 ) p->vel[1] = 0;
if ( p->vel[0] != 0 ) p->vel[0] *= 0.99;
if ( p->vel[1] != 0 ) p->vel[1] *= 0.99;

// Decelerate
if ( p->accel[2] > 0 ) p->accel[2]--;

// trace down to find the surface
trap_CM_BoxTrace( &trace, start, end, vec3_origin, vec3_origin, 0, CONTENTS_WATER );

Expand All @@ -1047,8 +1056,10 @@ void CG_BubblesWaterHandling( cparticle_t *p, vec3_t org ) {
VectorClear( p->accel );

// BFP - Make move less
p->vel[0] *= 0.9;
p->vel[1] *= 0.9;
if ( p->vel[0] >= -1 && p->vel[0] <= 0.9 ) p->vel[0] = 0;
else p->vel[0] *= 0.9;
if ( p->vel[1] >= -1 && p->vel[1] <= 0.9 ) p->vel[1] = 0;
else p->vel[1] *= 0.9;
}
}

Expand Down
17 changes: 11 additions & 6 deletions source/cgame/cg_players.c
Original file line number Diff line number Diff line change
Expand Up @@ -1887,15 +1887,20 @@ static qboolean CG_PlayerShadow( centity_t *cent, float *shadowPlane ) {
CG_ParticleDashSmoke( cent, cgs.media.particleSmokeShader, trace.endpos );
}

waterTrace.endpos[2] -= 20; // BFP - Put a bit down to make the bubbles move
if ( waterTrace.fraction >= 0.10f && waterTrace.fraction <= 0.70f ) {
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, waterTrace.endpos, end, 1, 10, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, waterTrace.endpos, end, 1, 10, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, waterTrace.endpos, end, 1, 10, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, waterTrace.endpos, end, 700, 10, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, waterTrace.endpos, end, 700, 10, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, waterTrace.endpos, end, 700, 10, 0 );
}
}

if ( ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_CHARGE ) { // BFP - Antigrav rock particles on ki charging status
if ( !( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) )
// if the player isn't moving
&& !cent->currentState.pos.trDelta[0]
&& !cent->currentState.pos.trDelta[1]
&& !cent->currentState.pos.trDelta[2]
&& ( trace.fraction <= 0.30f
// If the player is stepping a mover:
|| cent->currentState.groundEntityNum != ENTITYNUM_NONE ) ) {
Expand Down Expand Up @@ -2392,9 +2397,9 @@ void CG_Player( centity_t *cent ) {

if ( ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_FLYA
|| ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_FLYB ) {
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, bubbleOrigin, trace.endpos, 1, 10, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, bubbleOrigin, trace.endpos, 1, 10, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, bubbleOrigin, trace.endpos, 1, 10, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, bubbleOrigin, trace.endpos, 700, 10, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, bubbleOrigin, trace.endpos, 700, 10, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, bubbleOrigin, trace.endpos, 700, 10, 0 );
} else if ( ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_CHARGE ) {
bubbleOrigin[2] += -7; // put the origin a little below

Expand Down
6 changes: 3 additions & 3 deletions source/cgame/cg_weapons.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ static void CG_RocketTrail( centity_t *ent, const weaponInfo_t *wi ) {
if ( ( contents & lastContents & CONTENTS_WATER )
&& cg.frametime > 0.0f ) { // BFP - If paused, don't spawn bubble particles (cg_paused.integer < 1 is another solution, but not good enough for server responses)
// BFP - Apply particle bubble effect in that case
CG_ParticleBubble( ent, cgs.media.waterBubbleShader, origin, lastPos, 1, 0, 0 );
CG_ParticleBubble( ent, cgs.media.waterBubbleShader, origin, lastPos, 1, 0, 0 );
CG_ParticleBubble( ent, cgs.media.waterBubbleShader, origin, lastPos, 1, 0, 0 );
CG_ParticleBubble( ent, cgs.media.waterBubbleShader, origin, lastPos, 1200, 20, 0 );
CG_ParticleBubble( ent, cgs.media.waterBubbleShader, origin, lastPos, 1200, 20, 0 );
CG_ParticleBubble( ent, cgs.media.waterBubbleShader, origin, lastPos, 1200, 20, 0 );
// CG_BubbleTrail( lastPos, origin, 8 );
}
return;
Expand Down

0 comments on commit 9f3c681

Please sign in to comment.