@wildshard/shard-format 0.26.0 → 0.28.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 +3 -1
- package/src/format/actorMoves.ts +32 -0
- package/src/format/audio-mp4.ts +1 -1
- package/src/format/audioProfiles.ts +1 -1
- package/src/format/brains.ts +3 -3
- package/src/format/builtIndexes.ts +2 -2
- package/src/format/clientChannels.ts +3 -3
- package/src/format/clientScripts.ts +1 -1
- package/src/format/contentBounds.ts +1 -1
- package/src/format/creature-layers.ts +44 -1
- package/src/format/creature-projectile.ts +32 -0
- package/src/format/creature-ranks.ts +37 -0
- package/src/format/creature-sizes.ts +45 -4
- package/src/format/creature-volumes.ts +5 -4
- package/src/format/creatures.ts +20 -3
- package/src/format/crowds.ts +1 -1
- package/src/format/deviceMemoryCost.ts +2 -2
- package/src/format/directorStages.ts +3 -3
- package/src/format/flyers.ts +2 -2
- package/src/format/grazers.ts +2 -2
- package/src/format/items.ts +1 -1
- package/src/format/materialGraph.ts +7 -7
- package/src/format/materials.ts +10 -10
- package/src/format/memoryAdmission.ts +1 -1
- package/src/format/namedJsonContracts.ts +1 -1
- package/src/format/nativeGround.ts +3 -3
- package/src/format/navigation.ts +2 -2
- package/src/format/parsed-json.ts +91 -0
- package/src/format/placement-page-text.ts +281 -0
- package/src/format/questHost.ts +1 -1
- package/src/format/rows.ts +18 -5
- package/src/format/runtime-tier.ts +56 -0
- package/src/format/runtimeBinds.ts +6 -6
- package/src/format/runtimeCost.ts +1 -1
- package/src/format/runtimeSpawns.ts +2 -2
- package/src/format/scaledPostContract.ts +2 -2
- package/src/format/scriptAbi.ts +1 -1
- package/src/format/scriptWireV2.ts +1 -1
- package/src/format/shardSchema.ts +2 -2
- package/src/format/shardfile-assets.ts +1 -1
- package/src/format/shardfileValidation.ts +2 -1
- package/src/format/skin-file.ts +3 -0
- package/src/format/skinData.ts +39 -19
- package/src/format/skins.ts +21 -2
- package/src/format/sourceResidency.ts +1 -1
- package/src/format/spawnCombat.ts +10 -5
- package/src/format/standalone-catalogue.ts +1 -1
- package/src/format/terrain.ts +1 -1
- package/src/format/validationReceipt.ts +2 -2
- package/src/format/weaponProfiles.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/shard-format",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.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": {
|
|
@@ -305,6 +305,7 @@
|
|
|
305
305
|
"./rows": "./src/format/rows.ts",
|
|
306
306
|
"./runtime": "./src/format/runtime.ts",
|
|
307
307
|
"./runtimeBinds": "./src/format/runtimeBinds.ts",
|
|
308
|
+
"./runtime-tier": "./src/format/runtime-tier.ts",
|
|
308
309
|
"./runtimeCost": "./src/format/runtimeCost.ts",
|
|
309
310
|
"./runtimeSpawns": "./src/format/runtimeSpawns.ts",
|
|
310
311
|
"./scalarChannel": "./src/format/scalarChannel.ts",
|
|
@@ -406,6 +407,7 @@
|
|
|
406
407
|
"./worldSceneModels": "./src/format/worldSceneModels.ts",
|
|
407
408
|
"./worldScenePages": "./src/format/worldScenePages.ts",
|
|
408
409
|
"./worldScenePlacement": "./src/format/worldScenePlacement.ts",
|
|
410
|
+
"./placement-page-text": "./src/format/placement-page-text.ts",
|
|
409
411
|
"./worldSceneSlabs": "./src/format/worldSceneSlabs.ts",
|
|
410
412
|
"./worldSceneSurface": "./src/format/worldSceneSurface.ts",
|
|
411
413
|
"./worldSceneWeld": "./src/format/worldSceneWeld.ts",
|
package/src/format/actorMoves.ts
CHANGED
|
@@ -11,6 +11,14 @@ const turn = v.pipe(radius, v.maxValue(30));
|
|
|
11
11
|
const seconds = v.pipe(positive, v.maxValue(600));
|
|
12
12
|
const angle = v.pipe(finite, v.minValue(-2 * Math.PI), v.maxValue(2 * Math.PI));
|
|
13
13
|
const motion = { speed, turn, ground: v.optional(v.boolean(), false) };
|
|
14
|
+
/** CC17 leap: an arc to the target or a spot, peaking `height` metres above the start; `gravity` sets the time aloft. */
|
|
15
|
+
const LEAP_LIMIT = 100;
|
|
16
|
+
const EARTH_GRAVITY = 9.81;
|
|
17
|
+
const leapBound = v.pipe(positive, v.maxValue(LEAP_LIMIT));
|
|
18
|
+
const leapTarget = v.strictObject({ kind: v.literal('target') });
|
|
19
|
+
const leapSpot = v.strictObject({ kind: v.literal('spot'), spot: id });
|
|
20
|
+
const leapPoint = v.variant('kind', [leapTarget, leapSpot]);
|
|
21
|
+
const leap = v.strictObject({ id, kind: v.literal('leap'), to: leapPoint, height: leapBound, gravity: v.optional(leapBound, EARTH_GRAVITY) });
|
|
14
22
|
const ready = v.variant('kind', [
|
|
15
23
|
v.strictObject({ kind: v.literal('over'), radius: positive, height: positive }),
|
|
16
24
|
v.strictObject({ kind: v.literal('band'), tolerance: positive }),
|
|
@@ -41,6 +49,7 @@ export const ActorMoveSchema: v.GenericSchema<ActorMoveInput, ActorMove> = v.var
|
|
|
41
49
|
angularSpeed: v.optional(v.pipe(finite, v.minValue(-30), v.maxValue(30)), 0), closeRadius: v.optional(radius, 0), stopDistance: v.optional(radius, 0) }),
|
|
42
50
|
v.strictObject({ id, kind: v.literal('burrow'), field: id, rate: positive }),
|
|
43
51
|
v.strictObject({ id, kind: v.literal('surface'), field: id, rate: positive }),
|
|
52
|
+
leap,
|
|
44
53
|
]);
|
|
45
54
|
/** Plain `actors/moves` section, bounded and uniquely named. */
|
|
46
55
|
export const ActorMovesSchema: v.GenericSchema<unknown, ActorMoves> = v.pipe(v.unknown(), v.check(isJsonData, 'plain JSON move data'), v.array(ActorMoveSchema), v.maxLength(256),
|
|
@@ -62,6 +71,7 @@ export function actorMoveRules(rows: readonly ActorMove[], refs: { spots: Readon
|
|
|
62
71
|
if (row.kind === 'stalk' && row.ready.kind === 'range' && row.ready.strike !== undefined && !refs.strikes.has(row.ready.strike)) failures.add('move range resolves in actors/strikes');
|
|
63
72
|
if (row.kind === 'dive' && row.strike !== undefined && !refs.strikes.has(row.strike)) failures.add('move strike resolves in actors/strikes');
|
|
64
73
|
if ((row.kind === 'burrow' || row.kind === 'surface') && !refs.fields.has(row.field)) failures.add('move field resolves in declared actor fields');
|
|
74
|
+
if (row.kind === 'leap' && row.to.kind === 'spot' && !refs.spots.has(row.to.spot)) { failures.add('move location resolves in world spots'); }
|
|
65
75
|
}
|
|
66
76
|
return [...failures];
|
|
67
77
|
}
|
|
@@ -339,6 +349,17 @@ export type ActorMoveInput = (Omit<Omit<{
|
|
|
339
349
|
kind: 'surface';
|
|
340
350
|
field: string;
|
|
341
351
|
rate: number;
|
|
352
|
+
}) | ({
|
|
353
|
+
id: string;
|
|
354
|
+
kind: 'leap';
|
|
355
|
+
to: ({
|
|
356
|
+
kind: 'target';
|
|
357
|
+
}) | ({
|
|
358
|
+
kind: 'spot';
|
|
359
|
+
spot: string;
|
|
360
|
+
});
|
|
361
|
+
height: number;
|
|
362
|
+
gravity?: number | undefined;
|
|
342
363
|
});
|
|
343
364
|
export type ActorMove = (Omit<Omit<{
|
|
344
365
|
id: string;
|
|
@@ -612,4 +633,15 @@ export type ActorMove = (Omit<Omit<{
|
|
|
612
633
|
kind: 'surface';
|
|
613
634
|
field: string;
|
|
614
635
|
rate: number;
|
|
636
|
+
}) | ({
|
|
637
|
+
id: string;
|
|
638
|
+
kind: 'leap';
|
|
639
|
+
to: ({
|
|
640
|
+
kind: 'target';
|
|
641
|
+
}) | ({
|
|
642
|
+
kind: 'spot';
|
|
643
|
+
spot: string;
|
|
644
|
+
});
|
|
645
|
+
height: number;
|
|
646
|
+
gravity: number;
|
|
615
647
|
});
|
package/src/format/audio-mp4.ts
CHANGED
|
@@ -162,7 +162,7 @@ function mediaSeconds(source: Readonly<Bytes>, mdhd: number): number {
|
|
|
162
162
|
return scale === NONE ? NONE : frames / scale
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
/** The packet count and bytes from `stsz`; a count is never
|
|
165
|
+
/** The packet count and bytes from `stsz`; a count is never host-owned past the box's own bytes. */
|
|
166
166
|
function packets(
|
|
167
167
|
source: Readonly<Bytes>,
|
|
168
168
|
stsz: number,
|
|
@@ -289,7 +289,7 @@ export interface AudioAmbienceRouting { probes?: ({ kind: 'bounds'; id: string;
|
|
|
289
289
|
prewarmMissing?: boolean; list: { id: string; ir: string; weight: string; level: AudioMixExpr; feeds?:
|
|
290
290
|
string[]; }[]; }; zoneNames: string[]; samples?: { startDelay: number; tap: string; beds: { id: string; out:
|
|
291
291
|
string; panned: boolean; }[]; }; activeGains?: [ string, string | number ][]; }
|
|
292
|
-
/** Bounded zone/mixer data. Terrain, moving emitters and bespoke synthesis remain
|
|
292
|
+
/** Bounded zone/mixer data. Terrain, moving emitters and bespoke synthesis remain native runtime ports. */
|
|
293
293
|
/** Sampled loop levels and seeded distant calls; native mixers own playback. */
|
|
294
294
|
const sampleInterval = v.pipe(v.tuple([v.pipe(finite,v.minValue(0),v.maxValue(600)),v.pipe(finite,v.minValue(0),v.maxValue(600))]),v.check(row=>row[0]<=row[1]));
|
|
295
295
|
export const AudioSampleMixSchema: v.GenericSchema<AudioSampleMix> = v.pipe(v.strictObject({
|
package/src/format/brains.ts
CHANGED
|
@@ -31,10 +31,10 @@ export const ScriptBrainSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<
|
|
|
31
31
|
}), v.check(row => new Set(row.strikes.map(strike => strike.event)).size === row.strikes.length, 'Unique declared brain strike events'));
|
|
32
32
|
/** Validated script policy; only named admitted strikes may be requested and motion stays within its declared bounds. */
|
|
33
33
|
|
|
34
|
-
/** Validate a custom policy before module admission,
|
|
34
|
+
/** Validate a custom policy before module admission, native actor binding or physics allocation. */
|
|
35
35
|
export function parseScriptBrain(data: unknown): ShardScriptBrain { return v.parse(ScriptBrainSchema, data); }
|
|
36
36
|
|
|
37
|
-
/** Interior guardian policy; native floor and rise/sink recipes publish completion through
|
|
37
|
+
/** Interior guardian policy; native floor and rise/sink recipes publish completion through native ports. */
|
|
38
38
|
export const GuardianSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{ readonly id: v.GenericSchema<ShardGuardianInput['id'], ShardGuardian['id']>; readonly kind: v.GenericSchema<ShardGuardianInput['kind'], ShardGuardian['kind']>; readonly thinkDivisor: v.OptionalSchema<v.GenericSchema<Exclude<ShardGuardianInput['thinkDivisor'], undefined>, Exclude<ShardGuardian['thinkDivisor'], undefined>>, 6>; readonly wakeRadius: v.GenericSchema<ShardGuardianInput['wakeRadius'], ShardGuardian['wakeRadius']>; readonly guardRadius: v.GenericSchema<ShardGuardianInput['guardRadius'], ShardGuardian['guardRadius']>; readonly approachRadius: v.GenericSchema<ShardGuardianInput['approachRadius'], ShardGuardian['approachRadius']>; readonly swingRadius: v.GenericSchema<ShardGuardianInput['swingRadius'], ShardGuardian['swingRadius']>; readonly swingDuration: v.GenericSchema<ShardGuardianInput['swingDuration'], ShardGuardian['swingDuration']>; readonly speed: v.GenericSchema<ShardGuardianInput['speed'], ShardGuardian['speed']>; readonly holdRadius: v.GenericSchema<ShardGuardianInput['holdRadius'], ShardGuardian['holdRadius']>; readonly sideSpeed: v.GenericSchema<ShardGuardianInput['sideSpeed'], ShardGuardian['sideSpeed']>; readonly sideFlipSeconds: v.GenericSchema<ShardGuardianInput['sideFlipSeconds'], ShardGuardian['sideFlipSeconds']>; readonly sinkAfterSeconds: v.GenericSchema<ShardGuardianInput['sinkAfterSeconds'], ShardGuardian['sinkAfterSeconds']>; readonly cooldownSeconds: v.GenericSchema<ShardGuardianInput['cooldownSeconds'], ShardGuardian['cooldownSeconds']>; readonly hideOffset: v.GenericSchema<ShardGuardianInput['hideOffset'], ShardGuardian['hideOffset']>; readonly noticeCue: v.GenericSchema<ShardGuardianInput['noticeCue'], ShardGuardian['noticeCue']>; }, undefined>, v.CheckAction<{ [K in keyof ShardGuardian]: ShardGuardian[K] }, 'Ordered guardian radii'>]> = v.pipe(v.strictObject({
|
|
39
39
|
id: key, kind: v.literal('guardian'), thinkDivisor: cadence, wakeRadius: radius, guardRadius: radius, approachRadius: radius,
|
|
40
40
|
swingRadius: radius, swingDuration: v.pipe(duration, v.minValue(Number.MIN_VALUE)),
|
|
@@ -48,7 +48,7 @@ export const GuardianSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{ r
|
|
|
48
48
|
/** Validate guardian decisions before selecting the existing native motion and strike recipes. */
|
|
49
49
|
export function parseGuardian(data: unknown): ShardGuardian { return v.parse(GuardianSchema, data); }
|
|
50
50
|
|
|
51
|
-
/** Perch hunting decisions; native perch selection, vertical completion and shared attack RNG remain
|
|
51
|
+
/** Perch hunting decisions; native perch selection, vertical completion and shared attack RNG remain native host ports. */
|
|
52
52
|
export const PerchHunterSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{ readonly id: v.GenericSchema<ShardPerchHunterInput['id'], ShardPerchHunter['id']>; readonly kind: v.GenericSchema<ShardPerchHunterInput['kind'], ShardPerchHunter['kind']>; readonly thinkDivisor: v.OptionalSchema<v.GenericSchema<Exclude<ShardPerchHunterInput['thinkDivisor'], undefined>, Exclude<ShardPerchHunter['thinkDivisor'], undefined>>, 6>; readonly throwRadius: v.GenericSchema<ShardPerchHunterInput['throwRadius'], ShardPerchHunter['throwRadius']>; readonly throwDuration: v.GenericSchema<ShardPerchHunterInput['throwDuration'], ShardPerchHunter['throwDuration']>; readonly biteRadius: v.GenericSchema<ShardPerchHunterInput['biteRadius'], ShardPerchHunter['biteRadius']>; readonly biteDuration: v.GenericSchema<ShardPerchHunterInput['biteDuration'], ShardPerchHunter['biteDuration']>; readonly underRadius: v.GenericSchema<ShardPerchHunterInput['underRadius'], ShardPerchHunter['underRadius']>; readonly underSeconds: v.GenericSchema<ShardPerchHunterInput['underSeconds'], ShardPerchHunter['underSeconds']>; readonly holdRadius: v.GenericSchema<ShardPerchHunterInput['holdRadius'], ShardPerchHunter['holdRadius']>; readonly runSpeed: v.GenericSchema<ShardPerchHunterInput['runSpeed'], ShardPerchHunter['runSpeed']>; readonly activeGroundSeconds: v.GenericSchema<ShardPerchHunterInput['activeGroundSeconds'], ShardPerchHunter['activeGroundSeconds']>; readonly biteCooldown: v.GenericSchema<ShardPerchHunterInput['biteCooldown'], ShardPerchHunter['biteCooldown']>; readonly throwCooldownMin: v.GenericSchema<ShardPerchHunterInput['throwCooldownMin'], ShardPerchHunter['throwCooldownMin']>; readonly throwCooldownMax: v.GenericSchema<ShardPerchHunterInput['throwCooldownMax'], ShardPerchHunter['throwCooldownMax']>; readonly alertCue: v.GenericSchema<ShardPerchHunterInput['alertCue'], ShardPerchHunter['alertCue']>; readonly noticeCue: v.GenericSchema<ShardPerchHunterInput['noticeCue'], ShardPerchHunter['noticeCue']>; }, undefined>, v.CheckAction<{ [K in keyof ShardPerchHunter]: ShardPerchHunter[K] }, 'Ordered perch attack ranges and cooldowns'>]> = v.pipe(v.strictObject({
|
|
53
53
|
id: key, kind: v.literal('perch-hunter'), thinkDivisor: cadence, throwRadius: radius, throwDuration: v.pipe(duration, v.minValue(Number.MIN_VALUE)),
|
|
54
54
|
biteRadius: radius, biteDuration: v.pipe(duration, v.minValue(Number.MIN_VALUE)), underRadius: radius, underSeconds: duration,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare const __SHARDFILE_VERDICTS__: unknown;
|
|
2
2
|
|
|
3
|
-
/** Build-owned address for one
|
|
3
|
+
/** Build-owned address for one built-in index. The complete digest remains
|
|
4
4
|
* admission authority; its short URL version is only a cache identity. */
|
|
5
5
|
export function builtIndexHash(path: string): string | null {
|
|
6
6
|
const rows: unknown = typeof __SHARDFILE_VERDICTS__ === 'object' ? __SHARDFILE_VERDICTS__ : null;
|
|
@@ -16,7 +16,7 @@ export function builtIndexHash(path: string): string | null {
|
|
|
16
16
|
return found;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
/** The exact
|
|
19
|
+
/** The exact built-in index hashes this client build validated; null for an unbundled client or a build with none. */
|
|
20
20
|
export function builtIndexHashes(): ReadonlySet<string> | null {
|
|
21
21
|
const rows: unknown = typeof __SHARDFILE_VERDICTS__ === 'object' ? __SHARDFILE_VERDICTS__ : null;
|
|
22
22
|
if (!Array.isArray(rows)) return null;
|
|
@@ -171,14 +171,14 @@ function listOk(rows: readonly ClientChannelProgram[]): boolean {
|
|
|
171
171
|
}
|
|
172
172
|
/** Visual property identity, never an authoritative player or shared field. */
|
|
173
173
|
|
|
174
|
-
/** Strictly parse detached author data before the
|
|
174
|
+
/** Strictly parse detached author data before the native view owner binds it. */
|
|
175
175
|
export function parseClientChannels(input: unknown): ClientChannelProgram[] { return v.parse(ClientChannelsSchema, input); }
|
|
176
176
|
|
|
177
177
|
/** Bounded read-only numeric capabilities for a privately owned playback group. */
|
|
178
|
-
/** Admit only bounded paths;
|
|
178
|
+
/** Admit only bounded paths; native owners are supplied separately and are never writable channels. */
|
|
179
179
|
export function parseClientChannelInputs(input: unknown): v.InferOutput<typeof numericInputs> { return v.parse(numericInputs, input); }
|
|
180
180
|
|
|
181
|
-
/** Data-only private scene construction: geometry, textures and graph materials stay in
|
|
181
|
+
/** Data-only private scene construction: geometry, textures and graph materials stay in host-owned owned ports. */
|
|
182
182
|
const sceneCoordinate = v.pipe(v.number(), v.finite(), v.minValue(-1e5), v.maxValue(1e5));
|
|
183
183
|
const sceneVector = v.tuple([sceneCoordinate, sceneCoordinate, sceneCoordinate]);
|
|
184
184
|
const sceneChildren = v.pipe(v.array(name), v.maxLength(128));
|
|
@@ -25,7 +25,7 @@ export function clientScriptViewCost(data: ShardClientScripts): { capacity: numb
|
|
|
25
25
|
const capacity = Math.min(CLIENT_SCRIPT_LIMITS.particlesLive, data.bindings.reduce((sum, binding) => sum + binding.emitters.reduce((n, row) => n + row.live, 0), 0));
|
|
26
26
|
return { capacity, decoded: capacity * 56, gpu: capacity * 32, triangles: 0, draws: capacity > 0 ? 1 : 0 };
|
|
27
27
|
}
|
|
28
|
-
/** A declared visual anchor resolved by
|
|
28
|
+
/** A declared visual anchor resolved by native composition, never by a bytecode physics query. */
|
|
29
29
|
export type ClientScriptTarget = ShardClientScripts['bindings'][number]['target'];
|
|
30
30
|
/** Minimal format view for admission and projection, independent of rendering and author callbacks. */
|
|
31
31
|
export interface ClientScriptContent {
|
|
@@ -54,7 +54,7 @@ export const CONTENT_CAPS: { readonly l0: { readonly size: 62.5; readonly reside
|
|
|
54
54
|
overlap: 80 * CONTENT_MB, residentFactor: 1.11, nearRadius: 150, shadowRadius: 80, pitch: 562.5,
|
|
55
55
|
} as const;
|
|
56
56
|
|
|
57
|
-
/**
|
|
57
|
+
/** Host-owned GPU/transcoder capabilities, never authored shard data. */
|
|
58
58
|
export interface TextureTranscodeSupport { readonly astc: boolean; readonly bc7: boolean }
|
|
59
59
|
/** Exact LDR mip residency, including padded 4x4 ASTC/BC7 blocks at the smallest mip levels. */
|
|
60
60
|
export function textureMipBytes(width: number, height: number, levels: number, blocks: boolean): number {
|
|
@@ -20,9 +20,16 @@ import {
|
|
|
20
20
|
union,
|
|
21
21
|
} from 'valibot'
|
|
22
22
|
|
|
23
|
+
import { CreatureProjectileSchema } from './creature-projectile.ts'
|
|
24
|
+
import { CreatureSocketNameSchema } from './creature-volumes.ts'
|
|
25
|
+
import { CreatureSkinClipNameSchema } from './skinData.ts'
|
|
26
|
+
import { StrikeTellKindSchema } from './spawnCombat.ts'
|
|
23
27
|
import { HuntTuningSchema } from './speciesPrograms.ts'
|
|
24
28
|
|
|
25
29
|
import type { CreatureBody } from './creature-body.ts'
|
|
30
|
+
import type { CreatureProjectile } from './creature-projectile.ts'
|
|
31
|
+
import type { CreatureSkinClipName } from './skinData.ts'
|
|
32
|
+
import type { StrikeTellKind } from './spawnCombat.ts'
|
|
26
33
|
import type { SpeciesData } from './speciesPrograms.ts'
|
|
27
34
|
import type { GenericSchema } from 'valibot'
|
|
28
35
|
|
|
@@ -79,7 +86,15 @@ interface CreatureAbility {
|
|
|
79
86
|
speed?: number
|
|
80
87
|
windup?: number
|
|
81
88
|
duration?: number
|
|
89
|
+
from?: string
|
|
90
|
+
clip?: CreatureSkinClipName
|
|
91
|
+
effect?: 'knockback'
|
|
92
|
+
/** Horizontal travel in metres on clear ground. */
|
|
93
|
+
strength?: number
|
|
94
|
+
tell?: StrikeTellKind
|
|
95
|
+
projectile?: CreatureProjectile
|
|
82
96
|
}
|
|
97
|
+
type CreatureAbilityInput = Omit<CreatureAbility, 'clip'> & { clip?: string }
|
|
83
98
|
interface CreaturePresentation {
|
|
84
99
|
blood: boolean
|
|
85
100
|
sounds: {
|
|
@@ -106,6 +121,7 @@ const MAX_SOUND = 4096
|
|
|
106
121
|
const MAX_RADIUS = 500
|
|
107
122
|
const MAX_SPEED = 15
|
|
108
123
|
const MAX_TIME = 86_400
|
|
124
|
+
const MAX_KNOCKBACK_DISTANCE = 60
|
|
109
125
|
const MAX_AMOUNT = 10_000_000
|
|
110
126
|
const MAX_CALLS = 32
|
|
111
127
|
const MAX_TUNING_FIELDS = 64
|
|
@@ -118,6 +134,11 @@ const speed = pipe(scalar, minValue(ZERO), maxValue(MAX_SPEED))
|
|
|
118
134
|
const unit = pipe(scalar, minValue(ZERO), maxValue(ONE))
|
|
119
135
|
const time = pipe(scalar, minValue(ZERO), maxValue(MAX_TIME))
|
|
120
136
|
const amount = pipe(scalar, minValue(ZERO), maxValue(MAX_AMOUNT))
|
|
137
|
+
const knockbackDistance = pipe(
|
|
138
|
+
scalar,
|
|
139
|
+
minValue(ZERO),
|
|
140
|
+
maxValue(MAX_KNOCKBACK_DISTANCE),
|
|
141
|
+
)
|
|
121
142
|
const orderedRadius = pipe(
|
|
122
143
|
tuple([radius, radius]),
|
|
123
144
|
check<[number, number], 'Ordered creature ability range'>(
|
|
@@ -196,7 +217,7 @@ const CreatureSensesSchema: GenericSchema<CreatureSenses> = strictObject(
|
|
|
196
217
|
},
|
|
197
218
|
'Unknown creature sense',
|
|
198
219
|
)
|
|
199
|
-
const
|
|
220
|
+
const abilityRow = strictObject({
|
|
200
221
|
use: id,
|
|
201
222
|
range: union([radius, orderedRadius]),
|
|
202
223
|
cooldown: time,
|
|
@@ -206,7 +227,28 @@ const CreatureAbilitySchema: GenericSchema<CreatureAbility> = strictObject({
|
|
|
206
227
|
speed: exactOptional(amount),
|
|
207
228
|
windup: exactOptional(time),
|
|
208
229
|
duration: exactOptional(time),
|
|
230
|
+
from: exactOptional(CreatureSocketNameSchema),
|
|
231
|
+
clip: exactOptional(CreatureSkinClipNameSchema),
|
|
232
|
+
effect: exactOptional(picklist(['knockback'])),
|
|
233
|
+
strength: exactOptional(knockbackDistance),
|
|
234
|
+
tell: exactOptional(StrikeTellKindSchema),
|
|
235
|
+
projectile: exactOptional(CreatureProjectileSchema),
|
|
209
236
|
})
|
|
237
|
+
const abilityEffectCheck = check<
|
|
238
|
+
CreatureAbility,
|
|
239
|
+
'Creature knockback effect and strength must be specified together'
|
|
240
|
+
>(
|
|
241
|
+
({
|
|
242
|
+
effect,
|
|
243
|
+
strength,
|
|
244
|
+
}: Readonly<Pick<CreatureAbility, 'effect' | 'strength'>>): boolean =>
|
|
245
|
+
(effect === undefined) === (strength === undefined),
|
|
246
|
+
'Creature knockback effect and strength must be specified together',
|
|
247
|
+
)
|
|
248
|
+
const CreatureAbilitySchema: GenericSchema<
|
|
249
|
+
CreatureAbilityInput,
|
|
250
|
+
CreatureAbility
|
|
251
|
+
> = pipe(abilityRow, abilityEffectCheck)
|
|
210
252
|
const callVariants = pipe(array(sound), maxLength(MAX_CALLS))
|
|
211
253
|
const CreaturePresentationSchema: GenericSchema<CreaturePresentation> =
|
|
212
254
|
strictObject({
|
|
@@ -227,6 +269,7 @@ export {
|
|
|
227
269
|
CreaturePresentationSchema,
|
|
228
270
|
}
|
|
229
271
|
export type {
|
|
272
|
+
CreatureAbilityInput,
|
|
230
273
|
CreatureType,
|
|
231
274
|
CreatureSkeleton,
|
|
232
275
|
CreatureSize,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
finite,
|
|
3
|
+
gtValue,
|
|
4
|
+
minValue,
|
|
5
|
+
maxValue,
|
|
6
|
+
number,
|
|
7
|
+
pipe,
|
|
8
|
+
strictObject,
|
|
9
|
+
} from 'valibot'
|
|
10
|
+
|
|
11
|
+
import type { GenericSchema } from 'valibot'
|
|
12
|
+
|
|
13
|
+
interface CreatureProjectile {
|
|
14
|
+
/** Metres per second at launch. */
|
|
15
|
+
speed: number
|
|
16
|
+
/** Downward acceleration, metres per second squared. */
|
|
17
|
+
gravity: number
|
|
18
|
+
/** Sphere radius in metres. */
|
|
19
|
+
radius: number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const zero = 0
|
|
23
|
+
const maxRadius = 500
|
|
24
|
+
const finiteNumber = pipe(number(), finite())
|
|
25
|
+
const positive = pipe(finiteNumber, gtValue(zero))
|
|
26
|
+
const gravity = pipe(finiteNumber, minValue(zero))
|
|
27
|
+
const radius = pipe(positive, maxValue(maxRadius))
|
|
28
|
+
const CreatureProjectileSchema: GenericSchema<CreatureProjectile> =
|
|
29
|
+
strictObject({ speed: positive, gravity, radius })
|
|
30
|
+
|
|
31
|
+
export { CreatureProjectileSchema }
|
|
32
|
+
export type { CreatureProjectile }
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** A spawn row's rank (ONE-FORMAT OF28, Q-CC33 (a)): a stronger version of the
|
|
2
|
+
* same creature, scaled by fixed multipliers. The engine applies them; a shard
|
|
3
|
+
* only names the rank. Pine's and Nalati's elites move onto these (OF33). */
|
|
4
|
+
type CreatureRank = 'veteran' | 'elite' | 'champion' | 'legendary'
|
|
5
|
+
|
|
6
|
+
interface CreatureRankPolicy {
|
|
7
|
+
/** Maximum hit points. */
|
|
8
|
+
readonly hp: number
|
|
9
|
+
/** Every strike's damage. */
|
|
10
|
+
readonly damage: number
|
|
11
|
+
/** Body scale, on top of the spawn's own scale and its size class. */
|
|
12
|
+
readonly size: number
|
|
13
|
+
/** Loot rolls. */
|
|
14
|
+
readonly loot: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const CREATURE_RANK_NAMES: readonly CreatureRank[] = [
|
|
18
|
+
'veteran',
|
|
19
|
+
'elite',
|
|
20
|
+
'champion',
|
|
21
|
+
'legendary',
|
|
22
|
+
]
|
|
23
|
+
const CREATURE_RANKS: Readonly<Record<CreatureRank, CreatureRankPolicy>> = {
|
|
24
|
+
veteran: { hp: 2, damage: 1.25, size: 1.1, loot: 2 },
|
|
25
|
+
elite: { hp: 4, damage: 1.5, size: 1.2, loot: 3 },
|
|
26
|
+
champion: { hp: 10, damage: 2, size: 1.35, loot: 5 },
|
|
27
|
+
legendary: { hp: 25, damage: 2.5, size: 1.5, loot: 8 },
|
|
28
|
+
}
|
|
29
|
+
const UNRANKED: CreatureRankPolicy = { hp: 1, damage: 1, size: 1, loot: 1 }
|
|
30
|
+
|
|
31
|
+
/** The multipliers for a spawn row's rank; an unranked row keeps its own numbers. */
|
|
32
|
+
function creatureRank(rank?: CreatureRank): CreatureRankPolicy {
|
|
33
|
+
return rank === undefined ? UNRANKED : CREATURE_RANKS[rank]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { CREATURE_RANK_NAMES, CREATURE_RANKS, creatureRank }
|
|
37
|
+
export type { CreatureRank, CreatureRankPolicy }
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { creatureRank } from './creature-ranks.ts'
|
|
2
|
+
|
|
1
3
|
import type { CreatureBody, CreatureSize } from './creature-layers.ts'
|
|
4
|
+
import type { CreatureRank } from './creature-ranks.ts'
|
|
2
5
|
|
|
3
6
|
interface CreatureSizePolicy {
|
|
4
7
|
readonly scale: number
|
|
@@ -8,6 +11,10 @@ interface CreatureSizePolicy {
|
|
|
8
11
|
readonly maxHeight?: number
|
|
9
12
|
}
|
|
10
13
|
const GIANT_HEIGHT = 15
|
|
14
|
+
/** One row's full count may weigh at most one giant: 16 medium, 4 large. */
|
|
15
|
+
const COUNT_WEIGHT_CAP = 16
|
|
16
|
+
const ONE_CREATURE = 1
|
|
17
|
+
const NO_CREATURES = 0
|
|
11
18
|
const DEFAULT_SCALE = 1
|
|
12
19
|
const BODY_HEIGHT_FACTOR = 2
|
|
13
20
|
const MAX_VARIANT_SCALE = 1
|
|
@@ -42,6 +49,8 @@ interface SizedSpawn {
|
|
|
42
49
|
readonly id: string
|
|
43
50
|
readonly species: string
|
|
44
51
|
readonly scale: number
|
|
52
|
+
readonly rank?: CreatureRank
|
|
53
|
+
readonly count?: { readonly per: number; readonly max: number }
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
function creatureScale(
|
|
@@ -68,17 +77,30 @@ function creatureHeight(
|
|
|
68
77
|
)
|
|
69
78
|
return modelHeight * creatureScale(body, spawnScale)
|
|
70
79
|
}
|
|
80
|
+
function countRules(
|
|
81
|
+
row: SizedSpecies,
|
|
82
|
+
spawns: readonly SizedSpawn[],
|
|
83
|
+
): string[] {
|
|
84
|
+
const weight = CREATURE_SIZES[row.body?.size ?? 'medium'].cellWeight
|
|
85
|
+
return spawns.flatMap((spawn): string[] =>
|
|
86
|
+
spawn.species === row.id &&
|
|
87
|
+
spawn.count !== undefined &&
|
|
88
|
+
spawn.count.max * weight > COUNT_WEIGHT_CAP
|
|
89
|
+
? [`spawn ${spawn.id}: count ceiling outweighs its size class`]
|
|
90
|
+
: [],
|
|
91
|
+
)
|
|
92
|
+
}
|
|
71
93
|
function speciesSizeRules(
|
|
72
94
|
row: SizedSpecies,
|
|
73
95
|
spawns: readonly SizedSpawn[],
|
|
74
96
|
): string[] {
|
|
75
97
|
const { body } = row
|
|
76
98
|
if (body === undefined) {
|
|
77
|
-
return
|
|
99
|
+
return countRules(row, spawns)
|
|
78
100
|
}
|
|
79
101
|
const cap = CREATURE_SIZES[body.size].maxHeight
|
|
80
102
|
if (cap === undefined) {
|
|
81
|
-
return
|
|
103
|
+
return countRules(row, spawns)
|
|
82
104
|
}
|
|
83
105
|
const oversized = row.variants.some(
|
|
84
106
|
(variant): boolean =>
|
|
@@ -87,9 +109,14 @@ function speciesSizeRules(
|
|
|
87
109
|
const errors = oversized ? [`species ${row.id}: giant exceeds ${cap} m`] : []
|
|
88
110
|
return [
|
|
89
111
|
...errors,
|
|
112
|
+
...countRules(row, spawns),
|
|
90
113
|
...spawns.flatMap((spawn): string[] =>
|
|
91
114
|
spawn.species === row.id &&
|
|
92
|
-
creatureHeight(
|
|
115
|
+
creatureHeight(
|
|
116
|
+
body,
|
|
117
|
+
row.dims,
|
|
118
|
+
spawn.scale * creatureRank(spawn.rank).size,
|
|
119
|
+
) > cap
|
|
93
120
|
? [`spawn ${spawn.id}: giant exceeds ${cap} m`]
|
|
94
121
|
: [],
|
|
95
122
|
),
|
|
@@ -102,5 +129,19 @@ function creatureSizeRules(
|
|
|
102
129
|
return species.flatMap((row): string[] => speciesSizeRules(row, spawns))
|
|
103
130
|
}
|
|
104
131
|
|
|
105
|
-
|
|
132
|
+
/** The most creatures the rows can hold at once: a counted row at its ceiling. */
|
|
133
|
+
function spawnCapacity(spawns: readonly Pick<SizedSpawn, 'count'>[]): number {
|
|
134
|
+
return spawns.reduce(
|
|
135
|
+
(sum, spawn): number => sum + (spawn.count?.max ?? ONE_CREATURE),
|
|
136
|
+
NO_CREATURES,
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export {
|
|
141
|
+
CREATURE_SIZES,
|
|
142
|
+
creatureScale,
|
|
143
|
+
creatureHeight,
|
|
144
|
+
creatureSizeRules,
|
|
145
|
+
spawnCapacity,
|
|
146
|
+
}
|
|
106
147
|
export type { CreatureSizePolicy }
|
|
@@ -29,7 +29,7 @@ const MAX_VOLUMES = 16
|
|
|
29
29
|
const MAX_NAME = 128
|
|
30
30
|
const MAX_EXTENT = 500
|
|
31
31
|
const MAX_MULTIPLIER = 100
|
|
32
|
-
const
|
|
32
|
+
const CreatureSocketNameSchema: GenericSchema<string> = pipe(
|
|
33
33
|
string(),
|
|
34
34
|
regex(/^[a-zA-Z][a-zA-Z0-9_.:-]*$/u),
|
|
35
35
|
maxLength(MAX_NAME),
|
|
@@ -38,8 +38,8 @@ const scalar = pipe(number(), finite())
|
|
|
38
38
|
const extent = pipe(scalar, minValue(ZERO), maxValue(MAX_EXTENT))
|
|
39
39
|
const offset = pipe(scalar, minValue(-MAX_EXTENT), maxValue(MAX_EXTENT))
|
|
40
40
|
const volumeObject = strictObject({
|
|
41
|
-
part:
|
|
42
|
-
bone:
|
|
41
|
+
part: CreatureSocketNameSchema,
|
|
42
|
+
bone: CreatureSocketNameSchema,
|
|
43
43
|
shape: picklist(['sphere', 'capsule']),
|
|
44
44
|
radius: pipe(scalar, minValue(Number.MIN_VALUE), maxValue(MAX_EXTENT)),
|
|
45
45
|
halfLength: extent,
|
|
@@ -67,7 +67,7 @@ const CreatureVolumesSchema: GenericSchema<CreatureVolume[]> = pipe(
|
|
|
67
67
|
),
|
|
68
68
|
)
|
|
69
69
|
const CreatureLockSchema: GenericSchema<string[]> = pipe(
|
|
70
|
-
array(
|
|
70
|
+
array(CreatureSocketNameSchema),
|
|
71
71
|
minLength(ONE),
|
|
72
72
|
maxLength(MAX_VOLUMES),
|
|
73
73
|
check<string[], 'Duplicate creature lock point'>(
|
|
@@ -80,6 +80,7 @@ export {
|
|
|
80
80
|
CreatureVolumeSchema,
|
|
81
81
|
CreatureVolumesSchema,
|
|
82
82
|
CreatureLockSchema,
|
|
83
|
+
CreatureSocketNameSchema,
|
|
83
84
|
MAX_VOLUMES,
|
|
84
85
|
}
|
|
85
86
|
export type { CreatureVolume }
|
package/src/format/creatures.ts
CHANGED
|
@@ -62,7 +62,24 @@ const phase = v.pipe(finite, v.minValue(-2 * Math.PI), v.maxValue(2 * Math.PI));
|
|
|
62
62
|
const RESPAWN_MAX = 3600, RESPAWN_MIN = 1;
|
|
63
63
|
const respawn = v.pipe(finite, v.minValue(RESPAWN_MIN), v.maxValue(RESPAWN_MAX));
|
|
64
64
|
/** Social membership names no controller; the species temperament owns assistance. */
|
|
65
|
-
|
|
65
|
+
/** OF28: the rank names of ./creature-ranks.ts (kept in step by its test); the engine applies the multipliers. */
|
|
66
|
+
const rank = v.picklist(['veteran', 'elite', 'champion', 'legendary'], 'unknown creature rank');
|
|
67
|
+
/** OF28b (Q-CC35): one row grows by one creature per `per` players in the cell, to `max`; the size class weighs `max`. */
|
|
68
|
+
const MOST_PER_ROW = 64;
|
|
69
|
+
const FIRST_GROWN = 2;
|
|
70
|
+
const LAST_STAGE = 255;
|
|
71
|
+
const LEAST_PER_ROW = 1;
|
|
72
|
+
const FIRST_STAGE = 0;
|
|
73
|
+
const countPart = v.pipe(finite, v.integer(), v.minValue(LEAST_PER_ROW), v.maxValue(MOST_PER_ROW));
|
|
74
|
+
const count = v.strictObject({ per: countPart, max: v.pipe(countPart, v.minValue(FIRST_GROWN)) });
|
|
75
|
+
/** OF28c: when a row lives. `quest`: from that stage on; `time`: only by day or by night; `wave`: wave `index` of a `set`,
|
|
76
|
+
* after the wave before it in that set has fallen. Respawn timers (`respawn`) and group mix (`group`) stay their own fields. */
|
|
77
|
+
const stage = v.pipe(finite, v.integer(), v.minValue(FIRST_STAGE), v.maxValue(LAST_STAGE));
|
|
78
|
+
const questWhen = v.strictObject({ id, stage });
|
|
79
|
+
const waveWhen = v.strictObject({ set: id, index: countPart });
|
|
80
|
+
const timeWhen = v.picklist(['day', 'night'], 'unknown spawn time');
|
|
81
|
+
const when = v.strictObject({ quest: v.exactOptional(questWhen), time: v.exactOptional(timeWhen), wave: v.exactOptional(waveWhen) }, 'unknown spawn condition');
|
|
82
|
+
const spawn = v.strictObject({ perchBody: v.exactOptional(id), group: v.exactOptional(id), rank: v.exactOptional(rank), count: v.exactOptional(count), when: v.exactOptional(when), phaseOffset: v.optional(phase), home: v.optional(CreatureHomeSchema), respawn: v.optional(respawn), id, species: id, variant: id, brain: v.nullable(id), strike: v.nullable(id), seed: v.pipe(finite, v.integer(), v.minValue(0), v.maxValue(0xffffffff)), scale: v.pipe(finite, v.minValue(0.1), v.maxValue(10)), at: v.tuple([coord, coord, coord]), yaw: finite });
|
|
66
83
|
/** Pure-data creature archetypes and stable spawn layouts, expanded before the local sim boots. */
|
|
67
84
|
export const CreaturesSchema: v.GenericSchema<ShardCreaturesInput, ShardCreatures> = v.pipe(v.strictObject({ perchBodies: v.exactOptional(CreaturePerchBodiesSchema), brains: v.pipe(v.array(v.variant('kind', [brain, SkirmisherSchema, GuardianSchema, PerchHunterSchema, ScriptBrainSchema, RamGrazerSchema, ChallengeGrazerSchema, OrbitDiverSchema, PatrolDiverSchema, BurstFlyerSchema, GrazerSchema, DiverSchema, GuardianPatternsSchema, StalkerSchema])), v.maxLength(64)), groups: v.optional(v.pipe(v.array(GroupBrainSchema), v.maxLength(64)), []), spawns: v.pipe(v.array(spawn), v.maxLength(10000)) }),
|
|
68
85
|
v.check((c) => creatureRules(c).length === 0, 'creature reference rules'));
|
|
@@ -168,8 +185,8 @@ export interface CreatureMemoryActionsRows { stateKey: string; states: (string)[
|
|
|
168
185
|
export interface CreatureBodyRecipeRowsInput { actions?: CreatureMemoryActionsRowsInput; offset?: { field: string; from: number; to: number; }; kind: 'animal'; motion: 'ground' | 'flight'; attack: 'keeper' | 'unlimited'; stunned: 'none' | 'look-hold'; contact: ({ kind: 'environment'; halfArc: number; }) | ({ kind: 'actor'; halfArc: number; move: string; }); }
|
|
169
186
|
export interface CreatureBodyRecipeRows { actions?: CreatureMemoryActionsRows; offset?: { field: string; from: number; to: number; }; kind: 'animal'; motion: 'ground' | 'flight'; attack: 'keeper' | 'unlimited'; stunned: 'none' | 'look-hold'; contact: ({ kind: 'environment'; halfArc: number; }) | ({ kind: 'actor'; halfArc: number; move: string; }); }
|
|
170
187
|
// oxlint-disable-next-line typescript/consistent-type-definitions -- Valibot's readonly defaults need the alias's implicit dictionary compatibility.
|
|
171
|
-
export type ShardCreaturesInput = { perchBodies?: CreaturePerchBodyInput[]; brains: (({ id: string; kind: 'pursue'; awareRadius: number; leashRadius: number; speed: number; returnSpeed: number; stopDistance: number; turnRate: number; thinkDivisor: number; attackCooldownTicks: number; wanderRadius: number; wanderEveryTicks: number; }) | (v.InferInput<typeof SkirmisherSchema>) | (v.InferInput<typeof GuardianSchema>) | (v.InferInput<typeof PerchHunterSchema>) | (v.InferInput<typeof ScriptBrainSchema>) | (v.InferInput<typeof RamGrazerSchema>) | (v.InferInput<typeof ChallengeGrazerSchema>) | (v.InferInput<typeof OrbitDiverSchema>) | (v.InferInput<typeof PatrolDiverSchema>) | (v.InferInput<typeof BurstFlyerSchema>) | (v.InferInput<typeof GrazerSchema>) | (v.InferInput<typeof DiverSchema>) | (v.InferInput<typeof GuardianPatternsSchema>) | (v.InferInput<typeof StalkerSchema>))[]; groups?: (v.InferInput<typeof GroupBrainSchema>)[] | undefined; spawns: ({ perchBody?: string; group?: string; phaseOffset?: number | undefined; respawn?: number | undefined; home?: ShardCreatureHomeInput | undefined; id: string; species: string; variant: string; brain: (string) | null; strike: (string) | null; seed: number; scale: number; at: [number, number, number]; yaw: number; })[]; };
|
|
172
|
-
export interface ShardCreatures { perchBodies?: CreaturePerchBody[]; brains: (({ id: string; kind: 'pursue'; awareRadius: number; leashRadius: number; speed: number; returnSpeed: number; stopDistance: number; turnRate: number; thinkDivisor: number; attackCooldownTicks: number; wanderRadius: number; wanderEveryTicks: number; }) | (v.InferOutput<typeof SkirmisherSchema>) | (v.InferOutput<typeof GuardianSchema>) | (v.InferOutput<typeof PerchHunterSchema>) | (v.InferOutput<typeof ScriptBrainSchema>) | (v.InferOutput<typeof RamGrazerSchema>) | (v.InferOutput<typeof ChallengeGrazerSchema>) | (v.InferOutput<typeof OrbitDiverSchema>) | (v.InferOutput<typeof PatrolDiverSchema>) | (v.InferOutput<typeof BurstFlyerSchema>) | (v.InferOutput<typeof GrazerSchema>) | (v.InferOutput<typeof DiverSchema>) | (v.InferOutput<typeof GuardianPatternsSchema>) | (v.InferOutput<typeof StalkerSchema>))[]; groups: (v.InferOutput<typeof GroupBrainSchema>)[]; spawns: ({ perchBody?: string; group?: string; phaseOffset?: number | undefined; respawn?: number | undefined; home?: ShardCreatureHome | undefined; id: string; species: string; variant: string; brain: (string) | null; strike: (string) | null; seed: number; scale: number; at: [number, number, number]; yaw: number; })[]; }
|
|
188
|
+
export type ShardCreaturesInput = { perchBodies?: CreaturePerchBodyInput[]; brains: (({ id: string; kind: 'pursue'; awareRadius: number; leashRadius: number; speed: number; returnSpeed: number; stopDistance: number; turnRate: number; thinkDivisor: number; attackCooldownTicks: number; wanderRadius: number; wanderEveryTicks: number; }) | (v.InferInput<typeof SkirmisherSchema>) | (v.InferInput<typeof GuardianSchema>) | (v.InferInput<typeof PerchHunterSchema>) | (v.InferInput<typeof ScriptBrainSchema>) | (v.InferInput<typeof RamGrazerSchema>) | (v.InferInput<typeof ChallengeGrazerSchema>) | (v.InferInput<typeof OrbitDiverSchema>) | (v.InferInput<typeof PatrolDiverSchema>) | (v.InferInput<typeof BurstFlyerSchema>) | (v.InferInput<typeof GrazerSchema>) | (v.InferInput<typeof DiverSchema>) | (v.InferInput<typeof GuardianPatternsSchema>) | (v.InferInput<typeof StalkerSchema>))[]; groups?: (v.InferInput<typeof GroupBrainSchema>)[] | undefined; spawns: ({ perchBody?: string; group?: string; rank?: 'veteran' | 'elite' | 'champion' | 'legendary'; count?: { per: number; max: number }; when?: { quest?: { id: string; stage: number }; time?: 'day' | 'night'; wave?: { set: string; index: number } }; phaseOffset?: number | undefined; respawn?: number | undefined; home?: ShardCreatureHomeInput | undefined; id: string; species: string; variant: string; brain: (string) | null; strike: (string) | null; seed: number; scale: number; at: [number, number, number]; yaw: number; })[]; };
|
|
189
|
+
export interface ShardCreatures { perchBodies?: CreaturePerchBody[]; brains: (({ id: string; kind: 'pursue'; awareRadius: number; leashRadius: number; speed: number; returnSpeed: number; stopDistance: number; turnRate: number; thinkDivisor: number; attackCooldownTicks: number; wanderRadius: number; wanderEveryTicks: number; }) | (v.InferOutput<typeof SkirmisherSchema>) | (v.InferOutput<typeof GuardianSchema>) | (v.InferOutput<typeof PerchHunterSchema>) | (v.InferOutput<typeof ScriptBrainSchema>) | (v.InferOutput<typeof RamGrazerSchema>) | (v.InferOutput<typeof ChallengeGrazerSchema>) | (v.InferOutput<typeof OrbitDiverSchema>) | (v.InferOutput<typeof PatrolDiverSchema>) | (v.InferOutput<typeof BurstFlyerSchema>) | (v.InferOutput<typeof GrazerSchema>) | (v.InferOutput<typeof DiverSchema>) | (v.InferOutput<typeof GuardianPatternsSchema>) | (v.InferOutput<typeof StalkerSchema>))[]; groups: (v.InferOutput<typeof GroupBrainSchema>)[]; spawns: ({ perchBody?: string; group?: string; rank?: 'veteran' | 'elite' | 'champion' | 'legendary'; count?: { per: number; max: number }; when?: { quest?: { id: string; stage: number }; time?: 'day' | 'night'; wave?: { set: string; index: number } }; phaseOffset?: number | undefined; respawn?: number | undefined; home?: ShardCreatureHome | undefined; id: string; species: string; variant: string; brain: (string) | null; strike: (string) | null; seed: number; scale: number; at: [number, number, number]; yaw: number; })[]; }
|
|
173
190
|
export type CreatureStrikeRowsInput = CreatureStrikeRows;
|
|
174
191
|
export interface CreatureStrikeRows { debris?: StrikeDebrisPolicy; id: string; shape: ({ kind: 'arc'; radius: number; halfAngle: number; yawOffset?: number; }) | ({ kind: 'lane'; length: number; width: number; }) | ({ kind: 'ring'; inner: number; outer: number; }) | ({ kind: 'wedge'; length: number; halfAngle: number; }) | ({ kind: 'point'; radius: number; exclusive?: boolean; }) | ({ kind: 'sphere'; radius: number; }); windup: number; active: number; recover: number; cooldown: number; range: (number) | null; damage: number; tags: (`${string}.${string}`)[]; weight: ({ kind: 'constant'; value: number; }) | ({ kind: 'horizontal-distance'; above: number; far: number; near: number; }); units?: 'world' | 'actor'; alternatives?: (({ kind: 'arc'; radius: number; halfAngle: number; yawOffset?: number; }) | ({ kind: 'lane'; length: number; width: number; }) | ({ kind: 'ring'; inner: number; outer: number; }) | ({ kind: 'wedge'; length: number; halfAngle: number; }) | ({ kind: 'point'; radius: number; exclusive?: boolean; }) | ({ kind: 'sphere'; radius: number; }))[]; motion?: { speed?: number; delay?: number; track?: 'none' | 'lead' | 'follow'; overshoot?: number; skid?: number; }; eligibility?: { maxDy?: number; jumpDodges?: boolean; }; }
|
|
175
192
|
export type CreatureStrikesInput = unknown;
|
package/src/format/crowds.ts
CHANGED
|
@@ -6,7 +6,7 @@ const finite = v.pipe(v.number(), v.finite());
|
|
|
6
6
|
const coordinate = v.pipe(finite, v.minValue(-100000), v.maxValue(100000));
|
|
7
7
|
const speed = v.pipe(finite, v.minValue(0), v.maxValue(15));
|
|
8
8
|
|
|
9
|
-
/** Ordered instanced flock declaration; terrain, native view, prey and distance scheduling remain
|
|
9
|
+
/** Ordered instanced flock declaration; terrain, native view, prey and distance scheduling remain native ports. */
|
|
10
10
|
export const FlockSchema: v.GenericSchema<ShardFlockInput, ShardFlock> = v.strictObject({
|
|
11
11
|
id: key, kind: v.literal('flock'), x: coordinate, z: coordinate,
|
|
12
12
|
count: v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(256)),
|
|
@@ -12,7 +12,7 @@ export function acceptsShardfileCost(memory: MemoryAdmission | undefined, source
|
|
|
12
12
|
claimedBytes: cost.accounted, accountedBytes: cost.accounted, playingBytes: cost.playing, loadingBytes: cost.loading });
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
/** Reapply the current
|
|
15
|
+
/** Reapply the current host-owned memory policy to a previously validated exact declaration. */
|
|
16
16
|
export function acceptValidatedCost(source: Shardfile, cost: ReturnType<typeof worstContentCost>, memory?: MemoryAdmission): void {
|
|
17
17
|
if (!acceptsShardfileCost(memory, source, 'declared', cost)) throw new Error(`declared worst-location total exceeds envelope: play ${cost.playing}, load ${cost.loading}${overHardLine(Math.max(cost.playing, cost.loading))}`);
|
|
18
18
|
}
|
|
@@ -44,7 +44,7 @@ export function textureLibrarySource(source: Shardfile, assets: ReadonlyMap<stri
|
|
|
44
44
|
return { ...source, budgets: { ...source.budgets, library: { ...source.budgets.library, resident: Math.max(0, source.budgets.library.resident - saving) } } };
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
/**
|
|
47
|
+
/** Host-owned device's exact library projection, with all existing conservative neighbour and fallback ceilings retained. */
|
|
48
48
|
export function* deviceLibraryCostSteps(source: Shardfile, assets: ReadonlyMap<string, Uint8Array>, support?: TextureTranscodeSupport, deviceCosts?: ReadonlyMap<string, Ktx2DeviceCosts>): Generator<void, ReturnType<typeof worstContentCost>> {
|
|
49
49
|
const commons = Object.values(source.requires.commonsCosts).reduce((sum, row) => sum + row.decoded + row.gpu, 0);
|
|
50
50
|
return yield* worstContentCostSteps(textureLibrarySource(source, assets, support, deviceCosts), commons);
|
|
@@ -69,14 +69,14 @@ export type DirectorAction = DirectorStagesData['stages'][number]['do'][number];
|
|
|
69
69
|
export function parseDirectorStages(input: unknown): DirectorStagesData { return v.parse(DirectorStagesSchema, input); }
|
|
70
70
|
|
|
71
71
|
|
|
72
|
-
/** Root-owned pacing rows with distinct identities; an AS handler is installed only through explicit
|
|
72
|
+
/** Root-owned pacing rows with distinct identities; an AS handler is installed only through explicit native bindings. */
|
|
73
73
|
export const DirectorsSchema: v.GenericSchema<DirectorsDataInput, DirectorsData> = v.pipe(v.array(DirectorStagesSchema), v.maxLength(16), v.check(rows => new Set(rows.map(row => row.id)).size === rows.length, 'Unique director identities'));
|
|
74
74
|
|
|
75
75
|
/** Describe stock data-only support: quest flags, bounded day inputs and flag actions.
|
|
76
|
-
* Other admitted actions need
|
|
76
|
+
* Other admitted actions need native owners; emit is not AssemblyScript delivery. */
|
|
77
77
|
export function directorDataHostIssues(data: DirectorStagesData): readonly string[] {
|
|
78
78
|
const issues: string[] = [];
|
|
79
|
-
if (data.script !== null) issues.push('script requires a
|
|
79
|
+
if (data.script !== null) issues.push('script requires a host-owned typed director host');
|
|
80
80
|
for (const [inputName, binding] of Object.entries(data.inputs)) {
|
|
81
81
|
if (!binding.startsWith('flag:') && directorDayRange(binding) === null) issues.push(`input ${inputName} (${binding}) requires a native observation owner`);
|
|
82
82
|
}
|
package/src/format/flyers.ts
CHANGED
|
@@ -22,7 +22,7 @@ export const OrbitDiverSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
|
22
22
|
noticeRadius: radius, giveUpRadius: radius, initialRestSeconds: radius, stalkMaxSeconds: positive,
|
|
23
23
|
riseMargin: radius, targetHeight: radius, alignRadius: positive, alignTolerance: positive,
|
|
24
24
|
}), v.check(row => orderedOrbit(row), 'Ordered orbit perception'));
|
|
25
|
-
/** Admitted orbit/dive policy; native flight, token and contact execution remain
|
|
25
|
+
/** Admitted orbit/dive policy; native flight, token and contact execution remain native host ports. */
|
|
26
26
|
export type ShardOrbitDiver = v.InferOutput<typeof OrbitDiverSchema>;
|
|
27
27
|
/** Validate overhead dive data without instantiating a creature or executing its native flight recipe. */
|
|
28
28
|
export function parseOrbitDiver(data: unknown): ShardOrbitDiver { return v.parse(OrbitDiverSchema, data); }
|
|
@@ -41,7 +41,7 @@ export type ShardPatrolDiver = v.InferOutput<typeof PatrolDiverSchema>;
|
|
|
41
41
|
/** Refuse invalid patrol timing, memory fields and speed before any callbacks register. */
|
|
42
42
|
export function parsePatrolDiver(data: unknown): ShardPatrolDiver { return v.parse(PatrolDiverSchema, data); }
|
|
43
43
|
|
|
44
|
-
/** Small-circle drift and telegraphed chest dart; contact shove is declared data and applied only by a
|
|
44
|
+
/** Small-circle drift and telegraphed chest dart; contact shove is declared data and applied only by a native port. */
|
|
45
45
|
export const BurstFlyerSchema: v.StrictObjectSchema<{ readonly id: v.GenericSchema<BurstFlyerRowsInput['id'], BurstFlyerRows['id']>; readonly kind: v.GenericSchema<BurstFlyerRowsInput['kind'], BurstFlyerRows['kind']>; readonly thinkDivisor: v.OptionalSchema<v.GenericSchema<Exclude<BurstFlyerRowsInput['thinkDivisor'], undefined>, Exclude<BurstFlyerRows['thinkDivisor'], undefined>>, 6>; readonly strike: v.GenericSchema<BurstFlyerRowsInput['strike'], BurstFlyerRows['strike']>; readonly home: v.GenericSchema<BurstFlyerRowsInput['home'], BurstFlyerRows['home']>; readonly circleSpeed: v.GenericSchema<BurstFlyerRowsInput['circleSpeed'], BurstFlyerRows['circleSpeed']>; readonly dartSpeed: v.GenericSchema<BurstFlyerRowsInput['dartSpeed'], BurstFlyerRows['dartSpeed']>; readonly noticeRadius: v.GenericSchema<BurstFlyerRowsInput['noticeRadius'], BurstFlyerRows['noticeRadius']>; readonly shoveSpeed: v.GenericSchema<BurstFlyerRowsInput['shoveSpeed'], BurstFlyerRows['shoveSpeed']>; readonly liftSpeed: v.GenericSchema<BurstFlyerRowsInput['liftSpeed'], BurstFlyerRows['liftSpeed']>; readonly targetHeight: v.GenericSchema<BurstFlyerRowsInput['targetHeight'], BurstFlyerRows['targetHeight']>; }, undefined> = v.strictObject({
|
|
46
46
|
id: key, kind: v.literal('burst-flyer'), thinkDivisor: cadence, strike: key, home,
|
|
47
47
|
circleSpeed: speed, dartSpeed: speed, noticeRadius: radius, shoveSpeed: speed, liftSpeed: speed, targetHeight: radius,
|