Spielerando

Change the light when dusk arrives during a long fight

Fights take game time, and in a survival game the sun keeps moving while you swing. Lights, visibility and monster behaviour should change at the right moment, even when a long rest jumps over several days. This entry explains how to catch every crossing exactly once.

Why this works

Time can jump, and events do not care whether you were watching. Counting time as one ever-growing total and asking which marks lie between the old and the new moment catches every crossing once, however far the jump, which a look at the hour of day cannot.

When not to use it

Skip it in games where the time of day never changes, or is set by the story, such as a game with fixed scenes. Also skip it when light changes smoothly with no events attached: just compute the light from the clock each time.

In the full entry

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

Say this to your AI

Use the Spielerando entry "Change the light when dusk arrives during a long fight" (read_entry night-falls-in-the-middle-of-a-fight) 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