diff --git a/game/neo/scripts/ntre_bot_profiles.txt b/game/neo/scripts/ntre_bot_profiles.txt index 24045829d..7afb20a40 100644 --- a/game/neo/scripts/ntre_bot_profiles.txt +++ b/game/neo/scripts/ntre_bot_profiles.txt @@ -22,6 +22,7 @@ ntre_bot_profiles corporal "jittescoped" sergeant "zr68c" lieutenant "supa7" + loot "zr68s mx mx_silenced aa13" } assault { @@ -29,6 +30,7 @@ ntre_bot_profiles corporal "zr68s m41" sergeant "mx" lieutenant "aa13 srs" + loot "pz" } support { @@ -36,6 +38,7 @@ ntre_bot_profiles corporal "mx" sergeant "mx mx_silenced" lieutenant "mx mx_silenced pz" + loot "aa13" } } } @@ -50,11 +53,13 @@ ntre_bot_profiles recon { lieutenant "zr68c" + loot "zr68s" } assault { corporal "zr68s" lieutenant "mx" + loot "pz" } support { @@ -74,12 +79,14 @@ ntre_bot_profiles corporal "zr68l" sergeant "zr68l" lieutenant "m41s" + loot "m41 srs" } assault { corporal "m41" sergeant "m41s mx" lieutenant "srs" + loot "zr68l" } support { @@ -87,6 +94,7 @@ ntre_bot_profiles corporal "mx" sergeant "mx m41s" lieutenant "mx m41s" + loot "zr68l srs" } } } @@ -110,6 +118,7 @@ ntre_bot_profiles corporal "supa7 mx" sergeant "supa7 mx" lieutenant "supa7 mx" + loot "aa13" } } } @@ -149,6 +158,7 @@ ntre_bot_profiles corporal "jittescoped" sergeant "jittescoped" lieutenant "m41s" + loot "zr68s" } assault { @@ -163,6 +173,7 @@ ntre_bot_profiles corporal "mpn" sergeant "mx_silenced" lieutenant "mx_silenced" + loot "zr68s" } } } @@ -178,6 +189,7 @@ ntre_bot_profiles corporal "srm jitte" sergeant "zr68c" lieutenant "supa7" + loot "aa13" } assault { @@ -185,6 +197,7 @@ ntre_bot_profiles corporal "zr68c m41 supa7" sergeant "mx" lieutenant "mx aa13 srs" + loot "pz" } support { @@ -192,6 +205,7 @@ ntre_bot_profiles corporal "mx supa7" sergeant "mx" lieutenant "mx pz" + loot "aa13" } } } @@ -215,6 +229,7 @@ ntre_bot_profiles corporal "m41" sergeant "m41 m41s mx" lieutenant "m41 m41s mx aa13" + loot "pz" } support { @@ -222,6 +237,7 @@ ntre_bot_profiles corporal "m41 m41s mx" sergeant "m41 m41s mx" lieutenant "m41 m41s mx" + loot "aa13" } } } @@ -281,6 +297,7 @@ ntre_bot_profiles corporal "srm" sergeant "zr68c" lieutenant "zr68c supa7" + loot "zr68s mx mx_silenced aa13" } } } 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 9da3dc866..268f2ba1a 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 254af6f16..7aee7b695 100644 --- a/src/game/server/neo/bot/neo_bot_profile.cpp +++ b/src/game/server/neo/bot/neo_bot_profile.cpp @@ -223,6 +223,37 @@ static void SetProfileTempBotCommon(CNEOBotProfile *pProfile, KeyValues *kv) ++iBitWise; } } + + // Initialize loot prefs first with class compatible weapon selection prefs + 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]; + } + } + + // Apply additional looting preferences for class-excluded weapons + for (int idxClass = 0; idxClass < NEO_CLASS_VIP; ++idxClass) + { + KeyValues *wepClassKv = wepKv->FindKey(SZ_CLASSES[idxClass]); + if (!wepClassKv) + { + 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; + } } pProfile->flagDifficulty = FlagsFromStr(pProfile->flagDifficulty, @@ -338,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)) { @@ -425,6 +465,24 @@ void NEOBotProfileLoad() ++iBitWise; } } + for (int idxClass = 0; idxClass < NEO_CLASS_VIP; ++idxClass) + { + const auto lootFlag = + static_cast( + BOT_TEMPLATE_APPLIED_WEP_PREF_RECON_LOOT << idxClass); + + if (templateProfile->flagTemplateApplied & lootFlag) + { + 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]; + } + } + } 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 b15b3d3bd..a4f603b44 100644 --- a/src/game/server/neo/bot/neo_bot_profile.h +++ b/src/game/server/neo/bot/neo_bot_profile.h @@ -52,6 +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_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; @@ -65,6 +69,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; };