Skip to content

Commit

Permalink
Added semi-standardized custom model support to several NPCs
Browse files Browse the repository at this point in the history
  • Loading branch information
Blixibon committed Mar 7, 2021
1 parent 92866ca commit 251725c
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 26 deletions.
5 changes: 5 additions & 0 deletions sp/src/game/server/ai_basenpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ extern bool AIStrongOpt( void );
#ifdef MAPBASE
// Defines Mapbase's extended NPC response system usage.
#define EXPANDED_RESPONSE_SYSTEM_USAGE

// Use the model keyvalue if it is defined
#define DefaultOrCustomModel(defaultModel) GetModelName() != NULL_STRING ? STRING(GetModelName()) : defaultModel
#else
#define DefaultOrCustomModel() defaultModel
#endif

#ifdef EXPANDED_RESPONSE_SYSTEM_USAGE
Expand Down
6 changes: 3 additions & 3 deletions sp/src/game/server/hl2/npc_antlion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,17 @@ void CNPC_Antlion::Spawn( void )
#ifdef HL2_EPISODIC
if ( IsWorker() )
{
SetModel( ANTLION_WORKER_MODEL );
SetModel( DefaultOrCustomModel(ANTLION_WORKER_MODEL) );
AddSpawnFlags( SF_NPC_LONG_RANGE );
SetBloodColor( BLOOD_COLOR_ANTLION_WORKER );
}
else
{
SetModel( ANTLION_MODEL );
SetModel( DefaultOrCustomModel(ANTLION_MODEL) );
SetBloodColor( BLOOD_COLOR_ANTLION );
}
#else
SetModel( ANTLION_MODEL );
SetModel( DefaultOrCustomModel(ANTLION_MODEL) );
SetBloodColor( BLOOD_COLOR_YELLOW );
#endif // HL2_EPISODIC

Expand Down
4 changes: 2 additions & 2 deletions sp/src/game/server/hl2/npc_antlionguard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ void CNPC_AntlionGuard::UpdateOnRemove( void )
//-----------------------------------------------------------------------------
void CNPC_AntlionGuard::Precache( void )
{
PrecacheModel( ANTLIONGUARD_MODEL );
PrecacheModel( DefaultOrCustomModel( ANTLIONGUARD_MODEL ) );

PrecacheScriptSound( "NPC_AntlionGuard.Shove" );
PrecacheScriptSound( "NPC_AntlionGuard.HitHard" );
Expand Down Expand Up @@ -779,7 +779,7 @@ void CNPC_AntlionGuard::Spawn( void )
{
Precache();

SetModel( ANTLIONGUARD_MODEL );
SetModel( DefaultOrCustomModel( ANTLIONGUARD_MODEL ) );

// Switch our skin (for now), if we're the cavern guard
if ( m_bCavernBreed )
Expand Down
4 changes: 2 additions & 2 deletions sp/src/game/server/hl2/npc_barnacle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void CNPC_Barnacle::Spawn()
{
Precache( );

SetModel( "models/barnacle.mdl" );
SetModel( DefaultOrCustomModel( "models/barnacle.mdl" ) );
UTIL_SetSize( this, Vector(-16, -16, -40), Vector(16, 16, 0) );

SetSolid( SOLID_BBOX );
Expand Down Expand Up @@ -2375,7 +2375,7 @@ const impactdamagetable_t &CNPC_Barnacle::GetPhysicsImpactDamageTable( void )
//=========================================================
void CNPC_Barnacle::Precache()
{
PrecacheModel("models/barnacle.mdl");
PrecacheModel( DefaultOrCustomModel( "models/barnacle.mdl" ) );

// Precache all gibs
for ( int i=0; i < ARRAYSIZE(m_szGibNames); i++ )
Expand Down
12 changes: 6 additions & 6 deletions sp/src/game/server/hl2/npc_headcrab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2433,7 +2433,7 @@ void CBaseHeadcrab::CreateDust( bool placeDecal )
//-----------------------------------------------------------------------------
void CHeadcrab::Precache( void )
{
PrecacheModel( "models/headcrabclassic.mdl" );
PrecacheModel( DefaultOrCustomModel( "models/headcrabclassic.mdl" ) );

PrecacheScriptSound( "NPC_HeadCrab.Gib" );
PrecacheScriptSound( "NPC_HeadCrab.Idle" );
Expand All @@ -2455,7 +2455,7 @@ void CHeadcrab::Precache( void )
void CHeadcrab::Spawn( void )
{
Precache();
SetModel( "models/headcrabclassic.mdl" );
SetModel( DefaultOrCustomModel( "models/headcrabclassic.mdl" ) );

BaseClass::Spawn();

Expand Down Expand Up @@ -2570,7 +2570,7 @@ END_DATADESC()
//-----------------------------------------------------------------------------
void CFastHeadcrab::Precache( void )
{
PrecacheModel( "models/headcrab.mdl" );
PrecacheModel( DefaultOrCustomModel( "models/headcrab.mdl" ) );

PrecacheScriptSound( "NPC_FastHeadcrab.Idle" );
PrecacheScriptSound( "NPC_FastHeadcrab.Alert" );
Expand All @@ -2589,7 +2589,7 @@ void CFastHeadcrab::Precache( void )
void CFastHeadcrab::Spawn( void )
{
Precache();
SetModel( "models/headcrab.mdl" );
SetModel( DefaultOrCustomModel( "models/headcrab.mdl" ) );

BaseClass::Spawn();

Expand Down Expand Up @@ -3089,7 +3089,7 @@ void CBlackHeadcrab::TelegraphSound( void )
void CBlackHeadcrab::Spawn( void )
{
Precache();
SetModel( "models/headcrabblack.mdl" );
SetModel( DefaultOrCustomModel( "models/headcrabblack.mdl" ) );

BaseClass::Spawn();

Expand All @@ -3106,7 +3106,7 @@ void CBlackHeadcrab::Spawn( void )
//-----------------------------------------------------------------------------
void CBlackHeadcrab::Precache( void )
{
PrecacheModel( "models/headcrabblack.mdl" );
PrecacheModel( DefaultOrCustomModel( "models/headcrabblack.mdl" ) );

PrecacheScriptSound( "NPC_BlackHeadcrab.Telegraph" );
PrecacheScriptSound( "NPC_BlackHeadcrab.Attack" );
Expand Down
6 changes: 3 additions & 3 deletions sp/src/game/server/hl2/npc_manhack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2193,9 +2193,9 @@ void CNPC_Manhack::Precache(void)
//
// Model.
//
PrecacheModel("models/manhack.mdl");
PrecacheModel( DefaultOrCustomModel( "models/manhack.mdl" ) );
PrecacheModel( MANHACK_GLOW_SPRITE );
PropBreakablePrecacheAll( MAKE_STRING("models/manhack.mdl") );
PropBreakablePrecacheAll( MAKE_STRING( DefaultOrCustomModel( "models/manhack.mdl" ) ) );

PrecacheScriptSound( "NPC_Manhack.Die" );
PrecacheScriptSound( "NPC_Manhack.Bat" );
Expand Down Expand Up @@ -2389,7 +2389,7 @@ void CNPC_Manhack::Spawn(void)
AddSpawnFlags( SF_NPC_FADE_CORPSE );
#endif // _XBOX

SetModel( "models/manhack.mdl" );
SetModel( DefaultOrCustomModel( "models/manhack.mdl" ) );
SetHullType(HULL_TINY_CENTERED);
SetHullSizeNormal();

Expand Down
8 changes: 4 additions & 4 deletions sp/src/game/server/hl2/npc_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,11 @@ void CNPC_CScanner::Spawn(void)

if( m_bIsClawScanner )
{
SetModel( "models/shield_scanner.mdl");
SetModel( DefaultOrCustomModel( "models/shield_scanner.mdl" ) );
}
else
{
SetModel( "models/combine_scanner.mdl");
SetModel( DefaultOrCustomModel( "models/combine_scanner.mdl" ) );
}

m_iHealth = sk_scanner_health.GetFloat();
Expand Down Expand Up @@ -565,7 +565,7 @@ void CNPC_CScanner::Precache(void)
// Model
if( m_bIsClawScanner )
{
PrecacheModel("models/shield_scanner.mdl");
PrecacheModel( DefaultOrCustomModel( "models/shield_scanner.mdl" ) );

PrecacheModel("models/gibs/Shield_Scanner_Gib1.mdl");
PrecacheModel("models/gibs/Shield_Scanner_Gib2.mdl");
Expand All @@ -591,7 +591,7 @@ void CNPC_CScanner::Precache(void)
}
else
{
PrecacheModel("models/combine_scanner.mdl");
PrecacheModel( DefaultOrCustomModel( "models/combine_scanner.mdl" ) );

PrecacheModel("models/gibs/scanner_gib01.mdl" );
PrecacheModel("models/gibs/scanner_gib02.mdl" );
Expand Down
4 changes: 2 additions & 2 deletions sp/src/game/server/hl2/npc_stalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void CNPC_Stalker::Spawn( void )
{
Precache( );

SetModel( "models/stalker.mdl" );
SetModel( DefaultOrCustomModel( "models/stalker.mdl" ) );
SetHullType(HULL_HUMAN);
SetHullSizeNormal();

Expand Down Expand Up @@ -321,7 +321,7 @@ void CNPC_Stalker::Spawn( void )
//-----------------------------------------------------------------------------
void CNPC_Stalker::Precache( void )
{
PrecacheModel("models/stalker.mdl");
PrecacheModel( DefaultOrCustomModel( "models/stalker.mdl" ) );
PrecacheModel("sprites/laser.vmt");

PrecacheModel("sprites/redglow1.vmt");
Expand Down
4 changes: 2 additions & 2 deletions sp/src/game/server/hl2/npc_turret_ceiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ CNPC_CeilingTurret::~CNPC_CeilingTurret( void )
//-----------------------------------------------------------------------------
void CNPC_CeilingTurret::Precache( void )
{
PrecacheModel( CEILING_TURRET_MODEL );
PrecacheModel( DefaultOrCustomModel( CEILING_TURRET_MODEL ) );
PrecacheModel( CEILING_TURRET_GLOW_SPRITE );

// Activities
Expand Down Expand Up @@ -347,7 +347,7 @@ void CNPC_CeilingTurret::Spawn( void )
{
Precache();

SetModel( CEILING_TURRET_MODEL );
SetModel( DefaultOrCustomModel( CEILING_TURRET_MODEL ) );

BaseClass::Spawn();

Expand Down
4 changes: 2 additions & 2 deletions sp/src/game/server/hl2/npc_turret_ground.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ END_DATADESC()
void CNPC_GroundTurret::Precache( void )
{
PrecacheModel( GROUNDTURRET_BEAM_SPRITE );
PrecacheModel( "models/combine_turrets/ground_turret.mdl" );
PrecacheModel( DefaultOrCustomModel( "models/combine_turrets/ground_turret.mdl" ) );

PrecacheScriptSound( "NPC_CeilingTurret.Deploy" );
m_ShotSounds = PrecacheScriptSound( "NPC_FloorTurret.ShotSounds" );
Expand All @@ -88,7 +88,7 @@ void CNPC_GroundTurret::Spawn( void )
{
Precache();

UTIL_SetModel( this, "models/combine_turrets/ground_turret.mdl" );
UTIL_SetModel( this, DefaultOrCustomModel( "models/combine_turrets/ground_turret.mdl" ) );

SetNavType( NAV_FLY );
SetSolid( SOLID_VPHYSICS );
Expand Down

0 comments on commit 251725c

Please sign in to comment.