quake2ts 0.0.41 → 0.0.43
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/apps/viewer/dist/browser/index.global.js.map +1 -1
- package/apps/viewer/dist/cjs/index.cjs +8 -8
- package/apps/viewer/dist/cjs/index.cjs.map +1 -1
- package/apps/viewer/dist/esm/index.js +8 -8
- package/apps/viewer/dist/esm/index.js.map +1 -1
- package/apps/viewer/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/packages/game/dist/browser/index.global.js +1 -1
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs +192 -13
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +172 -13
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/inventory/ammo.d.ts +32 -0
- package/packages/game/dist/types/inventory/ammo.d.ts.map +1 -1
- package/packages/game/dist/types/inventory/index.d.ts +1 -0
- package/packages/game/dist/types/inventory/index.d.ts.map +1 -1
- package/packages/game/dist/types/inventory/playerInventory.d.ts +56 -0
- package/packages/game/dist/types/inventory/playerInventory.d.ts.map +1 -0
|
@@ -23,6 +23,7 @@ __export(index_exports, {
|
|
|
23
23
|
AIFlags: () => AIFlags,
|
|
24
24
|
AMMO_TYPE_COUNT: () => AMMO_TYPE_COUNT,
|
|
25
25
|
ARMOR_INFO: () => ARMOR_INFO,
|
|
26
|
+
AmmoItemId: () => AmmoItemId,
|
|
26
27
|
AmmoType: () => AmmoType,
|
|
27
28
|
ArmorType: () => ArmorType,
|
|
28
29
|
DamageFlags: () => DamageFlags,
|
|
@@ -34,8 +35,10 @@ __export(index_exports, {
|
|
|
34
35
|
EntitySystem: () => EntitySystem,
|
|
35
36
|
EnvironmentalFlags: () => EnvironmentalFlags,
|
|
36
37
|
FL_NOVISIBLE: () => FL_NOVISIBLE,
|
|
38
|
+
KeyId: () => KeyId,
|
|
37
39
|
MoveType: () => MoveType,
|
|
38
40
|
ORDERED_DAMAGE_MODS: () => ORDERED_DAMAGE_MODS,
|
|
41
|
+
PowerupId: () => PowerupId,
|
|
39
42
|
RANGE_MELEE: () => RANGE_MELEE,
|
|
40
43
|
RANGE_MID: () => RANGE_MID,
|
|
41
44
|
RANGE_NEAR: () => RANGE_NEAR,
|
|
@@ -49,6 +52,10 @@ __export(index_exports, {
|
|
|
49
52
|
T_Damage: () => T_Damage,
|
|
50
53
|
T_RadiusDamage: () => T_RadiusDamage,
|
|
51
54
|
TraceMask: () => TraceMask,
|
|
55
|
+
WeaponId: () => WeaponId,
|
|
56
|
+
addAmmo: () => addAmmo,
|
|
57
|
+
addKey: () => addKey,
|
|
58
|
+
addPowerup: () => addPowerup,
|
|
52
59
|
ai_charge: () => ai_charge,
|
|
53
60
|
ai_face: () => ai_face,
|
|
54
61
|
ai_move: () => ai_move,
|
|
@@ -67,13 +74,24 @@ __export(index_exports, {
|
|
|
67
74
|
changeYaw: () => changeYaw,
|
|
68
75
|
clampAmmoCounts: () => clampAmmoCounts,
|
|
69
76
|
classifyRange: () => classifyRange,
|
|
77
|
+
clearExpiredPowerups: () => clearExpiredPowerups,
|
|
78
|
+
createAmmoInventory: () => createAmmoInventory,
|
|
70
79
|
createBaseAmmoCaps: () => createBaseAmmoCaps,
|
|
71
80
|
createDefaultSpawnRegistry: () => createDefaultSpawnRegistry,
|
|
72
81
|
createGame: () => createGame,
|
|
82
|
+
createPlayerInventory: () => createPlayerInventory,
|
|
73
83
|
createSaveFile: () => createSaveFile,
|
|
74
84
|
damageModName: () => damageModName,
|
|
85
|
+
equipArmor: () => equipArmor,
|
|
75
86
|
facingIdeal: () => facingIdeal,
|
|
87
|
+
getAmmoItemDefinition: () => getAmmoItemDefinition,
|
|
88
|
+
giveAmmo: () => giveAmmo,
|
|
89
|
+
giveAmmoItem: () => giveAmmoItem,
|
|
90
|
+
giveWeapon: () => giveWeapon,
|
|
76
91
|
hasAnyDamageFlag: () => hasAnyDamageFlag,
|
|
92
|
+
hasKey: () => hasKey,
|
|
93
|
+
hasPowerup: () => hasPowerup,
|
|
94
|
+
hasWeapon: () => hasWeapon,
|
|
77
95
|
hashGameState: () => hashGameState,
|
|
78
96
|
infront: () => infront,
|
|
79
97
|
isZeroVector: () => isZeroVector,
|
|
@@ -81,8 +99,10 @@ __export(index_exports, {
|
|
|
81
99
|
parseEntityLump: () => parseEntityLump,
|
|
82
100
|
parseRereleaseSave: () => parseRereleaseSave,
|
|
83
101
|
parseSaveFile: () => parseSaveFile,
|
|
102
|
+
pickupAmmo: () => pickupAmmo,
|
|
84
103
|
rangeTo: () => rangeTo,
|
|
85
104
|
registerDefaultSpawns: () => registerDefaultSpawns,
|
|
105
|
+
selectWeapon: () => selectWeapon,
|
|
86
106
|
setMovedir: () => setMovedir,
|
|
87
107
|
spawnEntitiesFromText: () => spawnEntitiesFromText,
|
|
88
108
|
spawnEntityFromDictionary: () => spawnEntityFromDictionary,
|
|
@@ -2906,11 +2926,11 @@ function hasAnyDamageFlag(flags, mask) {
|
|
|
2906
2926
|
}
|
|
2907
2927
|
|
|
2908
2928
|
// src/combat/armor.ts
|
|
2909
|
-
var ArmorType = /* @__PURE__ */ ((
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
return
|
|
2929
|
+
var ArmorType = /* @__PURE__ */ ((ArmorType3) => {
|
|
2930
|
+
ArmorType3["BODY"] = "body";
|
|
2931
|
+
ArmorType3["COMBAT"] = "combat";
|
|
2932
|
+
ArmorType3["JACKET"] = "jacket";
|
|
2933
|
+
return ArmorType3;
|
|
2914
2934
|
})(ArmorType || {});
|
|
2915
2935
|
var ARMOR_INFO = {
|
|
2916
2936
|
["jacket" /* JACKET */]: {
|
|
@@ -3399,16 +3419,39 @@ function killBox(teleporter, targets, options = {}) {
|
|
|
3399
3419
|
}
|
|
3400
3420
|
|
|
3401
3421
|
// src/inventory/ammo.ts
|
|
3402
|
-
var AmmoType = /* @__PURE__ */ ((
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
return
|
|
3422
|
+
var AmmoType = /* @__PURE__ */ ((AmmoType3) => {
|
|
3423
|
+
AmmoType3[AmmoType3["Bullets"] = 0] = "Bullets";
|
|
3424
|
+
AmmoType3[AmmoType3["Shells"] = 1] = "Shells";
|
|
3425
|
+
AmmoType3[AmmoType3["Rockets"] = 2] = "Rockets";
|
|
3426
|
+
AmmoType3[AmmoType3["Grenades"] = 3] = "Grenades";
|
|
3427
|
+
AmmoType3[AmmoType3["Cells"] = 4] = "Cells";
|
|
3428
|
+
AmmoType3[AmmoType3["Slugs"] = 5] = "Slugs";
|
|
3429
|
+
return AmmoType3;
|
|
3410
3430
|
})(AmmoType || {});
|
|
3411
3431
|
var AMMO_TYPE_COUNT = Object.keys(AmmoType).length / 2;
|
|
3432
|
+
var AmmoItemId = /* @__PURE__ */ ((AmmoItemId3) => {
|
|
3433
|
+
AmmoItemId3["Shells"] = "ammo_shells";
|
|
3434
|
+
AmmoItemId3["Bullets"] = "ammo_bullets";
|
|
3435
|
+
AmmoItemId3["Rockets"] = "ammo_rockets";
|
|
3436
|
+
AmmoItemId3["Grenades"] = "ammo_grenades";
|
|
3437
|
+
AmmoItemId3["Cells"] = "ammo_cells";
|
|
3438
|
+
AmmoItemId3["Slugs"] = "ammo_slugs";
|
|
3439
|
+
return AmmoItemId3;
|
|
3440
|
+
})(AmmoItemId || {});
|
|
3441
|
+
var AMMO_ITEM_DEFINITIONS = {
|
|
3442
|
+
["ammo_shells" /* Shells */]: { id: "ammo_shells" /* Shells */, ammoType: 1 /* Shells */, quantity: 10, weaponAmmo: false },
|
|
3443
|
+
["ammo_bullets" /* Bullets */]: { id: "ammo_bullets" /* Bullets */, ammoType: 0 /* Bullets */, quantity: 50, weaponAmmo: false },
|
|
3444
|
+
["ammo_rockets" /* Rockets */]: { id: "ammo_rockets" /* Rockets */, ammoType: 2 /* Rockets */, quantity: 5, weaponAmmo: false },
|
|
3445
|
+
["ammo_grenades" /* Grenades */]: { id: "ammo_grenades" /* Grenades */, ammoType: 3 /* Grenades */, quantity: 5, weaponAmmo: true },
|
|
3446
|
+
["ammo_cells" /* Cells */]: { id: "ammo_cells" /* Cells */, ammoType: 4 /* Cells */, quantity: 50, weaponAmmo: false },
|
|
3447
|
+
["ammo_slugs" /* Slugs */]: { id: "ammo_slugs" /* Slugs */, ammoType: 5 /* Slugs */, quantity: 10, weaponAmmo: false }
|
|
3448
|
+
};
|
|
3449
|
+
function getAmmoItemDefinition(id) {
|
|
3450
|
+
return AMMO_ITEM_DEFINITIONS[id];
|
|
3451
|
+
}
|
|
3452
|
+
function createAmmoInventory(caps = createBaseAmmoCaps()) {
|
|
3453
|
+
return { caps: caps.slice(), counts: Array(AMMO_TYPE_COUNT).fill(0) };
|
|
3454
|
+
}
|
|
3412
3455
|
function createBaseAmmoCaps() {
|
|
3413
3456
|
const caps = Array(AMMO_TYPE_COUNT).fill(50);
|
|
3414
3457
|
caps[0 /* Bullets */] = 200;
|
|
@@ -3427,6 +3470,122 @@ function clampAmmoCounts(counts, caps) {
|
|
|
3427
3470
|
}
|
|
3428
3471
|
return clamped;
|
|
3429
3472
|
}
|
|
3473
|
+
function addAmmo(inventory, ammoType, amount) {
|
|
3474
|
+
const cap = inventory.caps[ammoType];
|
|
3475
|
+
const current = inventory.counts[ammoType] ?? 0;
|
|
3476
|
+
if (cap !== void 0 && current >= cap) {
|
|
3477
|
+
return { ammoType, added: 0, newCount: current, capped: cap, pickedUp: false };
|
|
3478
|
+
}
|
|
3479
|
+
const uncapped = current + amount;
|
|
3480
|
+
const newCount = cap === void 0 ? uncapped : Math.min(uncapped, cap);
|
|
3481
|
+
const added = newCount - current;
|
|
3482
|
+
inventory.counts[ammoType] = newCount;
|
|
3483
|
+
return { ammoType, added, newCount, capped: cap ?? Number.POSITIVE_INFINITY, pickedUp: added > 0 };
|
|
3484
|
+
}
|
|
3485
|
+
function pickupAmmo(inventory, itemId, options = {}) {
|
|
3486
|
+
const def = getAmmoItemDefinition(itemId);
|
|
3487
|
+
const amount = options.countOverride ?? def.quantity;
|
|
3488
|
+
return addAmmo(inventory, def.ammoType, amount);
|
|
3489
|
+
}
|
|
3490
|
+
|
|
3491
|
+
// src/inventory/playerInventory.ts
|
|
3492
|
+
var WeaponId = /* @__PURE__ */ ((WeaponId2) => {
|
|
3493
|
+
WeaponId2["Blaster"] = "blaster";
|
|
3494
|
+
WeaponId2["Shotgun"] = "shotgun";
|
|
3495
|
+
WeaponId2["SuperShotgun"] = "super_shotgun";
|
|
3496
|
+
WeaponId2["Machinegun"] = "machinegun";
|
|
3497
|
+
WeaponId2["Chaingun"] = "chaingun";
|
|
3498
|
+
WeaponId2["GrenadeLauncher"] = "grenade_launcher";
|
|
3499
|
+
WeaponId2["RocketLauncher"] = "rocket_launcher";
|
|
3500
|
+
WeaponId2["HyperBlaster"] = "hyperblaster";
|
|
3501
|
+
WeaponId2["Railgun"] = "railgun";
|
|
3502
|
+
WeaponId2["BFG10K"] = "bfg10k";
|
|
3503
|
+
return WeaponId2;
|
|
3504
|
+
})(WeaponId || {});
|
|
3505
|
+
var PowerupId = /* @__PURE__ */ ((PowerupId2) => {
|
|
3506
|
+
PowerupId2["QuadDamage"] = "quad";
|
|
3507
|
+
PowerupId2["Invulnerability"] = "invulnerability";
|
|
3508
|
+
PowerupId2["EnviroSuit"] = "enviro_suit";
|
|
3509
|
+
PowerupId2["Rebreather"] = "rebreather";
|
|
3510
|
+
PowerupId2["Silencer"] = "silencer";
|
|
3511
|
+
return PowerupId2;
|
|
3512
|
+
})(PowerupId || {});
|
|
3513
|
+
var KeyId = /* @__PURE__ */ ((KeyId2) => {
|
|
3514
|
+
KeyId2["Blue"] = "blue";
|
|
3515
|
+
KeyId2["Red"] = "red";
|
|
3516
|
+
KeyId2["Green"] = "green";
|
|
3517
|
+
KeyId2["Yellow"] = "yellow";
|
|
3518
|
+
return KeyId2;
|
|
3519
|
+
})(KeyId || {});
|
|
3520
|
+
function createPlayerInventory(options = {}) {
|
|
3521
|
+
const ammo = createAmmoInventory(options.ammoCaps);
|
|
3522
|
+
const ownedWeapons = new Set(options.weapons ?? []);
|
|
3523
|
+
const powerups = new Map(options.powerups ?? []);
|
|
3524
|
+
const keys = new Set(options.keys ?? []);
|
|
3525
|
+
return {
|
|
3526
|
+
ammo,
|
|
3527
|
+
ownedWeapons,
|
|
3528
|
+
currentWeapon: options.currentWeapon,
|
|
3529
|
+
armor: options.armor ?? null,
|
|
3530
|
+
powerups,
|
|
3531
|
+
keys
|
|
3532
|
+
};
|
|
3533
|
+
}
|
|
3534
|
+
function giveAmmo(inventory, ammoType, amount) {
|
|
3535
|
+
return addAmmo(inventory.ammo, ammoType, amount);
|
|
3536
|
+
}
|
|
3537
|
+
function giveAmmoItem(inventory, itemId, options) {
|
|
3538
|
+
return pickupAmmo(inventory.ammo, itemId, options);
|
|
3539
|
+
}
|
|
3540
|
+
function giveWeapon(inventory, weapon, select = false) {
|
|
3541
|
+
const hadWeapon = inventory.ownedWeapons.has(weapon);
|
|
3542
|
+
inventory.ownedWeapons.add(weapon);
|
|
3543
|
+
if (select || !inventory.currentWeapon) {
|
|
3544
|
+
inventory.currentWeapon = weapon;
|
|
3545
|
+
}
|
|
3546
|
+
return !hadWeapon;
|
|
3547
|
+
}
|
|
3548
|
+
function hasWeapon(inventory, weapon) {
|
|
3549
|
+
return inventory.ownedWeapons.has(weapon);
|
|
3550
|
+
}
|
|
3551
|
+
function selectWeapon(inventory, weapon) {
|
|
3552
|
+
if (!inventory.ownedWeapons.has(weapon)) {
|
|
3553
|
+
return false;
|
|
3554
|
+
}
|
|
3555
|
+
inventory.currentWeapon = weapon;
|
|
3556
|
+
return true;
|
|
3557
|
+
}
|
|
3558
|
+
function equipArmor(inventory, armorType, amount) {
|
|
3559
|
+
if (!armorType || amount <= 0) {
|
|
3560
|
+
inventory.armor = null;
|
|
3561
|
+
return null;
|
|
3562
|
+
}
|
|
3563
|
+
const info = ARMOR_INFO[armorType];
|
|
3564
|
+
const armorCount = Math.min(amount, info.maxCount);
|
|
3565
|
+
inventory.armor = { armorType, armorCount };
|
|
3566
|
+
return inventory.armor;
|
|
3567
|
+
}
|
|
3568
|
+
function addPowerup(inventory, powerup, expiresAt) {
|
|
3569
|
+
inventory.powerups.set(powerup, expiresAt);
|
|
3570
|
+
}
|
|
3571
|
+
function hasPowerup(inventory, powerup) {
|
|
3572
|
+
return inventory.powerups.has(powerup);
|
|
3573
|
+
}
|
|
3574
|
+
function clearExpiredPowerups(inventory, nowMs) {
|
|
3575
|
+
for (const [id, expiresAt] of inventory.powerups.entries()) {
|
|
3576
|
+
if (expiresAt !== null && expiresAt <= nowMs) {
|
|
3577
|
+
inventory.powerups.delete(id);
|
|
3578
|
+
}
|
|
3579
|
+
}
|
|
3580
|
+
}
|
|
3581
|
+
function addKey(inventory, key) {
|
|
3582
|
+
const before = inventory.keys.size;
|
|
3583
|
+
inventory.keys.add(key);
|
|
3584
|
+
return inventory.keys.size > before;
|
|
3585
|
+
}
|
|
3586
|
+
function hasKey(inventory, key) {
|
|
3587
|
+
return inventory.keys.has(key);
|
|
3588
|
+
}
|
|
3430
3589
|
|
|
3431
3590
|
// src/index.ts
|
|
3432
3591
|
var ZERO_VEC32 = { x: 0, y: 0, z: 0 };
|
|
@@ -3498,6 +3657,7 @@ function createGame(engine, options) {
|
|
|
3498
3657
|
AIFlags,
|
|
3499
3658
|
AMMO_TYPE_COUNT,
|
|
3500
3659
|
ARMOR_INFO,
|
|
3660
|
+
AmmoItemId,
|
|
3501
3661
|
AmmoType,
|
|
3502
3662
|
ArmorType,
|
|
3503
3663
|
DamageFlags,
|
|
@@ -3509,8 +3669,10 @@ function createGame(engine, options) {
|
|
|
3509
3669
|
EntitySystem,
|
|
3510
3670
|
EnvironmentalFlags,
|
|
3511
3671
|
FL_NOVISIBLE,
|
|
3672
|
+
KeyId,
|
|
3512
3673
|
MoveType,
|
|
3513
3674
|
ORDERED_DAMAGE_MODS,
|
|
3675
|
+
PowerupId,
|
|
3514
3676
|
RANGE_MELEE,
|
|
3515
3677
|
RANGE_MID,
|
|
3516
3678
|
RANGE_NEAR,
|
|
@@ -3524,6 +3686,10 @@ function createGame(engine, options) {
|
|
|
3524
3686
|
T_Damage,
|
|
3525
3687
|
T_RadiusDamage,
|
|
3526
3688
|
TraceMask,
|
|
3689
|
+
WeaponId,
|
|
3690
|
+
addAmmo,
|
|
3691
|
+
addKey,
|
|
3692
|
+
addPowerup,
|
|
3527
3693
|
ai_charge,
|
|
3528
3694
|
ai_face,
|
|
3529
3695
|
ai_move,
|
|
@@ -3542,13 +3708,24 @@ function createGame(engine, options) {
|
|
|
3542
3708
|
changeYaw,
|
|
3543
3709
|
clampAmmoCounts,
|
|
3544
3710
|
classifyRange,
|
|
3711
|
+
clearExpiredPowerups,
|
|
3712
|
+
createAmmoInventory,
|
|
3545
3713
|
createBaseAmmoCaps,
|
|
3546
3714
|
createDefaultSpawnRegistry,
|
|
3547
3715
|
createGame,
|
|
3716
|
+
createPlayerInventory,
|
|
3548
3717
|
createSaveFile,
|
|
3549
3718
|
damageModName,
|
|
3719
|
+
equipArmor,
|
|
3550
3720
|
facingIdeal,
|
|
3721
|
+
getAmmoItemDefinition,
|
|
3722
|
+
giveAmmo,
|
|
3723
|
+
giveAmmoItem,
|
|
3724
|
+
giveWeapon,
|
|
3551
3725
|
hasAnyDamageFlag,
|
|
3726
|
+
hasKey,
|
|
3727
|
+
hasPowerup,
|
|
3728
|
+
hasWeapon,
|
|
3552
3729
|
hashGameState,
|
|
3553
3730
|
infront,
|
|
3554
3731
|
isZeroVector,
|
|
@@ -3556,8 +3733,10 @@ function createGame(engine, options) {
|
|
|
3556
3733
|
parseEntityLump,
|
|
3557
3734
|
parseRereleaseSave,
|
|
3558
3735
|
parseSaveFile,
|
|
3736
|
+
pickupAmmo,
|
|
3559
3737
|
rangeTo,
|
|
3560
3738
|
registerDefaultSpawns,
|
|
3739
|
+
selectWeapon,
|
|
3561
3740
|
setMovedir,
|
|
3562
3741
|
spawnEntitiesFromText,
|
|
3563
3742
|
spawnEntityFromDictionary,
|