nav: allow bots to duck on goal and camp nodes if it's a route end

This commit is contained in:
jeefo 2024-04-13 15:04:04 +03:00
commit b790e7a4bb
No known key found for this signature in database
GPG key ID: 927BCA0779BEA8ED

View file

@ -819,9 +819,13 @@ void Bot::moveToGoal () {
findValidNode ();
// press duck button if we need to
if ((m_pathFlags & NodeFlag::Crouch) && !(m_pathFlags & (NodeFlag::Camp | NodeFlag::Goal))) {
if (m_pathFlags & NodeFlag::Crouch) {
constexpr auto kEndRouteThreshold = 3;
if (!(m_pathFlags & (NodeFlag::Camp | NodeFlag::Goal)) || m_pathWalk.length () < kEndRouteThreshold) {
pev->button |= IN_DUCK;
}
}
m_lastUsedNodesTime = game.time ();
// special movement for swimming here
@ -1114,7 +1118,7 @@ bool Bot::updateNavigation () {
}
float desiredDistanceSq = cr::sqrf (4.0f);
const float nodeDistanceSq = pev->origin.distanceSq2d (m_pathOrigin);
const float nodeDistanceSq = pev->origin.distanceSq (m_pathOrigin);
// initialize the radius for a special node type, where the node is considered to be reached
if (m_pathFlags & NodeFlag::Lift) {