Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions src/game/server/neo/bot/behavior/neo_bot_tactical_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,43 +135,43 @@ void CNEOBotTacticalMonitor::MonitorArmedStickyBombs( CNEOBot *me )

#endif //NEO
//-----------------------------------------------------------------------------------------
void CNEOBotTacticalMonitor::AvoidBumpingEnemies( CNEOBot *me )
void CNEOBotTacticalMonitor::AvoidBumpingFriends( CNEOBot *me )
{
if ( me->GetDifficulty() < CNEOBot::HARD )
return;

const float avoidRange = 200.0f;
const float avoidRange = 32.0f;

CUtlVector< CNEO_Player * > enemyVector;
CollectPlayers( &enemyVector, GetEnemyTeam( me->GetTeamNumber() ), COLLECT_ONLY_LIVING_PLAYERS );
CUtlVector< CNEO_Player * > friendVector;
CollectPlayers( &friendVector, me->GetTeamNumber(), COLLECT_ONLY_LIVING_PLAYERS );

CNEO_Player *closestEnemy = NULL;
CNEO_Player *closestFriend = NULL;
float closestRangeSq = avoidRange * avoidRange;

for( int i=0; i<enemyVector.Count(); ++i )
for( int i=0; i<friendVector.Count(); ++i )
{
CNEO_Player *enemy = enemyVector[i];
CNEO_Player *friendly = friendVector[i];

if ( friendly == me->GetEntity() )
continue;

float rangeSq = ( enemy->GetAbsOrigin() - me->GetAbsOrigin() ).LengthSqr();
float rangeSq = ( friendly->GetAbsOrigin() - me->GetAbsOrigin() ).LengthSqr();
if ( rangeSq < closestRangeSq )
{
closestEnemy = enemy;
closestFriend = friendly;
closestRangeSq = rangeSq;
}
}

if ( !closestEnemy )
if ( !closestFriend )
return;

// avoid unless hindrance returns a definitive "no"
if ( me->GetIntentionInterface()->IsHindrance( me, closestEnemy ) == ANSWER_UNDEFINED )
if ( me->GetIntentionInterface()->IsHindrance( me, closestFriend ) == ANSWER_UNDEFINED )
{
me->ReleaseForwardButton();
me->ReleaseLeftButton();
me->ReleaseRightButton();
me->ReleaseBackwardButton();

Vector away = me->GetAbsOrigin() - closestEnemy->GetAbsOrigin();
Vector away = me->GetAbsOrigin() - closestFriend->GetAbsOrigin();

me->GetLocomotionInterface()->Approach( me->GetLocomotionInterface()->GetFeet() + away );
}
Expand Down Expand Up @@ -346,6 +346,12 @@ ActionResult< CNEOBot > CNEOBotTacticalMonitor::Update( CNEOBot *me, float inter
MonitorArmedStickyBombs( me );
#endif

CNEO_Player* pBotPlayer = ToNEOPlayer( me->GetEntity() );
if ( pBotPlayer && !(pBotPlayer->m_nButtons & (IN_FORWARD | IN_BACK | IN_MOVELEFT | IN_MOVERIGHT)) )
{
AvoidBumpingFriends( me );
}

me->UpdateDelayedThreatNotices();

return Continue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CNEOBotTacticalMonitor : public Action< CNEOBot >

ActionResult< CNEOBot > ScavengeForPrimaryWeapon(CNEOBot* me);

void AvoidBumpingEnemies(CNEOBot* me);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we certain we don't want the bots to avoid bumping into enemies?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the likelihood that bots are going to be in close proximity with their enemies is relatively low. In the case where they did get into a situation where they are bumping into their enemies, I don't want to interrupt the bot's combat routine to mess with their movement keys like this function does. My speculation is that this function was more for a Left 4 Dead situation where an enemy like a Witch was passive, and you don't want your friendly AI to accidentally walk over them.

void AvoidBumpingFriends(CNEOBot* me);
void ReconConsiderSuperJump(CNEOBot *me);
ActionResult< CNEOBot > WatchForGrenades(CNEOBot* me);
};