@adatechnology/game-weapons 0.3.0 → 0.4.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 { Vec3, Use, ExplosionChain, Shot } from '@adatechnology/game-contracts';
2
- export { Shot, Use, Vec3 } from '@adatechnology/game-contracts';
1
+ import { Vec3, Use, ExplosionChain, DeepPartial, Shot } from '@adatechnology/game-contracts';
2
+ export { DeepPartial, Shot, Use, Vec3 } from '@adatechnology/game-contracts';
3
3
 
4
4
  type AttachmentId = string;
5
5
  /** Where on a weapon something goes. */
@@ -863,10 +863,7 @@ interface WeaponState {
863
863
  /** What happened since the last call (for animation and sound), in order of time; empties the list. */
864
864
  drain(): WeaponEvent[];
865
865
  }
866
- /** Recursively optional; arrays and functions are replaced as a whole, objects are merged. */
867
- type DeepPartial<TValue> = TValue extends (...args: never[]) => unknown ? TValue : TValue extends readonly unknown[] ? TValue : TValue extends object ? {
868
- [TKey in keyof TValue]?: DeepPartial<TValue[TKey]>;
869
- } : TValue;
866
+
870
867
  /** Changes to a weapon def: `action`, `timings` and `dimensions` merge field by field, anything else replaces. */
871
868
  type WeaponPatch = DeepPartial<Omit<WeaponDef, 'id'>>;
872
869
  interface ArsenalOptions {
@@ -1042,4 +1039,4 @@ type StageTable = Readonly<Record<ReloadKind, readonly ReloadStage[]>>;
1042
1039
  /** Where each step of a reload falls, as a fraction of its duration, from the key frames of the gallery animations. The runtime scales them to the duration of the weapon. */
1043
1040
  declare const RELOAD_STAGES: Readonly<Record<ReloadFamily, StageTable>>;
1044
1041
 
1045
- export { ARCHETYPE_IDS, ATTACHMENTS, 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 DeepPartial, type Detonation, EXPLOSIVES, type EffectCondition, ExplosiveBody, type ExplosiveBodyInit, type ExplosiveChain, type ExplosiveDef, type ExplosiveEvent, type ExplosiveId, type ExplosiveTrigger, type ExplosiveTripwire, type FaultContext, type FaultId, type FireMode, type FirearmAction, type FitOptions, type FitRefusal, type FitResult, type FittedAttachment, type IsCompatible, type Loadout, type LoadoutContext, type MountDef, type MountKind, RELOAD_STAGES, type ReloadFamily, type ReloadKind, type ReloadRequest, type ReloadStage, type ReloadStageId, type RimType, type StatModifier, type StockDef, type StockState, type SurfaceProbe, type TriggerResult, type TripwireSegment, WEAPONS, type WeaponAction, type WeaponCategory, type WeaponDef, type WeaponDimensions, type WeaponEvent, type WeaponId, type WeaponPatch, type WeaponPhase, type WeaponRules, type WeaponSnapshot, type WeaponStance, type WeaponStat, type WeaponState, type WeaponTimings, type WeaponsLocale, type WeaponsStrings, backblastEffect, blastEffect, canFit, canInstallWith, checkArsenal, createArsenal, createExplosiveBody, createRng, locales, muzzleEnergy, nominalFuse, resolveLoadout, resolveStrings, sampleFuse, tripwireSegment };
1042
+ export { ARCHETYPE_IDS, ATTACHMENTS, 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 ExplosiveTrigger, type ExplosiveTripwire, type FaultContext, type FaultId, type FireMode, type FirearmAction, type FitOptions, type FitRefusal, type FitResult, type FittedAttachment, type IsCompatible, type Loadout, type LoadoutContext, type MountDef, type MountKind, RELOAD_STAGES, type ReloadFamily, type ReloadKind, type ReloadRequest, type ReloadStage, type ReloadStageId, type RimType, type StatModifier, type StockDef, type StockState, type SurfaceProbe, type TriggerResult, type TripwireSegment, WEAPONS, type WeaponAction, type WeaponCategory, type WeaponDef, type WeaponDimensions, type WeaponEvent, type WeaponId, type WeaponPatch, type WeaponPhase, type WeaponRules, type WeaponSnapshot, type WeaponStance, type WeaponStat, type WeaponState, type WeaponTimings, type WeaponsLocale, type WeaponsStrings, backblastEffect, blastEffect, canFit, canInstallWith, checkArsenal, createArsenal, createExplosiveBody, createRng, locales, muzzleEnergy, nominalFuse, resolveLoadout, resolveStrings, sampleFuse, tripwireSegment };
@@ -1179,6 +1179,34 @@ var GameWeapons = (() => {
1179
1179
  }
1180
1180
  ];
1181
1181
 
1182
+ // ../game-contracts/dist/index.js
1183
+ var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
1184
+ var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
1185
+ var deepMerge = (base, patch) => {
1186
+ if (!patch) return base;
1187
+ const result2 = { ...base };
1188
+ for (const [key, value] of Object.entries(patch)) {
1189
+ if (value === void 0 || UNSAFE_KEYS.has(key)) continue;
1190
+ const current = result2[key];
1191
+ result2[key] = isPlainObject(current) && isPlainObject(value) ? deepMerge(current, value) : value;
1192
+ }
1193
+ return result2;
1194
+ };
1195
+ var mergeById = (shipped, extra) => {
1196
+ const entries = /* @__PURE__ */ new Map();
1197
+ for (const entry of [...shipped, ...extra ?? []]) entries.set(entry.id, entry);
1198
+ return entries;
1199
+ };
1200
+ var applyPatches = (entries, patches) => {
1201
+ for (const [id, patch] of Object.entries(patches ?? {})) {
1202
+ const entry = entries.get(id);
1203
+ if (entry) entries.set(id, deepMerge(entry, patch));
1204
+ }
1205
+ };
1206
+ var removeIds = (entries, ids) => {
1207
+ for (const id of ids ?? []) entries.delete(id);
1208
+ };
1209
+
1182
1210
  // src/data/archetypes.json
1183
1211
  var archetypes_default = [
1184
1212
  {
@@ -11135,6 +11163,209 @@ var GameWeapons = (() => {
11135
11163
  return { ok: true, mount: place.kind };
11136
11164
  };
11137
11165
 
11166
+ // src/data/melee-weapons.json
11167
+ var melee_weapons_default = [
11168
+ {
11169
+ id: "tactical_knife",
11170
+ name: "Tactical knife",
11171
+ category: "melee_blade",
11172
+ action: {
11173
+ kind: "melee",
11174
+ damage: "slash",
11175
+ energy: 45,
11176
+ radius: 0.03,
11177
+ reach: 0.6,
11178
+ rpm: 100,
11179
+ noise: 1
11180
+ },
11181
+ mass: 0.3
11182
+ },
11183
+ {
11184
+ id: "meat_cleaver",
11185
+ name: "Meat cleaver",
11186
+ category: "melee_blade",
11187
+ action: {
11188
+ kind: "melee",
11189
+ damage: "slash",
11190
+ energy: 120,
11191
+ radius: 0.05,
11192
+ reach: 0.6,
11193
+ rpm: 70,
11194
+ noise: 2
11195
+ },
11196
+ mass: 0.6
11197
+ },
11198
+ {
11199
+ id: "hatchet",
11200
+ name: "Hatchet",
11201
+ category: "melee_blade",
11202
+ action: {
11203
+ kind: "melee",
11204
+ damage: "slash",
11205
+ energy: 180,
11206
+ radius: 0.06,
11207
+ reach: 0.7,
11208
+ rpm: 55,
11209
+ noise: 2
11210
+ },
11211
+ mass: 0.8
11212
+ },
11213
+ {
11214
+ id: "nail_bat",
11215
+ name: "Nail bat",
11216
+ category: "melee_blunt",
11217
+ action: {
11218
+ kind: "melee",
11219
+ damage: "blunt",
11220
+ energy: 170,
11221
+ radius: 0.1,
11222
+ reach: 1,
11223
+ rpm: 60,
11224
+ noise: 3
11225
+ },
11226
+ mass: 1.2
11227
+ },
11228
+ {
11229
+ id: "iron_pipe",
11230
+ name: "Iron pipe",
11231
+ category: "melee_blunt",
11232
+ action: {
11233
+ kind: "melee",
11234
+ damage: "blunt",
11235
+ energy: 140,
11236
+ radius: 0.06,
11237
+ reach: 1,
11238
+ rpm: 60,
11239
+ noise: 4
11240
+ },
11241
+ mass: 1.2
11242
+ },
11243
+ {
11244
+ id: "pickaxe",
11245
+ name: "Pickaxe",
11246
+ category: "melee_blade",
11247
+ action: {
11248
+ kind: "melee",
11249
+ damage: "slash",
11250
+ energy: 260,
11251
+ radius: 0.05,
11252
+ reach: 1,
11253
+ rpm: 40,
11254
+ noise: 4
11255
+ },
11256
+ mass: 2.8,
11257
+ tags: [
11258
+ "heavy"
11259
+ ]
11260
+ },
11261
+ {
11262
+ id: "sickle",
11263
+ name: "Sickle",
11264
+ category: "melee_blade",
11265
+ action: {
11266
+ kind: "melee",
11267
+ damage: "slash",
11268
+ energy: 70,
11269
+ radius: 0.05,
11270
+ reach: 1.1,
11271
+ rpm: 70,
11272
+ noise: 2
11273
+ },
11274
+ mass: 1.2
11275
+ },
11276
+ {
11277
+ id: "police_baton",
11278
+ name: "Police baton",
11279
+ category: "melee_blunt",
11280
+ action: {
11281
+ kind: "melee",
11282
+ damage: "blunt",
11283
+ energy: 70,
11284
+ radius: 0.04,
11285
+ reach: 0.7,
11286
+ rpm: 90,
11287
+ noise: 3
11288
+ },
11289
+ mass: 0.6
11290
+ },
11291
+ {
11292
+ id: "cast_iron_skillet",
11293
+ name: "Cast iron skillet",
11294
+ category: "melee_blunt",
11295
+ action: {
11296
+ kind: "melee",
11297
+ damage: "blunt",
11298
+ energy: 110,
11299
+ radius: 0.12,
11300
+ reach: 0.6,
11301
+ rpm: 60,
11302
+ noise: 8
11303
+ },
11304
+ mass: 1.2
11305
+ },
11306
+ {
11307
+ id: "improvised_spear",
11308
+ name: "Improvised spear",
11309
+ category: "melee_blade",
11310
+ action: {
11311
+ kind: "melee",
11312
+ damage: "slash",
11313
+ energy: 90,
11314
+ radius: 0.02,
11315
+ reach: 1.6,
11316
+ rpm: 50,
11317
+ noise: 1
11318
+ },
11319
+ mass: 1.1
11320
+ },
11321
+ {
11322
+ id: "chainsaw",
11323
+ name: "Chainsaw",
11324
+ category: "melee_blade",
11325
+ action: {
11326
+ kind: "melee",
11327
+ damage: "slash",
11328
+ energy: 400,
11329
+ radius: 0.1,
11330
+ reach: 0.9,
11331
+ rpm: 300,
11332
+ noise: 120
11333
+ },
11334
+ mass: 6,
11335
+ tags: [
11336
+ "heavy"
11337
+ ]
11338
+ },
11339
+ {
11340
+ id: "recurve_bow",
11341
+ name: "Recurve bow",
11342
+ category: "bow",
11343
+ action: {
11344
+ kind: "firearm",
11345
+ caliber: "arrow",
11346
+ rpm: 20,
11347
+ modes: [
11348
+ "single"
11349
+ ],
11350
+ magazine: 1,
11351
+ reload: 1.5,
11352
+ barrel: 1,
11353
+ spreadDeg: 0.4,
11354
+ bloomDeg: 0.4,
11355
+ recoveryDegPerS: 2,
11356
+ recoil: [
11357
+ 0.3,
11358
+ 0.1
11359
+ ],
11360
+ range: 40
11361
+ },
11362
+ mass: 1.2,
11363
+ tags: [
11364
+ "silent"
11365
+ ]
11366
+ }
11367
+ ];
11368
+
11138
11369
  // src/check-arsenal.ts
11139
11370
  var findDuplicateIds = (kind, entries) => {
11140
11371
  const seen = /* @__PURE__ */ new Set();
@@ -11221,20 +11452,6 @@ var GameWeapons = (() => {
11221
11452
  ...checkRuleDefaults(rules)
11222
11453
  ];
11223
11454
 
11224
- // src/merge.ts
11225
- var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
11226
- var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
11227
- var deepMerge = (base, patch) => {
11228
- if (!patch) return base;
11229
- const result2 = { ...base };
11230
- for (const [key, value] of Object.entries(patch)) {
11231
- if (value === void 0 || UNSAFE_KEYS.has(key)) continue;
11232
- const current = result2[key];
11233
- result2[key] = isPlainObject(current) && isPlainObject(value) ? deepMerge(current, value) : value;
11234
- }
11235
- return result2;
11236
- };
11237
-
11238
11455
  // src/locale.ts
11239
11456
  var modesEn = { single: "single action", semi: "semi-automatic", burst: "burst", auto: "automatic", pump: "pump action", bolt: "bolt action", lever: "lever action", break: "break action", volley: "volley" };
11240
11457
  var categoriesEn = {
@@ -11431,20 +11648,6 @@ var GameWeapons = (() => {
11431
11648
  };
11432
11649
 
11433
11650
  // src/registry.ts
11434
- var mergeById = (shipped, extra) => {
11435
- const entries = /* @__PURE__ */ new Map();
11436
- for (const entry of [...shipped, ...extra ?? []]) entries.set(entry.id, entry);
11437
- return entries;
11438
- };
11439
- var applyPatches = (entries, patches) => {
11440
- for (const [id, patch] of Object.entries(patches ?? {})) {
11441
- const entry = entries.get(id);
11442
- if (entry) entries.set(id, deepMerge(entry, patch));
11443
- }
11444
- };
11445
- var removeIds = (entries, ids) => {
11446
- for (const id of ids ?? []) entries.delete(id);
11447
- };
11448
11651
  var resolveThrowables = (weapons, explosives) => {
11449
11652
  for (const [id, def] of weapons) {
11450
11653
  if (def.action.kind !== "throwable" || def.action.explosive === void 0) continue;
@@ -12722,6 +12925,7 @@ var GameWeapons = (() => {
12722
12925
  caliber: cal.diameter,
12723
12926
  caliberId: cal.id,
12724
12927
  speed,
12928
+ mass: cal.bulletGrams,
12725
12929
  energyAt,
12726
12930
  pellet: p,
12727
12931
  weapon: this.def.id
@@ -12911,7 +13115,7 @@ var GameWeapons = (() => {
12911
13115
  var EXPLOSIVES = explosives_default;
12912
13116
  var ARCHETYPES = archetypes_default;
12913
13117
  var ARCHETYPE_IDS = ARCHETYPES.map((def) => def.id);
12914
- var WEAPONS = [...ARCHETYPES, ...firearms_default, ...launchers_default, ...explosive_weapons_default];
13118
+ var WEAPONS = [...ARCHETYPES, ...firearms_default, ...launchers_default, ...explosive_weapons_default, ...melee_weapons_default];
12915
13119
  var DEFAULT_LOADOUT = [
12916
13120
  "hand",
12917
13121
  "kick",