From d8e1d3f2603c27bc3010c001bee9682b2bf7103c Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Thu, 2 Dec 2021 17:59:57 -0500 Subject: [PATCH] Use random sound array. --- dlls/islave.cpp | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/dlls/islave.cpp b/dlls/islave.cpp index f2c81ea26..2f39f2a6f 100644 --- a/dlls/islave.cpp +++ b/dlls/islave.cpp @@ -239,7 +239,7 @@ void CISlave::PainSound() { if (RANDOM_LONG(0, 2) == 0) { - EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, pPainSounds[RANDOM_LONG(0, ARRAYSIZE(pPainSounds) - 1)], 1.0, ATTN_NORM, 0, m_voicePitch); + EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pPainSounds), 1.0, ATTN_NORM, 0, m_voicePitch); } } @@ -249,7 +249,7 @@ void CISlave::PainSound() void CISlave::DeathSound() { - EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, pDeathSounds[RANDOM_LONG(0, ARRAYSIZE(pDeathSounds) - 1)], 1.0, ATTN_NORM, 0, m_voicePitch); + EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pDeathSounds), 1.0, ATTN_NORM, 0, m_voicePitch); } @@ -322,12 +322,12 @@ void CISlave::HandleAnimEvent(MonsterEvent_t* pEvent) pHurt->pev->punchangle.x = 5; } // Play a random attack hit sound - EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG(0, ARRAYSIZE(pAttackHitSounds) - 1)], 1.0, ATTN_NORM, 0, m_voicePitch); + EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pAttackHitSounds), 1.0, ATTN_NORM, 0, m_voicePitch); } 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, m_voicePitch); + EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pAttackMissSounds), 1.0, ATTN_NORM, 0, m_voicePitch); } } break; @@ -342,11 +342,11 @@ void CISlave::HandleAnimEvent(MonsterEvent_t* pEvent) pHurt->pev->punchangle.z = -18; pHurt->pev->punchangle.x = 5; } - EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, pAttackHitSounds[RANDOM_LONG(0, ARRAYSIZE(pAttackHitSounds) - 1)], 1.0, ATTN_NORM, 0, m_voicePitch); + EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pAttackHitSounds), 1.0, ATTN_NORM, 0, m_voicePitch); } else { - EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG(0, ARRAYSIZE(pAttackMissSounds) - 1)], 1.0, ATTN_NORM, 0, m_voicePitch); + EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pAttackMissSounds), 1.0, ATTN_NORM, 0, m_voicePitch); } } break; @@ -546,8 +546,6 @@ void CISlave::Spawn() //========================================================= void CISlave::Precache() { - int i; - PRECACHE_MODEL("models/islave.mdl"); PRECACHE_MODEL("sprites/lgtning.spr"); PRECACHE_SOUND("debris/zap1.wav"); @@ -558,17 +556,10 @@ void CISlave::Precache() PRECACHE_SOUND("headcrab/hc_headbite.wav"); PRECACHE_SOUND("weapons/cbar_miss1.wav"); - 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(pPainSounds); i++) - PRECACHE_SOUND((char*)pPainSounds[i]); - - for (i = 0; i < ARRAYSIZE(pDeathSounds); i++) - PRECACHE_SOUND((char*)pDeathSounds[i]); + PRECACHE_SOUND_ARRAY(pAttackHitSounds); + PRECACHE_SOUND_ARRAY(pAttackMissSounds); + PRECACHE_SOUND_ARRAY(pPainSounds); + PRECACHE_SOUND_ARRAY(pDeathSounds); UTIL_PrecacheOther("test_effect"); }