From Valve Developer Community
Jump to: navigation, search

game_weapon_manager is a point entity available in all Source games.

Entity description

It is 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.


This entity conducts a count of all the weapons in the world of my type and see if we have a surplus. If there is a surplus, try to find suitable candidates for removal. Right now we just remove the first weapons we find that are behind the player, or are out of the player's PVS.

Note:This code is designed to not remove weapons that are hand-placed by level designers. It should only clean up weapons dropped by dead NPCs, which is useful in situations where enemies are spawned in for a sustained period of time.

Warning: This entity is designed using UTIL_GetLocalPlayer, which returns NULL in any type of multiplayer game.

In code it is represented by class CGameWeaponManager, defined in basecombatweapon_shared.cpp.


Weapon Classname <string>
Classname of the weapon type to limit.
Max Allowed in Level <integer>
The maximum amount of the specified weapon type allowed in the world.
Ammo modifier <float>
Modifier for amount of ammo dropped by a weapon.


Name (targetname) <string>
The targetname that other entities refer to this entity by.


SetAmmoModifier <float>
Adjust the ammo modifier.


AddOutput <string>
Format: <key> <value>
FireUser1 to FireUser4
Fire the OnUser outputs; see User Inputs and Outputs.
Use  !FGD
This input is not included in Valve's FGDs.
RunScriptFile <script> (New with Left 4 Dead 2)
RunScriptCode <string> (New with Left 4 Dead 2)
Execute a VScript function in the scope of the receiving entity.
SetLocalOrigin <coordinates> (New with Alien Swarm) !FGD
SetLocalAngles <angles> (New with Alien Swarm) !FGD
Set this entity's angles.



OnUser1 to OnUser4
OnKilled  (Only in the Left 4 Dead series)