NPCs
From GMod Wiki
Revision as of 16:34, 21 August 2010 by SorryForN00B (Talk | contribs)
This page has multiple issues. See the Page Details section for information. |
Lua: NPC |
Description: | Explains how to manipulate NPCs using Lua. |
Original Author: | Flukes |
Created: | 1 January 2007 |
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, and how NPCs move and attack. GMod supports an NPC object, which is derived from the Entity object and therefore shares all Entity functions.
Movement
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.
NPC:SetLastPosition( vector ) NPC:SetSchedule( SCHED_FORCED_GO_RUN )
Schedule Enumerations
Use these enumerations with NPC.SetSchedule to instruct the NPC to follow a specific order.
SERVER | 0000000000000000 | 00000000000000000 | SCHED_NONE SERVER | 0000000000000001 | 00000000000000001 | SCHED_IDLE_STAND SERVER | 0000000000000002 | 00000000000000010 | SCHED_IDLE_WALK SERVER | 0000000000000003 | 00000000000000011 | SCHED_IDLE_WANDER SERVER | 0000000000000004 | 00000000000000100 | SCHED_WAKE_ANGRY SERVER | 0000000000000005 | 00000000000000101 | SCHED_ALERT_FACE SERVER | 0000000000000006 | 00000000000000110 | SCHED_ALERT_FACE_BESTSOUND SERVER | 0000000000000007 | 00000000000000111 | SCHED_ALERT_REACT_TO_COMBAT_SOUND SERVER | 0000000000000008 | 00000000000001000 | SCHED_ALERT_SCAN SERVER | 0000000000000009 | 00000000000001001 | SCHED_ALERT_STAND SERVER | 0000000000000010 | 00000000000001010 | SCHED_ALERT_WALK SERVER | 0000000000000011 | 00000000000001011 | SCHED_INVESTIGATE_SOUND SERVER | 0000000000000012 | 00000000000001100 | SCHED_COMBAT_FACE SERVER | 0000000000000013 | 00000000000001101 | SCHED_COMBAT_SWEEP SERVER | 0000000000000014 | 00000000000001110 | SCHED_FEAR_FACE SERVER | 0000000000000015 | 00000000000001111 | SCHED_COMBAT_STAND SERVER | 0000000000000016 | 00000000000010000 | SCHED_COMBAT_WALK SERVER | 0000000000000017 | 00000000000010001 | SCHED_CHASE_ENEMY SERVER | 0000000000000018 | 00000000000010010 | SCHED_CHASE_ENEMY_FAILED SERVER | 0000000000000019 | 00000000000010011 | SCHED_VICTORY_DANCE SERVER | 0000000000000020 | 00000000000010100 | SCHED_TARGET_FACE SERVER | 0000000000000021 | 00000000000010101 | SCHED_TARGET_CHASE SERVER | 0000000000000022 | 00000000000010110 | SCHED_SMALL_FLINCH SERVER | 0000000000000023 | 00000000000010111 | SCHED_BIG_FLINCH SERVER | 0000000000000024 | 00000000000011000 | SCHED_BACK_AWAY_FROM_ENEMY SERVER | 0000000000000025 | 00000000000011001 | SCHED_MOVE_AWAY_FROM_ENEMY SERVER | 0000000000000026 | 00000000000011010 | SCHED_BACK_AWAY_FROM_SAVE_POSITION SERVER | 0000000000000027 | 00000000000011011 | SCHED_TAKE_COVER_FROM_ENEMY SERVER | 0000000000000028 | 00000000000011100 | SCHED_TAKE_COVER_FROM_BEST_SOUND SERVER | 0000000000000029 | 00000000000011101 | SCHED_FLEE_FROM_BEST_SOUND SERVER | 0000000000000030 | 00000000000011110 | SCHED_TAKE_COVER_FROM_ORIGIN SERVER | 0000000000000031 | 00000000000011111 | SCHED_FAIL_TAKE_COVER SERVER | 0000000000000032 | 00000000000100000 | SCHED_RUN_FROM_ENEMY SERVER | 0000000000000033 | 00000000000100001 | SCHED_RUN_FROM_ENEMY_FALLBACK SERVER | 0000000000000034 | 00000000000100010 | SCHED_MOVE_TO_WEAPON_RANGE SERVER | 0000000000000035 | 00000000000100011 | SCHED_ESTABLISH_LINE_OF_FIRE SERVER | 0000000000000036 | 00000000000100100 | SCHED_ESTABLISH_LINE_OF_FIRE_FALLBACK SERVER | 0000000000000037 | 00000000000100101 | SCHED_PRE_FAIL_ESTABLISH_LINE_OF_FIRE SERVER | 0000000000000038 | 00000000000100110 | SCHED_FAIL_ESTABLISH_LINE_OF_FIRE SERVER | 0000000000000039 | 00000000000100111 | SCHED_SHOOT_ENEMY_COVER SERVER | 0000000000000040 | 00000000000101000 | SCHED_COWER SERVER | 0000000000000041 | 00000000000101001 | SCHED_MELEE_ATTACK1 SERVER | 0000000000000042 | 00000000000101010 | SCHED_MELEE_ATTACK2 SERVER | 0000000000000043 | 00000000000101011 | SCHED_RANGE_ATTACK1 SERVER | 0000000000000044 | 00000000000101100 | SCHED_RANGE_ATTACK2 SERVER | 0000000000000045 | 00000000000101101 | SCHED_SPECIAL_ATTACK1 SERVER | 0000000000000046 | 00000000000101110 | SCHED_SPECIAL_ATTACK2 SERVER | 0000000000000047 | 00000000000101111 | SCHED_STANDOFF SERVER | 0000000000000048 | 00000000000110000 | SCHED_ARM_WEAPON SERVER | 0000000000000049 | 00000000000110001 | SCHED_DISARM_WEAPON SERVER | 0000000000000050 | 00000000000110010 | SCHED_HIDE_AND_RELOAD SERVER | 0000000000000051 | 00000000000110011 | SCHED_RELOAD SERVER | 0000000000000052 | 00000000000110100 | SCHED_AMBUSH SERVER | 0000000000000053 | 00000000000110101 | SCHED_DIE SERVER | 0000000000000054 | 00000000000110110 | SCHED_DIE_RAGDOLL SERVER | 0000000000000055 | 00000000000110111 | SCHED_WAIT_FOR_SCRIPT SERVER | 0000000000000056 | 00000000000111000 | SCHED_AISCRIPT SERVER | 0000000000000057 | 00000000000111001 | SCHED_SCRIPTED_WALK SERVER | 0000000000000058 | 00000000000111010 | SCHED_SCRIPTED_RUN SERVER | 0000000000000059 | 00000000000111011 | SCHED_SCRIPTED_CUSTOM_MOVE SERVER | 0000000000000060 | 00000000000111100 | SCHED_SCRIPTED_WAIT SERVER | 0000000000000061 | 00000000000111101 | SCHED_SCRIPTED_FACE SERVER | 0000000000000062 | 00000000000111110 | SCHED_SCENE_GENERIC SERVER | 0000000000000063 | 00000000000111111 | SCHED_NEW_WEAPON SERVER | 0000000000000064 | 00000000001000000 | SCHED_NEW_WEAPON_CHEAT SERVER | 0000000000000065 | 00000000001000001 | SCHED_SWITCH_TO_PENDING_WEAPON SERVER | 0000000000000066 | 00000000001000010 | SCHED_GET_HEALTHKIT SERVER | 0000000000000067 | 00000000001000011 | SCHED_WAIT_FOR_SPEAK_FINISH SERVER | 0000000000000068 | 00000000001000100 | SCHED_MOVE_AWAY SERVER | 0000000000000069 | 00000000001000101 | SCHED_MOVE_AWAY_FAIL SERVER | 0000000000000070 | 00000000001000110 | SCHED_MOVE_AWAY_END SERVER | 0000000000000071 | 00000000001000111 | SCHED_FORCED_GO SERVER | 0000000000000072 | 00000000001001000 | SCHED_FORCED_GO_RUN SERVER | 0000000000000073 | 00000000001001001 | SCHED_NPC_FREEZE SERVER | 0000000000000074 | 00000000001001010 | SCHED_PATROL_WALK SERVER | 0000000000000075 | 00000000001001011 | SCHED_COMBAT_PATROL SERVER | 0000000000000076 | 00000000001001100 | SCHED_PATROL_RUN SERVER | 0000000000000077 | 00000000001001101 | SCHED_RUN_RANDOM SERVER | 0000000000000078 | 00000000001001110 | SCHED_FALL_TO_GROUND SERVER | 0000000000000079 | 00000000001001111 | SCHED_DROPSHIP_DUSTOFF SERVER | 0000000000000080 | 00000000001010000 | SCHED_FLINCH_PHYSICS SERVER | 0000000000000081 | 00000000001010001 | SCHED_FAIL SERVER | 0000000000000082 | 00000000001010010 | SCHED_FAIL_NOSTOP SERVER | 0000000000000083 | 00000000001010011 | SCHED_RUN_FROM_ENEMY_MOB SERVER | 0000000000000084 | 00000000001010100 | SCHED_DUCK_DODGE SERVER | 0000000000000085 | 00000000001010101 | SCHED_INTERACTION_MOVE_TO_PARTNER SERVER | 0000000000000086 | 00000000001010110 | SCHED_INTERACTION_WAIT_FOR_PARTNER SERVER | 0000000000000087 | 00000000001010111 | SCHED_SLEEP
Page Details
This page needs to be edited as it contains information that is unclear or incorrect. Improvement can be discussed on the talk page. Find more pages that need work here. Details: None given. |
This article is a stub. You can help the GMod Wiki by expanding it. |