mirror of
https://github.com/ENSL/NS.git
synced 2024-11-24 21:41:17 +00:00
Bot stuck checks
* Bots will now suicide if falling for more than 15 seconds, handle stuck situations * Bots will hopefully not get stuck in walk nodes as much
This commit is contained in:
parent
fcddb5b6c3
commit
ff3b4afb1c
3 changed files with 16 additions and 0 deletions
|
@ -607,6 +607,7 @@ typedef struct _NAV_STATUS
|
|||
Vector UnstuckMoveLocation = g_vecZero; // If the bot is unable to find a path, blindly move here to try and fix the problem
|
||||
|
||||
float LandedTime = 0.0f; // When the bot last landed after a fall/jump.
|
||||
float AirStartedTime = 0.0f; // When the bot left the ground if in the air
|
||||
float LeapAttemptedTime = 0.0f; // When the bot last attempted to leap/blink. Avoid spam that sends it flying around too fast
|
||||
bool bIsJumping = false; // Is the bot in the air from a jump? Will duck so it can duck-jump
|
||||
bool IsOnGround = true; // Is the bot currently on the ground, or on a ladder?
|
||||
|
|
|
@ -4687,6 +4687,8 @@ bool IsBotOffWalkNode(const AvHAIPlayer* pBot, Vector MoveStart, Vector MoveEnd,
|
|||
// This shouldn't happen... but does occasionally. Walk moves should always be directly reachable from start to end
|
||||
//if (!UTIL_PointIsDirectlyReachable(MoveStart, MoveEnd)) { return true; }
|
||||
|
||||
if (UTIL_PointIsDirectlyReachable(MoveStart, MoveEnd) && !UTIL_PointIsDirectlyReachable(pBot->CurrentFloorPosition, MoveEnd)) { return true; }
|
||||
|
||||
Vector NearestPointOnLine = vClosestPointOnLine2D(MoveStart, MoveEnd, pBot->Edict->v.origin);
|
||||
|
||||
if (vDist2DSq(pBot->Edict->v.origin, NearestPointOnLine) > sqrf(GetPlayerRadius(pBot->Edict) * 3.0f)) { return true; }
|
||||
|
|
|
@ -1782,11 +1782,24 @@ void StartNewBotFrame(AvHAIPlayer* pBot)
|
|||
|
||||
pBot->BotNavInfo.IsOnGround = true;
|
||||
pBot->BotNavInfo.bIsJumping = false;
|
||||
pBot->BotNavInfo.AirStartedTime = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pBot->BotNavInfo.IsOnGround)
|
||||
{
|
||||
pBot->BotNavInfo.AirStartedTime = gpGlobals->time;
|
||||
}
|
||||
|
||||
pBot->BotNavInfo.IsOnGround = false;
|
||||
|
||||
// It's possible that players can get stuck in angled geometry where they're permanently in the air
|
||||
// This just checks for that possibility: if a bot is falling for more than 15 seconds they're probably stuck and should suicide
|
||||
if (pBot->BotNavInfo.AirStartedTime > 0.0f && gpGlobals->time - pBot->BotNavInfo.AirStartedTime > 15.0f)
|
||||
{
|
||||
BotSuicide(pBot);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pBot->BotNavInfo.bHasAttemptedJump = false;
|
||||
|
|
Loading…
Reference in a new issue