From b69d37e30e0d6a16f07f5beff8aad5606f86b17a Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Fri, 22 Jul 2022 15:56:02 +0300 Subject: [PATCH] Fix scientist's voice pitch selection (#292) --- dlls/scientist.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dlls/scientist.cpp b/dlls/scientist.cpp index e04fabea..15acf989 100644 --- a/dlls/scientist.cpp +++ b/dlls/scientist.cpp @@ -639,6 +639,13 @@ void CScientist::HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= void CScientist::Spawn( void ) { + // We need to set it before precache so the right voice will be chosen + if( pev->body == -1 ) + { + // -1 chooses a random head + pev->body = RANDOM_LONG( 0, NUM_SCIENTIST_HEADS - 1 );// pick a head, any head + } + Precache(); SET_MODEL( ENT( pev ), "models/scientist.mdl" ); @@ -659,12 +666,6 @@ void CScientist::Spawn( void ) // White hands pev->skin = 0; - if( pev->body == -1 ) - { - // -1 chooses a random head - pev->body = RANDOM_LONG( 0, NUM_SCIENTIST_HEADS - 1 );// pick a head, any head - } - // Luther is black, make his hands black if( pev->body == HEAD_LUTHER ) pev->skin = 1; @@ -722,7 +723,7 @@ void CScientist::TalkInit() m_szGrp[TLK_MORTAL] = "SC_MORTAL"; // get voice for head - switch( pev->body % 3 ) + switch( pev->body % NUM_SCIENTIST_HEADS ) { default: case HEAD_GLASSES: