Scripted Encounters


Big milestone today: Riftwake now has scripted encounter sequences — interleaved dialogue and combat that play out like a cinematic scene during gameplay.

The Problem

The quest engine could handle dialogue and combat separately, but weaving them together was a nightmare. Four attempts at using React's useEffect hooks to trigger quest combat kept failing — React's rendering timing and state batching made reactive combat spawning unreliable. Combat would either never fire or fire at the wrong time.

The Solution

Threw out the reactive approach entirely. Combat now triggers imperatively during movement, using the same pattern that already worked for shift-day encounters. Two new async helpers — showDialogueAndWait and spawnCombatAndWait — let encounter sequences run top-to-bottom like a script. A Promise-based ref callback pattern makes dialogue and combat "awaitable" without any useEffect involvement.

First Scripted Sequence

The first use of the system is an ambush encounter during the prologue. The player is sent to investigate a disturbance. When they arrive:

  1. A radio warning crackles in — something is burrowing toward you
  2. An enemy surfaces — combat begins
  3. An NPC arrives to help and After victory, introduces themselves
  4. They hand over a vehicle — the player's second addition to their caravan

The whole sequence — narrative setup, combat, character introduction, vehicle bestow — flows without any manual intervention from the player beyond dismissing dialogue and fighting.

Technical Bits

  • sequenceRunningRef gates all other combat paths (map encounters, click handlers) while a scripted sequence is running — prevents race conditions
  • Defeat objectives now carry hex coordinates so they trigger at specific locations during movement
  • Movement pauses for all quest dialogue now, not just scripted encounters
  • Vehicle bestow checks quest rewards for a blueprint type with vehicle data

Leave a comment

Log in with itch.io to leave a comment.