Skip to content

Commit

Permalink
Merge pull request #102 from malortie/sound-array-islave
Browse files Browse the repository at this point in the history
Use sound array macros (Alien Slave)
  • Loading branch information
SamVanheer authored Dec 4, 2021
2 parents 2da4bbf + d8e1d3f commit b692d13
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions dlls/islave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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);
}


Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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");
}
Expand Down

0 comments on commit b692d13

Please sign in to comment.