@adatechnology/game-weapons-three 0.19.0 → 0.19.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.global.js +79 -6
- package/dist/index.global.js.map +1 -1
- package/package.json +6 -6
package/dist/index.global.js
CHANGED
|
@@ -4469,13 +4469,18 @@ var GameWeaponsThree = (() => {
|
|
|
4469
4469
|
tnt: 0.045,
|
|
4470
4470
|
destructionLevel: 2,
|
|
4471
4471
|
noise: 450,
|
|
4472
|
+
armRange: [
|
|
4473
|
+
14,
|
|
4474
|
+
27
|
|
4475
|
+
],
|
|
4472
4476
|
triggers: [
|
|
4473
4477
|
"impact"
|
|
4474
4478
|
],
|
|
4475
4479
|
sources: [
|
|
4476
4480
|
"arsenal",
|
|
4477
4481
|
"lab",
|
|
4478
|
-
"gallery"
|
|
4482
|
+
"gallery",
|
|
4483
|
+
"reference"
|
|
4479
4484
|
]
|
|
4480
4485
|
},
|
|
4481
4486
|
{
|
|
@@ -4694,11 +4699,16 @@ var GameWeaponsThree = (() => {
|
|
|
4694
4699
|
tnt: 0.045,
|
|
4695
4700
|
destructionLevel: 2,
|
|
4696
4701
|
noise: 450,
|
|
4702
|
+
armRange: [
|
|
4703
|
+
10,
|
|
4704
|
+
40
|
|
4705
|
+
],
|
|
4697
4706
|
triggers: [
|
|
4698
4707
|
"impact"
|
|
4699
4708
|
],
|
|
4700
4709
|
sources: [
|
|
4701
4710
|
"lab",
|
|
4711
|
+
"reference",
|
|
4702
4712
|
"derived"
|
|
4703
4713
|
]
|
|
4704
4714
|
},
|
|
@@ -14612,6 +14622,7 @@ var GameWeaponsThree = (() => {
|
|
|
14612
14622
|
const problems = [];
|
|
14613
14623
|
const [low, high] = explosive.fuseRange ?? [1, 1];
|
|
14614
14624
|
if (!(low > 0 && high >= low)) problems.push(`explosive "${explosive.id}" has a fuse range of ${low} to ${high} s`);
|
|
14625
|
+
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`);
|
|
14615
14626
|
if (explosive.fuseLength !== void 0 && !(explosive.fuseLength > 0)) problems.push(`explosive "${explosive.id}" has a fuse length of ${explosive.fuseLength} m`);
|
|
14616
14627
|
if (explosive.burnRate !== void 0 && !(explosive.burnRate > 0)) problems.push(`explosive "${explosive.id}" has a burn rate of ${explosive.burnRate} s/m`);
|
|
14617
14628
|
if (explosive.burnTolerance !== void 0 && !(explosive.burnTolerance >= 0 && explosive.burnTolerance < 1)) problems.push(`explosive "${explosive.id}" has a burn tolerance of ${explosive.burnTolerance}`);
|
|
@@ -15227,7 +15238,12 @@ var GameWeaponsThree = (() => {
|
|
|
15227
15238
|
energy: explosive.energy,
|
|
15228
15239
|
injuryRadius: explosive.injuryRadius
|
|
15229
15240
|
});
|
|
15230
|
-
var
|
|
15241
|
+
var sampleArmDistance = (action, explosive, random) => {
|
|
15242
|
+
const range3 = explosive?.armRange;
|
|
15243
|
+
if (!range3) return action.minArmDistance;
|
|
15244
|
+
return range3[0] + (range3[1] - range3[0]) * random();
|
|
15245
|
+
};
|
|
15246
|
+
var launcherUses = ({ action, explosive, origin, direction, armDistance }) => {
|
|
15231
15247
|
const velocity = [direction[0] * action.speed, direction[1] * action.speed, direction[2] * action.speed];
|
|
15232
15248
|
const projectile = {
|
|
15233
15249
|
kind: "throw",
|
|
@@ -15238,7 +15254,7 @@ var GameWeaponsThree = (() => {
|
|
|
15238
15254
|
origin,
|
|
15239
15255
|
explosive: action.projectile,
|
|
15240
15256
|
trigger: "impact",
|
|
15241
|
-
armDistance: action.minArmDistance,
|
|
15257
|
+
armDistance: armDistance ?? action.minArmDistance,
|
|
15242
15258
|
...explosive ? { injuryRadius: explosive.injuryRadius } : {}
|
|
15243
15259
|
};
|
|
15244
15260
|
if (action.backblast <= 0) return [projectile];
|
|
@@ -16415,7 +16431,7 @@ var GameWeaponsThree = (() => {
|
|
|
16415
16431
|
this._ammo -= 1;
|
|
16416
16432
|
this._heat = Math.min(this.rules.heat.cap, this._heat + heatPerRound({ action: a, caliber: null, energy: 0, barrelMass: this.barrelMass, rules: this.rules.heat }));
|
|
16417
16433
|
this.emit({ type: "shot", shots: 0, rounds: 1, mode: this.mode, at: t });
|
|
16418
|
-
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] });
|
|
16434
|
+
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] });
|
|
16419
16435
|
}
|
|
16420
16436
|
fireMelee(a, origin, dir, start, end3) {
|
|
16421
16437
|
const t0 = Math.max(start, this.readyAt);
|
|
@@ -22389,7 +22405,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22389
22405
|
for (const l of layers) if (onFace(l, face)) sum2 += l.def.thickness;
|
|
22390
22406
|
return sum2;
|
|
22391
22407
|
};
|
|
22392
|
-
var
|
|
22408
|
+
var REBAR_COVER = 0.03;
|
|
22409
|
+
var COVER = REBAR_COVER;
|
|
22393
22410
|
var MAX_BARS_PER_DIRECTION = 24;
|
|
22394
22411
|
var MAX_MEMBER_BARS_PER_SIDE = 6;
|
|
22395
22412
|
var STEEL_DENSITY = 7850;
|
|
@@ -24625,6 +24642,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24625
24642
|
var PANEL_PI = 6e6;
|
|
24626
24643
|
var PANEL_POINTS = [[0, 0], [-0.3, 0], [0.3, 0], [0, -0.3], [0, 0.3]];
|
|
24627
24644
|
var PANEL_POINTS_LOADED = 4;
|
|
24645
|
+
var MEMBER_BAND = 0.1;
|
|
24646
|
+
var MEMBER_CRATER_CALIBRES = 3.4;
|
|
24647
|
+
var MEMBER_BARED_MAX = 24;
|
|
24648
|
+
var MEMBER_CUT_LOSS = 0.9;
|
|
24628
24649
|
var BLAST_EDGE_WEAR = 0.6;
|
|
24629
24650
|
var RESIDUAL_CAPACITY = 0.15;
|
|
24630
24651
|
var SEVER_BAND = 0.1;
|
|
@@ -26031,6 +26052,57 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26031
26052
|
const lp = toLocal(p.pos, p.q, objectPoint);
|
|
26032
26053
|
return cells.some((c) => Math.abs(lp[u] - c.center[u]) <= c.size[u] / 2 && Math.abs(lp[v] - c.center[v]) <= c.size[v] / 2);
|
|
26033
26054
|
};
|
|
26055
|
+
const wearMember = (o, p, entry2, d, E, caliber, penMm, src) => {
|
|
26056
|
+
var _a, _b;
|
|
26057
|
+
if (!p.spec.reinforcement || !p.spec.units || !isMember(p.dims) || p.st.stripped || isLost(p) || p.spec.shape.kind !== "box") return false;
|
|
26058
|
+
const along = p.dims.indexOf(Math.max(...p.dims));
|
|
26059
|
+
const lp = toLocal(p.pos, p.q, objLocal(o, entry2));
|
|
26060
|
+
const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
|
|
26061
|
+
let depth = Infinity;
|
|
26062
|
+
for (let a = 0; a < 3; a++) if (a !== along && Math.abs(ld[a]) > 1e-3) depth = Math.min(depth, p.dims[a] / Math.abs(ld[a]));
|
|
26063
|
+
if (!Number.isFinite(depth)) return true;
|
|
26064
|
+
const into = (penMm ?? E / Math.max(p.mat.penetration, 1e-6)) / 1e3;
|
|
26065
|
+
const h = Math.min(into, depth);
|
|
26066
|
+
const r = Math.min(MEMBER_CRATER_CALIBRES * caliber / 1e3, h);
|
|
26067
|
+
const volume = Math.PI / 3 * r * r * h;
|
|
26068
|
+
const section = p.dims.reduce((product2, size, a) => a === along ? product2 : product2 * size, 1);
|
|
26069
|
+
const bands = Math.max(1, Math.round(p.dims[along] / MEMBER_BAND));
|
|
26070
|
+
const band = clamp2(Math.floor((lp[along] + p.dims[along] / 2) / p.dims[along] * bands), 0, bands - 1);
|
|
26071
|
+
const height = p.dims[along] / bands;
|
|
26072
|
+
const worn = (_a = p.rt).bands ?? (_a.bands = {});
|
|
26073
|
+
const before = worn[band] ?? 0;
|
|
26074
|
+
const after2 = Math.min(1, before + volume / (section * height));
|
|
26075
|
+
worn[band] = after2;
|
|
26076
|
+
markDamaged(p);
|
|
26077
|
+
const bandCenter = -p.dims[along] / 2 + (band + 0.5) * height;
|
|
26078
|
+
if (h > REBAR_COVER && after2 < MEMBER_CUT_LOSS) {
|
|
26079
|
+
const bared = (_b = p.rt).bared ?? (_b.bared = []);
|
|
26080
|
+
const center = [lp[0], lp[1], lp[2]];
|
|
26081
|
+
const size = [p.dims[0], p.dims[1], p.dims[2]];
|
|
26082
|
+
for (let a = 0; a < 3; a++) if (Math.abs(ld[a]) < 0.5) size[a] = 2 * r;
|
|
26083
|
+
if (bared.length < MEMBER_BARED_MAX && !bared.some((box5) => box5.center.every((x, a) => Math.abs(x - center[a]) < box5.size[a] / 4))) {
|
|
26084
|
+
bared.push({ center, size });
|
|
26085
|
+
exposeRebar(o, p, src);
|
|
26086
|
+
}
|
|
26087
|
+
}
|
|
26088
|
+
if (before >= MEMBER_CUT_LOSS || after2 < MEMBER_CUT_LOSS) return true;
|
|
26089
|
+
const axisUp = rotateVec(p.q, [0, 0, 0].map((_, k) => k === along ? 1 : 0));
|
|
26090
|
+
const standing = Math.abs(axisUp[1]) > 0.7;
|
|
26091
|
+
const upward = axisUp[1] >= 0 ? 1 : -1;
|
|
26092
|
+
const grid = gridOf(p);
|
|
26093
|
+
const gone = p.rt.chips ?? {};
|
|
26094
|
+
const out = [];
|
|
26095
|
+
for (let i = 0; i < grid.length; i++) {
|
|
26096
|
+
if (gone[i] === -1) continue;
|
|
26097
|
+
const at4 = grid[i].center[along];
|
|
26098
|
+
const inBand = Math.abs(at4 - bandCenter) <= height / 2 + 1e-6;
|
|
26099
|
+
const above2 = standing && (at4 - bandCenter) * upward > height / 2;
|
|
26100
|
+
if (inBand || above2) out.push(i);
|
|
26101
|
+
}
|
|
26102
|
+
if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src);
|
|
26103
|
+
giveAtCut(o, p, src);
|
|
26104
|
+
return true;
|
|
26105
|
+
};
|
|
26034
26106
|
const chipUnits = (o, p, kind, wp, hitEnergy, dir, radius, src) => {
|
|
26035
26107
|
var _a, _b, _c;
|
|
26036
26108
|
if (!p.spec.units || !p.staged || chipEnergy <= 0 || p.st.stripped || isLost(p) || (p.st.stage ?? 0) >= 2) return;
|
|
@@ -26172,6 +26244,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26172
26244
|
else {
|
|
26173
26245
|
bars = [];
|
|
26174
26246
|
for (const cell of p.st.chipped ?? []) bars.push(...clipBarsToBox(all, u, v, cell.center, cell.size));
|
|
26247
|
+
for (const box5 of p.rt.bared ?? []) bars.push(...clipBarsToBox(all, u, v, box5.center, box5.size));
|
|
26175
26248
|
const op = p.st.opening;
|
|
26176
26249
|
if (op) {
|
|
26177
26250
|
const lc = toLocal(p.pos, p.q, op.center);
|
|
@@ -26710,7 +26783,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26710
26783
|
const absorbed = penetrated && (mat.ductility >= 0.5 && mat.fracture !== "tear" || hollowTear) ? Math.min(E, thr) : E;
|
|
26711
26784
|
const dmg = applyDamage(o, p, absorbed * DMG_PER_J * scale, "ballistic", entry2, d, absorbed * 0.1, 12, src);
|
|
26712
26785
|
if (!isLost(p)) tearAt(o, p, "ballistic", entry2, penetrated ? exitPoint : void 0, d, E, caliber / 1e3, src);
|
|
26713
|
-
chipUnits(o, p, "ballistic", entry2, penetrated ? Math.min(E, Math.max(thr, E * 0.5)) : E, d, Math.max(0.05, caliber / 1e3 * 8), src);
|
|
26786
|
+
if (!wearMember(o, p, entry2, d, E, caliber, penMm, src)) chipUnits(o, p, "ballistic", entry2, penetrated ? Math.min(E, Math.max(thr, E * 0.5)) : E, d, Math.max(0.05, caliber / 1e3 * 8), src);
|
|
26714
26787
|
return { penetrated, exitEnergy: penetrated ? penMm !== void 0 ? E * (1 - thr / Ep) : E - thr / (hard ? piercing : 1) : 0, exitPoint, damage: dmg };
|
|
26715
26788
|
};
|
|
26716
26789
|
const melee = (o, p, kind, E, point, n, d, contactR, src) => {
|