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.
@@ -2812,11 +2812,11 @@ function hasAnyDamageFlag(flags, mask) {
2812
2812
  }
2813
2813
 
2814
2814
  // src/combat/armor.ts
2815
- var ArmorType = /* @__PURE__ */ ((ArmorType2) => {
2816
- ArmorType2["BODY"] = "body";
2817
- ArmorType2["COMBAT"] = "combat";
2818
- ArmorType2["JACKET"] = "jacket";
2819
- return ArmorType2;
2815
+ var ArmorType = /* @__PURE__ */ ((ArmorType3) => {
2816
+ ArmorType3["BODY"] = "body";
2817
+ ArmorType3["COMBAT"] = "combat";
2818
+ ArmorType3["JACKET"] = "jacket";
2819
+ return ArmorType3;
2820
2820
  })(ArmorType || {});
2821
2821
  var ARMOR_INFO = {
2822
2822
  ["jacket" /* JACKET */]: {
@@ -3305,16 +3305,39 @@ function killBox(teleporter, targets, options = {}) {
3305
3305
  }
3306
3306
 
3307
3307
  // src/inventory/ammo.ts
3308
- var AmmoType = /* @__PURE__ */ ((AmmoType2) => {
3309
- AmmoType2[AmmoType2["Bullets"] = 0] = "Bullets";
3310
- AmmoType2[AmmoType2["Shells"] = 1] = "Shells";
3311
- AmmoType2[AmmoType2["Rockets"] = 2] = "Rockets";
3312
- AmmoType2[AmmoType2["Grenades"] = 3] = "Grenades";
3313
- AmmoType2[AmmoType2["Cells"] = 4] = "Cells";
3314
- AmmoType2[AmmoType2["Slugs"] = 5] = "Slugs";
3315
- return AmmoType2;
3308
+ var AmmoType = /* @__PURE__ */ ((AmmoType3) => {
3309
+ AmmoType3[AmmoType3["Bullets"] = 0] = "Bullets";
3310
+ AmmoType3[AmmoType3["Shells"] = 1] = "Shells";
3311
+ AmmoType3[AmmoType3["Rockets"] = 2] = "Rockets";
3312
+ AmmoType3[AmmoType3["Grenades"] = 3] = "Grenades";
3313
+ AmmoType3[AmmoType3["Cells"] = 4] = "Cells";
3314
+ AmmoType3[AmmoType3["Slugs"] = 5] = "Slugs";
3315
+ return AmmoType3;
3316
3316
  })(AmmoType || {});
3317
3317
  var AMMO_TYPE_COUNT = Object.keys(AmmoType).length / 2;
3318
+ var AmmoItemId = /* @__PURE__ */ ((AmmoItemId3) => {
3319
+ AmmoItemId3["Shells"] = "ammo_shells";
3320
+ AmmoItemId3["Bullets"] = "ammo_bullets";
3321
+ AmmoItemId3["Rockets"] = "ammo_rockets";
3322
+ AmmoItemId3["Grenades"] = "ammo_grenades";
3323
+ AmmoItemId3["Cells"] = "ammo_cells";
3324
+ AmmoItemId3["Slugs"] = "ammo_slugs";
3325
+ return AmmoItemId3;
3326
+ })(AmmoItemId || {});
3327
+ var AMMO_ITEM_DEFINITIONS = {
3328
+ ["ammo_shells" /* Shells */]: { id: "ammo_shells" /* Shells */, ammoType: 1 /* Shells */, quantity: 10, weaponAmmo: false },
3329
+ ["ammo_bullets" /* Bullets */]: { id: "ammo_bullets" /* Bullets */, ammoType: 0 /* Bullets */, quantity: 50, weaponAmmo: false },
3330
+ ["ammo_rockets" /* Rockets */]: { id: "ammo_rockets" /* Rockets */, ammoType: 2 /* Rockets */, quantity: 5, weaponAmmo: false },
3331
+ ["ammo_grenades" /* Grenades */]: { id: "ammo_grenades" /* Grenades */, ammoType: 3 /* Grenades */, quantity: 5, weaponAmmo: true },
3332
+ ["ammo_cells" /* Cells */]: { id: "ammo_cells" /* Cells */, ammoType: 4 /* Cells */, quantity: 50, weaponAmmo: false },
3333
+ ["ammo_slugs" /* Slugs */]: { id: "ammo_slugs" /* Slugs */, ammoType: 5 /* Slugs */, quantity: 10, weaponAmmo: false }
3334
+ };
3335
+ function getAmmoItemDefinition(id) {
3336
+ return AMMO_ITEM_DEFINITIONS[id];
3337
+ }
3338
+ function createAmmoInventory(caps = createBaseAmmoCaps()) {
3339
+ return { caps: caps.slice(), counts: Array(AMMO_TYPE_COUNT).fill(0) };
3340
+ }
3318
3341
  function createBaseAmmoCaps() {
3319
3342
  const caps = Array(AMMO_TYPE_COUNT).fill(50);
3320
3343
  caps[0 /* Bullets */] = 200;
@@ -3333,6 +3356,122 @@ function clampAmmoCounts(counts, caps) {
3333
3356
  }
3334
3357
  return clamped;
3335
3358
  }
3359
+ function addAmmo(inventory, ammoType, amount) {
3360
+ const cap = inventory.caps[ammoType];
3361
+ const current = inventory.counts[ammoType] ?? 0;
3362
+ if (cap !== void 0 && current >= cap) {
3363
+ return { ammoType, added: 0, newCount: current, capped: cap, pickedUp: false };
3364
+ }
3365
+ const uncapped = current + amount;
3366
+ const newCount = cap === void 0 ? uncapped : Math.min(uncapped, cap);
3367
+ const added = newCount - current;
3368
+ inventory.counts[ammoType] = newCount;
3369
+ return { ammoType, added, newCount, capped: cap ?? Number.POSITIVE_INFINITY, pickedUp: added > 0 };
3370
+ }
3371
+ function pickupAmmo(inventory, itemId, options = {}) {
3372
+ const def = getAmmoItemDefinition(itemId);
3373
+ const amount = options.countOverride ?? def.quantity;
3374
+ return addAmmo(inventory, def.ammoType, amount);
3375
+ }
3376
+
3377
+ // src/inventory/playerInventory.ts
3378
+ var WeaponId = /* @__PURE__ */ ((WeaponId2) => {
3379
+ WeaponId2["Blaster"] = "blaster";
3380
+ WeaponId2["Shotgun"] = "shotgun";
3381
+ WeaponId2["SuperShotgun"] = "super_shotgun";
3382
+ WeaponId2["Machinegun"] = "machinegun";
3383
+ WeaponId2["Chaingun"] = "chaingun";
3384
+ WeaponId2["GrenadeLauncher"] = "grenade_launcher";
3385
+ WeaponId2["RocketLauncher"] = "rocket_launcher";
3386
+ WeaponId2["HyperBlaster"] = "hyperblaster";
3387
+ WeaponId2["Railgun"] = "railgun";
3388
+ WeaponId2["BFG10K"] = "bfg10k";
3389
+ return WeaponId2;
3390
+ })(WeaponId || {});
3391
+ var PowerupId = /* @__PURE__ */ ((PowerupId2) => {
3392
+ PowerupId2["QuadDamage"] = "quad";
3393
+ PowerupId2["Invulnerability"] = "invulnerability";
3394
+ PowerupId2["EnviroSuit"] = "enviro_suit";
3395
+ PowerupId2["Rebreather"] = "rebreather";
3396
+ PowerupId2["Silencer"] = "silencer";
3397
+ return PowerupId2;
3398
+ })(PowerupId || {});
3399
+ var KeyId = /* @__PURE__ */ ((KeyId2) => {
3400
+ KeyId2["Blue"] = "blue";
3401
+ KeyId2["Red"] = "red";
3402
+ KeyId2["Green"] = "green";
3403
+ KeyId2["Yellow"] = "yellow";
3404
+ return KeyId2;
3405
+ })(KeyId || {});
3406
+ function createPlayerInventory(options = {}) {
3407
+ const ammo = createAmmoInventory(options.ammoCaps);
3408
+ const ownedWeapons = new Set(options.weapons ?? []);
3409
+ const powerups = new Map(options.powerups ?? []);
3410
+ const keys = new Set(options.keys ?? []);
3411
+ return {
3412
+ ammo,
3413
+ ownedWeapons,
3414
+ currentWeapon: options.currentWeapon,
3415
+ armor: options.armor ?? null,
3416
+ powerups,
3417
+ keys
3418
+ };
3419
+ }
3420
+ function giveAmmo(inventory, ammoType, amount) {
3421
+ return addAmmo(inventory.ammo, ammoType, amount);
3422
+ }
3423
+ function giveAmmoItem(inventory, itemId, options) {
3424
+ return pickupAmmo(inventory.ammo, itemId, options);
3425
+ }
3426
+ function giveWeapon(inventory, weapon, select = false) {
3427
+ const hadWeapon = inventory.ownedWeapons.has(weapon);
3428
+ inventory.ownedWeapons.add(weapon);
3429
+ if (select || !inventory.currentWeapon) {
3430
+ inventory.currentWeapon = weapon;
3431
+ }
3432
+ return !hadWeapon;
3433
+ }
3434
+ function hasWeapon(inventory, weapon) {
3435
+ return inventory.ownedWeapons.has(weapon);
3436
+ }
3437
+ function selectWeapon(inventory, weapon) {
3438
+ if (!inventory.ownedWeapons.has(weapon)) {
3439
+ return false;
3440
+ }
3441
+ inventory.currentWeapon = weapon;
3442
+ return true;
3443
+ }
3444
+ function equipArmor(inventory, armorType, amount) {
3445
+ if (!armorType || amount <= 0) {
3446
+ inventory.armor = null;
3447
+ return null;
3448
+ }
3449
+ const info = ARMOR_INFO[armorType];
3450
+ const armorCount = Math.min(amount, info.maxCount);
3451
+ inventory.armor = { armorType, armorCount };
3452
+ return inventory.armor;
3453
+ }
3454
+ function addPowerup(inventory, powerup, expiresAt) {
3455
+ inventory.powerups.set(powerup, expiresAt);
3456
+ }
3457
+ function hasPowerup(inventory, powerup) {
3458
+ return inventory.powerups.has(powerup);
3459
+ }
3460
+ function clearExpiredPowerups(inventory, nowMs) {
3461
+ for (const [id, expiresAt] of inventory.powerups.entries()) {
3462
+ if (expiresAt !== null && expiresAt <= nowMs) {
3463
+ inventory.powerups.delete(id);
3464
+ }
3465
+ }
3466
+ }
3467
+ function addKey(inventory, key) {
3468
+ const before = inventory.keys.size;
3469
+ inventory.keys.add(key);
3470
+ return inventory.keys.size > before;
3471
+ }
3472
+ function hasKey(inventory, key) {
3473
+ return inventory.keys.has(key);
3474
+ }
3336
3475
 
3337
3476
  // src/index.ts
3338
3477
  var ZERO_VEC32 = { x: 0, y: 0, z: 0 };
@@ -3403,6 +3542,7 @@ export {
3403
3542
  AIFlags,
3404
3543
  AMMO_TYPE_COUNT,
3405
3544
  ARMOR_INFO,
3545
+ AmmoItemId,
3406
3546
  AmmoType,
3407
3547
  ArmorType,
3408
3548
  DamageFlags,
@@ -3414,8 +3554,10 @@ export {
3414
3554
  EntitySystem,
3415
3555
  EnvironmentalFlags,
3416
3556
  FL_NOVISIBLE,
3557
+ KeyId,
3417
3558
  MoveType,
3418
3559
  ORDERED_DAMAGE_MODS,
3560
+ PowerupId,
3419
3561
  RANGE_MELEE,
3420
3562
  RANGE_MID,
3421
3563
  RANGE_NEAR,
@@ -3429,6 +3571,10 @@ export {
3429
3571
  T_Damage,
3430
3572
  T_RadiusDamage,
3431
3573
  TraceMask,
3574
+ WeaponId,
3575
+ addAmmo,
3576
+ addKey,
3577
+ addPowerup,
3432
3578
  ai_charge,
3433
3579
  ai_face,
3434
3580
  ai_move,
@@ -3447,13 +3593,24 @@ export {
3447
3593
  changeYaw,
3448
3594
  clampAmmoCounts,
3449
3595
  classifyRange,
3596
+ clearExpiredPowerups,
3597
+ createAmmoInventory,
3450
3598
  createBaseAmmoCaps,
3451
3599
  createDefaultSpawnRegistry,
3452
3600
  createGame,
3601
+ createPlayerInventory,
3453
3602
  createSaveFile,
3454
3603
  damageModName,
3604
+ equipArmor,
3455
3605
  facingIdeal,
3606
+ getAmmoItemDefinition,
3607
+ giveAmmo,
3608
+ giveAmmoItem,
3609
+ giveWeapon,
3456
3610
  hasAnyDamageFlag,
3611
+ hasKey,
3612
+ hasPowerup,
3613
+ hasWeapon,
3457
3614
  hashGameState,
3458
3615
  infront,
3459
3616
  isZeroVector,
@@ -3461,8 +3618,10 @@ export {
3461
3618
  parseEntityLump,
3462
3619
  parseRereleaseSave,
3463
3620
  parseSaveFile,
3621
+ pickupAmmo,
3464
3622
  rangeTo,
3465
3623
  registerDefaultSpawns,
3624
+ selectWeapon,
3466
3625
  setMovedir,
3467
3626
  spawnEntitiesFromText,
3468
3627
  spawnEntityFromDictionary,