Mapbase/Entities/NPCs
This page lists Mapbase's changes to CAI_BaseNPC, which every NPC derives from. This means every NPC in the game technically possesses these changes, although some changes might only be relevant to a specific group of them.
Some I/O were ported from other games or were already possible through other, more complicated means (e.g. keyvalues changed with AddOutput).
See Custom Animations for more information on Mapbase's new NPC animations.
I/O/KV

Inputs
- SetHealthFraction <float>
- Sets a NPC's health as a ratio in between 0 and 1. This input already existed on npc_helicopter, but it was expanded to be used on any NPC.
- GiveWeaponHolstered <string>
- Gives a NPC the specified weapon, but make it start holstered (meaning the NPC has to get it out on their own).
- ChangeWeapon <string>
- Holsters a NPC's current weapon, and then unholsters the specified weapon.
- PickupWeapon <targetname>
- Makes a NPC look for and pick up the specified weapon, which should be an entity in the world.
- PickupItem <targetname>
- Makes a NPC look for and pick up the specified weapon, which should be an entity in the world.
- PickupItem <integer>
- SetDynamicInteractions <integer>
- AddCapabilities <flags>
- Adds the specified Capability_t capabilities to a NPC.
- RemoveCapabilities <flags>
- Removes the specified Capability_t capabilities from a NPC.
- SetCondition <string>
- Adds the specified condition to a NPC. Can be the name or integer ID of the condition.
- RemoveCondition <string>
- Removes the specified condition from a NPC. Can be the name or integer ID of the condition.
- SetHintGroup <string>
- Sets a NPC's hint group.
- SetThinkNPC <float>
- Sets an entity's general think function to CallNPCThink. A float can be passed to delay this by a specific time.
- SetDistLook <float>
- Manually sets this NPC's sight distance. Pass '0' to reset.
- SetDistTooFar <float>
- Manually sets the distance in which NPCs will consider a target too far to attack. Pass '0' to reset.
- SetSpeedModifier <float>
- Set a float value to multiply movement animation speed.
Outputs
- OnStateChange <integer>
- Fires whenever a NPC changes state, passing the NPC's new state.
- OnItemPickup <targetname>
- Fires when a NPC picks up an item (e.g. a health vial), passing the item entity.
- OnHolsterWeapon <targetname>
- Fires when a NPC holsters their current weapon, passing the weapon entity.
- OnUnholsterWeapon <targetname>
- Fires when a NPC unholsters their current weapon, passing the weapon entity.
KeyValues
- Friendly fire override (FriendlyFireOverride) <choices>
- Dynamic interactions enabled (SetDynamicInteractions) <choices>
- Spawn with StartScripting (SpawnWithStartScripting) <choices>
- Spawns a NPC in the StartScripting state.
- Speed Modifier (BaseSpeedModifier) <float>
- Multiplies how far a NPC travels while moving. Does not affect the animation itself.
Increased weapon portability
Mapbase greatly expands the capabilities for NPCs using weapons in Half-Life 2 through additional programming as well as new or restored NPC animations.
The following table shows which HL2 NPCs were capable of using various weapons in vanilla Source 2013:
Weapon | Male npc_citizen and allies | Female npc_citizen and allies | npc_metropolice | npc_combine_s |
---|---|---|---|---|
weapon_pistol | Partially | Partially | Yes | No |
weapon_smg1 | Yes | Yes | Yes | Yes |
weapon_ar2 | Yes | Yes | No | Yes |
weapon_shotgun | Yes | Yes | No | Yes |
weapon_357 | No | No | No | No |
weapon_crossbow | No | No | No | No |
weapon_rpg | Yes | Yes | No | No |
weapon_crowbar | Partially | Partially | Yes | No |
weapon_stunstick | Partially | Partially | Yes | No |
weapon_citizenpackage | Yes | Yes | No | No |
weapon_citizensuitcase | Yes | No | No | No |
By contrast, this table shows which HL2 NPCs are capable of using those weapons in Mapbase:
Weapon | Male npc_citizen and allies | Female npc_citizen and allies | npc_metropolice | npc_combine_s |
---|---|---|---|---|
weapon_pistol | Yes | Yes | Yes | Yes |
weapon_smg1 | Yes | Yes | Yes | Yes |
weapon_ar2 | Yes | Yes | Yes | Yes |
weapon_shotgun | Yes | Yes | Yes | Yes |
weapon_357 | Yes | Yes | Yes | Yes |
weapon_crossbow | Yes | Yes | Yes | Yes |
weapon_rpg | Yes | Yes | Partially | Partially |
weapon_crowbar | Partially | Partially | Yes | Yes |
weapon_stunstick | Partially | Partially | Yes | Yes |
weapon_citizenpackage | Yes | Yes | Yes | Yes |
weapon_citizensuitcase | Yes | Yes | Yes | Yes |
Many of these weapons include completely new animations which are detailed in Custom Animations.
Weapon alt-fire capabilities
In vanilla Source 2013, only npc_combine_s is capable of using a weapon's secondary attack, and weapon_ar2 is the only weapon it can use the secondary attack with. Mapbase expands this capability to almost all human NPCs and also gives them the ability to use weapon_smg1's secondary attack.
Remapped activities
Mapbase changes the activities of many Half-Life 2 NPCs to be more consistent with each other and the standards expected from the base activity definitions. See the article linked above for more information.