AI incident||doc135576

September 20, 2022


 AIControl:handleEvent(name, ...)
  • The class to which the function belongs:AIControl


Trigger an AI event, received by the current state.


event name Briefly Parameters
Specific case any number of parameters
MOVEMEETCOLLISION encounter obstacles $params1: whether it is a block, $params2: block coordinates, $params3: objID of the entity, $obj1: ai itself
MOVEMEETCLIFF encounter a cliff $ obj1: ai real
ARRIVEDTARGETPOS reach the target point $ obj1: ai real
ONHURT ai is attacked $ obj1: ai real
ENTERAISTATUSGOHOME ai triggers to enter the state of returning to the territory $ obj1: ai real

The above event will be called automatically, and the custom event needs to be called by yourself

Add the onEvent function to the script code of the current state

function AIStateDance:onEvent(event, ...)
    print(self.control, "onEvent", event)

Code Samples

local control = entity:getAIControl()