Added func_tank behavior to vortigaunts and Barney

This commit is contained in:
Blixibon 2021-10-27 17:02:49 -05:00
parent a5c0091588
commit 65478e754d
10 changed files with 59 additions and 4 deletions

View File

@ -110,6 +110,28 @@ bool CAI_FuncTankBehavior::IsInterruptable( void )
return BaseClass::IsInterruptable();
}
ConVar ai_tank_allow_expanded_npcs( "ai_tank_allow_expanded_npcs", "1", FCVAR_NONE, "Allows Father Grigori, Barney, and vortigaunts to automatically man func_tanks." );
//-----------------------------------------------------------------------------
// Purpose:
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CAI_FuncTankBehavior::CanManTank( CFuncTank *pTank, bool bForced )
{
if (!bForced)
{
// In order to prevent potential problems in existing maps, Father Grigori, Barney, and vortigaunts can be set to not automatically man func_tanks by default.
if (ai_tank_allow_expanded_npcs.GetBool() == false)
{
const char *pszClass = GetOuter()->GetClassname();
if ( FStrEq( pszClass, "npc_monk" ) || FStrEq( pszClass, "npc_barney" ) || FStrEq( pszClass, "npc_vortigaunt" ) )
return false;
}
}
return true;
}
#endif
//-----------------------------------------------------------------------------

View File

@ -51,6 +51,8 @@ public:
void PrescheduleThink();
#ifdef MAPBASE
bool IsInterruptable( void );
bool CanManTank( CFuncTank *pTank, bool bForced );
#endif
Activity NPC_TranslateActivity( Activity activity );

View File

@ -402,7 +402,11 @@ void CFuncTank::InputFindNPCToManTank( inputdata_t &inputdata )
{
// Verify the npc has the func_tank controller behavior.
CAI_FuncTankBehavior *pBehavior;
#ifdef MAPBASE
if ( pNPC->GetBehavior( &pBehavior ) && pBehavior->CanManTank( this, true ) )
#else
if ( pNPC->GetBehavior( &pBehavior ) )
#endif
{
m_hController = pNPC;
pBehavior->SetFuncTank( this );
@ -439,7 +443,7 @@ void CFuncTank::InputTeleportNPCToManTank( inputdata_t &inputdata )
{
// Verify the npc has the func_tank controller behavior.
CAI_FuncTankBehavior *pBehavior;
if ( pNPC->GetBehavior( &pBehavior ) )
if ( pNPC->GetBehavior( &pBehavior ) && pBehavior->CanManTank( this, true ) )
{
Vector vecVec;
QAngle angAng;
@ -512,7 +516,7 @@ void CFuncTank::InputForceNPCToManTank( inputdata_t &inputdata )
{
// Verify the npc has the func_tank controller behavior.
CAI_FuncTankBehavior *pBehavior;
if ( pNPC->GetBehavior( &pBehavior ) )
if ( pNPC->GetBehavior( &pBehavior ) && pBehavior->CanManTank( this, true ) )
{
// Set the forced condition
pBehavior->SetCondition( CAI_FuncTankBehavior::COND_FUNCTANK_FORCED );
@ -627,7 +631,11 @@ void CFuncTank::NPC_FindController( void )
continue;
CAI_FuncTankBehavior *pBehavior;
#ifdef MAPBASE
if ( pNPC->GetBehavior( &pBehavior ) && pBehavior->CanManTank( this, false ) )
#else
if ( pNPC->GetBehavior( &pBehavior ) )
#endif
{
// Don't mount the func_tank if your "enemy" is within X feet or it or the npc.
CBaseEntity *pEnemy = pNPC->GetEnemy();

View File

@ -321,7 +321,9 @@ CNPC_Alyx *CNPC_Alyx::GetAlyx( void )
//=========================================================
bool CNPC_Alyx::CreateBehaviors()
{
#ifndef MAPBASE // Moved to CNPC_PlayerCompanion
AddBehavior( &m_FuncTankBehavior );
#endif
bool result = BaseClass::CreateBehaviors();
return result;

View File

@ -235,7 +235,9 @@ private:
bool m_bShouldHaveEMP;
#ifndef MAPBASE // Moved to CNPC_PlayerCompanion
CAI_FuncTankBehavior m_FuncTankBehavior;
#endif
COutputEvent m_OnFinishInteractWithObject;
COutputEvent m_OnPlayerUse;

View File

@ -439,10 +439,11 @@ CSimpleSimTimer CNPC_Citizen::gm_PlayerSquadEvaluateTimer;
bool CNPC_Citizen::CreateBehaviors()
{
BaseClass::CreateBehaviors();
AddBehavior( &m_FuncTankBehavior );
#ifdef MAPBASE
AddBehavior( &m_RappelBehavior );
AddBehavior( &m_PolicingBehavior );
#else // Moved to CNPC_PlayerCompanion
AddBehavior( &m_FuncTankBehavior );
#endif
return true;

View File

@ -370,7 +370,6 @@ private:
#endif
//-----------------------------------------------------
CAI_FuncTankBehavior m_FuncTankBehavior;
#ifdef MAPBASE
CAI_RappelBehavior m_RappelBehavior;
CAI_PolicingBehavior m_PolicingBehavior;
@ -378,6 +377,8 @@ private:
// Rappel
virtual bool IsWaitingToRappel( void ) { return m_RappelBehavior.IsWaitingToRappel(); }
void BeginRappel() { m_RappelBehavior.BeginRappel(); }
#else // Moved to CNPC_PlayerCompanion
CAI_FuncTankBehavior m_FuncTankBehavior;
#endif
CHandle<CAI_FollowGoal> m_hSavedFollowGoalEnt;

View File

@ -211,6 +211,10 @@ bool CNPC_PlayerCompanion::CreateBehaviors()
AddBehavior( &m_FollowBehavior );
AddBehavior( &m_LeadBehavior );
#endif//HL2_EPISODIC
#ifdef MAPBASE
AddBehavior( &m_FuncTankBehavior );
#endif
return BaseClass::CreateBehaviors();
}

View File

@ -23,6 +23,7 @@
#endif
#ifdef MAPBASE
#include "ai_behavior_functank.h"
#include "mapbase/ai_grenade.h"
#endif
@ -432,6 +433,9 @@ protected:
CAI_OperatorBehavior m_OperatorBehavior;
CAI_PassengerBehaviorCompanion m_PassengerBehavior;
CAI_FearBehavior m_FearBehavior;
#endif
#ifdef MAPBASE
CAI_FuncTankBehavior m_FuncTankBehavior;
#endif
//-----------------------------------------------------

View File

@ -2718,6 +2718,15 @@ void CNPC_Vortigaunt::OnSquishedGrub( const CBaseEntity *pGrub )
//-----------------------------------------------------------------------------
void CNPC_Vortigaunt::AimGun( void )
{
#ifdef MAPBASE
// Use base for func_tank
if (m_FuncTankBehavior.IsRunning())
{
BaseClass::AimGun();
return;
}
#endif
// If our aim lock is on, don't bother
if ( m_flAimDelay >= gpGlobals->curtime )
return;