Bots avoid hazard areas#2020
Conversation
Bots avoid hazard areas: - areas that are in line of sight of a smoke cloud - areas that are in line of sight of a grenade trajectory - areas where a teammate recently died
| else | ||
| { | ||
| // Fallback if GetLastKnownArea is null, try finding nearest nav area | ||
| CNavArea *nearestArea = TheNavMesh->GetNearestNavArea( me->GetAbsOrigin() ); |
There was a problem hiding this comment.
I decided that if for some reason the situation was bugged enough that we don't know the GetLastKnownArea of a bot, we shouldn't bother trying to search for GetNearestNavArea. GetNearestNavArea is a bit more expensive and, if the situation is glitched, might not even return an appropriate navarea.
sunzenshen
left a comment
There was a problem hiding this comment.
The goal of this PR was to have bots avoid areas that were visible from smoked areas, if they do not have thermal vision. Before this PR, bots tended to disregard smoke and would fall victim to either Support bots or humans that know to spray into the smoke. This PR introduces a time-expiring hazard area marking lookup for smoke and general hazardous areas.
Along with support for smoke, I added hazard area marking for grenades and death locations. The thinking for bot grenade trajectories is that they are so erratic that it's safer to assume that any place along the trajectory towards the target and beyond is a dangerous area. For marking death areas of friendly bots, it's mostly to have bots pause towards running into a fatal funnel if the room is narrow enough to be blocked by the bot death locations.
| return -1.0f; | ||
| return -1.0f; // attempt to route around hazards | ||
| } | ||
| } |
There was a problem hiding this comment.
The diff on this file is kind of ugly, but this hazard avoidance marking is the new change. A return value of -1.0 is considered an impassable navarea. The assumption is that this impassability applies only when a bot is not in a hazard area, and if a bot was in a hazard area, then they will check that in tactical monitor and try to exit the hazard area.
| // first area in path, no cost | ||
| return 0.0f; | ||
| } | ||
| else |
There was a problem hiding this comment.
The rest of this file was getting rid of one level of indentation inherited from copying CSimpleBotPathCost, by getting rid of this else.
|
Demo example of bots moving out of a room with smoke coverage, into one where there is no exposed smoke: bot-avoid-smoke-demo.mp4 |
sunzenshen
left a comment
There was a problem hiding this comment.
I forgot that I also incremented OnStuck area avoidance penalties for bot death areas, not just for bots getting stuck so here's another set of adjustments when testing the allowance of bot death areas as candidates for where to escape a hazard.
| { | ||
| return true; | ||
| } | ||
| if (CNEOBotPathReservations()->GetAreaAvoidPenalty(navAreaId) >= m_onStuckPenalty) |
There was a problem hiding this comment.
I forgot I added avoidance penalties for areas where a bot died, so I made the threshold under which a bot got stuck in a location, allowing to minor penalty for death areas to be used as candidates if under the OnStuck threshold.
|
|
||
| if ( m_goalArea && m_attackCoverArea ) | ||
| { | ||
| return ANSWER_NO; |
There was a problem hiding this comment.
While preventing the bots from retreating when they are rushing for a cover area was okay for proving out #2000, it made the bots a bit suicidal when their chosen advancing cover was too exposed, so I think it's better to retreat when there's any incoming fire.
This also encourages more grenade throw attempts which is helpful for viewing the smoke and grenade avoidance behavior.
| { | ||
| m_coverArea = FindCoverArea( me ); | ||
| CNEOBotPathCompute(me, m_path, m_coverArea->GetCenter(), FASTEST_ROUTE); | ||
| CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat()); |
There was a problem hiding this comment.
If a bot gets stuck, sometimes the chosen cover area is the culprit, so look for another random cover area to reset.
Description
Bots avoid hazard areas:
Toolchain