@adatechnology/game-weapons 0.9.2 → 0.10.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 +5 -0
- package/dist/index.global.js +20 -4
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -317,6 +317,11 @@ interface ExplosiveDef {
|
|
|
317
317
|
readonly fuse?: number;
|
|
318
318
|
/** Seconds from arming to the blast, sampled per throw between the two ends (a flashbang: 1.0 to 2.3 s from the lever). */
|
|
319
319
|
readonly fuseRange?: readonly [number, number];
|
|
320
|
+
/**
|
|
321
|
+
* Metres the projectile flies before its fuze arms, sampled per shot between the two ends (the M406 40 mm grenade: 14 to 27 m, from the spin
|
|
322
|
+
* that unlocks the rotor). Short of it an impact is a dud. Absent: the launcher's `minArmDistance`.
|
|
323
|
+
*/
|
|
324
|
+
readonly armRange?: readonly [number, number];
|
|
320
325
|
/** Metres of safety fuse; with `burnRate` it gives the fuse in seconds, so a longer fuse builds a delayed trap. */
|
|
321
326
|
readonly fuseLength?: number;
|
|
322
327
|
/** Seconds the safety fuse takes to burn one metre (about 131 s/m). */
|
package/dist/index.global.js
CHANGED
|
@@ -4193,13 +4193,18 @@ var GameWeapons = (() => {
|
|
|
4193
4193
|
tnt: 0.045,
|
|
4194
4194
|
destructionLevel: 2,
|
|
4195
4195
|
noise: 450,
|
|
4196
|
+
armRange: [
|
|
4197
|
+
14,
|
|
4198
|
+
27
|
|
4199
|
+
],
|
|
4196
4200
|
triggers: [
|
|
4197
4201
|
"impact"
|
|
4198
4202
|
],
|
|
4199
4203
|
sources: [
|
|
4200
4204
|
"arsenal",
|
|
4201
4205
|
"lab",
|
|
4202
|
-
"gallery"
|
|
4206
|
+
"gallery",
|
|
4207
|
+
"reference"
|
|
4203
4208
|
]
|
|
4204
4209
|
},
|
|
4205
4210
|
{
|
|
@@ -4418,11 +4423,16 @@ var GameWeapons = (() => {
|
|
|
4418
4423
|
tnt: 0.045,
|
|
4419
4424
|
destructionLevel: 2,
|
|
4420
4425
|
noise: 450,
|
|
4426
|
+
armRange: [
|
|
4427
|
+
10,
|
|
4428
|
+
40
|
|
4429
|
+
],
|
|
4421
4430
|
triggers: [
|
|
4422
4431
|
"impact"
|
|
4423
4432
|
],
|
|
4424
4433
|
sources: [
|
|
4425
4434
|
"lab",
|
|
4435
|
+
"reference",
|
|
4426
4436
|
"derived"
|
|
4427
4437
|
]
|
|
4428
4438
|
},
|
|
@@ -14348,6 +14358,7 @@ var GameWeapons = (() => {
|
|
|
14348
14358
|
const problems = [];
|
|
14349
14359
|
const [low, high] = explosive.fuseRange ?? [1, 1];
|
|
14350
14360
|
if (!(low > 0 && high >= low)) problems.push(`explosive "${explosive.id}" has a fuse range of ${low} to ${high} s`);
|
|
14361
|
+
if (explosive.armRange && !(explosive.armRange[0] > 0 && explosive.armRange[1] >= explosive.armRange[0])) problems.push(`explosive "${explosive.id}" arms between ${explosive.armRange[0]} and ${explosive.armRange[1]} m`);
|
|
14351
14362
|
if (explosive.fuseLength !== void 0 && !(explosive.fuseLength > 0)) problems.push(`explosive "${explosive.id}" has a fuse length of ${explosive.fuseLength} m`);
|
|
14352
14363
|
if (explosive.burnRate !== void 0 && !(explosive.burnRate > 0)) problems.push(`explosive "${explosive.id}" has a burn rate of ${explosive.burnRate} s/m`);
|
|
14353
14364
|
if (explosive.burnTolerance !== void 0 && !(explosive.burnTolerance >= 0 && explosive.burnTolerance < 1)) problems.push(`explosive "${explosive.id}" has a burn tolerance of ${explosive.burnTolerance}`);
|
|
@@ -14977,7 +14988,12 @@ var GameWeapons = (() => {
|
|
|
14977
14988
|
energy: explosive.energy,
|
|
14978
14989
|
injuryRadius: explosive.injuryRadius
|
|
14979
14990
|
});
|
|
14980
|
-
var
|
|
14991
|
+
var sampleArmDistance = (action, explosive, random) => {
|
|
14992
|
+
const range = explosive?.armRange;
|
|
14993
|
+
if (!range) return action.minArmDistance;
|
|
14994
|
+
return range[0] + (range[1] - range[0]) * random();
|
|
14995
|
+
};
|
|
14996
|
+
var launcherUses = ({ action, explosive, origin, direction, armDistance }) => {
|
|
14981
14997
|
const velocity = [direction[0] * action.speed, direction[1] * action.speed, direction[2] * action.speed];
|
|
14982
14998
|
const projectile = {
|
|
14983
14999
|
kind: "throw",
|
|
@@ -14988,7 +15004,7 @@ var GameWeapons = (() => {
|
|
|
14988
15004
|
origin,
|
|
14989
15005
|
explosive: action.projectile,
|
|
14990
15006
|
trigger: "impact",
|
|
14991
|
-
armDistance: action.minArmDistance,
|
|
15007
|
+
armDistance: armDistance ?? action.minArmDistance,
|
|
14992
15008
|
...explosive ? { injuryRadius: explosive.injuryRadius } : {}
|
|
14993
15009
|
};
|
|
14994
15010
|
if (action.backblast <= 0) return [projectile];
|
|
@@ -16204,7 +16220,7 @@ var GameWeapons = (() => {
|
|
|
16204
16220
|
this._ammo -= 1;
|
|
16205
16221
|
this._heat = Math.min(this.rules.heat.cap, this._heat + heatPerRound({ action: a, caliber: null, energy: 0, barrelMass: this.barrelMass, rules: this.rules.heat }));
|
|
16206
16222
|
this.emit({ type: "shot", shots: 0, rounds: 1, mode: this.mode, at: t });
|
|
16207
|
-
return result("ok", { uses: launcherUses(a, this.explosive, origin, dir), recoil: [a.recoil[0], a.recoil[1]], noise: a.noise ?? 0, rounds: 1, roundTimes: [t - start] });
|
|
16223
|
+
return result("ok", { uses: launcherUses({ action: a, explosive: this.explosive, origin, direction: dir, armDistance: sampleArmDistance(a, this.explosive, this.fuseRng) }), recoil: [a.recoil[0], a.recoil[1]], noise: a.noise ?? 0, rounds: 1, roundTimes: [t - start] });
|
|
16208
16224
|
}
|
|
16209
16225
|
fireMelee(a, origin, dir, start, end) {
|
|
16210
16226
|
const t0 = Math.max(start, this.readyAt);
|