@wildshard/shard-format 0.46.2 → 0.47.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.47.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": {
|
package/src/format/creatures.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { CreaturePatrolsSchema, patrolsAdmitted, GroupBrainSchema, groupBrainRul
|
|
|
12
12
|
import { RamGrazerSchema, ChallengeGrazerSchema, GrazerSchema } from './grazers.ts';
|
|
13
13
|
import { DiverSchema, OrbitDiverSchema, PatrolDiverSchema, BurstFlyerSchema } from './flyers.ts';
|
|
14
14
|
/** One creature spawn row; input and output differ only in the home they carry. */
|
|
15
|
-
interface CreatureSpawnRow<Home> { 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?: Home | undefined; id: string; species: string; variant: string; brain: (string) | null; strike: (string) | null; seed: number; scale: number; at: [number, number, number]; yaw: number; }
|
|
15
|
+
interface CreatureSpawnRow<Home> { hold?: { field: string; until: string }; 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?: Home | undefined; id: string; species: string; variant: string; brain: (string) | null; strike: (string) | null; seed: number; scale: number; at: [number, number, number]; yaw: number; }
|
|
16
16
|
|
|
17
17
|
const ID_LENGTH = 128;
|
|
18
18
|
const id = v.pipe(v.string(), v.regex(/^[a-z][a-z0-9.:-]*$/u), v.maxLength(ID_LENGTH));
|
|
@@ -85,7 +85,9 @@ const questWhen = v.strictObject({ id, stage });
|
|
|
85
85
|
const waveWhen = v.strictObject({ set: id, index: countPart });
|
|
86
86
|
const timeWhen = v.picklist(['day', 'night'], 'unknown spawn time');
|
|
87
87
|
const when = v.strictObject({ quest: v.exactOptional(questWhen), time: v.exactOptional(timeWhen), wave: v.exactOptional(waveWhen) }, 'unknown spawn condition');
|
|
88
|
-
|
|
88
|
+
// OF19b: the body's memory `field` reads 1 until the quest flag `until` is set (a runtime plan's population `holds` row)
|
|
89
|
+
const hold = v.strictObject({ field: memoryKey, until: id });
|
|
90
|
+
const spawn = v.strictObject({ hold: v.exactOptional(hold), 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: speciesId, 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 });
|
|
89
91
|
/** Pure-data creature archetypes and stable spawn layouts, expanded before the local sim boots. */
|
|
90
92
|
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)), []), patrols: v.exactOptional(CreaturePatrolsSchema), spawns: v.pipe(v.array(spawn), v.maxLength(10000)) }),
|
|
91
93
|
v.check((c) => creatureRules(c).length === 0 && patrolsAdmitted(c.patrols ?? [], c.spawns, c.groups), 'creature reference rules'));
|
|
@@ -381,6 +381,7 @@ export function shardfileRules(s: Shardfile, sections?: ReadonlyMap<string, unkn
|
|
|
381
381
|
if (s.crowds.some(row => Math.abs(row.x) > CHUNK_HALF || Math.abs(row.z) > CHUNK_HALF)) errors.push('declared crowd home in cell');
|
|
382
382
|
if (spawnCapacity(s.creatures.spawns) + crowdMembers > s.serverBudget.entities) errors.push('declared entity capacity');
|
|
383
383
|
errors.push(...creatureSizeRules(s.rows.species, s.creatures.spawns));
|
|
384
|
+
for (const { hold } of s.creatures.spawns) { if (hold !== undefined && !s.quests.flags.includes(hold.until)) { errors.push('declared spawn hold flag'); } }
|
|
384
385
|
for (const spawn of s.creatures.spawns) if (!species.get(spawn.species)?.variants.some((row) => row.id === spawn.variant) || (spawn.strike !== null && !strikes.has(spawn.strike))) errors.push(`declared spawn species/variant/strike: ${spawn.id}`);
|
|
385
386
|
errors.push(...encounterRules(s.encounters, s.creatures.spawns.map((spawn) => spawn.id), s.ui.filter((row) => row.kind === 'bossPanel')));
|
|
386
387
|
const controlled = new Set(s.encounters.map((row) => row.entity));
|