Skip to content
Permalink
Browse files

cgame: cleanup and make bullet weapon impact depend (was MP40 for all)

  • Loading branch information...
Aranud committed May 13, 2019
1 parent ba8f7ad commit 89992b8f140704d16b300920f3b6dcd7945099a9
Showing with 25 additions and 65 deletions.
  1. +2 −33 src/cgame/cg_local.h
  2. +7 −10 src/cgame/cg_main.c
  3. +16 −22 src/cgame/cg_weapons.c
@@ -761,8 +761,8 @@ typedef struct weaponModel_s
*/
typedef struct impactSounds_s
{
int count;
sfxHandle_t sounds[MAX_IMPACT_SOUNDS];
int count;
sfxHandle_t sounds[MAX_IMPACT_SOUNDS];
}impactSounds_t;

/**
@@ -1539,10 +1539,6 @@ typedef struct
qhandle_t wakeMarkShaderAnim;
qhandle_t bloodMarkShaders[5];
qhandle_t bloodDotShaders[5];
qhandle_t bulletMarkShader;
qhandle_t bulletMarkShaderMetal;
qhandle_t bulletMarkShaderWood;
qhandle_t bulletMarkShaderGlass;
qhandle_t burnMarkShader;

qhandle_t flamebarrel;
@@ -1582,43 +1578,18 @@ typedef struct
qhandle_t alliedUniformShader;
qhandle_t axisUniformShader;

sfxHandle_t sfx_artilleryExp[3];
sfxHandle_t sfx_artilleryDist;

sfxHandle_t sfx_airstrikeExp[3];
sfxHandle_t sfx_airstrikeDist;

// sounds
sfxHandle_t noFireUnderwater;
sfxHandle_t selectSound;
sfxHandle_t landHurt;

sfxHandle_t footsteps[FOOTSTEP_TOTAL][4];
sfxHandle_t sfx_rockexp;
sfxHandle_t sfx_rockexpDist;
sfxHandle_t sfx_rockexpWater;
sfxHandle_t sfx_satchelexp;
sfxHandle_t sfx_satchelexpDist;
sfxHandle_t sfx_landmineexp;
sfxHandle_t sfx_landmineexpDist;
sfxHandle_t sfx_mortarexp[4];
sfxHandle_t sfx_mortarexpDist;
sfxHandle_t sfx_grenexp;
sfxHandle_t sfx_grenexpDist;
sfxHandle_t sfx_brassSound[BRASSSOUND_MAX][3][2];
sfxHandle_t sfx_rubbleBounce[3];

//sfxHandle_t sfx_bullet_fleshhit[MAX_IMPACT_SOUNDS];
sfxHandle_t sfx_bullet_metalhit[MAX_IMPACT_SOUNDS];
sfxHandle_t sfx_bullet_woodhit[MAX_IMPACT_SOUNDS];
sfxHandle_t sfx_bullet_glasshit[MAX_IMPACT_SOUNDS];
sfxHandle_t sfx_bullet_stonehit[MAX_IMPACT_SOUNDS];
sfxHandle_t sfx_bullet_waterhit[MAX_IMPACT_SOUNDS];

sfxHandle_t sfx_dynamiteexp;
sfxHandle_t sfx_dynamiteexpDist;

sfxHandle_t sfx_knifehit[5];
sfxHandle_t gibSound;
sfxHandle_t landSound[FOOTSTEP_TOTAL];

@@ -1632,8 +1603,6 @@ typedef struct
sfxHandle_t watrGaspSound;

sfxHandle_t underWaterSound;
sfxHandle_t fireSound;
sfxHandle_t waterSound;

sfxHandle_t countFight;
sfxHandle_t countPrepare;
@@ -1439,10 +1439,12 @@ static void CG_RegisterSounds(void)

cgs.media.boneBounceSound = trap_S_RegisterSound("sound/world/boardbreak.wav", qfalse); // TODO: need a real sound for this

cgs.media.sfx_mortarexp[0] = trap_S_RegisterSound("sound/weapons/mortar/mortar_expl1.wav", qfalse);
cgs.media.sfx_mortarexp[1] = trap_S_RegisterSound("sound/weapons/mortar/mortar_expl2.wav", qfalse);
cgs.media.sfx_mortarexp[2] = trap_S_RegisterSound("sound/weapons/mortar/mortar_expl3.wav", qfalse);
cgs.media.sfx_mortarexp[3] = trap_S_RegisterSound("sound/weapons/mortar/mortar_expl.wav", qfalse);
cgs.media.sfx_rockexp = trap_S_RegisterSound("sound/weapons/rocket/rocket_expl.wav", qfalse);

cgs.media.sfx_mortarexp[0] = trap_S_RegisterSound("sound/weapons/mortar/mortar_expl1.wav", qfalse);
cgs.media.sfx_mortarexp[1] = trap_S_RegisterSound("sound/weapons/mortar/mortar_expl2.wav", qfalse);
cgs.media.sfx_mortarexp[2] = trap_S_RegisterSound("sound/weapons/mortar/mortar_expl3.wav", qfalse);
cgs.media.sfx_mortarexp[3] = trap_S_RegisterSound("sound/weapons/mortar/mortar_expl.wav", qfalse);

for (i = 0; i < 3; i++)
{
@@ -1882,7 +1884,7 @@ static void CG_RegisterGraphics(void)
}

// cgs.media.grenadeExplosionShader = trap_R_RegisterShader("grenadeExplosion"); // unused FIXME: remove from shader def
// cgs.media.rocketExplosionShader = trap_R_RegisterShader("rocketExplosion"); // unused
// cgs.media.rocketExplosionShader = trap_R_RegisterShader("rocketExplosion"); // unused

cgs.media.hWeaponSnd = trap_S_RegisterSound("sound/weapons/mg42/mg42_fire.wav", qfalse);
cgs.media.hWeaponEchoSnd = trap_S_RegisterSound("sound/weapons/mg42/mg42_far.wav", qfalse);
@@ -1898,17 +1900,12 @@ static void CG_RegisterGraphics(void)
cgs.media.minePrimedSound = trap_S_RegisterSound("sound/weapons/landmine/mine_on.wav", qfalse);

// wall marks
cgs.media.bulletMarkShader = trap_R_RegisterShaderNoMip("gfx/damage/bullet_mrk");
cgs.media.burnMarkShader = trap_R_RegisterShaderNoMip("gfx/damage/burn_med_mrk");
cgs.media.shadowFootShader = trap_R_RegisterShaderNoMip("markShadowFoot");
cgs.media.shadowTorsoShader = trap_R_RegisterShaderNoMip("markShadowTorso");
cgs.media.wakeMarkShader = trap_R_RegisterShaderNoMip("wake");
cgs.media.wakeMarkShaderAnim = trap_R_RegisterShaderNoMip("wakeAnim");

cgs.media.bulletMarkShaderMetal = trap_R_RegisterShaderNoMip("gfx/damage/metal_mrk");
cgs.media.bulletMarkShaderWood = trap_R_RegisterShaderNoMip("gfx/damage/wood_mrk");
cgs.media.bulletMarkShaderGlass = trap_R_RegisterShaderNoMip("gfx/damage/glass_mrk");

for (i = 0 ; i < 5 ; i++)
{
//Com_sprintf( name, sizeof(name), "textures/decals/blood%i", i+1 );
@@ -1272,15 +1272,15 @@ static qboolean CG_RW_ParseImpactSound(int handle, weaponInfo_t *weaponInfo)

for (i = 0; i < token.intvalue && i < MAX_IMPACT_SOUNDS ; i++)
{
weaponInfo->impactSound[impactSurface].sounds[i] = trap_S_RegisterSound(va("%s%i", filename, i + 1), qfalse);
weaponInfo->impactSound[impactSurface].sounds[i] = trap_S_RegisterSound(va("%s%i", filename, i + 1), qfalse);
}
weaponInfo->impactSound[impactSurface].count = i;

weaponInfo->impactSound[impactSurface].count = i;
}
else // assume only one file sound must be register
{
weaponInfo->impactSound[impactSurface].count = 1;
weaponInfo->impactSound[impactSurface].sounds[0] = trap_S_RegisterSound(token.string, qfalse);
weaponInfo->impactSound[impactSurface].count = 1;
weaponInfo->impactSound[impactSurface].sounds[0] = trap_S_RegisterSound(token.string, qfalse);
}
}

@@ -5341,13 +5341,13 @@ void CG_WaterRipple(qhandle_t shader, vec3_t loc, vec3_t dir, int size, int life
*/
static sfxHandle_t CG_GetRandomImpactSound(int weapon, impactSurface_t surf)
{
int c = cg_weapons[weapon].impactSound[surf].count;
int c = cg_weapons[weapon].impactSound[surf].count;

if (c)
{
c = rand() % c;

return cg_weapons[weapon].impactSound[surf].sounds[c];
return cg_weapons[weapon].impactSound[surf].sounds[c];
}

return 0;
@@ -6362,11 +6362,13 @@ void CG_Bullet(vec3_t end, int sourceEntityNum, qboolean flesh, int fleshEntityN
if (fleshEntityNum == cg.snap->ps.clientNum)
{
//trap_S_StartSound(NULL, fleshEntityNum, CHAN_BODY, cgs.media.sfx_bullet_fleshhit[rand() % MAX_IMPACT_SOUNDS]);
trap_S_StartSound(NULL, fleshEntityNum, CHAN_BODY, cgs.media.sfx_bullet_stonehit[rand() % MAX_IMPACT_SOUNDS]);
trap_S_StartSound(NULL, fleshEntityNum, CHAN_BODY,
cg_weapons[cg.snap->ps.weapon].impactSound[W_IMPACT_DEFAULT].sounds[rand() % cg_weapons[cg.snap->ps.weapon].impactSound[W_IMPACT_DEFAULT].count]);
}
else
{
trap_S_StartSound(cg_entities[fleshEntityNum].currentState.origin, ENTITYNUM_WORLD, CHAN_BODY, cgs.media.sfx_bullet_stonehit[rand() % MAX_IMPACT_SOUNDS]);
trap_S_StartSound(cg_entities[fleshEntityNum].currentState.origin, ENTITYNUM_WORLD, CHAN_BODY,
cg_weapons[cg.snap->ps.weapon].impactSound[W_IMPACT_DEFAULT].sounds[rand() % cg_weapons[cg.snap->ps.weapon].impactSound[W_IMPACT_DEFAULT].count]);
}

// if we haven't dropped a blood spat in a while, check if this is a good scenario
@@ -6444,11 +6446,8 @@ void CG_Bullet(vec3_t end, int sourceEntityNum, qboolean flesh, int fleshEntityN
VectorSubtract(end, start, dist);
VectorMA(start, waterfraction, dist, end2);

trap_S_StartSound(end, -1, CHAN_AUTO, cgs.media.sfx_bullet_waterhit[rand() % 5]);

// WP_MP40: all bullet weapons have the same fx, and this stops pvs issues causing grenade explosions
CG_MissileHitWall(WP_MP40, PS_FX_WATER, end2, dir, 0, qfalse);
CG_MissileHitWall(WP_MP40, PS_FX_COMMON, end, trace.plane.normal, 0, qfalse);
CG_MissileHitWall(cg.snap->ps.weapon, PS_FX_WATER, end2, dir, 0, qfalse);
CG_MissileHitWall(cg.snap->ps.weapon, PS_FX_COMMON, end, trace.plane.normal, 0, qfalse);
}
else
{
@@ -6465,23 +6464,18 @@ void CG_Bullet(vec3_t end, int sourceEntityNum, qboolean flesh, int fleshEntityN

if (trace.fraction != trace2.fraction)
{
//trap_CM_BoxTrace( &trace2, start, end, NULL, NULL, -1, MASK_WATER );

trap_S_StartSound(end, -1, CHAN_AUTO, cgs.media.sfx_bullet_waterhit[rand() % 5]);

cg.bulletTrace = qtrue;
CG_Trace(&trace2, start, NULL, NULL, end, -1, MASK_WATER);
cg.bulletTrace = qfalse;

// WP_MP40: all bullet weapons have the same fx
CG_MissileHitWall(WP_MP40, PS_FX_WATER, trace2.endpos, trace2.plane.normal, trace2.surfaceFlags, qfalse);
CG_MissileHitWall(cg.snap->ps.weapon, PS_FX_WATER, trace2.endpos, trace2.plane.normal, trace2.surfaceFlags, qfalse);
return;
}

// better bullet marks
VectorSubtract(vec3_origin, dir, dir);
// WP_MP40: all bullet weapons have the same fx
CG_MissileHitWall(WP_MP40, PS_FX_COMMON, trace.endpos, dir, trace.surfaceFlags, qfalse);

CG_MissileHitWall(cg.snap->ps.weapon, PS_FX_COMMON, trace.endpos, dir, trace.surfaceFlags, qfalse);
}
}
}

0 comments on commit 89992b8

Please sign in to comment.
You can’t perform that action at this time.