@adatechnology/game-weapons 0.10.1 → 0.11.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 +36 -2
- package/dist/index.global.js +60 -4
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +60 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -14591,7 +14591,7 @@ var DEFAULT_RULES = {
|
|
|
14591
14591
|
heat: DEFAULT_HEAT,
|
|
14592
14592
|
noiseBurst: { step: 0.05, window: 3, cap: 0.5 },
|
|
14593
14593
|
// jogo.js (Jogo) explosionsUpdate 68300-68312: vy -= 9,8·dt; chão vy·-0,35 e vx,vz·0,6; parede v·-0,4
|
|
14594
|
-
explosives: { gravity: 9.8, groundRestitution: 0.35, groundFriction: 0.6, wallRestitution: 0.4, placeFuseFrom: 10, tripwire: { length: 10, angleDeg: 0, height: 0.15 } },
|
|
14594
|
+
explosives: { gravity: 9.8, groundRestitution: 0.35, groundFriction: 0.6, wallRestitution: 0.4, placeFuseFrom: 10, tripwire: { length: 10, angleDeg: 0, height: 0.15 }, unarmedImpact: "detonate", restSpeed: 0.5, selfDestructSeconds: 20 },
|
|
14595
14595
|
// Arsenal §11: montar e desmontar exige chave de fenda ou bancada; 2/15/30 s e a troca do lança-granadas (0,8 s) são padrões aprovados pelo dono (2026-10-24)
|
|
14596
14596
|
attachments: { fitSeconds: { field: 2, tool: 15, bench: 30 }, switchSeconds: 0.8, speedOfSound: 343 },
|
|
14597
14597
|
// Arsenal §08: tempo de mira = 0,15 s + 0,05 s por kg. O quadril do Arsenal é ×6 (o ZombiAdA liga isso por configuração); o SDK é neutro (1)
|
|
@@ -14644,6 +14644,8 @@ var negate = (v) => [0 - v[0], 0 - v[1], 0 - v[2]];
|
|
|
14644
14644
|
|
|
14645
14645
|
// src/explosive-body.ts
|
|
14646
14646
|
var EPS = 1e-9;
|
|
14647
|
+
var STILL_STEPS = 2;
|
|
14648
|
+
var STILL_SHARE = 0.05;
|
|
14647
14649
|
var bounce = (velocity, normal, ground, rules) => {
|
|
14648
14650
|
const along = dot(velocity, normal);
|
|
14649
14651
|
if (along >= 0) return velocity;
|
|
@@ -14671,6 +14673,9 @@ var ExplosiveBody = class {
|
|
|
14671
14673
|
__publicField(this, "isArmed");
|
|
14672
14674
|
__publicField(this, "isDone", false);
|
|
14673
14675
|
__publicField(this, "isDud", false);
|
|
14676
|
+
/** Fired with a speed and an impact fuze (a rocket, a 40 mm grenade): it must end in a blast, never lie live on what it hit. */
|
|
14677
|
+
__publicField(this, "isLaunched");
|
|
14678
|
+
__publicField(this, "stillSteps", 0);
|
|
14674
14679
|
this.explosive = init.explosive;
|
|
14675
14680
|
this.position = [init.origin[0], init.origin[1], init.origin[2]];
|
|
14676
14681
|
this.velocity = init.velocity ? [init.velocity[0], init.velocity[1], init.velocity[2]] : [0, 0, 0];
|
|
@@ -14680,6 +14685,7 @@ var ExplosiveBody = class {
|
|
|
14680
14685
|
this.isArmed = this.armDistance <= 0;
|
|
14681
14686
|
this.fuseLeft = this.triggers.has("timer") ? init.fuse : void 0;
|
|
14682
14687
|
this.rules = init.rules;
|
|
14688
|
+
this.isLaunched = this.triggers.has("impact") && this.moves();
|
|
14683
14689
|
}
|
|
14684
14690
|
get age() {
|
|
14685
14691
|
return this.clock;
|
|
@@ -14709,6 +14715,10 @@ var ExplosiveBody = class {
|
|
|
14709
14715
|
const slice = this.fuseLeft === void 0 ? seconds : Math.min(seconds, this.fuseLeft);
|
|
14710
14716
|
this.fly(slice, probe, events);
|
|
14711
14717
|
if (this.isDone) return events;
|
|
14718
|
+
if (this.isLaunched && this.isSpent()) {
|
|
14719
|
+
events.push(this.detonate(this.clock >= this.rules.selfDestructSeconds ? "timer" : "impact"));
|
|
14720
|
+
return events;
|
|
14721
|
+
}
|
|
14712
14722
|
if (this.fuseLeft !== void 0) {
|
|
14713
14723
|
this.fuseLeft -= slice;
|
|
14714
14724
|
if (this.fuseLeft <= EPS) events.push(this.detonate("timer"));
|
|
@@ -14724,11 +14734,17 @@ var ExplosiveBody = class {
|
|
|
14724
14734
|
moves() {
|
|
14725
14735
|
return length(this.velocity) > EPS;
|
|
14726
14736
|
}
|
|
14737
|
+
/** A launched round that came to rest (stopped, or still for `STILL_STEPS` steps) or flew past its self-destruct time. */
|
|
14738
|
+
isSpent() {
|
|
14739
|
+
if (this.clock >= this.rules.selfDestructSeconds) return true;
|
|
14740
|
+
return !this.moves() || this.stillSteps >= STILL_STEPS;
|
|
14741
|
+
}
|
|
14727
14742
|
fly(seconds, probe, events) {
|
|
14728
14743
|
if (seconds <= 0 || !this.moves()) {
|
|
14729
14744
|
this.clock += Math.max(0, seconds);
|
|
14730
14745
|
return;
|
|
14731
14746
|
}
|
|
14747
|
+
const start = this.position;
|
|
14732
14748
|
this.velocity = [this.velocity[0], this.velocity[1] - this.rules.gravity * seconds, this.velocity[2]];
|
|
14733
14749
|
const next = [this.position[0] + this.velocity[0] * seconds, this.position[1] + this.velocity[1] * seconds, this.position[2] + this.velocity[2] * seconds];
|
|
14734
14750
|
const hit = probe?.(this.position, next) ?? null;
|
|
@@ -14737,11 +14753,12 @@ var ExplosiveBody = class {
|
|
|
14737
14753
|
const planned = distance(this.position, next);
|
|
14738
14754
|
this.flown += moved;
|
|
14739
14755
|
this.position = [target[0], target[1], target[2]];
|
|
14740
|
-
const
|
|
14756
|
+
const hitAt2 = this.clock + (hit && planned > EPS ? seconds * Math.min(1, moved / planned) : seconds);
|
|
14741
14757
|
this.clock += seconds;
|
|
14742
14758
|
if (length(this.velocity) > EPS) this.facing = normalize(this.velocity);
|
|
14759
|
+
this.stillSteps = distance(start, this.position) < this.rules.restSpeed * STILL_SHARE * seconds ? this.stillSteps + 1 : 0;
|
|
14743
14760
|
this.checkArmed(events);
|
|
14744
|
-
if (hit) this.onImpact(hit,
|
|
14761
|
+
if (hit) this.onImpact(hit, hitAt2, events);
|
|
14745
14762
|
}
|
|
14746
14763
|
checkArmed(events) {
|
|
14747
14764
|
if (this.isArmed || this.flown < this.armDistance) return;
|
|
@@ -14751,7 +14768,7 @@ var ExplosiveBody = class {
|
|
|
14751
14768
|
onImpact(hit, at, events) {
|
|
14752
14769
|
events.push({ type: "impact", at, point: hit.point, armed: this.isArmed });
|
|
14753
14770
|
if (this.triggers.has("impact")) {
|
|
14754
|
-
if (this.isArmed) events.push(this.detonate("impact", at));
|
|
14771
|
+
if (this.isArmed || this.rules.unarmedImpact !== "dud") events.push(this.detonate("impact", at));
|
|
14755
14772
|
else {
|
|
14756
14773
|
this.isDone = true;
|
|
14757
14774
|
this.isDud = true;
|
|
@@ -16271,6 +16288,44 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
|
|
|
16271
16288
|
};
|
|
16272
16289
|
};
|
|
16273
16290
|
|
|
16291
|
+
// src/ground-sweep.ts
|
|
16292
|
+
var BISECTIONS = 10;
|
|
16293
|
+
var SLOPE_STEP = 0.1;
|
|
16294
|
+
var lerp = (from, to, k) => [from[0] + (to[0] - from[0]) * k, from[1] + (to[1] - from[1]) * k, from[2] + (to[2] - from[2]) * k];
|
|
16295
|
+
var groundNormal = (groundAt, x, z) => {
|
|
16296
|
+
const slopeX = (groundAt(x + SLOPE_STEP, z) - groundAt(x - SLOPE_STEP, z)) / (2 * SLOPE_STEP);
|
|
16297
|
+
const slopeZ = (groundAt(x, z + SLOPE_STEP) - groundAt(x, z - SLOPE_STEP)) / (2 * SLOPE_STEP);
|
|
16298
|
+
const size = Math.hypot(slopeX, 1, slopeZ);
|
|
16299
|
+
return [-slopeX / size, 1 / size, -slopeZ / size];
|
|
16300
|
+
};
|
|
16301
|
+
function sweepGround(from, to, groundAt, options = {}) {
|
|
16302
|
+
const clearance = options.clearance ?? 0;
|
|
16303
|
+
const below = (point) => point[1] < groundAt(point[0], point[2]) + clearance;
|
|
16304
|
+
const length2 = Math.hypot(to[0] - from[0], to[1] - from[1], to[2] - from[2]);
|
|
16305
|
+
const samples = Math.max(1, Math.ceil(length2 / (options.spacing ?? 0.1)));
|
|
16306
|
+
let above = 0;
|
|
16307
|
+
if (below(from)) return hitAt(from, from, groundAt, clearance);
|
|
16308
|
+
for (let index = 1; index <= samples; index++) {
|
|
16309
|
+
const k = index / samples;
|
|
16310
|
+
if (!below(lerp(from, to, k))) {
|
|
16311
|
+
above = k;
|
|
16312
|
+
continue;
|
|
16313
|
+
}
|
|
16314
|
+
let high = k;
|
|
16315
|
+
for (let step = 0; step < BISECTIONS; step++) {
|
|
16316
|
+
const middle = (above + high) / 2;
|
|
16317
|
+
if (below(lerp(from, to, middle))) high = middle;
|
|
16318
|
+
else above = middle;
|
|
16319
|
+
}
|
|
16320
|
+
return hitAt(from, lerp(from, to, high), groundAt, clearance);
|
|
16321
|
+
}
|
|
16322
|
+
return null;
|
|
16323
|
+
}
|
|
16324
|
+
var hitAt = (from, at, groundAt, clearance) => {
|
|
16325
|
+
const point = [at[0], groundAt(at[0], at[2]) + clearance, at[2]];
|
|
16326
|
+
return { point, normal: groundNormal(groundAt, at[0], at[2]), ground: true, distance: Math.hypot(point[0] - from[0], point[1] - from[1], point[2] - from[2]) };
|
|
16327
|
+
};
|
|
16328
|
+
|
|
16274
16329
|
// src/explosive-effect.ts
|
|
16275
16330
|
var OUT_OF_REACH = { zone: "none", distance: Infinity, falloff: 0, stunSeconds: 0 };
|
|
16276
16331
|
var insideCone = (offset, facing, halfAngleDeg) => {
|
|
@@ -16499,6 +16554,7 @@ export {
|
|
|
16499
16554
|
roundsToWarning,
|
|
16500
16555
|
roundsToWarningOf,
|
|
16501
16556
|
sampleFuse,
|
|
16557
|
+
sweepGround,
|
|
16502
16558
|
tripwireSegment,
|
|
16503
16559
|
weaponMenu
|
|
16504
16560
|
};
|