Skip to content

Commit 9ba6f42

Browse files
committed
Config: Utility slot equip priority
Choose between standard source engine bucket behavior or prioritizing the default class utility (default)
1 parent b2c7e37 commit 9ba6f42

File tree

5 files changed

+76
-28
lines changed

5 files changed

+76
-28
lines changed

src/game/client/hl2/hud_weaponselection.cpp

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifdef NEO
1414
#include "c_neo_player.h"
1515
#include "neo_enums.h"
16+
#include "neo/ui/neo_root_settings.h"
1617
#endif // NEO
1718

1819
#include "VGuiMatSurface/IMatSystemSurface.h"
@@ -29,6 +30,9 @@
2930
#include "tier0/memdbgon.h"
3031

3132
ConVar hud_showemptyweaponslots( "hud_showemptyweaponslots", "1", FCVAR_ARCHIVE, "Shows slots for missing weapons when recieving weapons out of order" );
33+
#ifdef NEO
34+
extern ConVar cl_neo_equip_utility_priority;
35+
#endif // NEO
3236

3337
#define SELECTION_TIMEOUT_THRESHOLD 0.5f // Seconds
3438
#define SELECTION_FADEOUT_TIME 0.75f
@@ -1242,16 +1246,21 @@ void CHudWeaponSelection::CycleToNextWeapon( void )
12421246

12431247
m_pLastWeapon = pPlayer->GetActiveWeapon();
12441248

1245-
#ifdef NEO
1246-
C_BaseCombatWeapon *pNextWeapon = FindAndSelectWeaponInCycle(
1247-
pPlayer,
1248-
&CHudWeaponSelection::FindNextWeaponInWeaponSelection,
1249-
1, // iDirection for GetNeoPrioritizedWeaponOnCycle
1250-
-1, // iWrapAroundSlot
1251-
-1 // iWrapAroundPosition
1252-
);
1253-
#else // refactored into FindAndSelectWeaponInCycle
12541249
C_BaseCombatWeapon *pNextWeapon = NULL;
1250+
#ifdef NEO
1251+
if ( cl_neo_equip_utility_priority.GetInt() == NeoSettings::EquipUtilityPriorityType::EQUIP_UTILITY_PRIORITY_CLASS_SPECIFIC )
1252+
{
1253+
pNextWeapon = FindAndSelectWeaponInCycle(
1254+
pPlayer,
1255+
&CHudWeaponSelection::FindNextWeaponInWeaponSelection,
1256+
1, // iDirection for GetNeoPrioritizedWeaponOnCycle
1257+
-1, // iWrapAroundSlot
1258+
-1 // iWrapAroundPosition
1259+
);
1260+
}
1261+
else // EQUIP_UTILITY_PRIORITY_FRAG_SMOKE_DETPACK
1262+
{
1263+
#endif // NEO
12551264
if ( IsInSelectionMode() )
12561265
{
12571266
// find the next selection spot
@@ -1276,6 +1285,8 @@ void CHudWeaponSelection::CycleToNextWeapon( void )
12761285
// wrap around back to start
12771286
pNextWeapon = FindNextWeaponInWeaponSelection(-1, -1);
12781287
}
1288+
#ifdef NEO
1289+
}
12791290
#endif
12801291

12811292
if ( pNextWeapon )
@@ -1305,16 +1316,21 @@ void CHudWeaponSelection::CycleToPrevWeapon( void )
13051316

13061317
m_pLastWeapon = pPlayer->GetActiveWeapon();
13071318

1308-
#ifdef NEO
1309-
C_BaseCombatWeapon *pNextWeapon = FindAndSelectWeaponInCycle(
1310-
pPlayer,
1311-
&CHudWeaponSelection::FindPrevWeaponInWeaponSelection,
1312-
-1, // iDirection for GetNeoPrioritizedWeaponOnCycle
1313-
MAX_WEAPON_SLOTS, // iWrapAroundSlot
1314-
MAX_WEAPON_POSITIONS // iWrapAroundPosition
1315-
);
1316-
#else // refactored into FindAndSelectWeaponInCycle
13171319
C_BaseCombatWeapon *pNextWeapon = NULL;
1320+
#ifdef NEO
1321+
if ( cl_neo_equip_utility_priority.GetInt() == NeoSettings::EquipUtilityPriorityType::EQUIP_UTILITY_PRIORITY_CLASS_SPECIFIC )
1322+
{
1323+
pNextWeapon = FindAndSelectWeaponInCycle(
1324+
pPlayer,
1325+
&CHudWeaponSelection::FindPrevWeaponInWeaponSelection,
1326+
-1, // iDirection for GetNeoPrioritizedWeaponOnCycle
1327+
MAX_WEAPON_SLOTS, // iWrapAroundSlot
1328+
MAX_WEAPON_POSITIONS // iWrapAroundPosition
1329+
);
1330+
}
1331+
else // EQUIP_UTILITY_PRIORITY_FRAG_SMOKE_DETPACK
1332+
{
1333+
#endif // NEO
13181334
if ( IsInSelectionMode() )
13191335
{
13201336
// find the next selection spot
@@ -1339,6 +1355,8 @@ void CHudWeaponSelection::CycleToPrevWeapon( void )
13391355
// wrap around back to end of weapon list
13401356
pNextWeapon = FindPrevWeaponInWeaponSelection(MAX_WEAPON_SLOTS, MAX_WEAPON_POSITIONS);
13411357
}
1358+
#ifdef NEO
1359+
}
13421360
#endif
13431361

13441362
if ( pNextWeapon )
@@ -1524,13 +1542,16 @@ void CHudWeaponSelection::FastWeaponSwitch( int iWeaponSlot )
15241542
C_BaseCombatWeapon *pNextWeapon = NULL;
15251543
C_BaseCombatWeapon *pActiveWeapon = pPlayer->GetActiveWeapon();
15261544

1527-
// Check if the player is already in the target slot
1528-
bool bAlreadyInSlot = (pActiveWeapon && pActiveWeapon->GetSlot() == iWeaponSlot);
1529-
1530-
// Apply class-based prioritization only when switching into the slot
1531-
if (!bAlreadyInSlot)
1545+
if (cl_neo_equip_utility_priority.GetInt() == NeoSettings::EquipUtilityPriorityType::EQUIP_UTILITY_PRIORITY_CLASS_SPECIFIC)
15321546
{
1533-
pNextWeapon = GetNeoClassUtilityWeapon(iWeaponSlot, pPlayer);
1547+
// Check if the player is already in the target slot
1548+
bool bAlreadyInSlot = (pActiveWeapon && pActiveWeapon->GetSlot() == iWeaponSlot);
1549+
1550+
// Apply class-based prioritization only when switching into the slot
1551+
if (!bAlreadyInSlot)
1552+
{
1553+
pNextWeapon = GetNeoClassUtilityWeapon(iWeaponSlot, pPlayer);
1554+
}
15341555
}
15351556

15361557
// If no class-prioritized weapon was found, or if already in the slot, proceed with original cycling logic
@@ -1539,14 +1560,16 @@ void CHudWeaponSelection::FastWeaponSwitch( int iWeaponSlot )
15391560
#endif // NEO
15401561
// see where we should start selection
15411562
int iPosition = -1;
1563+
#ifndef NEO // avoid shadowing NEO pActiveWeapon above
15421564
C_BaseCombatWeapon *pActiveWeapon = pPlayer->GetActiveWeapon();
1565+
#endif // if not defined NEO
15431566
if ( pActiveWeapon && pActiveWeapon->GetSlot() == iWeaponSlot )
15441567
{
15451568
// start after this weapon
15461569
iPosition = pActiveWeapon->GetPosition();
15471570
}
15481571

1549-
#ifndef NEO // avoid shadowing NEO location above
1572+
#ifndef NEO // avoid shadowing NEO pNextWeapon above
15501573
C_BaseCombatWeapon *pNextWeapon = NULL;
15511574
#endif // if not defined NEO
15521575

src/game/client/neo/c_neo_player.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ ConVar cl_drawhud_quickinfo("cl_drawhud_quickinfo", "0", 0,
140140

141141
ConVar cl_neo_streamermode("cl_neo_streamermode", "0", FCVAR_ARCHIVE | FCVAR_USERINFO, "Streamer mode turns player names into generic names and hide avatars.", true, 0.0f, true, 1.0f);
142142
ConVar cl_neo_streamermode_autodetect_obs("cl_neo_streamermode_autodetect_obs", "0", FCVAR_ARCHIVE, "Automatically turn cl_neo_streamermode on if OBS was detected on startup.", true, 0.0f, true, 1.0f);
143+
ConVar cl_neo_equip_utility_priority("cl_neo_equip_utility_priority", "1", FCVAR_ARCHIVE, "Utility slot equip priority. 0 = Frag,Smoke,Detpack, 1 = Class Specific First.", true, 0.0f, true, 1.0f);
143144

144145
extern ConVar sv_neo_clantag_allow;
145146
extern ConVar sv_neo_dev_test_clantag;

src/game/client/neo/ui/neo_root_settings.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ void NeoSettingsRestore(NeoSettings *ns, const NeoSettings::Keys::Flags flagsKey
417417
pGeneral->bExtendedKillfeed = cvr->cl_neo_hud_extended_killfeed.GetBool();
418418
pGeneral->iBackground = clamp(cvr->sv_unlockedchapters.GetInt(), 0, ns->iCBListSize - 1);
419419
pGeneral->iKdinfoToggletype = cvr->cl_neo_kdinfo_toggletype.GetInt();
420+
pGeneral->iEquipUtilityPriority = cvr->cl_neo_equip_utility_priority.GetInt();
420421
NeoSettingsBackgroundWrite(ns);
421422
NeoUI::ResetTextures();
422423
}
@@ -699,6 +700,7 @@ void NeoSettingsSave(const NeoSettings *ns)
699700
cvr->cl_neo_hud_extended_killfeed.SetValue(pGeneral->bExtendedKillfeed);
700701
cvr->sv_unlockedchapters.SetValue(pGeneral->iBackground);
701702
cvr->cl_neo_kdinfo_toggletype.SetValue(pGeneral->iKdinfoToggletype);
703+
cvr->cl_neo_equip_utility_priority.SetValue(pGeneral->iEquipUtilityPriority);
702704
NeoSettingsBackgroundWrite(ns);
703705
}
704706
{
@@ -898,6 +900,11 @@ static const wchar_t *KDMGINFO_TOGGLETYPE_LABELS[KDMGINFO_TOGGLETYPE__TOTAL] = {
898900
L"Never", // KDMGINFO_TOGGLETYPE_NEVER
899901
};
900902

903+
static const wchar_t *EQUIP_UTILITY_PRIORITY_LABELS[NeoSettings::EquipUtilityPriorityType::EQUIP_UTILITY_PRIORITY__TOTAL] = {
904+
L"Frag, Smoke, Detpack", // EQUIP_UTILITY_PRIORITY_FRAG_SMOKE_DETPACK
905+
L"Class Specific First" // EQUIP_UTILITY_PRIORITY_CLASS_SPECIFIC
906+
};
907+
901908
void NeoSettings_General(NeoSettings *ns)
902909
{
903910
NeoSettings::General *pGeneral = &ns->general;
@@ -937,6 +944,7 @@ void NeoSettings_General(NeoSettings *ns)
937944
NeoUI::RingBoxBool(L"Show rangefinder", &pGeneral->bEnableRangeFinder);
938945
NeoUI::RingBoxBool(L"Extended Killfeed", &pGeneral->bExtendedKillfeed);
939946
NeoUI::RingBox(L"Killer damage info auto show", KDMGINFO_TOGGLETYPE_LABELS, KDMGINFO_TOGGLETYPE__TOTAL, &pGeneral->iKdinfoToggletype);
947+
NeoUI::RingBox(L"Utility slot equip priority", EQUIP_UTILITY_PRIORITY_LABELS, NeoSettings::EquipUtilityPriorityType::EQUIP_UTILITY_PRIORITY__TOTAL, &pGeneral->iEquipUtilityPriority);
940948

941949

942950
NeoUI::HeadingLabel(L"MAIN MENU");

src/game/client/neo/ui/neo_root_settings.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct NeoSettings
6464
bool bExtendedKillfeed;
6565
int iBackground;
6666
int iKdinfoToggletype;
67+
int iEquipUtilityPriority;
6768
};
6869

6970
struct Keys
@@ -175,6 +176,14 @@ struct NeoSettings
175176
Texture arTextures[CROSSHAIR_STYLE__TOTAL];
176177
};
177178

179+
enum EquipUtilityPriorityType
180+
{
181+
EQUIP_UTILITY_PRIORITY_FRAG_SMOKE_DETPACK = 0,
182+
EQUIP_UTILITY_PRIORITY_CLASS_SPECIFIC,
183+
184+
EQUIP_UTILITY_PRIORITY__TOTAL,
185+
};
186+
178187
General general;
179188
Keys keys;
180189
Mouse mouse;
@@ -220,6 +229,7 @@ struct NeoSettings
220229
CONVARREF_DEF(cl_neo_hud_rangefinder_enabled);
221230
CONVARREF_DEF(sv_unlockedchapters);
222231
CONVARREF_DEF(cl_neo_kdinfo_toggletype);
232+
CONVARREF_DEF(cl_neo_equip_utility_priority);
223233

224234
// Multiplayer
225235
CONVARREF_DEF(cl_spraydisable);

src/game/server/neo/neo_player.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2894,9 +2894,9 @@ void GiveDet(CNEO_Player* pPlayer)
28942894
auto pWeapon = assert_cast<CNEOBaseCombatWeapon*>((CBaseEntity*)pent);
28952895
if (pWeapon)
28962896
{
2897-
const int detXpCost = pWeapon->GetNeoWepXPCost(pPlayer->GetClass());
2897+
const int detXpCost = -1;
28982898
// Cost of -1 XP means no XP cost.
2899-
const bool canHaveDet = (detXpCost < 0 || pPlayer->m_iXP >= detXpCost);
2899+
const bool canHaveDet = true;
29002900

29012901
pWeapon->SetSubType(0);
29022902
if (canHaveDet)
@@ -2924,17 +2924,23 @@ void CNEO_Player::GiveDefaultItems(void)
29242924
case NEO_CLASS_RECON:
29252925
GiveNamedItem("weapon_knife");
29262926
GiveNamedItem("weapon_milso");
2927-
if (this->m_iXP >= 4) { GiveDet(this); }
2927+
GiveNamedItem("weapon_smokegrenade");
2928+
GiveNamedItem("weapon_grenade");
2929+
GiveDet(this);
29282930
Weapon_Switch(Weapon_OwnsThisType("weapon_milso"));
29292931
break;
29302932
case NEO_CLASS_ASSAULT:
29312933
GiveNamedItem("weapon_knife");
29322934
GiveNamedItem("weapon_tachi");
2935+
GiveDet(this);
2936+
GiveNamedItem("weapon_smokegrenade");
29332937
GiveNamedItem("weapon_grenade");
29342938
Weapon_Switch(Weapon_OwnsThisType("weapon_tachi"));
29352939
break;
29362940
case NEO_CLASS_SUPPORT:
29372941
GiveNamedItem("weapon_kyla");
2942+
GiveDet(this);
2943+
GiveNamedItem("weapon_grenade");
29382944
GiveNamedItem("weapon_smokegrenade");
29392945
Weapon_Switch(Weapon_OwnsThisType("weapon_kyla"));
29402946
break;

0 commit comments

Comments
 (0)