@adatechnology/game-weapons 0.14.0 → 0.15.1

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
@@ -315,4 +315,4 @@ em português (`arsenal.name('rifle_5_56')` devolve "fuzil 5,56"). A recarga nun
315
315
 
316
316
  ## Melee families
317
317
 
318
- `MELEE_FAMILIES` (`data/melee-families.json`, spec 015 R3) groups the melee weapons that strike alike and lists their blows in order: `short_blade` (knife, tactical knife, KA-BAR, cleaver) cuts then thrusts (`knife_slash`, `knife_stab`), `one_hand_swing` (machete, hatchet, sickle, hammer, baton, skillet) chops from over the shoulder, `two_hand_swing` (bats, pipe, crowbar, axe, sledgehammer, pickaxe, katana) swings flat as the shovel. A blow names the body's clip (`ATTACK_CLIPS` of game-characters-people), the weapon's motion (`TOOL_MOTIONS` of game-weapons-three) and their seconds. `meleeFamilyOf(id)`, `meleeStrikeClips()` (the clip of each weapon, for a host's strike-clip map) and `createMeleeBlowCycle()` (the next blow of a family; after `reset` seconds without one it starts over) read them.
318
+ `MELEE_FAMILIES` (`data/melee-families.json`, spec 015 R3) groups the melee weapons that strike alike and lists their blows in order: `short_blade` (knife, tactical knife, KA-BAR, cleaver) cuts then thrusts (`knife_slash`, `knife_stab`), `one_hand_swing` (machete, hatchet, sickle, hammer, baton, skillet) chops from over the shoulder, `bat_swing` (bats, pipe, crowbar, sledgehammer: clubs held at the knob end in both hands) draws back behind the right shoulder, swings level through the chest and follows through over the left shoulder (`bat_swing`), `two_hand_swing` (axe, pickaxe, katana) swings flat and low as the shovel. A blow names the body's clip (`ATTACK_CLIPS` of game-characters-people), the weapon's motion (`TOOL_MOTIONS` of game-weapons-three) and their seconds. `meleeFamilyOf(id)`, `meleeStrikeClips()` (the clip of each weapon, for a host's strike-clip map) and `createMeleeBlowCycle()` (the next blow of a family; after `reset` seconds without one it starts over) read them.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Vec3, Use, BlastCasing, ExplosionChain, DeepPartial, Shot, HitIgnition } from '@adatechnology/game-contracts';
1
+ import { Vec3 as Vec3$1, Use, BlastCasing, ExplosionChain, DeepPartial, Shot, HitIgnition } from '@adatechnology/game-contracts';
2
2
  export { DeepPartial, Shot, Use, Vec3 } from '@adatechnology/game-contracts';
3
3
 
4
4
  type AttachmentId = string;
@@ -150,9 +150,9 @@ declare const canFit: (def: WeaponDef, attachment: AttachmentDef, fitted: readon
150
150
  interface Detonation {
151
151
  readonly explosive: ExplosiveId;
152
152
  readonly cause: ExplosiveTrigger;
153
- readonly point: Vec3;
153
+ readonly point: Vec3$1;
154
154
  /** The way a directional charge faces; for everything else the direction the body was moving (or facing when placed). */
155
- readonly direction: Vec3;
155
+ readonly direction: Vec3$1;
156
156
  /** Seconds on the clock of the body. */
157
157
  readonly at: number;
158
158
  readonly energy: number;
@@ -176,32 +176,32 @@ type ExplosiveEvent = {
176
176
  } | {
177
177
  type: 'impact';
178
178
  at: number;
179
- point: Vec3;
179
+ point: Vec3$1;
180
180
  armed: boolean;
181
181
  }
182
182
  /** Hit something before it was armed and `rules.explosives.unarmedImpact` is `dud`: it does not explode. */
183
183
  | {
184
184
  type: 'dud';
185
185
  at: number;
186
- point: Vec3;
186
+ point: Vec3$1;
187
187
  } | {
188
188
  type: 'detonate';
189
189
  at: number;
190
190
  detonation: Detonation;
191
191
  };
192
192
  /** The first surface the segment `from` to `to` crosses: where, its normal and whether it is ground (default: normal pointing up). */
193
- type SurfaceProbe = (from: Vec3, to: Vec3) => {
194
- point: Vec3;
195
- normal: Vec3;
193
+ type SurfaceProbe = (from: Vec3$1, to: Vec3$1) => {
194
+ point: Vec3$1;
195
+ normal: Vec3$1;
196
196
  ground?: boolean;
197
197
  } | null;
198
198
  interface ExplosiveBodyInit {
199
199
  readonly explosive: ExplosiveDef;
200
- readonly origin: Vec3;
200
+ readonly origin: Vec3$1;
201
201
  /** Initial velocity in m/s; absent for something set down. */
202
- readonly velocity?: Vec3;
202
+ readonly velocity?: Vec3$1;
203
203
  /** Facing of a placed charge (the cone of a mine). */
204
- readonly direction?: Vec3;
204
+ readonly direction?: Vec3$1;
205
205
  /** `timer`: explodes `fuse` seconds after it leaves the hand; `impact`: explodes on the first hit once armed; `wire`/`remote`: waits for `trigger()`. */
206
206
  readonly triggers: readonly ExplosiveTrigger[];
207
207
  readonly fuse?: number;
@@ -214,8 +214,8 @@ interface ExplosiveBodyInit {
214
214
  * for a wire, a remote detonator, a bullet, fire or a nearby blast. Same inputs, same events: there is no randomness.
215
215
  */
216
216
  declare class ExplosiveBody {
217
- position: Vec3;
218
- velocity: Vec3;
217
+ position: Vec3$1;
218
+ velocity: Vec3$1;
219
219
  readonly explosive: ExplosiveDef;
220
220
  private readonly triggers;
221
221
  private readonly armDistance;
@@ -1026,12 +1026,12 @@ interface WeaponState {
1026
1026
  * 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
1027
1027
  * `inHand`). Impact and remote ones, and the ones set down, act on the pull.
1028
1028
  */
1029
- trigger(origin: Vec3, direction: Vec3, dt: number, held?: boolean, source?: string): TriggerResult;
1029
+ trigger(origin: Vec3$1, direction: Vec3$1, dt: number, held?: boolean, source?: string): TriggerResult;
1030
1030
  /**
1031
1031
  * 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
1032
1032
  * (`origin` and `direction` default to the aim of the last `trigger` call); anything else returns null.
1033
1033
  */
1034
- release(origin?: Vec3, direction?: Vec3): TriggerResult | null;
1034
+ release(origin?: Vec3$1, direction?: Vec3$1): TriggerResult | null;
1035
1035
  /** True while a throwable's pin is pulled and the trigger is held. */
1036
1036
  readonly cooking: boolean;
1037
1037
  /** Turns the safety on or off; returns the state it is in now. */
@@ -1285,8 +1285,8 @@ type GroundSweepOptions = {
1285
1285
  readonly spacing?: number;
1286
1286
  };
1287
1287
  type GroundSweepHit = {
1288
- readonly point: Vec3;
1289
- readonly normal: Vec3;
1288
+ readonly point: Vec3$1;
1289
+ readonly normal: Vec3$1;
1290
1290
  readonly ground: true;
1291
1291
  readonly distance: number;
1292
1292
  };
@@ -1294,7 +1294,7 @@ type GroundSweepHit = {
1294
1294
  * Where the segment `from` to `to` first goes under the ground, read every `spacing` metres along it and narrowed by halving, or null when it stays
1295
1295
  * above. Only the end of a step is not enough: a round that crosses a heap, a kerb or a crater rim within one frame would go through it.
1296
1296
  */
1297
- declare function sweepGround(from: Vec3, to: Vec3, groundAt: GroundHeight, options?: GroundSweepOptions): GroundSweepHit | null;
1297
+ declare function sweepGround(from: Vec3$1, to: Vec3$1, groundAt: GroundHeight, options?: GroundSweepOptions): GroundSweepHit | null;
1298
1298
 
1299
1299
  interface BlastEffect {
1300
1300
  /** `lethal` kills and dismembers, `injury` wounds, `none` is out of reach (or behind a directional charge). */
@@ -1306,14 +1306,14 @@ interface BlastEffect {
1306
1306
  readonly stunSeconds: number;
1307
1307
  }
1308
1308
  /** What a detonation does to something at `target`: the zone, how hard, and the stun. A directional charge only reaches inside its cone. */
1309
- declare const blastEffect: (detonation: Detonation, target: Vec3) => BlastEffect;
1309
+ declare const blastEffect: (detonation: Detonation, target: Vec3$1) => BlastEffect;
1310
1310
  /** How much of the blast behind a launcher reaches `target`: 0 outside the cone or the radius, falling linearly from 1 at the tube. */
1311
1311
  declare const backblastEffect: (use: Extract<Use, {
1312
1312
  kind: "backblast";
1313
- }>, target: Vec3) => number;
1313
+ }>, target: Vec3$1) => number;
1314
1314
  interface TripwireSegment {
1315
- readonly from: Vec3;
1316
- readonly to: Vec3;
1315
+ readonly from: Vec3$1;
1316
+ readonly to: Vec3$1;
1317
1317
  }
1318
1318
  /**
1319
1319
  * Where the wire of a charge set down with `use` runs: from the charge, `length` metres along the horizontal facing turned by `angleDeg`
@@ -1521,6 +1521,8 @@ interface MeleeFamily {
1521
1521
  readonly weapons: readonly string[];
1522
1522
  readonly blows: readonly MeleeBlow[];
1523
1523
  readonly reset: number;
1524
+ /** Length of the line the weapon meets a surface along (a bat's or a pipe's barrel), metres; absent: a round face or an edge. */
1525
+ readonly contactLength?: number;
1524
1526
  }
1525
1527
  declare const MELEE_FAMILIES: readonly MeleeFamily[];
1526
1528
  /** The family a weapon strikes with, or undefined. */
@@ -1532,5 +1534,16 @@ interface MeleeBlowCycle {
1532
1534
  next(weaponId: string, now: number): MeleeBlow | undefined;
1533
1535
  }
1534
1536
  declare const createMeleeBlowCycle: (families?: readonly MeleeFamily[]) => MeleeBlowCycle;
1537
+ /**
1538
+ * Which way each motion moves the weapon across what it meets, in the striker's view (shares of its right and of the world's up): a cut runs along it, and a club's
1539
+ * barrel lies along it (a bat swung level runs right to left). A motion not listed (a thrust, a punch, a kick) has no sweep.
1540
+ */
1541
+ declare const MOTION_SWEEPS: Readonly<Record<string, {
1542
+ readonly right: number;
1543
+ readonly up: number;
1544
+ }>>;
1545
+ type Vec3 = readonly [number, number, number];
1546
+ /** The world direction a blow of `motion` sweeps across a surface, for a striker looking along `forward`; undefined for a motion without a sweep. */
1547
+ declare const sweepOf: (motion: string | undefined, forward: Vec3) => [number, number, number] | undefined;
1535
1548
 
1536
- 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 GroundHeight, type GroundSweepHit, type GroundSweepOptions, type IsCompatible, type Loadout, type LoadoutContext, MELEE_FAMILIES, MUZZLE_SMOKE, type MeleeBlow, type MeleeBlowCycle, type MeleeFamily, 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, SLING_SWING_DEFAULTS, type SlingSwing, type SlingSwingRules, type SlingSwingState, 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 WeaponHands, 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, createMeleeBlowCycle, createRng, createSlingSwing, decayHeat, genericWeapons, locales, meleeFamilyOf, meleeStrikeClips, muzzleEnergy, muzzleSmokeOf, nominalFuse, realLoadout, resolveLoad, resolveLoadout, resolveStrings, roundsToWarning, roundsToWarningOf, sampleFuse, sweepGround, tripwireSegment, weaponHandsOf, weaponMenu };
1549
+ 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 GroundHeight, type GroundSweepHit, type GroundSweepOptions, type IsCompatible, type Loadout, type LoadoutContext, MELEE_FAMILIES, MOTION_SWEEPS, MUZZLE_SMOKE, type MeleeBlow, type MeleeBlowCycle, type MeleeFamily, 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, SLING_SWING_DEFAULTS, type SlingSwing, type SlingSwingRules, type SlingSwingState, 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 WeaponHands, 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, createMeleeBlowCycle, createRng, createSlingSwing, decayHeat, genericWeapons, locales, meleeFamilyOf, meleeStrikeClips, muzzleEnergy, muzzleSmokeOf, nominalFuse, realLoadout, resolveLoad, resolveLoadout, resolveStrings, roundsToWarning, roundsToWarningOf, sampleFuse, sweepGround, sweepOf, tripwireSegment, weaponHandsOf, weaponMenu };
@@ -33,6 +33,7 @@ var GameWeapons = (() => {
33
33
  ExplosiveBody: () => ExplosiveBody,
34
34
  GALLERY_HEAT: () => GALLERY_HEAT,
35
35
  MELEE_FAMILIES: () => MELEE_FAMILIES,
36
+ MOTION_SWEEPS: () => MOTION_SWEEPS,
36
37
  MUZZLE_SMOKE: () => MUZZLE_SMOKE,
37
38
  RELOAD_STAGES: () => RELOAD_STAGES,
38
39
  SLING_SWING_DEFAULTS: () => SLING_SWING_DEFAULTS,
@@ -70,6 +71,7 @@ var GameWeapons = (() => {
70
71
  roundsToWarningOf: () => roundsToWarningOf,
71
72
  sampleFuse: () => sampleFuse,
72
73
  sweepGround: () => sweepGround,
74
+ sweepOf: () => sweepOf,
73
75
  tripwireSegment: () => tripwireSegment,
74
76
  weaponHandsOf: () => weaponHandsOf,
75
77
  weaponMenu: () => weaponMenu
@@ -16907,15 +16909,30 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
16907
16909
  reset: 1.2
16908
16910
  },
16909
16911
  {
16910
- id: "two_hand_swing",
16911
- note: "a long weapon in both hands (bat, pipe, crowbar, axe, sledgehammer, katana): swung flat from the right shoulder across the body, the hips leading, as the shovel's swing",
16912
+ id: "bat_swing",
16913
+ note: "a club in both hands (bat, pipe, crowbar, sledgehammer): drawn back behind the right shoulder, swung level through the chest with the hips and shoulders turning, and carried round over the left shoulder (follow-through)",
16912
16914
  weapons: [
16913
16915
  "baseball_bat",
16914
16916
  "nail_bat",
16915
16917
  "iron_pipe",
16916
16918
  "crowbar",
16919
+ "sledgehammer"
16920
+ ],
16921
+ blows: [
16922
+ {
16923
+ clip: "bat_swing",
16924
+ motion: "bat_swing",
16925
+ seconds: 0.7
16926
+ }
16927
+ ],
16928
+ reset: 1.2,
16929
+ contactLength: 0.3
16930
+ },
16931
+ {
16932
+ id: "two_hand_swing",
16933
+ note: "a long weapon in both hands with its weight at the head or an edge (axe, pickaxe, katana): swung flat and low from the right shoulder across the body, the hips leading, as the shovel's swing",
16934
+ weapons: [
16917
16935
  "axe",
16918
- "sledgehammer",
16919
16936
  "pickaxe",
16920
16937
  "katana"
16921
16938
  ],
@@ -16948,6 +16965,22 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
16948
16965
  }
16949
16966
  };
16950
16967
  };
16968
+ var MOTION_SWEEPS = {
16969
+ slash: { right: -0.7, up: -0.7 },
16970
+ chop: { right: -0.15, up: -1 },
16971
+ bat_swing: { right: -1, up: 0 },
16972
+ swing: { right: -0.95, up: -0.3 }
16973
+ };
16974
+ var sweepOf = (motion, forward) => {
16975
+ const share = motion ? MOTION_SWEEPS[motion] : void 0;
16976
+ if (!share) return void 0;
16977
+ const right = [-forward[2], 0, forward[0]];
16978
+ const flat = Math.hypot(right[0], right[2]);
16979
+ if (flat < 1e-6) return void 0;
16980
+ const v = [right[0] / flat * share.right, share.up, right[2] / flat * share.right];
16981
+ const length2 = Math.hypot(v[0], v[1], v[2]);
16982
+ return [v[0] / length2, v[1] / length2, v[2] / length2];
16983
+ };
16951
16984
  return __toCommonJS(index_exports);
16952
16985
  })();
16953
16986
  //# sourceMappingURL=index.global.js.map