Game weapon manager

From Valve Developer Community

This point-based entity is available in all Source games.

Table of contents

Entity Description

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.

The properties of this entity apply to the whole map. Multiple instances of this entity within a map may cause errors.

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.

Image:note.png 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.png 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 (http://doxygen.page.needed//class_c_game_weapon_manager.html), defined in basecombatweapon_shared.cpp (http://doxygen.page.needed/basecombatweapon__shared_8cpp-source.html).

Keyvalues

Defines the name that other entities refer to this entity by.
  • hammerid [Episode Two Update]
<integer readonly> This id is used for debugging purposes in Hammer.
  • weaponname
<string> Classname of the weapon type to limit.
  • maxpieces
<integer> The maximum amount of the specified weapon type allowed in the world.
  • ammomod [Episode One Update]
<float> Modifier for amount of ammo dropped by a weapon.

Inputs

  • Kill
Removes this entity from the world.
Removes this entity and all its children from the world.
  • AddOutput <string>
Evaluates a keyvalue/output on this entity. It can be potentially very dangerous, use with care.
Format: <key> <value>
Format: <output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire (-1 == infinite)>
Causes this entity's OnUser1-4 outputs to be fired. See User Inputs and Outputs.
  • SetAmmoModifier [Episode One Update]
<float> Adjust the ammo modifier.

Outputs

Fired in response to FireUser1-4 inputs. See User Inputs and Outputs.
!activator = activator