AI controller||doc135329

September 20, 2022

AIControl

Introduction

The AI state machine is attached to the entity. After the AI is turned on, the entity can not be controlled by the player, but controlled by the AI. Each state will perform a specific behavior. Several states are added to the AI state machine. The state machine judges the current state according to the prescribed rules.


Function

void setAIData (stringkey, variantvalue)

Set up AI configuration

variant aiData (stringkey)

Get AI configuration

table getCurState ()

Get the current state of AI

void addCustomState (stringname, CreateParamsparams, funcenterEvaluatorFunc)

Add AI status

void delState (stringname)

Remove AI state

void setStatePriority (stringname, intprior)

Set AI state priority

void addSkill (paramsparams)

Add attack skills

void removeSkill (stringskillKey)

Remove attack skills based on skillKey

void removeSkillWithFullName (stringfullName)

Removed attack skills by pathname

void removeAllSkill ()

Clear the attack skill list

void setFollowTarget (Entityentity)

Set a target to follow

Entity getFollowTarget ()

Get the target to follow

Entity getMaxHatredEntity ()

Get the target with the highest hatred

void clearHatred (intobjID)

clear hatred

void addHatred (intobjID)

add hatred

float getMinSkillAttackDis ()

Get the shortest attack distance

bool canSeeEnemy (Entityentity)

Get whether the AI can see the entity

Entity getNearestEnemy ()

Get the target closest to the AI

Entity getEnemy ()

Get AI's current hate target

Vector3 randPosInHomeArea ()

Get random points within the territory

Vector3 randPosNearBy (floatmaxDis)

Get a random point within a distance

bool isInForceGoHomeState ()

Get whether the AI is in a forced home state