@wildshard/shard-format 0.27.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
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": {
|
|
@@ -20,12 +20,16 @@ import {
|
|
|
20
20
|
union,
|
|
21
21
|
} from 'valibot'
|
|
22
22
|
|
|
23
|
+
import { CreatureProjectileSchema } from './creature-projectile.ts'
|
|
23
24
|
import { CreatureSocketNameSchema } from './creature-volumes.ts'
|
|
24
25
|
import { CreatureSkinClipNameSchema } from './skinData.ts'
|
|
26
|
+
import { StrikeTellKindSchema } from './spawnCombat.ts'
|
|
25
27
|
import { HuntTuningSchema } from './speciesPrograms.ts'
|
|
26
28
|
|
|
27
29
|
import type { CreatureBody } from './creature-body.ts'
|
|
30
|
+
import type { CreatureProjectile } from './creature-projectile.ts'
|
|
28
31
|
import type { CreatureSkinClipName } from './skinData.ts'
|
|
32
|
+
import type { StrikeTellKind } from './spawnCombat.ts'
|
|
29
33
|
import type { SpeciesData } from './speciesPrograms.ts'
|
|
30
34
|
import type { GenericSchema } from 'valibot'
|
|
31
35
|
|
|
@@ -84,6 +88,11 @@ interface CreatureAbility {
|
|
|
84
88
|
duration?: number
|
|
85
89
|
from?: string
|
|
86
90
|
clip?: CreatureSkinClipName
|
|
91
|
+
effect?: 'knockback'
|
|
92
|
+
/** Horizontal travel in metres on clear ground. */
|
|
93
|
+
strength?: number
|
|
94
|
+
tell?: StrikeTellKind
|
|
95
|
+
projectile?: CreatureProjectile
|
|
87
96
|
}
|
|
88
97
|
type CreatureAbilityInput = Omit<CreatureAbility, 'clip'> & { clip?: string }
|
|
89
98
|
interface CreaturePresentation {
|
|
@@ -112,6 +121,7 @@ const MAX_SOUND = 4096
|
|
|
112
121
|
const MAX_RADIUS = 500
|
|
113
122
|
const MAX_SPEED = 15
|
|
114
123
|
const MAX_TIME = 86_400
|
|
124
|
+
const MAX_KNOCKBACK_DISTANCE = 60
|
|
115
125
|
const MAX_AMOUNT = 10_000_000
|
|
116
126
|
const MAX_CALLS = 32
|
|
117
127
|
const MAX_TUNING_FIELDS = 64
|
|
@@ -124,6 +134,11 @@ const speed = pipe(scalar, minValue(ZERO), maxValue(MAX_SPEED))
|
|
|
124
134
|
const unit = pipe(scalar, minValue(ZERO), maxValue(ONE))
|
|
125
135
|
const time = pipe(scalar, minValue(ZERO), maxValue(MAX_TIME))
|
|
126
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
|
+
)
|
|
127
142
|
const orderedRadius = pipe(
|
|
128
143
|
tuple([radius, radius]),
|
|
129
144
|
check<[number, number], 'Ordered creature ability range'>(
|
|
@@ -202,10 +217,7 @@ const CreatureSensesSchema: GenericSchema<CreatureSenses> = strictObject(
|
|
|
202
217
|
},
|
|
203
218
|
'Unknown creature sense',
|
|
204
219
|
)
|
|
205
|
-
const
|
|
206
|
-
CreatureAbilityInput,
|
|
207
|
-
CreatureAbility
|
|
208
|
-
> = strictObject({
|
|
220
|
+
const abilityRow = strictObject({
|
|
209
221
|
use: id,
|
|
210
222
|
range: union([radius, orderedRadius]),
|
|
211
223
|
cooldown: time,
|
|
@@ -217,7 +229,26 @@ const CreatureAbilitySchema: GenericSchema<
|
|
|
217
229
|
duration: exactOptional(time),
|
|
218
230
|
from: exactOptional(CreatureSocketNameSchema),
|
|
219
231
|
clip: exactOptional(CreatureSkinClipNameSchema),
|
|
232
|
+
effect: exactOptional(picklist(['knockback'])),
|
|
233
|
+
strength: exactOptional(knockbackDistance),
|
|
234
|
+
tell: exactOptional(StrikeTellKindSchema),
|
|
235
|
+
projectile: exactOptional(CreatureProjectileSchema),
|
|
220
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)
|
|
221
252
|
const callVariants = pipe(array(sound), maxLength(MAX_CALLS))
|
|
222
253
|
const CreaturePresentationSchema: GenericSchema<CreaturePresentation> =
|
|
223
254
|
strictObject({
|
|
@@ -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 }
|
|
@@ -4,23 +4,28 @@ import { CreatureStrikeSchema } from './creatures.ts';
|
|
|
4
4
|
|
|
5
5
|
const id = v.pipe(v.string(), v.minLength(1), v.maxLength(128));
|
|
6
6
|
const amount = v.pipe(v.number(), v.finite(), v.minValue(0), v.maxValue(60));
|
|
7
|
+
type StrikeTellKind = 'lane' | 'ring';
|
|
8
|
+
const StrikeTellKindSchema: v.GenericSchema<StrikeTellKind> = v.picklist(['lane', 'ring']);
|
|
7
9
|
/** V1 strike capabilities use the existing contact kernel. Effects and presentation edges are rows, never hooks. */
|
|
8
|
-
|
|
10
|
+
const SpawnCombatSchema: v.GenericSchema<SpawnCombatInput, SpawnCombat> = v.pipe(v.unknown(), v.check(isJsonData, 'plain JSON scripted strikes'), v.array(v.strictObject({ id, row: CreatureStrikeSchema,
|
|
9
11
|
trauma: v.pipe(v.number(), v.finite(), v.minValue(0), v.maxValue(1)), stun: amount,
|
|
10
|
-
tell: v.exactOptional(
|
|
12
|
+
tell: v.exactOptional(StrikeTellKindSchema), startCue: v.exactOptional(id), activeCue: v.exactOptional(id), doneCue: v.exactOptional(id),
|
|
11
13
|
})), v.maxLength(32), v.check(rows => new Set(rows.map(row => row.id)).size === rows.length
|
|
12
14
|
&& new Set(rows.map(row => row.row.id)).size === rows.length, 'unique scripted strikes'));
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
/** Admitted data contracts, independent of validator implementation metadata. */
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
type SpawnCombatInput = unknown;
|
|
19
|
+
type SpawnCombat = ({
|
|
18
20
|
id: string;
|
|
19
21
|
row: v.InferOutput<typeof CreatureStrikeSchema>;
|
|
20
22
|
trauma: number;
|
|
21
23
|
stun: number;
|
|
22
|
-
tell?:
|
|
24
|
+
tell?: StrikeTellKind;
|
|
23
25
|
startCue?: string;
|
|
24
26
|
activeCue?: string;
|
|
25
27
|
doneCue?: string;
|
|
26
28
|
})[];
|
|
29
|
+
|
|
30
|
+
export { SpawnCombatSchema, StrikeTellKindSchema };
|
|
31
|
+
export type { SpawnCombat, SpawnCombatInput, StrikeTellKind };
|