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:

Server

Parameters:

  • pos: Position to face towards.

Return values:

  1. (boolean) True if the NPC was rotated, false otherwise.
  2. (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:

Server

Return 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:

Server

Parameters:

  • target: The target entity.

Return values:

  1. (number) The disposition the NPC has towards the target (one of the npc.D_* enum values.)
  2. (number) The priority associated with the disposition type.
NPC:getTarget()
Returns the NPC's current enemy target.

Environment:

Server

Return 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:

Server

Parameters:

  • class: The class name of the weapon to give to the NPC.

Return values:

  1. (boolean) True if the weapon was given, false otherwise.
  2. (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:

Server

Return values:

  1. (boolean) True if the NPC was set to melee attack, false otherwise.
  2. (string) If the NPC was not set to melee attack, the reason why.
NPC:removeWeapons()
Removes all weapons from the NPC.

Environment:

Server

Return values:

  1. (boolean) True if the NPC's weapons were removed, false otherwise.
  2. (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:

Server

Parameters:

  • vec: Position vector.

Return values:

  1. (boolean) True if the NPC was set to run, false otherwise.
  2. (string) If the NPC was not set to run, the reason why.
NPC:setCurrentWeaponProficiency( proficiency )
Sets the NPC's current weapon proficiency.

Environment:

Server

Parameters:

  • proficiency: The proficiency level to set (one of npc.WEAPON_PROFICIENCY_*).

Return values:

  1. (boolean) True if the proficiency was set.
  2. (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:

Server

Parameters:

  • target: The target entity.
  • disposition: One of the npc.D_* enum values.
  • priority: Weighting, up to 99.

Return values:

  1. (boolean) True if the relationship was set, false otherwise.
  2. (string) If the relationship was not set, the reason why.
NPC:setTarget( target )
Sets the NPC's enemy target.

Environment:

Server

Parameters:

  • target: The target entity.

Return values:

  1. (boolean) True if the target was set, false otherwise.
  2. (string) If the target was not set, the reason why.
NPC:shoot()
Makes the NPC shoot their weapon once.

Environment:

Server

Return values:

  1. (boolean) True if the NPC was set to fire, false otherwise.
  2. (string) If the NPC was not set to fire, the reason why.
NPC:stop()
Stops what the NPC is doing.

Environment:

Server

Return values:

  1. (boolean) True if the NPC was stopped, false otherwise.
  2. (string) If the NPC was not stopped, the reason why.
NPC:walkTo( vec )
Makes the NPC walk to the given position.

Environment:

Server

Parameters:

  • vec: Position vector.

Return values:

  1. (boolean) True if the NPC was set to walk, false otherwise.
  2. (string) If the NPC was not set to walk, the reason why.

Valid XHTML 1.0!