-
Notifications
You must be signed in to change notification settings - Fork 22
Bots loot weapons they could not select on spawn due to class restrictions #1997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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<BotTemplateApplied_>( | ||
| 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; | ||
|
Comment on lines
+254
to
+255
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With other coding guidelines that I've worked under, we tended to reserve all caps for just macro definitions, though I have have also heard of capitalizing all constants in some other style guidelines. In this case, I wanted to keep the naming similar to idxClass since it might be distracting to have them look different like, |
||
| } | ||
| } | ||
|
|
||
| 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<BotTemplateApplied>( | ||
| 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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially considered allowing the specification of relative class-exclusive weapon preferences by ranking, but having that level of control turned out to be both messy, and in my opinion not that useful.
One can see the prototype for the rank-specific preference here in this earlier commit:
66f7eaf
It seems easier to just assume that any class-exclusive looting preferences should apply to the LT level, mostly because when I tried to come up with initial configurations I ended up putting most preferences at the LT level anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also for reference, since I needed to consider whether selections would have been redundant and already possible with #1800, these are the weapons that each class can never select even if they were LT rank:
Recon:
Assault:
Support:
For testing, the permutations are kind of tricky, but a basic test is to set all bots to Recon with
bot_class 0, spawn as an Assault with a ZR suppressed, and throw it at a friendly recon bot. Before with #1800 the bots would not consider the swap.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was wondering why it's all tied to LT rank but checking
GetBotWeaponPreferenceRankfunction made sense. So LGTMThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I thought maybe bots may want to loot intermediate rank weapons at lower ranks, but in practice I didn't feel that the benefits were worth it for the extra complication of the loot preferences config population code, especially since there's already other options provided by the spawn selection preferences.