Combat AI Code Example

COMBAT AI CODE EXAMPLE

The purpose of this CE is to show some simple, yet fun branching combat AI, and player combat system – created in around 15 hours.

Several features are explored, yet this CE is purely based on Combat AI, with simplistic camera, animations, and character implementations merely allowing for assessment of the combat AI.

A debug widget is available to show most of the “brain” functions happening during gameplay.

PLAYER FEATURES

• Player can use input buffer for combos
• Some attacks (those at the end of combos) do not accept further input buffer
• Most attacks can be evade cancelled, except those at the end of combos
• Attacks at end of combos are indefensible
•Player will orient itself towards the closest aggressive enemy, allowing for relative to player avatar input
•Player can block or evade enemy attack
• A successful block will leave enemy on a staggered state and trigger bullet time for fun visuals and “feel”
•Player can evade backwards, laterally or forward when close to enemy to gain advantage. Lateral evasions from close up will rotate around the enemy to gain advantage towards its back
•Player can evade in any direction when not close to enemy, and it will stop upon proximity to a new close enemy
•Player can cancel an evade into some attacks during the last part of the evasion animation to allow for very fluid combo possibilities

ENEMY FEATURES

• Enemies will attack player based on who is closer, with the other enemies
leaving space for the fight, based on a circular EQS
• Enemies will try to get Player into a 3-hit combo, but will stop current combo if Player defends / evades and decide which next action to take
• Enemies will always end their completed combos with an indefensible attack which will stun player if hit, but which does not track player movement. Most attacks will track rotation so at to not make the enemies look “too dumb/easy”
• Can defend, based on how many times they’ve seen an attack / combo. Enemies remember which attacks they’ve seen lately, which sets a chance to defend. The more the player uses the same attacks, the higher chance of enemy defending.
• Enemies can block, evade, or both in succession. At the moment this choice is weight based, but it could easily be context based.
• A successful block will leave Player on a staggered state
• Enemies are not able to defend when hit form behind their backs
• Enemies will try to counter attack after a successful defense. The timing is left intentionally loose so players have 1 chance to evade quickly, or else be punished
• Enemies will taunt player if he is hit by and indefensible attack or counter attack
•Enemy attack tells are created with time dilation, as I did not have animations with correct tells

Combat AI