nav: pause a little if doing jump sequence

This commit is contained in:
jeefo 2023-05-12 22:41:53 +03:00
commit 57f5c1f323
No known key found for this signature in database
GPG key ID: 927BCA0779BEA8ED
3 changed files with 17 additions and 7 deletions

View file

@ -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

View file

@ -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 () {

View file

@ -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