scmJS docs

Cutscenes

trigscript/cutscene acts out a scene: the camera looks, pans, follows a unit and shakes, units walk to their marks, and a portrait speaks a line. A player can skip it.

import { Camera, walk, line, play, SECOND } from "trigscript/cutscene";

async function intro(raider: Unit) {
  const cam = new Camera(raider.x, raider.y);
  await line(units.JimRaynorMarine, "Something's moving out there.", 3 * SECOND);
  const there = start(walk(raider, 1200, 640));      // the walk goes on while the camera follows
  await cam.follow(raider, 2 * SECOND);
  await there;
  await cam.pan(1600, 400, 2 * SECOND);
  await cam.shake(12);
}

program(async () => {
  const raider = first(unitsAt(locations.Base, { owner: P1, type: units.TerranMarine }));
  if (!raider) return;
  const skipped = await play(P1, start(intro(raider)));   // Escape skips the rest of it
  if (skipped) print("Skipped.");
});

Everything here is something a trigger can do, done a frame at a time. The camera is Center View on a location the module keeps for itself, moved to where the camera should look. A walk is a Move order to another location. A line is the speaker's portrait talking and the words in the middle of the screen. Places are pixels (32 a tile) from the map's top left, and times are frames. The camera is that of the player the program runs as.

When a scene is skipped it stops where it was, so put things where it would have left them when play gives true.

Name What it does
new Camera(x, y) A camera, looking at (x, y) at once.
cam.look(x, y) Look at a point now.
cam.pan(x, y, time, ease?) Glide there over time frames; ease is "linear", "in", "out", "inOut" (the default) or "back".
cam.follow(unit, time) Keep a unit in the middle of the screen for time frames, or until it is gone.
cam.shake(time, size?) Shake for time frames, size pixels each way (8).
walk(unit, x, y, near?, limit?) Send a unit to a point and wait until it is within near pixels (48), gone, or limit frames (30 seconds) have passed. Gives whether it got there.
charge(unit, x, y, near?, limit?) The same with an Attack order: it fights what it meets.
walkAll(group, x, y, near?, limit?) A group together. Gives how many got there.
line(speaker, text, time?) The speaker's portrait talks and the words show for time frames (3 seconds).
play(player, scene, key?) Play a scene started as a task, until it ends or the player presses key (Escape). Gives whether it was skipped.