Skip to content

Commit

Permalink
cgame: Fix antigrav rock particles when staying suspended in air afte…
Browse files Browse the repository at this point in the history
…r few bounces, now bounces are physically correct, apply entityNum check for antigrav rock particles and fix dash smoke particles aren't spawning when toggling ki boost
  • Loading branch information
LegendaryGuard committed Sep 13, 2024
1 parent b8e47c8 commit 2e61409
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 31 deletions.
2 changes: 1 addition & 1 deletion source/cgame/cg_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ void CG_ParticleBubble (centity_t *cent, qhandle_t pshader, vec3_t origin, vec3_
// 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
void CG_ParticleAntigravRock (qhandle_t pshader, centity_t *cent, vec3_t origin);
void CG_ParticleAntigravRock (qhandle_t pshader, centity_t *cent, int entityNum, vec3_t origin);
void CG_AntigravRockHandling (centity_t *cent);
// BFP - Particle aura
void CG_ParticleAura (centity_t *cent, int entityNum, qhandle_t pshader, vec3_t origin, vec3_t origin2, float range);
Expand Down
44 changes: 20 additions & 24 deletions source/cgame/cg_particles.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,9 @@ void CG_AddParticleToScene (cparticle_t *p, vec3_t org, float alpha)
{
// BFP - To detect if there is something solid
trace_t trace;
vec3_t rockPos = {0, 0, -1}; // place a bit above
// contents should be CONTENTS_SOLID, so the particles don't touch any entity like the player
CG_Trace( &trace, p->org, vec3_origin, vec3_origin, org, -1, CONTENTS_SOLID );
CG_Trace( &trace, p->org, rockPos, rockPos, org, -1, CONTENTS_SOLID );

p->time = timenonscaled;
p->snum = 1; // handle the p->snum when already entered in this phase for correction of client side visuals
Expand All @@ -428,23 +429,25 @@ void CG_AddParticleToScene (cparticle_t *p, vec3_t org, float alpha)
p->accel[0] = 0;
p->accel[1] = 0;
// not hit anything or not a collider
if ( trace.fraction == 1.0f && p->roll > 0 )
if ( trace.fraction == 1.0f )
{
VectorCopy (org, p->org);
p->vel[2] -= 50;
p->accel[2] -= 200;
}
else // bouncing
{
// BFP - TODO: Temporary solution... Make bouncing more interactive when there's a mover moving
// if the particle is touching a mover and moves down, so keep bouncing
if ( trace.fraction <= 0 ) {
p->roll = 16;
p->roll = 6;
} else {
p->vel[2] = p->accel[2] = (p->roll > 0) ? 50 * p->roll : 0;
p->roll--; // that decreases bounces
}
}
if ( p->roll <= 0 ) { // keep detecting the position
VectorCopy (trace.endpos, p->org);
}
}

// BFP - When reaching into this top, remove the particle!
Expand Down Expand Up @@ -1027,7 +1030,7 @@ void CG_ParticleDashSmoke (centity_t *cent, qhandle_t pshader, vec3_t origin)
}

// BFP - Antigrav rock particles for ki charging status
void CG_ParticleAntigravRock (qhandle_t pshader, centity_t *cent, vec3_t origin)
void CG_ParticleAntigravRock (qhandle_t pshader, centity_t *cent, int entityNum, vec3_t origin)
{
cparticle_t *p;

Expand All @@ -1052,6 +1055,9 @@ void CG_ParticleAntigravRock (qhandle_t pshader, centity_t *cent, vec3_t origin)
active_particles = p;
p->time = timenonscaled;

// BFP - Keep entity number to identify who is using
p->entityNum = entityNum;

p->endtime = timenonscaled + 450 + (crandom() * 20);

p->color = 0;
Expand Down Expand Up @@ -1099,27 +1105,17 @@ void CG_AntigravRockHandling (centity_t *cent)
for (p=active_particles ; p ; p=next)
{
next = p->next;
if (p->type == P_ANTIGRAV_ROCK)
if ( p->type != P_ANTIGRAV_ROCK ) continue;

if ( p->entityNum == cent->currentState.clientNum
&& !( cent->currentState.eFlags & EF_DEAD )
&& ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) != LEGS_CHARGE )
{
if ( cent->currentState.clientNum == cg.snap->ps.clientNum
&& !( cent->currentState.eFlags & EF_DEAD )
&& ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) != LEGS_CHARGE )
// BFP - Make each particle fall when they aren't on ki charging status
if (!p->link)
{
// BFP - Make each particle fall when they aren't on ki charging status
if (!p->link && !p->snum) // to handle the client side visuals
{
p->endtime = timenonscaled + 1650;
p->link = qtrue;
}
}
// if the player sees the other player doing that, the handling is different from itself,
// to correct the client side visuals in this case
if ( cent->currentState.clientNum != cg.snap->ps.clientNum
&& ( cent->currentState.eFlags & EF_AURA )
&& !( cent->currentState.eFlags & EF_DEAD )
&& ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_CHARGE
&& !p->snum ) { // use p->snum to handle the client side visual of the other player
p->link = qfalse; // keep this way, otherwise the rocks fall
p->endtime = timenonscaled + 1650;
p->link = qtrue;
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions source/cgame/cg_players.c
Original file line number Diff line number Diff line change
Expand Up @@ -1922,11 +1922,10 @@ static qboolean CG_PlayerShadow( centity_t *cent, float *shadowPlane ) {
// BFP - Dash smoke and bubble particles when using ki boost on the ground or above the water
contents = CG_PointContents( trace.endpos, -1 );
if ( cent->currentState.eFlags & EF_AURA ) {
if ( !( cent->currentState.powerups & ( 1 << PW_HASTE ) )
&& ( ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_RUN
if ( ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_RUN
|| ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_BACK
|| ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_FLYA
|| ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_FLYB ) ) {
|| ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_FLYB ) {
if ( !( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) )
&& ( trace.fraction <= 0.70f
// If the player is stepping a mover:
Expand Down Expand Up @@ -1958,15 +1957,15 @@ static qboolean CG_PlayerShadow( centity_t *cent, float *shadowPlane ) {
int shaderIndex = rand() % 3;
switch ( shaderIndex ) {
case 0: {
CG_ParticleAntigravRock( cgs.media.pebbleShader1, cent, trace.endpos );
CG_ParticleAntigravRock( cgs.media.pebbleShader1, cent, cent->currentState.clientNum, trace.endpos );
break;
}
case 1: {
CG_ParticleAntigravRock( cgs.media.pebbleShader2, cent, trace.endpos );
CG_ParticleAntigravRock( cgs.media.pebbleShader2, cent, cent->currentState.clientNum, trace.endpos );
break;
}
default: {
CG_ParticleAntigravRock( cgs.media.pebbleShader3, cent, trace.endpos );
CG_ParticleAntigravRock( cgs.media.pebbleShader3, cent, cent->currentState.clientNum, trace.endpos );
}
}
}
Expand Down

0 comments on commit 2e61409

Please sign in to comment.