@team-antioch/sc2-adjutant 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/data/blizzard-baseline.json +3061 -0
- package/data/button-hotkeys.json +5722 -0
- package/data/game-assets.json +50909 -0
- package/data/package-entries.json +32361 -2
- package/dist/capture/bank-fixtures.d.ts +13 -0
- package/dist/capture/bank-fixtures.js +35 -0
- package/dist/capture/bank-snapshots.d.ts +95 -0
- package/dist/capture/bank-snapshots.js +302 -0
- package/dist/capture/editor-broker-client.d.ts +27 -4
- package/dist/capture/editor-broker-client.js +3 -3
- package/dist/capture/editor-broker.js +154 -9
- package/dist/capture/effect-tour.d.ts +113 -0
- package/dist/capture/effect-tour.js +283 -0
- package/dist/capture/effect-video.d.ts +74 -0
- package/dist/capture/effect-video.js +173 -0
- package/dist/capture/exemplar-capture.d.ts +4 -0
- package/dist/capture/exemplar-capture.js +4 -1
- package/dist/capture/shots.d.ts +6 -1
- package/dist/capture/shots.js +1 -1
- package/dist/capture/stop-tour.d.ts +3 -1
- package/dist/capture/stop-tour.js +1 -1
- package/dist/capture/style-pack-captures.d.ts +67 -0
- package/dist/capture/style-pack-captures.js +172 -0
- package/dist/catalog/stock-catalog.d.ts +8 -0
- package/dist/catalog/stock-catalog.js +13 -0
- package/dist/cli/capture-exemplars.js +18 -32
- package/dist/cli/effect-tour.d.ts +2 -0
- package/dist/cli/effect-tour.js +378 -0
- package/dist/cli/make-frames.d.ts +1 -0
- package/dist/cli/make-frames.js +21 -0
- package/dist/cli/sound-mix.d.ts +1 -0
- package/dist/cli/sound-mix.js +75 -0
- package/dist/cli/study.js +6 -26
- package/dist/domain/blueprint-trigger.d.ts +355 -3
- package/dist/domain/blueprint-trigger.js +149 -8
- package/dist/domain/library-interface.d.ts +50 -29
- package/dist/domain/library-interface.js +54 -41
- package/dist/domain/mission-blueprint.d.ts +13 -6
- package/dist/domain/mission-blueprint.js +6 -0
- package/dist/domain/mod-blueprint.d.ts +4 -4
- package/dist/host/game-logs.d.ts +63 -0
- package/dist/host/game-logs.js +178 -0
- package/dist/host/game-ownership.d.ts +37 -0
- package/dist/host/game-ownership.js +84 -0
- package/dist/host/game-run-report.d.ts +63 -0
- package/dist/host/game-run-report.js +119 -0
- package/dist/host/known-errors.d.ts +34 -0
- package/dist/host/known-errors.js +73 -0
- package/dist/init/init-workspace.d.ts +3 -1
- package/dist/init/init-workspace.js +10 -1
- package/dist/map/convert-mission-triggers.d.ts +115 -7
- package/dist/map/convert-mission-triggers.js +527 -47
- package/dist/map/editor-changes.d.ts +1 -1
- package/dist/map/editor-form.d.ts +5 -0
- package/dist/map/editor-form.js +72 -0
- package/dist/map/game-packages.d.ts +3 -2
- package/dist/map/game-packages.js +5 -2
- package/dist/map/kept-references.js +47 -1
- package/dist/map/kept-session.js +3 -1
- package/dist/map/outline-diff.d.ts +24 -0
- package/dist/map/outline-diff.js +95 -0
- package/dist/map/outline-trigger.d.ts +7 -0
- package/dist/map/outline-trigger.js +29 -20
- package/dist/map/ownership-plan.d.ts +6 -2
- package/dist/map/ownership-plan.js +1 -1
- package/dist/map/package-output.js +13 -8
- package/dist/map/tune-kept-triggers.d.ts +7 -0
- package/dist/map/tune-kept-triggers.js +33 -6
- package/dist/map/write-blueprint-trigger.d.ts +9 -4
- package/dist/map/write-blueprint-trigger.js +46 -13
- package/dist/map/write-map-package.js +20 -9
- package/dist/mcp/capture-jobs.d.ts +2 -0
- package/dist/mcp/capture-jobs.js +2 -0
- package/dist/mcp/server.d.ts +11 -2
- package/dist/mcp/server.js +17 -4
- package/dist/mcp/tools/bank-report.d.ts +19 -0
- package/dist/mcp/tools/bank-report.js +51 -0
- package/dist/mcp/tools/blueprint.js +18 -14
- package/dist/mcp/tools/capture.d.ts +4 -0
- package/dist/mcp/tools/capture.js +22 -5
- package/dist/mcp/tools/catalog.d.ts +1 -1
- package/dist/mcp/tools/catalog.js +30 -1
- package/dist/mcp/tools/compile.d.ts +1 -1
- package/dist/mcp/tools/compile.js +100 -9
- package/dist/mcp/tools/editor-handoff.d.ts +4 -1
- package/dist/mcp/tools/editor-handoff.js +6 -3
- package/dist/mcp/tools/style-pack.d.ts +11 -0
- package/dist/mcp/tools/style-pack.js +245 -0
- package/dist/mcp/tools/tool-group.d.ts +9 -0
- package/dist/mods/button-hotkeys.d.ts +45 -0
- package/dist/mods/button-hotkeys.js +185 -0
- package/dist/mods/compile-mod.js +19 -5
- package/dist/mods/custom-doodads.d.ts +21 -1
- package/dist/mods/custom-doodads.js +53 -7
- package/dist/mods/data-rules.js +8 -1
- package/dist/mods/effective-entry.d.ts +18 -0
- package/dist/mods/effective-entry.js +52 -0
- package/dist/mods/function-search.js +12 -0
- package/dist/mods/library-xml.d.ts +34 -5
- package/dist/mods/library-xml.js +94 -22
- package/dist/mods/sound-mix.d.ts +92 -0
- package/dist/mods/sound-mix.js +195 -0
- package/dist/plugins/check-workspace.js +22 -3
- package/dist/plugins/plugin-api.d.ts +59 -5
- package/dist/plugins/plugin-api.js +6 -0
- package/dist/plugins/plugin-sdk.d.ts +13 -1
- package/dist/plugins/plugin-sdk.js +16 -1
- package/dist/plugins/plugin-sources.js +1 -0
- package/dist/plugins/registry.d.ts +4 -0
- package/dist/plugins/registry.js +6 -2
- package/dist/plugins/workspace.d.ts +5 -0
- package/dist/plugins/workspace.js +10 -2
- package/dist/study/blizzard-baseline.d.ts +76 -0
- package/dist/study/blizzard-baseline.js +137 -0
- package/dist/study/exemplar-report.d.ts +71 -0
- package/dist/study/exemplar-report.js +163 -0
- package/dist/study/find-places.d.ts +127 -0
- package/dist/study/find-places.js +306 -0
- package/dist/study/load-map-package.d.ts +3 -0
- package/dist/study/load-map-package.js +11 -0
- package/dist/study/map-study.d.ts +1 -0
- package/dist/study/map-study.js +3 -0
- package/dist/study/measure-lighting.d.ts +6 -0
- package/dist/study/measure-lighting.js +1 -1
- package/dist/study/measures.d.ts +225 -0
- package/dist/study/measures.js +366 -0
- package/dist/study/scaffold-style-pack.d.ts +58 -0
- package/dist/study/scaffold-style-pack.js +261 -0
- package/dist/study/study-exemplars.d.ts +67 -0
- package/dist/study/study-exemplars.js +133 -0
- package/dist/triggers/blueprint-triggers.d.ts +71 -11
- package/dist/triggers/blueprint-triggers.js +403 -48
- package/dist/triggers/kept-trigger-galaxy.d.ts +29 -0
- package/dist/triggers/kept-trigger-galaxy.js +103 -7
- package/dist/triggers/splice-map-script.d.ts +2 -0
- package/dist/triggers/splice-map-script.js +309 -8
- package/dist/triggers/write-triggers-xml.js +20 -5
- package/dist/ui/frame-path-check.d.ts +43 -4
- package/dist/ui/frame-path-check.js +121 -13
- package/dist/ui/frame-paths.d.ts +21 -1
- package/dist/ui/frame-paths.js +26 -6
- package/dist/ui/toast.d.ts +4 -5
- package/dist/ui/toast.js +6 -10
- package/examples/example-campaign/README.md +27 -0
- package/examples/example-campaign/missions/ashfall-relay/blueprint.json +11 -1
- package/examples/example-campaign/missions/ashfall-relay/triggers/ash-tremors.json +69 -0
- package/examples/example-campaign/missions/ashfall-relay/triggers/start-ash-tremors.json +31 -0
- package/package.json +3 -3
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
// The effect tour: films the game's effect models (Assets/Effects) in the game itself, for an
|
|
2
|
+
// effects gallery (sc2-asset-catalog docs/effects-gallery.md). A batch map holds one CModel per
|
|
3
|
+
// effect file and a script that, for each effect in turn, attaches it to a host unit on a pad,
|
|
4
|
+
// films its Birth, its Stand, the host moving (do its particles trail?), a plain Destroy (do they
|
|
5
|
+
// linger?) and its Death, and announces each frame in bank "FxTour" for the Host Adapter's capture
|
|
6
|
+
// to screenshot. A renderer can't show this: Blender and WhiteoutFlakes draw no particles.
|
|
7
|
+
//
|
|
8
|
+
// Each effect's timing comes from its own animations and its framing from its bounds, both read
|
|
9
|
+
// from the .m3 (catalog/m3-sequences.ts, m3-footprint.ts).
|
|
10
|
+
import { PLAYER_CAMERA } from "./area-tour.js";
|
|
11
|
+
import { galaxyString } from "./capture-copy.js";
|
|
12
|
+
/** The bank the effect tour saves, with int key `stop`. */
|
|
13
|
+
export const EFFECT_TOUR_BANK = "FxTour";
|
|
14
|
+
/** The tour's Custom Script element and its init function. */
|
|
15
|
+
export const EFFECT_TOUR_SCRIPT_ID = "F7700001";
|
|
16
|
+
export const EFFECT_TOUR_INIT = "FxTour_Init";
|
|
17
|
+
/** The camera's pitch: three quarters from above, as effects are seen in play but with more of their height. */
|
|
18
|
+
export const EFFECT_PITCH = 40;
|
|
19
|
+
/** How much more than the effect's bounds the frame holds: bounds seldom cover all the particles. */
|
|
20
|
+
export const FRAME_MARGIN = 1.3;
|
|
21
|
+
/** The closest and farthest the camera goes. */
|
|
22
|
+
const MIN_DISTANCE = 6;
|
|
23
|
+
const MAX_DISTANCE = 70;
|
|
24
|
+
/** The longest wait into a part: a 30 s Birth is filmed 4 s in. */
|
|
25
|
+
const MAX_PART = 4;
|
|
26
|
+
/** An animation under this long is a flash; one this long or longer has time to move in. */
|
|
27
|
+
const MOVE_MIN = 1.5;
|
|
28
|
+
const animation = (sequences, name) => sequences.find((sequence) => sequence.name.toLowerCase() === name.toLowerCase()) ?? sequences.find((sequence) => sequence.name.toLowerCase().startsWith(`${name.toLowerCase()} `));
|
|
29
|
+
const round = (value) => Math.round(value * 100) / 100;
|
|
30
|
+
/**
|
|
31
|
+
* Plans one effect: which frames it gets and when. The game plays a generic model actor's
|
|
32
|
+
* animations as a bracket, Birth, then Stand (looping), then Death once the bracket is stopped,
|
|
33
|
+
* so the plan follows the animations the file has:
|
|
34
|
+
* - `birth` half way through Birth, when it has one;
|
|
35
|
+
* - `stand` a second into a looping Stand, or half way through one that plays once (a one-shot);
|
|
36
|
+
* - `moving` after the host has moved sideways for a second, when Stand loops or lasts long enough;
|
|
37
|
+
* - `after-destroy` half a second after a plain Destroy, which shows particles left in the world;
|
|
38
|
+
* - `death` half way through Death, on a fresh copy whose bracket is stopped, when it has one.
|
|
39
|
+
* `firstStop` is the first stop number; the plan numbers its frames on from it.
|
|
40
|
+
*/
|
|
41
|
+
export function planEffect(effect, firstStop) {
|
|
42
|
+
const birth = animation(effect.sequences, "Birth");
|
|
43
|
+
const named = animation(effect.sequences, "Stand");
|
|
44
|
+
const stand = named ?? (birth ? undefined : effect.sequences[0]);
|
|
45
|
+
const play = !birth && !named && stand ? stand.name : "";
|
|
46
|
+
// A model whose only animation is Death plays it at once: no second copy for a death frame.
|
|
47
|
+
const death = play && play === animation(effect.sequences, "Death")?.name ? undefined : animation(effect.sequences, "Death");
|
|
48
|
+
const standSeconds = stand ? stand.durationMs / 1000 : 0;
|
|
49
|
+
const looping = stand?.looping ?? true;
|
|
50
|
+
const standShot = round(looping ? Math.min(1, Math.max(standSeconds / 2, 0.25)) : Math.min(MAX_PART, Math.max(standSeconds / 2, 0.1)));
|
|
51
|
+
const moves = looping || standSeconds - standShot >= MOVE_MIN;
|
|
52
|
+
const [x0, y0, z0] = effect.min;
|
|
53
|
+
const [x1, y1, z1] = effect.max;
|
|
54
|
+
// Framed as a sphere round its bounds, on the pad: SC2 models stand on their origin.
|
|
55
|
+
const radius = Math.max(0.5, Math.hypot(x1 - x0, y1 - y0, z1 - z0) / 2);
|
|
56
|
+
const halfFov = ((PLAYER_CAMERA.fov / 2) * Math.PI) / 180;
|
|
57
|
+
const distance = round(Math.min(MAX_DISTANCE, Math.max(MIN_DISTANCE, (radius * FRAME_MARGIN) / Math.tan(halfFov))));
|
|
58
|
+
const labels = [...(birth ? ["birth"] : []), "stand", ...(moves ? ["moving"] : []), "after-destroy", ...(death ? ["death"] : [])];
|
|
59
|
+
const stops = { birth: 0, stand: 0, moving: 0, "after-destroy": 0, death: 0 };
|
|
60
|
+
labels.forEach((label, n) => (stops[label] = firstStop + n));
|
|
61
|
+
return {
|
|
62
|
+
birth: birth ? round(Math.min(MAX_PART, birth.durationMs / 2000)) : 0,
|
|
63
|
+
standShot,
|
|
64
|
+
move: moves ? 1 : 0,
|
|
65
|
+
// A quarter of the frame's width, so the host stays in view: the frame is about 0.84 × distance wide.
|
|
66
|
+
moveCells: moves ? round(Math.min(12, Math.max(1, distance * 0.21))) : 0,
|
|
67
|
+
death: death ? round(Math.min(MAX_PART, Math.max(death.durationMs / 2000, 0.1))) : 0,
|
|
68
|
+
play,
|
|
69
|
+
distance,
|
|
70
|
+
height: round(Math.max(0, Math.min((z0 + z1) / 2, radius))),
|
|
71
|
+
stops,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/** The map-local CModel id of a batch's `n`th effect. */
|
|
75
|
+
export const effectModelId = (n) => `FxTour${String(n + 1).padStart(4, "0")}`;
|
|
76
|
+
/** Plans a batch: its effects' plans, numbered from stop 1. */
|
|
77
|
+
export function planEffectBatch(effects) {
|
|
78
|
+
if (effects.length === 0)
|
|
79
|
+
throw new Error("An effect tour needs at least one effect");
|
|
80
|
+
let next = 1;
|
|
81
|
+
const plans = effects.map((effect) => {
|
|
82
|
+
const plan = planEffect(effect, next);
|
|
83
|
+
next += Object.values(plan.stops).filter((stop) => stop > 0).length;
|
|
84
|
+
return plan;
|
|
85
|
+
});
|
|
86
|
+
if (next - 1 > 9999)
|
|
87
|
+
throw new Error(`An effect tour's frames are numbered in 4 digits; this batch has ${next - 1}: split it`);
|
|
88
|
+
const shots = plans
|
|
89
|
+
.flatMap((plan, effect) => Object.entries(plan.stops).filter(([, stop]) => stop > 0).map(([label, stop]) => ({ stop, effect, file: effects[effect].file, label })))
|
|
90
|
+
.sort((a, b) => a.stop - b.stop);
|
|
91
|
+
return { effects, ids: effects.map((_, n) => effectModelId(n)), plans, shots };
|
|
92
|
+
}
|
|
93
|
+
/** About how long a batch takes in game, in seconds, after the game starts. The game's waits run at real speed in Test Document: the test batch (2026-11-23) took 143 s against 117 planned. */
|
|
94
|
+
export function batchSeconds(batch, options = {}) {
|
|
95
|
+
const hold = (options.hold ?? DEFAULT_HOLD) + 0.25;
|
|
96
|
+
return Math.round(batch.plans.reduce((sum, plan) => sum + 1 + plan.birth * 2 + plan.standShot + plan.move + 0.5 + (plan.death ? 1.5 + plan.death * 2 + 0.5 : 0) + Object.values(plan.stops).filter((stop) => stop > 0).length * hold, 0) + 5);
|
|
97
|
+
}
|
|
98
|
+
/** `--batches`: one batch (`3`) or a range (`3-5`); every batch when unset. */
|
|
99
|
+
export function batchRange(range) {
|
|
100
|
+
if (range === undefined)
|
|
101
|
+
return [1, Infinity];
|
|
102
|
+
const match = /^(\d+)(?:-(\d+))?$/.exec(range);
|
|
103
|
+
if (!match || Number(match[1]) < 1 || (match[2] !== undefined && Number(match[2]) < Number(match[1]))) {
|
|
104
|
+
throw new Error(`--batches takes one batch (3) or a range (3-5), not ${JSON.stringify(range)}`);
|
|
105
|
+
}
|
|
106
|
+
return [Number(match[1]), Number(match[2] ?? match[1])];
|
|
107
|
+
}
|
|
108
|
+
/** The map-local ModelData: one CModel per effect file. */
|
|
109
|
+
export function effectModelData(batch) {
|
|
110
|
+
const models = batch.effects.map((effect, n) => ` <CModel id="${batch.ids[n]}" parent="FX">\n <Model value="${effect.file.replace(/\//g, "\\")}"/>\n </CModel>`);
|
|
111
|
+
return `<?xml version="1.0" encoding="utf-8"?>\n<Catalog>\n${models.join("\n")}\n</Catalog>\n`;
|
|
112
|
+
}
|
|
113
|
+
/** Seconds of real time each frame is held for the screenshot, by default. */
|
|
114
|
+
export const DEFAULT_HOLD = 1.5;
|
|
115
|
+
const fx = (value) => (Number.isInteger(value) ? `${value}.0` : String(value));
|
|
116
|
+
/**
|
|
117
|
+
* The batch's Galaxy: hide the UI, make the host, then film each effect in turn on the pad. Each
|
|
118
|
+
* frame is announced by saving bank "FxTour" with key `stop`, held for the screenshot, and the
|
|
119
|
+
* tour ends with stop -1. Waits for animations are in game time, waits for screenshots in real time.
|
|
120
|
+
*/
|
|
121
|
+
export function effectTourScript(batch, options = {}) {
|
|
122
|
+
const [px, py] = options.pad ?? [128, 128];
|
|
123
|
+
const host = options.host ?? "Marine";
|
|
124
|
+
const n = batch.effects.length;
|
|
125
|
+
const freeze = options.freeze ?? false;
|
|
126
|
+
const data = batch.plans.map((plan, i) => [
|
|
127
|
+
` fxModel[${i}] = ${galaxyString(batch.ids[i])}; fxPlay[${i}] = ${galaxyString(plan.play)};`,
|
|
128
|
+
`fxBirth[${i}] = ${fx(plan.birth)}; fxStand[${i}] = ${fx(plan.standShot)}; fxMove[${i}] = ${fx(plan.move)}; fxMoveCells[${i}] = ${fx(plan.moveCells)}; fxDeath[${i}] = ${fx(plan.death)};`,
|
|
129
|
+
`fxDistance[${i}] = ${fx(plan.distance)}; fxHeight[${i}] = ${fx(plan.height)};`,
|
|
130
|
+
`fxShot[${i}][0] = ${plan.stops.birth}; fxShot[${i}][1] = ${plan.stops.stand}; fxShot[${i}][2] = ${plan.stops.moving}; fxShot[${i}][3] = ${plan.stops["after-destroy"]}; fxShot[${i}][4] = ${plan.stops.death};`,
|
|
131
|
+
].join(" "));
|
|
132
|
+
return `// Effect tour (generated by npm run effect-tour): films each effect model on a pad and announces
|
|
133
|
+
// each frame by saving bank "${EFFECT_TOUR_BANK}" with key "stop", for an outside watcher to screenshot.
|
|
134
|
+
include "TriggerLibs/NativeLib"
|
|
135
|
+
const int fxCount = ${n};
|
|
136
|
+
const fixed fxHold = ${fx(options.hold ?? DEFAULT_HOLD)};
|
|
137
|
+
const bool fxFreeze = ${freeze ? "true" : "false"};
|
|
138
|
+
const bool fxVideo = ${options.video ? "true" : "false"};
|
|
139
|
+
const string fxLighting = ${galaxyString(options.lighting ?? "")};
|
|
140
|
+
string[fxCount] fxModel;
|
|
141
|
+
string[fxCount] fxPlay;
|
|
142
|
+
fixed[fxCount] fxBirth;
|
|
143
|
+
fixed[fxCount] fxStand;
|
|
144
|
+
fixed[fxCount] fxMove;
|
|
145
|
+
fixed[fxCount] fxMoveCells;
|
|
146
|
+
fixed[fxCount] fxDeath;
|
|
147
|
+
fixed[fxCount] fxDistance;
|
|
148
|
+
fixed[fxCount] fxHeight;
|
|
149
|
+
int[fxCount][5] fxShot;
|
|
150
|
+
bank fxBank;
|
|
151
|
+
unit fxHost;
|
|
152
|
+
point fxPad;
|
|
153
|
+
|
|
154
|
+
void FxTour_Data() {
|
|
155
|
+
${data.join("\n")}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Announces a frame (none when stop is 0): holds the game still, clears messages, saves the bank,
|
|
159
|
+
// and holds the frame for the screenshot.
|
|
160
|
+
void FxTour_Shot(int stop) {
|
|
161
|
+
if (stop <= 0) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (fxFreeze) {
|
|
165
|
+
GameSetGlobalTimeScale(0.0);
|
|
166
|
+
}
|
|
167
|
+
UIClearMessages(PlayerGroupAll(), c_messageAreaAll);
|
|
168
|
+
Wait(0.25, c_timeReal);
|
|
169
|
+
BankValueSetFromInt(fxBank, "tour", "stop", stop);
|
|
170
|
+
BankSave(fxBank);
|
|
171
|
+
Wait(fxHold, c_timeReal);
|
|
172
|
+
if (fxFreeze) {
|
|
173
|
+
GameSetGlobalTimeScale(1.0);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Puts the host back on the pad, clears every particle left over, and points the camera.
|
|
178
|
+
void FxTour_Reset(int i) {
|
|
179
|
+
ActorWorldParticleFXDestroy();
|
|
180
|
+
UnitSetPosition(fxHost, fxPad, false);
|
|
181
|
+
UnitSetFacing(fxHost, 270.0, 0.0);
|
|
182
|
+
CameraSetValue(1, c_cameraValueDistance, fxDistance[i], 0.0, -1, 10.0);
|
|
183
|
+
CameraSetValue(1, c_cameraValueHeightOffset, fxHeight[i], 0.0, -1, 10.0);
|
|
184
|
+
CameraPan(1, fxPad, 0.0, -1, 10.0, false);
|
|
185
|
+
if (fxVideo) {
|
|
186
|
+
// Marks the bare pad in the video, then waits long enough that the host noticing the bank
|
|
187
|
+
// late still finds the pad bare: the effect is attached a second after the mark.
|
|
188
|
+
BankValueSetFromInt(fxBank, "tour", "mark", i + 1);
|
|
189
|
+
BankSave(fxBank);
|
|
190
|
+
Wait(1.0, c_timeReal);
|
|
191
|
+
} else {
|
|
192
|
+
Wait(0.5, c_timeReal);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
void FxTour_Film(int i) {
|
|
197
|
+
actor fx;
|
|
198
|
+
fixed step;
|
|
199
|
+
fixed moved;
|
|
200
|
+
FxTour_Reset(i);
|
|
201
|
+
fx = libNtve_gf_AttachModelToUnit(fxHost, fxModel[i], "Ref_Origin");
|
|
202
|
+
if (fxPlay[i] != "") {
|
|
203
|
+
ActorSend(fx, "AnimPlay FxTour " + fxPlay[i]);
|
|
204
|
+
}
|
|
205
|
+
if (fxBirth[i] > 0.0) {
|
|
206
|
+
Wait(fxBirth[i], c_timeGame);
|
|
207
|
+
FxTour_Shot(fxShot[i][0]);
|
|
208
|
+
Wait(fxBirth[i], c_timeGame);
|
|
209
|
+
}
|
|
210
|
+
Wait(fxStand[i], c_timeGame);
|
|
211
|
+
FxTour_Shot(fxShot[i][1]);
|
|
212
|
+
if (fxMove[i] > 0.0) {
|
|
213
|
+
// Moved a step each game loop, the art blended between, so the effect sees a smooth move.
|
|
214
|
+
step = fxMoveCells[i] / (fxMove[i] * 16.0);
|
|
215
|
+
moved = 0.0;
|
|
216
|
+
while (moved < fxMoveCells[i]) {
|
|
217
|
+
moved += step;
|
|
218
|
+
UnitSetPosition(fxHost, PointWithOffset(fxPad, moved, 0.0), true);
|
|
219
|
+
Wait(0.0625, c_timeGame);
|
|
220
|
+
}
|
|
221
|
+
FxTour_Shot(fxShot[i][2]);
|
|
222
|
+
}
|
|
223
|
+
ActorSend(fx, "Destroy");
|
|
224
|
+
Wait(0.5, c_timeGame);
|
|
225
|
+
FxTour_Shot(fxShot[i][3]);
|
|
226
|
+
if (fxDeath[i] > 0.0) {
|
|
227
|
+
FxTour_Reset(i);
|
|
228
|
+
fx = libNtve_gf_AttachModelToUnit(fxHost, fxModel[i], "Ref_Origin");
|
|
229
|
+
Wait(fxBirth[i] * 2.0 + 0.75, c_timeGame);
|
|
230
|
+
// Played outright: stopping the bracket of the generic actor this makes removes it at once.
|
|
231
|
+
ActorSend(fx, "AnimPlay FxTour Death");
|
|
232
|
+
Wait(fxDeath[i], c_timeGame);
|
|
233
|
+
FxTour_Shot(fxShot[i][4]);
|
|
234
|
+
ActorSend(fx, "Destroy Immediate");
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
bool FxTour_Run(bool testConds, bool runActions) {
|
|
239
|
+
int i;
|
|
240
|
+
fxBank = BankLoad("${EFFECT_TOUR_BANK}", 1);
|
|
241
|
+
fxPad = Point(${fx(px)}, ${fx(py)});
|
|
242
|
+
if (fxLighting != "") {
|
|
243
|
+
GameSetLighting(fxLighting, 0.0);
|
|
244
|
+
}
|
|
245
|
+
VisEnable(c_visTypeMask, false);
|
|
246
|
+
VisEnable(c_visTypeFog, false);
|
|
247
|
+
libNtve_gf_HideGameUI(false, PlayerGroupAll());
|
|
248
|
+
UISetFrameVisible(PlayerGroupAll(), c_syncFrameTypeMenuBar, false);
|
|
249
|
+
UISetFrameVisible(PlayerGroupAll(), c_syncFrameTypeErrorDisplayPanel, false);
|
|
250
|
+
TriggerDebugOutputEnable(false);
|
|
251
|
+
TriggerDebugWindowOpen(false);
|
|
252
|
+
UISetCursorVisible(PlayerGroupAll(), false);
|
|
253
|
+
PlayerSetColorIndex(1, ${options.teamColor ?? 8}, true);
|
|
254
|
+
UnitCreate(1, ${galaxyString(host)}, c_unitCreateIgnorePlacement, 1, fxPad, 270.0);
|
|
255
|
+
fxHost = UnitLastCreated();
|
|
256
|
+
UnitSetState(fxHost, c_unitStateInvulnerable, true);
|
|
257
|
+
UnitSetState(fxHost, c_unitStateSelectable, false);
|
|
258
|
+
CameraLockInput(1, true);
|
|
259
|
+
CameraApplyInfo(1, CameraInfoDefault(), 0.0, -1, 10.0, false);
|
|
260
|
+
CameraSetValue(1, c_cameraValuePitch, ${fx(EFFECT_PITCH)}, 0.0, -1, 10.0);
|
|
261
|
+
FxTour_Data();
|
|
262
|
+
// Recording, the Host Adapter can resize and start recording the window only once the game has
|
|
263
|
+
// loaded: a longer wait, so the first effect is filmed.
|
|
264
|
+
if (fxVideo) {
|
|
265
|
+
Wait(12.0, c_timeReal);
|
|
266
|
+
} else {
|
|
267
|
+
Wait(3.0, c_timeReal);
|
|
268
|
+
}
|
|
269
|
+
i = 0;
|
|
270
|
+
while (i < fxCount) {
|
|
271
|
+
FxTour_Film(i);
|
|
272
|
+
i += 1;
|
|
273
|
+
}
|
|
274
|
+
BankValueSetFromInt(fxBank, "tour", "stop", -1);
|
|
275
|
+
BankSave(fxBank);
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
void ${EFFECT_TOUR_INIT}() {
|
|
280
|
+
TriggerAddEventMapInit(TriggerCreate("FxTour_Run"));
|
|
281
|
+
}
|
|
282
|
+
`;
|
|
283
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { EffectShot } from "./effect-tour.js";
|
|
2
|
+
/** A recording's timeline, from video-stops.txt: each stop's time into the video, and each mark's (`m<n>`, saved once the pad is reset for effect n - 1, a second before it is attached). */
|
|
3
|
+
export type VideoTimeline = {
|
|
4
|
+
readonly stops: ReadonlyMap<number, number>;
|
|
5
|
+
readonly marks: ReadonlyMap<number, number>;
|
|
6
|
+
};
|
|
7
|
+
/** Reads video-stops.txt: `<stop> <seconds>` and `m<mark> <seconds>` lines; the first time of each wins. */
|
|
8
|
+
export declare function parseVideoStops(text: string): VideoTimeline;
|
|
9
|
+
/**
|
|
10
|
+
* One effect's place in the video, in seconds: `base` is a frame of the host on the pad before the
|
|
11
|
+
* effect is attached; frames are searched from `base` to `searchEnd`, before the host moves; the
|
|
12
|
+
* clip runs from `base` to `end`.
|
|
13
|
+
*/
|
|
14
|
+
export type EffectSegment = {
|
|
15
|
+
readonly effect: number;
|
|
16
|
+
readonly base: number;
|
|
17
|
+
readonly searchEnd: number;
|
|
18
|
+
readonly end: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* How long after its mark an effect's base frame is. The tour saves the mark once the pad is reset
|
|
22
|
+
* and attaches the effect a second later; the host notices the mark a little late (a poll, more
|
|
23
|
+
* when its loop stalls), so the base is a little after the noted time and still a bare pad as long
|
|
24
|
+
* as the host is under 0.8 s late.
|
|
25
|
+
*/
|
|
26
|
+
export declare const BASE_AFTER_MARK = 0.2;
|
|
27
|
+
/**
|
|
28
|
+
* Where each effect is in the video. Its mark (saved once its pad is reset) places it: the base
|
|
29
|
+
* frame is BASE_AFTER_MARK later. A recording without marks places it by the previous effect's
|
|
30
|
+
* last stop instead: after that frame's hold, the tour resets the pad and waits
|
|
31
|
+
* RESET_WAIT, and the base is the middle of that wait. The first effect of such a recording has
|
|
32
|
+
* no previous one: its base is `leadIn(effect)` seconds before its first stop, the time the tour
|
|
33
|
+
* spends from the attach to that frame, plus half the reset wait. The search ends at its stand
|
|
34
|
+
* frame's stop (the host moves only after it), else its last stop; the clip ends at the next
|
|
35
|
+
* effect's base, or `hold` after its own last stop. An effect with no
|
|
36
|
+
* timed stop has no segment.
|
|
37
|
+
*/
|
|
38
|
+
export declare function effectSegments(shots: readonly EffectShot[], timeline: VideoTimeline, hold: number, leadIn?: (effect: number) => number): EffectSegment[];
|
|
39
|
+
/**
|
|
40
|
+
* The `count` frames that changed most, by `scores` (one per frame), at least `minGap` frames
|
|
41
|
+
* apart so they don't all show the same instant; in time order. Frames scoring under `floor` are
|
|
42
|
+
* never picked: a stretch where nothing happened gives none.
|
|
43
|
+
*/
|
|
44
|
+
export declare function pickPeaks(scores: readonly number[], count: number, minGap: number, floor?: number): number[];
|
|
45
|
+
/**
|
|
46
|
+
* How far each frame is from the first: the percentage of its grey pixels that changed by more
|
|
47
|
+
* than PIXEL_CHANGE. A share, not a mean difference, so a small effect seen from far off (a Psi
|
|
48
|
+
* Storm filmed whole is about 1% of the frame) still stands out of the noise.
|
|
49
|
+
*/
|
|
50
|
+
export declare function changeScores(frames: Uint8Array, frameBytes: number, threshold?: number): number[];
|
|
51
|
+
/** What one effect's clip and frames came to. */
|
|
52
|
+
export type EffectVideoResult = {
|
|
53
|
+
readonly effect: number;
|
|
54
|
+
readonly clip: string;
|
|
55
|
+
/** The picked frames' files, and each one's seconds after the base frame. */
|
|
56
|
+
readonly peaks: readonly {
|
|
57
|
+
readonly file: string;
|
|
58
|
+
readonly seconds: number;
|
|
59
|
+
}[];
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* A clip's HEVC quality (hevc_videotoolbox's -q:v, 0-100): as high as the recording's, so the
|
|
63
|
+
* second encode loses next to nothing more. The clips are masters, which a gallery encodes for the
|
|
64
|
+
* web itself.
|
|
65
|
+
*/
|
|
66
|
+
export declare const CLIP_QUALITY = 90;
|
|
67
|
+
/**
|
|
68
|
+
* Cuts `segment` of `video` into `<outDir>/clips/<name>.mp4` and writes its peak frames as
|
|
69
|
+
* `<outDir>/peaks/<name>-<n>.jpg`. `name` is usually the effect's number. The clip is HEVC at the
|
|
70
|
+
* recording's size and CLIP_QUALITY. It is encoded again, not copied: a copy can only start at a
|
|
71
|
+
* keyframe, the recorder's come about a second apart, and the bare pad before an attach can be as
|
|
72
|
+
* short as 0.3 s, so a copied clip would start on the previous effect.
|
|
73
|
+
*/
|
|
74
|
+
export declare function cutEffect(video: string, segment: EffectSegment, outDir: string, name: string): Promise<EffectVideoResult>;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// The effect tour's video: cuts a recording of a batch's tour (the Host Adapter's video.mp4 and
|
|
2
|
+
// video-stops.txt) into one short clip per effect, and picks the frames where most is on screen.
|
|
3
|
+
// A screenshot misses what's over before it's taken: Heroes impacts, and SC2's own, burst 30-100 ms
|
|
4
|
+
// into Birth, and their particles live a few tenths of a second (sc2-research
|
|
5
|
+
// docs/research/hots-effects/particles.md). The host notes stop times only to a tenth of a second
|
|
6
|
+
// or so, too coarse to aim at a burst, so the frames are picked by what they show: the most changed
|
|
7
|
+
// from a frame of the host on the pad just before the effect was attached.
|
|
8
|
+
import { copyFile, mkdir, mkdtemp, readFile, rename, rm } from "node:fs/promises";
|
|
9
|
+
import os from "node:os";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import { runBounded } from "../host/derive.js";
|
|
12
|
+
/** Reads video-stops.txt: `<stop> <seconds>` and `m<mark> <seconds>` lines; the first time of each wins. */
|
|
13
|
+
export function parseVideoStops(text) {
|
|
14
|
+
const stops = new Map();
|
|
15
|
+
const marks = new Map();
|
|
16
|
+
for (const line of text.split("\n")) {
|
|
17
|
+
const match = /^(m?)(\d+)\s+([0-9.]+)$/.exec(line.trim());
|
|
18
|
+
if (!match)
|
|
19
|
+
continue;
|
|
20
|
+
const into = match[1] ? marks : stops;
|
|
21
|
+
const key = Number(match[2]);
|
|
22
|
+
if (!into.has(key))
|
|
23
|
+
into.set(key, Number(match[3]));
|
|
24
|
+
}
|
|
25
|
+
return { stops, marks };
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* How long after its mark an effect's base frame is. The tour saves the mark once the pad is reset
|
|
29
|
+
* and attaches the effect a second later; the host notices the mark a little late (a poll, more
|
|
30
|
+
* when its loop stalls), so the base is a little after the noted time and still a bare pad as long
|
|
31
|
+
* as the host is under 0.8 s late.
|
|
32
|
+
*/
|
|
33
|
+
export const BASE_AFTER_MARK = 0.2;
|
|
34
|
+
/** The tour's wait on the bare pad before each attach (FxTour_Reset), in real seconds. */
|
|
35
|
+
const RESET_WAIT = 0.5;
|
|
36
|
+
/**
|
|
37
|
+
* Where each effect is in the video. Its mark (saved once its pad is reset) places it: the base
|
|
38
|
+
* frame is BASE_AFTER_MARK later. A recording without marks places it by the previous effect's
|
|
39
|
+
* last stop instead: after that frame's hold, the tour resets the pad and waits
|
|
40
|
+
* RESET_WAIT, and the base is the middle of that wait. The first effect of such a recording has
|
|
41
|
+
* no previous one: its base is `leadIn(effect)` seconds before its first stop, the time the tour
|
|
42
|
+
* spends from the attach to that frame, plus half the reset wait. The search ends at its stand
|
|
43
|
+
* frame's stop (the host moves only after it), else its last stop; the clip ends at the next
|
|
44
|
+
* effect's base, or `hold` after its own last stop. An effect with no
|
|
45
|
+
* timed stop has no segment.
|
|
46
|
+
*/
|
|
47
|
+
export function effectSegments(shots, timeline, hold, leadIn = () => 4) {
|
|
48
|
+
const effects = [...new Set(shots.map((shot) => shot.effect))].sort((a, b) => a - b);
|
|
49
|
+
const placed = [];
|
|
50
|
+
let previousLast;
|
|
51
|
+
for (const effect of effects) {
|
|
52
|
+
const timed = shots.filter((shot) => shot.effect === effect && timeline.stops.has(shot.stop));
|
|
53
|
+
if (timed.length === 0) {
|
|
54
|
+
previousLast = undefined;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const times = timed.map((shot) => timeline.stops.get(shot.stop));
|
|
58
|
+
const first = Math.min(...times);
|
|
59
|
+
const last = Math.max(...times);
|
|
60
|
+
const mark = timeline.marks.get(effect + 1);
|
|
61
|
+
const base = mark !== undefined
|
|
62
|
+
? mark + BASE_AFTER_MARK
|
|
63
|
+
: previousLast !== undefined
|
|
64
|
+
? previousLast + hold + RESET_WAIT / 2
|
|
65
|
+
: first - leadIn(effect) - RESET_WAIT / 2;
|
|
66
|
+
const stand = timeline.stops.get(timed.find((shot) => shot.label === "stand")?.stop ?? -1);
|
|
67
|
+
placed.push({ effect, base: Math.max(0, Math.min(base, first)), searchEnd: stand ?? last, last });
|
|
68
|
+
previousLast = last;
|
|
69
|
+
}
|
|
70
|
+
return placed.map((each, n) => {
|
|
71
|
+
const next = placed[n + 1];
|
|
72
|
+
const end = next && next.effect === each.effect + 1 ? next.base : each.last + hold;
|
|
73
|
+
return { effect: each.effect, base: each.base, searchEnd: Math.max(each.base, each.searchEnd), end: Math.max(each.searchEnd, end) };
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The `count` frames that changed most, by `scores` (one per frame), at least `minGap` frames
|
|
78
|
+
* apart so they don't all show the same instant; in time order. Frames scoring under `floor` are
|
|
79
|
+
* never picked: a stretch where nothing happened gives none.
|
|
80
|
+
*/
|
|
81
|
+
export function pickPeaks(scores, count, minGap, floor = 0) {
|
|
82
|
+
const order = scores.map((score, frame) => ({ score, frame })).sort((a, b) => b.score - a.score || a.frame - b.frame);
|
|
83
|
+
const picked = [];
|
|
84
|
+
for (const { score, frame } of order) {
|
|
85
|
+
if (picked.length >= count || score < floor)
|
|
86
|
+
break;
|
|
87
|
+
if (picked.every((other) => Math.abs(other - frame) >= minGap))
|
|
88
|
+
picked.push(frame);
|
|
89
|
+
}
|
|
90
|
+
return picked.sort((a, b) => a - b);
|
|
91
|
+
}
|
|
92
|
+
/** How much a grey pixel must change to count: past the video's compression noise. */
|
|
93
|
+
const PIXEL_CHANGE = 16;
|
|
94
|
+
/**
|
|
95
|
+
* How far each frame is from the first: the percentage of its grey pixels that changed by more
|
|
96
|
+
* than PIXEL_CHANGE. A share, not a mean difference, so a small effect seen from far off (a Psi
|
|
97
|
+
* Storm filmed whole is about 1% of the frame) still stands out of the noise.
|
|
98
|
+
*/
|
|
99
|
+
export function changeScores(frames, frameBytes, threshold = PIXEL_CHANGE) {
|
|
100
|
+
const count = Math.floor(frames.length / frameBytes);
|
|
101
|
+
const scores = [];
|
|
102
|
+
for (let n = 0; n < count; n++) {
|
|
103
|
+
let changed = 0;
|
|
104
|
+
for (let i = 0; i < frameBytes; i++)
|
|
105
|
+
if (Math.abs(frames[n * frameBytes + i] - frames[i]) > threshold)
|
|
106
|
+
changed++;
|
|
107
|
+
scores.push((100 * changed) / frameBytes);
|
|
108
|
+
}
|
|
109
|
+
return scores;
|
|
110
|
+
}
|
|
111
|
+
/** The size the frames are compared at, and their rate. */
|
|
112
|
+
const PROBE_WIDTH = 320;
|
|
113
|
+
const PROBE_HEIGHT = 180;
|
|
114
|
+
const PROBE_FPS = 30;
|
|
115
|
+
/** How many peak frames an effect gets, and how far apart, in seconds. */
|
|
116
|
+
const PEAKS = 4;
|
|
117
|
+
const PEAK_GAP = 0.15;
|
|
118
|
+
/** Under this share of changed pixels (percent) a frame shows nothing new: noise, or the host's idle animation. */
|
|
119
|
+
const CHANGE_FLOOR = 0.05;
|
|
120
|
+
const limits = (seconds, maxOutputBytes) => ({ timeoutMs: (60 + seconds * 4) * 1000, maxOutputBytes });
|
|
121
|
+
/**
|
|
122
|
+
* A clip's HEVC quality (hevc_videotoolbox's -q:v, 0-100): as high as the recording's, so the
|
|
123
|
+
* second encode loses next to nothing more. The clips are masters, which a gallery encodes for the
|
|
124
|
+
* web itself.
|
|
125
|
+
*/
|
|
126
|
+
export const CLIP_QUALITY = 90;
|
|
127
|
+
/** The largest clip written, in bytes: a clip of an effect is seconds long, a few MB at CLIP_QUALITY. */
|
|
128
|
+
const CLIP_MAX_BYTES = 200 * 1024 * 1024;
|
|
129
|
+
/**
|
|
130
|
+
* Cuts `segment` of `video` into `<outDir>/clips/<name>.mp4` and writes its peak frames as
|
|
131
|
+
* `<outDir>/peaks/<name>-<n>.jpg`. `name` is usually the effect's number. The clip is HEVC at the
|
|
132
|
+
* recording's size and CLIP_QUALITY. It is encoded again, not copied: a copy can only start at a
|
|
133
|
+
* keyframe, the recorder's come about a second apart, and the bare pad before an attach can be as
|
|
134
|
+
* short as 0.3 s, so a copied clip would start on the previous effect.
|
|
135
|
+
*/
|
|
136
|
+
export async function cutEffect(video, segment, outDir, name) {
|
|
137
|
+
const seconds = Math.max(0.1, segment.end - segment.base);
|
|
138
|
+
const searchSeconds = Math.max(0.1, segment.searchEnd - segment.base);
|
|
139
|
+
const clips = path.join(outDir, "clips");
|
|
140
|
+
const peaksDir = path.join(outDir, "peaks");
|
|
141
|
+
await mkdir(clips, { recursive: true });
|
|
142
|
+
await mkdir(peaksDir, { recursive: true });
|
|
143
|
+
const clip = path.join(clips, `${name}.mp4`);
|
|
144
|
+
const at = ["-ss", segment.base.toFixed(3), "-t", seconds.toFixed(3)];
|
|
145
|
+
await runBounded("ffmpeg", ["-v", "error", "-y", ...at, "-i", video, "-an", "-c:v", "hevc_videotoolbox", "-q:v", String(CLIP_QUALITY), "-tag:v", "hvc1", "-fs", String(CLIP_MAX_BYTES), clip], limits(seconds, CLIP_MAX_BYTES));
|
|
146
|
+
const scratch = await mkdtemp(path.join(os.tmpdir(), "effect-video-"));
|
|
147
|
+
try {
|
|
148
|
+
const raw = path.join(scratch, "frames.gray");
|
|
149
|
+
const frameBytes = PROBE_WIDTH * PROBE_HEIGHT;
|
|
150
|
+
const frameCount = Math.ceil(searchSeconds * PROBE_FPS + 2);
|
|
151
|
+
// One decode for both: the small grey frames that are scored and the full frames to keep, from
|
|
152
|
+
// the same resampled stream, so a picked frame is the one scored. Seeking for each picked frame
|
|
153
|
+
// instead can land a frame off in a recording whose frames come unevenly, and a burst lasts three.
|
|
154
|
+
await runBounded("ffmpeg", [
|
|
155
|
+
"-v", "error", "-y", "-ss", segment.base.toFixed(3), "-t", searchSeconds.toFixed(3), "-i", video, "-an",
|
|
156
|
+
"-filter_complex", `fps=${PROBE_FPS},split=2[probe][full];[probe]scale=${PROBE_WIDTH}:${PROBE_HEIGHT},format=gray[grey]`,
|
|
157
|
+
"-map", "[grey]", "-f", "rawvideo", raw,
|
|
158
|
+
"-map", "[full]", "-q:v", "3", path.join(scratch, "%05d.jpg"),
|
|
159
|
+
], limits(searchSeconds, frameCount * (frameBytes + 2 * 1024 * 1024)));
|
|
160
|
+
const scores = changeScores(new Uint8Array(await readFile(raw)), frameBytes);
|
|
161
|
+
const picked = pickPeaks(scores, PEAKS, Math.round(PEAK_GAP * PROBE_FPS), CHANGE_FLOOR);
|
|
162
|
+
const peaks = [];
|
|
163
|
+
for (const [n, frame] of picked.entries()) {
|
|
164
|
+
const file = path.join(peaksDir, `${name}-${n + 1}.jpg`);
|
|
165
|
+
await rename(path.join(scratch, `${String(frame + 1).padStart(5, "0")}.jpg`), file).catch(() => copyFile(path.join(scratch, `${String(frame + 1).padStart(5, "0")}.jpg`), file));
|
|
166
|
+
peaks.push({ file, seconds: frame / PROBE_FPS });
|
|
167
|
+
}
|
|
168
|
+
return { effect: segment.effect, clip, peaks };
|
|
169
|
+
}
|
|
170
|
+
finally {
|
|
171
|
+
await rm(scratch, { recursive: true, force: true });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -60,6 +60,10 @@ export type CaptureExemplarToursOptions = {
|
|
|
60
60
|
/** Keep data errors on screen, to debug a tour that doesn't start. */
|
|
61
61
|
readonly showErrors?: boolean;
|
|
62
62
|
readonly log?: (line: string) => void;
|
|
63
|
+
/** Hears the broker's id for each tour as it is queued. */
|
|
64
|
+
readonly onQueued?: (id: string) => void;
|
|
65
|
+
/** Cancels the tour running or waiting, and fails the call, leaving the tours after it. */
|
|
66
|
+
readonly signal?: AbortSignal;
|
|
63
67
|
};
|
|
64
68
|
export type ExemplarTourOutcome = {
|
|
65
69
|
readonly id: string;
|
|
@@ -54,6 +54,7 @@ export async function captureExemplarTours(host, tours, options) {
|
|
|
54
54
|
hostContext(host.machine).requirePath("cacheDir");
|
|
55
55
|
const outcomes = [];
|
|
56
56
|
for (const tour of tours) {
|
|
57
|
+
options.signal?.throwIfAborted();
|
|
57
58
|
const outputDir = path.join(options.capturesRoot, tour.id, "captures", tour.label);
|
|
58
59
|
if (existsSync(outputDir) && (await readdir(outputDir)).some((file) => file.endsWith(".jpg"))) {
|
|
59
60
|
log(`${tour.id}/${tour.label}: already captured`);
|
|
@@ -77,11 +78,13 @@ export async function captureExemplarTours(host, tours, options) {
|
|
|
77
78
|
},
|
|
78
79
|
settings: { frameDigits: 3, recordKeys: ["x", "y"], width: 1600, quality: 80, startSeconds: 300, pressSpaceAfterSeconds: 30 },
|
|
79
80
|
outputDir,
|
|
80
|
-
}, { log: (line) => log(`${tour.id}/${tour.label}: ${line}`) });
|
|
81
|
+
}, { log: (line) => log(`${tour.id}/${tour.label}: ${line}`), ...(options.onQueued ? { onQueued: options.onQueued } : {}), ...(options.signal ? { signal: options.signal } : {}) });
|
|
81
82
|
log(`${tour.id}/${tour.label}: ${result.end}, ${result.frames} frames`);
|
|
82
83
|
outcomes.push({ id: tour.id, label: tour.label, outcome: result.end, frames: result.frames });
|
|
83
84
|
}
|
|
84
85
|
catch (error) {
|
|
86
|
+
if (options.signal?.aborted)
|
|
87
|
+
throw error;
|
|
85
88
|
const reason = error instanceof Error ? error.message : String(error);
|
|
86
89
|
log(`${tour.id}/${tour.label}: failed: ${reason}`);
|
|
87
90
|
outcomes.push({ id: tour.id, label: tour.label, outcome: "failed", frames: 0, reason });
|
package/dist/capture/shots.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { type Host } from "../host/host.js";
|
|
3
|
-
import type { CaptureTourResult } from "../plugins/plugin-api.js";
|
|
3
|
+
import type { CaptureTourResult, GameProcess } from "../plugins/plugin-api.js";
|
|
4
4
|
import { type FittedCamera } from "./area-tour.js";
|
|
5
5
|
/**
|
|
6
6
|
* A rectangle of the map that a frame must show: the least it shows, since the 16:9 frame shows
|
|
@@ -59,6 +59,11 @@ export type CaptureShotsResult = {
|
|
|
59
59
|
readonly outputDir: string;
|
|
60
60
|
/** The capture copy the tour ran on. */
|
|
61
61
|
readonly copy: string;
|
|
62
|
+
/** The games the capture started, and when it began: what the run's GameLogs are found by (host/game-run-report.ts). */
|
|
63
|
+
readonly run: {
|
|
64
|
+
readonly games: readonly GameProcess[];
|
|
65
|
+
readonly startedAt?: string;
|
|
66
|
+
};
|
|
62
67
|
};
|
|
63
68
|
/** Captures each Shot in game, as above. */
|
|
64
69
|
export declare function captureShots(source: ShotsSource, shots: readonly Shot[], options: CaptureShotsOptions): Promise<CaptureShotsResult>;
|
package/dist/capture/shots.js
CHANGED
|
@@ -103,5 +103,5 @@ export async function captureShots(source, shots, options) {
|
|
|
103
103
|
const partial = planned.filter((shot) => !shot.whole).map(named);
|
|
104
104
|
const summary = tourSummary(`Captured ${frames.length} Shot${frames.length === 1 ? "" : "s"} in ${outputDir}`, result.end, missing, partial, { its: "rectangle", why: "too big for the camera, or at the map's edge" });
|
|
105
105
|
log(summary);
|
|
106
|
-
return { summary, end: result.end, shots: captured, frames, missing, partial, outputDir, copy };
|
|
106
|
+
return { summary, end: result.end, shots: captured, frames, missing, partial, outputDir, copy, run: { games: result.games, ...(result.startedAt ? { startedAt: result.startedAt } : {}) } };
|
|
107
107
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Host } from "../host/host.js";
|
|
2
|
-
import type { CaptureTourResult } from "../plugins/plugin-api.js";
|
|
2
|
+
import type { CaptureTourResult, GameProcess } from "../plugins/plugin-api.js";
|
|
3
3
|
import type { CaptureCopyOptions } from "./capture-copy.js";
|
|
4
4
|
/** A prefix (`capture-` by default) and the time in UTC, as the renders' folders are named. */
|
|
5
5
|
export declare function defaultName(now?: Date, prefix?: string): string;
|
|
@@ -25,6 +25,8 @@ export declare function runStopTour(host: Host, request: {
|
|
|
25
25
|
readonly signal?: AbortSignal;
|
|
26
26
|
}): Promise<CaptureTourResult & {
|
|
27
27
|
readonly copy: string;
|
|
28
|
+
readonly games: readonly GameProcess[];
|
|
29
|
+
readonly startedAt?: string;
|
|
28
30
|
}>;
|
|
29
31
|
/** Gives each stop's frame (the host names them by stop) its planned name: the frames' paths, null for a stop with none. */
|
|
30
32
|
export declare function nameFrames(outputDir: string, stops: readonly {
|
|
@@ -38,7 +38,7 @@ export async function runStopTour(host, request) {
|
|
|
38
38
|
settings: { frameDigits: 2, recordKeys: ["x", "y"], width: 1600, quality: 85, startSeconds: 300, pressSpaceAfterSeconds: 30 },
|
|
39
39
|
outputDir: request.outputDir,
|
|
40
40
|
}, { log: request.log, ...(request.onQueued ? { onQueued: request.onQueued } : {}), ...(request.signal ? { signal: request.signal } : {}) });
|
|
41
|
-
return { frames: result.frames, end: result.end, copy: result.copy };
|
|
41
|
+
return { frames: result.frames, end: result.end, copy: result.copy, games: result.games ?? [], ...(result.startedAt ? { startedAt: result.startedAt } : {}) };
|
|
42
42
|
}
|
|
43
43
|
/** Gives each stop's frame (the host names them by stop) its planned name: the frames' paths, null for a stop with none. */
|
|
44
44
|
export async function nameFrames(outputDir, stops) {
|