-
Notifications
You must be signed in to change notification settings - Fork 2
Waypoint AI
Each WPTLevelEnemyNode has a WPTBrain reference that controls the enemy's behavior. This WPTBrain is made from a WPTBrainTemplate that is loaded from an entry in the brains.plist file.
The WPTBrain is a state machine that has one of 4 active states at a time. The 4 states are: nothingState, offenseState, defenseState, and fleeState. Only the nothingState is required, and there can be 0 or 1 of the other state types.
See the Brain State Diagram for more detail on how these states are transitioned. In general, the brains will shift states based on an enemy's distance to the player and the enemy's current health.
Each brain state needs to be a subclass of WPTBrainState, and set its appropriate WPTBrainStateType internally. Additionally, a case to the switch statement in WPTBrainStateFactory must be implemented for each brain state that is made.
- Nothing State
- This state is the default state and defines what an enemy will do when it doesn't really care about the player's position.
- Offense State
- Generally describes how the enemy will attack the player.
- Defense State
- When the enemy feels that it would be better to take a defensive stance, this will describe its behavior.
- Flee State
- When the enemy feels that it should flee for its safety, this will describe its behavior.
This is an array of brains with the following properties:
name: a uniquely identifying name.
brainStates:
- nothing: the name of the WPTBrainState subclass that defines the Nothing state. This is required.
- defense: the name of the WPTBrainState subclass that defines the Defense state. Optional.
- offense: the name of the WPTBrainState subclass that defines the Offense state. Optional.
- flee: the name of the WPTBrainState subclass that defines the Flee state. Optional.
In WPTConfig, setting the 'showBrainRadii' flag to true will render circles that represent the 4 cutoff distances around each enemy.
Info related to the various assets in the game
Info related to the player and enemies present in the game.
Info related to the structure of the scenes in the game.