Skip to content

Commit

Permalink
Merge pull request #101 from malortie/sound-array-gargantua
Browse files Browse the repository at this point in the history
Use sound array macros (Gargantua)
  • Loading branch information
SamVanheer authored Dec 4, 2021
2 parents 99a2228 + 6f16acd commit 2da4bbf
Showing 1 changed file with 18 additions and 41 deletions.
59 changes: 18 additions & 41 deletions dlls/gargantua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ void CGargantua::StompAttack()
UTIL_TraceLine(vecStart, vecEnd, ignore_monsters, edict(), &trace);
CStomp::StompCreate(vecStart, trace.vecEndPos, 0);
UTIL_ScreenShake(pev->origin, 12.0, 100.0, 2.0, 1000);
EMIT_SOUND_DYN(edict(), CHAN_WEAPON, pStompSounds[RANDOM_LONG(0, ARRAYSIZE(pStompSounds) - 1)], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG(-10, 10));
EMIT_SOUND_DYN(edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pStompSounds), 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG(-10, 10));

UTIL_TraceLine(pev->origin, pev->origin - Vector(0, 0, 20), ignore_monsters, edict(), &trace);
if (trace.flFraction < 1.0)
Expand Down Expand Up @@ -794,8 +794,6 @@ void CGargantua::Spawn()
//=========================================================
void CGargantua::Precache()
{
int i;

PRECACHE_MODEL("models/garg.mdl");
PRECACHE_MODEL(GARG_EYE_SPRITE_NAME);
PRECACHE_MODEL(GARG_BEAM_SPRITE_NAME);
Expand All @@ -804,38 +802,17 @@ void CGargantua::Precache()
gGargGibModel = PRECACHE_MODEL(GARG_GIB_MODEL);
PRECACHE_SOUND(GARG_STOMP_BUZZ_SOUND);

for (i = 0; i < ARRAYSIZE(pAttackHitSounds); i++)
PRECACHE_SOUND((char*)pAttackHitSounds[i]);

for (i = 0; i < ARRAYSIZE(pBeamAttackSounds); i++)
PRECACHE_SOUND((char*)pBeamAttackSounds[i]);

for (i = 0; i < ARRAYSIZE(pAttackMissSounds); i++)
PRECACHE_SOUND((char*)pAttackMissSounds[i]);

for (i = 0; i < ARRAYSIZE(pRicSounds); i++)
PRECACHE_SOUND((char*)pRicSounds[i]);

for (i = 0; i < ARRAYSIZE(pFootSounds); i++)
PRECACHE_SOUND((char*)pFootSounds[i]);

for (i = 0; i < ARRAYSIZE(pIdleSounds); i++)
PRECACHE_SOUND((char*)pIdleSounds[i]);

for (i = 0; i < ARRAYSIZE(pAlertSounds); i++)
PRECACHE_SOUND((char*)pAlertSounds[i]);

for (i = 0; i < ARRAYSIZE(pPainSounds); i++)
PRECACHE_SOUND((char*)pPainSounds[i]);

for (i = 0; i < ARRAYSIZE(pAttackSounds); i++)
PRECACHE_SOUND((char*)pAttackSounds[i]);

for (i = 0; i < ARRAYSIZE(pStompSounds); i++)
PRECACHE_SOUND((char*)pStompSounds[i]);

for (i = 0; i < ARRAYSIZE(pBreatheSounds); i++)
PRECACHE_SOUND((char*)pBreatheSounds[i]);
PRECACHE_SOUND_ARRAY(pAttackHitSounds);
PRECACHE_SOUND_ARRAY(pBeamAttackSounds);
PRECACHE_SOUND_ARRAY(pAttackMissSounds);
PRECACHE_SOUND_ARRAY(pRicSounds);
PRECACHE_SOUND_ARRAY(pFootSounds);
PRECACHE_SOUND_ARRAY(pIdleSounds);
PRECACHE_SOUND_ARRAY(pAlertSounds);
PRECACHE_SOUND_ARRAY(pPainSounds);
PRECACHE_SOUND_ARRAY(pAttackSounds);
PRECACHE_SOUND_ARRAY(pStompSounds);
PRECACHE_SOUND_ARRAY(pBreatheSounds);
}


Expand All @@ -854,7 +831,7 @@ void CGargantua::TraceAttack(entvars_t* pevAttacker, float flDamage, Vector vecD
{
if (m_painSoundTime < gpGlobals->time)
{
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, pPainSounds[RANDOM_LONG(0, ARRAYSIZE(pPainSounds) - 1)], 1.0, ATTN_GARG, 0, PITCH_NORM);
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, RANDOM_SOUND_ARRAY(pPainSounds), 1.0, ATTN_GARG, 0, PITCH_NORM);
m_painSoundTime = gpGlobals->time + RANDOM_FLOAT(2.5, 4);
}
}
Expand Down Expand Up @@ -1008,10 +985,10 @@ void CGargantua::HandleAnimEvent(MonsterEvent_t* pEvent)
//UTIL_MakeVectors(pev->angles); // called by CheckTraceHullAttack
pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 100;
}
EMIT_SOUND_DYN(edict(), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG(0, ARRAYSIZE(pAttackHitSounds) - 1)], 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG(0, 15));
EMIT_SOUND_DYN(edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pAttackHitSounds), 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG(0, 15));
}
else // Play a random attack miss sound
EMIT_SOUND_DYN(edict(), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG(0, ARRAYSIZE(pAttackMissSounds) - 1)], 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG(0, 15));
EMIT_SOUND_DYN(edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pAttackMissSounds), 1.0, ATTN_NORM, 0, 50 + RANDOM_LONG(0, 15));

Vector forward;
UTIL_MakeVectorsPrivate(pev->angles, forward, NULL, NULL);
Expand All @@ -1021,7 +998,7 @@ void CGargantua::HandleAnimEvent(MonsterEvent_t* pEvent)
case GARG_AE_RIGHT_FOOT:
case GARG_AE_LEFT_FOOT:
UTIL_ScreenShake(pev->origin, 4.0, 3.0, 1.0, 750);
EMIT_SOUND_DYN(edict(), CHAN_BODY, pFootSounds[RANDOM_LONG(0, ARRAYSIZE(pFootSounds) - 1)], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG(-10, 10));
EMIT_SOUND_DYN(edict(), CHAN_BODY, RANDOM_SOUND_ARRAY(pFootSounds), 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG(-10, 10));
break;

case GARG_AE_STOMP:
Expand All @@ -1030,7 +1007,7 @@ void CGargantua::HandleAnimEvent(MonsterEvent_t* pEvent)
break;

case GARG_AE_BREATHE:
EMIT_SOUND_DYN(edict(), CHAN_VOICE, pBreatheSounds[RANDOM_LONG(0, ARRAYSIZE(pBreatheSounds) - 1)], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG(-10, 10));
EMIT_SOUND_DYN(edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY(pBreatheSounds), 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG(-10, 10));
break;

default:
Expand Down Expand Up @@ -1111,7 +1088,7 @@ void CGargantua::StartTask(Task_t* pTask)

case TASK_SOUND_ATTACK:
if (RANDOM_LONG(0, 100) < 30)
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, pAttackSounds[RANDOM_LONG(0, ARRAYSIZE(pAttackSounds) - 1)], 1.0, ATTN_GARG, 0, PITCH_NORM);
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, RANDOM_SOUND_ARRAY(pAttackSounds), 1.0, ATTN_GARG, 0, PITCH_NORM);
TaskComplete();
break;

Expand Down

0 comments on commit 2da4bbf

Please sign in to comment.