Garry's Mod Wiki

NPCData

Description

Information about the NPC data structure, used to define spawnable NPCs for the Sandbox gamemode.

Example usage:

list.Set( "NPC", "npc_tf2_ghost", { Name = "Example NPC", Class = "npc_tf2_ghost", Category = "Nextbot" } )

Members

string Name
The nice name of the NPC for UI display.
string Class
Class name of the entity to spawn.
string Category
Spawnmenu category to put the NPCinto.

Default: "Other"

table Weapons
A list of weapons this NPC is typically meant to use. One will be picked on spawn at random, unless overwritten by the player.

Default: {}

table KeyValues
Key-value pairs to apply to the NPC on spawn. See Entity:SetKeyValue.

Default: {}

string Model
Model override for this NPC.

Default: "nil"

number SpawnFlags
Additional spawnflags for this NPC. See Entity:GetSpawnFlags.

Ignored if TotalSpawnFlags key is present.

Default: 0

number TotalSpawnFlags
Total spawnflags override for this NPC.

Default: nil

boolean OnCeiling
If set to true, this NPC can only be spawned on the ceiling. Stacks with OnFloor.

Default: false

boolean OnFloor
If set to true, this NPC can only be spawned on the floor. Stacks with OnCeiling.

Default: false

number Offset
Offset, in Hammer units, away from the surface where the player is looking at for the NPC spawn position.

Default: 0

string Material
Material override for this NPC. See Entity:SetMaterial.

Default: ""

number Skin
Skin override for the NPC. See Entity:SetSkin.

Default: nil

boolean NoDrop
If set to true, do not try to teleport the NPC to the ground.

Default: false

Angle Rotate
Used to add additional rotation the NPC post spawn. Usually all NPCs would be facing the player on spawn. Value of Angle( 0, 180, 0 ) would make the NPC face away from the player.

Default: Angle( 0, 0, 0 )

number Health
Health override for this NPC. Also sets Entity:SetMaxHealth.

Default: nil

function OnDuplicated
If set, a function to be called when the NPC is pasted using the duplicator library.

Default: nil