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
29 changes: 29 additions & 0 deletions src/game/server/nav_area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,37 @@ CNavArea::CNavArea( void )
m_funcNavCostVector.RemoveAll();

m_nVisTestCounter = (uint32)-1;

#ifdef NEO
m_visibleAreaCount = 0;
#endif
}


#ifdef NEO
//--------------------------------------------------------------------------------------------------------------
struct CountPotentiallyVisibleAreas
{
int count;
CountPotentiallyVisibleAreas() : count(0) {}
bool operator()( CNavArea* area )
{
count++;
return true;
}
};


//--------------------------------------------------------------------------------------------------------------
void CNavArea::ComputePotentiallyVisibleAreaCount()
{
CountPotentiallyVisibleAreas counter;
const_cast<CNavArea*>(this)->ForAllPotentiallyVisibleAreas( counter );
m_visibleAreaCount = counter.count;
}
#endif


//--------------------------------------------------------------------------------------------------------------
/**
* Assumes Z is flat
Expand Down
7 changes: 7 additions & 0 deletions src/game/server/nav_area.h
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,10 @@ class CNavArea : protected CNavAreaCriticalData
virtual bool IsPartiallyVisible( const Vector &eye, const CBaseEntity *ignore = NULL ) const; // return true if any portion of the area is visible from given eyepoint (CPU intensive)

virtual bool IsPotentiallyVisible( const CNavArea *area ) const; // return true if given area is potentially visible from somewhere in this area (very fast)
#ifdef NEO
int GetPotentiallyVisibleAreaCount() const { return m_visibleAreaCount; }
void ComputePotentiallyVisibleAreaCount();
#endif
virtual bool IsPotentiallyVisibleToTeam( int team ) const; // return true if any portion of this area is visible to anyone on the given team (very fast)

virtual bool IsCompletelyVisible( const CNavArea *area ) const; // return true if given area is completely visible from somewhere in this area (very fast)
Expand Down Expand Up @@ -662,6 +666,9 @@ class CNavArea : protected CNavAreaCriticalData
*/

static unsigned int m_nextID; // used to allocate unique IDs
#ifdef NEO
int m_visibleAreaCount;
#endif
unsigned int m_id; // unique area ID
unsigned int m_debugid;

Expand Down
8 changes: 8 additions & 0 deletions src/game/server/nav_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,14 @@ NavErrorType CNavMesh::PostLoad( unsigned int version )
area->PostLoad();
}

#ifdef NEO
FOR_EACH_VEC( TheNavAreas, vit )
{
CNavArea *area = TheNavAreas[ vit ];
area->ComputePotentiallyVisibleAreaCount();
}
#endif

// allow hiding spots to compute information
FOR_EACH_VEC( TheHidingSpots, hit )
{
Expand Down
62 changes: 61 additions & 1 deletion src/game/server/neo/bot/neo_bot_path_cost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,34 @@
#include "neo_bot_locomotion.h"
#include "nav_mesh.h"
#include "neo_bot_path_reservation.h"
#include "weapon_neobasecombatweapon.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", false, 0, false, 60);

ConVar neo_bot_path_penalty_jump_multiplier("neo_bot_path_penalty_jump_multiplier", "100.0", FCVAR_CHEAT,
ConVar neo_bot_path_penalty_jump_multiplier("neo_bot_path_penalty_jump_multiplier", "1000.0", FCVAR_CHEAT,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that NavArea pathing costs are slightly elevated, need to bump up the penalty for jump paths to match the relatively increased baseline penalty costs.

"Maximum penalty multiplier for jump height changes in pathfinding", false, 0.01f, false, 1000.0f);

ConVar neo_bot_path_penalty_ladder_multiplier("neo_bot_path_penalty_ladder_multiplier", "3.0", FCVAR_CHEAT,
"Penalty multiplier for ladder traversal in pathfinding", true, 0.1f, true, 100.0f);

ConVar neo_bot_path_penalty_exposure_base("neo_bot_path_penalty_exposure_base", "5.0", FCVAR_CHEAT,
"General additional penalty per visible area for bots to avoid exposed areas", true, 0.0f, false, 0.0f);

ConVar neo_bot_path_penalty_exposure_pistol("neo_bot_path_penalty_exposure_pistol", "10.0", FCVAR_CHEAT,
"Additional penalty per visible area for bots wielding pistol caliber weapons", true, 0.0f, false, 0.0f);

ConVar neo_bot_path_penalty_exposure_shotgun("neo_bot_path_penalty_exposure_shotgun", "20.0", FCVAR_CHEAT,
"Additional penalty per visible area for shotgun-wielding bots", true, 0.0f, false, 0.0f);

ConVar neo_bot_path_penalty_exposure_inverse_base_battle_rifle("neo_bot_path_penalty_exposure_inverse_base_battle_rifle", "500.0", FCVAR_CHEAT,
"Base penalty for calculating inverse traversal penalty for semi-auto battle rifles", true, 1.0f, false, 0.0f);

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);

//-------------------------------------------------------------------------------------------------
CNEOBotPathCost::CNEOBotPathCost(CNEOBot* me, RouteType routeType)
{
Expand Down Expand Up @@ -126,6 +142,50 @@ float CNEOBotPathCost::operator()(CNavArea* baseArea, CNavArea* fromArea, const
cost += CNEOBotPathReservations()->GetPredictedFriendlyPathCount(area->GetID(), m_me->GetTeamNumber()) * neo_bot_path_reservation_penalty.GetFloat();
cost += CNEOBotPathReservations()->GetAreaAvoidPenalty(area->GetID());

// Weapon range penalties
CNEOBaseCombatWeapon* myWeapon = ToNEOWeapon(m_me->GetActiveWeapon());
const int nWeaponBits = myWeapon->GetNeoWepBits();
if (myWeapon && (nWeaponBits & NEO_WEP_FIREARM))
{
constexpr int nShotgunBits = NEO_WEP_AA13 | NEO_WEP_SUPA7;
constexpr int nBattleRifleBits = NEO_WEP_M41 | NEO_WEP_M41_S;
constexpr int nPistolCaliberBits = NEO_WEP_MILSO | NEO_WEP_TACHI | NEO_WEP_KYLA
| NEO_WEP_MPN | NEO_WEP_MPN_S | NEO_WEP_JITTE | NEO_WEP_JITTE_S | NEO_WEP_SRM | NEO_WEP_SRM_S;

const int visibleAreaCount = area->GetPotentiallyVisibleAreaCount();

if (nWeaponBits & nPistolCaliberBits)
{
// Weapons that don't have max first shot accuracy
const float exposurePenalty = neo_bot_path_penalty_exposure_pistol.GetFloat();
dist += visibleAreaCount * exposurePenalty;
}
else if (nWeaponBits & nShotgunBits)
{
// Weapons that have spread that can't hit long range targets
const float exposurePenalty = neo_bot_path_penalty_exposure_shotgun.GetFloat();
dist += visibleAreaCount * exposurePenalty;
}
else if (nWeaponBits & nBattleRifleBits)
{
// Weapons that benefit from medium sightlines that can see many NavAreas
const float baseline_penalty = neo_bot_path_penalty_exposure_inverse_base_battle_rifle.GetFloat();
dist += baseline_penalty / visibleAreaCount;
}
else if (nWeaponBits & NEO_WEP_SCOPEDWEAPON)
{
// Weapons that benefit from long sightlines that can see many NavAreas
const float baseline_penalty = neo_bot_path_penalty_exposure_inverse_base_scoped.GetFloat();
dist += baseline_penalty / visibleAreaCount;
}
else
{
// Generally avoiding exposed areas when traversing a wide open area
const float exposurePenalty = neo_bot_path_penalty_exposure_base.GetFloat();
dist += visibleAreaCount * exposurePenalty;
}
}

if (m_routeType == SAFEST_ROUTE)
{
// NEO Jank Cheat: Incorporate enemy bot paths so that we don't run directly into their line of fire
Expand Down
2 changes: 1 addition & 1 deletion src/game/server/neo/bot/neo_bot_path_reservation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ConVar neo_bot_path_reservation_avoid_penalty_enable("neo_bot_path_reservation_a
ConVar neo_bot_path_reservation_killed_penalty("neo_bot_path_reservation_killed_penalty", "10", FCVAR_NONE,
"Path selection penalty added to a nav area each time a bot dies moving through that area.", true, 0, false, 0);

ConVar neo_bot_path_reservation_onstuck_penalty("neo_bot_path_reservation_onstuck_penalty", "10000", FCVAR_NONE,
ConVar neo_bot_path_reservation_onstuck_penalty("neo_bot_path_reservation_onstuck_penalty", "1000", FCVAR_NONE,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When working on ladder climbing, I noticed that the previous penalty cost was so heavy that bots would fail to climb a challenging ladder a couple times and then never touch that ladder again for the rest of the match. So I figured toning down this penalty was warranted.

"Path selection penalty added to a nav area each time a bot gets stuck moving through that area.", true, 0, false, 0);


Expand Down
10 changes: 10 additions & 0 deletions src/game/shared/neo/weapons/weapon_neobasecombatweapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,14 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon

};


inline CNEOBaseCombatWeapon *ToNEOWeapon(CBaseCombatWeapon *pWeapon)
{
if (!pWeapon)
{
return nullptr;
}
return dynamic_cast<CNEOBaseCombatWeapon*>(pWeapon);
}

#endif // WEAPON_NEO_BASECOMBATWEAPON_SHARED_H
Loading