From d3dff431c6f2440f71a91bad24089c269de1de29 Mon Sep 17 00:00:00 2001 From: jeefo Date: Tue, 4 Feb 2020 20:05:32 +0300 Subject: [PATCH] Do not react on enemies while climbing ladders instead of jumping from them. #119 Do not test for bad primary weapon, if we have no secondary at all. #119 --- source/basecode.cpp | 7 +------ source/combat.cpp | 2 +- source/graph.cpp | 14 ++++++++------ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/source/basecode.cpp b/source/basecode.cpp index 60c3731..6eaa98c 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -2176,7 +2176,7 @@ bool Bot::reactOnEnemy () { auto lineDist = (m_enemy->v.origin - pev->origin).length (); auto pathDist = static_cast (graph.getPathDist (ownIndex, enemyIndex)); - if (pathDist - lineDist > 112.0f) { + if (pathDist - lineDist > 112.0f || isOnLadder ()) { m_isEnemyReachable = false; } else { @@ -3444,11 +3444,6 @@ void Bot::attackEnemy_ () { if (!game.isNullEntity (m_enemy)) { ignoreCollision (); - - if (isOnLadder ()) { - pev->button |= IN_JUMP; - clearSearchNodes (); - } attackMovement (); if (m_currentWeapon == Weapon::Knife && !m_lastEnemyOrigin.empty ()) { diff --git a/source/combat.cpp b/source/combat.cpp index 58e637c..cc6df86 100644 --- a/source/combat.cpp +++ b/source/combat.cpp @@ -945,7 +945,7 @@ bool Bot::isWeaponBadAtDistance (int weaponIndex, float distance) { auto &info = conf.getWeapons (); - if (m_difficulty < 2) { + if (m_difficulty < 2 || !hasSecondaryWeapon ()) { return false; } int wid = info[weaponIndex].id; diff --git a/source/graph.cpp b/source/graph.cpp index 20227d2..857d571 100644 --- a/source/graph.cpp +++ b/source/graph.cpp @@ -2673,16 +2673,18 @@ void BotGraph::eraseFromDisk () { // this function removes graph file from the hard disk StringArray forErase; - const char *map = game.getMapName (); + + auto map = game.getMapName (); + auto data = getDataDirectory (); bots.kickEveryone (true); // if we're delete graph, delete all corresponding to it files - forErase.push (strings.format ("%s%s.pwf", getDataDirectory (), map)); // graph itself - forErase.push (strings.format ("%slearned/%s.exp", getDataDirectory (), map)); // corresponding to practice - forErase.push (strings.format ("%slearned/%s.vis", getDataDirectory (), map)); // corresponding to vistable - forErase.push (strings.format ("%slearned/%s.pmx", getDataDirectory (), map)); // corresponding to matrix - forErase.push (strings.format ("%sgraph/%s.graph", getDataDirectory (), map)); // new format graph + forErase.push (strings.format ("%s%s.pwf", data, map)); // graph itself + forErase.push (strings.format ("%slearned/%s.exp", data, map)); // corresponding to practice + forErase.push (strings.format ("%slearned/%s.vis", data, map)); // corresponding to vistable + forErase.push (strings.format ("%slearned/%s.pmx", data, map)); // corresponding to matrix + forErase.push (strings.format ("%sgraph/%s.graph", data, map)); // new format graph for (const auto &item : forErase) { if (File::exists (item)) {