From 66f7eafd8b293eb8d88088c989ea11ce56d11b25 Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Thu, 18 Jun 2026 02:39:15 -0600 Subject: [PATCH 1/2] Bots can scavenge class-exclusive weapons as a per level relative preference --- game/neo/scripts/ntre_bot_profiles.txt | 136 ++++++++++++++++++ .../neo/bot/behavior/neo_bot_seek_weapon.cpp | 2 +- src/game/server/neo/bot/neo_bot_profile.cpp | 77 ++++++++++ src/game/server/neo/bot/neo_bot_profile.h | 13 ++ 4 files changed, 227 insertions(+), 1 deletion(-) diff --git a/game/neo/scripts/ntre_bot_profiles.txt b/game/neo/scripts/ntre_bot_profiles.txt index 24045829d7..e1c9eed006 100644 --- a/game/neo/scripts/ntre_bot_profiles.txt +++ b/game/neo/scripts/ntre_bot_profiles.txt @@ -23,6 +23,10 @@ ntre_bot_profiles sergeant "zr68c" lieutenant "supa7" } + recon_loot + { + lieutenant "zr68s mx mx_silenced aa13" + } assault { private "zr68s" @@ -30,6 +34,10 @@ ntre_bot_profiles sergeant "mx" lieutenant "aa13 srs" } + assault_loot + { + lieutenant "pz" + } support { private "zr68c supa7" @@ -37,6 +45,10 @@ ntre_bot_profiles sergeant "mx mx_silenced" lieutenant "mx mx_silenced pz" } + support_loot + { + lieutenant "aa13" + } } } @@ -51,16 +63,28 @@ ntre_bot_profiles { lieutenant "zr68c" } + recon_loot + { + lieutenant "zr68s" + } assault { corporal "zr68s" lieutenant "mx" } + assault_loot + { + lieutenant "pz" + } support { private "zr68c" lieutenant "mx_silenced" } + support_loot + { + private "zr68s" + } } } @@ -75,12 +99,26 @@ ntre_bot_profiles sergeant "zr68l" lieutenant "m41s" } + recon_loot + { + // private "" + // corporal "" + // sergeant "" + lieutenant "srs" + } assault { corporal "m41" sergeant "m41s mx" lieutenant "srs" } + assault_loot + { + // private "" + // corporal "" + // sergeant "" + // lieutenant "" + } support { private "m41" @@ -88,6 +126,13 @@ ntre_bot_profiles sergeant "mx m41s" lieutenant "mx m41s" } + support_loot + { + // private "" + // corporal "" + // sergeant "" + // lieutenant "srs" + } } } @@ -104,6 +149,13 @@ ntre_bot_profiles sergeant "supa7 mx" lieutenant "aa13" } + assault_loot + { + // private "" + // corporal "" + // sergeant "" + // lieutenant "" + } support { private "supa7" @@ -111,6 +163,13 @@ ntre_bot_profiles sergeant "supa7 mx" lieutenant "supa7 mx" } + support_loot + { + // private "" + // corporal "" + // sergeant "" + // lieutenant "aa13" + } } } @@ -128,6 +187,13 @@ ntre_bot_profiles sergeant "mx" lieutenant "mx" } + assault_loot + { + // private "" + // corporal "" + // sergeant "" + // lieutenant "" + } support { private "zr68c" @@ -135,6 +201,13 @@ ntre_bot_profiles sergeant "mx" lieutenant "mx" } + support_loot + { + // private "" + // corporal "" + // sergeant "" + // lieutenant "" + } } } @@ -150,6 +223,13 @@ ntre_bot_profiles sergeant "jittescoped" lieutenant "m41s" } + recon_loot + { + // private "" + // corporal "" + // sergeant "" + // lieutenant "zr68s" + } assault { private "zr68s" @@ -157,6 +237,13 @@ ntre_bot_profiles sergeant "zr68s m41s" lieutenant "zr68s m41s" } + assault_loot + { + // private "" + // corporal "" + // sergeant "" + // lieutenant "" + } support { private "mpn" @@ -164,6 +251,13 @@ ntre_bot_profiles sergeant "mx_silenced" lieutenant "mx_silenced" } + support_loot + { + // private "" + // corporal "" + // sergeant "" + // lieutenant "zr68s" + } } } @@ -179,6 +273,13 @@ ntre_bot_profiles sergeant "zr68c" lieutenant "supa7" } + recon_loot + { + // private "zr68c" + // corporal "" + // sergeant "" + // lieutenant "aa13" + } assault { private "zr68c" @@ -186,6 +287,13 @@ ntre_bot_profiles sergeant "mx" lieutenant "mx aa13 srs" } + assault_loot + { + // private "" + // corporal "" + // sergeant "pz" + // lieutenant "" + } support { private "zr68c m41 supa7" @@ -193,6 +301,13 @@ ntre_bot_profiles sergeant "mx" lieutenant "mx pz" } + support_loot + { + // private "" + // corporal "" + // sergeant "" + // lieutenant "aa13" + } } } } @@ -216,6 +331,13 @@ ntre_bot_profiles sergeant "m41 m41s mx" lieutenant "m41 m41s mx aa13" } + assault_loot + { + // private "" + // corporal "" + // sergeant "" + // lieutenant "" + } support { private "m41" @@ -223,6 +345,13 @@ ntre_bot_profiles sergeant "m41 m41s mx" lieutenant "m41 m41s mx" } + support_loot + { + // private "" + // corporal "" + // sergeant "" + // lieutenant "" + } } } "Grey" @@ -282,6 +411,13 @@ ntre_bot_profiles sergeant "zr68c" lieutenant "zr68c supa7" } + recon_loot + { + // private "" + // corporal "" + // sergeant "" + // lieutenant "zr68s" + } } } "Wolf" diff --git a/src/game/server/neo/bot/behavior/neo_bot_seek_weapon.cpp b/src/game/server/neo/bot/behavior/neo_bot_seek_weapon.cpp index 9da3dc866d..268f2ba1ac 100644 --- a/src/game/server/neo/bot/behavior/neo_bot_seek_weapon.cpp +++ b/src/game/server/neo/bot/behavior/neo_bot_seek_weapon.cpp @@ -32,7 +32,7 @@ int GetBotWeaponPreferenceRank( const CNEOBot *me, NEO_WEP_BITS_UNDERLYING_TYPE for ( int idxRank = NEO_RANK__TOTAL - 1; idxRank >= 0; --idxRank ) { - if ( me->m_profile.flagsWepPrefs[playerClass][idxRank] & wepBit ) + if ( me->m_profile.flagsLootWepPrefs[playerClass][idxRank] & wepBit ) { return idxRank; } diff --git a/src/game/server/neo/bot/neo_bot_profile.cpp b/src/game/server/neo/bot/neo_bot_profile.cpp index 254af6f16f..6a4c17844e 100644 --- a/src/game/server/neo/bot/neo_bot_profile.cpp +++ b/src/game/server/neo/bot/neo_bot_profile.cpp @@ -64,6 +64,33 @@ inline const CNEOBotProfile FIXED_DEFAULT_PROFILE = { NEO_WEP_ZR68_C | NEO_WEP_SUPA7, // Lieutenant }, }, + .flagsLootWepPrefs = { + { + // Recon + NEO_WEP_SRM_S | NEO_WEP_JITTE_S, // Private + NEO_WEP_MX, // Corporal + NEO_WEP_MX_S, // Sergeant + NEO_WEP_ZR68_S | NEO_WEP_AA13 | NEO_WEP_SRS | NEO_WEP_M41_S | NEO_WEP_M41_L, // Lieutenant + }, + { + // Assault + NEO_WEP_SRM_S | NEO_WEP_JITTE_S, // Private + NEO_WEP_PZ, // Corporal + 0, // Sergeant + 0, // Lieutenant + }, + { + // Support + NEO_WEP_SRM_S | NEO_WEP_JITTE_S, // Private + NEO_WEP_ZR68_S, // Corporal + NEO_WEP_SRS, // Sergeant + NEO_WEP_AA13, // Lieutenant + }, + { + // VIP + 0, 0, 0, 0 + }, + }, }; template @@ -173,6 +200,10 @@ static void SetProfileTempBotCommon(CNEOBotProfile *pProfile, KeyValues *kv) (1 << 0)); static_assert(BOT_TEMPLATE_APPLIED_WEP_PREF_VIP_LIEUTENANT == (1 << ((NEO_CLASS_LOADOUTABLE_COUNT * NEO_RANK_TOTAL) - 1))); + static_assert(BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_RECON_PRIVATE == + (1 << 19)); + static_assert(BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_SUPPORT_LIEUTENANT == + (1 << (19 + (NEO_CLASS_VIP * NEO_RANK_TOTAL) - 1))); int iBitWise = 0; @@ -223,6 +254,36 @@ static void SetProfileTempBotCommon(CNEOBotProfile *pProfile, KeyValues *kv) ++iBitWise; } } + + int iLootBitWise = 19; // see BotTemplateApplied_ + for (int idxClass = 0; idxClass < NEO_CLASS_VIP; ++idxClass) // skip VIP + { + char szLootKey[64]; + V_snprintf(szLootKey, sizeof(szLootKey), "%s_loot", SZ_CLASSES[idxClass]); + KeyValues *wepClassLootPrefKv = wepKv->FindKey(szLootKey); + if (!wepClassLootPrefKv) + { + iLootBitWise += NEO_RANK__TOTAL; + continue; + } + + for (int idxRank = 0; idxRank < NEO_RANK__TOTAL; ++idxRank) + { + const auto flagsWepPrefCur = FlagsFromStr(pProfile->flagsLootWepPrefs[idxClass][idxRank], + WEP_BIT_FLAG_CMP, wepClassLootPrefKv->GetString(SZ_RANKS[idxRank]), + &pProfile->flagTemplateApplied, static_cast(1 << iLootBitWise)); + pProfile->flagsLootWepPrefs[idxClass][idxRank] = flagsWepPrefCur; + ++iLootBitWise; + } + } + + for (int idxClass = 0; idxClass < NEO_CLASS__LOADOUTABLE_COUNT; ++idxClass) + { + for (int idxRank = 0; idxRank < NEO_RANK__TOTAL; ++idxRank) + { + pProfile->flagsLootWepPrefs[idxClass][idxRank] |= pProfile->flagsWepPrefs[idxClass][idxRank]; + } + } } pProfile->flagDifficulty = FlagsFromStr(pProfile->flagDifficulty, @@ -425,6 +486,22 @@ void NEOBotProfileLoad() ++iBitWise; } } + int iLootBitWise = 19; // see BotTemplateApplied_ + for (int idxClass = 0; idxClass < NEO_CLASS_VIP; ++idxClass) // skip VIP + { + for (int idxRank = 0; idxRank < NEO_RANK__TOTAL; ++idxRank) + { + if (templateProfile->flagTemplateApplied & (1 << iLootBitWise)) + { +#if LOG_DBG_LEVEL >= 2 + Msg(" BOTS: Template (%s): Applied loot wep pref %d,%d = %d\n", szKey, idxClass, idxRank, templateProfile->flagsLootWepPrefs[idxClass][idxRank]); +#endif + newBotProfile.flagsLootWepPrefs[idxClass][idxRank] = templateProfile->flagsLootWepPrefs[idxClass][idxRank]; + newBotProfile.flagTemplateApplied |= (1 << iLootBitWise); + } + ++iLootBitWise; + } + } if (templateProfile->flagTemplateApplied & BOT_TEMPLATE_APPLIED_DIFFICULTY) { #if LOG_DBG_LEVEL >= 2 diff --git a/src/game/server/neo/bot/neo_bot_profile.h b/src/game/server/neo/bot/neo_bot_profile.h index b15b3d3bd9..90a7c95d89 100644 --- a/src/game/server/neo/bot/neo_bot_profile.h +++ b/src/game/server/neo/bot/neo_bot_profile.h @@ -52,6 +52,18 @@ enum BotTemplateApplied_ BOT_TEMPLATE_APPLIED_DIFFICULTY = 1 << 16, BOT_TEMPLATE_APPLIED_DIFFICULTY_SELECT = 1 << 17, BOT_TEMPLATE_APPLIED_CLASS = 1 << 18, + BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_RECON_PRIVATE = 1 << 19, + BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_RECON_CORPORAL = 1 << 20, + BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_RECON_SERGEANT = 1 << 21, + BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_RECON_LIEUTENANT = 1 << 22, + BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_ASSAULT_PRIVATE = 1 << 23, + BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_ASSAULT_CORPORAL = 1 << 24, + BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_ASSAULT_SERGEANT = 1 << 25, + BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_ASSAULT_LIEUTENANT = 1 << 26, + BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_SUPPORT_PRIVATE = 1 << 27, + BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_SUPPORT_CORPORAL = 1 << 28, + BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_SUPPORT_SERGEANT = 1 << 29, + BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_SUPPORT_LIEUTENANT = 1 << 30, }; typedef int BotTemplateApplied; @@ -65,6 +77,7 @@ struct CNEOBotProfile int iDifficultyForced; BotClassFlag flagClass; NEO_WEP_BITS_UNDERLYING_TYPE flagsWepPrefs[NEO_CLASS__LOADOUTABLE_COUNT][NEO_RANK__TOTAL]; + NEO_WEP_BITS_UNDERLYING_TYPE flagsLootWepPrefs[NEO_CLASS__LOADOUTABLE_COUNT][NEO_RANK__TOTAL]; BotTemplateApplied flagTemplateApplied; }; From 23a2dabaeafe9e4f5692686236e2f24425f3538c Mon Sep 17 00:00:00 2001 From: Alan Shen Date: Fri, 19 Jun 2026 00:32:03 -0600 Subject: [PATCH 2/2] Bots can scavenge class-exclusive weapons as LT rank preference --- game/neo/scripts/ntre_bot_profiles.txt | 153 +++----------------- src/game/server/neo/bot/neo_bot_profile.cpp | 95 +++++------- src/game/server/neo/bot/neo_bot_profile.h | 16 +- 3 files changed, 59 insertions(+), 205 deletions(-) diff --git a/game/neo/scripts/ntre_bot_profiles.txt b/game/neo/scripts/ntre_bot_profiles.txt index e1c9eed006..7afb20a406 100644 --- a/game/neo/scripts/ntre_bot_profiles.txt +++ b/game/neo/scripts/ntre_bot_profiles.txt @@ -22,10 +22,7 @@ ntre_bot_profiles corporal "jittescoped" sergeant "zr68c" lieutenant "supa7" - } - recon_loot - { - lieutenant "zr68s mx mx_silenced aa13" + loot "zr68s mx mx_silenced aa13" } assault { @@ -33,10 +30,7 @@ ntre_bot_profiles corporal "zr68s m41" sergeant "mx" lieutenant "aa13 srs" - } - assault_loot - { - lieutenant "pz" + loot "pz" } support { @@ -44,10 +38,7 @@ ntre_bot_profiles corporal "mx" sergeant "mx mx_silenced" lieutenant "mx mx_silenced pz" - } - support_loot - { - lieutenant "aa13" + loot "aa13" } } } @@ -62,29 +53,19 @@ ntre_bot_profiles recon { lieutenant "zr68c" - } - recon_loot - { - lieutenant "zr68s" + loot "zr68s" } assault { corporal "zr68s" lieutenant "mx" - } - assault_loot - { - lieutenant "pz" + loot "pz" } support { private "zr68c" lieutenant "mx_silenced" } - support_loot - { - private "zr68s" - } } } @@ -98,26 +79,14 @@ ntre_bot_profiles corporal "zr68l" sergeant "zr68l" lieutenant "m41s" - } - recon_loot - { - // private "" - // corporal "" - // sergeant "" - lieutenant "srs" + loot "m41 srs" } assault { corporal "m41" sergeant "m41s mx" lieutenant "srs" - } - assault_loot - { - // private "" - // corporal "" - // sergeant "" - // lieutenant "" + loot "zr68l" } support { @@ -125,13 +94,7 @@ ntre_bot_profiles corporal "mx" sergeant "mx m41s" lieutenant "mx m41s" - } - support_loot - { - // private "" - // corporal "" - // sergeant "" - // lieutenant "srs" + loot "zr68l srs" } } } @@ -149,26 +112,13 @@ ntre_bot_profiles sergeant "supa7 mx" lieutenant "aa13" } - assault_loot - { - // private "" - // corporal "" - // sergeant "" - // lieutenant "" - } support { private "supa7" corporal "supa7 mx" sergeant "supa7 mx" lieutenant "supa7 mx" - } - support_loot - { - // private "" - // corporal "" - // sergeant "" - // lieutenant "aa13" + loot "aa13" } } } @@ -187,13 +137,6 @@ ntre_bot_profiles sergeant "mx" lieutenant "mx" } - assault_loot - { - // private "" - // corporal "" - // sergeant "" - // lieutenant "" - } support { private "zr68c" @@ -201,13 +144,6 @@ ntre_bot_profiles sergeant "mx" lieutenant "mx" } - support_loot - { - // private "" - // corporal "" - // sergeant "" - // lieutenant "" - } } } @@ -222,13 +158,7 @@ ntre_bot_profiles corporal "jittescoped" sergeant "jittescoped" lieutenant "m41s" - } - recon_loot - { - // private "" - // corporal "" - // sergeant "" - // lieutenant "zr68s" + loot "zr68s" } assault { @@ -237,26 +167,13 @@ ntre_bot_profiles sergeant "zr68s m41s" lieutenant "zr68s m41s" } - assault_loot - { - // private "" - // corporal "" - // sergeant "" - // lieutenant "" - } support { private "mpn" corporal "mpn" sergeant "mx_silenced" lieutenant "mx_silenced" - } - support_loot - { - // private "" - // corporal "" - // sergeant "" - // lieutenant "zr68s" + loot "zr68s" } } } @@ -272,13 +189,7 @@ ntre_bot_profiles corporal "srm jitte" sergeant "zr68c" lieutenant "supa7" - } - recon_loot - { - // private "zr68c" - // corporal "" - // sergeant "" - // lieutenant "aa13" + loot "aa13" } assault { @@ -286,13 +197,7 @@ ntre_bot_profiles corporal "zr68c m41 supa7" sergeant "mx" lieutenant "mx aa13 srs" - } - assault_loot - { - // private "" - // corporal "" - // sergeant "pz" - // lieutenant "" + loot "pz" } support { @@ -300,13 +205,7 @@ ntre_bot_profiles corporal "mx supa7" sergeant "mx" lieutenant "mx pz" - } - support_loot - { - // private "" - // corporal "" - // sergeant "" - // lieutenant "aa13" + loot "aa13" } } } @@ -330,13 +229,7 @@ ntre_bot_profiles corporal "m41" sergeant "m41 m41s mx" lieutenant "m41 m41s mx aa13" - } - assault_loot - { - // private "" - // corporal "" - // sergeant "" - // lieutenant "" + loot "pz" } support { @@ -344,13 +237,7 @@ ntre_bot_profiles corporal "m41 m41s mx" sergeant "m41 m41s mx" lieutenant "m41 m41s mx" - } - support_loot - { - // private "" - // corporal "" - // sergeant "" - // lieutenant "" + loot "aa13" } } } @@ -410,13 +297,7 @@ ntre_bot_profiles corporal "srm" sergeant "zr68c" lieutenant "zr68c supa7" - } - recon_loot - { - // private "" - // corporal "" - // sergeant "" - // lieutenant "zr68s" + loot "zr68s mx mx_silenced aa13" } } } diff --git a/src/game/server/neo/bot/neo_bot_profile.cpp b/src/game/server/neo/bot/neo_bot_profile.cpp index 6a4c17844e..7aee7b6953 100644 --- a/src/game/server/neo/bot/neo_bot_profile.cpp +++ b/src/game/server/neo/bot/neo_bot_profile.cpp @@ -64,33 +64,6 @@ inline const CNEOBotProfile FIXED_DEFAULT_PROFILE = { NEO_WEP_ZR68_C | NEO_WEP_SUPA7, // Lieutenant }, }, - .flagsLootWepPrefs = { - { - // Recon - NEO_WEP_SRM_S | NEO_WEP_JITTE_S, // Private - NEO_WEP_MX, // Corporal - NEO_WEP_MX_S, // Sergeant - NEO_WEP_ZR68_S | NEO_WEP_AA13 | NEO_WEP_SRS | NEO_WEP_M41_S | NEO_WEP_M41_L, // Lieutenant - }, - { - // Assault - NEO_WEP_SRM_S | NEO_WEP_JITTE_S, // Private - NEO_WEP_PZ, // Corporal - 0, // Sergeant - 0, // Lieutenant - }, - { - // Support - NEO_WEP_SRM_S | NEO_WEP_JITTE_S, // Private - NEO_WEP_ZR68_S, // Corporal - NEO_WEP_SRS, // Sergeant - NEO_WEP_AA13, // Lieutenant - }, - { - // VIP - 0, 0, 0, 0 - }, - }, }; template @@ -200,10 +173,6 @@ static void SetProfileTempBotCommon(CNEOBotProfile *pProfile, KeyValues *kv) (1 << 0)); static_assert(BOT_TEMPLATE_APPLIED_WEP_PREF_VIP_LIEUTENANT == (1 << ((NEO_CLASS_LOADOUTABLE_COUNT * NEO_RANK_TOTAL) - 1))); - static_assert(BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_RECON_PRIVATE == - (1 << 19)); - static_assert(BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_SUPPORT_LIEUTENANT == - (1 << (19 + (NEO_CLASS_VIP * NEO_RANK_TOTAL) - 1))); int iBitWise = 0; @@ -255,34 +224,35 @@ static void SetProfileTempBotCommon(CNEOBotProfile *pProfile, KeyValues *kv) } } - int iLootBitWise = 19; // see BotTemplateApplied_ - for (int idxClass = 0; idxClass < NEO_CLASS_VIP; ++idxClass) // skip VIP + // Initialize loot prefs first with class compatible weapon selection prefs + for (int idxClass = 0; idxClass < NEO_CLASS__LOADOUTABLE_COUNT; ++idxClass) { - char szLootKey[64]; - V_snprintf(szLootKey, sizeof(szLootKey), "%s_loot", SZ_CLASSES[idxClass]); - KeyValues *wepClassLootPrefKv = wepKv->FindKey(szLootKey); - if (!wepClassLootPrefKv) - { - iLootBitWise += NEO_RANK__TOTAL; - continue; - } - for (int idxRank = 0; idxRank < NEO_RANK__TOTAL; ++idxRank) { - const auto flagsWepPrefCur = FlagsFromStr(pProfile->flagsLootWepPrefs[idxClass][idxRank], - WEP_BIT_FLAG_CMP, wepClassLootPrefKv->GetString(SZ_RANKS[idxRank]), - &pProfile->flagTemplateApplied, static_cast(1 << iLootBitWise)); - pProfile->flagsLootWepPrefs[idxClass][idxRank] = flagsWepPrefCur; - ++iLootBitWise; + pProfile->flagsLootWepPrefs[idxClass][idxRank] = pProfile->flagsWepPrefs[idxClass][idxRank]; } } - for (int idxClass = 0; idxClass < NEO_CLASS__LOADOUTABLE_COUNT; ++idxClass) + // Apply additional looting preferences for class-excluded weapons + for (int idxClass = 0; idxClass < NEO_CLASS_VIP; ++idxClass) { - for (int idxRank = 0; idxRank < NEO_RANK__TOTAL; ++idxRank) + KeyValues *wepClassKv = wepKv->FindKey(SZ_CLASSES[idxClass]); + if (!wepClassKv) { - pProfile->flagsLootWepPrefs[idxClass][idxRank] |= pProfile->flagsWepPrefs[idxClass][idxRank]; + continue; } + + const auto lootFlags = FlagsFromStr( + (NEO_WEP_BITS_UNDERLYING_TYPE)0, + WEP_BIT_FLAG_CMP, + wepClassKv->GetString("loot"), + &pProfile->flagTemplateApplied, + static_cast( + BOT_TEMPLATE_APPLIED_WEP_PREF_RECON_LOOT << idxClass)); + + // Append loot preference to lieutenant level + const int idxLieutenant = NEO_RANK__TOTAL - 1; + pProfile->flagsLootWepPrefs[idxClass][idxLieutenant] |= lootFlags; } } @@ -399,6 +369,15 @@ void NEOBotProfileLoad() CNEOBotProfile defaultProfile; V_memcpy(&defaultProfile, &FIXED_DEFAULT_PROFILE, sizeof(CNEOBotProfile)); + // Initialize bot weapon looting preferences from weapon selection preferences + for (int idxClass = 0; idxClass < NEO_CLASS__LOADOUTABLE_COUNT; ++idxClass) + { + for (int idxRank = 0; idxRank < NEO_RANK__TOTAL; ++idxRank) + { + defaultProfile.flagsLootWepPrefs[idxClass][idxRank] = defaultProfile.flagsWepPrefs[idxClass][idxRank]; + } + } + KeyValues *kv = new KeyValues("ntre_bot_profiles"); if (!kv->LoadFromFile(g_pFullFileSystem, "scripts/" MAIN_PROFILE_FNAME)) { @@ -486,20 +465,22 @@ void NEOBotProfileLoad() ++iBitWise; } } - int iLootBitWise = 19; // see BotTemplateApplied_ - for (int idxClass = 0; idxClass < NEO_CLASS_VIP; ++idxClass) // skip VIP + for (int idxClass = 0; idxClass < NEO_CLASS_VIP; ++idxClass) { - for (int idxRank = 0; idxRank < NEO_RANK__TOTAL; ++idxRank) + const auto lootFlag = + static_cast( + BOT_TEMPLATE_APPLIED_WEP_PREF_RECON_LOOT << idxClass); + + if (templateProfile->flagTemplateApplied & lootFlag) { - if (templateProfile->flagTemplateApplied & (1 << iLootBitWise)) + for (int idxRank = 0; idxRank < NEO_RANK__TOTAL; ++idxRank) { #if LOG_DBG_LEVEL >= 2 Msg(" BOTS: Template (%s): Applied loot wep pref %d,%d = %d\n", szKey, idxClass, idxRank, templateProfile->flagsLootWepPrefs[idxClass][idxRank]); #endif - newBotProfile.flagsLootWepPrefs[idxClass][idxRank] = templateProfile->flagsLootWepPrefs[idxClass][idxRank]; - newBotProfile.flagTemplateApplied |= (1 << iLootBitWise); + newBotProfile.flagsLootWepPrefs[idxClass][idxRank] = + templateProfile->flagsLootWepPrefs[idxClass][idxRank]; } - ++iLootBitWise; } } if (templateProfile->flagTemplateApplied & BOT_TEMPLATE_APPLIED_DIFFICULTY) diff --git a/src/game/server/neo/bot/neo_bot_profile.h b/src/game/server/neo/bot/neo_bot_profile.h index 90a7c95d89..a4f603b44e 100644 --- a/src/game/server/neo/bot/neo_bot_profile.h +++ b/src/game/server/neo/bot/neo_bot_profile.h @@ -52,18 +52,10 @@ enum BotTemplateApplied_ BOT_TEMPLATE_APPLIED_DIFFICULTY = 1 << 16, BOT_TEMPLATE_APPLIED_DIFFICULTY_SELECT = 1 << 17, BOT_TEMPLATE_APPLIED_CLASS = 1 << 18, - BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_RECON_PRIVATE = 1 << 19, - BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_RECON_CORPORAL = 1 << 20, - BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_RECON_SERGEANT = 1 << 21, - BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_RECON_LIEUTENANT = 1 << 22, - BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_ASSAULT_PRIVATE = 1 << 23, - BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_ASSAULT_CORPORAL = 1 << 24, - BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_ASSAULT_SERGEANT = 1 << 25, - BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_ASSAULT_LIEUTENANT = 1 << 26, - BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_SUPPORT_PRIVATE = 1 << 27, - BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_SUPPORT_CORPORAL = 1 << 28, - BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_SUPPORT_SERGEANT = 1 << 29, - BOT_TEMPLATE_APPLIED_LOOT_WEP_PREF_SUPPORT_LIEUTENANT = 1 << 30, + BOT_TEMPLATE_APPLIED_WEP_PREF_RECON_LOOT = 1 << 19, + BOT_TEMPLATE_APPLIED_WEP_PREF_ASSAULT_LOOT = 1 << 20, + BOT_TEMPLATE_APPLIED_WEP_PREF_SUPPORT_LOOT = 1 << 21, + BOT_TEMPLATE_APPLIED_WEP_PREF_VIP_LOOT = 1 << 22, }; typedef int BotTemplateApplied;