some changes
This commit is contained in:
parent
44567766be
commit
003fd33d59
6 changed files with 18 additions and 26 deletions
|
|
@ -61,12 +61,12 @@ if(GIT_FOUND)
|
||||||
target_compile_definitions(${PROJECT_NAME} PRIVATE VERSION_GENERATED)
|
target_compile_definitions(${PROJECT_NAME} PRIVATE VERSION_GENERATED)
|
||||||
endif()
|
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)
|
set(BUILD_X86 true)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") AND NOT MSVC)
|
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")
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
|
||||||
target_compile_options(${PROJECT_NAME} PRIVATE -march=armv8-a+fp+simd)
|
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")
|
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)
|
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_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)
|
target_link_options(${PROJECT_NAME} PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/ext/ldscripts/version.lds -Wl,--gc-sections)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8e2acfd0f9a64043909769dc844c37b3023d2299
|
Subproject commit 2a521ddaaf8c5f60b9480dc36fadcdb0a139968e
|
||||||
|
|
@ -760,7 +760,7 @@ public:
|
||||||
bool hasShield ();
|
bool hasShield ();
|
||||||
bool isShieldDrawn ();
|
bool isShieldDrawn ();
|
||||||
bool findNextBestNode ();
|
bool findNextBestNode ();
|
||||||
bool findNextBestNodeEx (const IntArray &data, bool returnFailure);
|
bool findNextBestNodeEx (const IntArray &data, bool handleFails);
|
||||||
bool seesEntity (const Vector &dest, bool fromBody = false);
|
bool seesEntity (const Vector &dest, bool fromBody = false);
|
||||||
|
|
||||||
int getAmmo ();
|
int getAmmo ();
|
||||||
|
|
|
||||||
|
|
@ -3204,7 +3204,7 @@ void Bot::checkSpawnConditions () {
|
||||||
void Bot::logic () {
|
void Bot::logic () {
|
||||||
// this function gets called each frame and is the core of all bot ai. from here all other subroutines are called
|
// 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 ();
|
resetMovement ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1596,7 +1596,7 @@ void Bot::attackMovement () {
|
||||||
&& (m_jumpTime + 5.0f < game.time ()
|
&& (m_jumpTime + 5.0f < game.time ()
|
||||||
&& isOnFloor ()
|
&& isOnFloor ()
|
||||||
&& rg (0, 1000) < (m_isReloading ? 8 : 2)
|
&& rg (0, 1000) < (m_isReloading ? 8 : 2)
|
||||||
&& pev->velocity.length2d () > 150.0f) && !usesSniper ()) {
|
&& pev->velocity.length2d () > 150.0f) && !usesSniper () && isEnemyCone) {
|
||||||
|
|
||||||
pev->button |= IN_JUMP;
|
pev->button |= IN_JUMP;
|
||||||
}
|
}
|
||||||
|
|
@ -1623,14 +1623,6 @@ void Bot::attackMovement () {
|
||||||
m_strafeSpeed = 0.0f;
|
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) {
|
if (m_isReloading) {
|
||||||
m_moveSpeed = -pev->maxspeed;
|
m_moveSpeed = -pev->maxspeed;
|
||||||
m_duckTime = game.time () - 1.0f;
|
m_duckTime = game.time () - 1.0f;
|
||||||
|
|
|
||||||
|
|
@ -486,7 +486,7 @@ void Bot::doPlayerAvoidance (const Vector &normal) {
|
||||||
const auto otherPrio = bots.getPlayerPriority (client.ent);
|
const auto otherPrio = bots.getPlayerPriority (client.ent);
|
||||||
|
|
||||||
// give some priorities to bot avoidance
|
// give some priorities to bot avoidance
|
||||||
if (ownPrio < otherPrio) {
|
if (ownPrio > otherPrio) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -495,7 +495,7 @@ void Bot::doPlayerAvoidance (const Vector &normal) {
|
||||||
const auto avoidPrio = bots.getPlayerPriority (m_hindrance);
|
const auto avoidPrio = bots.getPlayerPriority (m_hindrance);
|
||||||
|
|
||||||
// ignore because we're already avoiding someone better
|
// ignore because we're already avoiding someone better
|
||||||
if (avoidPrio < otherPrio) {
|
if (avoidPrio > otherPrio) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -557,7 +557,7 @@ void Bot::checkTerrain (float movedDistance, const Vector &dirNormal) {
|
||||||
// standing still, no need to check?
|
// standing still, no need to check?
|
||||||
if (m_lastCollTime < game.time () && getCurrentTaskId () != Task::Attack) {
|
if (m_lastCollTime < game.time () && getCurrentTaskId () != Task::Attack) {
|
||||||
// didn't we move enough previously?
|
// 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_prevTime = game.time (); // then consider being stuck
|
||||||
m_isStuck = true;
|
m_isStuck = true;
|
||||||
|
|
||||||
|
|
@ -1285,7 +1285,7 @@ bool Bot::updateNavigation () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// needs precise placement - check if we get past the point
|
// 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);
|
const auto predictRangeSq = m_pathOrigin.distanceSq (pev->origin + pev->velocity * m_frameInterval);
|
||||||
|
|
||||||
if (predictRangeSq >= nodeDistanceSq || predictRangeSq <= desiredDistanceSq) {
|
if (predictRangeSq >= nodeDistanceSq || predictRangeSq <= desiredDistanceSq) {
|
||||||
|
|
@ -1305,7 +1305,7 @@ bool Bot::updateNavigation () {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeDistanceSq < desiredDistanceSq) {
|
if (nodeDistanceSq <= desiredDistanceSq) {
|
||||||
// did we reach a destination node?
|
// did we reach a destination node?
|
||||||
if (getTask ()->data == m_currentNodeIndex) {
|
if (getTask ()->data == m_currentNodeIndex) {
|
||||||
if (m_chosenGoalIndex != kInvalidNodeIndex) {
|
if (m_chosenGoalIndex != kInvalidNodeIndex) {
|
||||||
|
|
@ -1766,7 +1766,7 @@ bool Bot::findNextBestNode () {
|
||||||
return true;
|
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
|
// 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.
|
// to be restarted over again.
|
||||||
|
|
||||||
|
|
@ -1777,7 +1777,7 @@ bool Bot::findNextBestNodeEx (const IntArray &data, bool returnFailure) {
|
||||||
lessDist[i] = kInfiniteDistance;
|
lessDist[i] = kInfiniteDistance;
|
||||||
lessIndex[i] = kInvalidNodeIndex;
|
lessIndex[i] = kInvalidNodeIndex;
|
||||||
}
|
}
|
||||||
const auto &numToSkip = returnFailure ? 0 : cr::clamp (rg (0, 2), 0, static_cast <int> (data.length () / 2));
|
const auto &numToSkip = handleFails ? 1 : rg (1, 4);
|
||||||
|
|
||||||
for (const auto &i : data) {
|
for (const auto &i : data) {
|
||||||
const auto &path = graph[i];
|
const auto &path = graph[i];
|
||||||
|
|
@ -1855,7 +1855,7 @@ bool Bot::findNextBestNodeEx (const IntArray &data, bool returnFailure) {
|
||||||
|
|
||||||
// worst case... find at least something
|
// worst case... find at least something
|
||||||
if (selected == kInvalidNodeIndex) {
|
if (selected == kInvalidNodeIndex) {
|
||||||
if (returnFailure) {
|
if (handleFails) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
selected = findNearestNode ();
|
selected = findNearestNode ();
|
||||||
|
|
@ -1960,7 +1960,7 @@ int Bot::findNearestNode () {
|
||||||
int index = kInvalidNodeIndex;
|
int index = kInvalidNodeIndex;
|
||||||
float nearestDistanceSq = cr::sqrf (kMaxDistance);
|
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);
|
const auto &bucket = graph.getNodesInBucket (origin);
|
||||||
|
|
||||||
for (const auto &i : bucket) {
|
for (const auto &i : bucket) {
|
||||||
|
|
@ -1969,7 +1969,7 @@ int Bot::findNearestNode () {
|
||||||
if (!graph.exists (path.number)) {
|
if (!graph.exists (path.number)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const float distanceSq = path.origin.distanceSq (pev->origin);
|
const float distanceSq = path.origin.distanceSq (origin);
|
||||||
|
|
||||||
if (distanceSq < nearestDistanceSq) {
|
if (distanceSq < nearestDistanceSq) {
|
||||||
// if bot doing navigation, make sure node really visible and reachable
|
// if bot doing navigation, make sure node really visible and reachable
|
||||||
|
|
@ -1991,7 +1991,7 @@ int Bot::findNearestNode () {
|
||||||
if (!graph.exists (path.number)) {
|
if (!graph.exists (path.number)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const float distanceSq = path.origin.distanceSq (pev->origin);
|
const float distanceSq = path.origin.distanceSq (origin);
|
||||||
|
|
||||||
if (distanceSq < nearestDistanceSq) {
|
if (distanceSq < nearestDistanceSq) {
|
||||||
TraceResult tr {};
|
TraceResult tr {};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue