Skip to content
Permalink
Browse files

game: optimize arty/airstrike sound before impact think and add morta…

…r sound before impact (same as artillery)
  • Loading branch information...
Aranud committed May 13, 2019
1 parent 71798db commit c376f111552de7bec5b22920d796f10c6dd81630
Showing with 34 additions and 49 deletions.
  1. +1 −1 etmain/weapons/axis_mortar_set.weap
  2. +1 −1 etmain/weapons/mortar_set.weap
  3. +28 −16 src/game/g_missile.c
  4. +4 −31 src/game/g_weapon.c
@@ -45,7 +45,7 @@ weaponDef
impactFunction "SmallExplosionImpact" // supports "MeleeImpact", "BulletImpact", "SmallExplosionImpact", "BigExplosionImpact", "MapMortarImpact" and "DynamiteExplosionImpact"

impactSound {
default 4 "sound/weapons/mortar/mortar_expl"
default "sound/weapons/mortar/mortar_expl.wav"
far "sound/weapons/mortar/mortar_expl_far.wav"
water "sound/weapons/grenade/gren_expl_water.wav"
}
@@ -44,7 +44,7 @@ weaponDef
impactSoundVolume 127
impactMarkRadius 64
impactSound {
default 4 "sound/weapons/mortar/mortar_expl"
default "sound/weapons/mortar/mortar_expl.wav"
far "sound/weapons/mortar/mortar_expl_far.wav"
water "sound/weapons/grenade/gren_expl_water.wav"
}
@@ -576,7 +576,8 @@ void G_RunMissile(gentity_t *ent)
// ignoring interactions with the missile owner
trap_Trace(&tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, ent->r.ownerNum, ent->clipmask);

if (CHECKBITWISE(GetWeaponTableData(ent->s.weapon)->type, WEAPON_TYPE_MORTAR | WEAPON_TYPE_SET) && ent->count2 == 1)
if ((CHECKBITWISE(GetWeaponTableData(ent->s.weapon)->type, WEAPON_TYPE_MORTAR | WEAPON_TYPE_SET) ||
ent->s.weapon == WP_AIRSTRIKE || ent->s.weapon == WP_ARTY) && ent->count2 == 1)
{
if (ent->r.currentOrigin[2] > origin[2] && origin[2] - BG_GetGroundHeightAtPoint(origin) < 512)
{
@@ -590,27 +591,38 @@ void G_RunMissile(gentity_t *ent)

if (mortar_tr.fraction != 1.f)
{
gentity_t *tent;
int i;

impactpos[2] = BG_GetGroundHeightAtPoint(impactpos);
i = rand() % 3;

tent = G_TempEntity(impactpos, EV_MORTAR_IMPACT);
tent->s.clientNum = ent->r.ownerNum;
tent->r.svFlags |= SVF_BROADCAST;
// Sound effect for spotter round, had to do this as half-second bomb warning
G_AddEvent(ent, EV_GENERAL_SOUND_VOLUME, GAMESOUND_WPN_ARTILLERY_FLY_1 + i);
ent->s.onFireStart = 255; // sound control

ent->count2 = 2;
if ((CHECKBITWISE(GetWeaponTableData(ent->s.weapon)->type, WEAPON_TYPE_MORTAR | WEAPON_TYPE_SET)))
{
gentity_t *tent;

/*{
gentity_t *tent;
impactpos[2] = BG_GetGroundHeightAtPoint(impactpos);

tent = G_TempEntity( origin, EV_RAILTRAIL );
VectorCopy( impactpos, tent->s.origin2 );
tent->s.dmgFlags = 0;
tent = G_TempEntity(impactpos, EV_MORTAR_IMPACT);
tent->s.clientNum = ent->r.ownerNum;
tent->r.svFlags |= SVF_BROADCAST;

ent->count2 = 2;

/*{
gentity_t *tent;
tent = G_TempEntity( origin, EV_RAILTRAIL );
VectorCopy( ent->r.currentOrigin, tent->s.origin2 );
tent->s.dmgFlags = 0;
}*/
tent = G_TempEntity( origin, EV_RAILTRAIL );
VectorCopy( impactpos, tent->s.origin2 );
tent->s.dmgFlags = 0;
tent = G_TempEntity( origin, EV_RAILTRAIL );
VectorCopy( ent->r.currentOrigin, tent->s.origin2 );
tent->s.dmgFlags = 0;
}*/
}
}
}
}
@@ -2833,33 +2833,6 @@ void weapon_callAirStrike(gentity_t *ent)
}
}

/**
* @brief Sound effect for spotter round, had to do this as half-second bomb warning
* @details Sound is played when the bomb is close enough to the ground
* @param[in,out] ent
*/
void artilleryThink(gentity_t *ent)
{
float groundHeight;

groundHeight = BG_GetGroundHeightAtPoint(ent->r.currentOrigin);

// are we enough close to the ground to produce shelling sound
if (ent->r.currentOrigin[2] - groundHeight < 1024 /*4096*/)
{
int i;

i = rand() % 3;

G_AddEvent(ent, EV_GENERAL_SOUND_VOLUME, GAMESOUND_WPN_ARTILLERY_FLY_1 + i);
ent->s.onFireStart = 255; // sound control

return;
}

ent->nextthink = level.time + FRAMETIME;
}

/**
* @brief Makes smoke disappear after a bit (just unregisters stuff)
* @param[out] ent
@@ -2947,8 +2920,8 @@ void artillerySpotterThink(gentity_t *ent)
// next bomb drop, add randomness
ent->nextthink = bomb->nextthink + crandom() * 800;

// overwrite, spotter is thinking for next bomb so let think for shelling sound
bomb->nextthink = level.time + FRAMETIME;
// overwrite
bomb->nextthink = 0;

if (bomboffset[2] >= BG_GetSkyHeightAtPoint(bomboffset))
{
@@ -4076,7 +4049,7 @@ weapFireTable_t weapFireTable[] =
{ WP_STEN, Bullet_Fire, NULL, NULL, ET_GENERAL, EF_NONE, SVF_NONE, CONTENTS_NONE, TR_LINEAR, 0, { { 0, 0, 0 }, { 0, 0, 0 } }, MASK_SHOT, 0, 0, 0, 0, },
{ WP_MEDIC_SYRINGE, Weapon_Syringe, NULL, NULL, ET_GENERAL, EF_NONE, SVF_NONE, CONTENTS_NONE, TR_LINEAR, 0, { { 0, 0, 0 }, { 0, 0, 0 } }, MASK_SHOT, 0, 0, 0, 0, },
{ WP_AMMO, Weapon_MagicAmmo, MagicSink, NULL, ET_ITEM, EF_NONE, SVF_NONE, CONTENTS_NONE, TR_GRAVITY, 0, { { 0, 0, 0 }, { 0, 0, 0 } }, MASK_SHOT, 30000, 0, 0, 0, },
{ WP_ARTY, NULL, artilleryThink, G_ArtilleryExplode, ET_MISSILE, EF_NONE, SVF_BROADCAST, CONTENTS_NONE, TR_GRAVITY, 1, { { 0, 0, 0 }, { 0, 0, 0 } }, MASK_MISSILESHOT, 2000, 2, 0, 0, },
{ WP_ARTY, NULL, NULL, G_ArtilleryExplode, ET_MISSILE, EF_NONE, SVF_BROADCAST, CONTENTS_NONE, TR_GRAVITY, 1, { { 0, 0, 0 }, { 0, 0, 0 } }, MASK_MISSILESHOT, 2000, 2, 0, 0, },
{ WP_SILENCER, Bullet_Fire, NULL, NULL, ET_GENERAL, EF_NONE, SVF_NONE, CONTENTS_NONE, TR_LINEAR, 0, { { 0, 0, 0 }, { 0, 0, 0 } }, MASK_SHOT, 0, 0, 0, 0, },
{ WP_DYNAMITE, weapon_grenadelauncher_fire, DynaSink, DynaFree, ET_MISSILE, EF_BOUNCE_HALF | EF_BOUNCE, SVF_BROADCAST, CONTENTS_CORPSE, TR_GRAVITY, -50, { { -12.f, -12.f, 0.f }, { 12.f, 12.f, 20.f } }, MASK_MISSILESHOT, 15000, 0, 5, 16500, },
{ WP_SMOKETRAIL, NULL, artilleryGoAway, NULL, ET_MISSILE, EF_BOUNCE, SVF_NONE, CONTENTS_NONE, TR_GRAVITY, 1, { { 0, 0, 0 }, { 0, 0, 0 } }, MASK_MISSILESHOT, 1000, 0, 0, 0, },
@@ -4123,7 +4096,7 @@ weapFireTable_t weapFireTable[] =
{ WP_MORTAR2_SET, weapon_mortar_fire, NULL, NULL, ET_MISSILE, EF_NONE, SVF_BROADCAST, CONTENTS_NONE, TR_GRAVITY, -50, { { -4.f, -4.f, 0.f }, { 4.f, 4.f, 6.f } }, MASK_MISSILESHOT, 0, 0, 0, 0, },
{ WP_BAZOOKA, weapon_antitank_fire, G_ExplodeMissile, NULL, ET_MISSILE, EF_NONE, SVF_BROADCAST, CONTENTS_NONE, TR_LINEAR, -50, { { 0, 0, 0 }, { 0, 0, 0 } }, MASK_MISSILESHOT, 20000, 4, 0, 0, },
{ WP_MP34, Bullet_Fire, NULL, NULL, ET_GENERAL, EF_NONE, SVF_NONE, CONTENTS_NONE, TR_LINEAR, 0, { { 0, 0, 0 }, { 0, 0, 0 } }, MASK_SHOT, 0, 0, 0, 0, },
{ WP_AIRSTRIKE, NULL, artilleryThink, NULL, ET_MISSILE, EF_NONE, SVF_BROADCAST, CONTENTS_NONE, TR_GRAVITY, 1, { { 0, 0, 0 }, { 0, 0, 0 } }, MASK_MISSILESHOT, FRAMETIME, 2, 0, 0, },
{ WP_AIRSTRIKE, NULL, NULL, NULL, ET_MISSILE, EF_NONE, SVF_BROADCAST, CONTENTS_NONE, TR_GRAVITY, 1, { { 0, 0, 0 }, { 0, 0, 0 } }, MASK_MISSILESHOT, 0, 2, 0, 0, },
};
// *INDENT-ON*

0 comments on commit c376f11

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