From 2113410f800c8c102947f27d597cd489e60c3824 Mon Sep 17 00:00:00 2001 From: arbabf Date: Sat, 13 Apr 2024 00:43:14 +1000 Subject: [PATCH 1/3] Add random spawn type for env_headcrabcanister --- .../game/server/hl2/env_headcrabcanister.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sp/src/game/server/hl2/env_headcrabcanister.cpp b/sp/src/game/server/hl2/env_headcrabcanister.cpp index e94fe3f1..139b7b08 100644 --- a/sp/src/game/server/hl2/env_headcrabcanister.cpp +++ b/sp/src/game/server/hl2/env_headcrabcanister.cpp @@ -33,6 +33,9 @@ ConVar sk_env_headcrabcanister_shake_radius( "sk_env_headcrabcanister_shake_radi ConVar sk_env_headcrabcanister_shake_radius_vehicle( "sk_env_headcrabcanister_shake_radius_vehicle", "2500" ); #define ENV_HEADCRABCANISTER_TRAIL_TIME 3.0f +#ifdef MAPBASE +#define RANDOM_CRAB_TYPE 3 +#endif //----------------------------------------------------------------------------- // Spawn flags @@ -258,7 +261,22 @@ void CEnvHeadcrabCanister::Precache( void ) PrecacheScriptSound( "HeadcrabCanister.SkyboxExplosion" ); PrecacheScriptSound( "HeadcrabCanister.Open" ); +#ifdef MAPBASE + if (m_nHeadcrabType != RANDOM_CRAB_TYPE) + { + UTIL_PrecacheOther( s_pHeadcrabClass[m_nHeadcrabType] ); + } + else + { + // precache all the headcrabs if we're spawning random species + for (int i = 0; i < ARRAYSIZE(s_pHeadcrabClass); i++) + { + UTIL_PrecacheOther( s_pHeadcrabClass[i] ); + } + } +#else UTIL_PrecacheOther( s_pHeadcrabClass[m_nHeadcrabType] ); +#endif } @@ -733,7 +751,17 @@ void CEnvHeadcrabCanister::HeadcrabCanisterSpawnHeadcrabThink() int nHeadCrabAttachment = LookupAttachment( "headcrab" ); if ( GetAttachment( nHeadCrabAttachment, vecSpawnPosition, vecSpawnAngles ) ) { +#ifdef MAPBASE + int iHeadcrabType = m_nHeadcrabType; + if (m_nHeadcrabType == RANDOM_CRAB_TYPE) + { + iHeadcrabType = RandomInt( 0, ARRAYSIZE(s_pHeadcrabClass) - 1 ); + } + + CBaseEntity *pEnt = CreateEntityByName( s_pHeadcrabClass[iHeadcrabType] ); +#else CBaseEntity *pEnt = CreateEntityByName( s_pHeadcrabClass[m_nHeadcrabType] ); +#endif CBaseHeadcrab *pHeadCrab = assert_cast(pEnt); // Necessary to get it to eject properly (don't allow the NPC From f370074d10ccdeaaad0ee311cc13cc5261529efa Mon Sep 17 00:00:00 2001 From: arbabf Date: Sat, 13 Apr 2024 00:46:36 +1000 Subject: [PATCH 2/3] Fix spacing to be more consistent --- sp/src/game/server/hl2/env_headcrabcanister.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sp/src/game/server/hl2/env_headcrabcanister.cpp b/sp/src/game/server/hl2/env_headcrabcanister.cpp index 139b7b08..15a39f0d 100644 --- a/sp/src/game/server/hl2/env_headcrabcanister.cpp +++ b/sp/src/game/server/hl2/env_headcrabcanister.cpp @@ -262,14 +262,14 @@ void CEnvHeadcrabCanister::Precache( void ) PrecacheScriptSound( "HeadcrabCanister.Open" ); #ifdef MAPBASE - if (m_nHeadcrabType != RANDOM_CRAB_TYPE) + if ( m_nHeadcrabType != RANDOM_CRAB_TYPE ) { UTIL_PrecacheOther( s_pHeadcrabClass[m_nHeadcrabType] ); } else { // precache all the headcrabs if we're spawning random species - for (int i = 0; i < ARRAYSIZE(s_pHeadcrabClass); i++) + for ( int i = 0; i < ARRAYSIZE( s_pHeadcrabClass ); i++ ) { UTIL_PrecacheOther( s_pHeadcrabClass[i] ); } @@ -753,9 +753,9 @@ void CEnvHeadcrabCanister::HeadcrabCanisterSpawnHeadcrabThink() { #ifdef MAPBASE int iHeadcrabType = m_nHeadcrabType; - if (m_nHeadcrabType == RANDOM_CRAB_TYPE) + if ( m_nHeadcrabType == RANDOM_CRAB_TYPE ) { - iHeadcrabType = RandomInt( 0, ARRAYSIZE(s_pHeadcrabClass) - 1 ); + iHeadcrabType = RandomInt( 0, ARRAYSIZE( s_pHeadcrabClass ) - 1 ); } CBaseEntity *pEnt = CreateEntityByName( s_pHeadcrabClass[iHeadcrabType] ); From 2c001ff2595a3b6414b78027f170ca8ee2291916 Mon Sep 17 00:00:00 2001 From: arbabf Date: Sat, 13 Apr 2024 16:10:01 +1000 Subject: [PATCH 3/3] Change RANDOM_CRAB_TYPE to -1 --- sp/src/game/server/hl2/env_headcrabcanister.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sp/src/game/server/hl2/env_headcrabcanister.cpp b/sp/src/game/server/hl2/env_headcrabcanister.cpp index 15a39f0d..4cf7fffb 100644 --- a/sp/src/game/server/hl2/env_headcrabcanister.cpp +++ b/sp/src/game/server/hl2/env_headcrabcanister.cpp @@ -34,7 +34,7 @@ ConVar sk_env_headcrabcanister_shake_radius_vehicle( "sk_env_headcrabcanister_sh #define ENV_HEADCRABCANISTER_TRAIL_TIME 3.0f #ifdef MAPBASE -#define RANDOM_CRAB_TYPE 3 +#define RANDOM_CRAB_TYPE -1 #endif //-----------------------------------------------------------------------------