AI base state||doc135572

September 20, 2022


state state name Briefly priority open condition Conditions that need to be met to enter the state exit status condition
follow the target stateFollowEntity Always follow the target, if you can't keep up, you will be teleported 1 This entity is a pet of another entity 1. There is a target 2. When there is no attack target, it is far away from the target followEntityDistanceWhenNotTarget, and when there is an attack target, it is far away from the target followEntityDistanceWhenHasTarget After entering the state entity configuration followEntityFrequency or 20 frames
Return to the origin of the territory stateGoHome Leaving the territory, returning to a point within the territory 2 AI configuration check AI movement range -> limit movement range out of territory 1. Reach the target point 2. Or there is a hate target within the field of vision 3. When AI is configured with isAIGoHomePos, the default maximum is always 999 frames, and when not, the maximum is always 40 frames
attack target stateAttack attack target 3 AI configuration check Combat status -> attackable enemies -> add skills for attacking 1. There is an attack target within the chaseDistance range 2. There is a skill that can attack the target 1. Complete the release skill 2. If the skill configuration hurtStop is true, the entity is injured
chase the target stateChase chase the target 4 AI configuration check the combat status -> can attack the enemy 1. There is a chaseable aggro target within the chaseDistance range 2. Or when autoAttack is true, there is an attackable target within the chaseDistance range but cannot be attacked 1. After entering the state, after the chaseInterval time configured by ai or there is an attack target
random walk stateRandMove random walk 5 ai configuration -> patrol mode -> random patrol A certain probability is mutually exclusive with idleProb 10 frames after entering state
daze stateIdle daze 6 ai configuration -> patrol mode -> random patrol -> daze when patrolling Certain probability ai configure idleProb 0-1 After entering the state, wait for ai to configure a random number of frames within the idleTime range. Default {10,30}

The basic state can be added by checking the AI configuration by default. The editor will automatically add the fields used by the enabled basic state. For example: after the chase state is turned on, the chaseDistance field will be automatically added when the entity AI is turned on.

The basic state can be added or deleted in the code. When the basic state is added, there is a default entry state judgment function, and the custom enterEvaluatorFunc can not be passed in.

local control = entity:getAIControl()

local enterEvaluatorFunc = function()
    return true

--Delete state
--Add state
control:addCustomState("CHASE", {})