@wildshard/shard-format 0.18.0 → 0.19.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/shard-format",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "The raw shardfile format: the spec, the validator and a validate CLI. The public, versioned contract every other repo builds on.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -106,6 +106,7 @@
|
|
|
106
106
|
"./creatures": "./src/format/creatures.ts",
|
|
107
107
|
"./creaturePerch": "./src/format/creature-perch.ts",
|
|
108
108
|
"./creatureLayers": "./src/format/creature-layers.ts",
|
|
109
|
+
"./creatureVolumes": "./src/format/creature-volumes.ts",
|
|
109
110
|
"./creatureSkeletons": "./src/format/creature-skeletons.ts",
|
|
110
111
|
"./crowdPresentation": "./src/format/crowdPresentation.ts",
|
|
111
112
|
"./crowds": "./src/format/crowds.ts",
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
check,
|
|
3
|
+
exactOptional,
|
|
4
|
+
finite,
|
|
5
|
+
maxLength,
|
|
6
|
+
maxValue,
|
|
7
|
+
minValue,
|
|
8
|
+
number,
|
|
9
|
+
picklist,
|
|
10
|
+
pipe,
|
|
11
|
+
regex,
|
|
12
|
+
strictObject,
|
|
13
|
+
string,
|
|
14
|
+
} from 'valibot'
|
|
15
|
+
|
|
16
|
+
import { CREATURE_SKELETONS } from './creature-skeletons.ts'
|
|
17
|
+
import {
|
|
18
|
+
CreatureVolumesSchema,
|
|
19
|
+
CreatureLockSchema,
|
|
20
|
+
MAX_VOLUMES,
|
|
21
|
+
} from './creature-volumes.ts'
|
|
22
|
+
|
|
23
|
+
import type { CreatureSkeleton, CreatureSize } from './creature-layers.ts'
|
|
24
|
+
import type { CreatureVolume } from './creature-volumes.ts'
|
|
25
|
+
import type { GenericSchema } from 'valibot'
|
|
26
|
+
|
|
27
|
+
const ONE = 1
|
|
28
|
+
const MAX_SCALE = 10
|
|
29
|
+
const MAX_ID = 128
|
|
30
|
+
const id = pipe(string(), regex(/^[a-z][a-zA-Z0-9.:-]*$/u), maxLength(MAX_ID))
|
|
31
|
+
const scalar = pipe(number(), finite())
|
|
32
|
+
interface CreatureBody {
|
|
33
|
+
/** Omit for a GLB with its own rig; a kit poser names its contract explicitly. */
|
|
34
|
+
skeleton?: CreatureSkeleton
|
|
35
|
+
size: CreatureSize
|
|
36
|
+
scale: number
|
|
37
|
+
look: string
|
|
38
|
+
volumes?: CreatureVolume[]
|
|
39
|
+
lock?: string[]
|
|
40
|
+
hits?: 'rest' | 'clip'
|
|
41
|
+
}
|
|
42
|
+
const bodyObject = strictObject({
|
|
43
|
+
skeleton: exactOptional(
|
|
44
|
+
picklist(['quadruped', 'biped'], 'Unknown creature skeleton'),
|
|
45
|
+
),
|
|
46
|
+
size: picklist(
|
|
47
|
+
['tiny', 'small', 'medium', 'large', 'giant'],
|
|
48
|
+
'Unknown creature size',
|
|
49
|
+
),
|
|
50
|
+
scale: pipe(scalar, minValue(Number.MIN_VALUE), maxValue(MAX_SCALE)),
|
|
51
|
+
look: id,
|
|
52
|
+
volumes: exactOptional(CreatureVolumesSchema),
|
|
53
|
+
lock: exactOptional(CreatureLockSchema),
|
|
54
|
+
hits: exactOptional(picklist(['rest', 'clip'])),
|
|
55
|
+
})
|
|
56
|
+
const CreatureBodySchema: GenericSchema<CreatureBody> = pipe(
|
|
57
|
+
bodyObject,
|
|
58
|
+
check<CreatureBody, 'Only giants have multiple lock points or clip hits'>(
|
|
59
|
+
(body: {
|
|
60
|
+
readonly size: CreatureSize
|
|
61
|
+
readonly lock?: readonly string[]
|
|
62
|
+
readonly hits?: 'rest' | 'clip'
|
|
63
|
+
}): boolean =>
|
|
64
|
+
body.size === 'giant' ||
|
|
65
|
+
((body.lock?.length ?? ONE) <= ONE && body.hits !== 'clip'),
|
|
66
|
+
'Only giants have multiple lock points or clip hits',
|
|
67
|
+
),
|
|
68
|
+
check<CreatureBody, 'Too many resolved creature volumes'>(
|
|
69
|
+
(body: {
|
|
70
|
+
readonly skeleton?: CreatureSkeleton
|
|
71
|
+
readonly volumes?: readonly { readonly part: string }[]
|
|
72
|
+
}): boolean => {
|
|
73
|
+
const defaults =
|
|
74
|
+
body.skeleton === undefined
|
|
75
|
+
? []
|
|
76
|
+
: CREATURE_SKELETONS[body.skeleton].volumes
|
|
77
|
+
return (
|
|
78
|
+
new Set(
|
|
79
|
+
[...defaults, ...(body.volumes ?? [])].map(
|
|
80
|
+
(volume: { readonly part: string }): string => volume.part,
|
|
81
|
+
),
|
|
82
|
+
).size <= MAX_VOLUMES
|
|
83
|
+
)
|
|
84
|
+
},
|
|
85
|
+
'Too many resolved creature volumes',
|
|
86
|
+
),
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
export { CreatureBodySchema }
|
|
90
|
+
export type { CreatureBody }
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
|
|
23
23
|
import { HuntTuningSchema } from './speciesPrograms.ts'
|
|
24
24
|
|
|
25
|
+
import type { CreatureBody } from './creature-body.ts'
|
|
25
26
|
import type { SpeciesData } from './speciesPrograms.ts'
|
|
26
27
|
import type { GenericSchema } from 'valibot'
|
|
27
28
|
|
|
@@ -48,13 +49,6 @@ type CreatureTuningValue =
|
|
|
48
49
|
| Record<string, CreatureTuningScalar>
|
|
49
50
|
type CreatureTuning = Record<string, CreatureTuningValue>
|
|
50
51
|
|
|
51
|
-
interface CreatureBody {
|
|
52
|
-
/** Omit for a GLB with its own rig; a kit poser names its contract explicitly. */
|
|
53
|
-
skeleton?: CreatureSkeleton
|
|
54
|
-
size: CreatureSize
|
|
55
|
-
scale: number
|
|
56
|
-
look: string
|
|
57
|
-
}
|
|
58
52
|
/** The spawn supplies home position; these numbers control its return policy. */
|
|
59
53
|
interface CreatureTemperament {
|
|
60
54
|
brain: string
|
|
@@ -113,7 +107,6 @@ const MAX_RADIUS = 500
|
|
|
113
107
|
const MAX_SPEED = 15
|
|
114
108
|
const MAX_TIME = 86_400
|
|
115
109
|
const MAX_AMOUNT = 10_000_000
|
|
116
|
-
const MAX_SCALE = 10
|
|
117
110
|
const MAX_CALLS = 32
|
|
118
111
|
const MAX_TUNING_FIELDS = 64
|
|
119
112
|
|
|
@@ -167,17 +160,6 @@ const CreatureTypeSchema: GenericSchema<CreatureType> = picklist(
|
|
|
167
160
|
],
|
|
168
161
|
'Unknown creature type',
|
|
169
162
|
)
|
|
170
|
-
const CreatureBodySchema: GenericSchema<CreatureBody> = strictObject({
|
|
171
|
-
skeleton: exactOptional(
|
|
172
|
-
picklist(['quadruped', 'biped'], 'Unknown creature skeleton'),
|
|
173
|
-
),
|
|
174
|
-
size: picklist(
|
|
175
|
-
['tiny', 'small', 'medium', 'large', 'giant'],
|
|
176
|
-
'Unknown creature size',
|
|
177
|
-
),
|
|
178
|
-
scale: pipe(scalar, minValue(Number.MIN_VALUE), maxValue(MAX_SCALE)),
|
|
179
|
-
look: id,
|
|
180
|
-
})
|
|
181
163
|
const CreatureTemperamentSchema: GenericSchema<CreatureTemperament> =
|
|
182
164
|
strictObject({
|
|
183
165
|
brain: id,
|
|
@@ -239,7 +221,6 @@ const CreaturePresentationSchema: GenericSchema<CreaturePresentation> =
|
|
|
239
221
|
|
|
240
222
|
export {
|
|
241
223
|
CreatureTypeSchema,
|
|
242
|
-
CreatureBodySchema,
|
|
243
224
|
CreatureTemperamentSchema,
|
|
244
225
|
CreatureSensesSchema,
|
|
245
226
|
CreatureAbilitySchema,
|
|
@@ -250,7 +231,6 @@ export type {
|
|
|
250
231
|
CreatureSkeleton,
|
|
251
232
|
CreatureSize,
|
|
252
233
|
CreatureReaction,
|
|
253
|
-
CreatureBody,
|
|
254
234
|
CreatureTemperament,
|
|
255
235
|
CreatureSenses,
|
|
256
236
|
CreatureAbility,
|
|
@@ -260,3 +240,6 @@ export type {
|
|
|
260
240
|
CreatureTuningValue,
|
|
261
241
|
CreatureTuning,
|
|
262
242
|
}
|
|
243
|
+
|
|
244
|
+
export { CreatureBodySchema } from './creature-body.ts'
|
|
245
|
+
export type { CreatureBody } from './creature-body.ts'
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
array,
|
|
3
|
+
check,
|
|
4
|
+
exactOptional,
|
|
5
|
+
finite,
|
|
6
|
+
maxLength,
|
|
7
|
+
maxValue,
|
|
8
|
+
minLength,
|
|
9
|
+
minValue,
|
|
10
|
+
number,
|
|
11
|
+
picklist,
|
|
12
|
+
pipe,
|
|
13
|
+
regex,
|
|
14
|
+
strictObject,
|
|
15
|
+
string,
|
|
16
|
+
tuple,
|
|
17
|
+
} from 'valibot'
|
|
18
|
+
|
|
19
|
+
import type { SkeletonVolume } from './creature-skeletons.ts'
|
|
20
|
+
import type { GenericSchema } from 'valibot'
|
|
21
|
+
|
|
22
|
+
/** Bone-local rest offset. The runtime clamps the scaled radius, not the source. */
|
|
23
|
+
interface CreatureVolume extends SkeletonVolume {
|
|
24
|
+
at?: [number, number, number]
|
|
25
|
+
}
|
|
26
|
+
const ZERO = 0
|
|
27
|
+
const ONE = 1
|
|
28
|
+
const MAX_VOLUMES = 16
|
|
29
|
+
const MAX_NAME = 128
|
|
30
|
+
const MAX_EXTENT = 500
|
|
31
|
+
const MAX_MULTIPLIER = 100
|
|
32
|
+
const name = pipe(
|
|
33
|
+
string(),
|
|
34
|
+
regex(/^[a-zA-Z][a-zA-Z0-9_.:-]*$/u),
|
|
35
|
+
maxLength(MAX_NAME),
|
|
36
|
+
)
|
|
37
|
+
const scalar = pipe(number(), finite())
|
|
38
|
+
const extent = pipe(scalar, minValue(ZERO), maxValue(MAX_EXTENT))
|
|
39
|
+
const offset = pipe(scalar, minValue(-MAX_EXTENT), maxValue(MAX_EXTENT))
|
|
40
|
+
const volumeObject = strictObject({
|
|
41
|
+
part: name,
|
|
42
|
+
bone: name,
|
|
43
|
+
shape: picklist(['sphere', 'capsule']),
|
|
44
|
+
radius: pipe(scalar, minValue(Number.MIN_VALUE), maxValue(MAX_EXTENT)),
|
|
45
|
+
halfLength: extent,
|
|
46
|
+
axis: picklist(['y', 'z']),
|
|
47
|
+
multiplier: pipe(scalar, minValue(ZERO), maxValue(MAX_MULTIPLIER)),
|
|
48
|
+
at: exactOptional(tuple([offset, offset, offset])),
|
|
49
|
+
})
|
|
50
|
+
const CreatureVolumeSchema: GenericSchema<CreatureVolume> = pipe(
|
|
51
|
+
volumeObject,
|
|
52
|
+
check<CreatureVolume, 'A sphere has zero halfLength'>(
|
|
53
|
+
(row: Readonly<Pick<CreatureVolume, 'shape' | 'halfLength'>>): boolean =>
|
|
54
|
+
row.shape !== 'sphere' || row.halfLength === ZERO,
|
|
55
|
+
'A sphere has zero halfLength',
|
|
56
|
+
),
|
|
57
|
+
)
|
|
58
|
+
const CreatureVolumesSchema: GenericSchema<CreatureVolume[]> = pipe(
|
|
59
|
+
array(CreatureVolumeSchema),
|
|
60
|
+
minLength(ONE),
|
|
61
|
+
maxLength(MAX_VOLUMES),
|
|
62
|
+
check<CreatureVolume[], 'Duplicate creature volume part'>(
|
|
63
|
+
(rows: readonly { readonly part: string }[]): boolean =>
|
|
64
|
+
new Set(rows.map((row: { readonly part: string }): string => row.part))
|
|
65
|
+
.size === rows.length,
|
|
66
|
+
'Duplicate creature volume part',
|
|
67
|
+
),
|
|
68
|
+
)
|
|
69
|
+
const CreatureLockSchema: GenericSchema<string[]> = pipe(
|
|
70
|
+
array(name),
|
|
71
|
+
minLength(ONE),
|
|
72
|
+
maxLength(MAX_VOLUMES),
|
|
73
|
+
check<string[], 'Duplicate creature lock point'>(
|
|
74
|
+
(rows: readonly string[]): boolean => new Set(rows).size === rows.length,
|
|
75
|
+
'Duplicate creature lock point',
|
|
76
|
+
),
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
CreatureVolumeSchema,
|
|
81
|
+
CreatureVolumesSchema,
|
|
82
|
+
CreatureLockSchema,
|
|
83
|
+
MAX_VOLUMES,
|
|
84
|
+
}
|
|
85
|
+
export type { CreatureVolume }
|
|
@@ -6,11 +6,13 @@ const time = bounded(0, 3600);
|
|
|
6
6
|
const point = v.tuple([bounded(-250, 250), bounded(-250, 250), bounded(-250, 250)]);
|
|
7
7
|
const rotation = v.pipe(v.tuple([finite, finite, finite, finite]), v.check(q => Math.abs(Math.hypot(...q) - 1) < 1e-5));
|
|
8
8
|
/** Fixed driver identities preserve their guest ABI and continuation across row migrations. */
|
|
9
|
-
export const MOVER_DRIVER_MODULES: Readonly<{ ride: "f8f90ba2e03401910448a2af1e8b02420bc7b2e1003076bc6241d9cb0c688a22"; hinge: "1371d8959aebb567404fc8db59592b0d63f7afeb7060f0b74ea4f12389e6bafd"; waves: "9a5171bc3dd84488aae9de29ebd07fdb12dfbd2500c45cf91cf37e5bbbc712f0"; clip: "871aef47d9b0dd009d46ad41e5cb3c793625bc20325bdaca00134a8677b0c6f1"; }> = Object.freeze({
|
|
9
|
+
export const MOVER_DRIVER_MODULES: Readonly<{ ride: "f8f90ba2e03401910448a2af1e8b02420bc7b2e1003076bc6241d9cb0c688a22"; hinge: "1371d8959aebb567404fc8db59592b0d63f7afeb7060f0b74ea4f12389e6bafd"; waves: "9a5171bc3dd84488aae9de29ebd07fdb12dfbd2500c45cf91cf37e5bbbc712f0"; clip: "871aef47d9b0dd009d46ad41e5cb3c793625bc20325bdaca00134a8677b0c6f1"; steer: "d7ee08f609c5a350692fba79d47d5aa6bebd14d324f955a5ba20b52c603e9270"; }> = Object.freeze({
|
|
10
10
|
ride: 'f8f90ba2e03401910448a2af1e8b02420bc7b2e1003076bc6241d9cb0c688a22',
|
|
11
11
|
hinge: '1371d8959aebb567404fc8db59592b0d63f7afeb7060f0b74ea4f12389e6bafd',
|
|
12
12
|
waves: '9a5171bc3dd84488aae9de29ebd07fdb12dfbd2500c45cf91cf37e5bbbc712f0',
|
|
13
13
|
clip: '871aef47d9b0dd009d46ad41e5cb3c793625bc20325bdaca00134a8677b0c6f1',
|
|
14
|
+
/** Native only (SS-MS2a1): no guest module carries it; the identity is sha256 of "wildshard mover driver steer v1". */
|
|
15
|
+
steer: 'd7ee08f609c5a350692fba79d47d5aa6bebd14d324f955a5ba20b52c603e9270',
|
|
14
16
|
});
|
|
15
17
|
/** Bounded real transform keys; both channels share their strictly increasing time grid. */
|
|
16
18
|
export const MoverTrackSchema: v.GenericSchema<MoverTrackRowsInput, MoverTrackRows> = v.pipe(v.strictObject({
|
|
@@ -30,6 +32,13 @@ export const MoverTriggerSchema: v.GenericSchema<MoverTriggerRowsInput, MoverTri
|
|
|
30
32
|
v.strictObject({ kind: v.literal('shared'), field: v.pipe(finite, v.integer(), v.minValue(1), v.maxValue(0x7fffffff)), equals: v.union([v.boolean(), finite]) }),
|
|
31
33
|
]);
|
|
32
34
|
const wave = v.tuple([bounded(-1, 1), bounded(-1, 1), bounded(0, 10), bounded(0.005, 1000), bounded(-100, 100), bounded(0, 10)]);
|
|
35
|
+
/** SS-MS2a1 steer bounds: top speed m/s, turn rad/s, boost multiplier, acceleration m/s²; the least is the format's 0.005. */
|
|
36
|
+
const STEER_ACCEL_MAX = 100;
|
|
37
|
+
const STEER_BOOST_MAX = 4;
|
|
38
|
+
const STEER_BOOST_MIN = 1;
|
|
39
|
+
const STEER_LEAST = 0.005;
|
|
40
|
+
const STEER_SPEED_MAX = 60;
|
|
41
|
+
const STEER_TURN_MAX = Math.PI + Math.PI;
|
|
33
42
|
/** Numeric fixed policies compiled to the session's existing fenced guest driver. */
|
|
34
43
|
export const MoverDriverSchema: v.GenericSchema<MoverDriverRowsInput, MoverDriverRows> = v.variant('kind', [
|
|
35
44
|
v.strictObject({ kind: v.literal('waves'), damping: bounded(0, 1), waves: v.tuple([wave, wave, wave, wave]) }),
|
|
@@ -39,6 +48,9 @@ export const MoverDriverSchema: v.GenericSchema<MoverDriverRowsInput, MoverDrive
|
|
|
39
48
|
v.strictObject({ kind: v.literal('static') }),
|
|
40
49
|
v.strictObject({ kind: v.literal('track') }),
|
|
41
50
|
v.strictObject({ kind: v.literal('pendulum'), axis: v.picklist(['x', 'y', 'z']), amplitude: bounded(0, Math.PI), period: bounded(0.005, 3600) }),
|
|
51
|
+
// SS-MS2a1: a vehicle its rider steers. Top speed (m/s), turn rate (rad/s), the boost multiplier, acceleration (m/s²),
|
|
52
|
+
// and whether it follows the ground under it or keeps its rest height. Board and leave are its carry's prompts.
|
|
53
|
+
v.strictObject({ kind: v.literal('steer'), speed: bounded(STEER_LEAST, STEER_SPEED_MAX), turn: bounded(STEER_LEAST, STEER_TURN_MAX), boost: bounded(STEER_BOOST_MIN, STEER_BOOST_MAX), accel: bounded(STEER_LEAST, STEER_ACCEL_MAX), ground: v.boolean() }),
|
|
42
54
|
]);
|
|
43
55
|
/** Stop track, activation and fixed driver before ABI lowering. */
|
|
44
56
|
export const MoverMotionSchema: v.GenericSchema<MoverMotionRowsInput, MoverMotionRows> = v.strictObject({
|
|
@@ -85,6 +97,10 @@ export function lowerMoverMotion(input: unknown, rest: { at: { x: number; y: num
|
|
|
85
97
|
if (trigger.kind !== 'always' || track !== undefined) throw new Error('Waves require an always trigger without a clip');
|
|
86
98
|
return { module: MOVER_DRIVER_MODULES.waves, input: [rest.at.x, rest.at.y, rest.at.z, rest.euler.y, driver.damping, ...driver.waves.flat()] };
|
|
87
99
|
}
|
|
100
|
+
if (driver.kind === 'steer') {
|
|
101
|
+
if (trigger.kind !== 'interact' || Boolean(trigger.permission) || track !== undefined) { throw new Error('Steer driver requires an ungated board press without a clip'); }
|
|
102
|
+
return { module: MOVER_DRIVER_MODULES.steer, input: [driver.speed, driver.turn, driver.boost, driver.accel, Number(driver.ground), rest.at.x, rest.at.y, rest.at.z, rest.euler.y] };
|
|
103
|
+
}
|
|
88
104
|
if (driver.kind === 'static') {
|
|
89
105
|
if (trigger.kind !== 'always' || track !== undefined) throw new Error('Static mover cannot consume a clip or interaction');
|
|
90
106
|
return { module: MOVER_DRIVER_MODULES.hinge, input: [0] };
|
|
@@ -197,6 +213,13 @@ export type MoverDriverRows = ({
|
|
|
197
213
|
axis: 'x' | 'y' | 'z';
|
|
198
214
|
amplitude: number;
|
|
199
215
|
period: number;
|
|
216
|
+
}) | ({
|
|
217
|
+
kind: 'steer';
|
|
218
|
+
speed: number;
|
|
219
|
+
turn: number;
|
|
220
|
+
boost: number;
|
|
221
|
+
accel: number;
|
|
222
|
+
ground: boolean;
|
|
200
223
|
});
|
|
201
224
|
interface MoverMotionRowsInputFields {
|
|
202
225
|
track?: MoverTrackRowsInput;
|
package/src/format/movers.ts
CHANGED
|
@@ -25,7 +25,8 @@ export function parseMovers(input: unknown): MoverData {
|
|
|
25
25
|
if (m.kind === 'chain' ? m.chain === undefined || m.boxes.length > 0 : m.chain !== undefined || (m.kind === 'channel' ? m.boxes.length > 0 : m.boxes.length === 0)) throw new Error('Mover primitive shape');
|
|
26
26
|
if (m.execution === 'native' && (m.driver === undefined || m.trigger === undefined)) throw new Error('Native mover requires admitted motion');
|
|
27
27
|
if (m.kind === 'channel' && m.driver?.kind !== 'track' && m.carry === undefined) throw new Error('Channel mover requires its declared track');
|
|
28
|
-
if (m.carry !== undefined && (m.execution !== 'native' || m.kind !== 'channel' || m.driver?.kind !== 'winch' || m.driver.mode !== 'ride' || m.driver.return !== 'command' || m.driver.gate)) throw new Error('Carry requires an admitted native command path');
|
|
28
|
+
if (m.carry !== undefined && (m.execution !== 'native' || m.kind !== 'channel' || (m.driver?.kind !== 'steer' && (m.driver?.kind !== 'winch' || m.driver.mode !== 'ride' || m.driver.return !== 'command' || m.driver.gate)))) { throw new Error('Carry requires an admitted native command path'); }
|
|
29
|
+
if (m.driver?.kind === 'steer' && (m.carry === undefined || m.execution !== 'native')) { throw new Error('A steer driver is a native carry'); }
|
|
29
30
|
if (m.execution !== 'native' && m.driver?.kind === 'winch' && m.driver.mode === 'ride' && (m.driver.return !== undefined || m.driver.ease !== undefined || m.driver.snap !== undefined)) throw new Error('Guest mover cannot accept native path tuning');
|
|
30
31
|
if (m.restoreFrom !== undefined && (m.atEnd?.field !== 5 || m.atEnd.equals !== 1 || m.track?.loop !== 'once'
|
|
31
32
|
|| !(m.driver?.kind === 'track' || m.driver?.kind === 'winch' && m.driver.mode === 'hinge'))) throw new Error('Mover restore requires an admitted one-shot endpoint');
|
package/src/format/quests.ts
CHANGED
|
@@ -23,7 +23,11 @@ const RACE_CAP_MAX_S = 3600;
|
|
|
23
23
|
const RACE_CAP_MIN_S = 1;
|
|
24
24
|
const RACES_MAX = 32;
|
|
25
25
|
const raceCap = v.pipe(finite, v.safeInteger(), v.minValue(RACE_CAP_MIN_S), v.maxValue(RACE_CAP_MAX_S));
|
|
26
|
-
|
|
26
|
+
/** Flags a run's finish and a lapse lower beside `start` and `stop`, so the next run counts them again (a gate line's middle gates). */
|
|
27
|
+
const RACE_RESETS_MAX = 64;
|
|
28
|
+
const RACE_RESETS_MIN = 1;
|
|
29
|
+
const raceResets = v.pipe(v.array(id), v.minLength(RACE_RESETS_MIN), v.maxLength(RACE_RESETS_MAX));
|
|
30
|
+
const race = v.strictObject({ id, start: id, stop: id, fact: id, cap: raceCap, resets: v.exactOptional(raceResets) });
|
|
27
31
|
const raceRows = v.pipe(v.array(race), v.maxLength(RACES_MAX));
|
|
28
32
|
const raceList = v.exactOptional(raceRows);
|
|
29
33
|
const choice = v.strictObject({ id, label: text, next: v.nullable(id), when: v.exactOptional(condition), sets: v.exactOptional(names), scene: v.exactOptional(id) });
|
|
@@ -50,8 +54,9 @@ export function questDataRules(data: QuestData): string[] {
|
|
|
50
54
|
for (const t of data.triggers) checkFlags([t.flag, ...reads(t.when)]);
|
|
51
55
|
const raceIds: string[] = [];
|
|
52
56
|
for (const run of data.races ?? []) {
|
|
53
|
-
raceIds.push(run.id); checkFlags([run.start, run.stop]);
|
|
57
|
+
raceIds.push(run.id); checkFlags([run.start, run.stop, ...(run.resets ?? [])]);
|
|
54
58
|
if (run.start === run.stop) { errors.push(`race ${run.id} starts and stops on one flag`); }
|
|
59
|
+
if (run.resets?.some((flag): boolean => flag === run.start || flag === run.stop) === true) { errors.push(`race ${run.id} resets its own start or stop`); }
|
|
55
60
|
}
|
|
56
61
|
unique(raceIds);
|
|
57
62
|
for (const d of data.dialogue) {
|
|
@@ -190,6 +195,7 @@ interface QuestDataInputFields {
|
|
|
190
195
|
stop: string;
|
|
191
196
|
fact: string;
|
|
192
197
|
cap: number;
|
|
198
|
+
resets?: (string)[];
|
|
193
199
|
})[];
|
|
194
200
|
dialogue: ({
|
|
195
201
|
id: string;
|
|
@@ -332,6 +338,7 @@ interface QuestDataFields {
|
|
|
332
338
|
stop: string;
|
|
333
339
|
fact: string;
|
|
334
340
|
cap: number;
|
|
341
|
+
resets?: (string)[];
|
|
335
342
|
})[];
|
|
336
343
|
dialogue: ({
|
|
337
344
|
id: string;
|