Saturday 16 February 2013

AI Breakdown - Part 2

Not only does the AI have alternate states, there is also a python module called AIFunctions, which holds a variety of external functions. Most are small functions such as aligning the AI to a vector, searching for visible nodes. However some are needed to make sense of the AI code.

def Attacking():
The attacking function simply aligns the AI to the player, and fires it's weapon, in other words attacking the player.
States - detailed

The constant state, is just that, it runs constantly. The actions associated with it run all the functions that the AI requires to operate.
The death action:
 if Ai["Ai_health"] < 1:
     Ai.state = 17
(Notably this is the only action in constant which changes the AI's state, because constant runs at all times, it will always override any actions that change the AI's state, from other states below it.)
The Cycle action:
This relates to activating AI's, the actual function to activate the AI is run on the entire scene(AI independent), this function merely updates the AI when it does become active.
The cycle function's main purpose is to update the AI's awareness of it's surroundings, it checks the following two points.
  • can it see the player.
  • is it defending.
The Aggro action:
This simply switches the player from it's initial Idle state to an aggressive state if it realises the player is near.
The Idle state is not often used, it is more of a transition state.
If the AI  is aware of the player the idle state defines whether the AI should attack the player, of whether it should defend the point it is at.
It also allows the AI to move to key points on the map, whereupon they will be set to the defence state.
The Turtle state is how the AI deals with close proximity to the player, or when the AI needs to react aggressively at a certain point. 
The AI is able to quickly dart from side to side, there is two triggers for this to happen.  
The Shuffle action:
  • A random value (two values trigger this, one to shift left, one to shift right).
  • If the player hits the AI it will shuttle (or die).
The AI is also able to attack the player whilst in this state, this is handle by the AIFunctions module.
The Attack action:
  • The Turtle action uses the Attack Function from the AIFunctions file.
The attack state is more focused on getting the AI into a position to attack the player, rather than the attacking itself.
The Follow action:
The attack action runs simultaneously with the follow action so the AI can attack the player whilst moving. Bone constraints are used to maintain orientation and aim towards the player.
 The Turtle action:
 Whilst in this state the AI can trigger the turtle state, this happens when the player gets too close to the AI.
 The Attack action: 
The follow action uses the path-finding functions defined in the AIFunctions file, it causes the AI to pursue the player.
  • The Attack State calls the Turtle state when the player gets too close, (see above).
  • The Turtle action uses the Attack Function from the AIFunctions file.
The defend state is nearly identical to the attack state, The only difference being how the AI deals with attacking the player.
  • The AI will pursue the player within a certain radius of the node it  is defending (see post 1 for nodes).
  • If the player exits the radius then the AI will move back towards the node.

Exactly what it says, this state deals with cleaning up the AI when it dies.

No comments:

Post a Comment