@adatechnology/game-weapons 0.6.0 → 0.7.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.d.ts CHANGED
@@ -431,6 +431,11 @@ interface WeaponRules {
431
431
  readonly base: number;
432
432
  readonly perKg: number;
433
433
  readonly hipSpread: number;
434
+ /**
435
+ * How much the view closes in while aiming down the iron sights, by weapon category (1 no change): the eye settles on the sights and the field narrows. A fitted optic gives its
436
+ * own magnification instead. A category left out does not zoom.
437
+ */
438
+ readonly ironSightZoom: Readonly<Record<string, number>>;
434
439
  };
435
440
  /** Folding or sliding in the stock: the seconds it takes and what it does to the weapon while it is in. */
436
441
  readonly stock: {
@@ -1249,4 +1254,61 @@ interface MuzzleSmokeParams {
1249
1254
  */
1250
1255
  declare function muzzleSmokeOf({ caliber, weapon, suppressed }: MuzzleSmokeParams): MuzzleSmokeProfile;
1251
1256
 
1252
- export { AMMO, ARCHETYPE_IDS, ATTACHMENTS, type AmmoCore, type AmmoDef, type AmmoJacket, type AmmoKind, type AmmoLoad, type AmmoPenetration, 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 ExplosiveLeak, type ExplosiveShell, type ExplosiveTrigger, type ExplosiveTripwire, type FaultContext, type FaultId, type FireMode, type FirearmAction, type FitOptions, type FitRefusal, type FitResult, type FittedAttachment, GALLERY_HEAT, type IsCompatible, type Loadout, type LoadoutContext, MUZZLE_SMOKE, type MountDef, type MountKind, type MuzzleSmokeParams, type MuzzleSmokeProfile, type MuzzleSmokeProfileId, 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, ammoId, ammoIgnition, backblastEffect, blastEffect, canFit, canInstallWith, checkArsenal, createArsenal, createExplosiveBody, createRng, locales, muzzleEnergy, muzzleSmokeOf, nominalFuse, resolveLoad, resolveLoadout, resolveStrings, sampleFuse, tripwireSegment };
1257
+ /**
1258
+ * How much the view closes in while a weapon aims: the magnification of the optic fitted on it (the lowest of a variable one, the AUG's integral 1.5x), else the iron-sight zoom
1259
+ * of its category (`rules.aim.ironSightZoom`); 1 for a weapon that does not aim (a knife, a grenade).
1260
+ */
1261
+ declare function aimZoomOf(arsenal: Arsenal, weaponId: WeaponId, attachments?: readonly AttachmentId[]): number;
1262
+
1263
+ /** One group of the weapon menu as a game declares it: the categories it lists, in order, each a section of its own. */
1264
+ interface WeaponMenuGroupDef {
1265
+ readonly id: string;
1266
+ /** Name by locale (`en`, `pt-BR`...); the id when the locale has none. */
1267
+ readonly name: Readonly<Record<string, string>>;
1268
+ readonly categories: readonly string[];
1269
+ }
1270
+ interface WeaponMenuEntry {
1271
+ readonly id: WeaponId;
1272
+ readonly name: string;
1273
+ /** The maker of a brand weapon (Glock, Taurus, Heckler & Koch...), so a search by maker finds it. */
1274
+ readonly maker?: string;
1275
+ /** The tags of the weapon (`pdw`, `explosive`...), so a search by them finds it. */
1276
+ readonly tags?: readonly string[];
1277
+ /** The section it is listed in (its category, or `flame` for a flamethrower filed as a launcher). */
1278
+ readonly category: string;
1279
+ }
1280
+ interface WeaponMenuSection {
1281
+ /** The category. */
1282
+ readonly id: string;
1283
+ readonly name: string;
1284
+ readonly weapons: readonly WeaponMenuEntry[];
1285
+ }
1286
+ interface WeaponMenuGroup {
1287
+ readonly id: string;
1288
+ readonly name: string;
1289
+ readonly sections: readonly WeaponMenuSection[];
1290
+ }
1291
+ interface WeaponMenuOptions {
1292
+ /** Locale of the group names (default `en`); the weapon and category names are the arsenal's own. */
1293
+ readonly locale?: string;
1294
+ /** The groups and their categories (default `WEAPON_MENU_GROUPS`). A category no group lists goes to a last `other` group. */
1295
+ readonly groups?: readonly WeaponMenuGroupDef[];
1296
+ /** Weapons left out of the menu (default none). */
1297
+ readonly exclude?: (def: WeaponDef) => boolean;
1298
+ /** List the generic guns too (`genericWeapons`: the `9 mm service pistol` that wears the Beretta's model); default false, the real weapons stand for them. */
1299
+ readonly generics?: boolean;
1300
+ }
1301
+ /** The groups of the menu: firearms, bladed and blunt weapons, explosives (throwables and launchers), tools (and the flames). */
1302
+ declare const WEAPON_MENU_GROUPS: readonly WeaponMenuGroupDef[];
1303
+ /** The whole arsenal by group and section, each section sorted by name: what a weapon picker lists. */
1304
+ declare function weaponMenu(arsenal: Arsenal, options?: WeaponMenuOptions): WeaponMenuGroup[];
1305
+
1306
+ /**
1307
+ * The generic guns of the arsenal (the `9 mm service pistol`, the `5.56 mm assault rifle`...) and the real weapon that stands for each: the brand weapon of lowest id that names
1308
+ * it as its `archetype` and fires the same way, the one whose model it wears; `undefined` for a generic no real weapon stands for (the `.22 LR pistol`).
1309
+ */
1310
+ declare function genericWeapons(arsenal: Arsenal): ReadonlyMap<WeaponId, WeaponId | undefined>;
1311
+ /** A loadout with each generic gun swapped for the real weapon that stands for it (dropped when none does), and no id twice. */
1312
+ declare function realLoadout(arsenal: Arsenal, loadout: readonly WeaponId[]): WeaponId[];
1313
+
1314
+ export { AMMO, ARCHETYPE_IDS, ATTACHMENTS, type AmmoCore, type AmmoDef, type AmmoJacket, type AmmoKind, type AmmoLoad, type AmmoPenetration, 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 ExplosiveLeak, type ExplosiveShell, type ExplosiveTrigger, type ExplosiveTripwire, type FaultContext, type FaultId, type FireMode, type FirearmAction, type FitOptions, type FitRefusal, type FitResult, type FittedAttachment, GALLERY_HEAT, type IsCompatible, type Loadout, type LoadoutContext, MUZZLE_SMOKE, type MountDef, type MountKind, type MuzzleSmokeParams, type MuzzleSmokeProfile, type MuzzleSmokeProfileId, 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, WEAPON_MENU_GROUPS, type WeaponAction, type WeaponCategory, type WeaponDef, type WeaponDimensions, type WeaponEvent, type WeaponId, type WeaponMenuEntry, type WeaponMenuGroup, type WeaponMenuGroupDef, type WeaponMenuOptions, type WeaponMenuSection, type WeaponPatch, type WeaponPhase, type WeaponRules, type WeaponSnapshot, type WeaponStance, type WeaponStat, type WeaponState, type WeaponTimings, type WeaponsLocale, type WeaponsStrings, aimZoomOf, ammoId, ammoIgnition, backblastEffect, blastEffect, canFit, canInstallWith, checkArsenal, createArsenal, createExplosiveBody, createRng, genericWeapons, locales, muzzleEnergy, muzzleSmokeOf, nominalFuse, realLoadout, resolveLoad, resolveLoadout, resolveStrings, sampleFuse, tripwireSegment, weaponMenu };
@@ -35,6 +35,8 @@ var GameWeapons = (() => {
35
35
  MUZZLE_SMOKE: () => MUZZLE_SMOKE,
36
36
  RELOAD_STAGES: () => RELOAD_STAGES,
37
37
  WEAPONS: () => WEAPONS,
38
+ WEAPON_MENU_GROUPS: () => WEAPON_MENU_GROUPS,
39
+ aimZoomOf: () => aimZoomOf,
38
40
  ammoId: () => ammoId,
39
41
  ammoIgnition: () => ammoIgnition,
40
42
  backblastEffect: () => backblastEffect,
@@ -45,15 +47,18 @@ var GameWeapons = (() => {
45
47
  createArsenal: () => createArsenal,
46
48
  createExplosiveBody: () => createExplosiveBody,
47
49
  createRng: () => createRng,
50
+ genericWeapons: () => genericWeapons,
48
51
  locales: () => locales,
49
52
  muzzleEnergy: () => muzzleEnergy,
50
53
  muzzleSmokeOf: () => muzzleSmokeOf,
51
54
  nominalFuse: () => nominalFuse,
55
+ realLoadout: () => realLoadout,
52
56
  resolveLoad: () => resolveLoad,
53
57
  resolveLoadout: () => resolveLoadout,
54
58
  resolveStrings: () => resolveStrings,
55
59
  sampleFuse: () => sampleFuse,
56
- tripwireSegment: () => tripwireSegment
60
+ tripwireSegment: () => tripwireSegment,
61
+ weaponMenu: () => weaponMenu
57
62
  });
58
63
 
59
64
  // src/rng.ts
@@ -5688,7 +5693,10 @@ var GameWeapons = (() => {
5688
5693
  ]
5689
5694
  }
5690
5695
  ],
5691
- fitted: []
5696
+ fitted: [],
5697
+ tags: [
5698
+ "pdw"
5699
+ ]
5692
5700
  },
5693
5701
  {
5694
5702
  id: "kriss_vector",
@@ -10147,7 +10155,9 @@ var GameWeapons = (() => {
10147
10155
  "arsenal",
10148
10156
  "reference",
10149
10157
  "derived"
10150
- ]
10158
+ ],
10159
+ mounts: [],
10160
+ fitted: []
10151
10161
  },
10152
10162
  {
10153
10163
  id: "hk_mp5sd3",
@@ -10906,7 +10916,10 @@ var GameWeapons = (() => {
10906
10916
  fitted: [],
10907
10917
  stock: {
10908
10918
  kind: "retract"
10909
- }
10919
+ },
10920
+ tags: [
10921
+ "pdw"
10922
+ ]
10910
10923
  },
10911
10924
  {
10912
10925
  id: "hk_g36",
@@ -12617,7 +12630,8 @@ var GameWeapons = (() => {
12617
12630
  dmr: "marksman rifle",
12618
12631
  hunting: "hunting rifle",
12619
12632
  machine_gun: "machine gun",
12620
- launcher: "launcher"
12633
+ launcher: "launcher",
12634
+ pdw: "PDW (personal defence weapon)"
12621
12635
  };
12622
12636
  var faultsEn = { misfire: "misfire", stovepipe: "stovepipe", double_feed: "double feed", failure_to_extract: "failure to extract" };
12623
12637
  var conditionsEn = { new: "new", used: "used", worn: "worn", rusty: "rusty" };
@@ -12670,7 +12684,27 @@ var GameWeapons = (() => {
12670
12684
  hunting_rifle_30_06: ".30-06 hunting rifle",
12671
12685
  m2_flamethrower: "M2 flamethrower",
12672
12686
  improvised_flamethrower: "Improvised flamethrower",
12673
- m79: "M79 grenade launcher"
12687
+ m79: "M79 grenade launcher",
12688
+ m203: "M203 grenade launcher",
12689
+ gp_25: "GP-25 grenade launcher",
12690
+ ag36: "AG36 grenade launcher",
12691
+ flashbang: "Flashbang",
12692
+ dynamite: "Dynamite",
12693
+ c4: "C4 charge",
12694
+ claymore: "Claymore mine",
12695
+ tactical_knife: "Tactical knife",
12696
+ meat_cleaver: "Meat cleaver",
12697
+ hatchet: "Hatchet",
12698
+ nail_bat: "Nail bat",
12699
+ iron_pipe: "Iron pipe",
12700
+ pickaxe: "Pickaxe",
12701
+ sickle: "Sickle",
12702
+ police_baton: "Police baton",
12703
+ cast_iron_skillet: "Cast iron skillet",
12704
+ improvised_spear: "Improvised spear",
12705
+ chainsaw: "Chainsaw",
12706
+ recurve_bow: "Recurve bow",
12707
+ m134: "M134 Minigun"
12674
12708
  },
12675
12709
  modes: modesEn,
12676
12710
  categories: categoriesEn,
@@ -12744,7 +12778,27 @@ var GameWeapons = (() => {
12744
12778
  hunting_rifle_30_06: "Rifle de ca\xE7a .30-06",
12745
12779
  m2_flamethrower: "Lan\xE7a-chamas M2",
12746
12780
  improvised_flamethrower: "Lan\xE7a-chamas caseiro",
12747
- m79: "Lan\xE7a-granadas M79"
12781
+ m79: "Lan\xE7a-granadas M79",
12782
+ m203: "Lan\xE7a-granadas M203",
12783
+ gp_25: "Lan\xE7a-granadas GP-25",
12784
+ ag36: "Lan\xE7a-granadas AG36",
12785
+ flashbang: "granada de luz",
12786
+ dynamite: "dinamite",
12787
+ c4: "C4 com detonador",
12788
+ claymore: "mina Claymore",
12789
+ tactical_knife: "faca t\xE1tica",
12790
+ meat_cleaver: "cutelo",
12791
+ hatchet: "machadinha",
12792
+ nail_bat: "taco com pregos",
12793
+ iron_pipe: "cano de ferro",
12794
+ pickaxe: "picareta",
12795
+ sickle: "foice",
12796
+ police_baton: "cassetete",
12797
+ cast_iron_skillet: "frigideira de ferro",
12798
+ improvised_spear: "lan\xE7a improvisada",
12799
+ chainsaw: "motosserra",
12800
+ recurve_bow: "arco recurvo",
12801
+ m134: "Minigun M134"
12748
12802
  },
12749
12803
  modes: { single: "tiro \xFAnico", semi: "semiautom\xE1tico", burst: "rajada", auto: "autom\xE1tico", pump: "repeti\xE7\xE3o", bolt: "ferrolho", lever: "alavanca", break: "basculante", volley: "salva" },
12750
12804
  categories: {
@@ -12768,7 +12822,8 @@ var GameWeapons = (() => {
12768
12822
  dmr: "fuzil de precis\xE3o semiautom\xE1tico",
12769
12823
  hunting: "arma de ca\xE7a",
12770
12824
  machine_gun: "metralhadora",
12771
- launcher: "lan\xE7ador"
12825
+ launcher: "lan\xE7ador",
12826
+ pdw: "PDW (arma de defesa pessoal)"
12772
12827
  },
12773
12828
  explosives: {
12774
12829
  m67: "Granada M67",
@@ -12867,7 +12922,13 @@ var GameWeapons = (() => {
12867
12922
  // 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)
12868
12923
  attachments: { fitSeconds: { field: 2, tool: 15, bench: 30 }, switchSeconds: 0.8, speedOfSound: 343 },
12869
12924
  // 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)
12870
- aim: { base: 0.15, perKg: 0.05, hipSpread: 1 },
12925
+ aim: {
12926
+ base: 0.15,
12927
+ perKg: 0.05,
12928
+ hipSpread: 1,
12929
+ // the iron sights close the view in a little: more for a long gun, whose sights sit farther from the eye, than for a handgun
12930
+ ironSightZoom: { pistol: 1.1, revolver: 1.1, smg: 1.2, carbine: 1.25, shotgun: 1.15, rifle: 1.3, hunting: 1.35, dmr: 1.4, sniper: 1.4, machine_gun: 1.2, launcher: 1.15, bow: 1.15, crossbow: 1.25 }
12931
+ },
12871
12932
  // Arsenal §08/§11: coronha retrátil saca mais rápido, mais recuo; os números são padrões aprovados pelo dono (2026-10-24)
12872
12933
  stock: {
12873
12934
  seconds: 0.6,
@@ -14577,6 +14638,79 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
14577
14638
  const id = caliber?.propellant === "black_powder" ? "black_powder" : caliber?.propellant === "none" ? "none" : "smokeless";
14578
14639
  return MUZZLE_SMOKE[id];
14579
14640
  }
14641
+
14642
+ // src/aim-zoom.ts
14643
+ function aimZoomOf(arsenal, weaponId, attachments = arsenal.weapons.get(weaponId)?.fitted?.map((part) => part.id) ?? []) {
14644
+ const def = arsenal.weapons.get(weaponId);
14645
+ if (!def) return 1;
14646
+ const optic = attachments.map((id) => arsenal.attachments.get(id)?.optic).find((entry) => entry !== void 0);
14647
+ if (optic) return optic.zoom[0];
14648
+ return arsenal.rules.aim.ironSightZoom[def.category] ?? 1;
14649
+ }
14650
+
14651
+ // src/generics.ts
14652
+ var isGenericKind = (kind, category) => kind === "firearm" && category !== "bow" && category !== "crossbow" || kind === "flame";
14653
+ function genericWeapons(arsenal) {
14654
+ const archetypes = new Set(ARCHETYPE_IDS);
14655
+ const generics = /* @__PURE__ */ new Map();
14656
+ for (const def of arsenal.weapons.values()) if (archetypes.has(def.id) && isGenericKind(def.action.kind, def.category) && !def.maker) generics.set(def.id, void 0);
14657
+ for (const def of [...arsenal.weapons.values()].sort((a, b) => a.id < b.id ? -1 : 1)) {
14658
+ const { archetype } = def;
14659
+ if (!archetype || archetypes.has(def.id) || !generics.has(archetype) || generics.get(archetype)) continue;
14660
+ if (arsenal.weapons.get(archetype)?.action.kind === def.action.kind) generics.set(archetype, def.id);
14661
+ }
14662
+ for (const [id, brand] of generics) if (!brand && arsenal.weapons.get(id)?.action.kind === "flame") generics.delete(id);
14663
+ return generics;
14664
+ }
14665
+ function realLoadout(arsenal, loadout) {
14666
+ const generics = genericWeapons(arsenal);
14667
+ const real = loadout.flatMap((id) => generics.has(id) ? [generics.get(id)].filter((brand) => brand !== void 0) : [id]);
14668
+ return [...new Set(real)];
14669
+ }
14670
+
14671
+ // src/menu.ts
14672
+ var WEAPON_MENU_GROUPS = [
14673
+ {
14674
+ id: "firearms",
14675
+ name: { en: "Firearms", "pt-BR": "Armas de fogo" },
14676
+ categories: ["pistol", "revolver", "smg", "pdw", "carbine", "rifle", "dmr", "hunting", "sniper", "shotgun", "machine_gun", "bow", "crossbow"]
14677
+ },
14678
+ { id: "melee", name: { en: "Melee weapons", "pt-BR": "Armas brancas" }, categories: ["melee_blade", "melee_blunt", "hand"] },
14679
+ { id: "explosives", name: { en: "Explosives", "pt-BR": "Explosivos" }, categories: ["throwable", "launcher"] },
14680
+ { id: "tools", name: { en: "Tools", "pt-BR": "Ferramentas" }, categories: ["tool", "heat", "flame", "extinguisher"] }
14681
+ ];
14682
+ var OTHER_GROUP = { id: "other", name: { en: "Other", "pt-BR": "Outros" }, categories: [] };
14683
+ var sectionOf = (def) => {
14684
+ if (def.category === "launcher" && def.action.kind === "flame") return "flame";
14685
+ return def.tags?.includes("pdw") ? "pdw" : def.category;
14686
+ };
14687
+ var nameIn = (def, locale) => def.name[locale] ?? def.name.en ?? def.id;
14688
+ var capitalize = (text) => text.charAt(0).toLocaleUpperCase() + text.slice(1);
14689
+ function weaponMenu(arsenal, options = {}) {
14690
+ const locale = options.locale ?? "en";
14691
+ const groups = options.groups ?? WEAPON_MENU_GROUPS;
14692
+ const bySection = /* @__PURE__ */ new Map();
14693
+ const generics = options.generics ? /* @__PURE__ */ new Map() : genericWeapons(arsenal);
14694
+ for (const def of arsenal.weapons.values()) {
14695
+ if (options.exclude?.(def) || generics.has(def.id)) continue;
14696
+ const category = sectionOf(def);
14697
+ const list = bySection.get(category) ?? [];
14698
+ list.push({ id: def.id, name: capitalize(arsenal.name(def.id)), category, ...def.maker ? { maker: def.maker } : {}, ...def.tags?.length ? { tags: def.tags } : {} });
14699
+ bySection.set(category, list);
14700
+ }
14701
+ const listed = new Set(groups.flatMap((group) => group.categories));
14702
+ const other = { ...OTHER_GROUP, categories: [...bySection.keys()].filter((category) => !listed.has(category)) };
14703
+ const sectionsOf = (group) => group.categories.flatMap((category) => {
14704
+ const weapons = bySection.get(category);
14705
+ if (!weapons?.length) return [];
14706
+ const sorted = [...weapons].sort((a, b) => a.name.localeCompare(b.name, locale));
14707
+ return [{ id: category, name: capitalize(arsenal.name(category)), weapons: sorted }];
14708
+ });
14709
+ return [...groups, other].flatMap((group) => {
14710
+ const sections = sectionsOf(group);
14711
+ return sections.length ? [{ id: group.id, name: nameIn(group, locale), sections }] : [];
14712
+ });
14713
+ }
14580
14714
  return __toCommonJS(index_exports);
14581
14715
  })();
14582
14716
  //# sourceMappingURL=index.global.js.map