Type NPC
NPC
Methods
| facePos( pos ) | Makes the NPC face the given position. |
| getActiveWeapon() | Returns the weapon the NPC is currently using, if any. |
| getBlockingEntity() | Returns the entity currently blocking the NPC. |
| getDisposition( target ) | Gets the disposition the NPC has towards the target. |
| getTarget() | Returns the NPC's current enemy target. |
| giveWeapon( class ) | Gives the NPC the given weapon, replacing their current weapon. |
| kill() | Kills the NPC. |
| meleeAttack() | Makes the NPC perform their melee attack once. |
| removeWeapons() | Removes all weapons from the NPC. |
| runTo( vec ) | Makes the NPC run to the given position. |
| setCurrentWeaponProficiency( proficiency ) | Sets the NPC's current weapon proficiency. |
| setRelationship( target, disposition, priority ) | Sets the NPC's relationship with the given target. |
| setTarget( target ) | Sets the NPC's enemy target. |
| shoot() | Makes the NPC shoot their weapon once. |
| stop() | Stops what the NPC is doing. |
| walkTo( vec ) | Makes the NPC walk to the given position. |
Methods
- NPC:facePos( pos )
-
Makes the NPC face the given position.
Environment:
ServerParameters:
-
pos: Position to face towards.
Return values:
-
(boolean)True if the NPC was rotated, false otherwise. -
(string)If the NPC was not rotated, the reason why.
-
- NPC:getActiveWeapon()
-
Returns the weapon the NPC is currently using, if any.
Environment:
Server - NPC:getBlockingEntity()
-
Returns the entity currently blocking the NPC.
Environment:
ServerReturn value:
(Entity | nil)The entity blocking the NPC from moving, if there is one. - NPC:getDisposition( target )
-
Gets the disposition the NPC has towards the target.
Environment:
ServerParameters:
-
target: The target entity.
Return values:
-
(number)The disposition the NPC has towards the target (one of the npc.D_* enum values.) -
(number)The priority associated with the disposition type.
-
- NPC:getTarget()
-
Returns the NPC's current enemy target.
Environment:
ServerReturn value:
(Entity | nil)The entity the NPC is currently targeting, or nil if they are not targeting anyone. - NPC:giveWeapon( class )
-
Gives the NPC the given weapon, replacing their current weapon. The class name must be valid (see npc.getUsableWeaponClassNames()) and the instance owner must have permission to spawn it.
Environment:
ServerParameters:
-
class: The class name of the weapon to give to the NPC.
Return values:
-
(boolean)True if the weapon was given, false otherwise. -
(string)If the weapon was not given, the reason why.
-
- NPC:kill()
-
Kills the NPC.
Environment:
Server - NPC:meleeAttack()
-
Makes the NPC perform their melee attack once.
Environment:
ServerReturn values:
-
(boolean)True if the NPC was set to melee attack, false otherwise. -
(string)If the NPC was not set to melee attack, the reason why.
-
- NPC:removeWeapons()
-
Removes all weapons from the NPC.
Environment:
ServerReturn values:
-
(boolean)True if the NPC's weapons were removed, false otherwise. -
(string)If the NPC's weapons could not be removed, the reason why.
-
- NPC:runTo( vec )
-
Makes the NPC run to the given position.
Environment:
ServerParameters:
-
vec: Position vector.
Return values:
-
(boolean)True if the NPC was set to run, false otherwise. -
(string)If the NPC was not set to run, the reason why.
-
- NPC:setCurrentWeaponProficiency( proficiency )
-
Sets the NPC's current weapon proficiency.
Environment:
ServerParameters:
-
proficiency: The proficiency level to set (one of npc.WEAPON_PROFICIENCY_*).
Return values:
-
(boolean)True if the proficiency was set. -
(string)If the proficiency was not set, the reason why.
-
- NPC:setRelationship( target, disposition, priority )
-
Sets the NPC's relationship with the given target.
Environment:
ServerParameters:
-
target: The target entity. -
disposition: One of the npc.D_* enum values. -
priority: Weighting, up to 99.
Return values:
-
(boolean)True if the relationship was set, false otherwise. -
(string)If the relationship was not set, the reason why.
-
- NPC:setTarget( target )
-
Sets the NPC's enemy target.
Environment:
ServerParameters:
-
target: The target entity.
Return values:
-
(boolean)True if the target was set, false otherwise. -
(string)If the target was not set, the reason why.
-
- NPC:shoot()
-
Makes the NPC shoot their weapon once.
Environment:
ServerReturn values:
-
(boolean)True if the NPC was set to fire, false otherwise. -
(string)If the NPC was not set to fire, the reason why.
-
- NPC:stop()
-
Stops what the NPC is doing.
Environment:
ServerReturn values:
-
(boolean)True if the NPC was stopped, false otherwise. -
(string)If the NPC was not stopped, the reason why.
-
- NPC:walkTo( vec )
-
Makes the NPC walk to the given position.
Environment:
ServerParameters:
-
vec: Position vector.
Return values:
-
(boolean)True if the NPC was set to walk, false otherwise. -
(string)If the NPC was not set to walk, the reason why.
-