🧍NPC

AddBehavior

Add a behavior

(method) NACT_NPC:AddBehavior(cBehaviorClass: Class, tMaybeBehaviorConfig: BehaviorConfigTable)

Parameters

Name
Type
Description

cBehaviorClass

Class

Class of the behavior to add in the list

tMaybeBehaviorConfig

BehaviorConfigTable

(optional) The config of the behavior

CleanupCharacter

Clean-ups a character if it is currently focused by this NPC (death of disconnect for example)

(method) NACT_NPC:CleanupCharacter(cToCleanUp: Character)

Parameters

Name
Type
Description

cToCleanUp

Character

the character to cleanup if necessary

Constructor

INTERNAL NACT_NPC constructor. You should call NACT.RegisterNPC instead of this function directly

(method) NACT_NPC:Constructor(cNpcToHandle: Character, sTerritoryName: string, tNpcConfig: table)

Parameters

Name
Type
Description

cNpcToHandle

Character

Nanos world character to be controlled

sTerritoryName

string

Territory to tie this NPC

tNpcConfig

table

To be defined, quite unused for now

Debug_PrintTriggerStates

INTERNAL. This will flood

(method) NACT_NPC:Debug_PrintTriggerStates()

Parameters

Destructor

undefined

(method) NACT_NPC:Destructor()

Parameters

Error

undefined

(method) NACT_NPC:Error(sMessage: any)

Parameters

Name
Type
Description

sMessage

any

GetAlliesInZone

Get the number of allies in the given trigger of the NPC

(method) NACT_NPC:GetAlliesInZone(sTriggerName: string)
  -> Array: table

Returns

table Sequential array of characters in the zone

Parameters

Name
Type
Description

sTriggerName

string

detection

GetDistanceToFocused

Distance to the focused entity

(method) NACT_NPC:GetDistanceToFocused()
  -> number

Returns

number Distance to the focused entity. 0 if the entity was not found

Parameters

GetEnemiesInZone

Get the number of enemies in the given trigger of the NPC

(method) NACT_NPC:GetEnemiesInZone(sTriggerName: string)
  -> Array: table

Returns

table Characters array of enemies in the trigger

Parameters

Name
Type
Description

sTriggerName

string

detection

GetFocused

Get the currently focused character if the NPC has one

(method) NACT_NPC:GetFocused()
  -> Character|nil

Returns

Character|nil undefined

Parameters

GetFocusedLocation

Returns the focused location. This will return nothing if the focused entity becomes out of sight

(method) NACT_NPC:GetFocusedLocation()
  -> Focused: Vector

Returns

Vector |nil @Location of the focused entity if found, nil ortherwise

Parameters

GetFromCharacter

Gets the NACT_NPC instance tied to this character Will return nil if this Character is not controlled by NACT

function NACT_NPC.GetFromCharacter(character: Character)
  -> NACT_NPC: NACT_NPC|nil

Returns

NACT_NPC|nil that is controlled by NACT or nil

Parameters

Name
Type
Description

character

Character

the nanos world character

GetTriggerPopulation

Gets the entities that populates a trigger, enemies or allies. Given they are valid and alive

sPopulationType:
    | "allies"
    | "enemies"
(method) NACT_NPC:GetTriggerPopulation(sTriggerName: any, sPopulationType: "allies"|"enemies")
  -> Characters: table

Returns

table array of population in the trigger

Parameters

Name
Type
Description

sTriggerName

any

sPopulationType

"allies"

"enemies"

GetWeapon

Firearm NPC functions, in the future it should be done by extending the NACT_NPC base class

(method) NACT_NPC:GetWeapon()

Parameters

GoNextBehavior

Goes to the next behavior if there is one

(method) NACT_NPC:GoNextBehavior()

Parameters

GoPreviousBehavior

Goes to the next previous if there is one

(method) NACT_NPC:GoPreviousBehavior()

Parameters

IsFocusedVisible

Returns if the focused entity is currently visible. Meaning if it is hit by the vision system and is in the vision angle of the NPC.

(method) NACT_NPC:IsFocusedVisible()
  -> boolean

Returns

boolean Is the focused entity is currently visible.

Parameters

IsInVisionAngle

Checks if the character in parameter is in the vision angle of the NPC This function is not enough to check if the entity is really visible. You must use vision traces for that

(method) NACT_NPC:IsInVisionAngle(cEntity: Character)
  -> boolean

Returns

boolean If the character is in vision angle.

Parameters

Name
Type
Description

cEntity

Character

The character to check for vision range

Log

undefined

(method) NACT_NPC:Log(sMessage: any)

Parameters

Name
Type
Description

sMessage

any

LookForFocused

This function attemps to change focused entity. If there is an enemy in the detection trigger of the NACT_NPC and there the enemy is in the vision range of the player. You can call this function like there is no tommorrow, it is throttled and will NOT trigger each time it is called

(method) NACT_NPC:LookForFocused()

Parameters

MoveTo

MoveTo without looking to point. Falls back to SetLocation if there is no network authority

(method) NACT_NPC:MoveTo(vPoint: Vector)

Parameters

Name
Type
Description

vPoint

Vector

Point to go

MoveToFocused

Will make the NPC move to the location of the focused character or it's last known position

(method) NACT_NPC:MoveToFocused()

Parameters

MoveToPoint

Move but also look towards point

(method) NACT_NPC:MoveToPoint(vPoint: Vector, nAcceptanceRadius: Number)

Parameters

Name
Type
Description

vPoint

Vector

Point to go

nAcceptanceRadius

Number

Acce

RandomPointToFocusedQuery

Query the player that has the network authority on the territory for a random point to the focused location or it's last known position

The querying is async. Reply will be passed in a OnRandomPointResult callback in your behavior if it is defined, as such:

My_Behavior:OnRandomPointResult(vTargetPoint)
(method) NACT_NPC:RandomPointToFocusedQuery(radius: number)

Parameters

Name
Type
Description

radius

number

Radius for the search to the random point

RandomPointToQuery

Query the player that has the network authority on the territory for a random point in the range of the poinst

(method) NACT_NPC:RandomPointToQuery(vLocation: Vector, radius: number)

Parameters

Name
Type
Description

vLocation

Vector

Point at the center of the random point query

radius

number

Radius for the search

RegisterEvent

Registers an event on this NPC and delegates it on the behavior via the "On" callback

(method) NACT_NPC:RegisterEvent(cNpcToHandle: NACT_NPC, sRegisteredEvent: string)

Parameters

Name
Type
Description

cNpcToHandle

NACT_NPC

to delegate the event to

sRegisteredEvent

string

event name to be delegated

Reload

Makes the NPC reload its weapon If the NPC has no weapon it will be a no op

(method) NACT_NPC:Reload()

Parameters

SetBehavior

Sets the behavior by the class

(method) NACT_NPC:SetBehavior(cBehaviorClass: Class)

Parameters

Name
Type
Description

cBehaviorClass

Class

Class of the behavior to set (eg: NACT_Detection, NACT_Combat)

SetBehaviorConfig

Set behavior config. Currently, this will not change the config if the behavior is running, but only on the next time it is spawned, this a limitation for now

(method) NACT_NPC:SetBehaviorConfig(cBehaviorClass: Class, tBehaviorConfigTable: BehaviorConfigTable)

Parameters

Name
Type
Description

cBehaviorClass

Class

Class of the behavior to change the configuration

tBehaviorConfigTable

BehaviorConfigTable

The behavior config to be set

SetBehaviorIndex

Jumps to the behavior at the specified index

(method) NACT_NPC:SetBehaviorIndex(iBehaviorIndex: number)

Parameters

Name
Type
Description

iBehaviorIndex

number

Index of the behavior to switch to

SetBehaviorValue

Set a behavior config value instead of replacing the whole config. This currently has the same limitations as the SetBehaviorConfig function

(method) NACT_NPC:SetBehaviorValue(cBehaviorClass: Class, sBehaviorKey: string, aBehaviorConfigValue: any)

Parameters

Name
Type
Description

cBehaviorClass

Class

Class of the behavior to change the configuration

sBehaviorKey

string

the config key to change (example: minCoverDistance)

aBehaviorConfigValue

any

the value to set (example: 350)

SetFocused

Sets the character the NPC will focus

(method) NACT_NPC:SetFocused(newFocused: Character)

Parameters

Name
Type
Description

newFocused

Character

the character to focus

SetFocusedEntity

Sets the currently focused charcter by the NPC

(method) NACT_NPC:SetFocusedEntity(cEntity: Character|nil)

Parameters

Name
Type
Description

cEntity

Character

nil

ShouldReload

Checks if the NPC has no more ammo left to fire

(method) NACT_NPC:ShouldReload()
  -> If: boolean

Returns

boolean the npc should reload

Parameters

StartTracing

Starts tracing for the vision logic. If no entity is focused tracing will stat when one is

You don't have to handle it manually if autoTracing is set to true (default) in the NPC config

(method) NACT_NPC:StartTracing()

Parameters

StopTracing

Stop the tracing for the vision logic.

You don't have to handle it manually if autoTracing is set to true (default) in the NPC config

(method) NACT_NPC:StopTracing()

Parameters

TurnTo

Makes the NPC turn towards a location

(method) NACT_NPC:TurnTo(vLocation: Vector, nInaccuracyFactor: number)

Parameters

Name
Type
Description

vLocation

Vector

Location to turn towards

nInaccuracyFactor

number

Innacuracy factor fo turn to

TurnToFocused

Turns the NPC towards the focused entity. Remember to specify an innacuracyFactor if you intend to shoot right after, or your NPC will quickly kill opponents.

(method) NACT_NPC:TurnToFocused(nInaccuracyFactor: number)

Parameters

Name
Type
Description

nInaccuracyFactor

number

Innacuracy to apply to the NPC when shooting

_registerTriggerBoxes

INTERNAL. Register the trigger boxes for a NACT_NPC I mean you can use if you want, but, why ?

(method) NACT_NPC:_registerTriggerBoxes(tNpcTriggerConfig: any)

Parameters

Name
Type
Description

tNpcTriggerConfig

any

createTriggerBox

INTERNAL. Creates a typical trigger box attached to a NACT Entity

(method) NACT_NPC:createTriggerBox(eTriggerType: TriggerType, nRadius: number, eDebugColor: Color, checkEvery: any)
  -> Created: table

Returns

table trigger box

Parameters

Name
Type
Description

eTriggerType

TriggerType

nRadius

number

Radius of the sphere

eDebugColor

Color

Debug color when NACT_DEBUG_TRIGGERS is true

checkEvery

any

Last updated