Better enemy AI
Opened this issue · 0 comments
its-danny commented
DNA
Each enemy is a mixed bag of the following:
- Terrestrial
- Only moves on land tiles
- Aquatic
- Only moves on water tiles
- Swimmer
- Can move onto water tiles, but will try not to drown
- Flying
- Can move on any tile
- Stealthy
- Prefers to stay out of sight of other entity's
- Hates
- A list of entity's this entity will target on sight
- Avoids
- A list of entity's this entity prefers to avoid
- Fear threshold
- Max fear before it will flee the situation
- Packs
- This entity prefers running in packs
- Solo
- This entity prefers being solo
- Aggression
- How aggressive they are,
float
from 0 to 1. When deciding to target, it's just aMathUtils.random() > aggressive
- How aggressive they are,
- Afraid of
- List of things that cause fear to rise in this entity
- Seeing other entity's die
- Almost dying
- Getting too close to an entity they prefer to avoid
- List of things that cause fear to rise in this entity
How does fear work?
Each enemy has a fear
value, a float
from 0 to 1.
Some of their actions are determined by both fear
and fearThreshold
. Fear lowers over time.
A simple example:
Jaguar has a fear threshold of 0.8, it's current fear is 0.2
It sees the player because it's fear is below its threshold
As it takes damage, the fear rises
Once fear is equal to or more than it's threshold, it flees
A more entertaining example
Jaguar has a fear threshold of 0.8, it's current fear is 0.2
It sees the player because it's fear is below its threshold
On its way toward the player, it sees another creature die
Its fear is now raised to 0.5
Status
- Terrestrial
- Aquatic
- Swimmer
- Flying
- Stealthy
- Hates
- Avoids
- Fear
- Fleeing
- Aggression
- Pack
- Solo