Mapbase/Entities/NPCs: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Mapbase NPC changes documentation)
 
m (Substituted IO templates)
 
Line 12: Line 12:


== Inputs ==
== Inputs ==
{{IO|SetHealthFraction|param=float|Sets a NPC's health as a ratio in between 0 and 1. This input already existed on {{ent|npc_helicopter}}, but it was expanded to be used on any NPC.}}
{{I|SetHealthFraction|param=float|Sets a NPC's health as a ratio in between 0 and 1. This input already existed on {{ent|npc_helicopter}}, but it was expanded to be used on any NPC.}}
<hr>
<hr>
{{IO|GiveWeaponHolstered|param=string|Gives a NPC the specified weapon, but make it start holstered (meaning the NPC has to get it out on their own).}}
{{I|GiveWeaponHolstered|param=string|Gives a NPC the specified weapon, but make it start holstered (meaning the NPC has to get it out on their own).}}
{{IO|ChangeWeapon|param=string|Holsters a NPC's current weapon, and then unholsters the specified weapon.}}
{{I|ChangeWeapon|param=string|Holsters a NPC's current weapon, and then unholsters the specified weapon.}}
{{IO|PickupWeapon|param=target_destination|Makes a NPC look for and pick up the specified weapon, which should be an entity in the world.}}
{{I|PickupWeapon|param=target_destination|Makes a NPC look for and pick up the specified weapon, which should be an entity in the world.}}
{{IO|PickupItem|param=target_destination|Makes a NPC look for and pick up the specified weapon, which should be an entity in the world.}}
{{I|PickupItem|param=target_destination|Makes a NPC look for and pick up the specified weapon, which should be an entity in the world.}}
<hr>
<hr>
{{IO|PickupItem|param=integer|Overrides how the game should treat friendly fire towards a specific NPC. 0 = No friendly fire, 1 = Friendly fire, 2 = Use NPC settings/no override}}
{{I|PickupItem|param=integer|Overrides how the game should treat friendly fire towards a specific NPC. 0 = No friendly fire, 1 = Friendly fire, 2 = Use NPC settings/no override}}
{{IO|SetDynamicInteractions|param=integer|Sets a NPC's ability to use dynamic interactions. 0 = No interactions allowed, 1 = All interactions allowed, 2 = Non-Mapbase interactions only}}
{{I|SetDynamicInteractions|param=integer|Sets a NPC's ability to use dynamic interactions. 0 = No interactions allowed, 1 = All interactions allowed, 2 = Non-Mapbase interactions only}}
<hr>
<hr>
{{IO|AddCapabilities|param=flags|Adds the specified {{code|Capability_t}} capabilities to a NPC.}}
{{I|AddCapabilities|param=flags|Adds the specified {{code|Capability_t}} capabilities to a NPC.}}
{{IO|RemoveCapabilities|param=flags|Removes the specified {{code|Capability_t}} capabilities from a NPC.}}
{{I|RemoveCapabilities|param=flags|Removes the specified {{code|Capability_t}} capabilities from a NPC.}}
<hr>
<hr>
{{IO|SetCondition|param=string|Adds the specified condition to a NPC. Can be the name or integer ID of the condition.}}
{{I|SetCondition|param=string|Adds the specified condition to a NPC. Can be the name or integer ID of the condition.}}
{{IO|RemoveCondition|param=string|Removes the specified condition from a NPC. Can be the name or integer ID of the condition.}}
{{I|RemoveCondition|param=string|Removes the specified condition from a NPC. Can be the name or integer ID of the condition.}}
<hr>
<hr>
{{IO|SetHintGroup|param=string|Sets a NPC's hint group.}}
{{I|SetHintGroup|param=string|Sets a NPC's hint group.}}
<hr>
<hr>
{{IO|SetThinkNPC|param=float|Sets an entity's general think function to {{code|CallNPCThink}}. A float can be passed to delay this by a specific time.}}
{{I|SetThinkNPC|param=float|Sets an entity's general think function to {{code|CallNPCThink}}. A float can be passed to delay this by a specific time.}}
<hr>
<hr>
{{IO|SetDistLook|param=float|Manually sets this NPC's sight distance. Pass '0' to reset.}}
{{I|SetDistLook|param=float|Manually sets this NPC's sight distance. Pass '0' to reset.}}
{{IO|SetDistTooFar|param=float|Manually sets the distance in which NPCs will consider a target too far to attack. Pass '0' to reset.}}
{{I|SetDistTooFar|param=float|Manually sets the distance in which NPCs will consider a target too far to attack. Pass '0' to reset.}}
<hr>
<hr>
{{IO|SetSpeedModifier|param=float|Set a float value to multiply movement animation speed.}}
{{I|SetSpeedModifier|param=float|Set a float value to multiply movement animation speed.}}


== Outputs ==
== Outputs ==
{{IO|OnStateChange|param=integer|Fires whenever a NPC changes state, passing the NPC's new state.}}
{{O|OnStateChange|param=integer|Fires whenever a NPC changes state, passing the NPC's new state.}}
<hr>
<hr>
{{IO|OnItemPickup|param=target_destination|Fires when a NPC picks up an item (e.g. a health vial), passing the item entity.}}
{{O|OnItemPickup|param=target_destination|Fires when a NPC picks up an item (e.g. a health vial), passing the item entity.}}
<hr>
<hr>
{{IO|OnHolsterWeapon|param=target_destination|Fires when a NPC holsters their current weapon, passing the weapon entity.}}
{{O|OnHolsterWeapon|param=target_destination|Fires when a NPC holsters their current weapon, passing the weapon entity.}}
{{IO|OnUnholsterWeapon|param=target_destination|Fires when a NPC unholsters their current weapon, passing the weapon entity.}}
{{O|OnUnholsterWeapon|param=target_destination|Fires when a NPC unholsters their current weapon, passing the weapon entity.}}


== KeyValues ==
== KeyValues ==

Latest revision as of 11:09, 21 April 2025

This page lists Mapbase 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

Icon-Important.pngImportant:I/O/KV which were added to both players and NPCs can be found in Base Combat Character.

Inputs

SetHealthFraction <floatRedirectInput/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 <stringRedirectInput/string>
Gives a NPC the specified weapon, but make it start holstered (meaning the NPC has to get it out on their own).
ChangeWeapon <stringRedirectInput/string>
Holsters a NPC's current weapon, and then unholsters the specified weapon.
PickupWeapon <targetnameRedirectInput/string>
Makes a NPC look for and pick up the specified weapon, which should be an entity in the world.
PickupItem <targetnameRedirectInput/string>
Makes a NPC look for and pick up the specified weapon, which should be an entity in the world.

PickupItem <integerRedirectInput/integer>
SetDynamicInteractions <integerRedirectInput/integer>

AddCapabilities <flags>
Adds the specified Capability_t capabilities to a NPC.
RemoveCapabilities <flags>
Removes the specified Capability_t capabilities from a NPC.

SetCondition <stringRedirectInput/string>
Adds the specified condition to a NPC. Can be the name or integer ID of the condition.
RemoveCondition <stringRedirectInput/string>
Removes the specified condition from a NPC. Can be the name or integer ID of the condition.

SetHintGroup <stringRedirectInput/string>
Sets a NPC's hint group.

SetThinkNPC <floatRedirectInput/float>
Sets an entity's general think function to CallNPCThink. A float can be passed to delay this by a specific time.

SetDistLook <floatRedirectInput/float>
Manually sets this NPC's sight distance. Pass '0' to reset.
SetDistTooFar <floatRedirectInput/float>
Manually sets the distance in which NPCs will consider a target too far to attack. Pass '0' to reset.

SetSpeedModifier <floatRedirectInput/float>
Set a float value to multiply movement animation speed.

Outputs

OnStateChange <integerRedirectOutput/integer>
Fires whenever a NPC changes state, passing the NPC's new state.

OnItemPickup <targetnameRedirectOutput/string>
Fires when a NPC picks up an item (e.g. a health vial), passing the item entity.

OnHolsterWeapon <targetnameRedirectOutput/string>
Fires when a NPC holsters their current weapon, passing the weapon entity.
OnUnholsterWeapon <targetnameRedirectOutput/string>
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 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

Main article:  Custom Animations

Mapbase changes the activities of many Half-Life 2 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.