Enemy - kawabart/Wodnik GitHub Wiki

Overview

Enemies need advanced AI that supports states for both combat and stealth. They patrol map, search for player, chase and attack when noticed, communicate by allerting nearby agents and check player's last known position. Enemy states should be telegraphed and easily readable by the player. Their actions should be consistent enough so that player can sometimes exploit their behaviour. Enemies can also be stunned or thrown to the ground, which makes them easy target for the player.

Enemy types

At least two basic enemy types - weak peasant and armed guard. Both armed with long piercing weapons, like forks/spear. Armed enemies should be much harder to take down, blocking attacks etc.

Peasant

Weakest enemy, can be taken down easily.

Knight

Larger HP, can block some of our attacks.

Archer

As weak as peasant, but has ranged attacks.

Lantern

Has no weapon, just the torch in hands. Can't attack player. Usually follows other enemies, casting light around. Flees and alerts others upon contact with player. When killed, he drops the torch, and it casts light until is destroyed (player can use it like any other weapon - throw it at enemy or drown in water).

Other types and questions

shield: should enemy carry only shield, or shield and another weapon simoultanously?

ranged attacks: should everyone have it? Like guards in ac

Visuals and implementation

Enemies are viewed from top down.

Their animations change based on if they're agitated or not. Their hand animation changes based on whatever weapon/tool theyre holding.

Enemy Attack

Basic enemy attack is just this piercing motion - with windup lasting less then half a second. Range is about 1 in game units. Game draws a capsule for 1 frame during attack, connecting 2 points on a weapon - for example handle and the tip of the blade, so the range can vary between weapons.

Enemy AI

Aggro states:

Relaxed:

Performs basic tasks like Idle or Patrol.

Suspicious:

When hears or sees something suspicious, performs states like Investigate, or looks around. Stuff like suspicious sounds increase aggro. While not investigating, aggro slowly falls.

Agitated:

Enemy chases and attacks player, tries to get weapon or flees. If player is out of sight, checks last known position and searches around.

Enemy states:

Idle

Plays idle animation.

Patrol

Goes to designated point. While at point, changes to idle for x seconds, and then patrol again.

Investigate

Goes to the investigated location and looks around. When sees or hears something suspicious. When reaches destination, looks around.

Visual: ? over head

Look around

Character stands in place and looks around (to sides). Lasts about 5-10 s, then back to idle.

Shocked

When enemy notices player and is totally unprepared for that. For example, if player hasnt been seen by anyone for around 30 seconds etc. Enemy is confused for about 1-2 seconds. This gives player a small grace period if they tried to remain hidden. Enemy is still vulnerable in this state. Kind of similar to meme sound from MGS.

Visual: !? over head

Search

Choses random point next to investigated location and quickly investigates it. Reapeats a few times. Is usually called while line of sight to player is lost.

Chase

Follows player quickly if player is out of range.

Visual: ! over head

Blocking

Enemy waits for their turn to attack, composed. Frontal attacks wont hurt them.

Windup

When all requirements to perform an attack are met. Enemy starts playing windup animation.

Attack

State that lasts one frame, when enemy casts damage.

Recovery

After attack. Optional, time to get back to basic states after attack. For some enemies can be 0.

Get weapon

If an enemy is unarmed, fleeing, and theres a weapon lying on the ground close by.

Flee

Runs away from player, if distanced enough looks in the direction of player. If sees player, is unarmed, and dont see weapons around.

Staggered/Stunned

Enemy stands, but is vulnerable to being grabbed or pushed. Lests 5 seconds.

Visual: stars over head

Downed

Enemy lies on the ground, vulnerable. Wakes up and gets up after 10 seconds.

Getting up

After enemy was downed. Lasts about 1s. Enemy is still vulnerable in this state.

Killed

No ai behaviour, just basic entity mechanics, like the ability to be pushed, grabbed, destroyed etc.

Vulnerability

Players need to get creative to get a satisfying devouring kill or to grab an enemy. Thats why enemies can be grabbed or devoured only if at least one of the above is true:

  • enemy has no weapon
  • enemy is stunned
  • enemy is lying on the ground
  • player is behind enemy
  • enemy doesnt know where player is
  • enemy isn't in any of the alerted states