@adatechnology/game-weapons 0.1.4 → 0.3.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/dist/index.d.ts CHANGED
@@ -1,6 +1,500 @@
1
- import { Vec3, Shot, Use } from '@adatechnology/game-contracts';
1
+ import { Vec3, Use, ExplosionChain, Shot } from '@adatechnology/game-contracts';
2
2
  export { Shot, Use, Vec3 } from '@adatechnology/game-contracts';
3
3
 
4
+ type AttachmentId = string;
5
+ /** Where on a weapon something goes. */
6
+ type MountKind = 'muzzle' | 'rail_top' | 'rail_bottom' | 'rail_left' | 'rail_right' | 'underbarrel' | 'magazine' | 'stock' | 'barrel' | 'sling' | 'feed';
7
+ /**
8
+ * A place on a weapon an accessory can take. `interfaces` is what the place accepts: `picatinny`, `mlok`, `ak_side`, `dovetail`, `thread_1/2x28`, `thread_5/8x24`,
9
+ * `thread_14x1lh`, `thread_24x1.5`, `hk_3lug`, `m203`, `gp25`, `ag36`, `mag_<family>`, `buffer_tube`, `swivel`, `belt`, `tripod`.
10
+ */
11
+ interface MountDef {
12
+ readonly kind: MountKind;
13
+ readonly interfaces: readonly string[];
14
+ /** Metres of rail or free length at the place. */
15
+ readonly length?: number;
16
+ readonly sources: readonly DataSource[];
17
+ }
18
+ /** What an accessory changes on the weapon it is on. */
19
+ type WeaponStat = 'noise' | 'spread' | 'hipSpreadExcess' | 'recoilVertical' | 'recoilHorizontal' | 'range' | 'muzzleSpeed' | 'mass' | 'capacity' | 'reload' | 'reloadEmpty' | 'draw' | 'aim' | 'faultChance' | 'heatPerShot';
20
+ /** When an effect counts: `supported` is lying down or on a bipod or tripod, `subsonic` the bullet is slower than sound, `collapsed` the stock is folded. */
21
+ type EffectCondition = 'always' | 'aiming' | 'hip' | 'supported' | 'subsonic' | 'collapsed';
22
+ /** One change of one number: every `set` first, then the sum of the `add`s, then the product of the `mul`s. */
23
+ interface StatModifier {
24
+ readonly stat: WeaponStat;
25
+ readonly mul?: number;
26
+ readonly add?: number;
27
+ readonly set?: number;
28
+ readonly when?: EffectCondition;
29
+ }
30
+ type AttachmentKind = 'suppressor' | 'muzzle_device' | 'optic' | 'light' | 'laser' | 'grip' | 'bipod' | 'underbarrel' | 'magazine' | 'stock' | 'barrel' | 'sling' | 'feed' | 'mount';
31
+ type AttachmentInstall = 'field' | 'tool' | 'bench';
32
+ interface AttachmentDef {
33
+ readonly id: AttachmentId;
34
+ /** Generic real-world description used as the default name. */
35
+ readonly name?: string;
36
+ readonly kind: AttachmentKind;
37
+ /** The places it can take. */
38
+ readonly mounts: readonly MountKind[];
39
+ /** The interfaces it fits (one of them must be on the mount). */
40
+ readonly interfaces: readonly string[];
41
+ /** Places that stop being usable while it is on (a grenade launcher takes the lower rail). */
42
+ readonly blocks?: readonly MountKind[];
43
+ /** A suppressor takes calibres up to a diameter and an energy; `ids` limits it to named calibres. */
44
+ readonly calibers?: {
45
+ readonly maxDiameter?: number;
46
+ readonly maxEnergy?: number;
47
+ readonly ids?: readonly CaliberId[];
48
+ };
49
+ readonly categories?: readonly WeaponCategory[];
50
+ /** Kg. */
51
+ readonly mass: number;
52
+ /** Metres. */
53
+ readonly dims?: {
54
+ readonly length: number;
55
+ readonly diameter?: number;
56
+ readonly width?: number;
57
+ readonly height?: number;
58
+ };
59
+ /** Where it can be put on: in the field with the hands, with a tool, or only at a bench. */
60
+ readonly install: AttachmentInstall;
61
+ readonly removable?: boolean;
62
+ readonly effects: readonly StatModifier[];
63
+ readonly optic?: {
64
+ readonly zoom: readonly [number, number];
65
+ readonly reticle: 'dot' | 'holo' | 'chevron' | 'duplex' | 'mildot';
66
+ readonly vision?: 'day' | 'night' | 'thermal';
67
+ readonly batteryHours?: number;
68
+ };
69
+ readonly light?: {
70
+ readonly coneDeg: number;
71
+ readonly range: number;
72
+ readonly visibleFrom: number;
73
+ readonly batteryHours?: number;
74
+ };
75
+ readonly laser?: {
76
+ readonly color: number;
77
+ readonly range: number;
78
+ readonly visibleFrom: number;
79
+ };
80
+ /** The weapon a grenade launcher accessory is. */
81
+ readonly launcher?: WeaponId;
82
+ /** Shots until it breaks, between the two numbers (a home-made suppressor). */
83
+ readonly durability?: {
84
+ readonly shots: readonly [number, number];
85
+ };
86
+ /** Carried on the back (an ammunition backpack). */
87
+ readonly carry?: 'back';
88
+ /** Can be slung, which lets the weapon be stowed on the body (a sling). */
89
+ readonly stowable?: boolean;
90
+ /** The effects count on every second reload only: the spare magazine is already coupled (a dual coupler). */
91
+ readonly secondReload?: boolean;
92
+ /** Name of the model the renderer draws it with. */
93
+ readonly model: string;
94
+ readonly sources: readonly DataSource[];
95
+ }
96
+ /** An accessory on a weapon: the place it is in, whether it came with the weapon (`integral`) and, for a light or a laser, whether it is on. */
97
+ interface FittedAttachment {
98
+ readonly id: AttachmentId;
99
+ readonly mount: MountKind;
100
+ readonly integral?: boolean;
101
+ readonly on?: boolean;
102
+ /** Shots until a home-made accessory breaks (drawn when it goes on). */
103
+ readonly shotsLeft?: number;
104
+ }
105
+ type StockState = 'collapsed' | 'extended';
106
+ /** What the stock of a weapon does: `fold` swings to a side, `retract` slides in, `none` has no shoulder piece. */
107
+ interface StockDef {
108
+ readonly kind: 'fixed' | 'fold' | 'retract' | 'fold_retract' | 'none';
109
+ readonly foldAxis?: 'right' | 'left' | 'under' | 'over';
110
+ }
111
+ /** What `snapshot()` gives and `arsenal.restore()` takes: enough to rebuild a weapon exactly as it was (the random streams restart from the seed given). */
112
+ interface WeaponSnapshot {
113
+ readonly id: WeaponId;
114
+ readonly attachments: readonly FittedAttachment[];
115
+ readonly stock: StockState;
116
+ readonly ammo: number;
117
+ readonly reserve: number;
118
+ readonly mode: FireMode;
119
+ readonly condition: string;
120
+ readonly ammoQuality: string;
121
+ readonly underbarrel?: WeaponSnapshot;
122
+ }
123
+
124
+ type FitRefusal = 'no_mount' | 'interface' | 'caliber' | 'category' | 'occupied' | 'blocked' | 'rejected';
125
+ type CanFit = {
126
+ readonly ok: true;
127
+ readonly mount: MountKind;
128
+ } | {
129
+ readonly ok: false;
130
+ readonly reason: FitRefusal;
131
+ };
132
+ /** What a game adds to the rule: false keeps the accessory off the weapon whatever the mounts say. */
133
+ type IsCompatible = (def: WeaponDef, attachment: AttachmentDef, fitted: readonly FittedAttachment[]) => boolean;
134
+ interface CanFitContext {
135
+ readonly caliber: CaliberDef | null;
136
+ readonly catalogue: ReadonlyMap<string, AttachmentDef>;
137
+ readonly isCompatible?: IsCompatible;
138
+ }
139
+ /** Whether what is at hand (`field`: the hands, `tool`: a tool, `bench`: a bench) is enough to put the accessory on or take it off. */
140
+ declare const canInstallWith: (available: AttachmentInstall, needed: AttachmentInstall) => boolean;
141
+ /**
142
+ * Whether the accessory goes on the weapon, and where. Order of the checks: a place of its kind (`no_mount`), an interface the place takes
143
+ * (`interface`), the calibre limits of a suppressor (`caliber`), the weapon categories (`category`), the place being free (`occupied`),
144
+ * something else covering it (`blocked`), then the game's own `isCompatible` (`rejected`).
145
+ */
146
+ declare const canFit: (def: WeaponDef, attachment: AttachmentDef, fitted: readonly FittedAttachment[], context: CanFitContext, mount?: MountKind) => CanFit;
147
+
148
+ /** Everything a host needs to apply a blast: where, how big, in which direction, and what else it does. */
149
+ interface Detonation {
150
+ readonly explosive: ExplosiveId;
151
+ readonly cause: ExplosiveTrigger;
152
+ readonly point: Vec3;
153
+ /** The way a directional charge faces; for everything else the direction the body was moving (or facing when placed). */
154
+ readonly direction: Vec3;
155
+ /** Seconds on the clock of the body. */
156
+ readonly at: number;
157
+ readonly energy: number;
158
+ readonly lethalRadius: number;
159
+ readonly injuryRadius: number;
160
+ readonly noise: number;
161
+ readonly destructionLevel: ExplosiveDef['destructionLevel'];
162
+ readonly cone?: ExplosiveDef['cone'];
163
+ readonly stunSeconds?: number;
164
+ readonly fire?: ExplosiveDef['fire'];
165
+ }
166
+ type ExplosiveEvent = {
167
+ type: 'armed';
168
+ at: number;
169
+ distance: number;
170
+ } | {
171
+ type: 'impact';
172
+ at: number;
173
+ point: Vec3;
174
+ armed: boolean;
175
+ }
176
+ /** Hit something before it was armed: it does not explode. */
177
+ | {
178
+ type: 'dud';
179
+ at: number;
180
+ point: Vec3;
181
+ } | {
182
+ type: 'detonate';
183
+ at: number;
184
+ detonation: Detonation;
185
+ };
186
+ /** The first surface the segment `from` to `to` crosses: where, its normal and whether it is ground (default: normal pointing up). */
187
+ type SurfaceProbe = (from: Vec3, to: Vec3) => {
188
+ point: Vec3;
189
+ normal: Vec3;
190
+ ground?: boolean;
191
+ } | null;
192
+ interface ExplosiveBodyInit {
193
+ readonly explosive: ExplosiveDef;
194
+ readonly origin: Vec3;
195
+ /** Initial velocity in m/s; absent for something set down. */
196
+ readonly velocity?: Vec3;
197
+ /** Facing of a placed charge (the cone of a mine). */
198
+ readonly direction?: Vec3;
199
+ /** `timer`: explodes `fuse` seconds after it leaves the hand; `impact`: explodes on the first hit once armed; `wire`/`remote`: waits for `trigger()`. */
200
+ readonly triggers: readonly ExplosiveTrigger[];
201
+ readonly fuse?: number;
202
+ /** Metres to fly before an impact sets it off (rockets); 0 arms it at once. */
203
+ readonly armDistance?: number;
204
+ readonly rules: WeaponRules['explosives'];
205
+ }
206
+ /**
207
+ * One explosive in flight or set down. `step` flies it (gravity, bounces off what `probe` finds) and counts the fuse; `trigger` sets off what waits
208
+ * for a wire, a remote detonator, a bullet, fire or a nearby blast. Same inputs, same events: there is no randomness.
209
+ */
210
+ declare class ExplosiveBody {
211
+ position: Vec3;
212
+ velocity: Vec3;
213
+ readonly explosive: ExplosiveDef;
214
+ private readonly triggers;
215
+ private readonly armDistance;
216
+ private readonly rules;
217
+ private facing;
218
+ private clock;
219
+ private flown;
220
+ private fuseLeft;
221
+ private isArmed;
222
+ private isDone;
223
+ private isDud;
224
+ constructor(init: ExplosiveBodyInit);
225
+ get age(): number;
226
+ /** Metres flown so far. */
227
+ get travelled(): number;
228
+ get armed(): boolean;
229
+ /** Exploded or turned out a dud: nothing more happens. */
230
+ get done(): boolean;
231
+ get dud(): boolean;
232
+ /** Seconds until the timer sets it off, or undefined without one. */
233
+ get fuseRemaining(): number | undefined;
234
+ step(dt: number, probe?: SurfaceProbe): ExplosiveEvent[];
235
+ /** Sets it off from outside; undefined when this explosive does not answer to `cause` or is already done. */
236
+ trigger(cause: ExplosiveTrigger): ExplosiveEvent | undefined;
237
+ private moves;
238
+ private fly;
239
+ private checkArmed;
240
+ private onImpact;
241
+ private detonate;
242
+ }
243
+ /** The body of the explosive a `throw` or `place` use carries; undefined for any other use or an unknown explosive id. */
244
+ declare const createExplosiveBody: (use: Use, explosives: ReadonlyMap<ExplosiveId, ExplosiveDef>, rules: WeaponRules["explosives"]) => ExplosiveBody | undefined;
245
+
246
+ type ExplosiveId = string;
247
+ /** What sets an explosive off: its own timer, hitting something, a bullet, fire, a trip wire, a remote detonator, or another blast nearby. */
248
+ type ExplosiveTrigger = 'timer' | 'impact' | 'shot' | 'fire' | 'wire' | 'remote' | 'explosion';
249
+ /** Chain reaction of an explosive that sits in the world (fuel barrel, car tank, gas pump); `game-destruction` reads it from `explodes.chain`. */
250
+ type ExplosiveChain = ExplosionChain;
251
+ /** The wire a placed charge stretches: from the charge, `length` metres out at `angleDeg` from the way it faces, `height` metres above where it sits. */
252
+ interface ExplosiveTripwire {
253
+ /** Metres. */
254
+ readonly length: number;
255
+ /** Degrees from the facing of the charge, counter-clockwise seen from above (default 0: straight ahead). */
256
+ readonly angleDeg?: number;
257
+ /** Metres above the charge (default 0.15: shin height). */
258
+ readonly height?: number;
259
+ }
260
+ interface ExplosiveDef {
261
+ readonly id: ExplosiveId;
262
+ readonly name?: string;
263
+ readonly kind: 'fragmentation' | 'blast' | 'incendiary' | 'directional' | 'flash' | 'shaped_charge' | 'fuel';
264
+ /** Radius in metres inside which everything dies. */
265
+ readonly lethalRadius: number;
266
+ /** Radius in metres of the wounding area (damage falls with distance). */
267
+ readonly injuryRadius: number;
268
+ readonly cone?: {
269
+ readonly halfAngleDeg: number;
270
+ readonly length: number;
271
+ };
272
+ /** Joules. */
273
+ readonly energy: number;
274
+ /** What the blast tears down: 0 nothing, 1 light, 2 walls, 3 structures. */
275
+ readonly destructionLevel: 0 | 1 | 2 | 3;
276
+ /** Audible distance in metres. */
277
+ readonly noise: number;
278
+ /** Seconds from arming to the blast; fixed. Overridden by `fuseLength` with `burnRate`, or by `fuseRange`. */
279
+ readonly fuse?: number;
280
+ /** Seconds from arming to the blast, sampled per throw between the two ends (a flashbang: 1.0 to 2.3 s from the lever). */
281
+ readonly fuseRange?: readonly [number, number];
282
+ /** Metres of safety fuse; with `burnRate` it gives the fuse in seconds, so a longer fuse builds a delayed trap. */
283
+ readonly fuseLength?: number;
284
+ /** Seconds the safety fuse takes to burn one metre (about 131 s/m). */
285
+ readonly burnRate?: number;
286
+ /** Scatter of the burn rate as a fraction, sampled per throw (0.1 = ±10%). */
287
+ readonly burnTolerance?: number;
288
+ readonly stunSeconds?: number;
289
+ readonly fire?: {
290
+ temperature: number;
291
+ radius: number;
292
+ seconds: number;
293
+ };
294
+ readonly triggers?: readonly ExplosiveTrigger[];
295
+ readonly chain?: ExplosiveChain;
296
+ /** The trip wire of an explosive with the `wire` trigger; without it the one in `rules.explosives.tripwire` is used. */
297
+ readonly tripwire?: ExplosiveTripwire;
298
+ /** Kilograms. */
299
+ readonly mass?: number;
300
+ readonly sources?: readonly DataSource[];
301
+ }
302
+
303
+ /** Locales shipped with the package. Unknown locales fall back to `en`. */
304
+ type WeaponsLocale = 'en' | 'pt-BR';
305
+ interface WeaponsStrings {
306
+ /** Display name of each weapon id. */
307
+ weapons: Record<string, string>;
308
+ /** Display name of each fire mode. */
309
+ modes: Record<string, string>;
310
+ /** Display name of each weapon category. */
311
+ categories: Record<string, string>;
312
+ /** Display name of each explosive id. */
313
+ explosives: Record<string, string>;
314
+ /** Display name of each weapon fault. */
315
+ faults: Record<string, string>;
316
+ /** Display name of each weapon condition. */
317
+ conditions: Record<string, string>;
318
+ }
319
+ declare const locales: Record<WeaponsLocale, WeaponsStrings>;
320
+ declare const resolveStrings: (locale: string | undefined, overrides?: DeepPartial<WeaponsStrings>) => WeaponsStrings;
321
+
322
+ type FaultId = 'misfire' | 'stovepipe' | 'double_feed' | 'failure_to_extract';
323
+ /** Wear of a weapon and how likely it jams. */
324
+ interface ConditionDef {
325
+ readonly id: string;
326
+ /** Chance of a fault per round, 0 to 1. */
327
+ readonly faultChance: number;
328
+ }
329
+ /** Quality of the ammunition and how likely a round does not fire. */
330
+ interface AmmoQualityDef {
331
+ readonly id: string;
332
+ readonly faultChance: number;
333
+ }
334
+ interface FaultContext {
335
+ readonly def: WeaponDef;
336
+ readonly condition: ConditionDef;
337
+ /** Heat of the weapon, 0 to `rules.heat.cap`. */
338
+ readonly heat: number;
339
+ }
340
+ /** Numbers that rule how weapons behave in a game; override any of them with `ArsenalOptions.rules`. */
341
+ interface WeaponRules {
342
+ readonly faults: boolean;
343
+ readonly conditions: readonly ConditionDef[];
344
+ readonly defaultCondition: string;
345
+ readonly ammoQualities: readonly AmmoQualityDef[];
346
+ readonly defaultAmmoQuality: string;
347
+ readonly faultChance: (context: FaultContext) => number;
348
+ readonly heat: {
349
+ readonly cap: number;
350
+ readonly displayMax: number;
351
+ readonly decayBase: number;
352
+ readonly decayPerPoint: number;
353
+ readonly faultFrom: number;
354
+ readonly faultSpan: number;
355
+ readonly perShot: Readonly<Record<CaseType, number>>;
356
+ readonly perRocket: number;
357
+ };
358
+ /** Each shot in the last `window` seconds raises the noise radius by `step`, up to `cap`. */
359
+ readonly noiseBurst: {
360
+ readonly step: number;
361
+ readonly window: number;
362
+ readonly cap: number;
363
+ };
364
+ /** How thrown and launched explosives fly and bounce. */
365
+ readonly explosives: {
366
+ /** m/s². */
367
+ readonly gravity: number;
368
+ /** Fraction of the speed along the surface normal kept (and reversed) in a bounce off the ground. */
369
+ readonly groundRestitution: number;
370
+ /** Fraction of the speed along the ground kept after a bounce off the ground. */
371
+ readonly groundFriction: number;
372
+ /** Fraction of the speed kept (and reversed) in a bounce off a wall. */
373
+ readonly wallRestitution: number;
374
+ /** A timer explosive whose fuse is at least this many seconds is set down lit instead of thrown (a long safety fuse: a delayed trap). */
375
+ readonly placeFuseFrom: number;
376
+ /** The wire of a charge set down with the `wire` trigger that does not name one. */
377
+ readonly tripwire: Required<ExplosiveTripwire>;
378
+ };
379
+ /** Putting accessories on and taking them off. */
380
+ readonly attachments: {
381
+ /** Seconds the work takes, by where it can be done: with the hands, with a tool, at a bench. */
382
+ readonly fitSeconds: Readonly<Record<AttachmentInstall, number>>;
383
+ /** Seconds to change between the weapon and the launcher under its barrel. */
384
+ readonly switchSeconds: number;
385
+ /** m/s: a bullet slower than this is subsonic (a suppressor mutes it more). */
386
+ readonly speedOfSound: number;
387
+ };
388
+ /** Time to raise the weapon to the sights (`base` + `perKg` × mass) and how much worse the hip is: `hipSpread` times the spread when not aiming (1: no difference). */
389
+ readonly aim: {
390
+ readonly base: number;
391
+ readonly perKg: number;
392
+ readonly hipSpread: number;
393
+ };
394
+ /** Folding or sliding in the stock: the seconds it takes and what it does to the weapon while it is in. */
395
+ readonly stock: {
396
+ readonly seconds: number;
397
+ readonly collapsed: readonly StatModifier[];
398
+ };
399
+ readonly draw: number;
400
+ readonly clear: number;
401
+ readonly startSafe: boolean;
402
+ }
403
+ type ReloadKind = 'tactical' | 'empty' | 'one_by_one';
404
+ type ReloadStageId = 'magazine_out' | 'magazine_in' | 'charge' | 'bolt_open' | 'round_in' | 'bolt_close' | 'pump_cycle' | 'lever_cycle' | 'cylinder_open' | 'cylinder_eject' | 'cylinder_load' | 'cylinder_close' | 'barrels_open' | 'casings_eject' | 'rounds_in' | 'barrels_close' | 'cover_open' | 'belt_swap' | 'cover_close' | 'tank_swap' | 'tube_drop' | 'tube_seat' | 'rocket_seat' | 'breech_open' | 'breech_close';
405
+ /** `at` is a fraction (0 to 1) of the whole reload. */
406
+ interface ReloadStage {
407
+ readonly stage: ReloadStageId;
408
+ readonly at: number;
409
+ }
410
+ /** Events a weapon emits for a host to animate and play sounds; `at` is the weapon clock in seconds. */
411
+ type WeaponEvent = {
412
+ type: 'draw';
413
+ phase: 'start' | 'end';
414
+ at: number;
415
+ } | {
416
+ type: 'shot';
417
+ shots: number;
418
+ rounds: number;
419
+ mode: FireMode;
420
+ at: number;
421
+ suppressed?: boolean;
422
+ } | {
423
+ type: 'misfire';
424
+ at: number;
425
+ } | {
426
+ type: 'cycle';
427
+ phase: 'start' | 'end';
428
+ at: number;
429
+ } | {
430
+ type: 'reload';
431
+ phase: 'start' | 'end';
432
+ kind: ReloadKind;
433
+ at: number;
434
+ } | {
435
+ type: 'reload_stage';
436
+ stage: ReloadStageId;
437
+ at: number;
438
+ } | {
439
+ type: 'feed';
440
+ at: number;
441
+ } | {
442
+ type: 'empty';
443
+ at: number;
444
+ } | {
445
+ type: 'mode';
446
+ mode: FireMode;
447
+ at: number;
448
+ } | {
449
+ type: 'fault';
450
+ fault: FaultId;
451
+ at: number;
452
+ } | {
453
+ type: 'clear';
454
+ fault: FaultId;
455
+ phase: 'start' | 'end';
456
+ at: number;
457
+ } | {
458
+ type: 'safety';
459
+ on: boolean;
460
+ at: number;
461
+ }
462
+ /** Cooking a throwable: `start` pulls the pin, `throw` releases it with `fuse` seconds left, `burst` is the fuse running out while held (`fuse` 0). */
463
+ | {
464
+ type: 'cook';
465
+ phase: 'start' | 'throw' | 'burst';
466
+ fuse: number;
467
+ at: number;
468
+ }
469
+ /** An accessory goes on (`fit`), comes off (`remove`) or breaks (`break`, a home-made suppressor). `mount` is where it was. */
470
+ | {
471
+ type: 'attachment';
472
+ action: 'fit' | 'remove' | 'break';
473
+ id: AttachmentId;
474
+ mount: MountKind;
475
+ at: number;
476
+ }
477
+ /** A light or a laser is turned on or off. */
478
+ | {
479
+ type: 'toggle';
480
+ id: AttachmentId;
481
+ on: boolean;
482
+ at: number;
483
+ }
484
+ /** The stock is folded or slid in (`collapsed`) or opened (`extended`). */
485
+ | {
486
+ type: 'stock';
487
+ state: StockState;
488
+ kind: StockDef['kind'];
489
+ at: number;
490
+ }
491
+ /** The weapon in the hand changes between the rifle and the launcher under its barrel. */
492
+ | {
493
+ type: 'underbarrel';
494
+ on: boolean;
495
+ at: number;
496
+ };
497
+
4
498
  /**
5
499
  * Public types of @adatechnology/game-weapons.
6
500
  *
@@ -34,9 +528,52 @@ interface CaliberDef {
34
528
  /** Armour-piercing or hollow-point flavour (a damage model may use it). */
35
529
  kind?: 'fmj' | 'hp' | 'ap' | 'buck' | 'slug' | 'birdshot' | 'rimfire' | 'arrow' | 'bolt';
36
530
  tags?: string[];
531
+ /** Audible distance of a shot in this calibre, metres. A weapon may override it (suppressor). */
532
+ noise?: number;
533
+ caseType?: CaseType;
534
+ rim?: RimType;
535
+ cartridge?: CartridgeDims;
536
+ /** Where the numbers come from (team deliveries, the SDK itself, a published reference, or derived from a sibling). */
537
+ sources?: readonly DataSource[];
538
+ }
539
+ type CaseType = 'pistol' | 'rifle' | 'shell' | 'big' | 'tiny';
540
+ type RimType = 'rimfire' | 'rimmed' | 'rimless' | 'shell';
541
+ type DataSource = 'gallery' | 'arsenal' | 'game' | 'lab' | 'sdk' | 'reference' | 'derived';
542
+ /** Real cartridge dimensions in mm. */
543
+ interface CartridgeDims {
544
+ readonly caseDiameter: number;
545
+ readonly overallLength: number;
546
+ readonly caseLength: number;
547
+ readonly projectileDiameter: number;
548
+ }
549
+ /** What a `firearm` action holds. */
550
+ type FirearmAction = Extract<WeaponAction, {
551
+ kind: 'firearm';
552
+ }>;
553
+ type FireMode = 'single' | 'semi' | 'burst' | 'auto' | 'pump' | 'bolt' | 'lever' | 'break' | 'volley';
554
+ type WeaponCategory = 'pistol' | 'revolver' | 'smg' | 'rifle' | 'carbine' | 'sniper' | 'dmr' | 'hunting' | 'machine_gun' | 'launcher' | 'shotgun' | 'bow' | 'crossbow' | 'melee_blunt' | 'melee_blade' | 'flame' | 'heat' | 'throwable' | 'tool' | 'extinguisher' | 'hand';
555
+ /** How a weapon is reloaded; it picks the animation set and the order of the reload stages. */
556
+ type ReloadFamily = 'pistol' | 'magazine' | 'top_magazine' | 'top_load_semi' | 'tube_semi' | 'pump' | 'lever' | 'bolt' | 'bolt_magazine' | 'belt' | 'revolver' | 'break' | 'rocket' | 'underbarrel' | 'flame';
557
+ /** Seconds of each phase of handling a weapon. */
558
+ interface WeaponTimings {
559
+ readonly draw: number;
560
+ readonly reload: number;
561
+ readonly reloadEmpty?: number;
562
+ /** Seconds per round when the weapon loads one round at a time. */
563
+ readonly perRound?: number;
564
+ /** Seconds to cycle a manual action between shots. */
565
+ readonly cycle?: number;
566
+ /** Seconds to clear a fault. */
567
+ readonly clear: number;
568
+ readonly modeSwitch?: number;
569
+ }
570
+ /** Real dimensions: metres and kilograms. */
571
+ interface WeaponDimensions {
572
+ readonly length: number;
573
+ readonly barrel: number;
574
+ readonly emptyMass: number;
575
+ readonly lengthCollapsed?: number;
37
576
  }
38
- type FireMode = 'single' | 'semi' | 'burst' | 'auto' | 'pump' | 'bolt' | 'lever' | 'break';
39
- type WeaponCategory = 'pistol' | 'revolver' | 'smg' | 'rifle' | 'carbine' | 'sniper' | 'shotgun' | 'bow' | 'crossbow' | 'melee_blunt' | 'melee_blade' | 'flame' | 'heat' | 'throwable' | 'tool' | 'extinguisher' | 'hand';
40
577
  /** What using the item does. Firearms produce ballistic shots; the rest produce one `Use` of their kind. */
41
578
  type WeaponAction = {
42
579
  kind: 'firearm';
@@ -62,8 +599,50 @@ type WeaponAction = {
62
599
  recoil: [number, number];
63
600
  /** Effective range in metres (shots past it keep going with drag; the host may cut them). */
64
601
  range: number;
65
- /** Audible distance in metres (a horde game uses it to attract zombies). */
66
- noise: number;
602
+ /** Audible distance in metres (a horde game uses it to attract zombies). Defaults to the calibre's `noise`. */
603
+ noise?: number;
604
+ /** Muzzle speed of this weapon, m/s. Defaults to the calibre reference times `barrel`. */
605
+ muzzleSpeed?: number;
606
+ family?: ReloadFamily;
607
+ timings?: WeaponTimings;
608
+ /** Rounds that fit in the chamber on top of the magazine. */
609
+ chamber?: number;
610
+ /** Other magazine sizes the weapon accepts. */
611
+ magazineOptions?: readonly number[];
612
+ /** Magazine tubes (a bullpup shotgun has two). */
613
+ tubes?: number;
614
+ /** Multiplies the fault chance (1 = average, below 1 more reliable). */
615
+ faultFactor?: number;
616
+ /** A rotary gun: seconds the barrels need to reach speed before the first round of a pull, and how long they keep spinning after the last one. */
617
+ spin?: {
618
+ readonly upSeconds: number;
619
+ readonly holdSeconds: number;
620
+ };
621
+ /** The cyclic rates a rotary gun can be set to; `rpm` is the default and a `patch` may change it inside this range. */
622
+ rpmRange?: readonly [number, number];
623
+ /** Real accuracy in minutes of angle (data only). */
624
+ moa?: number;
625
+ /** Shotgun pattern width at 25 m in centimetres (data only). */
626
+ patternCm?: number;
627
+ /** Other calibres the weapon fires (a .357 revolver also fires .38 Special). */
628
+ acceptsCalibers?: readonly CaliberId[];
629
+ } | {
630
+ kind: 'launcher';
631
+ projectile: ExplosiveId;
632
+ magazine: number;
633
+ reload: number;
634
+ timings?: WeaponTimings;
635
+ family: 'rocket' | 'break' | 'underbarrel';
636
+ disposable?: boolean;
637
+ speed: number;
638
+ /** Distance in metres below which the projectile hits without exploding. */
639
+ minArmDistance: number;
640
+ /** Radius in metres of the blast behind the launcher. */
641
+ backblast: number;
642
+ /** Half-angle in degrees of the cone behind the launcher where the blast is dangerous (default 180: the whole sphere of `backblast`). */
643
+ backblastHalfAngleDeg?: number;
644
+ recoil: [number, number];
645
+ noise?: number;
67
646
  } | {
68
647
  kind: 'melee';
69
648
  damage: 'blunt' | 'slash';
@@ -82,6 +661,8 @@ type WeaponAction = {
82
661
  fuel: number;
83
662
  cone?: boolean;
84
663
  noise: number;
664
+ family?: ReloadFamily;
665
+ timings?: WeaponTimings;
85
666
  } | {
86
667
  kind: 'heat';
87
668
  temperature: number;
@@ -92,7 +673,8 @@ type WeaponAction = {
92
673
  noise: number;
93
674
  } | {
94
675
  kind: 'throwable'; /** Throwables carried (default 3). */
95
- count?: number;
676
+ count?: number; /** The explosive this throwable uses; `energy`, `radius` and `noise` come from it. */
677
+ explosive?: ExplosiveId;
96
678
  energy: number;
97
679
  radius: number;
98
680
  fuse: number;
@@ -127,6 +709,20 @@ interface WeaponDef {
127
709
  /** Mass in kg (carry weight, and thrown melee weapons). */
128
710
  mass: number;
129
711
  tags?: string[];
712
+ dimensions?: WeaponDimensions;
713
+ /** Maker of a real-world model, e.g. `Glock`. */
714
+ maker?: string;
715
+ /** The generic weapon whose handling numbers (spread, bloom, range, recoil) this model uses. */
716
+ archetype?: WeaponId;
717
+ /** The weapon this one is a variant of. */
718
+ variantOf?: WeaponId;
719
+ /** The places an accessory can go on this weapon. */
720
+ mounts?: readonly MountDef[];
721
+ /** The accessories the weapon comes with; their effects are already in the numbers of `action`. */
722
+ fitted?: readonly FittedAttachment[];
723
+ /** What the stock does (fold, retract); absent: a fixed stock or none. */
724
+ stock?: StockDef;
725
+ sources?: readonly DataSource[];
130
726
  }
131
727
  interface TriggerResult {
132
728
  /** Shots fired this call (firearms). */
@@ -134,11 +730,45 @@ interface TriggerResult {
134
730
  /** Uses this call (everything else). */
135
731
  uses: Use[];
136
732
  /** `ok`, or why nothing happened. */
137
- status: 'ok' | 'empty' | 'reloading' | 'cooldown' | 'no_fuel' | 'safe';
733
+ status: 'ok' | 'empty' | 'reloading' | 'cooldown' | 'no_fuel' | 'safe' | 'drawing' | 'fault' | 'misfire' | 'clearing' | 'busy';
138
734
  /** Camera kick to apply, degrees [pitch, yaw]. */
139
735
  recoil: [number, number];
140
736
  /** Audible radius of what happened, metres (0 when nothing). */
141
737
  noise: number;
738
+ /** True when a suppressor was on for the shots of this call (the host passes it to the shot sound). */
739
+ suppressed?: boolean;
740
+ /** Cartridges spent by this call: a shotgun shell is one, a burst is several. */
741
+ rounds: number;
742
+ /** Seconds after the start of the call at which each round left the barrel. */
743
+ roundTimes: number[];
744
+ /** The fault that stopped the weapon during this call, if any. */
745
+ fault?: FaultId;
746
+ }
747
+ type ReloadRequest = 'auto' | 'full' | 'one_by_one';
748
+ /** What the weapon is busy with right now, and between which seconds of its own clock. */
749
+ interface WeaponPhase {
750
+ readonly id: 'draw' | 'cycle' | 'reload' | 'clear' | 'mode' | 'fit' | 'stock' | 'switch';
751
+ readonly start: number;
752
+ readonly end: number;
753
+ }
754
+ /** What the hands have to put an accessory on (`install`) and where, when it fits on more than one place (`mount`). */
755
+ interface FitOptions {
756
+ readonly install?: AttachmentInstall;
757
+ readonly mount?: MountKind;
758
+ }
759
+ /** Whether the work started, with the seconds it takes (the phase `fit`), or why not. */
760
+ type FitResult = {
761
+ readonly ok: true;
762
+ readonly seconds: number;
763
+ } | {
764
+ readonly ok: false;
765
+ readonly reason: FitRefusal | 'busy' | 'unknown' | 'install' | 'fixed' | 'not_fitted';
766
+ };
767
+ /** How the weapon is held: it decides which conditional effects count. */
768
+ interface WeaponStance {
769
+ readonly aiming?: boolean;
770
+ /** Lying down, or on a bipod or tripod. */
771
+ readonly supported?: boolean;
142
772
  }
143
773
  interface WeaponState {
144
774
  readonly def: WeaponDef;
@@ -150,65 +780,266 @@ interface WeaponState {
150
780
  reserve: number;
151
781
  mode: FireMode;
152
782
  readonly reloading: boolean;
783
+ /** True after a pistol fires its last round: the slide stays back until the magazine is changed. */
784
+ readonly locked: boolean;
785
+ readonly phase: WeaponPhase | null;
786
+ /** The fault the weapon is stuck with until it is cleared. */
787
+ readonly fault: FaultId | null;
788
+ readonly clearing: boolean;
789
+ /** With the safety on the trigger does nothing. */
790
+ readonly safety: boolean;
791
+ /** Heat of the barrel, 0 to `rules.heat.cap`. */
792
+ readonly heat: number;
793
+ /** 0 to 1: the heat against what the display shows as full. */
794
+ readonly heatLevel: number;
795
+ readonly condition: string;
796
+ readonly ammoQuality: string;
153
797
  /** Current spread in degrees (base + bloom). */
154
798
  readonly spread: number;
155
799
  /**
156
800
  * Pull or hold the trigger for `dt` seconds from `origin` towards `direction`. `held` = the trigger stays down (auto fire, continuous
157
- * flame); a new pull with `held: false` fires semi/single once.
801
+ * flame); a new pull with `held: false` fires semi/single once. A throwable with a timer fuse is cooked: the pull takes the pin out and the
802
+ * fuse starts to count, `release()` throws it with the fuse that is left, and holding past the fuse sets it off in the hand (a `throw` use with
803
+ * `inHand`). Impact and remote ones, and the ones set down, act on the pull.
158
804
  */
159
805
  trigger(origin: Vec3, direction: Vec3, dt: number, held?: boolean, source?: string): TriggerResult;
160
- release(): void;
161
- reload(): boolean;
806
+ /**
807
+ * Lets go of the trigger. A throwable being cooked (see `trigger`) is thrown with what is left of its fuse, so this returns the result of that throw
808
+ * (`origin` and `direction` default to the aim of the last `trigger` call); anything else returns null.
809
+ */
810
+ release(origin?: Vec3, direction?: Vec3): TriggerResult | null;
811
+ /** True while a throwable's pin is pulled and the trigger is held. */
812
+ readonly cooking: boolean;
813
+ /** Turns the safety on or off; returns the state it is in now. */
814
+ setSafety(on: boolean): boolean;
815
+ /** Starts clearing the fault (it takes `timings.clear` seconds); false when there is nothing to clear. */
816
+ clearFault(): boolean;
817
+ /** Wear of the weapon, by `rules.conditions` id; it sets how likely a round jams. */
818
+ setCondition(id: string): void;
819
+ /** Quality of the rounds, by `rules.ammoQualities` id. */
820
+ setAmmoQuality(id: string): void;
821
+ /** Metres of safety fuse for explosives that burn one (dynamite): replaces the explosive's `fuseLength`; `undefined` goes back to it. */
822
+ setFuseLength(metres: number | undefined): void;
823
+ /** Start putting the weapon in hand; the trigger answers `drawing` until it is ready. */
824
+ draw(): void;
825
+ /**
826
+ * Start a reload; false when there is nothing to do. `auto` picks by the weapon (one by one when it loads that way, a magazine swap
827
+ * otherwise); `full` loads a revolver all at once (speed loader); `one_by_one` forces round by round.
828
+ */
829
+ reload(kind?: ReloadRequest): boolean;
162
830
  cycleMode(): FireMode;
163
831
  /** Advance reload, cooldown and spread recovery. */
164
832
  update(dt: number): void;
165
833
  /** Fill the magazine and reserve (test rooms). */
166
834
  refill(): void;
835
+ /** What is on the weapon, factory parts included. */
836
+ readonly attachments: readonly FittedAttachment[];
837
+ /** Kg: the weapon with what is on it. */
838
+ readonly mass: number;
839
+ /** Seconds to raise the weapon to the sights: `rules.aim.base` + `perKg` × mass, with the effects of the accessories. */
840
+ readonly aimSeconds: number;
841
+ /** True while a suppressor is on: shots carry `suppressed` and the noise already counts it. */
842
+ readonly suppressed: boolean;
843
+ readonly stock: StockState;
844
+ /** Whether the accessory goes on, and where, with what is on the weapon now. */
845
+ canFit(id: AttachmentId, mount?: MountKind): CanFit;
846
+ /** Starts putting an accessory on (phase `fit`, `rules.attachments.fitSeconds` by where it installs); it counts when the phase ends. */
847
+ fit(id: AttachmentId, options?: FitOptions): FitResult;
848
+ /** Starts taking an accessory off; a factory part that is `integral` stays. Sobra de cartuchos de um carregador maior volta à reserva. */
849
+ remove(id: AttachmentId, options?: FitOptions): FitResult;
850
+ /** Turns a light or a laser on or off; returns the state it is in now, or null when the accessory is not a light or a laser on the weapon. */
851
+ toggle(id: AttachmentId): boolean | null;
852
+ /** Folds or slides the stock in or opens it (phase `stock`); false when the weapon has no such stock or it is already there. */
853
+ setStock(state: StockState): boolean;
854
+ setStance(stance: WeaponStance): void;
855
+ /** The launcher under the barrel (a second state with its own ammunition), or null when no launcher is fitted. */
856
+ readonly underbarrel: WeaponState | null;
857
+ /** True while the trigger and the reload go to the launcher. */
858
+ readonly underbarrelActive: boolean;
859
+ /** Changes between the weapon and the launcher under its barrel (phase `switch`, `rules.attachments.switchSeconds`); false when there is none, it is already so, or the weapon is busy. */
860
+ useUnderbarrel(on: boolean): boolean;
861
+ /** Enough to rebuild the weapon as it is (`arsenal.restore`). */
862
+ snapshot(): WeaponSnapshot;
863
+ /** What happened since the last call (for animation and sound), in order of time; empties the list. */
864
+ drain(): WeaponEvent[];
167
865
  }
866
+ /** Recursively optional; arrays and functions are replaced as a whole, objects are merged. */
867
+ type DeepPartial<TValue> = TValue extends (...args: never[]) => unknown ? TValue : TValue extends readonly unknown[] ? TValue : TValue extends object ? {
868
+ [TKey in keyof TValue]?: DeepPartial<TValue[TKey]>;
869
+ } : TValue;
870
+ /** Changes to a weapon def: `action`, `timings` and `dimensions` merge field by field, anything else replaces. */
871
+ type WeaponPatch = DeepPartial<Omit<WeaponDef, 'id'>>;
168
872
  interface ArsenalOptions {
169
- /** Extra or overriding calibres and weapons (merged by id over `CALIBERS` and `WEAPONS`). */
873
+ /** Extra or overriding calibres, weapons and explosives (merged by id over the ones the kit ships). */
170
874
  calibers?: CaliberDef[];
171
875
  weapons?: WeaponDef[];
876
+ explosives?: ExplosiveDef[];
877
+ /** Changes to shipped or added entries, by id, applied after the lists above are merged. */
878
+ patch?: {
879
+ weapons?: Record<WeaponId, WeaponPatch>;
880
+ calibers?: Record<CaliberId, Partial<CaliberDef>>;
881
+ explosives?: Record<ExplosiveId, Partial<ExplosiveDef>>;
882
+ attachments?: Record<AttachmentId, DeepPartial<AttachmentDef>>;
883
+ };
884
+ /** Entries to leave out, by id. */
885
+ remove?: {
886
+ weapons?: WeaponId[];
887
+ calibers?: CaliberId[];
888
+ explosives?: ExplosiveId[];
889
+ attachments?: AttachmentId[];
890
+ };
891
+ /** Keeps a weapon only when this returns true (applied after `remove`). */
892
+ include?: (def: WeaponDef) => boolean;
893
+ /** Added or replaced accessories (merged by id over the ones the kit ships). */
894
+ attachments?: AttachmentDef[];
895
+ /** Keeps an accessory off a weapon whatever its mounts say (applied after the mounts and calibre checks). */
896
+ isCompatible?: IsCompatible;
897
+ /** Numbers that rule faults, heat, noise bursts and handling times. */
898
+ rules?: DeepPartial<WeaponRules>;
899
+ /** Replaces display names (merged over the locale). */
900
+ strings?: DeepPartial<WeaponsStrings>;
172
901
  seed?: number;
173
902
  locale?: string;
174
903
  }
175
904
  interface Arsenal {
176
905
  readonly calibers: ReadonlyMap<CaliberId, CaliberDef>;
177
906
  readonly weapons: ReadonlyMap<WeaponId, WeaponDef>;
907
+ readonly explosives: ReadonlyMap<ExplosiveId, ExplosiveDef>;
908
+ readonly attachments: ReadonlyMap<AttachmentId, AttachmentDef>;
909
+ readonly rules: WeaponRules;
910
+ /** Whether an accessory goes on a weapon with the given parts on it (a weapon as it ships when `fitted` is left out), and where. */
911
+ canFit(weapon: WeaponId, attachment: AttachmentId, options?: {
912
+ fitted?: readonly FittedAttachment[];
913
+ mount?: MountKind;
914
+ }): CanFit;
915
+ /** Rebuilds a weapon from `WeaponState.snapshot()`; the random streams start again from `seed`. */
916
+ restore(snapshot: WeaponSnapshot, options?: {
917
+ seed?: number;
918
+ }): WeaponState;
178
919
  /** Make a runtime state for a weapon (each holder gets its own). Unknown id throws. */
179
920
  create(id: WeaponId, options?: {
180
921
  seed?: number;
181
922
  reserve?: number;
923
+ condition?: string;
924
+ ammoQuality?: string;
182
925
  }): WeaponState;
183
926
  /** Muzzle energy of a calibre (optionally with a barrel factor). */
184
927
  muzzleEnergy(caliber: CaliberId, barrel?: number): number;
185
- /** Translated name of a weapon / calibre category / fire mode. */
186
- name(id: WeaponId): string;
928
+ /** The explosive a `throw` or `place` use carries, ready to fly (`step`) or wait for its trigger; undefined when the use carries none. */
929
+ explosiveBody(use: Use): ExplosiveBody | undefined;
930
+ /** Joules of what one use of a weapon delivers: one projectile (or one pellet), a blast, or a melee blow. */
931
+ energy(id: WeaponId): number;
932
+ /** Translated name of a weapon, explosive, fire mode, category, fault, condition or calibre. */
933
+ name(id: string): string;
187
934
  list(category?: WeaponCategory): WeaponDef[];
188
935
  }
189
936
 
937
+ /** Deterministic mulberry32 generator; returns floats in [0, 1). */
938
+ declare const createRng: (seed: number) => (() => number);
939
+
940
+ interface ArsenalParts {
941
+ readonly weapons: ReadonlyMap<WeaponId, WeaponDef>;
942
+ readonly calibers: ReadonlyMap<CaliberId, CaliberDef>;
943
+ readonly explosives: ReadonlyMap<ExplosiveId, ExplosiveDef>;
944
+ readonly attachments?: ReadonlyMap<AttachmentId, AttachmentDef>;
945
+ /** When given, the default condition and ammunition quality must be ones the rules define. */
946
+ readonly rules?: Pick<WeaponRules, 'conditions' | 'defaultCondition' | 'ammoQualities' | 'defaultAmmoQuality'>;
947
+ }
948
+ /** Every problem found in an arsenal, so a game sees them all at once instead of one per run. Empty when it is consistent. */
949
+ declare const checkArsenal: ({ weapons, calibers, explosives, attachments, rules }: ArsenalParts) => string[];
950
+
951
+ /** How the weapon is held and what it is in: what the conditional effects (`aiming`, `hip`, `supported`, `subsonic`, `collapsed`) ask. */
952
+ interface LoadoutContext {
953
+ readonly aiming: boolean;
954
+ readonly supported: boolean;
955
+ readonly stock: 'collapsed' | 'extended';
956
+ readonly caliber: CaliberDef | null;
957
+ readonly rules: Pick<WeaponRules, 'attachments' | 'aim' | 'stock'>;
958
+ }
959
+ interface Loadout {
960
+ /** The action with every effect applied; the very object of the def when nothing differs from the weapon as it ships. */
961
+ readonly action: WeaponAction;
962
+ /** Kg: the weapon with what is on it. */
963
+ readonly mass: number;
964
+ /** Seconds to raise the weapon to the sights. */
965
+ readonly aimSeconds: number;
966
+ /** Times the spread when not aiming. */
967
+ readonly hipFactor: number;
968
+ readonly suppressed: boolean;
969
+ readonly drawFactor: number;
970
+ readonly heatFactor: number;
971
+ readonly faultFactor: number;
972
+ /** What a dual coupler does to the reload of every second magazine change (1: nothing). */
973
+ readonly secondReloadFactor: number;
974
+ readonly optic: AttachmentDef['optic'] | undefined;
975
+ readonly light: (NonNullable<AttachmentDef['light']> & {
976
+ readonly id: AttachmentId;
977
+ }) | undefined;
978
+ readonly laser: (NonNullable<AttachmentDef['laser']> & {
979
+ readonly id: AttachmentId;
980
+ }) | undefined;
981
+ }
982
+ type Catalogue = ReadonlyMap<AttachmentId, AttachmentDef>;
983
+ /** The weapon with what is on it: the numbers of the action, the mass, the time to aim, and the lights, laser and optic that are on. */
984
+ declare const resolveLoadout: (def: WeaponDef, fitted: readonly FittedAttachment[], catalogue: Catalogue, context: LoadoutContext) => Loadout;
985
+
190
986
  /** Muzzle energy in joules of ONE projectile (a bullet, or one pellet): 0.5 × mass × speed², speed scaled by the barrel factor. */
191
987
  declare const muzzleEnergy: (caliber: CaliberDef, barrel?: number) => number;
192
988
 
193
989
  declare const CALIBERS: CaliberDef[];
990
+ declare const ATTACHMENTS: AttachmentDef[];
991
+ declare const EXPLOSIVES: ExplosiveDef[];
992
+ declare const ARCHETYPE_IDS: readonly WeaponId[];
194
993
  declare const WEAPONS: WeaponDef[];
195
994
  /** A reasonable starting kit for a test room or a sandbox. */
196
995
  declare const DEFAULT_LOADOUT: WeaponId[];
197
996
 
198
- /** Create an arsenal: the built-in calibres and weapons merged (by id) with the ones in `options`. */
997
+ /**
998
+ * Create an arsenal. Order: the shipped entries, then `calibers`/`weapons`/`explosives` (added or replaced by id), then `patch`, then `remove`, then `include`;
999
+ * a throwable that names an explosive follows that explosive. Every inconsistency found is reported in one error.
1000
+ */
199
1001
  declare const createArsenal: (options?: ArsenalOptions) => Arsenal;
200
1002
 
201
- /** Locales shipped with the package. Unknown locales fall back to `en`. */
202
- type WeaponsLocale = 'en' | 'pt-BR';
203
- interface WeaponsStrings {
204
- /** Display name of each weapon id. */
205
- weapons: Record<string, string>;
206
- /** Display name of each fire mode. */
207
- modes: Record<string, string>;
208
- /** Display name of each weapon category. */
209
- categories: Record<string, string>;
1003
+ /** The rules the kit ships with; a game overrides any of them through `ArsenalOptions.rules`. */
1004
+ declare const DEFAULT_RULES: WeaponRules;
1005
+
1006
+ interface BlastEffect {
1007
+ /** `lethal` kills and dismembers, `injury` wounds, `none` is out of reach (or behind a directional charge). */
1008
+ readonly zone: 'lethal' | 'injury' | 'none';
1009
+ readonly distance: number;
1010
+ /** 1 in the lethal zone, falling linearly to 0 at the edge of the injury zone. */
1011
+ readonly falloff: number;
1012
+ /** Seconds of stun for whoever is in reach (flashbang). */
1013
+ readonly stunSeconds: number;
210
1014
  }
211
- declare const locales: Record<WeaponsLocale, WeaponsStrings>;
212
- declare const resolveStrings: (locale: string | undefined) => WeaponsStrings;
1015
+ /** What a detonation does to something at `target`: the zone, how hard, and the stun. A directional charge only reaches inside its cone. */
1016
+ declare const blastEffect: (detonation: Detonation, target: Vec3) => BlastEffect;
1017
+ /** How much of the blast behind a launcher reaches `target`: 0 outside the cone or the radius, falling linearly from 1 at the tube. */
1018
+ declare const backblastEffect: (use: Extract<Use, {
1019
+ kind: "backblast";
1020
+ }>, target: Vec3) => number;
1021
+ interface TripwireSegment {
1022
+ readonly from: Vec3;
1023
+ readonly to: Vec3;
1024
+ }
1025
+ /**
1026
+ * Where the wire of a charge set down with `use` runs: from the charge, `length` metres along the horizontal facing turned by `angleDeg`
1027
+ * (counter-clockwise seen from above), `height` metres above it. Null for a charge with no wire.
1028
+ */
1029
+ declare const tripwireSegment: (use: Extract<Use, {
1030
+ kind: "place";
1031
+ }>) => TripwireSegment | null;
1032
+
1033
+ /** The fuse of an explosive with no randomness: a fixed `fuse`, the burn of a safety fuse (length times rate), or the middle of `fuseRange`. */
1034
+ declare const nominalFuse: (explosive: ExplosiveDef, fuseLength?: number) => number | undefined;
1035
+ /**
1036
+ * The fuse of one throw. A safety fuse burns `fuseLength × burnRate` seconds, scattered by `burnTolerance` (a fraction, ±); `fuseRange` picks a time
1037
+ * between its two ends; a fixed `fuse` is returned as is. Draws from `random` only when the explosive is not fixed, so fixed ones leave the stream alone.
1038
+ */
1039
+ declare const sampleFuse: (explosive: ExplosiveDef, random: () => number, fuseLength?: number) => number | undefined;
1040
+
1041
+ type StageTable = Readonly<Record<ReloadKind, readonly ReloadStage[]>>;
1042
+ /** Where each step of a reload falls, as a fraction of its duration, from the key frames of the gallery animations. The runtime scales them to the duration of the weapon. */
1043
+ declare const RELOAD_STAGES: Readonly<Record<ReloadFamily, StageTable>>;
213
1044
 
214
- export { type Arsenal, type ArsenalOptions, CALIBERS, type CaliberDef, type CaliberId, DEFAULT_LOADOUT, type FireMode, type TriggerResult, WEAPONS, type WeaponAction, type WeaponCategory, type WeaponDef, type WeaponId, type WeaponState, type WeaponsLocale, type WeaponsStrings, createArsenal, locales, muzzleEnergy, resolveStrings };
1045
+ export { ARCHETYPE_IDS, ATTACHMENTS, type AmmoQualityDef, type Arsenal, type ArsenalOptions, type AttachmentDef, type AttachmentId, type AttachmentInstall, type AttachmentKind, type BlastEffect, CALIBERS, type CaliberDef, type CaliberId, type CanFit, type CanFitContext, type CartridgeDims, type CaseType, type ConditionDef, DEFAULT_LOADOUT, DEFAULT_RULES, type DataSource, type DeepPartial, type Detonation, EXPLOSIVES, type EffectCondition, ExplosiveBody, type ExplosiveBodyInit, type ExplosiveChain, type ExplosiveDef, type ExplosiveEvent, type ExplosiveId, type ExplosiveTrigger, type ExplosiveTripwire, type FaultContext, type FaultId, type FireMode, type FirearmAction, type FitOptions, type FitRefusal, type FitResult, type FittedAttachment, type IsCompatible, type Loadout, type LoadoutContext, type MountDef, type MountKind, RELOAD_STAGES, type ReloadFamily, type ReloadKind, type ReloadRequest, type ReloadStage, type ReloadStageId, type RimType, type StatModifier, type StockDef, type StockState, type SurfaceProbe, type TriggerResult, type TripwireSegment, WEAPONS, type WeaponAction, type WeaponCategory, type WeaponDef, type WeaponDimensions, type WeaponEvent, type WeaponId, type WeaponPatch, type WeaponPhase, type WeaponRules, type WeaponSnapshot, type WeaponStance, type WeaponStat, type WeaponState, type WeaponTimings, type WeaponsLocale, type WeaponsStrings, backblastEffect, blastEffect, canFit, canInstallWith, checkArsenal, createArsenal, createExplosiveBody, createRng, locales, muzzleEnergy, nominalFuse, resolveLoadout, resolveStrings, sampleFuse, tripwireSegment };