Spielerando

Make an enemy run to cover without crossing the player's line of fire

The enemy picks the closest hiding spot and sprints across open ground to reach it, getting shot on the way. Here is how to rate a hiding spot by what the trip to it costs, and why the check for being seen has to work in both directions.

Why this works

The nearest hiding place is a trap, because the trip counts too. Rating every step by how much the player can see of it turns a short run across open ground into an expensive one, and a longer walk behind walls into a cheap one.

When not to use it

Don't use it for enemies that should charge, such as swarms or brutes, or when the player can't shoot back. Cover-seeking makes them look timid. Also skip it in open arenas with nothing to hide behind, where it finds no spot.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 3 common mistakes and the fix
  • 45 lines of example code with 4 checks that pass
  • How your AI shows you that it works

Say this to your AI

Use the Spielerando entry "Make an enemy run to cover without crossing the player's line of fire" (read_entry enemy-takes-cover-out-of-sight) in my game. Build it step by step, and show me how you checked that it works.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP