Skip to content

Weapon Information

KernCore edited this page May 18, 2024 · 5 revisions

You can assign custom weapons information about its functionality by defining the function bool GetItemInfo(ItemInfo& out info) inside the weapon class.

ItemInfo Contents

Convers the full contents of ItemInfo.

ItemInfo Variables Expected Value Type
int iMaxAmmo1 -1 if the weapon does not use Primary Ammo.
int iAmmo1Drop Amount of primary ammo dropped, player won't drop anything below this value.
int iMaxAmmo2 -1 if the weapon does not use Secondary Ammo
int iAmmo2Drop Amount of secondary ammo dropped. (Player won't drop anything below this value).
int iSlot Assigns a slot for the Weapon. Any value between 0 and 9 (9 is a hidden weapon slot).
int iPosition Weapon position in the assigned slot. Any value between 0 and 24 (Most slots have positions 0 to 3 covered by the game's weapons).
int iFlags Weapon flags
int iWeight Weapon's importance when autoselecting
int iId (1) Weapon's id
int iMaxClip (2) Weapon's primary ammo max clip contents.

(1) The function CItemRegistry::GetIdForName(string) be used to automatically assign the weapon's ID.
(2) Assigning Secondary ammo clips requires directly setting CBasePlayerWeapon::m_iClip2 to a value (Weapon must have secondary ammo).

ItemInfo Functions Description
void ItemInfo() Constructor.
void ItemInfo(const ItemInfo& in other) Constructor.
ItemInfo& opAssign(const ItemInfo& in other) Assignment operator.
string szName() const Returns the weapon's name.
string szAmmo1() const Returns the weapon's primary ammo name.
string szAmmo2() const Returns the weapon's secondary ammo name.

ItemFlag Contents

Covers the flags used in ItemInfo::iFlags.

Item Flags Description
ITEM_FLAG_SELECTONEMPTY (1) Allow this weapon to be selected if it has no ammo.
ITEM_FLAG_NOAUTORELOAD (2) Don't automatically reload this weapon.
ITEM_FLAG_NOAUTOSWITCHEMPTY (4) Don't automatically switch away from this weapon when it runs out of ammo.
ITEM_FLAG_LIMITINWORLD (8) If there are few entity slots left, this item will not respawn.
ITEM_FLAG_EXHAUSTIBLE (16) A player can totally exhaust their ammo supply and lose this weapon.
ITEM_FLAG_DUALWIELD (32) Use a special HUD ammo configuration unique to a dual wielded weapons.
ITEM_FLAG_IGNOREWEAPONSTAY (64) Ignore weaponstay settings when respawning this weapon.
ITEM_FLAG_ESSENTIAL (128) This weapon should not be dropped straight away when the player dies, only if he is gibbed or if he respawned.
Clone this wiki locally