This commit is contained in:
FluorescentCIAAfricanAmerican
2020-04-22 12:56:21 -04:00
commit 3bf9df6b27
15370 changed files with 5489726 additions and 0 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,69 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
// tf_bot_medic_heal.h
// Heal a teammate
// Michael Booth, February 2009
#ifndef TF_BOT_MEDIC_HEAL_H
#define TF_BOT_MEDIC_HEAL_H
#include "Path/NextBotChasePath.h"
class CWeaponMedigun;
class CTFBotMedicHeal : public Action< CTFBot >
{
public:
virtual ActionResult< CTFBot > OnStart( CTFBot *me, Action< CTFBot > *priorAction );
virtual ActionResult< CTFBot > Update( CTFBot *me, float interval );
virtual ActionResult< CTFBot > OnResume( CTFBot *me, Action< CTFBot > *interruptingAction );
virtual EventDesiredResult< CTFBot > OnStuck( CTFBot *me );
virtual EventDesiredResult< CTFBot > OnMoveToSuccess( CTFBot *me, const Path *path );
virtual EventDesiredResult< CTFBot > OnMoveToFailure( CTFBot *me, const Path *path, MoveToFailureType reason );
virtual EventDesiredResult< CTFBot > OnActorEmoted( CTFBot *me, CBaseCombatCharacter *emoter, int emote );
virtual QueryResultType ShouldHurry( const INextBot *me ) const; // are we in a hurry?
virtual QueryResultType ShouldAttack( const INextBot *me, const CKnownEntity *them ) const; // should we attack "them"?
virtual QueryResultType ShouldRetreat( const INextBot *bot ) const;
virtual const char *GetName( void ) const { return "Heal"; };
private:
ChasePath m_chasePath;
CTFPlayer *SelectPatient( CTFBot *me, CTFPlayer *current );
CountdownTimer m_changePatientTimer;
CountdownTimer m_delayUberTimer;
CHandle< CTFPlayer > m_patient;
Vector m_patientAnchorPos; // a spot where the patient was, to track if they are moving
CountdownTimer m_isPatientRunningTimer;
bool IsPatientRunning( void ) const;
bool IsStable( CTFPlayer *patient ) const; // return true if the given patient is healthy and safe for now
CTFNavArea *FindCoverArea( CTFBot *me );
CTFNavArea *m_coverArea;
CountdownTimer m_coverTimer;
PathFollower m_coverPath;
void ComputeFollowPosition( CTFBot *me );
Vector m_followGoal;
bool IsVisibleToEnemy( CTFBot *me, const Vector &where ) const;
bool IsReadyToDeployUber( const CWeaponMedigun* pMedigun ) const;
bool IsGoodUberTarget( CTFPlayer *who ) const;
bool CanDeployUber( CTFBot *me, const CWeaponMedigun* pMedigun ) const;
};
inline bool CTFBotMedicHeal::IsPatientRunning( void ) const
{
return m_isPatientRunningTimer.IsElapsed() ? false : true;
}
#endif // TF_BOT_MEDIC_HEAL_H
@@ -0,0 +1,144 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
// tf_bot_retreat.cpp
// Retreat towards our spawn to find another patient
// Michael Booth, May 2009
#include "cbase.h"
#include "tf_player.h"
#include "tf_gamerules.h"
#include "tf_weapon_medigun.h"
#include "bot/tf_bot.h"
#include "bot/behavior/medic/tf_bot_medic_retreat.h"
#include "nav_mesh.h"
extern ConVar tf_bot_path_lookahead_range;
extern ConVar tf_bot_medic_follow_range;
extern ConVar tf_bot_force_class;
//---------------------------------------------------------------------------------------------
ActionResult< CTFBot > CTFBotMedicRetreat::OnStart( CTFBot *me, Action< CTFBot > *priorAction )
{
CTFNavArea *homeArea = me->GetSpawnArea();
if ( homeArea == NULL )
{
return Done( "No home area!" );
}
m_path.SetMinLookAheadDistance( tf_bot_path_lookahead_range.GetFloat() );
CTFBotPathCost cost( me, FASTEST_ROUTE );
m_path.Compute( me, homeArea->GetCenter(), cost );
return Continue();
}
//---------------------------------------------------------------------------------------------
class CUsefulHealTargetFilter : public INextBotEntityFilter
{
public:
CUsefulHealTargetFilter( int team )
{
m_team = team;
}
virtual bool IsAllowed( CBaseEntity *entity ) const
{
if ( entity && entity->IsPlayer() && entity->GetTeamNumber() == m_team )
{
return !ToTFPlayer( entity )->IsPlayerClass( TF_CLASS_MEDIC ) && !ToTFPlayer( entity )->IsPlayerClass( TF_CLASS_SNIPER );
}
return false;
}
int m_team;
};
//---------------------------------------------------------------------------------------------
ActionResult< CTFBot > CTFBotMedicRetreat::Update( CTFBot *me, float interval )
{
// equip the syringegun and defend ourselves!
CTFWeaponBase *myWeapon = me->m_Shared.GetActiveTFWeapon();
if ( myWeapon )
{
if ( myWeapon->GetWeaponID() != TF_WEAPON_SYRINGEGUN_MEDIC )
{
CBaseCombatWeapon *syringeGun = me->Weapon_GetSlot( TF_WPN_TYPE_PRIMARY );
if ( syringeGun )
{
me->Weapon_Switch( syringeGun );
}
}
}
m_path.Update( me );
// look around to try to spot a friend to heal
if ( m_lookAroundTimer.IsElapsed() )
{
m_lookAroundTimer.Start( RandomFloat( 0.33f, 1.0f ) );
QAngle angle;
angle.x = 0.0f;
angle.y = RandomFloat( -180.0f, 180.0f );
angle.z = 0.0f;
Vector forward;
AngleVectors( angle, &forward );
me->GetBodyInterface()->AimHeadTowards( me->EyePosition() + forward, IBody::IMPORTANT, 0.1f, NULL, "Looking for someone to heal" );
}
// if we see a friend, heal them
CUsefulHealTargetFilter filter( me->GetTeamNumber() );
const CKnownEntity *known = me->GetVisionInterface()->GetClosestKnown( filter );
if ( known )
{
return Done( "I know of a teammate" );
}
return Continue();
}
//---------------------------------------------------------------------------------------------
ActionResult< CTFBot > CTFBotMedicRetreat::OnResume( CTFBot *me, Action< CTFBot > *interruptingAction )
{
CTFBotPathCost cost( me, FASTEST_ROUTE );
m_path.Compute( me, me->GetSpawnArea()->GetCenter(), cost );
return Continue();
}
//---------------------------------------------------------------------------------------------
EventDesiredResult< CTFBot > CTFBotMedicRetreat::OnStuck( CTFBot *me )
{
CTFBotPathCost cost( me, FASTEST_ROUTE );
m_path.Compute( me, me->GetSpawnArea()->GetCenter(), cost );
return TryContinue();
}
//---------------------------------------------------------------------------------------------
EventDesiredResult< CTFBot > CTFBotMedicRetreat::OnMoveToFailure( CTFBot *me, const Path *path, MoveToFailureType reason )
{
CTFBotPathCost cost( me, FASTEST_ROUTE );
m_path.Compute( me, me->GetSpawnArea()->GetCenter(), cost );
return TryContinue();
}
//---------------------------------------------------------------------------------------------
QueryResultType CTFBotMedicRetreat::ShouldAttack( const INextBot *me, const CKnownEntity *them ) const
{
// defend ourselves!
return ANSWER_YES;
}
@@ -0,0 +1,29 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
// tf_bot_retreat.cpp
// Retreat towards our spawn to find another patient
// Michael Booth, May 2009
#ifndef TF_BOT_MEDIC_RETREAT_H
#define TF_BOT_MEDIC_RETREAT_H
#include "Path/NextBotChasePath.h"
class CTFBotMedicRetreat : public Action< CTFBot >
{
public:
virtual ActionResult< CTFBot > OnStart( CTFBot *me, Action< CTFBot > *priorAction );
virtual ActionResult< CTFBot > Update( CTFBot *me, float interval );
virtual ActionResult< CTFBot > OnResume( CTFBot *me, Action< CTFBot > *interruptingAction );
virtual EventDesiredResult< CTFBot > OnStuck( CTFBot *me );
virtual EventDesiredResult< CTFBot > OnMoveToFailure( CTFBot *me, const Path *path, MoveToFailureType reason );
virtual QueryResultType ShouldAttack( const INextBot *me, const CKnownEntity *them ) const;
virtual const char *GetName( void ) const { return "Retreat"; };
private:
PathFollower m_path;
CountdownTimer m_lookAroundTimer;
};
#endif // TF_BOT_MEDIC_RETREAT_H