-
Notifications
You must be signed in to change notification settings - Fork 22
Bots apply nav pathing penalties based on weapon limits #1805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
eca69c6
824d781
2ff7598
0d3c381
9aea8eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,13 +9,28 @@ | |
| 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); | ||
| "How often to check for friendly path dispersion", true, 0, true, 60); | ||
|
|
||
| ConVar neo_bot_path_penalty_jump_multiplier("neo_bot_path_penalty_jump_multiplier", "100.0", FCVAR_CHEAT, | ||
| "Maximum penalty multiplier for jump height changes in pathfinding", false, 0.01f, false, 1000.0f); | ||
| ConVar neo_bot_path_penalty_jump_multiplier("neo_bot_path_penalty_jump_multiplier", "100000.0", FCVAR_CHEAT, | ||
| "Maximum penalty multiplier for jump height changes in pathfinding", true, 0.01f, false, 0.0f); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Further increasing the jump penalty as I increased the path reservation penalty below. |
||
|
|
||
| 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); | ||
| "Penalty multiplier for ladder traversal in pathfinding", true, 0.1f, false, 0.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) | ||
|
|
@@ -126,6 +141,55 @@ 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 | ||
| auto* myWeapon = assert_cast<CNEOBaseCombatWeapon*>(m_me->GetActiveWeapon()); | ||
| if (myWeapon) | ||
| { | ||
| const int nWeaponBits = myWeapon->GetNeoWepBits(); | ||
| if (nWeaponBits & NEO_WEP_FIREARM) | ||
| { | ||
| const int visibleAreaCount = area->GetPotentiallyVisibleAreaCount(); | ||
| if (visibleAreaCount > 0) | ||
| { | ||
| 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; | ||
|
|
||
| if (nWeaponBits & nPistolCaliberBits) | ||
| { | ||
| // Weapons that don't have max first shot accuracy | ||
| const float exposurePenalty = neo_bot_path_penalty_exposure_pistol.GetFloat(); | ||
| cost += visibleAreaCount * exposurePenalty; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing the penalty addition to cost enhanced the effect of bots bunching up together behind cover, so I tweaked the other penalties to encourage bots to spread out if they are in the same room. |
||
| } | ||
| 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(); | ||
| cost += 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(); | ||
| cost += 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(); | ||
| cost += baseline_penalty / visibleAreaCount; | ||
| } | ||
| else | ||
| { | ||
| // Generally avoiding exposed areas when traversing a wide open area | ||
| const float exposurePenalty = neo_bot_path_penalty_exposure_base.GetFloat(); | ||
| cost += 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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,13 +12,13 @@ ConVar neo_bot_path_reservation_enable("neo_bot_path_reservation_enable", "1", F | |
| "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); | ||
| "How long a path reservation lasts, in seconds.", true, 1, false, 0); | ||
|
|
||
| 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_distance("neo_bot_path_reservation_distance", "100000", FCVAR_NONE, | ||
| "How far along the path to reserve, in Hammer units.", true, 0, false, 0); | ||
|
|
||
| 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_penalty("neo_bot_path_reservation_penalty", "10000", FCVAR_NONE, | ||
| "Pathing cost penalty for a reserved area.", true, 0, false, 0); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Encourage bots to spread out in a room if they are traversing the same room as other bot teammates. Otherwise bots bunch up together to take the same covered path. |
||
|
|
||
| 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); | ||
|
|
@@ -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, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With DEFAULT_ROUTE on this PR, bots don't chase ghost carriers fast enough as they sneak behind cover which wastes pursuit time. I decided that it's better to risk bunching up while taking the FASTEST_ROUTE, and then let the dispatch to the Attack behavior above to use DEFAULT_ROUTE when actually attacking enemies. So pursuers beeline as fast as possible to the ghoster until they contact the enemy, and then split up along different paths at that point.