Snayff / nqp4

GNU General Public License v3.0
0 stars 0 forks source link

Combat AI & Pathfinding #3

Open Snayff opened 2 months ago

Snayff commented 2 months ago

Summary

A set of defined behaviours that enable Actors to act out combat in the desired way. Behaviours are broad enough to create dynamic interactions. Unit AI should enable a group of Actors to act in a unified way, Actor AI should allow Actors to work independently.

Definitions

Actor - a single entity that can act independently in combat. Unit - a cohesive, linked group of Actors. CombatActive - an ability or skill that causes effects on use. Behaviour - a set of conditions that determine how an Actor will act (or behave). Blob / Blobbing - moving to attack enemy actors, but not moving any distance to get into range, so they "blob" together. Dangerous Terrain - a tile identified as being dangerous to the actor e.g. lava.

High Level Requirements

Minimum

Unit AI

  1. A Unit can target another Unit;
  2. When a Unit is targeting another Unit;
    1. Actors in the Unit ignore their own targeting.
    2. Actors in the Unit attempt to move towards the target Unit in formation.
    3. Actors in the Unit attempt to attack Actors in the target Unit.
  3. A Unit can be instructed to move to a target position.
  4. When a Unit is moving to a target position;
    1. Actors in the Unit ignore their own targeting.
    2. Actors in the Unit attempt to move towards the target position.
  5. A Unit targeting another Unit or moving to a target position will only do so for a period of time, before reverting to normal.
  6. When a Unit is moving together (i.e. as a cohesive Unit), it will move in formation;
    1. An organised formation, where Actors are in lines.
    2. A disorganised formation, where Actors are in a clump/loose grouping.

Actor AI

  1. Actors can act independently of their Unit;
    1. Actors can identify their own targets, as determined by their target preferences.
    2. Actors will move towards their identified target, until they are in range to use their CombatActives.
    3. An Actor will try to stay close to the Actors in their Unit, meaning they Blob together when trying to get to the enemy.
    4. Actors can use their CombatActives;
      1. If the CombatActive is off cooldown.
      2. If the CombatActive is in range of the target.
      3. If the Actor has unblocked line of sight of the target.
  2. Actors avoid colliding or existing in the same space as other physical bodies, such as Actors or obstacles.

Player

  1. A Unit can be identified as being the Player and is entirely manually controlled.
  2. A Unit controlled by the Player can only ever contain a single Actor.

Desired

  1. A Unit can have defined Behaviours based on the Unit type;
    1. Infantry - move as close to the target as possible and stay there.
    2. Ranged - stay as close to the maximum range of the smallest-range CombatActive from the target.
    3. Hit and Run (aka cavalry) - move as close to the possible to the target when CombatActives are off cooldown (i.e. ready) and as far away from the enemy otherwise.
  2. A Unit can have a defined Behaviour set by circumstances;
    1. Flee - move as far away from the enemy as possible.
  3. Actors in a Unit can synchronise their use of a given CombatActive.
  4. A Units target, whether position or enemy Unit can be indicated.

    Ideal

  5. Actors will always try to avoid Dangerous Terrain;
    1. The "force" of this avoidance;
      1. is configurable, such that some Actors are more or less likely to avoid Dangerous Terrain than others.
      2. considers the "threat" to the Actor. (We dont want an Actor immune to fire damage running around fire)
    2. Actors are not guaranteed to avoid Dangerous Terrain. The avoidance is a steer, not an override.

      Technical Considerations

  6. Actors can be different sizes.
  7. For performance, do we need to support pathfinding with Quadtree and/or FlowField methods?

    Outstanding Questions

  8. For the Disorganised formation, should we use a Flocking behaviour? Link: https://howtorts.github.io/2014/01/03/steering-flocking.html

    Examples

    Images / Gifs

    Moving in formation - Warhammer Total War firefox_nLOHb7f86W firefox_SxLHk5sw7d

Leaving formation / deferring to Actor AI - Warhammer Total War firefox_W27AKgMW0U

"Blobbing" - Hero's Hour firefox_W4Y2rra9Zn

Reading

Article on moving in formation - https://github.com/libgdx/gdx-ai/wiki/Formation-Motion Efficient AI updating - https://youtu.be/Te2Nu7QmZDI?si=YCjQ-ozf5Z8pnt1n Godot moving in formation - https://youtu.be/y4yzgBWivNk?si=6GQGjQtVsK-L8ED1 Pathfinding physics tweaks - https://www.youtube.com/watch?v=NRmz5Bfrn4c&list=PLUpZYfr0B25kliLbLmz9NnYKkFeHOEOpZ&index=201 Godot formations: https://youtu.be/X07_J4C3lso?si=mhhr3EzZUpDUqg53