@adatechnology/game-weapons 0.8.0 → 0.9.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/README.md CHANGED
@@ -271,6 +271,18 @@ optic that is fitted over `aimSeconds`), and only when the click lands on the ro
271
271
  a throwable) leaves the button to the room, which grabs with it. The bench's **Supported** switch (`supported_stance`) puts the weapon in the supported stance (deployed or prone), so the bipod effect can be exercised;
272
272
  it goes back off when another tool is taken. The laser measures its distance at most 30 times a second and ignores hidden nodes (a hidden ancestor counts) and the weapon in the hands.
273
273
 
274
+ ### A weapon in each hand
275
+
276
+ `rules.dualWield` says which weapons go one in each hand and what that costs: `categories` (`pistol`, `revolver`), `weapons` (the Mini Uzi, Uzi, MAC-10, vz. 61, MP7, the knives, the
277
+ machete and the hatchet) less `exclude`, and the multipliers of a weapon held so: `spread` ×1.8 and `recoil` ×1.35. `canDualWield(arsenal, id)` answers it; each hand gets its own
278
+ `arsenal.create(id)` (its own magazine, reload, heat and fire rate) with `setStance({ dualWield: true })`, which applies the multipliers and keeps the weapon from aiming. A game changes
279
+ the lists with `createArsenal({ rules: { dualWield: { weapons: [...] } } })` (an array replaces the shipped one).
280
+
281
+ **In the test room**: Shift+click in the weapon picker puts two of an eligible weapon in the hands (a second Shift+click changes the left one; a plain click goes back to one). The left
282
+ mouse button fires the right hand, the right button the left hand (no aiming with two); R changes the magazines as a person does: the left weapon is tucked in the belt (`rules.dualWield.stowSeconds`), the free left hand changes the
283
+ right one's magazine and draws its weapon back, then the right weapon is tucked and the right hand changes the left one's; neither fires meanwhile. Q (fire mode) and B (safety)
284
+ act on the weapon of the hand that fired last; X clears the stuck one. Each index finger curls on its own trigger (`HandTargets.fingers` / `fingersL`).
285
+
274
286
  ## API
275
287
 
276
288
  - `createArsenal(options?)` returns an `Arsenal`: `calibers`, `weapons`, `explosives` (maps), `rules`, `create(id, { seed?, reserve?, condition?, ammoQuality? })` (unknown id throws), `attachments`, `canFit(weapon, attachment, options?)`, `restore(snapshot, options?)`,
package/dist/index.d.ts CHANGED
@@ -165,6 +165,7 @@ interface Detonation {
165
165
  readonly cone?: ExplosiveDef['cone'];
166
166
  readonly stunSeconds?: number;
167
167
  readonly fire?: ExplosiveDef['fire'];
168
+ readonly smoke?: ExplosiveDef['smoke'];
168
169
  }
169
170
  type ExplosiveEvent = {
170
171
  type: 'armed';
@@ -282,10 +283,17 @@ interface ExplosiveShell {
282
283
  /** Seconds the flying shell trails fire. */
283
284
  readonly trailSeconds: number;
284
285
  }
286
+ /** What a smoke canister gives off instead of a blast: the colour of the smoke and how long it burns (the real burn varies by lot, so it is a range). */
287
+ interface ExplosiveSmoke {
288
+ /** `0xRRGGBB` of the smoke. */
289
+ readonly color: number;
290
+ /** Seconds the filling burns once the fuse has lit it, between the two ends. */
291
+ readonly seconds: readonly [number, number];
292
+ }
285
293
  interface ExplosiveDef {
286
294
  readonly id: ExplosiveId;
287
295
  readonly name?: string;
288
- readonly kind: 'fragmentation' | 'blast' | 'incendiary' | 'directional' | 'flash' | 'shaped_charge' | 'fuel';
296
+ readonly kind: 'fragmentation' | 'blast' | 'incendiary' | 'directional' | 'flash' | 'shaped_charge' | 'fuel' | 'smoke';
289
297
  /** Radius in metres inside which everything dies. */
290
298
  readonly lethalRadius: number;
291
299
  /** Radius in metres of the wounding area (damage falls with distance). */
@@ -316,6 +324,8 @@ interface ExplosiveDef {
316
324
  /** Scatter of the burn rate as a fraction, sampled per throw (0.1 = ±10%). */
317
325
  readonly burnTolerance?: number;
318
326
  readonly stunSeconds?: number;
327
+ /** A smoke canister: it makes smoke for `seconds` and does not explode (energy and radii are 0). */
328
+ readonly smoke?: ExplosiveSmoke;
319
329
  readonly fire?: {
320
330
  temperature: number;
321
331
  radius: number;
@@ -462,6 +472,22 @@ interface WeaponRules {
462
472
  */
463
473
  readonly ironSightZoom: Readonly<Record<string, number>>;
464
474
  };
475
+ /**
476
+ * A weapon in each hand: which weapons a body can hold one of in each hand (by `categories`, plus the ids in `weapons`, less the ids in `exclude`), and how much worse each one shoots
477
+ * then (`spread` and `recoil` multiply the one-handed numbers: one hand holds the weapon, none steadies it, and the eye cannot sight two at once).
478
+ */
479
+ readonly dualWield: {
480
+ readonly categories: readonly WeaponCategory[];
481
+ readonly weapons: readonly WeaponId[];
482
+ readonly exclude: readonly WeaponId[];
483
+ readonly spread: number;
484
+ readonly recoil: number;
485
+ /**
486
+ * Seconds to put one weapon away against the body (tucked in the belt) to free its hand, and as long to take it back: a magazine is changed with the free hand, one weapon after
487
+ * the other, and neither fires meanwhile.
488
+ */
489
+ readonly stowSeconds: number;
490
+ };
465
491
  /** Folding or sliding in the stock: the seconds it takes and what it does to the weapon while it is in. */
466
492
  readonly stock: {
467
493
  readonly seconds: number;
@@ -781,7 +807,7 @@ type WeaponAction = {
781
807
  magazine: number;
782
808
  reload: number;
783
809
  timings?: WeaponTimings;
784
- family: 'rocket' | 'break' | 'underbarrel';
810
+ family: 'rocket' | 'break' | 'underbarrel' | 'revolver';
785
811
  disposable?: boolean;
786
812
  speed: number;
787
813
  /** Distance in metres below which the projectile hits without exploding. */
@@ -920,6 +946,8 @@ interface WeaponStance {
920
946
  readonly aiming?: boolean;
921
947
  /** Lying down, or on a bipod or tripod. */
922
948
  readonly supported?: boolean;
949
+ /** Held in one hand with another weapon in the other (`rules.dualWield`): the spread and the recoil are worse, and it does not aim. */
950
+ readonly dualWield?: boolean;
923
951
  }
924
952
  interface WeaponState {
925
953
  readonly def: WeaponDef;
@@ -1132,7 +1160,9 @@ interface LoadoutContext {
1132
1160
  readonly supported: boolean;
1133
1161
  readonly stock: 'collapsed' | 'extended';
1134
1162
  readonly caliber: CaliberDef | null;
1135
- readonly rules: Pick<WeaponRules, 'attachments' | 'aim' | 'stock'>;
1163
+ readonly rules: Pick<WeaponRules, 'attachments' | 'aim' | 'stock'> & Partial<Pick<WeaponRules, 'dualWield'>>;
1164
+ /** One hand with another weapon in the other: `rules.dualWield` makes the spread and the recoil worse. */
1165
+ readonly dualWield?: boolean;
1136
1166
  }
1137
1167
  interface Loadout {
1138
1168
  /** The action with every effect applied; the very object of the def when nothing differs from the weapon as it ships. */
@@ -1309,6 +1339,12 @@ declare function muzzleSmokeOf({ caliber, weapon, suppressed }: MuzzleSmokeParam
1309
1339
  */
1310
1340
  declare function aimZoomOf(arsenal: Arsenal, weaponId: WeaponId, attachments?: readonly AttachmentId[]): number;
1311
1341
 
1342
+ /**
1343
+ * Whether a body can hold one of this weapon in each hand (`rules.dualWield`): its category is listed or its id is, and it is not excluded. A game changes the lists through
1344
+ * `ArsenalOptions.rules`; an unknown id answers false.
1345
+ */
1346
+ declare function canDualWield(arsenal: Pick<Arsenal, 'weapons' | 'rules'>, weaponId: WeaponId): boolean;
1347
+
1312
1348
  /** One group of the weapon menu as a game declares it: the categories it lists, in order, each a section of its own. */
1313
1349
  interface WeaponMenuGroupDef {
1314
1350
  readonly id: string;
@@ -1360,4 +1396,4 @@ declare function genericWeapons(arsenal: Arsenal): ReadonlyMap<WeaponId, WeaponI
1360
1396
  /** A loadout with each generic gun swapped for the real weapon that stands for it (dropped when none does), and no id twice. */
1361
1397
  declare function realLoadout(arsenal: Arsenal, loadout: readonly WeaponId[]): WeaponId[];
1362
1398
 
1363
- export { AMMO, ARCHETYPE_IDS, ATTACHMENTS, type AmmoCore, type AmmoDef, type AmmoJacket, type AmmoKind, type AmmoLoad, type AmmoPenetration, 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 Detonation, EXPLOSIVES, type EffectCondition, ExplosiveBody, type ExplosiveBodyInit, type ExplosiveChain, type ExplosiveDef, type ExplosiveEvent, type ExplosiveId, type ExplosiveLeak, type ExplosiveShell, type ExplosiveTrigger, type ExplosiveTripwire, type FaultContext, type FaultId, type FireMode, type FirearmAction, type FitOptions, type FitRefusal, type FitResult, type FittedAttachment, GALLERY_HEAT, type IsCompatible, type Loadout, type LoadoutContext, MUZZLE_SMOKE, type MountDef, type MountKind, type MuzzleSmokeParams, type MuzzleSmokeProfile, type MuzzleSmokeProfileId, RELOAD_STAGES, type ReloadFamily, type ReloadKind, type ReloadRequest, type ReloadStage, type ReloadStageId, type RimType, type RoundsToWarningParams, type StatModifier, type StockDef, type StockState, type SurfaceProbe, type TriggerResult, type TripwireSegment, WEAPONS, WEAPON_MENU_GROUPS, type WeaponAction, type WeaponCategory, type WeaponDef, type WeaponDimensions, type WeaponEvent, type WeaponId, type WeaponMenuEntry, type WeaponMenuGroup, type WeaponMenuGroupDef, type WeaponMenuOptions, type WeaponMenuSection, type WeaponPatch, type WeaponPhase, type WeaponRules, type WeaponSnapshot, type WeaponStance, type WeaponStat, type WeaponState, type WeaponTimings, type WeaponsLocale, type WeaponsStrings, aimZoomOf, ammoId, ammoIgnition, backblastEffect, barrelMassOf, blastEffect, canFit, canInstallWith, checkArsenal, coolingTimeConstant, createArsenal, createExplosiveBody, createRng, decayHeat, genericWeapons, locales, muzzleEnergy, muzzleSmokeOf, nominalFuse, realLoadout, resolveLoad, resolveLoadout, resolveStrings, roundsToWarning, roundsToWarningOf, sampleFuse, tripwireSegment, weaponMenu };
1399
+ export { AMMO, ARCHETYPE_IDS, ATTACHMENTS, type AmmoCore, type AmmoDef, type AmmoJacket, type AmmoKind, type AmmoLoad, type AmmoPenetration, 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 Detonation, EXPLOSIVES, type EffectCondition, ExplosiveBody, type ExplosiveBodyInit, type ExplosiveChain, type ExplosiveDef, type ExplosiveEvent, type ExplosiveId, type ExplosiveLeak, type ExplosiveShell, type ExplosiveSmoke, type ExplosiveTrigger, type ExplosiveTripwire, type FaultContext, type FaultId, type FireMode, type FirearmAction, type FitOptions, type FitRefusal, type FitResult, type FittedAttachment, GALLERY_HEAT, type IsCompatible, type Loadout, type LoadoutContext, MUZZLE_SMOKE, type MountDef, type MountKind, type MuzzleSmokeParams, type MuzzleSmokeProfile, type MuzzleSmokeProfileId, RELOAD_STAGES, type ReloadFamily, type ReloadKind, type ReloadRequest, type ReloadStage, type ReloadStageId, type RimType, type RoundsToWarningParams, type StatModifier, type StockDef, type StockState, type SurfaceProbe, type TriggerResult, type TripwireSegment, WEAPONS, WEAPON_MENU_GROUPS, type WeaponAction, type WeaponCategory, type WeaponDef, type WeaponDimensions, type WeaponEvent, type WeaponId, type WeaponMenuEntry, type WeaponMenuGroup, type WeaponMenuGroupDef, type WeaponMenuOptions, type WeaponMenuSection, type WeaponPatch, type WeaponPhase, type WeaponRules, type WeaponSnapshot, type WeaponStance, type WeaponStat, type WeaponState, type WeaponTimings, type WeaponsLocale, type WeaponsStrings, aimZoomOf, ammoId, ammoIgnition, backblastEffect, barrelMassOf, blastEffect, canDualWield, canFit, canInstallWith, checkArsenal, coolingTimeConstant, createArsenal, createExplosiveBody, createRng, decayHeat, genericWeapons, locales, muzzleEnergy, muzzleSmokeOf, nominalFuse, realLoadout, resolveLoad, resolveLoadout, resolveStrings, roundsToWarning, roundsToWarningOf, sampleFuse, tripwireSegment, weaponMenu };