Skip to content

Commit

Permalink
[HL25] New item flag NOAUTOSWITCHTO for RPG
Browse files Browse the repository at this point in the history
Prevents the RPG from being auto-switched to on auto weapon switch events
  • Loading branch information
LogicAndTrick authored and JoelTroch committed Aug 29, 2024
1 parent 8d3d368 commit 2353ca4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions dlls/gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ CBasePlayerItem* CGameRules::FindNextBestWeapon(CBasePlayer* pPlayer, CBasePlaye
continue;
}

if ((pCheck->iFlags() & ITEM_FLAG_NOAUTOSWITCHTO) != 0)
{
continue;
}

if (pCheck->iWeight() > -1 && pCheck->iWeight() == currentWeight)
{
// this weapon is from the same category.
Expand Down
2 changes: 1 addition & 1 deletion dlls/rpg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ bool CRpg::GetItemInfo(ItemInfo* p)
p->iSlot = 3;
p->iPosition = 0;
p->iId = m_iId = WEAPON_RPG;
p->iFlags = 0;
p->iFlags = ITEM_FLAG_NOAUTOSWITCHTO;
p->iWeight = RPG_WEIGHT;

return true;
Expand Down
1 change: 1 addition & 0 deletions dlls/weapons.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ typedef enum
#define ITEM_FLAG_NOAUTOSWITCHEMPTY 4
#define ITEM_FLAG_LIMITINWORLD 8
#define ITEM_FLAG_EXHAUSTIBLE 16 // A player can totally exhaust their ammo supply and lose this weapon
#define ITEM_FLAG_NOAUTOSWITCHTO 32

#define WEAPON_IS_ONTARGET 0x40

Expand Down

0 comments on commit 2353ca4

Please sign in to comment.