From f0b74452d33a587cebc8a5579896af07ae7d58e7 Mon Sep 17 00:00:00 2001 From: jeefo Date: Fri, 31 Jan 2025 23:45:35 +0300 Subject: [PATCH] nav: break camp task if avoiding --- src/navigate.cpp | 17 +++++++++++++++-- src/support.cpp | 3 +-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/navigate.cpp b/src/navigate.cpp index f476aaf..4086c9c 100644 --- a/src/navigate.cpp +++ b/src/navigate.cpp @@ -478,6 +478,18 @@ void Bot::doPlayerAvoidance (const Vector &normal) { const auto ownPrio = bots.getPlayerPriority (ent ()); + auto clearCamp = [] (edict_t *ent) { + auto bot = bots[ent]; + + if (bot) { + auto tid = bot->getCurrentTaskId (); + + if (tid == Task::Camp || tid == Task::Hide || tid == Task::Pause) { + bot->completeTask (); + } + } + }; + // find nearest player to bot for (const auto &client : util.getClients ()) { if (!(client.flags & ClientFlags::Used) || !(client.flags & ClientFlags::Alive) || client.team != m_team || client.ent == ent ()) { @@ -554,6 +566,7 @@ void Bot::doPlayerAvoidance (const Vector &normal) { } } m_isStuck = false; + m_navTimeset = game.time (); if (distanceSq < cr::sqrf (96.0f)) { if ((dir | forward.normalize2d_apx ()) < 0.0f) { @@ -1304,7 +1317,7 @@ bool Bot::updateNavigation () { } // always increase reachability distance for occupied nodes - if (isOccupiedNode (m_path->number, pathHasFlags)) { + if (!(graph[m_path->number].flags & NodeFlag::Crouch) && isOccupiedNode (m_path->number, pathHasFlags)) { desiredDistanceSq = cr::sqrf (96.0f); nodeDistanceSq *= 0.5f; } @@ -2622,7 +2635,7 @@ void Bot::setPathOrigin () { }; // if node radius non zero vary origin a bit depending on the body angles - if (radius > 16.0f) { + if (radius > 16.0f && !isInNarrowPlace ()) { int nearestIndex = kInvalidNodeIndex; if (!m_pathWalk.empty () && m_pathWalk.hasNext ()) { diff --git a/src/support.cpp b/src/support.cpp index f85b136..815191d 100644 --- a/src/support.cpp +++ b/src/support.cpp @@ -266,13 +266,12 @@ bool BotSupport::isBreakableEntity (edict_t *ent, bool initialSeed) { constexpr auto kFuncWall = StringRef::fnv1a32 ("func_wall"); if (ent->v.takedamage > 0.0f && ent->v.impulse <= 0 && !(ent->v.flags & FL_WORLDBRUSH) && !(ent->v.spawnflags & SF_BREAK_TRIGGER_ONLY)) { - auto classHash = ent->v.classname.str ().hash (); + const auto classHash = ent->v.classname.str ().hash (); if (classHash == kFuncBreakable || (classHash == kFuncPushable && (ent->v.spawnflags & SF_PUSH_BREAKABLE)) || classHash == kFuncWall) { return ent->v.movetype == MOVETYPE_PUSH || ent->v.movetype == MOVETYPE_PUSHSTEP; } } - return false; }