From 003fd33d5921a944ab4eb8bade60132d5fd5c0f6 Mon Sep 17 00:00:00 2001 From: jeefo Date: Wed, 22 Jan 2025 20:14:11 +0300 Subject: [PATCH] some changes --- CMakeLists.txt | 6 +++--- ext/crlib | 2 +- inc/yapb.h | 2 +- src/botlib.cpp | 2 +- src/combat.cpp | 10 +--------- src/navigate.cpp | 22 +++++++++++----------- 6 files changed, 18 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20185aa..17894ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,12 +61,12 @@ if(GIT_FOUND) target_compile_definitions(${PROJECT_NAME} PRIVATE VERSION_GENERATED) endif() -if(NOT WIN32 AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" AND NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "arm" AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc" AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm64") +if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)" AND NOT CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(arm|aarch64|ppc)") set(BUILD_X86 true) endif() if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") AND NOT MSVC) - target_compile_options(${PROJECT_NAME} PRIVATE -flto=auto -fno-exceptions -fno-rtti -fno-threadsafe-statics -pthread) + target_compile_options(${PROJECT_NAME} PRIVATE -DCR_NATIVE_BUILD -flto=auto -fno-exceptions -fno-rtti -fno-threadsafe-statics -pthread) if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "arm64") target_compile_options(${PROJECT_NAME} PRIVATE -march=armv8-a+fp+simd) @@ -77,7 +77,7 @@ if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") target_compile_options(${PROJECT_NAME} PRIVATE -funroll-loops -fomit-frame-pointer -fno-stack-protector -fvisibility=hidden -fvisibility-inlines-hidden -fno-math-errno) - if(BUILD_X86) + if(NOT WIN32 AND BUILD_X86) target_compile_options(${PROJECT_NAME} PRIVATE -fdata-sections -ffunction-sections -fcf-protection=none -fno-plt) target_link_options(${PROJECT_NAME} PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/ext/ldscripts/version.lds -Wl,--gc-sections) diff --git a/ext/crlib b/ext/crlib index 8e2acfd..2a521dd 160000 --- a/ext/crlib +++ b/ext/crlib @@ -1 +1 @@ -Subproject commit 8e2acfd0f9a64043909769dc844c37b3023d2299 +Subproject commit 2a521ddaaf8c5f60b9480dc36fadcdb0a139968e diff --git a/inc/yapb.h b/inc/yapb.h index e02674b..f99c73f 100644 --- a/inc/yapb.h +++ b/inc/yapb.h @@ -760,7 +760,7 @@ public: bool hasShield (); bool isShieldDrawn (); bool findNextBestNode (); - bool findNextBestNodeEx (const IntArray &data, bool returnFailure); + bool findNextBestNodeEx (const IntArray &data, bool handleFails); bool seesEntity (const Vector &dest, bool fromBody = false); int getAmmo (); diff --git a/src/botlib.cpp b/src/botlib.cpp index 6b5afc1..e022db3 100644 --- a/src/botlib.cpp +++ b/src/botlib.cpp @@ -3204,7 +3204,7 @@ void Bot::checkSpawnConditions () { void Bot::logic () { // this function gets called each frame and is the core of all bot ai. from here all other subroutines are called - float movedDistance = 4.0f; // length of different vector (distance bot moved) + float movedDistance = 2.0f; // length of different vector (distance bot moved) resetMovement (); diff --git a/src/combat.cpp b/src/combat.cpp index 64f2658..b3e4dc3 100644 --- a/src/combat.cpp +++ b/src/combat.cpp @@ -1596,7 +1596,7 @@ void Bot::attackMovement () { && (m_jumpTime + 5.0f < game.time () && isOnFloor () && rg (0, 1000) < (m_isReloading ? 8 : 2) - && pev->velocity.length2d () > 150.0f) && !usesSniper ()) { + && pev->velocity.length2d () > 150.0f) && !usesSniper () && isEnemyCone) { pev->button |= IN_JUMP; } @@ -1623,14 +1623,6 @@ void Bot::attackMovement () { m_strafeSpeed = 0.0f; } - if (m_difficulty >= Difficulty::Normal && isOnFloor () && m_duckTime < game.time ()) { - if (distanceSq < cr::sqrf (kSprayDistanceX2)) { - if (rg (0, 1000) < rg (5, 10) && pev->velocity.length2d () > 150.0f && isEnemyCone) { - pev->button |= IN_JUMP; - } - } - } - if (m_isReloading) { m_moveSpeed = -pev->maxspeed; m_duckTime = game.time () - 1.0f; diff --git a/src/navigate.cpp b/src/navigate.cpp index 29cf7cc..a0da664 100644 --- a/src/navigate.cpp +++ b/src/navigate.cpp @@ -486,7 +486,7 @@ void Bot::doPlayerAvoidance (const Vector &normal) { const auto otherPrio = bots.getPlayerPriority (client.ent); // give some priorities to bot avoidance - if (ownPrio < otherPrio) { + if (ownPrio > otherPrio) { continue; } @@ -495,7 +495,7 @@ void Bot::doPlayerAvoidance (const Vector &normal) { const auto avoidPrio = bots.getPlayerPriority (m_hindrance); // ignore because we're already avoiding someone better - if (avoidPrio < otherPrio) { + if (avoidPrio > otherPrio) { continue; } } @@ -557,7 +557,7 @@ void Bot::checkTerrain (float movedDistance, const Vector &dirNormal) { // standing still, no need to check? if (m_lastCollTime < game.time () && getCurrentTaskId () != Task::Attack) { // didn't we move enough previously? - if (movedDistance < 4.0f && (m_prevSpeed > 20.0f || m_prevVelocity < m_moveSpeed / 2)) { + if (movedDistance < 2.0f && (m_prevSpeed > 20.0f || m_prevVelocity < m_moveSpeed / 2)) { m_prevTime = game.time (); // then consider being stuck m_isStuck = true; @@ -1285,7 +1285,7 @@ bool Bot::updateNavigation () { } // needs precise placement - check if we get past the point - if (desiredDistanceSq < cr::sqrf (22.0f) && nodeDistanceSq < cr::sqrf (30.0f)) { + if (desiredDistanceSq < cr::sqrf (20.0f) && nodeDistanceSq < cr::sqrf (30.0f)) { const auto predictRangeSq = m_pathOrigin.distanceSq (pev->origin + pev->velocity * m_frameInterval); if (predictRangeSq >= nodeDistanceSq || predictRangeSq <= desiredDistanceSq) { @@ -1305,7 +1305,7 @@ bool Bot::updateNavigation () { return false; } - if (nodeDistanceSq < desiredDistanceSq) { + if (nodeDistanceSq <= desiredDistanceSq) { // did we reach a destination node? if (getTask ()->data == m_currentNodeIndex) { if (m_chosenGoalIndex != kInvalidNodeIndex) { @@ -1766,7 +1766,7 @@ bool Bot::findNextBestNode () { return true; } -bool Bot::findNextBestNodeEx (const IntArray &data, bool returnFailure) { +bool Bot::findNextBestNodeEx (const IntArray &data, bool handleFails) { // this function find a node in the near of the bot if bot had lost his path of pathfinder needs // to be restarted over again. @@ -1777,7 +1777,7 @@ bool Bot::findNextBestNodeEx (const IntArray &data, bool returnFailure) { lessDist[i] = kInfiniteDistance; lessIndex[i] = kInvalidNodeIndex; } - const auto &numToSkip = returnFailure ? 0 : cr::clamp (rg (0, 2), 0, static_cast (data.length () / 2)); + const auto &numToSkip = handleFails ? 1 : rg (1, 4); for (const auto &i : data) { const auto &path = graph[i]; @@ -1855,7 +1855,7 @@ bool Bot::findNextBestNodeEx (const IntArray &data, bool returnFailure) { // worst case... find at least something if (selected == kInvalidNodeIndex) { - if (returnFailure) { + if (handleFails) { return false; } selected = findNearestNode (); @@ -1960,7 +1960,7 @@ int Bot::findNearestNode () { int index = kInvalidNodeIndex; float nearestDistanceSq = cr::sqrf (kMaxDistance); - const auto &origin = pev->origin + pev->velocity * m_frameInterval; + const auto &origin = pev->origin + Vector { pev->velocity.x, pev->velocity.y, 0.0f } * m_frameInterval; const auto &bucket = graph.getNodesInBucket (origin); for (const auto &i : bucket) { @@ -1969,7 +1969,7 @@ int Bot::findNearestNode () { if (!graph.exists (path.number)) { continue; } - const float distanceSq = path.origin.distanceSq (pev->origin); + const float distanceSq = path.origin.distanceSq (origin); if (distanceSq < nearestDistanceSq) { // if bot doing navigation, make sure node really visible and reachable @@ -1991,7 +1991,7 @@ int Bot::findNearestNode () { if (!graph.exists (path.number)) { continue; } - const float distanceSq = path.origin.distanceSq (pev->origin); + const float distanceSq = path.origin.distanceSq (origin); if (distanceSq < nearestDistanceSq) { TraceResult tr {};