@adatechnology/game-weapons 0.15.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/dist/index.d.ts +36 -23
- package/dist/index.global.js +20 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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 };
|
package/dist/index.global.js
CHANGED
|
@@ -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
|
|
@@ -16923,7 +16925,8 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
|
|
|
16923
16925
|
seconds: 0.7
|
|
16924
16926
|
}
|
|
16925
16927
|
],
|
|
16926
|
-
reset: 1.2
|
|
16928
|
+
reset: 1.2,
|
|
16929
|
+
contactLength: 0.3
|
|
16927
16930
|
},
|
|
16928
16931
|
{
|
|
16929
16932
|
id: "two_hand_swing",
|
|
@@ -16962,6 +16965,22 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
|
|
|
16962
16965
|
}
|
|
16963
16966
|
};
|
|
16964
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
|
+
};
|
|
16965
16984
|
return __toCommonJS(index_exports);
|
|
16966
16985
|
})();
|
|
16967
16986
|
//# sourceMappingURL=index.global.js.map
|