@adatechnology/game-weapons-three 0.13.1 → 0.14.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 CHANGED
@@ -1,5 +1,5 @@
1
- import { I as ItemModels, W as WeaponProps, a as WeaponItemModel, M as ModelKit, b as WeaponModel, c as ModelParts, d as ModelFamily, A as AttachmentModelRegistry, L as LaserRaycast } from './testing-DjtsFm2m.js';
2
- export { e as ARCHETYPE_MODELS, f as AttachmentBuildContext, g as AttachmentModel, h as AttachmentModelBuilder, C as CLASS_REFERENCE_ENERGY, i as COUNTER_ITEM_ID, j as CUES_IN_SAMPLE, k as CasingSound, l as CuePlayed, D as DEFAULT_ENERGY_CURVE, m as DEFAULT_EXPLOSIVES_SCENE, n as DistanceCurve, E as EXPLOSIVES_AREA_ID, o as EXPLOSIVES_TEXT, p as EnergyCurve, q as ExplosivesRoom, r as ExplosivesScene, s as ExplosivesTestModuleOptions, t as ExplosivesText, F as FlybySound, u as FxLayers, G as GAME_DISTANCE_CURVE, v as GAME_SOUND_CLASSES, w as GUNSHOT_PROFILES, x as GUNSHOT_SAMPLE, y as GUNSHOT_SAMPLE_IDS, z as Gunshot, B as GunshotInput, H as GunshotPlayed, J as ItemModelRequest, K as MECHANICAL_SOUNDS, N as MODEL_ENTRIES, O as MOUNTED_M134_ITEM_ID, P as MechanicalSoundId, Q as ModelEntry, R as ModelMaterials, S as ModelOptions, T as MountFrame, U as RELOAD_SAMPLE, V as RELOAD_SAMPLE_HITS, X as ShotExtras, Y as ShotSound, Z as ShotSoundClass, _ as ShotSoundInput, $ as ShotSoundOptions, a0 as SoundClassDef, a1 as SoundStep, a2 as WEAPON_ITEM_PREFIX, a3 as WEIGHT_INTENSITY, a4 as WeaponAudio, a5 as WeaponAudioOptions, a6 as WeaponFx, a7 as WeaponFxOptions, a8 as WeaponSampleOptions, a9 as WeaponsTestModuleOptions, aa as buildItemWeaponModel, ab as buildWeaponModel, ac as buildWeaponModelById, ad as computeCasingSound, ae as computeFlyby, af as computeGunshot, ag as computeShotSound, ah as createExplosivesTestModule, ai as createWeaponAudio, aj as createWeaponFx, ak as createWeaponsTestModule, al as defaultWeaponProps, am as deriveFrames, an as explosivesTextOf, ao as hasWeaponModel, ap as itemModelOfWeapon, aq as mechanicalSoundOf, ar as modelKit, as as mountFrame, at as registerWeaponItemModel, au as weaponSampleBank, av as weaponSampleDefaults, aw as weaponsLayout } from './testing-DjtsFm2m.js';
1
+ import { I as ItemModels, W as WeaponProps, a as WeaponItemModel, M as ModelKit, b as WeaponModel, c as ModelParts, d as ModelFamily, A as AttachmentModelRegistry, L as LaserRaycast } from './testing-DnPjEPC5.js';
2
+ export { e as ARCHETYPE_MODELS, f as AttachmentBuildContext, g as AttachmentModel, h as AttachmentModelBuilder, C as CLASS_REFERENCE_ENERGY, i as COUNTER_ITEM_ID, j as CUES_IN_SAMPLE, k as CasingSound, l as CuePlayed, D as DEFAULT_ENERGY_CURVE, m as DEFAULT_EXPLOSIVES_SCENE, n as DistanceCurve, E as EXPLOSIVES_AREA_ID, o as EXPLOSIVES_TEXT, p as EnergyCurve, q as ExplosivesRoom, r as ExplosivesScene, s as ExplosivesTestModuleOptions, t as ExplosivesText, F as FlybySound, u as FxLayers, G as GAME_DISTANCE_CURVE, v as GAME_SOUND_CLASSES, w as GUNSHOT_PROFILES, x as GUNSHOT_SAMPLE, y as GUNSHOT_SAMPLE_IDS, z as Gunshot, B as GunshotInput, H as GunshotPlayed, J as ItemModelRequest, K as MECHANICAL_SOUNDS, N as MODEL_ENTRIES, O as MOUNTED_M134_ITEM_ID, P as MechanicalSoundId, Q as ModelEntry, R as ModelMaterials, S as ModelOptions, T as MountFrame, U as RELOAD_SAMPLE, V as RELOAD_SAMPLE_HITS, X as ShotExtras, Y as ShotSound, Z as ShotSoundClass, _ as ShotSoundInput, $ as ShotSoundOptions, a0 as SoundClassDef, a1 as SoundStep, a2 as WEAPON_ITEM_PREFIX, a3 as WEIGHT_INTENSITY, a4 as WeaponAudio, a5 as WeaponAudioOptions, a6 as WeaponFx, a7 as WeaponFxOptions, a8 as WeaponSampleOptions, a9 as WeaponsTestModuleOptions, aa as buildItemWeaponModel, ab as buildWeaponModel, ac as buildWeaponModelById, ad as computeCasingSound, ae as computeFlyby, af as computeGunshot, ag as computeShotSound, ah as createExplosivesTestModule, ai as createWeaponAudio, aj as createWeaponFx, ak as createWeaponsTestModule, al as defaultWeaponProps, am as deriveFrames, an as explosivesTextOf, ao as hasWeaponModel, ap as itemModelOfWeapon, aq as mechanicalSoundOf, ar as modelKit, as as mountFrame, at as registerWeaponItemModel, au as weaponSampleBank, av as weaponSampleDefaults, aw as weaponsLayout } from './testing-DnPjEPC5.js';
3
3
  import * as THREE_NS from 'three';
4
4
  import { TestableItem, Vec3, HostEvent, EffectSink, DestructibleSpec, DeepPartial, ToolClipSet } from '@adatechnology/game-contracts';
5
5
  import { ExplosiveDef, Arsenal, WeaponDef, CartridgeDims, CaliberDef, CaseType, ReloadFamily, FittedAttachment, AttachmentDef } from '@adatechnology/game-weapons';
@@ -98,6 +98,24 @@ var GameWeaponsThree = (() => {
98
98
  });
99
99
 
100
100
  // ../game-contracts/dist/index.js
101
+ var DEFAULT_BLAST_IMPULSE = { bodyArea: 0.7, lift: 0.15, minSpeed: 0.3, tntPerJoule: 0.24 / 2e5 };
102
+ var NEAREST = 0.3;
103
+ function sideOnImpulse(tnt, distance3) {
104
+ if (!(tnt > 0)) return 0;
105
+ const w3 = Math.cbrt(tnt);
106
+ const z = Math.max(distance3, NEAREST) / w3;
107
+ const scaled2 = 0.067 * Math.sqrt(1 + (z / 0.23) ** 4) / (z * z * Math.cbrt(1 + (z / 1.55) ** 3));
108
+ return scaled2 * w3 * 100;
109
+ }
110
+ function bodyImpulse(tnt, distance3) {
111
+ if (!(tnt > 0)) return 0;
112
+ const z = Math.max(distance3, NEAREST) / Math.cbrt(tnt);
113
+ return sideOnImpulse(tnt, distance3) * (2 + 4 / (1 + z * z));
114
+ }
115
+ function blastBodySpeed(tnt, distance3, mass, reach = 1, options = {}) {
116
+ const area3 = options.bodyArea ?? DEFAULT_BLAST_IMPULSE.bodyArea;
117
+ return bodyImpulse(tnt, distance3) * area3 * Math.max(0, reach) / Math.max(mass, 1);
118
+ }
101
119
  var DEFAULT_COST_ALLOCATION_BYTES = 1024 * 1024;
102
120
  var DEFAULT_IGNITION_RULES = {
103
121
  fillCurve: [
@@ -4099,6 +4117,7 @@ var GameWeaponsThree = (() => {
4099
4117
  lethalRadius: 5,
4100
4118
  injuryRadius: 15,
4101
4119
  energy: 2e5,
4120
+ tnt: 0.24,
4102
4121
  destructionLevel: 2,
4103
4122
  noise: 500,
4104
4123
  fuse: 4,
@@ -4144,6 +4163,7 @@ var GameWeaponsThree = (() => {
4144
4163
  lethalRadius: 3,
4145
4164
  injuryRadius: 10,
4146
4165
  energy: 43200,
4166
+ tnt: 0.15,
4147
4167
  destructionLevel: 2,
4148
4168
  noise: 450,
4149
4169
  fuse: 3,
@@ -4163,6 +4183,7 @@ var GameWeaponsThree = (() => {
4163
4183
  lethalRadius: 5,
4164
4184
  injuryRadius: 14,
4165
4185
  energy: 2e5,
4186
+ tnt: 1.5,
4166
4187
  destructionLevel: 2,
4167
4188
  noise: 550,
4168
4189
  fire: {
@@ -4209,6 +4230,7 @@ var GameWeaponsThree = (() => {
4209
4230
  lethalRadius: 4,
4210
4231
  injuryRadius: 12,
4211
4232
  energy: 102400,
4233
+ tnt: 0.25,
4212
4234
  destructionLevel: 3,
4213
4235
  noise: 600,
4214
4236
  fuseLength: 0.03,
@@ -4231,6 +4253,7 @@ var GameWeaponsThree = (() => {
4231
4253
  lethalRadius: 6,
4232
4254
  injuryRadius: 18,
4233
4255
  energy: 345600,
4256
+ tnt: 0.76,
4234
4257
  destructionLevel: 3,
4235
4258
  noise: 700,
4236
4259
  triggers: [
@@ -4254,6 +4277,7 @@ var GameWeaponsThree = (() => {
4254
4277
  length: 50
4255
4278
  },
4256
4279
  energy: 102400,
4280
+ tnt: 0.9,
4257
4281
  destructionLevel: 1,
4258
4282
  noise: 500,
4259
4283
  triggers: [
@@ -4277,6 +4301,7 @@ var GameWeaponsThree = (() => {
4277
4301
  lethalRadius: 0,
4278
4302
  injuryRadius: 10,
4279
4303
  energy: 0,
4304
+ tnt: 0.01,
4280
4305
  destructionLevel: 0,
4281
4306
  noise: 400,
4282
4307
  fuseRange: [
@@ -4301,6 +4326,7 @@ var GameWeaponsThree = (() => {
4301
4326
  lethalRadius: 4,
4302
4327
  injuryRadius: 12,
4303
4328
  energy: 102400,
4329
+ tnt: 0.045,
4304
4330
  destructionLevel: 2,
4305
4331
  noise: 450,
4306
4332
  triggers: [
@@ -4319,6 +4345,7 @@ var GameWeaponsThree = (() => {
4319
4345
  lethalRadius: 5,
4320
4346
  injuryRadius: 15,
4321
4347
  energy: 2e5,
4348
+ tnt: 0.45,
4322
4349
  destructionLevel: 3,
4323
4350
  noise: 700,
4324
4351
  triggers: [
@@ -4337,6 +4364,7 @@ var GameWeaponsThree = (() => {
4337
4364
  lethalRadius: 5,
4338
4365
  injuryRadius: 16,
4339
4366
  energy: 2e5,
4367
+ tnt: 0.7,
4340
4368
  destructionLevel: 3,
4341
4369
  noise: 750,
4342
4370
  triggers: [
@@ -4355,6 +4383,7 @@ var GameWeaponsThree = (() => {
4355
4383
  lethalRadius: 5,
4356
4384
  injuryRadius: 16,
4357
4385
  energy: 2e5,
4386
+ tnt: 0.45,
4358
4387
  destructionLevel: 3,
4359
4388
  noise: 750,
4360
4389
  triggers: [
@@ -4373,6 +4402,7 @@ var GameWeaponsThree = (() => {
4373
4402
  lethalRadius: 5,
4374
4403
  injuryRadius: 16,
4375
4404
  energy: 2e5,
4405
+ tnt: 0.7,
4376
4406
  destructionLevel: 3,
4377
4407
  noise: 750,
4378
4408
  triggers: [
@@ -4391,6 +4421,7 @@ var GameWeaponsThree = (() => {
4391
4421
  lethalRadius: 4,
4392
4422
  injuryRadius: 12,
4393
4423
  energy: 102400,
4424
+ tnt: 1,
4394
4425
  destructionLevel: 2,
4395
4426
  noise: 550,
4396
4427
  fire: {
@@ -4424,6 +4455,7 @@ var GameWeaponsThree = (() => {
4424
4455
  lethalRadius: 5,
4425
4456
  injuryRadius: 14,
4426
4457
  energy: 2e5,
4458
+ tnt: 0.5,
4427
4459
  destructionLevel: 2,
4428
4460
  noise: 550,
4429
4461
  fire: {
@@ -4461,6 +4493,7 @@ var GameWeaponsThree = (() => {
4461
4493
  lethalRadius: 4,
4462
4494
  injuryRadius: 12,
4463
4495
  energy: 102400,
4496
+ tnt: 0.5,
4464
4497
  destructionLevel: 3,
4465
4498
  noise: 700,
4466
4499
  fire: {
@@ -4490,6 +4523,7 @@ var GameWeaponsThree = (() => {
4490
4523
  lethalRadius: 12,
4491
4524
  injuryRadius: 30,
4492
4525
  energy: 2764800,
4526
+ tnt: 20,
4493
4527
  destructionLevel: 3,
4494
4528
  noise: 700,
4495
4529
  fire: {
@@ -4517,6 +4551,7 @@ var GameWeaponsThree = (() => {
4517
4551
  lethalRadius: 4,
4518
4552
  injuryRadius: 12,
4519
4553
  energy: 102400,
4554
+ tnt: 0.045,
4520
4555
  destructionLevel: 2,
4521
4556
  noise: 450,
4522
4557
  triggers: [
@@ -13235,6 +13270,7 @@ var GameWeaponsThree = (() => {
13235
13270
  direction: this.facing,
13236
13271
  at: at3,
13237
13272
  energy: def.energy,
13273
+ ...def.tnt !== void 0 ? { tnt: def.tnt } : {},
13238
13274
  lethalRadius: def.lethalRadius,
13239
13275
  injuryRadius: def.injuryRadius,
13240
13276
  noise: def.noise,
@@ -23926,7 +23962,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23926
23962
  return;
23927
23963
  }
23928
23964
  if (ex) {
23929
- emit2({ ...base(o, src), type: "explode", part: p.spec.id, point: c, energy: ex.energy, radius: ex.radius, ...ex.lethalRadius !== void 0 ? { lethalRadius: ex.lethalRadius } : {}, ...ex.effect !== void 0 ? { effect: ex.effect } : {} });
23965
+ emit2({ ...base(o, src), type: "explode", part: p.spec.id, point: c, energy: ex.energy, radius: ex.radius, ...ex.lethalRadius !== void 0 ? { lethalRadius: ex.lethalRadius } : {}, ...ex.tnt !== void 0 ? { tnt: ex.tnt } : {}, ...ex.effect !== void 0 ? { effect: ex.effect } : {} });
23930
23966
  blasts.push({ point: c, energy: ex.energy, radius: ex.radius, ...ex.lethalRadius !== void 0 ? { lethalRadius: ex.lethalRadius } : {}, source: src });
23931
23967
  }
23932
23968
  partLost(o, p, src);
@@ -65312,7 +65348,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
65312
65348
  // a real mass (the vessel and what it holds) replaces the hollow-sheet density
65313
65349
  ...def.mass !== void 0 && shape.wall !== void 0 ? { mass: def.mass } : {},
65314
65350
  ...def.leak ? { contains: { fluid: def.leak.fluid, liters: def.leak.liters, pressurized: def.leak.pressurized } } : {},
65315
- explodes: { energy: def.energy * scale, radius: def.injuryRadius * scale, lethalRadius: def.lethalRadius * scale, effect: def.id, ...def.chain ? { chain: { ...def.chain } } : {} }
65351
+ explodes: { energy: def.energy * scale, radius: def.injuryRadius * scale, lethalRadius: def.lethalRadius * scale, effect: def.id, ...def.tnt !== void 0 ? { tnt: def.tnt * scale } : {}, ...def.chain ? { chain: { ...def.chain } } : {} }
65316
65352
  });
65317
65353
  var meshOf = (THREE, shape) => {
65318
65354
  const geometry = shape.shape.kind === "cylinder" ? new THREE.CylinderGeometry(shape.shape.radius, shape.shape.radius, shape.shape.height, 16) : shape.shape.kind === "box" ? new THREE.BoxGeometry(...shape.shape.size) : new THREE.SphereGeometry(0.2);
@@ -65983,7 +66019,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
65983
66019
  push_found: "{n} bodies were laid around the blast to be measured ({kinds})",
65984
66020
  push_outward: "Every body inside the reach moved away from the blast ({moved} of {n}, {least} m at the least)",
65985
66021
  push_falloff: "{what}: the nearer one moved more than the farther one ({near} m at {nearDistance} m, {far} m at {farDistance} m)",
65986
- push_person: "{who} at {distance} m was pushed {moved} m away",
66022
+ push_person_wave: "{who} at {distance} m moved {moved} m away, no farther than the blast wave pushes a person ({most} m at most)",
65987
66023
  push_sheltered: "{what} at {distance} m stood behind cover ({cover}% of the blast got through) and moved only {moved} m",
65988
66024
  push_heavy: "{what} (too heavy to grab, not fixed) was moved {moved} m by the blast"
65989
66025
  }
@@ -66069,7 +66105,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
66069
66105
  push_found: "{n} corpos foram postos em volta da explos\xE3o para serem medidos ({kinds})",
66070
66106
  push_outward: "Todo corpo dentro do alcance se afastou da explos\xE3o ({moved} de {n}, no m\xEDnimo {least} m)",
66071
66107
  push_falloff: "{what}: o mais perto andou mais que o mais longe ({near} m a {nearDistance} m, {far} m a {farDistance} m)",
66072
- push_person: "{who} a {distance} m foi empurrado {moved} m para longe",
66108
+ push_person_wave: "{who} a {distance} m se afastou {moved} m, n\xE3o mais do que a onda da explos\xE3o empurra uma pessoa (no m\xE1ximo {most} m)",
66073
66109
  push_sheltered: "{what} a {distance} m estava atr\xE1s de cobertura ({cover}% da explos\xE3o passou) e andou s\xF3 {moved} m",
66074
66110
  push_heavy: "{what} (pesado demais para pegar, mas solto) foi movido {moved} m pela explos\xE3o"
66075
66111
  }
@@ -66569,7 +66605,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
66569
66605
  }
66570
66606
  offs.push(
66571
66607
  lent.on((event) => {
66572
- if (event.type === "explosion") lastBlast = { point: event.point, energy: event.energy, radius: event.radius, cause: event.cause, ...event.explosive === void 0 ? {} : { explosive: event.explosive } };
66608
+ if (event.type === "explosion") lastBlast = { point: event.point, energy: event.energy, radius: event.radius, cause: event.cause, ...event.explosive === void 0 ? {} : { explosive: event.explosive }, ...event.tnt === void 0 ? {} : { tnt: event.tnt } };
66573
66609
  })
66574
66610
  );
66575
66611
  offs.push(lent.onFrame(frame2));
@@ -66621,6 +66657,9 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
66621
66657
  var CHEST = 1.1;
66622
66658
  var MIDDLE = 0.3;
66623
66659
  var HEAVY_ITEMS = ["camp_table"];
66660
+ var PERSON_MASS = 70;
66661
+ var GROUND_FRICTION2 = 7;
66662
+ var PERSON_SLACK = 0.4;
66624
66663
  var flat = (a, b) => Math.hypot(a[0] - b[0], a[2] - b[2]);
66625
66664
  var bearing = (centre, distance3, degrees) => [centre[0] + Math.sin(degrees * Math.PI / 180) * distance3, 0, centre[2] + Math.cos(degrees * Math.PI / 180) * distance3];
66626
66665
  var PUSH_LAYOUT = {
@@ -66714,7 +66753,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
66714
66753
  for (const row of sheltered) {
66715
66754
  expect(row.outward < SHELTERED_MOST, fillText2(text.push_sheltered, { what: things[row.kind] ?? row.kind, distance: row.distance.toFixed(1), cover: (row.cover * 100).toFixed(0), moved: Math.max(0, row.outward).toFixed(2) }), { row: { kind: row.kind, distance: row.distance, outward: row.outward, cover: row.cover } });
66716
66755
  }
66717
- const reached = inReach.filter((row) => row.cover >= SHELTERED);
66756
+ const isPerson = (row) => row.kind === "survivor" || row.kind === "zombie";
66757
+ const reached = inReach.filter((row) => row.cover >= SHELTERED && !isPerson(row));
66718
66758
  const movedAway = reached.filter((row) => row.outward >= MOVED);
66719
66759
  const least = reached.length === 0 ? 0 : Math.min(...reached.map((row) => row.outward));
66720
66760
  expect(reached.length > 0 && movedAway.length === reached.length, fillText2(text.push_outward, { moved: movedAway.length, n: reached.length, least: least.toFixed(2) }), { rows: reached.map((row) => ({ kind: row.kind, distance: row.distance, outward: row.outward })), torn: rows.filter(torn).map((row) => row.objectId) });
@@ -66725,8 +66765,12 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
66725
66765
  const far = ofKind[ofKind.length - 1];
66726
66766
  expect(near.outward > far.outward, fillText2(text.push_falloff, { what: things[kind] ?? kind, near: near.outward.toFixed(2), nearDistance: near.distance.toFixed(1), far: far.outward.toFixed(2), farDistance: far.distance.toFixed(1) }), { near: near.outward, far: far.outward });
66727
66767
  }
66728
- for (const row of reached.filter((entry2) => entry2.kind === "zombie" || entry2.kind === "survivor")) {
66729
- expect(row.outward >= MOVED, fillText2(text.push_person, { who: things[row.kind] ?? row.kind, distance: row.distance.toFixed(1), moved: row.outward.toFixed(2) }), { row: { kind: row.kind, distance: row.distance, outward: row.outward } });
66768
+ for (const row of inReach.filter(isPerson)) {
66769
+ const from = origin.get(row.objectId) ?? row.from;
66770
+ const chest = Math.hypot(from[0] - blast.point[0], from[1] + CHEST - blast.point[1], from[2] - blast.point[2]);
66771
+ const speed = blastBodySpeed(blast.tnt ?? blast.energy * DEFAULT_BLAST_IMPULSE.tntPerJoule, chest, PERSON_MASS, row.cover);
66772
+ const most = speed * speed / (2 * GROUND_FRICTION2) + PERSON_SLACK;
66773
+ expect(row.outward <= most, fillText2(text.push_person_wave, { who: things[row.kind] ?? row.kind, distance: row.distance.toFixed(1), moved: Math.max(0, row.outward).toFixed(2), most: most.toFixed(2) }), { row: { kind: row.kind, distance: row.distance, outward: row.outward, speed, most } });
66730
66774
  }
66731
66775
  const table = rows.find((row) => HEAVY_ITEMS.includes(row.kind) && row.distance < blast.radius * 0.85);
66732
66776
  if (table) expect(table.moved >= MOVED, fillText2(text.push_heavy, { what: things[table.itemId] ?? table.itemId, moved: table.moved.toFixed(2) }), { table });