Skip to content

Commit

Permalink
cgame: Apply bubble and dash smoke particles when entering under wate…
Browse files Browse the repository at this point in the history
…r, using ki boost or ki charge statuses and for projectile type weapons
  • Loading branch information
LegendaryGuard committed Jan 20, 2024
1 parent c461dfd commit 2b48d91
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 13 deletions.
12 changes: 12 additions & 0 deletions source/cgame/cg_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,18 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
case EV_WATER_UNDER:
DEBUGNAME("EV_WATER_UNDER");
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.watrUnSound );
// BFP - Bubble and splash particles when entering under water
{
// BFP - TODO: Splash particles (that appears bubbles outside water but bouncing once)
vec3_t end = {0, 0, 1};

// Blub, blub, blub...
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, cent->lerpOrigin, end, 0, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, cent->lerpOrigin, end, 0, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, cent->lerpOrigin, end, 0, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, cent->lerpOrigin, end, 0, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, cent->lerpOrigin, end, 0, 20, 0 );
}
break;
case EV_WATER_CLEAR:
DEBUGNAME("EV_WATER_CLEAR");
Expand Down
65 changes: 53 additions & 12 deletions source/cgame/cg_players.c
Original file line number Diff line number Diff line change
Expand Up @@ -1521,10 +1521,13 @@ static void CG_PlayerAngles( centity_t *cent, vec3_t legs[3], vec3_t torso[3], v
CG_HasteTrail
===============
*/
static void CG_HasteTrail( centity_t *cent ) {
static void CG_HasteTrail( centity_t *cent, vec3_t endPos ) { // BFP - Second parameter added for smoke particles
// BFP - No smoke puff effect
#if 0
localEntity_t *smoke;
vec3_t origin;
int anim;
#endif

if ( cent->trailTime > cg.time ) {
return;
Expand All @@ -1537,13 +1540,18 @@ static void CG_HasteTrail( centity_t *cent ) {
}
#endif

cent->trailTime += 50; // BFP - TODO: Just a test (before 100)
cent->trailTime += 100;
if ( cent->trailTime < cg.time ) {
cent->trailTime = cg.time;
}

// BFP - TODO: Make the smoke move up (always) and move a bit on the left or right (randomly)
// BFP - Apply dash smoke particle for the trail, if the function were used directly, it would generate too many particles than we expected
CG_ParticleDashSmoke( cent, cgs.media.hastePuffShader, endPos );
CG_ParticleDashSmoke( cent, cgs.media.hastePuffShader, endPos );
CG_ParticleDashSmoke( cent, cgs.media.hastePuffShader, endPos );

// BFP - No smoke puff effect
#if 0
VectorCopy( cent->lerpOrigin, origin );
origin[2] -= 16;

Expand All @@ -1558,6 +1566,7 @@ static void CG_HasteTrail( centity_t *cent ) {

// use the optimized local entity add
smoke->leType = LE_SCALE_FADE;
#endif
}

/*
Expand Down Expand Up @@ -1886,19 +1895,16 @@ static qboolean CG_PlayerShadow( centity_t *cent, float *shadowPlane ) {

*shadowPlane = trace.endpos[2] + 1;

// BFP - TODO: Only show smoke where the shadow is and make one smoke of each moving to the air,
// disappearing randomly according to time, making bigger according the size like BFP does
// CG_SmokePuff will help you to find out how to do

// BFP - Smoke trail when using ki boost on the ground
// BFP - Dash smoke particles when using ki boost on the ground
contents = CG_PointContents( trace.endpos, -1 );
if ( ( cent->currentState.eFlags & EF_AURA )
&& !( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) )
&& ( ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_RUN
&& !( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) )
&& ( ( 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 ) ) {
CG_HasteTrail( cent );
|| ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_FLYB )
&& trace.fraction <= 0.70f ) {
CG_HasteTrail( cent, trace.endpos );
}

if ( cg_shadows.integer != 1 ) { // no mark for stencil or projection shadows
Expand Down Expand Up @@ -2327,6 +2333,41 @@ void CG_Player( centity_t *cent ) {
}

if ( cent->currentState.eFlags & EF_AURA ) {
// BFP - TODO: Create a new function "CG_KiTrail" only when moving to draw ki trail and add the cvar for the length

// BFP - Traces for bubble particles only when moving in the water and charging
int sourceContentType, destContentType;
vec3_t start;

sourceContentType = trap_CM_PointContents( start, 0 );
destContentType = trap_CM_PointContents( cent->lerpOrigin, 0 );

// spawning bubble particles
if ( destContentType & CONTENTS_WATER ) {
trace_t trace;
vec3_t bubbleOrigin;

VectorCopy( legs.origin, bubbleOrigin );
trap_CM_BoxTrace( &trace, start, bubbleOrigin, NULL, NULL, 0, CONTENTS_WATER );

bubbleOrigin[2] += -15; // put the origin below the character's feet

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

CG_ParticleBubble( cent, cgs.media.waterBubbleShader, bubbleOrigin, trace.endpos, 0, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, bubbleOrigin, trace.endpos, 0, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, bubbleOrigin, trace.endpos, 0, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, bubbleOrigin, trace.endpos, 0, 20, 0 );
CG_ParticleBubble( cent, cgs.media.waterBubbleShader, bubbleOrigin, trace.endpos, 0, 20, 0 );
}
}

// Apply the render type
aura.reType = aura2.reType = RT_MODEL;

Expand Down
9 changes: 8 additions & 1 deletion source/cgame/cg_weapons.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,11 @@ static void CG_RocketTrail( centity_t *ent, const weaponInfo_t *wi ) {

if ( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) {
if ( contents & lastContents & CONTENTS_WATER ) {
CG_BubbleTrail( lastPos, origin, 8 );
// BFP - Apply particle bubble effect in that case
CG_ParticleBubble( ent, cgs.media.waterBubbleShader, origin, lastPos, 0, 20, 0 );
CG_ParticleBubble( ent, cgs.media.waterBubbleShader, origin, lastPos, 0, 20, 0 );
CG_ParticleBubble( ent, cgs.media.waterBubbleShader, origin, lastPos, 0, 20, 0 );
// CG_BubbleTrail( lastPos, origin, 8 );
}
return;
}
Expand Down Expand Up @@ -2033,6 +2037,8 @@ Renders bullet effects.
======================
*/
void CG_Bullet( vec3_t end, int sourceEntityNum, vec3_t normal, qboolean flesh, int fleshEntityNum ) {
// BFP - No water particles in BFP by firing a kind of ki-type bullet
#if 0
trace_t trace;
int sourceContentType, destContentType;
vec3_t start;
Expand Down Expand Up @@ -2065,6 +2071,7 @@ void CG_Bullet( vec3_t end, int sourceEntityNum, vec3_t normal, qboolean flesh,
}
}
}
#endif

// impact splash and mark
if ( flesh ) {
Expand Down

0 comments on commit 2b48d91

Please sign in to comment.