Game weapon manager
Jump to navigation
Jump to search


Entity description
It is used to limit the number of a particular weapon class in the world. Useful in places where NPCs are spawning rapidly, dying, and dropping weapons.
- On spawn, this entity will try to create an entity of the classname specified in the KeyValue
weaponname
. If this fails, this entity removes itself. That's why wildcards likeweapon_*
cannot be used. - This entity thinks every 2 seconds, potentially removing weapons.
- Every time this entity thinks, it conducts a count of all the weapons in the world of the specified class and checks if there is a surplus. If so, it tries to find suitable candidates for removal, namely all weapons of the specified class that satisfy
( !weapon->IsEffectActive( EF_NODRAW ) && weapon->IsRemoveable() )
.- Singleplayer games: It removes the first candidates that are found behind the player, or are out of the player's PVS.
- Multiplayer games: This entity removes the candidates with the lowest entity index, regardless of the players' PVS. That's because this entity is designed using UTIL_GetLocalPlayer, which returns
NULL
in any type of multiplayer game.

Keyvalues
- Weapon Classname (weaponname) <string>
- Classname of the weapon type to limit.
- Max Allowed in Level (maxpieces) <integer>
- The maximum amount of the specified weapon type allowed in the world.
- Ammo modifier (ammomod) <float>
- Modifier for amount of ammo dropped by a weapon.
Inputs
- SetAmmoModifier <float >
- Adjust the ammo modifier.
Outputs
FGD Code
This code adds the missing input SetMaxPieces
(namely the penultimate line) in Hammer and must be pasted in the corresponding place of base.fgd.
@PointClass base(Targetname) = game_weapon_manager :
"An entity used to limit the number of a particular weapon type in the world. Useful in places where NPCs are spawning rapidly, dying, and dropping weapons."
[
weaponname(string) : "Weapon Classname" : "" : "Classname of the weapon type to limit."
maxpieces(integer) : "Max Allowed in Level" : 0 : "The maximum amount of the specified weapon type allowed in the world."
ammomod(float) : "Ammo modifier" : 1 : "Modifier for ammount of ammo dropped by a weapon."
// Inputs
input SetAmmoModifier(float): "Adjust the ammo modifier."
input SetMaxPieces(integer): "Adjust the maximum number of specified weapons in the map." // added
]