Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions game/neo/scripts/ntre_bot_profiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,23 @@ ntre_bot_profiles
corporal "jittescoped"
sergeant "zr68c"
lieutenant "supa7"
loot "zr68s mx mx_silenced aa13"

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor Author

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:

  • ZR suppressed
  • MX
  • MX suppressed
  • SRS
  • AA13

Assault:

  • SRM suppressed
  • Jitte suppressed
  • ZR68 scoped
  • PZ

Support:

  • SRM suppressed
  • Jitte suppresed
  • ZR suppressed
  • ZR scoped
  • SRS
  • AA13

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.

}
assault
{
private "zr68s"
corporal "zr68s m41"
sergeant "mx"
lieutenant "aa13 srs"
loot "pz"
}
support
{
private "zr68c supa7"
corporal "mx"
sergeant "mx mx_silenced"
lieutenant "mx mx_silenced pz"
loot "aa13"
}
}
}
Expand All @@ -50,11 +53,13 @@ ntre_bot_profiles
recon
{
lieutenant "zr68c"
loot "zr68s"
}
assault
{
corporal "zr68s"
lieutenant "mx"
loot "pz"
}
support
{
Expand All @@ -74,19 +79,22 @@ ntre_bot_profiles
corporal "zr68l"
sergeant "zr68l"
lieutenant "m41s"
loot "m41 srs"
}
assault
{
corporal "m41"
sergeant "m41s mx"
lieutenant "srs"
loot "zr68l"
}
support
{
private "m41"
corporal "mx"
sergeant "mx m41s"
lieutenant "mx m41s"
loot "zr68l srs"
}
}
}
Expand All @@ -110,6 +118,7 @@ ntre_bot_profiles
corporal "supa7 mx"
sergeant "supa7 mx"
lieutenant "supa7 mx"
loot "aa13"
}
}
}
Expand Down Expand Up @@ -149,6 +158,7 @@ ntre_bot_profiles
corporal "jittescoped"
sergeant "jittescoped"
lieutenant "m41s"
loot "zr68s"
}
assault
{
Expand All @@ -163,6 +173,7 @@ ntre_bot_profiles
corporal "mpn"
sergeant "mx_silenced"
lieutenant "mx_silenced"
loot "zr68s"
}
}
}
Expand All @@ -178,20 +189,23 @@ ntre_bot_profiles
corporal "srm jitte"
sergeant "zr68c"
lieutenant "supa7"
loot "aa13"
}
assault
{
private "zr68c"
corporal "zr68c m41 supa7"
sergeant "mx"
lieutenant "mx aa13 srs"
loot "pz"
}
support
{
private "zr68c m41 supa7"
corporal "mx supa7"
sergeant "mx"
lieutenant "mx pz"
loot "aa13"
}
}
}
Expand All @@ -215,13 +229,15 @@ ntre_bot_profiles
corporal "m41"
sergeant "m41 m41s mx"
lieutenant "m41 m41s mx aa13"
loot "pz"
}
support
{
private "m41"
corporal "m41 m41s mx"
sergeant "m41 m41s mx"
lieutenant "m41 m41s mx"
loot "aa13"
}
}
}
Expand Down Expand Up @@ -281,6 +297,7 @@ ntre_bot_profiles
corporal "srm"
sergeant "zr68c"
lieutenant "zr68c supa7"
loot "zr68s mx mx_silenced aa13"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/server/neo/bot/behavior/neo_bot_seek_weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
58 changes: 58 additions & 0 deletions src/game/server/neo/bot/neo_bot_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

pProfile->flagDifficulty = FlagsFromStr(pProfile->flagDifficulty,
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/game/server/neo/bot/neo_bot_profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
};

Expand Down