From 085c4aab851f7f0c32ee3330c8b4f59d1213478d Mon Sep 17 00:00:00 2001 From: jeefo Date: Wed, 12 Apr 2023 11:28:57 +0300 Subject: [PATCH] bot: remove check for weapon switch time by now --- inc/yapb.h | 1 - src/botlib.cpp | 2 +- src/combat.cpp | 42 +++++++++++++++++++----------------------- src/manager.cpp | 1 - 4 files changed, 20 insertions(+), 26 deletions(-) diff --git a/inc/yapb.h b/inc/yapb.h index 105fb0e..5819871 100644 --- a/inc/yapb.h +++ b/inc/yapb.h @@ -686,7 +686,6 @@ private: float m_changeViewTime {}; // timestamp to change look at while at freezetime float m_breakableTime {}; // breakeble acquired time float m_jumpDistance {}; // last jump distance - float m_lastBadWeaponSwitchTime {}; // last time we're switched weapon as it's bad bool m_moveToGoal {}; // bot currently moving to goal?? bool m_isStuck {}; // bot is stuck diff --git a/src/botlib.cpp b/src/botlib.cpp index efbf192..a6e58df 100644 --- a/src/botlib.cpp +++ b/src/botlib.cpp @@ -1599,7 +1599,7 @@ void Bot::overrideConditions () { } // special handling for reloading - if (getCurrentTaskId () == Task::Normal && m_reloadState != Reload::None && m_isReloading && !isInNarrowPlace ()) { + if (getCurrentTaskId () == Task::Normal && m_reloadState != Reload::None && m_isReloading && !isDucking () && !isInNarrowPlace ()) { if (m_seeEnemyTime + 2.5f < game.time () && (m_states & (Sense::SuspectEnemy | Sense::HearingEnemy))) { m_moveSpeed = m_fearLevel > m_agressionLevel ? 0.0f : getShiftSpeed (); m_navTimeset = game.time (); diff --git a/src/combat.cpp b/src/combat.cpp index afd6322..5c590cc 100644 --- a/src/combat.cpp +++ b/src/combat.cpp @@ -1023,34 +1023,30 @@ bool Bot::isWeaponBadAtDistance (int weaponIndex, float distance) { // to attack our enemy, since current weapon is not very good in this situation. // do not switch weapons when crossing the distance line - if (m_lastBadWeaponSwitchTime + 3.0f < game.time ()) { - auto &info = conf.getWeapons (); + auto &info = conf.getWeapons (); - if (m_difficulty < Difficulty::Normal || !hasSecondaryWeapon ()) { - return false; - } - auto weaponType = info[weaponIndex].type; + if (m_difficulty < Difficulty::Normal || !hasSecondaryWeapon ()) { + return false; + } + auto weaponType = info[weaponIndex].type; - if (weaponType == WeaponType::Melee) { - return false; - } + if (weaponType == WeaponType::Melee) { + return false; + } - // check is ammo available for secondary weapon - if (m_ammoInClip[info[bestSecondaryCarried ()].id] >= 3) { - return false; - } + // check is ammo available for secondary weapon + if (m_ammoInClip[info[bestSecondaryCarried ()].id] >= 3) { + return false; + } - // better use pistol in short range distances, when using sniper weapons - if (weaponType == WeaponType::Sniper && distance < 400.0f) { - m_lastBadWeaponSwitchTime = game.time (); - return true; - } + // better use pistol in short range distances, when using sniper weapons + if (weaponType == WeaponType::Sniper && distance < 400.0f) { + return true; + } - // shotguns is too inaccurate at long distances, so weapon is bad - if (weaponType == WeaponType::Shotgun && distance > 750.0f) { - m_lastBadWeaponSwitchTime = game.time (); - return true; - } + // shotguns is too inaccurate at long distances, so weapon is bad + if (weaponType == WeaponType::Shotgun && distance > 750.0f) { + return true; } return false; } diff --git a/src/manager.cpp b/src/manager.cpp index d367980..e89128e 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -1411,7 +1411,6 @@ void Bot::newRound () { m_combatStrafeDir = Dodge::None; m_fightStyle = Fight::None; m_lastFightStyleCheck = 0.0f; - m_lastBadWeaponSwitchTime = 0.0f; m_checkWeaponSwitch = true; m_checkKnifeSwitch = true;