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 // set head latch
m_fLatchedPositions |= HUMANOID_LATCHED_HEAD; 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 )) if (!HasCondition( COND_IN_PVS ) || !GetAttachment( "eyes", m_latchedEyeOrigin, &m_latchedHeadDirection ))
#endif
{ {
m_latchedEyeOrigin = BaseClass::EyePosition( ); m_latchedEyeOrigin = BaseClass::EyePosition( );
AngleVectors( GetLocalAngles(), &m_latchedHeadDirection ); 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 // 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 )) if (!HasCondition( COND_IN_PVS ))
#endif
{ {
return; return;
} }

View File

@ -668,7 +668,7 @@ void CAI_BaseNPC::Ignite( float flFlameLifetime, bool bNPCOnly, float flSize, bo
#ifdef HL2_EPISODIC #ifdef HL2_EPISODIC
CBasePlayer *pPlayer = AI_GetSinglePlayer(); CBasePlayer *pPlayer = AI_GetSinglePlayer();
if ( pPlayer->IRelationType( this ) != D_LI ) if ( pPlayer && pPlayer->IRelationType( this ) != D_LI )
{ {
CNPC_Alyx *alyx = CNPC_Alyx::GetAlyx(); CNPC_Alyx *alyx = CNPC_Alyx::GetAlyx();
@ -993,29 +993,27 @@ int CAI_BaseNPC::OnTakeDamage_Alive( const CTakeDamageInfo &info )
// only fire once per frame // only fire once per frame
m_OnDamaged.FireOutput( info.GetAttacker(), this); m_OnDamaged.FireOutput( info.GetAttacker(), this);
if( info.GetAttacker()->IsPlayer() ) if ( info.GetAttacker() )
{ {
m_OnDamagedByPlayer.FireOutput( info.GetAttacker(), this ); if( info.GetAttacker()->IsPlayer() )
// This also counts as being harmed by player's squad.
m_OnDamagedByPlayerSquad.FireOutput( info.GetAttacker(), this );
}
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 )
{ {
if( pAttacker->GetSquad() != NULL && pAttacker->IsInPlayerSquad() ) m_OnDamagedByPlayer.FireOutput( info.GetAttacker(), this );
// This also counts as being harmed by player's squad.
m_OnDamagedByPlayerSquad.FireOutput( info.GetAttacker(), this );
}
else
{
// See if the person that injured me is an NPC.
CAI_BaseNPC *pAttacker = info.GetAttacker()->MyNPCPointer();
CBasePlayer *pPlayer = AI_GetSinglePlayer();
if( pAttacker && pAttacker->IsAlive() && pPlayer )
{ {
m_OnDamagedByPlayerSquad.FireOutput( info.GetAttacker(), this ); if( pAttacker->GetSquad() != NULL && pAttacker->IsInPlayerSquad() )
{
m_OnDamagedByPlayerSquad.FireOutput( info.GetAttacker(), this );
}
} }
} }
} }
@ -7466,7 +7464,11 @@ void CAI_BaseNPC::SetHullSizeNormal( bool force )
if ( m_fIsUsingSmallHull || 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 // 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(); const float flScale = GetModelScale();
#endif
Vector vecMins = ( GetHullMins() * flScale ); Vector vecMins = ( GetHullMins() * flScale );
Vector vecMaxs = ( GetHullMaxs() * flScale ); Vector vecMaxs = ( GetHullMaxs() * flScale );
@ -13423,6 +13425,10 @@ void CAI_BaseNPC::Teleport( const Vector *newPosition, const QAngle *newAngles,
CleanupScriptsOnTeleport( false ); CleanupScriptsOnTeleport( false );
BaseClass::Teleport( newPosition, newAngles, newVelocity ); BaseClass::Teleport( newPosition, newAngles, newVelocity );
#ifdef MAPBASE // From Alien Swarm SDK
CheckPVSCondition();
#endif
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------