Wikia

Garrys Mod Wiki

NPCs

Talk0
37pages on
this wiki
Caution: Enemy NPCs will attack you immediately once spawned and are active even while the game menu is open. If you spawn an Antlion or Antlion Guard, it will attack and if your health is reduced enough, kill you - immediately - if it can reach you, even though you haven't released the game menu. However, to prevent this, you can disable the AI, or select the "Ignore Player" check box at the bottom of the Menu.

In the Game Menu, the NPC tab brings up a selection of all the Non-Player Characters (NPCs) which you can create. Friend or enemy NPCs can be created from this menu. Click on one and it is immediately created at the place where the crosshair was when the Game Menu was opened.

For now, the remeinder of this article will just contain a few examples on how NPCs can be manipulated using Lua.

An NPC is a non-player controlled character. NPCs in GMod are semi-controlled by a basic friend-or-foe AI. This decides which NPCs will shoot at each other and players. GMod supports an NPC object, which is derived from the Entity object and therefore shares all Entity functions.

You can download more NPCs in http://www.garrysmod.org.

Or, at the Steam Workshop

Movement Edit

NPCs can be instructed to try and move to a new Vector position in the world. If they cannot directly reach this position, they will not try and find a path to it, thus remaining standing still.

The following code would tell an NPC to try and move to vector. Note: a full listing of SCHED_ enumerations can be found at the end of this article.


<lua> NPC:SetLastPosition( vector ) NPC:SetSchedule( SCHED_FORCED_GO_RUN ) </lua>

Schedule Enumerators Edit

Use these enumerations with NPC.SetSchedule to instruct the NPC to follow a specific order.

SCHED_NONE =			0
SCHED_IDLE_STAND =		1
SCHED_IDLE_WALK	=	 	2
SCHED_IDLE_WANDER=		3
SCHED_WAKE_ANGRY=		4
SCHED_ALERT_FACE =		5
SCHED_ALERT_FACE_BESTSOUND =	6
SCHED_ALERT_SCAN=		7
SCHED_ALERT_STAND =		8
SCHED_ALERT_WALK=		9
SCHED_INVESTIGATE_SOUND =	10
SCHED_COMBAT_FACE=		11
SCHED_COMBAT_SWEEP =		12
SCHED_FEAR_FACE =		13
SCHED_COMBAT_STAND =		14
SCHED_COMBAT_WALK =		15
SCHED_CHASE_ENEMY=		16
SCHED_CHASE_ENEMY_FAILED =	17
SCHED_VICTORY_DANCE =		18
SCHED_TARGET_FACE =		19
SCHED_TARGET_CHASE =		20
SCHED_SMALL_FLINCH =		21
SCHED_BIG_FLINCH =		22
SCHED_BACK_AWAY_FROM_ENEMY =	23
SCHED_BACK_AWAY_FROM_SAVE_POSITION =	24
SCHED_TAKE_COVER_FROM_ENEMY =	25
SCHED_TAKE_COVER_FROM_BEST_SOUND =	26
SCHED_FLEE_FROM_BEST_SOUND =	27
SCHED_TAKE_COVER_FROM_ORIGIN =	28
SCHED_FAIL_TAKE_COVER =		29
SCHED_RUN_FROM_ENEMY =		30
SCHED_RUN_FROM_ENEMY_FALLBACK =	31
SCHED_MOVE_TO_WEAPON_RANGE =	32
SCHED_ESTABLISH_LINE_OF_FIRE =	33
SCHED_SHOOT_ENEMY_COVER=	37
SCHED_ESTABLISH_LINE_OF_FIRE_FALLBACK =	34
SCHED_PRE_FAIL_ESTABLISH_LINE_OF_FIRE =	35
SCHED_FAIL_ESTABLISH_LINE_OF_FIRE =	36
SCHED_COWER =			38
SCHED_MELEE_ATTACK1 =		39
SCHED_MELEE_ATTACK2 =		40
SCHED_RANGE_ATTACK1 =		41
SCHED_RANGE_ATTACK2 =		42
SCHED_SPECIAL_ATTACK1 =		43
SCHED_SPECIAL_ATTACK2 =		44
SCHED_STANDOFF =		45
SCHED_ARM_WEAPON =		46
SCHED_DISARM_WEAPON =		47
SCHED_HIDE_AND_RELOAD =		48
SCHED_RELOAD =			49
SCHED_AMBUSH =			50
SCHED_DIE =			51
SCHED_DIE_RAGDOLL =		52
SCHED_WAIT_FOR_SCRIPT =		53
SCHED_AISCRIPT =		54
SCHED_SCRIPTED_WALK =		55
SCHED_SCRIPTED_RUN =		56
SCHED_SCRIPTED_CUSTOM_MOVE =	57
SCHED_SCRIPTED_WAIT =		58
SCHED_SCRIPTED_FACE =		59
SCHED_SCENE_GENERIC =		60
SCHED_NEW_WEAPON =		61
SCHED_NEW_WEAPON_CHEAT =	62
SCHED_GET_HEALTHKIT =		63
SCHED_GIVE_WAY=			65
SCHED_MOVE_AWAY=		66
SCHED_MOVE_AWAY_FAIL =		67
SCHED_MOVE_AWAY_END =		68
SCHED_WAIT_FOR_SPEAK_FINISH =	64
SCHED_FORCED_GO =		70
SCHED_FORCED_GO_RUN =		71
SCHED_PATROL_WALK =		72
SCHED_COMBAT_PATROL =		73
SCHED_PATROL_RUN =		74
SCHED_RUN_RANDOM =		75
SCHED_FAIL =			79
SCHED_FALL_TO_GROUND =		76
SCHED_DROPSHIP_DUSTOFF =	77
SCHED_NPC_FREEZE =		71
SCHED_FLINCH_PHYSICS =		78
SCHED_CROW_IDLE_WALK =		80
SCHED_CROW_IDLE_FLY =		81
SCHED_CROW_WALK_AWAY =		82
SCHED_CROW_RUN_AWAY =		83
SCHED_CROW_HOP_AWAY =		84
SCHED_CROW_FLY_AWAY =		85
SCHED_CROW_FLY =		86
SCHED_CROW_FLY_FAIL =		87

A list of NPC'sEdit

AnimalsEdit

  • Crow
  • Pigeon
  • Seagull
  • Father Grigori

CombineEdit

  • City Scanner
  • Claw Scanner
  • Combine Elite
  • Combine Soldier
  • Metro Police
  • Prison Guard
  • Strider
  • Stalker

Human and ResistanceEdit

  • Citizens
  • Alyx Vance
  • Dog
  • Dr.Isaac Kleiner
  • Odessa Cubbage
  • Refugee
  • Wallace Breen
  • Barney Calhoun
  • Vortigaunt
  • Eli Vance
  • Dr.Judith Mossman
  • Father Grigori

Zombies + Enemy AliensEdit

  • Antlion
  • Antlion Guard
  • Fast Zombie
  • Headcrab
  • Headcrab Black
  • Headcrab Fast
  • Poison Zombie
  • Zombie
  • Zombie Torso
  • Barnacle

Half Life: SourceEdit

  • Barney Calhoun
  • Headcrab
  • Zombie
  • Bull Chicken (Bull Squid)
  • Snark
  • Scientist
  • Grunt
  • Baby Crab
  • Big Momma
  • Alien Slave
  • Alien Grunt
  • Assassin
  • Controller
  • Gargantua
  • Nihilanth
  • Cockroach

NPCs that come in the game with Episode TwoEdit

  • Dr.Arne Magnusson
  • Antlion Worker
  • Antlion Guardian
  • Zombine
  • Hunter

NextbotEdit

  • Test NPC

Around Wikia's network

Random Wiki