ai:ForbidMoveDirection(dir)Parameter types:
dir: integer (required)
In a movement behaviour, add dir to the list of forbidden
directions, but don't select a specific movement.
ai:ForgetKnownMobs()Clears the AIs memory of any registered mobs, npcs or players
ai:ForgetKnownObjects()Clears the AIs memory of any registered objects
(not mobs/npcs or players)
ai:GetAttraction(obj)Parameter types:
obj: object (required)
Returns the obj's attraction value on the AI
Always returns 0 if obj is not known at all by the AI
ai:GetBehaviourlist()Returns a table representation of the behaviourlist (all
behaviours and their parameters)
To visualize the layout of the table you can try something like
print(DataStore.Serialize(ai:GetBehaviourlist()))
ai:GetFriendship(obj)Parameter types:
obj: object (required)
Returns the AI's friendship value towards obj
Always returns 0 if obj is not known at all by the AI
ai:GetKnownMobs()Returns an array with all mobs known by the AI
ai:GetKnownObjects()Returns an array with all objects known by the AI
ai:IsMoveDirectionAllowed(dir)Parameter types:
dir: integer (required)
In a movement behaviour, see if dir is in the list of forbidden
directions. It can have been added by an earlier behaviour or by
yourself.
ai:Knows(obj)Parameter types:
obj: object (required)
Returns true if the AI "knows about" obj, i.e. obj has been
observed and memorized by the AI.
ai:LastSeen(obj)Parameter types:
obj: object (required)
Returns information about when and where obj was last observed
by the AI.
Always returns nil if obj is not known at all by the AI
The following four values are returned:
- Time in seconds since last observation
- Map of last observation
- x coordinate on map
- y coordinate on map
ai:MoveRespondCoordinate(map, x, y)Parameter types:
map: map (required)
x: integer (required)
y: integer (required)
In a movement behaviour, set the reponse to the specified map
coordinate. The pathfinding system will then take over to find
the best way of getting there
ai:MoveRespondDirection(dir)Parameter types:
dir: integer (required)
In a movement behaviour, set the reponse direction to dir
ai:MoveRespondDirections(dir)Parameter types:
dir: integer (required)
In a movement behaviour, add dir as a reponse direction
(It is possible to add multiple possible directions, and then a
random one is chosen from the ones in the list).
ai:MoveRespondObject(obj)Parameter types:
obj: object (required)
In a movement behaviour, set the reponse to the specified object_t
The pathfinding system will then take over to find the best way
ai:Register(obj, friendship_change, attraction_change)Parameter types:
obj: object (required)
friendship_change: integer (optional)
attraction_change: integer (optional)
Add obj to the AI's memory and/or change the friendship and
attraction values for obj
ai:ReloadBehaviourlist()Recreates the AI from a new AI object in its mobs inventory
(if there's no such AI object, defaults are used as usual)
Version notes: Introduced in beta 4 pre3
ai:UsesDistanceAttack(obj)Parameter types:
obj: object (required)
Returns true if obj is known to make use of distance attacks
Always returns false if obj is not known at all by the AI