From 41233cb475750a09e4a571909d069a9bb096a8be Mon Sep 17 00:00:00 2001 From: Wikot235 <149392035+Wikot235@users.noreply.github.com> Date: Sat, 27 Jul 2024 23:49:31 +0200 Subject: [PATCH 1/6] Added Melee attack keyvalue --- sp/src/game/server/hl2/npc_BaseZombie.cpp | 1 + sp/src/game/server/hl2/npc_BaseZombie.h | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sp/src/game/server/hl2/npc_BaseZombie.cpp b/sp/src/game/server/hl2/npc_BaseZombie.cpp index f751d09a..1c5cde10 100644 --- a/sp/src/game/server/hl2/npc_BaseZombie.cpp +++ b/sp/src/game/server/hl2/npc_BaseZombie.cpp @@ -211,6 +211,7 @@ BEGIN_DATADESC( CNPC_BaseZombie ) DEFINE_FIELD( m_fIsTorso, FIELD_BOOLEAN ), #ifdef MAPBASE DEFINE_KEYFIELD( m_fIsHeadless, FIELD_BOOLEAN, "Headless" ), + DEFINE_KEYFIELD( m_flMeleeReach, FIELD_FLOAT, "MeleeReach" ), #else DEFINE_FIELD( m_fIsHeadless, FIELD_BOOLEAN ), #endif diff --git a/sp/src/game/server/hl2/npc_BaseZombie.h b/sp/src/game/server/hl2/npc_BaseZombie.h index fb17f037..aa7541c1 100644 --- a/sp/src/game/server/hl2/npc_BaseZombie.h +++ b/sp/src/game/server/hl2/npc_BaseZombie.h @@ -20,8 +20,6 @@ #define ENVELOPE_CONTROLLER (CSoundEnvelopeController::GetController()) -#define ZOMBIE_MELEE_REACH 55 - extern int AE_ZOMBIE_ATTACK_RIGHT; extern int AE_ZOMBIE_ATTACK_LEFT; extern int AE_ZOMBIE_ATTACK_BOTH; @@ -141,7 +139,7 @@ public: } int MeleeAttack1Conditions ( float flDot, float flDist ); - virtual float GetClawAttackRange() const { return ZOMBIE_MELEE_REACH; } + virtual float GetClawAttackRange() const { return m_flMeleeReach; } // No range attacks int RangeAttack1Conditions ( float flDot, float flDist ) { return( 0 ); } @@ -257,6 +255,8 @@ protected: float m_flNextFlinch; + float m_flMeleeReach; + bool m_bHeadShot; // Used to determine the survival of our crab beyond our death. // From a736b0f96a72136223465cbca9f22d4590f38c14 Mon Sep 17 00:00:00 2001 From: Wikot235 <149392035+Wikot235@users.noreply.github.com> Date: Sun, 28 Jul 2024 14:11:06 +0200 Subject: [PATCH 2/6] Added new spawnflag --- sp/src/game/server/hl2/npc_BaseZombie.cpp | 2 +- sp/src/game/server/hl2/npc_BaseZombie.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sp/src/game/server/hl2/npc_BaseZombie.cpp b/sp/src/game/server/hl2/npc_BaseZombie.cpp index 1c5cde10..0799fcf6 100644 --- a/sp/src/game/server/hl2/npc_BaseZombie.cpp +++ b/sp/src/game/server/hl2/npc_BaseZombie.cpp @@ -787,7 +787,7 @@ bool CNPC_BaseZombie::ShouldBecomeTorso( const CTakeDamageInfo &info, float flDa HeadcrabRelease_t CNPC_BaseZombie::ShouldReleaseHeadcrab( const CTakeDamageInfo &info, float flDamageThreshold ) { #ifdef MAPBASE - if ( m_iHealth <= 0 && !m_fIsHeadless ) + if ( m_iHealth <= 0 && !m_fIsHeadless && !HasSpawnFlags(SF_ZOMBIE_NO_HEADCRAB_SPAWN)) #else if ( m_iHealth <= 0 ) #endif diff --git a/sp/src/game/server/hl2/npc_BaseZombie.h b/sp/src/game/server/hl2/npc_BaseZombie.h index aa7541c1..16ca0db9 100644 --- a/sp/src/game/server/hl2/npc_BaseZombie.h +++ b/sp/src/game/server/hl2/npc_BaseZombie.h @@ -43,6 +43,7 @@ extern int AE_ZOMBIE_POUND; #ifdef MAPBASE #define SF_ZOMBIE_NO_TORSO ( 1 << 15 ) +#define SF_ZOMBIE_NO_HEADCRAB_SPAWN ( 1 << 16 ) #endif From 959af0b130dfa29f74c34a60874a555c1dec2952 Mon Sep 17 00:00:00 2001 From: Wikot235 <149392035+Wikot235@users.noreply.github.com> Date: Sun, 5 Jan 2025 16:13:16 +0100 Subject: [PATCH 3/6] m_iMeleeReach now defaults to 55 --- sp/src/game/server/hl2/npc_BaseZombie.cpp | 6 +++++- sp/src/game/server/hl2/npc_BaseZombie.h | 21 +++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/sp/src/game/server/hl2/npc_BaseZombie.cpp b/sp/src/game/server/hl2/npc_BaseZombie.cpp index 0799fcf6..6e389def 100644 --- a/sp/src/game/server/hl2/npc_BaseZombie.cpp +++ b/sp/src/game/server/hl2/npc_BaseZombie.cpp @@ -211,7 +211,7 @@ BEGIN_DATADESC( CNPC_BaseZombie ) DEFINE_FIELD( m_fIsTorso, FIELD_BOOLEAN ), #ifdef MAPBASE DEFINE_KEYFIELD( m_fIsHeadless, FIELD_BOOLEAN, "Headless" ), - DEFINE_KEYFIELD( m_flMeleeReach, FIELD_FLOAT, "MeleeReach" ), + DEFINE_KEYFIELD( m_iMeleeReach, FIELD_INTEGER, "MeleeReach" ), #else DEFINE_FIELD( m_fIsHeadless, FIELD_BOOLEAN ), #endif @@ -257,6 +257,10 @@ CNPC_BaseZombie::CNPC_BaseZombie() // moan loop. m_iMoanSound = g_numZombies; +#ifdef MAPBASE + m_iMeleeReach = 55; +#endif + g_numZombies++; } diff --git a/sp/src/game/server/hl2/npc_BaseZombie.h b/sp/src/game/server/hl2/npc_BaseZombie.h index 16ca0db9..b515144f 100644 --- a/sp/src/game/server/hl2/npc_BaseZombie.h +++ b/sp/src/game/server/hl2/npc_BaseZombie.h @@ -20,6 +20,10 @@ #define ENVELOPE_CONTROLLER (CSoundEnvelopeController::GetController()) +#ifndef MAPBASE + #define ZOMBIE_MELEE_REACH 55 +#endif + extern int AE_ZOMBIE_ATTACK_RIGHT; extern int AE_ZOMBIE_ATTACK_LEFT; extern int AE_ZOMBIE_ATTACK_BOTH; @@ -42,8 +46,8 @@ extern int AE_ZOMBIE_POUND; #define ZOMBIE_BLOOD_BITE 3 #ifdef MAPBASE -#define SF_ZOMBIE_NO_TORSO ( 1 << 15 ) -#define SF_ZOMBIE_NO_HEADCRAB_SPAWN ( 1 << 16 ) + #define SF_ZOMBIE_NO_TORSO ( 1 << 15 ) + #define SF_ZOMBIE_NO_HEADCRAB_SPAWN ( 1 << 16 ) #endif @@ -140,7 +144,14 @@ public: } int MeleeAttack1Conditions ( float flDot, float flDist ); - virtual float GetClawAttackRange() const { return m_flMeleeReach; } + virtual float GetClawAttackRange() const + { +#ifdef MAPBASE + return m_iMeleeReach; +#else + return ZOMBIE_MELEE_REACH; +#endif + } // No range attacks int RangeAttack1Conditions ( float flDot, float flDist ) { return( 0 ); } @@ -256,7 +267,9 @@ protected: float m_flNextFlinch; - float m_flMeleeReach; +#ifdef MAPBASE + int m_iMeleeReach; +#endif bool m_bHeadShot; // Used to determine the survival of our crab beyond our death. From 99c94f058b9c9b461a562cf51b8f3d9d3dcee75a Mon Sep 17 00:00:00 2001 From: Wikot235 <149392035+Wikot235@users.noreply.github.com> Date: Mon, 6 Jan 2025 16:54:54 +0100 Subject: [PATCH 4/6] Added more customizability --- sp/src/game/server/hl2/npc_BaseZombie.cpp | 25 ++++++++++++++++++----- sp/src/game/server/hl2/npc_BaseZombie.h | 2 ++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/sp/src/game/server/hl2/npc_BaseZombie.cpp b/sp/src/game/server/hl2/npc_BaseZombie.cpp index 6e389def..0c392f74 100644 --- a/sp/src/game/server/hl2/npc_BaseZombie.cpp +++ b/sp/src/game/server/hl2/npc_BaseZombie.cpp @@ -85,9 +85,16 @@ envelopePoint_t envDefaultZombieMoanVolume[] = #define ZOMBIE_FARTHEST_PHYSICS_OBJECT 40.0*12.0 #define ZOMBIE_PHYSICS_SEARCH_DEPTH 100 +#ifndef MAPBASE + // Don't swat objects unless player is closer than this. #define ZOMBIE_PLAYER_MAX_SWAT_DIST 1000 +// The heaviest physics object that a zombie should try to swat. (kg) +#define ZOMBIE_MAX_PHYSOBJ_MASS 60 + +#endif + // // How much health a Zombie torso gets when a whole zombie is broken // It's whole zombie's MAX Health * this value @@ -98,10 +105,6 @@ envelopePoint_t envDefaultZombieMoanVolume[] = // try to release its headcrab. #define ZOMBIE_RELEASE_HEALTH_FACTOR 0.5 -// -// The heaviest physics object that a zombie should try to swat. (kg) -#define ZOMBIE_MAX_PHYSOBJ_MASS 60 - // // Zombie tries to get this close to a physics object's origin to swat it #define ZOMBIE_PHYSOBJ_SWATDIST 80 @@ -212,6 +215,8 @@ BEGIN_DATADESC( CNPC_BaseZombie ) #ifdef MAPBASE DEFINE_KEYFIELD( m_fIsHeadless, FIELD_BOOLEAN, "Headless" ), DEFINE_KEYFIELD( m_iMeleeReach, FIELD_INTEGER, "MeleeReach" ), + DEFINE_KEYFIELD( m_iMaxPlayerDistToSwat, FIELD_INTEGER, "MaxPlayerDistToSwat" ), + DEFINE_KEYFIELD( m_iMaxObjWeightToSwat, FIELD_INTEGER, "MaxObjWeightToSwat" ), #else DEFINE_FIELD( m_fIsHeadless, FIELD_BOOLEAN ), #endif @@ -259,6 +264,8 @@ CNPC_BaseZombie::CNPC_BaseZombie() #ifdef MAPBASE m_iMeleeReach = 55; + m_iMaxPlayerDistToSwat = 1000; + m_iMaxObjWeightToSwat = 60; #endif g_numZombies++; @@ -300,7 +307,11 @@ bool CNPC_BaseZombie::FindNearestPhysicsObject( int iMaxMass ) float dist = VectorNormalize(vecDirToEnemy); vecDirToEnemy.z = 0; - if( dist > ZOMBIE_PLAYER_MAX_SWAT_DIST ) +#ifndef MAPBASE + if (dist > ZOMBIE_PLAYER_MAX_SWAT_DIST) +#else + if (dist > m_iMaxPlayerDistToSwat) +#endif { // Player is too far away. Don't bother // trying to swat anything at them until @@ -2159,7 +2170,11 @@ void CNPC_BaseZombie::GatherConditions( void ) // between him and the object he's heading for already. if( gpGlobals->curtime >= m_flNextSwatScan && (m_hPhysicsEnt == NULL) ) { +#ifdef MAPBASE + FindNearestPhysicsObject( m_iMaxObjWeightToSwat ); +#else FindNearestPhysicsObject( ZOMBIE_MAX_PHYSOBJ_MASS ); +#endif m_flNextSwatScan = gpGlobals->curtime + 2.0; } } diff --git a/sp/src/game/server/hl2/npc_BaseZombie.h b/sp/src/game/server/hl2/npc_BaseZombie.h index b515144f..c6d309cb 100644 --- a/sp/src/game/server/hl2/npc_BaseZombie.h +++ b/sp/src/game/server/hl2/npc_BaseZombie.h @@ -269,6 +269,8 @@ protected: #ifdef MAPBASE int m_iMeleeReach; + int m_iMaxPlayerDistToSwat; + int m_iMaxObjWeightToSwat; #endif bool m_bHeadShot; // Used to determine the survival of our crab beyond our death. From 0921f7409be0557011d41ca626bbfa13afdaed0a Mon Sep 17 00:00:00 2001 From: Wikot235 <149392035+Wikot235@users.noreply.github.com> Date: Wed, 8 Jan 2025 21:22:06 +0100 Subject: [PATCH 5/6] Fixed miscellaneous things. --- sp/src/game/server/hl2/npc_BaseZombie.cpp | 21 +++++++++------------ sp/src/game/server/hl2/npc_BaseZombie.h | 6 ++---- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/sp/src/game/server/hl2/npc_BaseZombie.cpp b/sp/src/game/server/hl2/npc_BaseZombie.cpp index 0c392f74..bb237242 100644 --- a/sp/src/game/server/hl2/npc_BaseZombie.cpp +++ b/sp/src/game/server/hl2/npc_BaseZombie.cpp @@ -85,16 +85,9 @@ envelopePoint_t envDefaultZombieMoanVolume[] = #define ZOMBIE_FARTHEST_PHYSICS_OBJECT 40.0*12.0 #define ZOMBIE_PHYSICS_SEARCH_DEPTH 100 -#ifndef MAPBASE - // Don't swat objects unless player is closer than this. #define ZOMBIE_PLAYER_MAX_SWAT_DIST 1000 -// The heaviest physics object that a zombie should try to swat. (kg) -#define ZOMBIE_MAX_PHYSOBJ_MASS 60 - -#endif - // // How much health a Zombie torso gets when a whole zombie is broken // It's whole zombie's MAX Health * this value @@ -105,6 +98,10 @@ envelopePoint_t envDefaultZombieMoanVolume[] = // try to release its headcrab. #define ZOMBIE_RELEASE_HEALTH_FACTOR 0.5 +// +// The heaviest physics object that a zombie should try to swat. (kg) +#define ZOMBIE_MAX_PHYSOBJ_MASS 60 + // // Zombie tries to get this close to a physics object's origin to swat it #define ZOMBIE_PHYSOBJ_SWATDIST 80 @@ -216,7 +213,7 @@ BEGIN_DATADESC( CNPC_BaseZombie ) DEFINE_KEYFIELD( m_fIsHeadless, FIELD_BOOLEAN, "Headless" ), DEFINE_KEYFIELD( m_iMeleeReach, FIELD_INTEGER, "MeleeReach" ), DEFINE_KEYFIELD( m_iMaxPlayerDistToSwat, FIELD_INTEGER, "MaxPlayerDistToSwat" ), - DEFINE_KEYFIELD( m_iMaxObjWeightToSwat, FIELD_INTEGER, "MaxObjWeightToSwat" ), + DEFINE_KEYFIELD( m_iMaxObjMassToSwat, FIELD_INTEGER, "MaxObjMassToSwat" ), #else DEFINE_FIELD( m_fIsHeadless, FIELD_BOOLEAN ), #endif @@ -263,9 +260,9 @@ CNPC_BaseZombie::CNPC_BaseZombie() m_iMoanSound = g_numZombies; #ifdef MAPBASE - m_iMeleeReach = 55; - m_iMaxPlayerDistToSwat = 1000; - m_iMaxObjWeightToSwat = 60; + m_iMeleeReach = ZOMBIE_MELEE_REACH; + m_iMaxPlayerDistToSwat = ZOMBIE_PLAYER_MAX_SWAT_DIST; + m_iMaxObjMassToSwat = ZOMBIE_MAX_PHYSOBJ_MASS; #endif g_numZombies++; @@ -2171,7 +2168,7 @@ void CNPC_BaseZombie::GatherConditions( void ) if( gpGlobals->curtime >= m_flNextSwatScan && (m_hPhysicsEnt == NULL) ) { #ifdef MAPBASE - FindNearestPhysicsObject( m_iMaxObjWeightToSwat ); + FindNearestPhysicsObject(m_iMaxObjMassToSwat); #else FindNearestPhysicsObject( ZOMBIE_MAX_PHYSOBJ_MASS ); #endif diff --git a/sp/src/game/server/hl2/npc_BaseZombie.h b/sp/src/game/server/hl2/npc_BaseZombie.h index c6d309cb..789d7d9b 100644 --- a/sp/src/game/server/hl2/npc_BaseZombie.h +++ b/sp/src/game/server/hl2/npc_BaseZombie.h @@ -20,9 +20,7 @@ #define ENVELOPE_CONTROLLER (CSoundEnvelopeController::GetController()) -#ifndef MAPBASE - #define ZOMBIE_MELEE_REACH 55 -#endif +#define ZOMBIE_MELEE_REACH 55 extern int AE_ZOMBIE_ATTACK_RIGHT; extern int AE_ZOMBIE_ATTACK_LEFT; @@ -270,7 +268,7 @@ protected: #ifdef MAPBASE int m_iMeleeReach; int m_iMaxPlayerDistToSwat; - int m_iMaxObjWeightToSwat; + int m_iMaxObjMassToSwat; #endif bool m_bHeadShot; // Used to determine the survival of our crab beyond our death. From aa31835f36fdd50568a1110a64981b044382f2fc Mon Sep 17 00:00:00 2001 From: "ALLEN-PC\\acj30" Date: Thu, 9 Jan 2025 12:50:19 -0600 Subject: [PATCH 6/6] Change new CNPC_BaseZombie customization vars to match actual data types --- sp/src/game/server/hl2/npc_BaseZombie.cpp | 10 +++++----- sp/src/game/server/hl2/npc_BaseZombie.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sp/src/game/server/hl2/npc_BaseZombie.cpp b/sp/src/game/server/hl2/npc_BaseZombie.cpp index bb237242..f8609f49 100644 --- a/sp/src/game/server/hl2/npc_BaseZombie.cpp +++ b/sp/src/game/server/hl2/npc_BaseZombie.cpp @@ -211,8 +211,8 @@ BEGIN_DATADESC( CNPC_BaseZombie ) DEFINE_FIELD( m_fIsTorso, FIELD_BOOLEAN ), #ifdef MAPBASE DEFINE_KEYFIELD( m_fIsHeadless, FIELD_BOOLEAN, "Headless" ), - DEFINE_KEYFIELD( m_iMeleeReach, FIELD_INTEGER, "MeleeReach" ), - DEFINE_KEYFIELD( m_iMaxPlayerDistToSwat, FIELD_INTEGER, "MaxPlayerDistToSwat" ), + DEFINE_KEYFIELD( m_flMeleeReach, FIELD_FLOAT, "MeleeReach" ), + DEFINE_KEYFIELD( m_flMaxDistToSwat, FIELD_FLOAT, "MaxDistToSwat" ), DEFINE_KEYFIELD( m_iMaxObjMassToSwat, FIELD_INTEGER, "MaxObjMassToSwat" ), #else DEFINE_FIELD( m_fIsHeadless, FIELD_BOOLEAN ), @@ -260,8 +260,8 @@ CNPC_BaseZombie::CNPC_BaseZombie() m_iMoanSound = g_numZombies; #ifdef MAPBASE - m_iMeleeReach = ZOMBIE_MELEE_REACH; - m_iMaxPlayerDistToSwat = ZOMBIE_PLAYER_MAX_SWAT_DIST; + m_flMeleeReach = ZOMBIE_MELEE_REACH; + m_flMaxDistToSwat = ZOMBIE_PLAYER_MAX_SWAT_DIST; m_iMaxObjMassToSwat = ZOMBIE_MAX_PHYSOBJ_MASS; #endif @@ -307,7 +307,7 @@ bool CNPC_BaseZombie::FindNearestPhysicsObject( int iMaxMass ) #ifndef MAPBASE if (dist > ZOMBIE_PLAYER_MAX_SWAT_DIST) #else - if (dist > m_iMaxPlayerDistToSwat) + if (dist > m_flMaxDistToSwat) #endif { // Player is too far away. Don't bother diff --git a/sp/src/game/server/hl2/npc_BaseZombie.h b/sp/src/game/server/hl2/npc_BaseZombie.h index 789d7d9b..cfc11566 100644 --- a/sp/src/game/server/hl2/npc_BaseZombie.h +++ b/sp/src/game/server/hl2/npc_BaseZombie.h @@ -145,7 +145,7 @@ public: virtual float GetClawAttackRange() const { #ifdef MAPBASE - return m_iMeleeReach; + return m_flMeleeReach; #else return ZOMBIE_MELEE_REACH; #endif @@ -266,8 +266,8 @@ protected: float m_flNextFlinch; #ifdef MAPBASE - int m_iMeleeReach; - int m_iMaxPlayerDistToSwat; + float m_flMeleeReach; + float m_flMaxDistToSwat; int m_iMaxObjMassToSwat; #endif