From 57f5c1f32311b77448dc2b52eb09a235e12e309e Mon Sep 17 00:00:00 2001 From: jeefo Date: Fri, 12 May 2023 22:41:53 +0300 Subject: [PATCH] nav: pause a little if doing jump sequence --- inc/yapb.h | 1 + src/botlib.cpp | 8 +------- src/navigate.cpp | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/inc/yapb.h b/inc/yapb.h index 2e8d4d9..0e9effd 100644 --- a/inc/yapb.h +++ b/inc/yapb.h @@ -764,6 +764,7 @@ private: bool m_needToSendWelcomeChat {}; // bot needs to greet people on server? bool m_isCreature {}; // bot is not a player, but something else ? zombie ? bool m_defuseNotified {}; // bot is notified about bomb defusion + bool m_jumpSequence {}; // next path link will be jump link Pickup m_pickupType {}; // type of entity which needs to be used/picked up PathWalk m_pathWalk {}; // pointer to current node from path diff --git a/src/botlib.cpp b/src/botlib.cpp index 08e7f9c..a99fc29 100644 --- a/src/botlib.cpp +++ b/src/botlib.cpp @@ -2773,13 +2773,7 @@ void Bot::executeTasks () { auto func = getTask ()->func; // run the current task - if (func != nullptr) { - (this->*func) (); - } - else { - logger.error ("Missing callback function of Task %d.", getCurrentTaskId ()); - kick (); // drop the player, as it's fatal for bot - } + (this->*func) (); } void Bot::checkSpawnConditions () { diff --git a/src/navigate.cpp b/src/navigate.cpp index 25823f0..91743f1 100644 --- a/src/navigate.cpp +++ b/src/navigate.cpp @@ -875,6 +875,12 @@ bool Bot::updateNavigation () { m_jumpFinished = true; m_checkTerrain = false; m_desiredVelocity = nullptr; + + // cool down a little if next path after current will be jump + if (m_jumpSequence) { + startTask (Task::Pause, TaskPri::Pause, kInvalidNodeIndex, game.time () + rg.get (0.75, 1.2f) + m_frameInterval, false); + m_jumpSequence = false; + } } } else if (!cv_jasonmode.bool_ () && usesKnife () && isOnFloor ()) { @@ -2201,7 +2207,10 @@ bool Bot::advanceMovement () { } if (!m_pathWalk.empty ()) { + m_jumpSequence = false; + const int destIndex = m_pathWalk.first (); + bool isCurrentJump = false; // find out about connection flags if (destIndex != kInvalidNodeIndex && m_currentNodeIndex != kInvalidNodeIndex) { @@ -2211,6 +2220,7 @@ bool Bot::advanceMovement () { m_desiredVelocity = link.velocity; m_jumpFinished = false; + isCurrentJump = true; break; } } @@ -2242,6 +2252,11 @@ bool Bot::advanceMovement () { } } + // mark as jump sequence, if the current and next paths are jumps + if (isCurrentJump) { + m_jumpSequence = willJump; + } + // is there a jump node right ahead and do we need to draw out the light weapon ? if (willJump && !usesKnife () && m_currentWeapon != Weapon::Scout && !m_isReloading && !usesPistol () && (jumpDistance > 145.0f || (dst.z - 32.0f > src.z && jumpDistance > 125.0f)) && !(m_states & Sense::SeeingEnemy)) { selectWeaponById (Weapon::Knife); // draw out the knife if we needed