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
13 changes: 6 additions & 7 deletions src/game/server/neo/bot/behavior/neo_bot_attack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ class CSearchForAttackCover : public ISearchSurroundingAreasFunctor
// only consider this new candidate area if it's an improvement
// as we assume earlier breadth first search nodes are closer to bot
// and thus faster to reach for safety.
if ( neo_bot_path_reservation_enable.GetBool() )
const int nFriendlyHere = CNEOBotPathReservations()->GetPredictedFriendlyPathCount( area->GetID(), m_me->GetTeamNumber(), m_me );
const int nFriendlyBest = CNEOBotPathReservations()->GetPredictedFriendlyPathCount( m_attackCoverArea->GetID(), m_me->GetTeamNumber(), m_me );
if ( nFriendlyHere != nFriendlyBest )
{
// prefer areas that friendly bots have reserved relatively less
return CNEOBotPathReservations()->GetPredictedFriendlyPathCount( area->GetID(), m_me->GetTeamNumber() )
< CNEOBotPathReservations()->GetPredictedFriendlyPathCount( m_attackCoverArea->GetID(), m_me->GetTeamNumber() );
return nFriendlyHere < nFriendlyBest;
}
// Fallback when path reservation is disabled: potentially visible area
// Tie-break when friendly reservations are equal (or disabled): potentially visible area
// count is a rough proxy for how exposed an area is. It ignores whether
// the area is actually reachable and does nothing to keep friendlies
// from bunching up in the same area.
Expand Down Expand Up @@ -135,9 +136,7 @@ class CSearchForAttackCover : public ISearchSurroundingAreasFunctor
}
}

float avoidPenalty = neo_bot_path_reservation_enable.GetBool()
? CNEOBotPathReservations()->GetAreaAvoidPenalty( area->GetID() )
: 0.0f;
float avoidPenalty = CNEOBotPathReservations()->GetAreaAvoidPenalty( area->GetID() );

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Would have been zero anyway if the system was disabled.

if ( !IsBetterCandidate( area, avoidPenalty ) )
{
return true; // the cover candidate we already have is at least as good
Expand Down
2 changes: 2 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_dead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "bot/neo_bot.h"
#include "bot/behavior/neo_bot_dead.h"
#include "bot/behavior/neo_bot_behavior.h"
#include "bot/neo_bot_path_reservation.h"

#include "nav_mesh.h"

Expand All @@ -13,6 +14,7 @@ extern void respawn( CBaseEntity* pEdict, bool fCopyCorpse );
ActionResult< CNEOBot > CNEOBotDead::OnStart( CNEOBot *me, Action< CNEOBot > *priorAction )
{
m_deadTimer.Start();
CNEOBotPathReservations()->ReleaseAllAreas( me );

return Continue();
}
Expand Down
1 change: 1 addition & 0 deletions src/game/server/neo/bot/neo_bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ void CNEOBot::AvoidPlayers(CUserCmd* pCmd)
void CNEOBot::UpdateOnRemove(void)
{
StopIdleSound();
CNEOBotPathReservations()->ReleaseAllAreas(this);

BaseClass::UpdateOnRemove();
}
Expand Down
5 changes: 0 additions & 5 deletions src/game/server/neo/bot/neo_bot_path_compute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

extern ConVar neo_bot_path_reservation_enable;
extern ConVar neo_bot_path_reservation_penalty;
extern ConVar neo_bot_path_reservation_duration;
extern ConVar neo_bot_path_reservation_distance;

static void CNEOBotReservePath(CNEOBot* me, PathFollower& path)
{
if (!neo_bot_path_reservation_enable.GetBool() || !path.IsValid())
Expand Down
37 changes: 24 additions & 13 deletions src/game/server/neo/bot/neo_bot_path_cost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include "nav_mesh.h"
#include "neo_bot_path_reservation.h"

extern ConVar neo_bot_path_reservation_enable;

ConVar neo_bot_path_around_friendly_cooldown("neo_bot_path_around_friendly_cooldown", "2.0", FCVAR_CHEAT,
"How often to check for friendly path dispersion", true, 0, true, 60);

Expand All @@ -32,6 +30,9 @@ ConVar neo_bot_path_penalty_exposure_inverse_base_battle_rifle("neo_bot_path_pen
ConVar neo_bot_path_penalty_exposure_inverse_base_scoped("neo_bot_path_penalty_exposure_inverse_base_scoped", "1000.0", FCVAR_CHEAT,
"Base penalty for calculating inverse traversal penalty for scoped weapons", true, 1.0f, false, 0.0f);

ConVar neo_bot_path_visibility_exposure_enable("neo_bot_path_visibility_exposure_enable", "1", FCVAR_NONE,
"Enable visibility-exposure pathing penalties", true, 0, true, 1);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Separate team-based path penalties from equipment based penalties.


//-------------------------------------------------------------------------------------------------
CNEOBotPathCost::CNEOBotPathCost(CNEOBot* me, RouteType routeType)
{
Expand All @@ -41,6 +42,7 @@ CNEOBotPathCost::CNEOBotPathCost(CNEOBot* me, RouteType routeType)
m_maxJumpHeight = me->GetLocomotionInterface()->GetMaxJumpHeight();
m_maxDropHeight = me->GetLocomotionInterface()->GetDeathDropHeight();
m_bIgnoreReservations = !neo_bot_path_reservation_enable.GetBool();
m_bIgnoreVisibilityExposure = !neo_bot_path_visibility_exposure_enable.GetBool();
}

//-------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -146,11 +148,29 @@ float CNEOBotPathCost::operator()(CNavArea* baseArea, CNavArea* fromArea, const

// ------------------------------------------------------------------------------------------------
// New path reservation related cost adjustments
if ( !m_bIgnoreReservations && (m_routeType != FASTEST_ROUTE) )
if ( NEORules()->IsTeamplay() && !m_bIgnoreReservations && (m_routeType != FASTEST_ROUTE) )
{
cost += CNEOBotPathReservations()->GetPredictedFriendlyPathCount(area->GetID(), m_me->GetTeamNumber()) * neo_bot_path_reservation_penalty.GetFloat();
const int nFriendly = CNEOBotPathReservations()->GetPredictedFriendlyPathCount(area->GetID(), m_me->GetTeamNumber(), m_me);
if (nFriendly > 0)
{
// Discourage team clustering: (n^2 * penalty)
cost += nFriendly * nFriendly * neo_bot_path_reservation_penalty.GetFloat();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Instead of using a huge flat penalty, power scale (n^2) based on number of friendlies on the path.

}
cost += CNEOBotPathReservations()->GetAreaAvoidPenalty(area->GetID());

if (m_routeType == SAFEST_ROUTE)
{
// NEO Jank Cheat: Incorporate enemy bot paths so that we don't run directly into their line of fire
// Intended for use by ghost carrier team, to emulate a team that knows where enemies are likely to ambush
// Compensates for bots' lack of meta knowledge by making them prefer routes not reserved by enemies
// Adheres to cheat against bots but not against humans philosophy by not considering human players' positions
const int nEnemy = CNEOBotPathReservations()->GetPredictedFriendlyPathCount(area->GetID(), GetEnemyTeam(m_me->GetTeamNumber()));
cost += nEnemy * neo_bot_path_reservation_penalty.GetFloat() * 2.0f;
}
}

if ( !m_bIgnoreVisibilityExposure && (m_routeType != FASTEST_ROUTE) )
{
// Weapon range penalties
auto* myWeapon = assert_cast<CNEOBaseCombatWeapon*>(m_me->GetActiveWeapon());
if (myWeapon)
Expand Down Expand Up @@ -199,15 +219,6 @@ float CNEOBotPathCost::operator()(CNavArea* baseArea, CNavArea* fromArea, const
}
}
}

if (m_routeType == SAFEST_ROUTE)
{
// NEO Jank Cheat: Incorporate enemy bot paths so that we don't run directly into their line of fire
// Intended for use by ghost carrier team, to emulate a team that knows where enemies are likely to ambush
// Compensates for bots' lack of meta knowledge by making them prefer routes not reserved by enemies
// Adheres to cheat against bots but not against humans philosophy by not considering human players' positions
cost += CNEOBotPathReservations()->GetPredictedFriendlyPathCount(area->GetID(), GetEnemyTeam(m_me->GetTeamNumber())) * neo_bot_path_reservation_penalty.GetFloat() * 2;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Consolidated with team-based penalties above.

}
}
// ------------------------------------------------------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions src/game/server/neo/bot/neo_bot_path_cost.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class CNEOBotPathCost : public IPathCost
virtual float operator()(CNavArea* baseArea, CNavArea* fromArea, const CNavLadder* ladder, const CFuncElevator* elevator, float length) const override;

bool m_bIgnoreReservations;
bool m_bIgnoreVisibilityExposure;

private:
CNEOBot* m_me;
Expand Down
Loading