Decide when an area counts as cleared so the story can move on
A story beat should start once the player has cleared the courtyard, but the guard who ran away, the enemies that keep respawning and the ambush that has not sprung yet all confuse the count. Here is how your AI defines cleared so the beat neither fires early nor never.
Why this works
Cleared is a promise that nothing is left that matters, not that nothing is alive right now. Defining it from the list of everything that belongs to the area, rather than from what is on screen, avoids the moment when the count is empty but the next wave has not arrived.
When not to use it
Skip it in an open world or endless defence game, where enemies keep coming and nothing is ever cleared. There use a timer, a score or a goal such as holding a place, and start the story beat from that instead.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- A diagram of every state
- 21 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 "Decide when an area counts as cleared so the story can move on" (read_entry cleared-area-flag-with-respawning-enemies) 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