Skip to content

Commit 8ef090c

Browse files
authored
Merge pull request #312 from Wikot235/Zombie_improved
Minor npc_zombie improvements
2 parents ed476cb + aa31835 commit 8ef090c

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

sp/src/game/server/hl2/npc_BaseZombie.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ BEGIN_DATADESC( CNPC_BaseZombie )
211211
DEFINE_FIELD( m_fIsTorso, FIELD_BOOLEAN ),
212212
#ifdef MAPBASE
213213
DEFINE_KEYFIELD( m_fIsHeadless, FIELD_BOOLEAN, "Headless" ),
214+
DEFINE_KEYFIELD( m_flMeleeReach, FIELD_FLOAT, "MeleeReach" ),
215+
DEFINE_KEYFIELD( m_flMaxDistToSwat, FIELD_FLOAT, "MaxDistToSwat" ),
216+
DEFINE_KEYFIELD( m_iMaxObjMassToSwat, FIELD_INTEGER, "MaxObjMassToSwat" ),
214217
#else
215218
DEFINE_FIELD( m_fIsHeadless, FIELD_BOOLEAN ),
216219
#endif
@@ -256,6 +259,12 @@ CNPC_BaseZombie::CNPC_BaseZombie()
256259
// moan loop.
257260
m_iMoanSound = g_numZombies;
258261

262+
#ifdef MAPBASE
263+
m_flMeleeReach = ZOMBIE_MELEE_REACH;
264+
m_flMaxDistToSwat = ZOMBIE_PLAYER_MAX_SWAT_DIST;
265+
m_iMaxObjMassToSwat = ZOMBIE_MAX_PHYSOBJ_MASS;
266+
#endif
267+
259268
g_numZombies++;
260269
}
261270

@@ -295,7 +304,11 @@ bool CNPC_BaseZombie::FindNearestPhysicsObject( int iMaxMass )
295304
float dist = VectorNormalize(vecDirToEnemy);
296305
vecDirToEnemy.z = 0;
297306

298-
if( dist > ZOMBIE_PLAYER_MAX_SWAT_DIST )
307+
#ifndef MAPBASE
308+
if (dist > ZOMBIE_PLAYER_MAX_SWAT_DIST)
309+
#else
310+
if (dist > m_flMaxDistToSwat)
311+
#endif
299312
{
300313
// Player is too far away. Don't bother
301314
// trying to swat anything at them until
@@ -786,7 +799,7 @@ bool CNPC_BaseZombie::ShouldBecomeTorso( const CTakeDamageInfo &info, float flDa
786799
HeadcrabRelease_t CNPC_BaseZombie::ShouldReleaseHeadcrab( const CTakeDamageInfo &info, float flDamageThreshold )
787800
{
788801
#ifdef MAPBASE
789-
if ( m_iHealth <= 0 && !m_fIsHeadless )
802+
if ( m_iHealth <= 0 && !m_fIsHeadless && !HasSpawnFlags(SF_ZOMBIE_NO_HEADCRAB_SPAWN))
790803
#else
791804
if ( m_iHealth <= 0 )
792805
#endif
@@ -2154,7 +2167,11 @@ void CNPC_BaseZombie::GatherConditions( void )
21542167
// between him and the object he's heading for already.
21552168
if( gpGlobals->curtime >= m_flNextSwatScan && (m_hPhysicsEnt == NULL) )
21562169
{
2170+
#ifdef MAPBASE
2171+
FindNearestPhysicsObject(m_iMaxObjMassToSwat);
2172+
#else
21572173
FindNearestPhysicsObject( ZOMBIE_MAX_PHYSOBJ_MASS );
2174+
#endif
21582175
m_flNextSwatScan = gpGlobals->curtime + 2.0;
21592176
}
21602177
}

sp/src/game/server/hl2/npc_BaseZombie.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ extern int AE_ZOMBIE_POUND;
4444
#define ZOMBIE_BLOOD_BITE 3
4545

4646
#ifdef MAPBASE
47-
#define SF_ZOMBIE_NO_TORSO ( 1 << 15 )
47+
#define SF_ZOMBIE_NO_TORSO ( 1 << 15 )
48+
#define SF_ZOMBIE_NO_HEADCRAB_SPAWN ( 1 << 16 )
4849
#endif
4950

5051

@@ -141,7 +142,14 @@ abstract_class CNPC_BaseZombie : public CAI_BaseZombieBase
141142
}
142143

143144
int MeleeAttack1Conditions ( float flDot, float flDist );
144-
virtual float GetClawAttackRange() const { return ZOMBIE_MELEE_REACH; }
145+
virtual float GetClawAttackRange() const
146+
{
147+
#ifdef MAPBASE
148+
return m_flMeleeReach;
149+
#else
150+
return ZOMBIE_MELEE_REACH;
151+
#endif
152+
}
145153

146154
// No range attacks
147155
int RangeAttack1Conditions ( float flDot, float flDist ) { return( 0 ); }
@@ -257,6 +265,12 @@ abstract_class CNPC_BaseZombie : public CAI_BaseZombieBase
257265

258266
float m_flNextFlinch;
259267

268+
#ifdef MAPBASE
269+
float m_flMeleeReach;
270+
float m_flMaxDistToSwat;
271+
int m_iMaxObjMassToSwat;
272+
#endif
273+
260274
bool m_bHeadShot; // Used to determine the survival of our crab beyond our death.
261275

262276
//

0 commit comments

Comments
 (0)