From e5ae2ac3f83552af9640fefbd949636a8a3582b6 Mon Sep 17 00:00:00 2001 From: dmitry Date: Fri, 17 Sep 2021 12:30:55 +0300 Subject: [PATCH] tweak: aiming code a little tweaked to reduce headshot ratio fix: fix crash with metamod since last commits add: mark last selected goals within round as used, so bots will take cover all the map --- ext/hlsdk/eiface.h | 2 +- src/botlib.cpp | 8 ++++++-- src/combat.cpp | 22 +++++++++++----------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/ext/hlsdk/eiface.h b/ext/hlsdk/eiface.h index abe08c4..c540a76 100644 --- a/ext/hlsdk/eiface.h +++ b/ext/hlsdk/eiface.h @@ -238,7 +238,7 @@ typedef struct enginefuncs_s { void (*pfnQueryClientCVarValue) (const edict_t *player, const char *cvarName); void (*pfnQueryClientCVarValue2) (const edict_t *player, const char *cvarName, int requestID); int (*pfnCheckParm) (const char *pchCmdLineToken, char **ppnext); - edict_t *(*pfnPEntityOfEntIndexAllEntities) (int iEntIndex); + // edict_t *(*pfnPEntityOfEntIndexAllEntities) (int iEntIndex); } enginefuncs_t; // Passed to pfnKeyValue diff --git a/src/botlib.cpp b/src/botlib.cpp index 2c546d2..aafcb44 100644 --- a/src/botlib.cpp +++ b/src/botlib.cpp @@ -3227,12 +3227,16 @@ void Bot::normal_ () { // did we already decide about a goal before? auto currIndex = getTask ()->data; - auto destIndex = graph.exists (currIndex) && !isBannedNode (currIndex) ? currIndex : findBestGoal (); + auto destIndex = graph.exists (currIndex) && !isBannedNode (currIndex) && m_prevGoalIndex != currIndex ? currIndex : findBestGoal (); // check for existance (this is failover, for i.e. csdm, this should be not true with normal gameplay, only when spawned outside of waypointed area) if (!graph.exists (destIndex)) { destIndex = graph.getFarest (pev->origin, 512.0f); } + + if (m_prevGoalIndex == currIndex && !(graph[currIndex].flags & NodeFlag::Goal)) { + m_goalHistory.push (currIndex); + } m_prevGoalIndex = destIndex; // remember index @@ -5520,7 +5524,7 @@ bool Bot::canSkipNextTrace (TraceChannel channel) { // for optmization purposes skip every second traceline fired, this doesn't affect ai // behaviour too much, but saves alot of cpu cycles. - constexpr auto kSkipTrace = 4; + constexpr auto kSkipTrace = 3; // check if we're have to skip if ((++m_traceSkip[channel] % kSkipTrace) == 0) { diff --git a/src/combat.cpp b/src/combat.cpp index ba6f421..ce688e9 100644 --- a/src/combat.cpp +++ b/src/combat.cpp @@ -403,7 +403,7 @@ bool Bot::lookupEnemies () { // shoot at dying players if no new enemy to give some more human-like illusion if (m_seeEnemyTime + 0.1f > game.time ()) { if (!usesSniper ()) { - m_shootAtDeadTime = game.time () + cr::clamp (m_agressionLevel * 1.25f, 0.45f, 1.05f); + m_shootAtDeadTime = game.time () + cr::clamp (m_agressionLevel * 1.25f, 0.45f, 0.60f); m_actualReactionTime = 0.0f; m_states |= Sense::SuspectEnemy; @@ -504,7 +504,7 @@ const Vector &Bot::getEnemyBodyOffset () { aimPos += getBodyOffsetError (distance); } else if (util.isPlayer (m_enemy)) { - const float highOffset = m_difficulty > Difficulty::Normal ? 3.5f : 0.0f; + const float highOffset = m_difficulty > Difficulty::Normal ? 1.5f : 0.0f; // now take in account different parts of enemy body if (m_enemyParts & (Visibility::Head | Visibility::Body)) { @@ -546,13 +546,13 @@ float Bot::getEnemyBodyOffsetCorrection (float distance) { static float offsetRanges[9][3] = { { 0.0f, 0.0f, 0.0f }, // none { 0.0f, 0.0f, 0.0f }, // melee - { 6.5f, 6.5f, 1.5f }, // pistol - { 9.5f, 9.0f, -5.0f }, // shotgun - { 4.5f, 3.5f, -5.0f }, // zoomrifle - { 4.5f, 1.0f, -4.5f }, // rifle - { 5.5f, 3.5f, -4.5f }, // smg - { 3.5f, 3.5f, 4.5f }, // sniper - { 2.5f, -2.0f, -6.0f } // heavy + { 2.5f, 1.5f, 0.2f }, // pistol + { 6.5f, 2.0f, -9.9f }, // shotgun + { 0.5f, -3.5f, -8.0f }, // zoomrifle + { 0.5f, -3.5f, -8.5f }, // rifle + { 2.5f, 0.5f, -4.5f }, // smg + { 0.5f, 0.5f, 1.5f }, // sniper + { 1.5f, -2.0f, -9.0f } // heavy }; // only highskilled bots do that @@ -561,10 +561,10 @@ float Bot::getEnemyBodyOffsetCorrection (float distance) { } // default distance index is short - int32 distanceIndex = DistanceIndex::Short; + auto distanceIndex = DistanceIndex::Short; // set distance index appropriate to distance - if (distance < 3072.0f && distance > kDoubleSprayDistance) { + if (distance < 2048.0f && distance > kDoubleSprayDistance) { distanceIndex = DistanceIndex::Long; } else if (distance > kSprayDistance && distance <= kDoubleSprayDistance) {