Ported some minor fixes from the Alien Swarm SDK

This commit is contained in:
Blixibon 2021-10-10 19:41:42 -05:00
parent 525e3214f2
commit 138d6c52aa
2 changed files with 35 additions and 21 deletions

View File

@ -835,7 +835,11 @@ void CAI_BaseActor::UpdateLatchedValues( )
// set head latch
m_fLatchedPositions |= HUMANOID_LATCHED_HEAD;
#ifdef MAPBASE // From Alien Swarm SDK
if ( CanSkipAnimation() || !GetAttachment( "eyes", m_latchedEyeOrigin, &m_latchedHeadDirection ))
#else
if (!HasCondition( COND_IN_PVS ) || !GetAttachment( "eyes", m_latchedEyeOrigin, &m_latchedHeadDirection ))
#endif
{
m_latchedEyeOrigin = BaseClass::EyePosition( );
AngleVectors( GetLocalAngles(), &m_latchedHeadDirection );
@ -1626,7 +1630,11 @@ void CAI_BaseActor::MaintainLookTargets( float flInterval )
}
// don't bother with any of the rest if the player can't see you
#ifdef MAPBASE // From Alien Swarm SDK
if ( CanSkipAnimation() )
#else
if (!HasCondition( COND_IN_PVS ))
#endif
{
return;
}

View File

@ -668,7 +668,7 @@ void CAI_BaseNPC::Ignite( float flFlameLifetime, bool bNPCOnly, float flSize, bo
#ifdef HL2_EPISODIC
CBasePlayer *pPlayer = AI_GetSinglePlayer();
if ( pPlayer->IRelationType( this ) != D_LI )
if ( pPlayer && pPlayer->IRelationType( this ) != D_LI )
{
CNPC_Alyx *alyx = CNPC_Alyx::GetAlyx();
@ -993,6 +993,8 @@ int CAI_BaseNPC::OnTakeDamage_Alive( const CTakeDamageInfo &info )
// only fire once per frame
m_OnDamaged.FireOutput( info.GetAttacker(), this);
if ( info.GetAttacker() )
{
if( info.GetAttacker()->IsPlayer() )
{
m_OnDamagedByPlayer.FireOutput( info.GetAttacker(), this );
@ -1003,12 +1005,7 @@ int CAI_BaseNPC::OnTakeDamage_Alive( const CTakeDamageInfo &info )
else
{
// See if the person that injured me is an NPC.
#ifdef MAPBASE
// Sometimes I find these things and I can't just sit idly by.
CAI_BaseNPC *pAttacker = info.GetAttacker()->MyNPCPointer();
#else
CAI_BaseNPC *pAttacker = dynamic_cast<CAI_BaseNPC *>( info.GetAttacker() );
#endif
CBasePlayer *pPlayer = AI_GetSinglePlayer();
if( pAttacker && pAttacker->IsAlive() && pPlayer )
@ -1020,6 +1017,7 @@ int CAI_BaseNPC::OnTakeDamage_Alive( const CTakeDamageInfo &info )
}
}
}
}
if( (info.GetDamageType() & DMG_CRUSH) && !(info.GetDamageType() & DMG_PHYSGUN) && info.GetDamage() >= MIN_PHYSICS_FLINCH_DAMAGE )
{
@ -7466,7 +7464,11 @@ void CAI_BaseNPC::SetHullSizeNormal( bool force )
if ( m_fIsUsingSmallHull || force )
{
// Find out what the height difference will be between the versions and adjust our bbox accordingly to keep us level
#ifdef MAPBASE // From Alien Swarm SDK
const float flScale = MIN( 1.0f, GetModelScale() ); // NOTE: Cannot scale NPC bounding box up, as pathfinding will fail (hull needs to match the traces used for the node network)
#else
const float flScale = GetModelScale();
#endif
Vector vecMins = ( GetHullMins() * flScale );
Vector vecMaxs = ( GetHullMaxs() * flScale );
@ -13423,6 +13425,10 @@ void CAI_BaseNPC::Teleport( const Vector *newPosition, const QAngle *newAngles,
CleanupScriptsOnTeleport( false );
BaseClass::Teleport( newPosition, newAngles, newVelocity );
#ifdef MAPBASE // From Alien Swarm SDK
CheckPVSCondition();
#endif
}
//-----------------------------------------------------------------------------