Skip to content

Commit

Permalink
cgame: Add explosion sound effects when hitting, apply muzzle effects…
Browse files Browse the repository at this point in the history
… to machine gun and shotgun as testing weapon types, adjust effects when hitting to another player and remove brass models, these machine gun and shotgun ammo shells
  • Loading branch information
LegendaryGuard committed Oct 16, 2024
1 parent 5b7b26a commit 50e4cc2
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 193 deletions.
25 changes: 21 additions & 4 deletions source/cgame/cg_effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,6 @@ CG_DebrisExplosion
*/
void CG_DebrisExplosion( vec3_t origin, vec3_t dir ) { // BFP - Debris particles explosion
int i;
// spawn randomly the shaders with the particles
int shaderIndex;
vec3_t sprOrg, sprVel;
int numRocks = 26;

Expand All @@ -585,7 +583,8 @@ void CG_DebrisExplosion( vec3_t origin, vec3_t dir ) { // BFP - Debris particles
// BFP - TODO: Apply number of rocks as indicated on default.cfg file of some character: explosionRocks <weaponNum> <numRocks>

for ( i = 0; i < numRocks; ++i ) {
shaderIndex = rand() % 3;
// spawn randomly the shaders with the particles
int shaderIndex = rand() % 3;

// that would be the range for debris particles
VectorMA( origin, 24, dir, sprOrg );
Expand Down Expand Up @@ -655,6 +654,24 @@ void CG_SparksExplosion( vec3_t origin, vec3_t dir ) { // BFP - Spark particles
}
}

/*
=================
CG_ExplosionSound
=================
*/
void CG_ExplosionSound( vec3_t origin ) { // BFP - Explosion sounds
int i = rand() % 6;

switch ( i ) {
case 0: trap_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.explosion1Sound ); break;
case 1: trap_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.explosion2Sound ); break;
case 2: trap_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.explosion3Sound ); break;
case 3: trap_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.explosion4Sound ); break;
case 4: trap_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.explosion5Sound ); break;
default: trap_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.explosion6Sound ); break;
}
}


/*
=================
Expand All @@ -670,7 +687,7 @@ void CG_ExplosionEffect( vec3_t origin, vec3_t dir ) { // BFP - Explosion effect
VectorMA( origin, 10, dir, origin );

// BFP - TODO: Apply explosionShader from bfp attack config, bfgExplosionShader is just a test
leSphere = CG_SpawnExplosionModel( origin, dir, LE_EXPLOSION, sphereModel, cgs.media.bfgExplosionShader, 1000 );
leSphere = CG_SpawnExplosionModel( origin, dir, LE_EXPLOSION_SPHERE, sphereModel, cgs.media.bfgExplosionShader, 1000 );
if ( cg_explosionShell.integer > 0 ) { // BFP - Explosion shell
leShell = CG_SpawnExplosionModel( origin, dir, LE_EXPLOSION_SHELL, sphereModel, cgs.media.explosionShellShader, 250 );
}
Expand Down
11 changes: 1 addition & 10 deletions source/cgame/cg_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,6 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
DEBUGNAME("EV_MISSILE_HIT");
ByteToDir( es->eventParm, dir );
CG_MissileHitPlayer( es->weapon, position, dir, es->otherEntityNum );
// BFP - Spark particles explosion
CG_SparksExplosion( position, dir );
break;

case EV_MISSILE_MISS:
Expand Down Expand Up @@ -905,14 +903,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
cent->currentState.weapon = WP_RAILGUN;
// if the end was on a nomark surface, don't make an explosion
CG_RailTrail( ci, es->origin2, es->pos.trBase );
if ( es->eventParm != 255 ) {
ByteToDir( es->eventParm, dir );
CG_MissileHitWall( es->weapon, es->clientNum, position, dir, IMPACTSOUND_DEFAULT );
// BFP - Debris particles explosion
CG_DebrisExplosion( position, dir );
// BFP - Spark particles explosion
CG_SparksExplosion( position, dir );
}
ByteToDir( es->eventParm, dir );
break;

case EV_BULLET_HIT_WALL:
Expand Down
14 changes: 11 additions & 3 deletions source/cgame/cg_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ typedef struct markPoly_s {
typedef enum {
LE_MARK,
LE_EXPLOSION,
LE_EXPLOSION_SPHERE, // BFP - Explosion sphere
LE_EXPLOSION_RING, // BFP - Explosion ring
LE_EXPLOSION_SHELL, // BFP - Explosion shell
LE_SPRITE_EXPLOSION,
Expand Down Expand Up @@ -694,9 +695,6 @@ typedef struct {

qhandle_t smoke2;

qhandle_t machinegunBrassModel;
qhandle_t shotgunBrassModel;

qhandle_t railRingsShader;
qhandle_t railCoreShader;

Expand Down Expand Up @@ -945,6 +943,14 @@ typedef struct {
sfxHandle_t wstbimpdSound;
sfxHandle_t wstbactvSound;

// BFP - Explosion sounds
sfxHandle_t explosion1Sound;
sfxHandle_t explosion2Sound;
sfxHandle_t explosion3Sound;
sfxHandle_t explosion4Sound;
sfxHandle_t explosion5Sound;
sfxHandle_t explosion6Sound;

sfxHandle_t kiChargeSound; // BFP - Ki charge sound
sfxHandle_t kiUseSound; // BFP - Ki use sound

Expand Down Expand Up @@ -1292,6 +1298,8 @@ localEntity_t *CG_SpawnExplosionModel( vec3_t origin, vec3_t dir, leType_t type,
void CG_DebrisExplosion( vec3_t origin, vec3_t dir );
// BFP - Spark particles explosion
void CG_SparksExplosion( vec3_t origin, vec3_t dir );
// BFP - Explosion sounds
void CG_ExplosionSound( vec3_t origin );
// BFP - Explosion effects
void CG_ExplosionEffect( vec3_t origin, vec3_t dir );

Expand Down
4 changes: 4 additions & 0 deletions source/cgame/cg_localents.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,9 @@ static void CG_AddExplosion( localEntity_t *ex ) {

switch( ex->leType ) {
case LE_EXPLOSION:
scale = 1.05f; // scale a bit faster to adjust
break;
case LE_EXPLOSION_SPHERE:
if ( cg.time > endTime ) {
scale = 0.9f * ( endScale + 0.5f ); // decrease size
}
Expand Down Expand Up @@ -719,6 +722,7 @@ void CG_AddLocalEntities( void ) {
break;

case LE_EXPLOSION:
case LE_EXPLOSION_SPHERE: // BFP - Explosion sphere
case LE_EXPLOSION_RING: // BFP - Explosion ring
case LE_EXPLOSION_SHELL: // BFP - Explosion shell
CG_AddExplosion( le );
Expand Down
11 changes: 8 additions & 3 deletions source/cgame/cg_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,14 @@ static void CG_RegisterSounds( void ) {
cgs.media.hgrenb1aSound = trap_S_RegisterSound("sound/weapons/grenade/hgrenb1a.wav", qfalse);
cgs.media.hgrenb2aSound = trap_S_RegisterSound("sound/weapons/grenade/hgrenb2a.wav", qfalse);

// BFP - Explosion sounds
cgs.media.explosion1Sound = trap_S_RegisterSound("sound/bfp/explosion1.wav", qfalse);
cgs.media.explosion2Sound = trap_S_RegisterSound("sound/bfp/explosion2.wav", qfalse);
cgs.media.explosion3Sound = trap_S_RegisterSound("sound/bfp/explosion3.wav", qfalse);
cgs.media.explosion4Sound = trap_S_RegisterSound("sound/bfp/explosion4.wav", qfalse);
cgs.media.explosion5Sound = trap_S_RegisterSound("sound/bfp/explosion5.wav", qfalse);
cgs.media.explosion6Sound = trap_S_RegisterSound("sound/bfp/explosion6.wav", qfalse);

cgs.media.kiChargeSound = trap_S_RegisterSound("sound/bfp/kicharge1.wav", qfalse); // BFP - Ki charge sound
cgs.media.kiUseSound = trap_S_RegisterSound("sound/bfp/kiuse1.wav", qfalse); // BFP - Ki use sound
cgs.media.defaultKiChargingSound = trap_S_RegisterSound("sound/bfp/attackcharge1.wav", qfalse); // BFP - Default ki charging attack sound
Expand Down Expand Up @@ -598,9 +606,6 @@ static void CG_RegisterGraphics( void ) {
cgs.media.armorModel = trap_R_RegisterModel( "models/powerups/armor/armor_yel.md3" );
cgs.media.armorIcon = trap_R_RegisterShaderNoMip( "icons/iconr_yellow" );

cgs.media.machinegunBrassModel = trap_R_RegisterModel( "models/weapons2/shells/m_shell.md3" );
cgs.media.shotgunBrassModel = trap_R_RegisterModel( "models/weapons2/shells/s_shell.md3" );

cgs.media.gibAbdomen = trap_R_RegisterModel( "models/gibs/abdomen.md3" );
cgs.media.gibArm = trap_R_RegisterModel( "models/gibs/arm.md3" );
cgs.media.gibChest = trap_R_RegisterModel( "models/gibs/chest.md3" );
Expand Down
Loading

0 comments on commit 50e4cc2

Please sign in to comment.