NPCs are set in a map using the classname "monster_". This will simply spawn the npcs in their location upon map initialization. They do not need to be triggered to spawn. If you need to dynamically spawn npcs in-game, use entities like squadmaker or for alien enemies, env_xenmaker- these do need to be triggered to spawn.
{ "classname" "monster_generic" "targetname" "target_me" "origin" "x y z" "angles" "p y r" "netname" "squad_x" "freeroam" "0/1" "path_name" "<path name>" "guard_ent" "<entity name>" "TriggerCondition" "c" "TriggerTarget" "another_entity" "weapons" "w" "body" "b" "sequence" "q" "model" "models/model.mdl" "rendercolor" "0 0 0" "spawnflags" "s" }
The code uses the monster_generic entity, this can be replaced with monster specific classnames which can be found in their pages- check the list below for the desired npc. In addition, some npcs have custom attributes and flags that can be used.
To find the specific npc you want to spawn, check the lists below to find their classname.
NPCs | ||
---|---|---|
Black Mesa | Scientist · Security Guard | |
HECU | Grunt · Engineer · Medic · Sergeant | |
Black Ops | Female Assassin · Male Assassin · Bodyguard | |
Aliens | Alien Controller · Alien Grunt · Alien Slave ·
Baby Gargantua · Baby Headcrab · Baby Voltigore · Barnacle · Bullsquid · Chumtoad · Gargantua · Gene Worm · Gonarch · Gonome · Headcrab · Houndeye · Ichthyosaur · Kingpin · Leech · Nihilanth · Panthereye · Pit Drone · Pit Worm · Shock Roach · Shock Trooper · Snark · Stukabat · Tentacle · Voltigore · Xen Commander · Zombie | |
Machines | Large Mounted Turret · Small Mounted Turret · Sentry Turret · Robot Grunt |
Attributes[]
- Display Name- "displayname" "<custom name>" : Assigns a customized name for the npc. The new name will be displayed in the monster information and the kill feed in-game. This is useful for giving names to important characters that use monster_generic.
- Health- "health" "hp" : Sets a custom health value for the spawns npc- replace hp with a numerical value of your choice. If not set the npc will spawn with its default health value, so usage of this key is optional and can be otherwise ignored.
- Is not revivable- "is_not_revivable" "0/1" : Enabling this will prevent npcs being revived.
- Squad Name- "netname" "<squad name>"- Name of a squad for this monster to be part of. Monsters which share the same squadname/are in the same squad, will attempt to stay together and follow their squad's leader (monster with "SquadLeader" flag).
- Entity To Guard- "guard_ent" "<entity targetname>" : If set, the monster will try to follow and protect (attack its attackers) the given entity.
Positioning[]
- Origin- "origin" "x y z" : This must be defined to set the spawn point for the npc on map initialization
- Angles- "angles" "p y r" : This sets the angle which the npc faces. Only the middle value should be changed, the first and last values should always be 0.
Appearance[]
The appearance of the spawned entity can be customized:
- Model- "model" "models/<modelname>.mdl" : changes the model of the npc to a selected one
- Body- "body" "b" : If the model has different bodygroups, b is the corresponding numerical value of that bodygroup. A model viewer can be used to display the different bodies and the corresponding value.
- Head-
- Skin-
- Weapons-
Triggering Functions[]
- Trigger Condition- "TriggerCondition" "c": This sets the requirement for the triggertarget to activate based on the behavior of the NPC. To select the condition, simply replace c with one of the numerical values below, which corresponds to the desired condition:
0 : "No Trigger" 1 : "See Player, Mad at Player" 2 : "Take Damage" 3 : "50% Health Remaining" 4 : "Death" 7 : "Hear World" 8 : "Hear Player" 9 : "Hear Combat" 10: "See Player Unconditional" 11: "See Player, Not In Combat"
- Trigger Target- "TriggerTarget" "<entity targetname>" : This attribute assigns the entity to trigger when the Trigger Condition is met.
Flags[]
"spawnflags" "s", when s equals:
- 1- Wait till seen: The npc's AI will be inactive until a player crosses its line of sight. The npc will not interact with anything until this point.
- 2- Gag: The npc's idle sounds will be muted until it is alerted by the player.
- 4- Monsterclip: this sets the npc to collide with a func_monsterclip. When set, the npc will not cross a monsterclip.
- 16- Prisoner: The npc will be set with yhe enemy classification but will not interact with the player.
- 64- Start Inactive: NPC ai will be disabled until triggered by an entity.
All items (41)