diff --git a/sp/src/game/server/ez2/npc_husk_base.h b/sp/src/game/server/ez2/npc_husk_base.h index 8687053cfd..37ff2f2feb 100644 --- a/sp/src/game/server/ez2/npc_husk_base.h +++ b/sp/src/game/server/ez2/npc_husk_base.h @@ -60,6 +60,10 @@ extern ConVar sk_husk_common_infight_time; DEFINE_OUTPUT(m_OnAggressionSuspicious, "OnAggressionSuspicious"), \ DEFINE_OUTPUT(m_OnAggressionAngry, "OnAggressionAngry"), \ +#define DEFINE_BASE_HUSK_SCRIPTDESC() \ + DEFINE_SCRIPTFUNC_NAMED( ScriptGetHuskAggressionLevel, "GetHuskAggressionLevel", "Get the husk's aggression level." ) \ + DEFINE_SCRIPTFUNC_NAMED( ScriptGetHuskCognitionFlags, "GetHuskCognitionFlags", "Get the husk's aggression flags." ) \ + #define DEFINE_BASE_HUSK_SENDPROPS() \ SendPropInt( SENDINFO( m_nHuskAggressionLevel ) ), \ SendPropInt( SENDINFO( m_nHuskCognitionFlags ) ), \ @@ -154,6 +158,7 @@ class CAI_BaseHusk : public BASE_NPC, public CAI_HuskSink // From CAI_HuskSink int GetHuskAggressionLevel() override { return this->m_nHuskAggressionLevel; } + int ScriptGetHuskAggressionLevel() { return this->m_nHuskAggressionLevel; } void MakeCalm( CBaseEntity *pActivator ) override; void MakeSuspicious( CBaseEntity *pActivator ) override; @@ -169,6 +174,7 @@ class CAI_BaseHusk : public BASE_NPC, public CAI_HuskSink // From CAI_HuskSink int GetHuskCognitionFlags() override { return this->m_nHuskCognitionFlags; } + int ScriptGetHuskCognitionFlags() { return this->m_nHuskCognitionFlags; } void RefreshCognitionFlags(); @@ -755,13 +761,23 @@ bool CAI_BaseHusk::FCanCheckAttacks( void ) template Vector CAI_BaseHusk::GetShootEnemyDir( const Vector &shootOrigin, bool bNoisy ) { - if ( this->HasCognitionFlags( bits_HUSK_COGNITION_BLIND ) && this->GetActiveWeapon() ) + if ( this->HasCognitionFlags( bits_HUSK_COGNITION_BLIND ) ) { // Can't see our enemy, just shoot forwards - Vector vecShootOrigin, vecShootDir; - QAngle angShootDir; - this->GetActiveWeapon()->GetAttachment( this->GetActiveWeapon()->LookupAttachment( "muzzle" ), vecShootOrigin, angShootDir ); - AngleVectors( angShootDir, &vecShootDir ); + matrix3x4_t attachmentToWorld; + if ( this->GetActiveWeapon() ) + { + this->GetActiveWeapon()->GetAttachment( this->GetActiveWeapon()->LookupAttachment( "muzzle" ), attachmentToWorld ); + } + else if ( this->CapabilitiesGet() & bits_CAP_INNATE_RANGE_ATTACK1 ) + { + this->GetAttachment( this->LookupAttachment( "muzzle" ), attachmentToWorld ); + } + else + return BaseClass::GetShootEnemyDir( shootOrigin, bNoisy ); + + Vector vecShootDir; + MatrixGetColumn( attachmentToWorld, 0, vecShootDir ); return vecShootDir; } @@ -773,11 +789,21 @@ Vector CAI_BaseHusk::GetShootEnemyDir( const Vector &shootOrigin, bool template Vector CAI_BaseHusk::GetActualShootPosition( const Vector &shootOrigin ) { - if ( this->HasCognitionFlags( bits_HUSK_COGNITION_BLIND ) && this->GetActiveWeapon() ) + if ( this->HasCognitionFlags( bits_HUSK_COGNITION_BLIND ) ) { // Can't see our enemy, just shoot forwards Vector vecShootOrigin, vecShootDir; - this->GetActiveWeapon()->GetAttachment( this->GetActiveWeapon()->LookupAttachment( "muzzle" ), vecShootOrigin, &vecShootDir ); + if ( this->GetActiveWeapon() ) + { + this->GetActiveWeapon()->GetAttachment( this->GetActiveWeapon()->LookupAttachment( "muzzle" ), vecShootOrigin, &vecShootDir ); + } + else if ( this->CapabilitiesGet() & bits_CAP_INNATE_RANGE_ATTACK1 ) + { + this->GetAttachment( this->LookupAttachment( "muzzle" ), vecShootOrigin, &vecShootDir ); + } + else + return BaseClass::GetActualShootPosition( shootOrigin ); + return vecShootOrigin + (vecShootDir * 128.0f); } diff --git a/sp/src/game/server/ez2/npc_husk_police.cpp b/sp/src/game/server/ez2/npc_husk_police.cpp index 081016e911..a84883ea57 100644 --- a/sp/src/game/server/ez2/npc_husk_police.cpp +++ b/sp/src/game/server/ez2/npc_husk_police.cpp @@ -31,6 +31,15 @@ BEGIN_DATADESC( CNPC_HuskPolice ) END_DATADESC() +//--------------------------------------------------------- +// VScript +//--------------------------------------------------------- +BEGIN_ENT_SCRIPTDESC( CNPC_HuskPolice, CAI_BaseActor, "Husk metrocop." ) + + DEFINE_BASE_HUSK_SCRIPTDESC() + +END_SCRIPTDESC() + //--------------------------------------------------------- // Custom Client entity //--------------------------------------------------------- diff --git a/sp/src/game/server/ez2/npc_husk_police.h b/sp/src/game/server/ez2/npc_husk_police.h index 5cbd001147..489c3eb0db 100644 --- a/sp/src/game/server/ez2/npc_husk_police.h +++ b/sp/src/game/server/ez2/npc_husk_police.h @@ -6,8 +6,8 @@ // //=============================================================================// -#ifndef NPC_HUSK_SOLDIER_H -#define NPC_HUSK_SOLDIER_H +#ifndef NPC_HUSK_POLICE_H +#define NPC_HUSK_POLICE_H #ifdef _WIN32 #pragma once #endif @@ -22,6 +22,7 @@ class CNPC_HuskPolice : public CAI_BaseHusk { DECLARE_CLASS( CNPC_HuskPolice, CAI_BaseHusk ); DECLARE_DATADESC(); + DECLARE_ENT_SCRIPTDESC(); DECLARE_SERVERCLASS(); public: @@ -43,6 +44,8 @@ class CNPC_HuskPolice : public CAI_BaseHusk int SelectAlertSchedule( void ); int SelectCombatSchedule( void ); + bool HasHumanGibs( void ) { return true; } + WeaponProficiency_t CalcWeaponProficiency( CBaseCombatWeapon *pWeapon ); IMPLEMENT_NETWORK_VAR_FOR_DERIVED( m_nHuskAggressionLevel ); @@ -64,4 +67,4 @@ class CNPC_HuskPolice : public CAI_BaseHusk }; }; -#endif // NPC_HUSK_SOLDIER_H +#endif // NPC_HUSK_POLICE_H diff --git a/sp/src/game/server/ez2/npc_husk_soldier.cpp b/sp/src/game/server/ez2/npc_husk_soldier.cpp index b8e8283c21..9ff63f03fa 100644 --- a/sp/src/game/server/ez2/npc_husk_soldier.cpp +++ b/sp/src/game/server/ez2/npc_husk_soldier.cpp @@ -172,6 +172,15 @@ BEGIN_DATADESC( CNPC_HuskSoldier ) END_DATADESC() +//--------------------------------------------------------- +// VScript +//--------------------------------------------------------- +BEGIN_ENT_SCRIPTDESC( CNPC_HuskSoldier, CAI_BaseActor, "Husk Combine soldier." ) + + DEFINE_BASE_HUSK_SCRIPTDESC() + +END_SCRIPTDESC() + //--------------------------------------------------------- // Custom Client entity //--------------------------------------------------------- diff --git a/sp/src/game/server/ez2/npc_husk_soldier.h b/sp/src/game/server/ez2/npc_husk_soldier.h index 8be1864409..4c808e7a97 100644 --- a/sp/src/game/server/ez2/npc_husk_soldier.h +++ b/sp/src/game/server/ez2/npc_husk_soldier.h @@ -39,6 +39,7 @@ class CNPC_HuskSoldier : public CAI_BaseHusk { DECLARE_CLASS( CNPC_HuskSoldier, CAI_BaseHusk ); DECLARE_DATADESC(); + DECLARE_ENT_SCRIPTDESC(); DECLARE_SERVERCLASS(); public: @@ -91,6 +92,7 @@ class CNPC_HuskSoldier : public CAI_BaseHusk bool IsHeavyDamage( const CTakeDamageInfo &info ); bool AllowedToIgnite( void ) { return true; } + bool HasHumanGibs( void ) { return true; } bool Crouch( void );