AI Combat

I implemented combat (for the player) and allowing AI to follow a path, but I can’t figure out the best way to implement combat for the AI. My game is meant to be a stealth shooter, so I want the AI to call in reinforcements when you are spotted and the game to get much harder, but to allow the player to hide and the AI will slowly return to their positions. The thing is that I can’t figure out how to have enemies:

  • Spot the player
  • Stop current “patrol” and chase after player
  • Call in reinforcements from a certain distance
  • Implement combat so that AI is smart (will use cover), but not unbeatable (no instant reload, aimbot, instant turn, etc…)

My code is at: https://github.com/novasharper/LocotusDesperatus

Why use TinySound when libgdx already there?

  1. use a raytrace between the enemy and the player. If the raytrace is unobstructed and the angle of the line is within the enemy’s field of view, the player is visible.
  2. Once the player is found, save the old path and position, and set a new path towards the player.
  3. Use the distance formula. If you’re within a certain distance, call a method on the other enemies to alert them to the player, so they can do #2
  4. I don’t know about cover, you might need to place some sort of “cover hint” entity. to avoid instant turn give each entity a turn speed which it will turn by until it hits the right angle.
    to avoid instant reload, use a countdown.

I still have tinysound included from when I was trying to make this as a Java2D game. I just haven’t removed it yet.