Control Living AI from Lua. Note: this is currently broken.
AIs within the Anarkis Gaming engine are finite state machines.
Every game update call, OnCycleStart is called if functions are bound to it to determine whether the Action set for the Living's current AIState, if any, should be called. In the game, Actions are generally interrupted by needs (e.g. combat).
Then, the Transition function for the current AIState, if any, is called (see AddTransition(AIState, Closure)). This is where you should check the environment and the result of the Action to determine whether you should switch states.
Finally, OnCycleEnd is called, if any functions are bound to it.
public class AI
Thetype exposes the following members.
Create a custom (flexible) AI component.
Create an AI component from one that exists in the game already.
Whether this is a custom (flexible) AI
Function to run when an AI cycle ends (after each update).
void OnCycleEnd( ai, Int32 gameTime)
Function to run when an AI cycle starts (before each update). Useful for interupting logic (i.e. when combat occurs). Return true here to skip this cycle.
Boolean (default false) OnCycleStart( ai, int gameTime)
This AI's AIState.
A function to call every update while this AI is in a certain AIState.
Check the environment and change AIStates if necessary
Attach this AI component to a Living.