@adatechnology/game-weapons 0.13.6 → 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/README.md +4 -0
- package/dist/index.d.ts +25 -1
- package/dist/index.global.js +93 -0
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +93 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -312,3 +312,7 @@ trava, calor do cano, dispersão, chumbos de espingarda, recuo, ruído), além d
|
|
|
312
312
|
`weapon.drain()` entrega os eventos (saque, tiro, pane, recarga...) para animação e som; `rules` muda qualquer número (`faults: false` desliga as panes). Cada disparo vira um `Shot` (energia em joules, calibre em mm, direção) que se passa direto para
|
|
313
313
|
`world.shoot(origem, direção, shot.energy, shot.caliber)` do `@adatechnology/game-destruction`. Use `createArsenal({ locale: 'pt-BR' })` para os nomes
|
|
314
314
|
em português (`arsenal.name('rifle_5_56')` devolve "fuzil 5,56"). A recarga nunca é automática; o jogo chama `reload()`.
|
|
315
|
+
|
|
316
|
+
## Melee families
|
|
317
|
+
|
|
318
|
+
`MELEE_FAMILIES` (`data/melee-families.json`, spec 015 R3) groups the melee weapons that strike alike and lists their blows in order: `short_blade` (knife, tactical knife, KA-BAR, cleaver) cuts then thrusts (`knife_slash`, `knife_stab`), `one_hand_swing` (machete, hatchet, sickle, hammer, baton, skillet) chops from over the shoulder, `two_hand_swing` (bats, pipe, crowbar, axe, sledgehammer, pickaxe, katana) swings flat as the shovel. A blow names the body's clip (`ATTACK_CLIPS` of game-characters-people), the weapon's motion (`TOOL_MOTIONS` of game-weapons-three) and their seconds. `meleeFamilyOf(id)`, `meleeStrikeClips()` (the clip of each weapon, for a host's strike-clip map) and `createMeleeBlowCycle()` (the next blow of a family; after `reset` seconds without one it starts over) read them.
|
package/dist/index.d.ts
CHANGED
|
@@ -1509,4 +1509,28 @@ declare function genericWeapons(arsenal: Arsenal): ReadonlyMap<WeaponId, WeaponI
|
|
|
1509
1509
|
/** A loadout with each generic gun swapped for the real weapon that stands for it (dropped when none does), and no id twice. */
|
|
1510
1510
|
declare function realLoadout(arsenal: Arsenal, loadout: readonly WeaponId[]): WeaponId[];
|
|
1511
1511
|
|
|
1512
|
-
|
|
1512
|
+
/** One blow of a family: the body's clip, the weapon's motion and their length (seconds). */
|
|
1513
|
+
interface MeleeBlow {
|
|
1514
|
+
readonly clip: string;
|
|
1515
|
+
readonly motion: string;
|
|
1516
|
+
readonly seconds: number;
|
|
1517
|
+
}
|
|
1518
|
+
/** Weapons that strike alike and their blows; a pause longer than `reset` seconds starts the blows over from the first. */
|
|
1519
|
+
interface MeleeFamily {
|
|
1520
|
+
readonly id: string;
|
|
1521
|
+
readonly weapons: readonly string[];
|
|
1522
|
+
readonly blows: readonly MeleeBlow[];
|
|
1523
|
+
readonly reset: number;
|
|
1524
|
+
}
|
|
1525
|
+
declare const MELEE_FAMILIES: readonly MeleeFamily[];
|
|
1526
|
+
/** The family a weapon strikes with, or undefined. */
|
|
1527
|
+
declare const meleeFamilyOf: (weaponId: string, families?: readonly MeleeFamily[]) => MeleeFamily | undefined;
|
|
1528
|
+
/** The strike clip of each weapon of the families (its first blow), as the strike-clip map a host keys by weapon id. */
|
|
1529
|
+
declare const meleeStrikeClips: (families?: readonly MeleeFamily[]) => Readonly<Record<string, string>>;
|
|
1530
|
+
/** Picks the blows of a family in turn: the next one, or the first again after `reset` seconds without a blow. */
|
|
1531
|
+
interface MeleeBlowCycle {
|
|
1532
|
+
next(weaponId: string, now: number): MeleeBlow | undefined;
|
|
1533
|
+
}
|
|
1534
|
+
declare const createMeleeBlowCycle: (families?: readonly MeleeFamily[]) => MeleeBlowCycle;
|
|
1535
|
+
|
|
1536
|
+
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 ExplosiveSmoke, type ExplosiveTrigger, type ExplosiveTripwire, type FaultContext, type FaultId, type FireMode, type FirearmAction, type FitOptions, type FitRefusal, type FitResult, type FittedAttachment, GALLERY_HEAT, type GroundHeight, type GroundSweepHit, type GroundSweepOptions, type IsCompatible, type Loadout, type LoadoutContext, MELEE_FAMILIES, MUZZLE_SMOKE, type MeleeBlow, type MeleeBlowCycle, type MeleeFamily, 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 RoundsToWarningParams, SLING_SWING_DEFAULTS, type SlingSwing, type SlingSwingRules, type SlingSwingState, 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 WeaponHands, 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, barrelMassOf, blastEffect, canDualWield, canFit, canInstallWith, checkArsenal, coolingTimeConstant, createArsenal, createExplosiveBody, createMeleeBlowCycle, createRng, createSlingSwing, decayHeat, genericWeapons, locales, meleeFamilyOf, meleeStrikeClips, muzzleEnergy, muzzleSmokeOf, nominalFuse, realLoadout, resolveLoad, resolveLoadout, resolveStrings, roundsToWarning, roundsToWarningOf, sampleFuse, sweepGround, tripwireSegment, weaponHandsOf, weaponMenu };
|
package/dist/index.global.js
CHANGED
|
@@ -32,6 +32,7 @@ var GameWeapons = (() => {
|
|
|
32
32
|
EXPLOSIVES: () => EXPLOSIVES,
|
|
33
33
|
ExplosiveBody: () => ExplosiveBody,
|
|
34
34
|
GALLERY_HEAT: () => GALLERY_HEAT,
|
|
35
|
+
MELEE_FAMILIES: () => MELEE_FAMILIES,
|
|
35
36
|
MUZZLE_SMOKE: () => MUZZLE_SMOKE,
|
|
36
37
|
RELOAD_STAGES: () => RELOAD_STAGES,
|
|
37
38
|
SLING_SWING_DEFAULTS: () => SLING_SWING_DEFAULTS,
|
|
@@ -50,11 +51,14 @@ var GameWeapons = (() => {
|
|
|
50
51
|
coolingTimeConstant: () => coolingTimeConstant,
|
|
51
52
|
createArsenal: () => createArsenal,
|
|
52
53
|
createExplosiveBody: () => createExplosiveBody,
|
|
54
|
+
createMeleeBlowCycle: () => createMeleeBlowCycle,
|
|
53
55
|
createRng: () => createRng,
|
|
54
56
|
createSlingSwing: () => createSlingSwing,
|
|
55
57
|
decayHeat: () => decayHeat,
|
|
56
58
|
genericWeapons: () => genericWeapons,
|
|
57
59
|
locales: () => locales,
|
|
60
|
+
meleeFamilyOf: () => meleeFamilyOf,
|
|
61
|
+
meleeStrikeClips: () => meleeStrikeClips,
|
|
58
62
|
muzzleEnergy: () => muzzleEnergy,
|
|
59
63
|
muzzleSmokeOf: () => muzzleSmokeOf,
|
|
60
64
|
nominalFuse: () => nominalFuse,
|
|
@@ -16855,6 +16859,95 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
|
|
|
16855
16859
|
return sections.length ? [{ id: group.id, name: nameIn(group, locale), sections }] : [];
|
|
16856
16860
|
});
|
|
16857
16861
|
}
|
|
16862
|
+
|
|
16863
|
+
// src/data/melee-families.json
|
|
16864
|
+
var melee_families_default = {
|
|
16865
|
+
families: [
|
|
16866
|
+
{
|
|
16867
|
+
id: "short_blade",
|
|
16868
|
+
note: "a knife held in one hand, edge forward: a diagonal cut from the right shoulder and a straight thrust, one after the other (spec 015 R3, 'golpe curto (faca)')",
|
|
16869
|
+
weapons: [
|
|
16870
|
+
"knife",
|
|
16871
|
+
"tactical_knife",
|
|
16872
|
+
"kabar",
|
|
16873
|
+
"meat_cleaver"
|
|
16874
|
+
],
|
|
16875
|
+
blows: [
|
|
16876
|
+
{
|
|
16877
|
+
clip: "knife_slash",
|
|
16878
|
+
motion: "slash",
|
|
16879
|
+
seconds: 0.46
|
|
16880
|
+
},
|
|
16881
|
+
{
|
|
16882
|
+
clip: "knife_stab",
|
|
16883
|
+
motion: "stab",
|
|
16884
|
+
seconds: 0.42
|
|
16885
|
+
}
|
|
16886
|
+
],
|
|
16887
|
+
reset: 1.2
|
|
16888
|
+
},
|
|
16889
|
+
{
|
|
16890
|
+
id: "one_hand_swing",
|
|
16891
|
+
note: "a short heavy tool or blade in one hand (machete, hatchet, hammer, baton, skillet): chopped down from over the right shoulder, the body turning into it as in the knife's cut",
|
|
16892
|
+
weapons: [
|
|
16893
|
+
"machete",
|
|
16894
|
+
"hatchet",
|
|
16895
|
+
"sickle",
|
|
16896
|
+
"hammer",
|
|
16897
|
+
"police_baton",
|
|
16898
|
+
"cast_iron_skillet"
|
|
16899
|
+
],
|
|
16900
|
+
blows: [
|
|
16901
|
+
{
|
|
16902
|
+
clip: "knife_slash",
|
|
16903
|
+
motion: "chop",
|
|
16904
|
+
seconds: 0.46
|
|
16905
|
+
}
|
|
16906
|
+
],
|
|
16907
|
+
reset: 1.2
|
|
16908
|
+
},
|
|
16909
|
+
{
|
|
16910
|
+
id: "two_hand_swing",
|
|
16911
|
+
note: "a long weapon in both hands (bat, pipe, crowbar, axe, sledgehammer, katana): swung flat from the right shoulder across the body, the hips leading, as the shovel's swing",
|
|
16912
|
+
weapons: [
|
|
16913
|
+
"baseball_bat",
|
|
16914
|
+
"nail_bat",
|
|
16915
|
+
"iron_pipe",
|
|
16916
|
+
"crowbar",
|
|
16917
|
+
"axe",
|
|
16918
|
+
"sledgehammer",
|
|
16919
|
+
"pickaxe",
|
|
16920
|
+
"katana"
|
|
16921
|
+
],
|
|
16922
|
+
blows: [
|
|
16923
|
+
{
|
|
16924
|
+
clip: "shovel_swing",
|
|
16925
|
+
motion: "swing",
|
|
16926
|
+
seconds: 0.6
|
|
16927
|
+
}
|
|
16928
|
+
],
|
|
16929
|
+
reset: 1.2
|
|
16930
|
+
}
|
|
16931
|
+
]
|
|
16932
|
+
};
|
|
16933
|
+
|
|
16934
|
+
// src/melee-families.ts
|
|
16935
|
+
var MELEE_FAMILIES = melee_families_default.families;
|
|
16936
|
+
var meleeFamilyOf = (weaponId, families = MELEE_FAMILIES) => families.find((family) => family.weapons.includes(weaponId));
|
|
16937
|
+
var meleeStrikeClips = (families = MELEE_FAMILIES) => Object.fromEntries(families.flatMap((family) => family.blows[0] ? family.weapons.map((weapon) => [weapon, family.blows[0].clip]) : []));
|
|
16938
|
+
var createMeleeBlowCycle = (families = MELEE_FAMILIES) => {
|
|
16939
|
+
const last = /* @__PURE__ */ new Map();
|
|
16940
|
+
return {
|
|
16941
|
+
next(weaponId, now) {
|
|
16942
|
+
const family = meleeFamilyOf(weaponId, families);
|
|
16943
|
+
if (!family || family.blows.length === 0) return void 0;
|
|
16944
|
+
const previous = last.get(family.id);
|
|
16945
|
+
const index = previous && now - previous.at <= family.reset ? (previous.index + 1) % family.blows.length : 0;
|
|
16946
|
+
last.set(family.id, { index, at: now });
|
|
16947
|
+
return family.blows[index];
|
|
16948
|
+
}
|
|
16949
|
+
};
|
|
16950
|
+
};
|
|
16858
16951
|
return __toCommonJS(index_exports);
|
|
16859
16952
|
})();
|
|
16860
16953
|
//# sourceMappingURL=index.global.js.map
|