Skip to content
Permalink
Browse files

cgame: fix water impact was played + replace hitFlesh param by PS_FX_…

…FLESH define + add water explosion for bigExplosion
  • Loading branch information...
Aranud committed May 13, 2019
1 parent 89992b8 commit 9324ba0408cd4880ac7b4e03ad75aa9ce6068efd
@@ -18,6 +18,7 @@ weaponDef

default 3 "sound/weapons/airstrike/airstrike_expl_"
far "sound/weapons/airstrike/airstrike_expl_far.wav"
water "sound/weapons/grenade/gren_expl_water.wav"
}
impactMark { // each surface supports up to 1 marks shader. available surface : default, far, wood, metal, roof, gravel, glass, snow, water, flesh
default "gfx/damage/burn_med_mrk"
@@ -19,6 +19,7 @@ weaponDef

default 3 "sound/weapons/artillery/artillery_expl_"
far "sound/weapons/artillery/artillery_expl_far.wav"
water "sound/weapons/grenade/gren_expl_water.wav"
}
impactMark { // each surface supports up to 1 marks shader. available surface : default, far, wood, metal, roof, gravel, glass, snow, water, flesh
default "gfx/damage/burn_med_mrk"
@@ -52,6 +52,7 @@ weaponDef

default "sound/weapons/rocket/rocket_expl.wav"
far "sound/weapons/rocket/rocket_expl_far.wav"
water "sound/weapons/grenade/gren_expl_water.wav"
}
impactMark { // each surface supports up to 1 marks shader. available surface : default, far, wood, metal, roof, gravel, glass, snow, water, flesh
default "gfx/damage/burn_med_mrk"
@@ -52,6 +52,7 @@ weaponDef

default "sound/weapons/rocket/rocket_expl.wav"
far "sound/weapons/rocket/rocket_expl_far.wav"
water "sound/weapons/grenade/gren_expl_water.wav"
}
impactMark { // each surface supports up to 1 marks shader. available surface : default, far, wood, metal, roof, gravel, glass, snow, water, flesh
default "gfx/damage/burn_med_mrk"
@@ -52,6 +52,7 @@ weaponDef

default 3 "sound/weapons/airstrike/airstrike_expl_"
far "sound/weapons/airstrike/airstrike_expl_far.wav"
water "sound/weapons/grenade/gren_expl_water.wav"
}
impactMark { // each surface supports up to 1 marks shader. available surface : default, far, wood, metal, roof, gravel, glass, snow, water, flesh
default "gfx/damage/burn_med_mrk"
@@ -1383,7 +1383,11 @@ void CG_Effect(centity_t *cent, vec3_t origin, vec3_t dir)

if (cent->currentState.eventParm & 1) // fire
{
CG_MissileHitWall(WP_DYNAMITE, PS_FX_NONE, origin, dir, 0, qfalse);
int effect;

effect = (CG_PointContents(origin, 0) & CONTENTS_WATER) ? PS_FX_WATER : PS_FX_NONE;

CG_MissileHitWall(WP_DYNAMITE, effect, origin, dir, 0);
return;
}

@@ -2263,9 +2267,12 @@ void CG_EntityEvent(centity_t *cent, vec3_t position)
case EV_MISSILE_MISS:
{
vec3_t dir;
int effect;

effect = (CG_PointContents(position, 0) & CONTENTS_WATER) ? PS_FX_WATER : PS_FX_NONE;

ByteToDir(es->eventParm, dir);
CG_MissileHitWall(es->weapon, PS_FX_NONE, position, dir, 0, qfalse);
CG_MissileHitWall(es->weapon, effect, position, dir, 0);
if (CHECKBITWISE(GetWeaponTableData(es->weapon)->type, WEAPON_TYPE_MORTAR | WEAPON_TYPE_SET))
{
if (!es->legsAnim)
@@ -2282,15 +2289,18 @@ void CG_EntityEvent(centity_t *cent, vec3_t position)
case EV_MISSILE_MISS_LARGE:
{
vec3_t dir;
int effect;

effect = (CG_PointContents(position, 0) & CONTENTS_WATER) ? PS_FX_WATER : PS_FX_NONE;

ByteToDir(es->eventParm, dir);
if (es->weapon == WP_ARTY || es->weapon == WP_AIRSTRIKE || es->weapon == WP_SMOKE_MARKER)
{
CG_MissileHitWall(es->weapon, PS_FX_NONE, position, dir, 0, qfalse);
CG_MissileHitWall(es->weapon, effect, position, dir, 0);
}
else
{
CG_MissileHitWall(VERYBIGEXPLOSION, PS_FX_NONE, position, dir, 0, qfalse);
CG_MissileHitWall(VERYBIGEXPLOSION, effect, position, dir, 0);
}
}
break;
@@ -829,7 +829,7 @@ typedef struct weaponInfo_s
float impactMarkRadius;
sfxHandle_t impactMark[W_MAX_IMPACTS];
impactSounds_t impactSound[W_MAX_IMPACTS];
void (*impactFunc)(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, qboolean hitFlesh, float *radius, int *markDuration);
void (*impactFunc)(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, float *radius, int *markDuration);
} weaponInfo_t;

#define MAX_VIEWDAMAGE 8
@@ -2611,6 +2611,7 @@ extern vmCvar_t cg_visualEffects; ///< turn invisible (0) / visible (1) visual
#define PS_FX_NONE 0
#define PS_FX_COMMON 1
#define PS_FX_WATER 2
#define PS_FX_FLESH 3

// cg_atmospheric.c
void CG_EffectParse(const char *effectstr);
@@ -2815,7 +2816,7 @@ void CG_RegisterItemVisuals(int itemNum);

void CG_FireWeapon(centity_t *cent);

void CG_MissileHitWall(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, qboolean hitFlesh); // modified to send missilehitwall surface parameters
void CG_MissileHitWall(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags); // modified to send missilehitwall surface parameters

void CG_MissileHitWallSmall(vec3_t origin, vec3_t dir);
void CG_DrawTracer(const vec3_t start, const vec3_t finish);
@@ -1342,12 +1342,12 @@ static qboolean CG_RW_ParseImpactMark(int handle, weaponInfo_t *weaponInfo)

typedef struct hitImpact_s hitImpact_t;

void CG_MeleeImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, qboolean hitFlesh, float *radius, int *markDuration);
void CG_BulletImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, qboolean hitFlesh, float *radius, int *markDuration);
void CG_SmallExplosionImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, qboolean hitFlesh, float *radius, int *markDuration);
void CG_BigExplosionImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, qboolean hitFlesh, float *radius, int *markDuration);
void CG_MapMortarImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, qboolean hitFlesh, float *radius, int *markDuration);
void CG_DynamiteExplosionImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, qboolean hitFlesh, float *radius, int *markDuration);
void CG_MeleeImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, float *radius, int *markDuration);
void CG_BulletImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, float *radius, int *markDuration);
void CG_SmallExplosionImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, float *radius, int *markDuration);
void CG_BigExplosionImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, float *radius, int *markDuration);
void CG_MapMortarImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, float *radius, int *markDuration);
void CG_DynamiteExplosionImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, float *radius, int *markDuration);

/**
* @brief CG_RW_ParseClient
@@ -5353,9 +5353,9 @@ static sfxHandle_t CG_GetRandomImpactSound(int weapon, impactSurface_t surf)
return 0;
}

void CG_MeleeImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, qboolean hitFlesh, float *radius, int *markDuration)
void CG_MeleeImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, float *radius, int *markDuration)
{
if (!hitFlesh)
if (missileEffect != PS_FX_FLESH)
{
*radius = 1 + rand() % 2;

@@ -5365,7 +5365,7 @@ void CG_MeleeImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, in
*markDuration = cg_markTime.integer;
}

void CG_BulletImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, qboolean hitFlesh, float *radius, int *markDuration)
void CG_BulletImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, float *radius, int *markDuration)
{
*markDuration = -1;

@@ -5431,14 +5431,14 @@ void CG_BulletImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, i
}
}

void CG_SmallExplosionImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, qboolean hitFlesh, float *radius, int *markDuration)
void CG_SmallExplosionImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, float *radius, int *markDuration)
{
trace_t trace;
vec3_t tmpv;

*markDuration = cg_markTime.integer * 3;

if (CG_PointContents(origin, 0) & CONTENTS_WATER)
if (missileEffect == PS_FX_WATER)
{
VectorCopy(origin, tmpv);
tmpv[2] += 10000;
@@ -5472,14 +5472,14 @@ void CG_SmallExplosionImpact(int weapon, int missileEffect, vec3_t origin, vec3_
}
}

void CG_BigExplosionImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, qboolean hitFlesh, float *radius, int *markDuration)
void CG_BigExplosionImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, float *radius, int *markDuration)
{
trace_t trace;
vec3_t tmpv;

*markDuration = cg_markTime.integer * 3;

if (CG_PointContents(origin, 0) & CONTENTS_WATER)
if (missileEffect == PS_FX_WATER)
{
VectorCopy(origin, tmpv);
tmpv[2] += 10000;
@@ -5529,14 +5529,14 @@ void CG_BigExplosionImpact(int weapon, int missileEffect, vec3_t origin, vec3_t
}
}

void CG_MapMortarImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, qboolean hitFlesh, float *radius, int *markDuration)
void CG_MapMortarImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, float *radius, int *markDuration)
{
trace_t trace;
vec3_t tmpv;

*markDuration = cg_markTime.integer * 3;

if (CG_PointContents(origin, 0) & CONTENTS_WATER)
if (missileEffect == PS_FX_WATER)
{
VectorCopy(origin, tmpv);
tmpv[2] += 10000;
@@ -5580,7 +5580,7 @@ void CG_MapMortarImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir
}
}

void CG_DynamiteExplosionImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, qboolean hitFlesh, float *radius, int *markDuration)
void CG_DynamiteExplosionImpact(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, float *radius, int *markDuration)
{
trace_t trace;
vec3_t tmpv;
@@ -5589,7 +5589,7 @@ void CG_DynamiteExplosionImpact(int weapon, int missileEffect, vec3_t origin, ve

// biggie dynamite explosions that mean it -- dynamite is biggest explode, so it gets extra crap thrown on
// check for water/dirt spurt
if (CG_PointContents(origin, 0) & CONTENTS_WATER)
if (missileEffect == PS_FX_WATER)
{
VectorCopy(origin, tmpv);
tmpv[2] += 10000;
@@ -5651,8 +5651,10 @@ void CG_DynamiteExplosionImpact(int weapon, int missileEffect, vec3_t origin, ve
* @param[in] origin
* @param[in] dir
* @param[in] surfFlags
*
* @note modified to send missilehitwall surface parameters
*/
void CG_MissileHitWall(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags, qboolean hitFlesh) // modified to send missilehitwall surface parameters
void CG_MissileHitWall(int weapon, int missileEffect, vec3_t origin, vec3_t dir, int surfFlags)
{
impactSurface_t impactSurfaceIndex = W_IMPACT_DEFAULT;
qhandle_t mark;
@@ -5666,34 +5668,31 @@ void CG_MissileHitWall(int weapon, int missileEffect, vec3_t origin, vec3_t dir,
return;
}

if (surfFlags)
if (surfFlags & SURF_SKY)
{
if (surfFlags & SURF_SKY)
{
return;
}
return;
}

if (missileEffect == PS_FX_COMMON)
if (missileEffect == PS_FX_COMMON)
{
for (impactSurfaceIndex = 0; impactSurfaceIndex < W_MAX_IMPACTS; impactSurfaceIndex++)
{
for (impactSurfaceIndex = 0; impactSurfaceIndex < W_MAX_IMPACTS; impactSurfaceIndex++)
{
if (surfFlags & impactSurfaceTable[impactSurfaceIndex].surfaceType)
{
break;
}
}

if (impactSurfaceIndex == W_MAX_IMPACTS)
if (surfFlags & impactSurfaceTable[impactSurfaceIndex].surfaceType)
{
impactSurfaceIndex = W_IMPACT_DEFAULT;
break;
}
}
else if (missileEffect == PS_FX_WATER)

if (impactSurfaceIndex == W_MAX_IMPACTS)
{
impactSurfaceIndex = W_IMPACT_WATER;
impactSurfaceIndex = W_IMPACT_DEFAULT;
}
}
else if (hitFlesh)
else if (missileEffect == PS_FX_WATER)
{
impactSurfaceIndex = W_IMPACT_WATER;
}
else if (missileEffect == PS_FX_FLESH)
{
impactSurfaceIndex = W_IMPACT_FLESH;
}
@@ -5703,7 +5702,7 @@ void CG_MissileHitWall(int weapon, int missileEffect, vec3_t origin, vec3_t dir,
mark = cg_weapons[weapon].impactMark[impactSurfaceIndex];
radius = cg_weapons[weapon].impactMarkRadius;

cg_weapons[weapon].impactFunc(weapon, missileEffect, origin, dir, surfFlags, hitFlesh, &radius, &markDuration);
cg_weapons[weapon].impactFunc(weapon, missileEffect, origin, dir, surfFlags, &radius, &markDuration);

// no sound found for given surface, force using default one if exist
if (!sfx)
@@ -5818,11 +5817,15 @@ void CG_MissileHitPlayer(centity_t *cent, int weapon, vec3_t origin, vec3_t dir,

if (GetWeaponTableData(weapon)->type & (WEAPON_TYPE_GRENADE | WEAPON_TYPE_PANZER))
{
CG_MissileHitWall(weapon, PS_FX_NONE, origin, dir, 0, qfalse); // like the old one
int effect;

effect = (CG_PointContents(origin, 0) & CONTENTS_WATER) ? PS_FX_WATER : PS_FX_NONE;

CG_MissileHitWall(weapon, effect, origin, dir, 0); // like the old one
}
else if (GetWeaponTableData(weapon)->type & WEAPON_TYPE_MELEE)
{
CG_MissileHitWall(weapon, PS_FX_NONE, origin, dir, 0, qtrue); // this one makes the hitting fleshy sound. whee
CG_MissileHitWall(weapon, PS_FX_FLESH, origin, dir, 0); // this one makes the hitting fleshy sound. whee
}
}

@@ -6446,8 +6449,8 @@ void CG_Bullet(vec3_t end, int sourceEntityNum, qboolean flesh, int fleshEntityN
VectorSubtract(end, start, dist);
VectorMA(start, waterfraction, dist, end2);

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);
CG_MissileHitWall(cg.snap->ps.weapon, PS_FX_WATER, end2, dir, 0);
CG_MissileHitWall(cg.snap->ps.weapon, PS_FX_COMMON, end, trace.plane.normal, 0);
}
else
{
@@ -6468,14 +6471,14 @@ void CG_Bullet(vec3_t end, int sourceEntityNum, qboolean flesh, int fleshEntityN
CG_Trace(&trace2, start, NULL, NULL, end, -1, MASK_WATER);
cg.bulletTrace = qfalse;

CG_MissileHitWall(cg.snap->ps.weapon, 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);
return;
}

// better bullet marks
VectorSubtract(vec3_origin, dir, dir);

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

0 comments on commit 9324ba0

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