From 8d19eeec10dc770491655b8bd1f50a3eb20c4d5d Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 7 Aug 2019 01:54:57 +0300 Subject: [PATCH] Fix shockroach sounds --- dlls/gearbox/shockroach.cpp | 12 ++++++++---- dlls/gearbox/shockroach.h | 3 +++ dlls/headcrab.cpp | 11 ++++++++--- dlls/headcrab.h | 3 +++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/dlls/gearbox/shockroach.cpp b/dlls/gearbox/shockroach.cpp index 9b258960..0aacfe21 100644 --- a/dlls/gearbox/shockroach.cpp +++ b/dlls/gearbox/shockroach.cpp @@ -27,7 +27,7 @@ #include "headcrab.h" #include "shockroach.h" -LINK_ENTITY_TO_CLASS(monster_shockroach, CShockRoach); +LINK_ENTITY_TO_CLASS(monster_shockroach, CShockRoach) TYPEDESCRIPTION CShockRoach::m_SaveData[] = { @@ -35,7 +35,7 @@ TYPEDESCRIPTION CShockRoach::m_SaveData[] = DEFINE_FIELD(CShockRoach, m_fRoachSolid, FIELD_BOOLEAN), }; -IMPLEMENT_SAVERESTORE(CShockRoach, CHeadCrab); +IMPLEMENT_SAVERESTORE(CShockRoach, CHeadCrab) const char *CShockRoach::pIdleSounds[] = { @@ -64,7 +64,7 @@ const char *CShockRoach::pDeathSounds[] = const char *CShockRoach::pBiteSounds[] = { - "shockroach/schock_bite.wav", + "shockroach/shock_bite.wav", }; @@ -207,7 +207,6 @@ void CShockRoach::StartTask(Task_t *pTask) { case TASK_RANGE_ATTACK1: { - EMIT_SOUND_DYN(edict(), CHAN_WEAPON, pAttackSounds[0], GetSoundVolume(), ATTN_IDLE, 0, GetVoicePitch()); m_IdealActivity = ACT_RANGE_ATTACK1; SetTouch(&CShockRoach::LeapTouch); break; @@ -222,3 +221,8 @@ int CShockRoach::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl // Skip headcrab's TakeDamage to avoid unwanted immunity to acid. return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); } + +void CShockRoach::AttackSound() +{ + EMIT_SOUND_DYN(edict(), CHAN_WEAPON, RANDOM_SOUND_ARRAY(pAttackSounds), GetSoundVolume(), ATTN_IDLE, 0, GetVoicePitch()); +} diff --git a/dlls/gearbox/shockroach.h b/dlls/gearbox/shockroach.h index 9a7251f7..6a60834a 100644 --- a/dlls/gearbox/shockroach.h +++ b/dlls/gearbox/shockroach.h @@ -47,6 +47,9 @@ public: float m_flBirthTime; BOOL m_fRoachSolid; + +protected: + void AttackSound(); }; diff --git a/dlls/headcrab.cpp b/dlls/headcrab.cpp index 00bd8d1d..cbdb8107 100644 --- a/dlls/headcrab.cpp +++ b/dlls/headcrab.cpp @@ -224,9 +224,7 @@ void CHeadCrab::HandleAnimEvent( MonsterEvent_t *pEvent ) vecJumpDir = Vector( gpGlobals->v_forward.x, gpGlobals->v_forward.y, gpGlobals->v_up.z ) * 350; } - int iSound = RANDOM_LONG(0,2); - if( iSound != 0 ) - EMIT_SOUND_DYN( edict(), CHAN_VOICE, pAttackSounds[iSound], GetSoundVolume(), ATTN_IDLE, 0, GetVoicePitch() ); + AttackSound(); pev->velocity = vecJumpDir; m_flNextAttack = gpGlobals->time + 2; @@ -445,6 +443,13 @@ Schedule_t *CHeadCrab::GetScheduleOfType( int Type ) return CBaseMonster::GetScheduleOfType( Type ); } +void CHeadCrab::AttackSound() +{ + int iSound = RANDOM_LONG(0,2); + if( iSound != 0 ) + EMIT_SOUND_DYN( edict(), CHAN_VOICE, pAttackSounds[iSound], GetSoundVolume(), ATTN_IDLE, 0, GetVoicePitch() ); +} + class CBabyCrab : public CHeadCrab { public: diff --git a/dlls/headcrab.h b/dlls/headcrab.h index 5b35ebc1..e3a801a9 100644 --- a/dlls/headcrab.h +++ b/dlls/headcrab.h @@ -56,6 +56,9 @@ public: static const char *pAttackSounds[]; static const char *pDeathSounds[]; static const char *pBiteSounds[]; + +protected: + virtual void AttackSound(); }; #endif