Skip to content

Commit

Permalink
Merge pull request #100 from malortie/sound-array-agrunt
Browse files Browse the repository at this point in the history
Use sound array macros (Alien grunt)
  • Loading branch information
SamVanheer authored Dec 4, 2021
2 parents c633af8 + 8f13d72 commit 99a2228
Showing 1 changed file with 15 additions and 31 deletions.
46 changes: 15 additions & 31 deletions dlls/agrunt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ void CAGrunt::DeathSound()
{
StopTalking();

EMIT_SOUND(ENT(pev), CHAN_VOICE, pDieSounds[RANDOM_LONG(0, ARRAYSIZE(pDieSounds) - 1)], 1.0, ATTN_NORM);
EMIT_SOUND(ENT(pev), CHAN_VOICE, RANDOM_SOUND_ARRAY(pDieSounds), 1.0, ATTN_NORM);
}

//=========================================================
Expand All @@ -349,7 +349,7 @@ void CAGrunt::AlertSound()
{
StopTalking();

EMIT_SOUND(ENT(pev), CHAN_VOICE, pAlertSounds[RANDOM_LONG(0, ARRAYSIZE(pAlertSounds) - 1)], 1.0, ATTN_NORM);
EMIT_SOUND(ENT(pev), CHAN_VOICE, RANDOM_SOUND_ARRAY(pAlertSounds), 1.0, ATTN_NORM);
}

//=========================================================
Expand All @@ -359,7 +359,7 @@ void CAGrunt::AttackSound()
{
StopTalking();

EMIT_SOUND(ENT(pev), CHAN_VOICE, pAttackSounds[RANDOM_LONG(0, ARRAYSIZE(pAttackSounds) - 1)], 1.0, ATTN_NORM);
EMIT_SOUND(ENT(pev), CHAN_VOICE, RANDOM_SOUND_ARRAY(pAttackSounds), 1.0, ATTN_NORM);
}

//=========================================================
Expand All @@ -376,7 +376,7 @@ void CAGrunt::PainSound()

StopTalking();

EMIT_SOUND(ENT(pev), CHAN_VOICE, pPainSounds[RANDOM_LONG(0, ARRAYSIZE(pPainSounds) - 1)], 1.0, ATTN_NORM);
EMIT_SOUND(ENT(pev), CHAN_VOICE, RANDOM_SOUND_ARRAY(pPainSounds), 1.0, ATTN_NORM);
}

//=========================================================
Expand Down Expand Up @@ -534,7 +534,7 @@ void CAGrunt::HandleAnimEvent(MonsterEvent_t* pEvent)
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 250;
}

EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG(0, ARRAYSIZE(pAttackHitSounds) - 1)], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5, 5));
EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pAttackHitSounds), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5, 5));

Vector vecArmPos, vecArmAng;
GetAttachment(0, vecArmPos, vecArmAng);
Expand All @@ -543,7 +543,7 @@ void CAGrunt::HandleAnimEvent(MonsterEvent_t* pEvent)
else
{
// Play a random attack miss sound
EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG(0, ARRAYSIZE(pAttackMissSounds) - 1)], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5, 5));
EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pAttackMissSounds), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5, 5));
}
}
break;
Expand All @@ -564,7 +564,7 @@ void CAGrunt::HandleAnimEvent(MonsterEvent_t* pEvent)
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * -250;
}

EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG(0, ARRAYSIZE(pAttackHitSounds) - 1)], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5, 5));
EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pAttackHitSounds), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5, 5));

Vector vecArmPos, vecArmAng;
GetAttachment(0, vecArmPos, vecArmAng);
Expand All @@ -573,7 +573,7 @@ void CAGrunt::HandleAnimEvent(MonsterEvent_t* pEvent)
else
{
// Play a random attack miss sound
EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG(0, ARRAYSIZE(pAttackMissSounds) - 1)], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5, 5));
EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pAttackMissSounds), 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5, 5));
}
}
break;
Expand Down Expand Up @@ -617,31 +617,15 @@ void CAGrunt::Spawn()
//=========================================================
void CAGrunt::Precache()
{
int i;

PRECACHE_MODEL("models/agrunt.mdl");

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

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

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

for (i = 0; i < ARRAYSIZE(pDieSounds); i++)
PRECACHE_SOUND((char*)pDieSounds[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(pAlertSounds); i++)
PRECACHE_SOUND((char*)pAlertSounds[i]);

PRECACHE_SOUND_ARRAY(pAttackHitSounds);
PRECACHE_SOUND_ARRAY(pAttackMissSounds);
PRECACHE_SOUND_ARRAY(pIdleSounds);
PRECACHE_SOUND_ARRAY(pDieSounds);
PRECACHE_SOUND_ARRAY(pPainSounds);
PRECACHE_SOUND_ARRAY(pAttackSounds);
PRECACHE_SOUND_ARRAY(pAlertSounds);

PRECACHE_SOUND("hassault/hw_shoot1.wav");

Expand Down

0 comments on commit 99a2228

Please sign in to comment.