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
4 changes: 2 additions & 2 deletions src/game/server/neo/bot/neo_bot_path_compute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

extern ConVar neo_bot_path_reservation_enabled;
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_enabled.GetBool() || !path.IsValid())
if (!neo_bot_path_reservation_enable.GetBool() || !path.IsValid())
{
return;
}
Expand Down
9 changes: 3 additions & 6 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,7 @@
#include "nav_mesh.h"
#include "neo_bot_path_reservation.h"

ConVar neo_bot_path_friendly_reservation_enable("neo_bot_path_friendly_reservation_enable", "1", FCVAR_NONE,
"Enable friendly bot path dispersal", true, 0, false, 1);
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", false, 0, false, 60);
Expand All @@ -23,7 +22,7 @@ CNEOBotPathCost::CNEOBotPathCost(CNEOBot* me, RouteType routeType)
m_stepHeight = me->GetLocomotionInterface()->GetStepHeight();
m_maxJumpHeight = me->GetLocomotionInterface()->GetMaxJumpHeight();
m_maxDropHeight = me->GetLocomotionInterface()->GetDeathDropHeight();
m_bIgnoreReservations = !neo_bot_path_friendly_reservation_enable.GetBool();
m_bIgnoreReservations = !neo_bot_path_reservation_enable.GetBool();
}

//-------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -112,9 +111,7 @@ float CNEOBotPathCost::operator()(CNavArea* baseArea, CNavArea* fromArea, const

// ------------------------------------------------------------------------------------------------
// New path reservation related cost adjustments
if ( neo_bot_path_friendly_reservation_enable.GetBool()
&& !m_bIgnoreReservations
&& (m_routeType != FASTEST_ROUTE) )
if ( !m_bIgnoreReservations && (m_routeType != FASTEST_ROUTE) )
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Realized that m_bIgnoreReservations was already set based on neo_bot_path_friendly_reservation_enable in the constructor, so there's no need to check the latter again.

{
cost += CNEOBotPathReservations()->GetPredictedFriendlyPathCount(area->GetID(), m_me->GetTeamNumber()) * neo_bot_path_reservation_penalty.GetFloat();
cost += CNEOBotPathReservations()->GetAreaStuckPenalty(area->GetID());
Expand Down
49 changes: 33 additions & 16 deletions src/game/server/neo/bot/neo_bot_path_reservation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,28 @@
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

ConVar neo_bot_path_reservation_enabled("neo_bot_path_reservation_enabled", "1", FCVAR_NONE, "Enable the bot path reservation system.");
ConVar neo_bot_path_reservation_penalty("neo_bot_path_reservation_penalty", "100", FCVAR_NONE, "Pathing cost penalty for a reserved area.");
ConVar neo_bot_path_reservation_duration("neo_bot_path_reservation_duration", "30.0", FCVAR_NONE, "How long a path reservation lasts, in seconds.");
ConVar neo_bot_path_reservation_distance("neo_bot_path_reservation_distance", "10000", FCVAR_NONE, "How far along the path to reserve, in Hammer units.");
ConVar neo_bot_path_reservation_onstuck_penalty_enabled("neo_bot_path_reservation_onstuck_penalty_enabled", "1", FCVAR_NONE, "Whether to update or retrieve the area onstuck penalty.");
ConVar neo_bot_path_reservation_onstuck_penalty("neo_bot_path_reservation_onstuck_penalty", "10000", FCVAR_NONE, "Path selection penalty added to a nav area each time a bot gets stuck moving through that area.");

ConVar neo_bot_path_reservation_enable("neo_bot_path_reservation_enable", "1", FCVAR_NONE,
"Enable the bot path reservation system.", true, 0, true, 1);

ConVar neo_bot_path_reservation_duration("neo_bot_path_reservation_duration", "30.0", FCVAR_NONE,
"How long a path reservation lasts, in seconds.", true, 1, true, 1000000);

ConVar neo_bot_path_reservation_distance("neo_bot_path_reservation_distance", "10000", FCVAR_NONE,
"How far along the path to reserve, in Hammer units.", true, 0, true, 1000000);

ConVar neo_bot_path_reservation_penalty("neo_bot_path_reservation_penalty", "100", FCVAR_NONE,
"Pathing cost penalty for a reserved area.", true, 0, true, 1000000);

ConVar neo_bot_path_reservation_friendly_penalty_enable("neo_bot_path_reservation_friendly_penalty_enable", "1", FCVAR_NONE,
"Whether to update or retrieve the area friendly reservation penalty.", true, 0, true, 1);

ConVar neo_bot_path_reservation_onstuck_penalty_enable("neo_bot_path_reservation_onstuck_penalty_enable", "1", FCVAR_NONE,
"Whether to update or retrieve the area onstuck penalty.", true, 0, true, 1);

ConVar neo_bot_path_reservation_onstuck_penalty("neo_bot_path_reservation_onstuck_penalty", "10000", FCVAR_NONE,
"Path selection penalty added to a nav area each time a bot gets stuck moving through that area.", true, 0, true, 1000000);



CNEOBotPathReservationSystem* CNEOBotPathReservations()
Expand All @@ -37,7 +53,7 @@ void CNEOBotPathReservationSystem::ReserveArea(CNavArea *area, CNEOBot *bot, flo
}

int team = bot->GetTeamNumber();
if (team < 0 || team >= MAX_TEAMS)
if (team < 0 || team >= TEAM__TOTAL)
{
return;
}
Expand Down Expand Up @@ -92,7 +108,7 @@ void CNEOBotPathReservationSystem::ReleaseArea(CNavArea *area, CNEOBot *bot)
}

int team = bot->GetTeamNumber();
if (team < 0 || team >= MAX_TEAMS)
if (team < 0 || team >= TEAM__TOTAL)
{
return;
}
Expand Down Expand Up @@ -138,7 +154,7 @@ void CNEOBotPathReservationSystem::ReleaseAllAreas(CNEOBot *bot)
}

int team = bot->GetTeamNumber();
if (team < 0 || team >= MAX_TEAMS)
if (team < 0 || team >= TEAM__TOTAL)
{
return;
}
Expand Down Expand Up @@ -190,7 +206,7 @@ bool CNEOBotPathReservationSystem::IsAreaReservedByTeammate(CNavArea *area, CNEO
}

int team = avoider->GetTeamNumber();
if (team < 0 || team >= MAX_TEAMS)
if (team < 0 || team >= TEAM__TOTAL)
{
return false;
}
Expand Down Expand Up @@ -226,7 +242,7 @@ bool CNEOBotPathReservationSystem::IsAreaReservedByTeammate(CNavArea *area, CNEO
*/
void CNEOBotPathReservationSystem::Clear()
{
for (int team = 0; team < MAX_TEAMS; ++team)
for (int team = 0; team < TEAM__TOTAL; ++team)
{
m_Reservations[team].RemoveAll();
m_AreaPathCounts[team].RemoveAll();
Expand All @@ -238,7 +254,7 @@ void CNEOBotPathReservationSystem::Clear()
//-------------------------------------------------------------------------------------------------
void CNEOBotPathReservationSystem::IncrementPredictedFriendlyPathCount( int areaID, int teamID )
{
if (teamID < 0 || teamID >= MAX_TEAMS)
if (teamID < 0 || teamID >= TEAM__TOTAL)
{
return;
}
Expand All @@ -257,7 +273,7 @@ void CNEOBotPathReservationSystem::IncrementPredictedFriendlyPathCount( int area
//-------------------------------------------------------------------------------------------------
void CNEOBotPathReservationSystem::DecrementPredictedFriendlyPathCount( int areaID, int teamID )
{
if (teamID < 0 || teamID >= MAX_TEAMS)
if (teamID < 0 || teamID >= TEAM__TOTAL)
{
return;
}
Expand All @@ -276,7 +292,8 @@ void CNEOBotPathReservationSystem::DecrementPredictedFriendlyPathCount( int area
//-------------------------------------------------------------------------------------------------
int CNEOBotPathReservationSystem::GetPredictedFriendlyPathCount( int areaID, int teamID ) const
{
if (teamID < 0 || teamID >= MAX_TEAMS)
if (!neo_bot_path_reservation_friendly_penalty_enable.GetBool()
|| teamID < 0 || teamID >= TEAM__TOTAL)
{
return 0;
}
Expand All @@ -293,7 +310,7 @@ int CNEOBotPathReservationSystem::GetPredictedFriendlyPathCount( int areaID, int
//-------------------------------------------------------------------------------------------------
void CNEOBotPathReservationSystem::IncrementAreaStuckPenalty(unsigned int navAreaID)
{
if ( !neo_bot_path_reservation_onstuck_penalty_enabled.GetBool() )
if ( !neo_bot_path_reservation_onstuck_penalty_enable.GetBool() )
{
return;
}
Expand All @@ -310,7 +327,7 @@ void CNEOBotPathReservationSystem::IncrementAreaStuckPenalty(unsigned int navAre
//-------------------------------------------------------------------------------------------------
float CNEOBotPathReservationSystem::GetAreaStuckPenalty(unsigned int navAreaID) const
{
if ( !neo_bot_path_reservation_onstuck_penalty_enabled.GetBool() )
if ( !neo_bot_path_reservation_onstuck_penalty_enable.GetBool() )
{
return 0.0f;
}
Expand Down
8 changes: 4 additions & 4 deletions src/game/server/neo/bot/neo_bot_path_reservation.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CNEOBotPathReservationSystem

CNEOBotPathReservationSystem() : m_BotReservedAreas(EHandleLessFunc), m_AreaOnStuckPenalties(DefLessFunc(unsigned int))
{
for (int i = 0; i < MAX_TEAMS; ++i)
for (int i = 0; i < TEAM__TOTAL; ++i)
{
m_Reservations[i].SetLessFunc(ReservationLessFunc);
m_AreaPathCounts[i].SetLessFunc(ReservationLessFunc);
Expand All @@ -68,16 +68,16 @@ class CNEOBotPathReservationSystem
friend CNEOBotPathReservationSystem* CNEOBotPathReservations();

private:
CUtlMap<int, ReservationInfo> m_Reservations[MAX_TEAMS];
CUtlMap<int, ReservationInfo> m_Reservations[TEAM__TOTAL];
CUtlMap<EHANDLE, BotReservedAreas_t> m_BotReservedAreas;
CUtlMap<int, int> m_AreaPathCounts[MAX_TEAMS];
CUtlMap<int, int> m_AreaPathCounts[TEAM__TOTAL];
CUtlMap<unsigned int, float> m_AreaOnStuckPenalties;
};


CNEOBotPathReservationSystem* CNEOBotPathReservations();

extern ConVar neo_bot_path_reservation_enabled;
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;