This is a list of all methods only available for NPCs. It is also possible to call Entity functions on NPCs.
NPC:AddEntityRelationship( Entity target, number disposition, number priority )
Makes the NPC like, hate, feel neutral towards, or fear the entity in question. If you want to setup relationship towards a certain entity class, use NPC:AddRelationship. NPCs do not see NextBots by default. This can be fixed by adding the FL_OBJECT flag to the NextBot.
NPC:AddRelationship( string relationstring )
Changes how an NPC feels towards another NPC. If you want to setup relationship towards a certain entity, use NPC:AddEntityRelationship.
Force an NPC to play his Alert sound.
Removes all of Capabilities the NPC has.
Clears the Enemy from the NPC's memory, effectively forgetting it until met again with either the NPC vision or with NPC:UpdateEnemyMemory.
Clears the NPC's current expression which can be set with NPC:SetExpression.
Clears the current NPC goal or target.
Stops the current schedule that the NPC is doing.
NPC:DropWeapon( Weapon weapon = nil, Vector target = nil, Vector velocity = nil )
Forces the NPC to drop the specified weapon.
Makes an NPC exit a scripted sequence, if one is playing.
Force an NPC to play his Fear sound.
Force an NPC to play its FoundEnemy sound.
Returns how proficient (skilled) an NPC is with its current weapon.
next update Gets the NPC's current waypoint position (where NPC is currently moving towards), if any is available.
Returns the entity that this NPC is trying to fight. This returns nil if the NPC has no enemy. You should use IsValid (which accounts for nil and NULL) on the return to verify validity of the enemy.
next update Gets the NPC's next waypoint position, where NPC will be moving after reaching current waypoint, if any is available.
Returns the amount of time it will take for the NPC to get to its Target Goal.
Returns the shooting position of the NPC. This only works properly when called on an NPC that can hold weapons, otherwise it will return the same value as Entity:GetPos.
Returns the NPC's current target set by NPC:SetTarget. This returns nil if the NPC has no target. You should use IsValid (which accounts for nil and NULL) on the return to verify validity of the target.
Force an NPC to play his Idle sound.
boolean NPC:IsCurrentSchedule( number schedule )
Returns whether or not the NPC is performing the given schedule.
Checks if the NPC is running an ai_goal. ( e.g. An npc_citizen NPC following the Player. )
boolean NPC:IsUnreachable( Entity testEntity )
Returns whether the entity given can be reached by this NPC.
Force an NPC to play his LostEnemy sound.
Tries to achieve our ideal animation state, playing any transition sequences that we need to play to get there.
Causes the NPC to temporarily forget the current enemy and switch on to a better one.
NPC:MoveOrder( Vector position )
Makes the NPC walk toward the given position. The NPC will return to the player after amount of time set by player_squad_autosummon_time ConVar. Only works on Citizens (npc_citizen) and is a part of the Half-Life 2 squad system. The NPC must be in the player's squad for this to work.
NPC:NavSetRandomGoal( number minPathLength, Vector dir )
Creates a random path of specified minimum length between a closest start node and random node in the specified direction.
NPC:NavSetWanderGoal( number xoffset, number yoffset )
Sets a goal in x, y offsets for the npc to wander to
number NPC:PlaySentence( string sentence, number delay, number volume )
Forces the NPC to play a sentence from scripts/sentences.txt
We advise against using this. It may be changed or removed in a future update. This function crashes the game no matter how it is used and will be removed in a future update. Use NPC:ClearEnemyMemory instead.
NPC:RunEngineTask( number taskID, number taskData )
Starts an engine task. Used internally by the ai_task.
Stops any sounds (speech) the NPC is currently palying. Equivalent to Entity:EmitSound( "AI_BaseNPC.SentenceStop" )
NPC:SetArrivalDistance( number dist )
Sets the distance to goal at which the NPC should stop moving and continue to other business such as doing the rest of their tasks in a schedule.
NPC:SetCurrentWeaponProficiency( number proficiency )
Sets the weapon proficiency of an NPC (how skilled an NPC is with its current weapon).
number NPC:SetExpression( string expression )
Sets the NPC's .vcd expression. Similar to Entity:PlayScene except the scene is looped until it's interrupted by default NPC behavior or NPC:ClearExpression.
Updates the NPC's hull and physics hull in order to match its model scale. Entity:SetModelScale seems to take care of this regardless.
NPC:SetLastPosition( Vector Position )
Sets the last registered or memorized position for an npc. When using scheduling, the NPC will focus on navigating to the last position via nodes. The navigation requires ground nodes to function properly, otherwise the NPC could only navigate in a small area. (https://developer.valvesoftware.com/wiki/Info_node)
NPC:SetMaxRouteRebuildTime( number time )
Sets how how long to try rebuilding path before failing task.
NPC:SetMovementSequence( number sequenceId )
Sets the sequence the NPC navigation path uses for speed calculation. Doesn't seem to have any visible effect on NPC movement.
NPC:StartEngineTask( number task, number taskData )
Forces the NPC to start an engine task, this has different results for every NPC.
Resets the NPC's movement animation and velocity. Does not actually stop the NPC from moving.
NPC:TargetOrder( Entity target )
Cancels NPC:MoveOrder basically. Only works on Citizens (npc_citizen) and is a part of the Half-Life 2 squad system. The NPC must be in the player's squad for this to work.
Marks the current NPC task as completed. This is meant to be used alongside NPC:TaskFail to complete or fail custom Lua defined tasks. (Schedule:AddTask)
NPC:TaskFail( string task )
Marks the current NPC task as failed. This is meant to be used alongside NPC:TaskComplete to complete or fail custom Lua defined tasks. (Schedule:AddTask)
NPC:UpdateEnemyMemory( Entity enemy, Vector pos )
Force the NPC to update information on the supplied enemy, as if it had line of sight to it.
Undoes the other Use*Behavior functions. Only usable on "ai" base entities.