quake2ts 0.0.256 → 0.0.257

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.
Files changed (39) hide show
  1. package/package.json +1 -1
  2. package/packages/client/dist/browser/index.global.js +5 -5
  3. package/packages/client/dist/browser/index.global.js.map +1 -1
  4. package/packages/client/dist/cjs/index.cjs +16 -2
  5. package/packages/client/dist/cjs/index.cjs.map +1 -1
  6. package/packages/client/dist/esm/index.js +35 -21
  7. package/packages/client/dist/esm/index.js.map +1 -1
  8. package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
  9. package/packages/client/dist/types/hud/icons.d.ts.map +1 -1
  10. package/packages/client/dist/types/hud/statusbar.d.ts.map +1 -1
  11. package/packages/engine/dist/browser/index.global.js.map +1 -1
  12. package/packages/engine/dist/cjs/index.cjs.map +1 -1
  13. package/packages/engine/dist/esm/index.js.map +1 -1
  14. package/packages/game/dist/browser/index.global.js +2 -2
  15. package/packages/game/dist/browser/index.global.js.map +1 -1
  16. package/packages/game/dist/cjs/index.cjs +231 -208
  17. package/packages/game/dist/cjs/index.cjs.map +1 -1
  18. package/packages/game/dist/esm/index.js +230 -206
  19. package/packages/game/dist/esm/index.js.map +1 -1
  20. package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
  21. package/packages/game/dist/types/combat/weapons/firing.d.ts.map +1 -1
  22. package/packages/game/dist/types/combat/weapons/projectSource.d.ts +28 -0
  23. package/packages/game/dist/types/combat/weapons/projectSource.d.ts.map +1 -0
  24. package/packages/game/dist/types/combat/weapons/rogue.d.ts +4 -4
  25. package/packages/game/dist/types/combat/weapons/rogue.d.ts.map +1 -1
  26. package/packages/game/dist/types/combat/weapons/state.d.ts +6 -0
  27. package/packages/game/dist/types/combat/weapons/state.d.ts.map +1 -1
  28. package/packages/game/dist/types/entities/playerStats.d.ts.map +1 -1
  29. package/packages/game/dist/types/inventory/ammo.d.ts.map +1 -1
  30. package/packages/game/dist/types/inventory/playerInventory.d.ts +91 -38
  31. package/packages/game/dist/types/inventory/playerInventory.d.ts.map +1 -1
  32. package/packages/shared/dist/browser/index.global.js +1 -1
  33. package/packages/shared/dist/browser/index.global.js.map +1 -1
  34. package/packages/shared/dist/cjs/index.cjs +7 -2
  35. package/packages/shared/dist/cjs/index.cjs.map +1 -1
  36. package/packages/shared/dist/esm/index.js +7 -2
  37. package/packages/shared/dist/esm/index.js.map +1 -1
  38. package/packages/shared/dist/tsconfig.tsbuildinfo +1 -1
  39. package/packages/shared/dist/types/protocol/stats.d.ts.map +1 -1
@@ -765,33 +765,6 @@ function setCompressedInteger(stats, startIndex, id, count, bitsPerValue) {
765
765
  const valueToWrite = base & ~mask | count << bitShift & mask;
766
766
  writeUint16LE(stats, startIndex, byteOffset, valueToWrite & 65535);
767
767
  }
768
- var PowerupId = /* @__PURE__ */ ((PowerupId22) => {
769
- PowerupId22["QuadDamage"] = "quad";
770
- PowerupId22["Invulnerability"] = "invulnerability";
771
- PowerupId22["EnviroSuit"] = "enviro_suit";
772
- PowerupId22["Rebreather"] = "rebreather";
773
- PowerupId22["Silencer"] = "silencer";
774
- PowerupId22["PowerScreen"] = "power_screen";
775
- PowerupId22["PowerShield"] = "power_shield";
776
- PowerupId22["QuadFire"] = "quad_fire";
777
- PowerupId22["Invisibility"] = "invisibility";
778
- PowerupId22["Bandolier"] = "bandolier";
779
- PowerupId22["AmmoPack"] = "ammo_pack";
780
- PowerupId22["IRGoggles"] = "ir_goggles";
781
- PowerupId22["DoubleDamage"] = "double_damage";
782
- PowerupId22["SphereVengeance"] = "sphere_vengeance";
783
- PowerupId22["SphereHunter"] = "sphere_hunter";
784
- PowerupId22["SphereDefender"] = "sphere_defender";
785
- PowerupId22["Doppelganger"] = "doppelganger";
786
- PowerupId22["TagToken"] = "tag_token";
787
- PowerupId22["TechResistance"] = "tech_resistance";
788
- PowerupId22["TechStrength"] = "tech_strength";
789
- PowerupId22["TechHaste"] = "tech_haste";
790
- PowerupId22["TechRegeneration"] = "tech_regeneration";
791
- PowerupId22["Flashlight"] = "flashlight";
792
- PowerupId22["Compass"] = "compass";
793
- return PowerupId22;
794
- })(PowerupId || {});
795
768
  var PlayerStat = /* @__PURE__ */ ((PlayerStat2) => {
796
769
  PlayerStat2[PlayerStat2["STAT_HEALTH_ICON"] = 0] = "STAT_HEALTH_ICON";
797
770
  PlayerStat2[PlayerStat2["STAT_HEALTH"] = 1] = "STAT_HEALTH";
@@ -886,7 +859,16 @@ var POWERUP_STAT_MAP = {
886
859
  "enviro_suit"
887
860
  /* EnviroSuit */
888
861
  ]: 9,
889
- // 10 is POWERUP_ADRENALINE (not in PowerupId?)
862
+ [
863
+ "bandolier"
864
+ /* Bandolier */
865
+ ]: 10,
866
+ // Placeholder/Map mismatch handling?
867
+ [
868
+ "ammo_pack"
869
+ /* AmmoPack */
870
+ ]: 10,
871
+ // Original reused indices or had gaps?
890
872
  [
891
873
  "ir_goggles"
892
874
  /* IRGoggles */
@@ -934,7 +916,12 @@ var POWERUP_STAT_MAP = {
934
916
  [
935
917
  "tech_regeneration"
936
918
  /* TechRegeneration */
937
- ]: 22
919
+ ]: 22,
920
+ // Add missing mappings to avoid runtime lookups failing for new types
921
+ [
922
+ "tag_token"
923
+ /* TagToken */
924
+ ]: -1
938
925
  };
939
926
  function G_SetAmmoStat(stats, ammoId, count) {
940
927
  if (ammoId < 0 || ammoId >= AMMO_MAX) return;
@@ -1063,28 +1050,6 @@ var applyPmove = (state, cmd, trace, pointContents2) => {
1063
1050
  velocity: finalVelocity
1064
1051
  };
1065
1052
  };
1066
- var WeaponId = /* @__PURE__ */ ((WeaponId22) => {
1067
- WeaponId22["Blaster"] = "blaster";
1068
- WeaponId22["Shotgun"] = "shotgun";
1069
- WeaponId22["SuperShotgun"] = "super_shotgun";
1070
- WeaponId22["Machinegun"] = "machinegun";
1071
- WeaponId22["Chaingun"] = "chaingun";
1072
- WeaponId22["HandGrenade"] = "hand_grenade";
1073
- WeaponId22["GrenadeLauncher"] = "grenade_launcher";
1074
- WeaponId22["RocketLauncher"] = "rocket_launcher";
1075
- WeaponId22["HyperBlaster"] = "hyperblaster";
1076
- WeaponId22["Railgun"] = "railgun";
1077
- WeaponId22["BFG10K"] = "bfg10k";
1078
- WeaponId22["Grapple"] = "grapple";
1079
- WeaponId22["ChainFist"] = "chainfist";
1080
- WeaponId22["EtfRifle"] = "etf_rifle";
1081
- WeaponId22["ProxLauncher"] = "prox_launcher";
1082
- WeaponId22["IonRipper"] = "ionripper";
1083
- WeaponId22["PlasmaBeam"] = "plasmabeam";
1084
- WeaponId22["Phalanx"] = "phalanx";
1085
- WeaponId22["Disruptor"] = "disruptor";
1086
- return WeaponId22;
1087
- })(WeaponId || {});
1088
1053
  var AmmoType = /* @__PURE__ */ ((AmmoType22) => {
1089
1054
  AmmoType22[AmmoType22["Bullets"] = 0] = "Bullets";
1090
1055
  AmmoType22[AmmoType22["Shells"] = 1] = "Shells";
@@ -1119,6 +1084,75 @@ var AmmoItemId = /* @__PURE__ */ ((AmmoItemId22) => {
1119
1084
  return AmmoItemId22;
1120
1085
  })(AmmoItemId || {});
1121
1086
 
1087
+ // src/inventory/ammo.ts
1088
+ var AMMO_ITEM_DEFINITIONS = {
1089
+ [AmmoItemId.Shells]: { id: AmmoItemId.Shells, ammoType: AmmoType.Shells, quantity: 10, weaponAmmo: false },
1090
+ [AmmoItemId.Bullets]: { id: AmmoItemId.Bullets, ammoType: AmmoType.Bullets, quantity: 50, weaponAmmo: false },
1091
+ [AmmoItemId.Rockets]: { id: AmmoItemId.Rockets, ammoType: AmmoType.Rockets, quantity: 5, weaponAmmo: false },
1092
+ [AmmoItemId.Grenades]: { id: AmmoItemId.Grenades, ammoType: AmmoType.Grenades, quantity: 5, weaponAmmo: true },
1093
+ [AmmoItemId.Cells]: { id: AmmoItemId.Cells, ammoType: AmmoType.Cells, quantity: 50, weaponAmmo: false },
1094
+ [AmmoItemId.Slugs]: { id: AmmoItemId.Slugs, ammoType: AmmoType.Slugs, quantity: 10, weaponAmmo: false },
1095
+ [AmmoItemId.MagSlugs]: { id: AmmoItemId.MagSlugs, ammoType: AmmoType.MagSlugs, quantity: 10, weaponAmmo: false },
1096
+ [AmmoItemId.Flechettes]: { id: AmmoItemId.Flechettes, ammoType: AmmoType.Flechettes, quantity: 50, weaponAmmo: false },
1097
+ [AmmoItemId.Disruptor]: { id: AmmoItemId.Disruptor, ammoType: AmmoType.Disruptor, quantity: 15, weaponAmmo: false },
1098
+ [AmmoItemId.Tesla]: { id: AmmoItemId.Tesla, ammoType: AmmoType.Tesla, quantity: 5, weaponAmmo: false },
1099
+ [AmmoItemId.Trap]: { id: AmmoItemId.Trap, ammoType: AmmoType.Trap, quantity: 5, weaponAmmo: false },
1100
+ [AmmoItemId.Prox]: { id: AmmoItemId.Prox, ammoType: AmmoType.Prox, quantity: 5, weaponAmmo: false }
1101
+ };
1102
+ function getAmmoItemDefinition(id) {
1103
+ return AMMO_ITEM_DEFINITIONS[id];
1104
+ }
1105
+ function createAmmoInventory(caps = createBaseAmmoCaps(), seed) {
1106
+ const counts = Array(AMMO_TYPE_COUNT).fill(0);
1107
+ if (seed) {
1108
+ for (const [ammoType, count] of Object.entries(seed)) {
1109
+ counts[Number(ammoType)] = count;
1110
+ }
1111
+ }
1112
+ return { caps: caps.slice(), counts };
1113
+ }
1114
+ function createBaseAmmoCaps() {
1115
+ const caps = Array(AMMO_TYPE_COUNT).fill(50);
1116
+ caps[AmmoType.Bullets] = 200;
1117
+ caps[AmmoType.Shells] = 100;
1118
+ caps[AmmoType.Cells] = 200;
1119
+ caps[AmmoType.MagSlugs] = 50;
1120
+ caps[AmmoType.Flechettes] = 200;
1121
+ caps[AmmoType.Disruptor] = 200;
1122
+ caps[AmmoType.Tesla] = 50;
1123
+ caps[AmmoType.Trap] = 50;
1124
+ caps[AmmoType.Prox] = 50;
1125
+ return caps;
1126
+ }
1127
+ function clampAmmoCounts(counts, caps) {
1128
+ const limit = Math.min(counts.length, caps.length);
1129
+ const clamped = counts.slice(0, limit);
1130
+ for (let i = 0; i < limit; i++) {
1131
+ const cap = caps[i];
1132
+ if (cap !== void 0) {
1133
+ clamped[i] = Math.min(counts[i], cap);
1134
+ }
1135
+ }
1136
+ return clamped;
1137
+ }
1138
+ function addAmmo(inventory, ammoType, amount) {
1139
+ const cap = inventory.caps[ammoType];
1140
+ const current = inventory.counts[ammoType] ?? 0;
1141
+ if (cap !== void 0 && current >= cap) {
1142
+ return { ammoType, added: 0, newCount: current, capped: cap, pickedUp: false };
1143
+ }
1144
+ const uncapped = current + amount;
1145
+ const newCount = cap === void 0 ? uncapped : Math.min(uncapped, cap);
1146
+ const added = newCount - current;
1147
+ inventory.counts[ammoType] = newCount;
1148
+ return { ammoType, added, newCount, capped: cap ?? Number.POSITIVE_INFINITY, pickedUp: added > 0 };
1149
+ }
1150
+ function pickupAmmo(inventory, itemId, options = {}) {
1151
+ const def = getAmmoItemDefinition(itemId);
1152
+ const amount = options.countOverride ?? def.quantity;
1153
+ return addAmmo(inventory, def.ammoType, amount);
1154
+ }
1155
+
1122
1156
  // src/combat/damageFlags.ts
1123
1157
  var DamageFlags = /* @__PURE__ */ ((DamageFlags2) => {
1124
1158
  DamageFlags2[DamageFlags2["NONE"] = 0] = "NONE";
@@ -1230,119 +1264,103 @@ function applyPowerArmor(damage, flags, hitPoint, _hitNormal, state, options = {
1230
1264
  return { saved, remainingCells };
1231
1265
  }
1232
1266
 
1233
- // src/inventory/ammo.ts
1234
- var AMMO_ITEM_DEFINITIONS = {
1235
- [AmmoItemId.Shells]: { id: AmmoItemId.Shells, ammoType: AmmoType.Shells, quantity: 10, weaponAmmo: false },
1236
- [AmmoItemId.Bullets]: { id: AmmoItemId.Bullets, ammoType: AmmoType.Bullets, quantity: 50, weaponAmmo: false },
1237
- [AmmoItemId.Rockets]: { id: AmmoItemId.Rockets, ammoType: AmmoType.Rockets, quantity: 5, weaponAmmo: false },
1238
- [AmmoItemId.Grenades]: { id: AmmoItemId.Grenades, ammoType: AmmoType.Grenades, quantity: 5, weaponAmmo: true },
1239
- [AmmoItemId.Cells]: { id: AmmoItemId.Cells, ammoType: AmmoType.Cells, quantity: 50, weaponAmmo: false },
1240
- [AmmoItemId.Slugs]: { id: AmmoItemId.Slugs, ammoType: AmmoType.Slugs, quantity: 10, weaponAmmo: false },
1241
- [AmmoItemId.MagSlugs]: { id: AmmoItemId.MagSlugs, ammoType: AmmoType.MagSlugs, quantity: 10, weaponAmmo: false },
1242
- [AmmoItemId.Flechettes]: { id: AmmoItemId.Flechettes, ammoType: AmmoType.Flechettes, quantity: 50, weaponAmmo: false },
1243
- [AmmoItemId.Disruptor]: { id: AmmoItemId.Disruptor, ammoType: AmmoType.Disruptor, quantity: 15, weaponAmmo: false },
1244
- [AmmoItemId.Tesla]: { id: AmmoItemId.Tesla, ammoType: AmmoType.Tesla, quantity: 5, weaponAmmo: false },
1245
- [AmmoItemId.Trap]: { id: AmmoItemId.Trap, ammoType: AmmoType.Trap, quantity: 5, weaponAmmo: false },
1246
- [AmmoItemId.Prox]: { id: AmmoItemId.Prox, ammoType: AmmoType.Prox, quantity: 5, weaponAmmo: false }
1247
- };
1248
- function getAmmoItemDefinition(id) {
1249
- return AMMO_ITEM_DEFINITIONS[id];
1250
- }
1251
- function createAmmoInventory(caps = createBaseAmmoCaps(), seed) {
1252
- const counts = Array(AMMO_TYPE_COUNT).fill(0);
1253
- if (seed) {
1254
- for (const [ammoType, count] of Object.entries(seed)) {
1255
- counts[Number(ammoType)] = count;
1256
- }
1257
- }
1258
- return { caps: caps.slice(), counts };
1259
- }
1260
- function createBaseAmmoCaps() {
1261
- const caps = Array(AMMO_TYPE_COUNT).fill(50);
1262
- caps[AmmoType.Bullets] = 200;
1263
- caps[AmmoType.Shells] = 100;
1264
- caps[AmmoType.Cells] = 200;
1265
- caps[AmmoType.MagSlugs] = 50;
1266
- caps[AmmoType.Flechettes] = 200;
1267
- caps[AmmoType.Disruptor] = 200;
1268
- caps[AmmoType.Tesla] = 50;
1269
- caps[AmmoType.Trap] = 50;
1270
- caps[AmmoType.Prox] = 50;
1271
- return caps;
1272
- }
1273
- function clampAmmoCounts(counts, caps) {
1274
- const limit = Math.min(counts.length, caps.length);
1275
- const clamped = counts.slice(0, limit);
1276
- for (let i = 0; i < limit; i++) {
1277
- const cap = caps[i];
1278
- if (cap !== void 0) {
1279
- clamped[i] = Math.min(counts[i], cap);
1280
- }
1281
- }
1282
- return clamped;
1283
- }
1284
- function addAmmo(inventory, ammoType, amount) {
1285
- const cap = inventory.caps[ammoType];
1286
- const current = inventory.counts[ammoType] ?? 0;
1287
- if (cap !== void 0 && current >= cap) {
1288
- return { ammoType, added: 0, newCount: current, capped: cap, pickedUp: false };
1289
- }
1290
- const uncapped = current + amount;
1291
- const newCount = cap === void 0 ? uncapped : Math.min(uncapped, cap);
1292
- const added = newCount - current;
1293
- inventory.counts[ammoType] = newCount;
1294
- return { ammoType, added, newCount, capped: cap ?? Number.POSITIVE_INFINITY, pickedUp: added > 0 };
1295
- }
1296
- function pickupAmmo(inventory, itemId, options = {}) {
1297
- const def = getAmmoItemDefinition(itemId);
1298
- const amount = options.countOverride ?? def.quantity;
1299
- return addAmmo(inventory, def.ammoType, amount);
1300
- }
1301
-
1302
1267
  // src/inventory/playerInventory.ts
1268
+ var WeaponId = /* @__PURE__ */ ((WeaponId3) => {
1269
+ WeaponId3["Blaster"] = "blaster";
1270
+ WeaponId3["Shotgun"] = "shotgun";
1271
+ WeaponId3["SuperShotgun"] = "supershotgun";
1272
+ WeaponId3["Machinegun"] = "machinegun";
1273
+ WeaponId3["Chaingun"] = "chaingun";
1274
+ WeaponId3["GrenadeLauncher"] = "grenadelauncher";
1275
+ WeaponId3["RocketLauncher"] = "rocketlauncher";
1276
+ WeaponId3["HyperBlaster"] = "hyperblaster";
1277
+ WeaponId3["Railgun"] = "railgun";
1278
+ WeaponId3["BFG10K"] = "bfg10k";
1279
+ WeaponId3["HandGrenade"] = "grenades";
1280
+ WeaponId3["Grapple"] = "grapple";
1281
+ WeaponId3["IonRipper"] = "ionripper";
1282
+ WeaponId3["Phalanx"] = "phalanx";
1283
+ WeaponId3["Trap"] = "trap";
1284
+ WeaponId3["PlasmaBeam"] = "plasmabeam";
1285
+ WeaponId3["EtfRifle"] = "etfrifle";
1286
+ WeaponId3["ProxLauncher"] = "proxlauncher";
1287
+ WeaponId3["ChainFist"] = "chainfist";
1288
+ WeaponId3["Disruptor"] = "disruptor";
1289
+ return WeaponId3;
1290
+ })(WeaponId || {});
1291
+ var PowerupId = /* @__PURE__ */ ((PowerupId3) => {
1292
+ PowerupId3["QuadDamage"] = "quad";
1293
+ PowerupId3["Invulnerability"] = "invulnerability";
1294
+ PowerupId3["Silencer"] = "silencer";
1295
+ PowerupId3["Rebreather"] = "rebreather";
1296
+ PowerupId3["EnviroSuit"] = "enviro";
1297
+ PowerupId3["DoubleDamage"] = "double";
1298
+ PowerupId3["QuadFire"] = "quadfire";
1299
+ PowerupId3["Invisibility"] = "invisibility";
1300
+ PowerupId3["Bandolier"] = "bandolier";
1301
+ PowerupId3["AmmoPack"] = "pack";
1302
+ PowerupId3["IRGoggles"] = "goggles";
1303
+ PowerupId3["SphereVengeance"] = "vengeance";
1304
+ PowerupId3["SphereHunter"] = "hunter";
1305
+ PowerupId3["SphereDefender"] = "defender";
1306
+ PowerupId3["Doppelganger"] = "doppelganger";
1307
+ PowerupId3["TagToken"] = "tagtoken";
1308
+ PowerupId3["TechResistance"] = "tech_resistance";
1309
+ PowerupId3["TechStrength"] = "tech_strength";
1310
+ PowerupId3["TechHaste"] = "tech_haste";
1311
+ PowerupId3["TechRegeneration"] = "tech_regeneration";
1312
+ PowerupId3["Flashlight"] = "flashlight";
1313
+ PowerupId3["Compass"] = "compass";
1314
+ return PowerupId3;
1315
+ })(PowerupId || {});
1303
1316
  var KeyId = /* @__PURE__ */ ((KeyId2) => {
1304
- KeyId2["Blue"] = "blue";
1305
- KeyId2["Red"] = "red";
1306
- KeyId2["Green"] = "green";
1307
- KeyId2["Yellow"] = "yellow";
1308
- KeyId2["DataCD"] = "data_cd";
1309
- KeyId2["PowerCube"] = "power_cube";
1310
- KeyId2["ExplosiveCharges"] = "explosive_charges";
1311
- KeyId2["PowerCore"] = "power_core";
1312
- KeyId2["Pyramid"] = "pyramid";
1313
- KeyId2["DataSpinner"] = "data_spinner";
1314
- KeyId2["Pass"] = "pass";
1315
- KeyId2["CommanderHead"] = "commander_head";
1316
- KeyId2["Airstrike"] = "airstrike";
1317
- KeyId2["NukeContainer"] = "nuke_container";
1318
- KeyId2["Nuke"] = "nuke";
1319
- KeyId2["RedFlag"] = "red_flag";
1320
- KeyId2["BlueFlag"] = "blue_flag";
1317
+ KeyId2["Blue"] = "key_blue";
1318
+ KeyId2["Red"] = "key_red";
1319
+ KeyId2["Green"] = "key_green";
1320
+ KeyId2["Yellow"] = "key_yellow";
1321
+ KeyId2["DataCD"] = "key_data_cd";
1322
+ KeyId2["PowerCube"] = "key_power_cube";
1323
+ KeyId2["ExplosiveCharges"] = "key_explosive_charges";
1324
+ KeyId2["PowerCore"] = "key_power_core";
1325
+ KeyId2["Pyramid"] = "key_pyramid";
1326
+ KeyId2["DataSpinner"] = "key_data_spinner";
1327
+ KeyId2["Pass"] = "key_pass";
1328
+ KeyId2["CommanderHead"] = "key_commander_head";
1329
+ KeyId2["Airstrike"] = "key_airstrike";
1330
+ KeyId2["NukeContainer"] = "key_nuke_container";
1331
+ KeyId2["Nuke"] = "key_nuke";
1332
+ KeyId2["RedFlag"] = "key_red_flag";
1333
+ KeyId2["BlueFlag"] = "key_blue_flag";
1321
1334
  return KeyId2;
1322
1335
  })(KeyId || {});
1323
- function createPlayerInventory(options = {}) {
1324
- const ammo = createAmmoInventory(options.ammoCaps, options.ammo);
1325
- const ownedWeapons = new Set(options.weapons ?? []);
1326
- const powerups = new Map(options.powerups ?? []);
1327
- const keys = new Set(options.keys ?? []);
1328
- const items = new Set(options.items ?? []);
1329
- return {
1330
- ammo,
1331
- ownedWeapons,
1332
- currentWeapon: options.currentWeapon,
1333
- armor: options.armor ?? null,
1334
- powerups,
1335
- keys,
1336
- items
1337
- };
1336
+ function createPlayerInventory(init = {}) {
1337
+ const ammoCaps = init.ammoCaps;
1338
+ const inv = {
1339
+ ammo: createAmmoInventory(ammoCaps),
1340
+ ownedWeapons: new Set(init.weapons ?? ["blaster" /* Blaster */]),
1341
+ armor: null,
1342
+ powerups: /* @__PURE__ */ new Map(),
1343
+ keys: /* @__PURE__ */ new Set(),
1344
+ items: /* @__PURE__ */ new Set()
1345
+ };
1346
+ if (init.ammo) {
1347
+ for (const [type, count] of Object.entries(init.ammo)) {
1348
+ inv.ammo.counts[Number(type)] = count;
1349
+ }
1350
+ }
1351
+ if (init.currentWeapon) {
1352
+ inv.currentWeapon = init.currentWeapon;
1353
+ } else if (inv.ownedWeapons.size > 0) {
1354
+ if (inv.ownedWeapons.has("blaster" /* Blaster */)) inv.currentWeapon = "blaster" /* Blaster */;
1355
+ else if (inv.ownedWeapons.has("shotgun" /* Shotgun */)) inv.currentWeapon = "shotgun" /* Shotgun */;
1356
+ else inv.currentWeapon = [...inv.ownedWeapons][0];
1357
+ }
1358
+ return inv;
1338
1359
  }
1339
1360
  function setPickup(inventory, item, time) {
1340
1361
  inventory.pickupItem = item;
1341
1362
  inventory.pickupTime = time;
1342
1363
  }
1343
- function giveAmmo(inventory, ammoType, amount) {
1344
- return addAmmo(inventory.ammo, ammoType, amount);
1345
- }
1346
1364
  function giveAmmoItem(inventory, itemId, options) {
1347
1365
  return pickupAmmo(inventory.ammo, itemId, options);
1348
1366
  }
@@ -1463,27 +1481,27 @@ function pickupPowerup(client, item, time) {
1463
1481
  let icon = "";
1464
1482
  switch (item.id) {
1465
1483
  case "item_quad":
1466
- powerupId = PowerupId.QuadDamage;
1484
+ powerupId = "quad" /* QuadDamage */;
1467
1485
  icon = "p_quad";
1468
1486
  break;
1469
1487
  case "item_invulnerability":
1470
- powerupId = PowerupId.Invulnerability;
1488
+ powerupId = "invulnerability" /* Invulnerability */;
1471
1489
  icon = "p_invulnerability";
1472
1490
  break;
1473
1491
  case "item_silencer":
1474
- powerupId = PowerupId.Silencer;
1492
+ powerupId = "silencer" /* Silencer */;
1475
1493
  icon = "p_silencer";
1476
1494
  break;
1477
1495
  case "item_rebreather":
1478
- powerupId = PowerupId.Rebreather;
1496
+ powerupId = "rebreather" /* Rebreather */;
1479
1497
  icon = "p_rebreather";
1480
1498
  break;
1481
1499
  case "item_enviro":
1482
- powerupId = PowerupId.EnviroSuit;
1500
+ powerupId = "enviro" /* EnviroSuit */;
1483
1501
  icon = "p_envirosuit";
1484
1502
  break;
1485
1503
  case "item_double":
1486
- powerupId = PowerupId.DoubleDamage;
1504
+ powerupId = "double" /* DoubleDamage */;
1487
1505
  icon = "p_double";
1488
1506
  break;
1489
1507
  }
@@ -1491,9 +1509,9 @@ function pickupPowerup(client, item, time) {
1491
1509
  const expiresAt = inventory.powerups.get(powerupId);
1492
1510
  const newExpiresAt = expiresAt && expiresAt > time ? expiresAt + item.timer * 1e3 : time + item.timer * 1e3;
1493
1511
  inventory.powerups.set(powerupId, newExpiresAt);
1494
- if (powerupId === PowerupId.QuadDamage) {
1512
+ if (powerupId === "quad" /* QuadDamage */) {
1495
1513
  client.quad_time = newExpiresAt / 1e3;
1496
- } else if (powerupId === PowerupId.DoubleDamage) {
1514
+ } else if (powerupId === "double" /* DoubleDamage */) {
1497
1515
  client.double_time = newExpiresAt / 1e3;
1498
1516
  }
1499
1517
  setPickup(inventory, icon, time);
@@ -1521,19 +1539,19 @@ function pickupKey(inventory, item, time) {
1521
1539
  let icon = "";
1522
1540
  switch (item.id) {
1523
1541
  case "key_blue":
1524
- keyId = "blue" /* Blue */;
1542
+ keyId = "key_blue" /* Blue */;
1525
1543
  icon = "k_bluekey";
1526
1544
  break;
1527
1545
  case "key_red":
1528
- keyId = "red" /* Red */;
1546
+ keyId = "key_red" /* Red */;
1529
1547
  icon = "k_redkey";
1530
1548
  break;
1531
1549
  case "key_green":
1532
- keyId = "green" /* Green */;
1550
+ keyId = "key_green" /* Green */;
1533
1551
  icon = "k_security";
1534
1552
  break;
1535
1553
  case "key_yellow":
1536
- keyId = "yellow" /* Yellow */;
1554
+ keyId = "key_yellow" /* Yellow */;
1537
1555
  icon = "k_pyramid";
1538
1556
  break;
1539
1557
  }
@@ -4261,6 +4279,13 @@ function registerTriggerSpawns(registry) {
4261
4279
  }
4262
4280
 
4263
4281
  // src/combat/weapons/state.ts
4282
+ var WeaponStateEnum = /* @__PURE__ */ ((WeaponStateEnum2) => {
4283
+ WeaponStateEnum2[WeaponStateEnum2["WEAPON_READY"] = 0] = "WEAPON_READY";
4284
+ WeaponStateEnum2[WeaponStateEnum2["WEAPON_ACTIVATING"] = 1] = "WEAPON_ACTIVATING";
4285
+ WeaponStateEnum2[WeaponStateEnum2["WEAPON_DROPPING"] = 2] = "WEAPON_DROPPING";
4286
+ WeaponStateEnum2[WeaponStateEnum2["WEAPON_FIRING"] = 3] = "WEAPON_FIRING";
4287
+ return WeaponStateEnum2;
4288
+ })(WeaponStateEnum || {});
4264
4289
  function createPlayerWeaponStates() {
4265
4290
  return {
4266
4291
  states: /* @__PURE__ */ new Map()
@@ -4283,7 +4308,7 @@ function chaingunThink(player, sys) {
4283
4308
  if (!player.client) {
4284
4309
  return;
4285
4310
  }
4286
- const weaponState = getWeaponState(player.client.weaponStates, WeaponId.Chaingun);
4311
+ const weaponState = getWeaponState(player.client.weaponStates, "chaingun" /* Chaingun */);
4287
4312
  if (!(player.client.buttons & BUTTON_ATTACK) && weaponState.spinupCount && weaponState.spinupCount > 0) {
4288
4313
  sys.sound(player, 0, "weapons/chngnd1a.wav", 1, 0, 0);
4289
4314
  weaponState.spinupCount = 0;
@@ -4296,7 +4321,7 @@ var WEAPON_ITEMS = {
4296
4321
  type: "weapon",
4297
4322
  id: "weapon_blaster",
4298
4323
  name: "Blaster",
4299
- weaponId: WeaponId.Blaster,
4324
+ weaponId: "blaster" /* Blaster */,
4300
4325
  ammoType: null,
4301
4326
  initialAmmo: 0,
4302
4327
  pickupAmmo: 0,
@@ -4306,7 +4331,7 @@ var WEAPON_ITEMS = {
4306
4331
  type: "weapon",
4307
4332
  id: "weapon_shotgun",
4308
4333
  name: "Shotgun",
4309
- weaponId: WeaponId.Shotgun,
4334
+ weaponId: "shotgun" /* Shotgun */,
4310
4335
  ammoType: AmmoType.Shells,
4311
4336
  initialAmmo: 10,
4312
4337
  pickupAmmo: 10,
@@ -4316,7 +4341,7 @@ var WEAPON_ITEMS = {
4316
4341
  type: "weapon",
4317
4342
  id: "weapon_supershotgun",
4318
4343
  name: "Super Shotgun",
4319
- weaponId: WeaponId.SuperShotgun,
4344
+ weaponId: "supershotgun" /* SuperShotgun */,
4320
4345
  ammoType: AmmoType.Shells,
4321
4346
  initialAmmo: 10,
4322
4347
  pickupAmmo: 10,
@@ -4326,7 +4351,7 @@ var WEAPON_ITEMS = {
4326
4351
  type: "weapon",
4327
4352
  id: "weapon_machinegun",
4328
4353
  name: "Machinegun",
4329
- weaponId: WeaponId.Machinegun,
4354
+ weaponId: "machinegun" /* Machinegun */,
4330
4355
  ammoType: AmmoType.Bullets,
4331
4356
  initialAmmo: 50,
4332
4357
  pickupAmmo: 50,
@@ -4337,7 +4362,7 @@ var WEAPON_ITEMS = {
4337
4362
  type: "weapon",
4338
4363
  id: "weapon_chaingun",
4339
4364
  name: "Chaingun",
4340
- weaponId: WeaponId.Chaingun,
4365
+ weaponId: "chaingun" /* Chaingun */,
4341
4366
  ammoType: AmmoType.Bullets,
4342
4367
  initialAmmo: 50,
4343
4368
  pickupAmmo: 50,
@@ -4347,7 +4372,7 @@ var WEAPON_ITEMS = {
4347
4372
  type: "weapon",
4348
4373
  id: "weapon_grenades",
4349
4374
  name: "Hand Grenade",
4350
- weaponId: WeaponId.HandGrenade,
4375
+ weaponId: "grenades" /* HandGrenade */,
4351
4376
  ammoType: AmmoType.Grenades,
4352
4377
  initialAmmo: 5,
4353
4378
  pickupAmmo: 5,
@@ -4357,7 +4382,7 @@ var WEAPON_ITEMS = {
4357
4382
  type: "weapon",
4358
4383
  id: "weapon_grenadelauncher",
4359
4384
  name: "Grenade Launcher",
4360
- weaponId: WeaponId.GrenadeLauncher,
4385
+ weaponId: "grenadelauncher" /* GrenadeLauncher */,
4361
4386
  ammoType: AmmoType.Grenades,
4362
4387
  initialAmmo: 10,
4363
4388
  pickupAmmo: 10,
@@ -4367,7 +4392,7 @@ var WEAPON_ITEMS = {
4367
4392
  type: "weapon",
4368
4393
  id: "weapon_rocketlauncher",
4369
4394
  name: "Rocket Launcher",
4370
- weaponId: WeaponId.RocketLauncher,
4395
+ weaponId: "rocketlauncher" /* RocketLauncher */,
4371
4396
  ammoType: AmmoType.Rockets,
4372
4397
  initialAmmo: 5,
4373
4398
  pickupAmmo: 5,
@@ -4377,7 +4402,7 @@ var WEAPON_ITEMS = {
4377
4402
  type: "weapon",
4378
4403
  id: "weapon_hyperblaster",
4379
4404
  name: "HyperBlaster",
4380
- weaponId: WeaponId.HyperBlaster,
4405
+ weaponId: "hyperblaster" /* HyperBlaster */,
4381
4406
  ammoType: AmmoType.Cells,
4382
4407
  initialAmmo: 50,
4383
4408
  pickupAmmo: 50,
@@ -4387,7 +4412,7 @@ var WEAPON_ITEMS = {
4387
4412
  type: "weapon",
4388
4413
  id: "weapon_railgun",
4389
4414
  name: "Railgun",
4390
- weaponId: WeaponId.Railgun,
4415
+ weaponId: "railgun" /* Railgun */,
4391
4416
  ammoType: AmmoType.Slugs,
4392
4417
  initialAmmo: 10,
4393
4418
  pickupAmmo: 10,
@@ -4397,7 +4422,7 @@ var WEAPON_ITEMS = {
4397
4422
  type: "weapon",
4398
4423
  id: "weapon_bfg",
4399
4424
  name: "BFG10K",
4400
- weaponId: WeaponId.BFG10K,
4425
+ weaponId: "bfg10k" /* BFG10K */,
4401
4426
  ammoType: AmmoType.Cells,
4402
4427
  initialAmmo: 50,
4403
4428
  pickupAmmo: 50,
@@ -4409,7 +4434,7 @@ var WEAPON_ITEMS = {
4409
4434
  id: "weapon_boomer",
4410
4435
  // Ion Ripper
4411
4436
  name: "Ion Ripper",
4412
- weaponId: WeaponId.IonRipper,
4437
+ weaponId: "ionripper" /* IonRipper */,
4413
4438
  ammoType: AmmoType.Cells,
4414
4439
  initialAmmo: 50,
4415
4440
  pickupAmmo: 50,
@@ -4419,7 +4444,7 @@ var WEAPON_ITEMS = {
4419
4444
  type: "weapon",
4420
4445
  id: "weapon_phalanx",
4421
4446
  name: "Phalanx",
4422
- weaponId: WeaponId.Phalanx,
4447
+ weaponId: "phalanx" /* Phalanx */,
4423
4448
  ammoType: AmmoType.MagSlugs,
4424
4449
  initialAmmo: 50,
4425
4450
  pickupAmmo: 50,
@@ -4429,7 +4454,7 @@ var WEAPON_ITEMS = {
4429
4454
  type: "weapon",
4430
4455
  id: "weapon_beam",
4431
4456
  name: "Plasma Beam",
4432
- weaponId: WeaponId.PlasmaBeam,
4457
+ weaponId: "plasmabeam" /* PlasmaBeam */,
4433
4458
  ammoType: AmmoType.Cells,
4434
4459
  initialAmmo: 50,
4435
4460
  pickupAmmo: 50,
@@ -4439,7 +4464,7 @@ var WEAPON_ITEMS = {
4439
4464
  type: "weapon",
4440
4465
  id: "weapon_etf_rifle",
4441
4466
  name: "ETF Rifle",
4442
- weaponId: WeaponId.EtfRifle,
4467
+ weaponId: "etfrifle" /* EtfRifle */,
4443
4468
  ammoType: AmmoType.Flechettes,
4444
4469
  initialAmmo: 50,
4445
4470
  pickupAmmo: 50,
@@ -4449,7 +4474,7 @@ var WEAPON_ITEMS = {
4449
4474
  type: "weapon",
4450
4475
  id: "weapon_proxlauncher",
4451
4476
  name: "Prox Launcher",
4452
- weaponId: WeaponId.ProxLauncher,
4477
+ weaponId: "proxlauncher" /* ProxLauncher */,
4453
4478
  ammoType: AmmoType.Prox,
4454
4479
  initialAmmo: 5,
4455
4480
  pickupAmmo: 5,
@@ -13620,24 +13645,24 @@ function player_think(self, sys) {
13620
13645
 
13621
13646
  // src/entities/playerStats.ts
13622
13647
  var WEAPON_WHEEL_ORDER = [
13623
- WeaponId.Blaster,
13624
- WeaponId.Shotgun,
13625
- WeaponId.SuperShotgun,
13626
- WeaponId.Machinegun,
13627
- WeaponId.Chaingun,
13628
- WeaponId.GrenadeLauncher,
13629
- WeaponId.RocketLauncher,
13630
- WeaponId.HandGrenade,
13631
- WeaponId.HyperBlaster,
13632
- WeaponId.Railgun,
13633
- WeaponId.BFG10K
13648
+ "blaster" /* Blaster */,
13649
+ "shotgun" /* Shotgun */,
13650
+ "supershotgun" /* SuperShotgun */,
13651
+ "machinegun" /* Machinegun */,
13652
+ "chaingun" /* Chaingun */,
13653
+ "grenadelauncher" /* GrenadeLauncher */,
13654
+ "rocketlauncher" /* RocketLauncher */,
13655
+ "grenades" /* HandGrenade */,
13656
+ "hyperblaster" /* HyperBlaster */,
13657
+ "railgun" /* Railgun */,
13658
+ "bfg10k" /* BFG10K */
13634
13659
  ];
13635
13660
  var POWERUP_TIMERS = [
13636
- { id: PowerupId.QuadDamage, priority: 1 },
13637
- { id: PowerupId.Invulnerability, priority: 2 },
13638
- { id: PowerupId.EnviroSuit, priority: 3 },
13639
- { id: PowerupId.Rebreather, priority: 4 },
13640
- { id: PowerupId.Silencer, priority: 5 }
13661
+ { id: "quad" /* QuadDamage */, priority: 1 },
13662
+ { id: "invulnerability" /* Invulnerability */, priority: 2 },
13663
+ { id: "enviro" /* EnviroSuit */, priority: 3 },
13664
+ { id: "rebreather" /* Rebreather */, priority: 4 },
13665
+ { id: "silencer" /* Silencer */, priority: 5 }
13641
13666
  ];
13642
13667
  function populatePlayerStats(player, timeSeconds) {
13643
13668
  if (!player.client) return [];
@@ -14035,20 +14060,20 @@ function createGame(imports, engine, options) {
14035
14060
  const blend = [0, 0, 0, 0];
14036
14061
  if (!player || !player.client) return blend;
14037
14062
  const inventory = player.client.inventory;
14038
- if (inventory.powerups.has(PowerupId.QuadDamage)) {
14063
+ if (inventory.powerups.has("quad" /* QuadDamage */)) {
14039
14064
  blend[2] = 1;
14040
14065
  blend[3] = 0.08;
14041
14066
  }
14042
- if (inventory.powerups.has(PowerupId.Invulnerability)) {
14067
+ if (inventory.powerups.has("invulnerability" /* Invulnerability */)) {
14043
14068
  blend[0] = 1;
14044
14069
  blend[1] = 1;
14045
14070
  blend[3] = 0.08;
14046
14071
  }
14047
- if (inventory.powerups.has(PowerupId.EnviroSuit)) {
14072
+ if (inventory.powerups.has("enviro" /* EnviroSuit */)) {
14048
14073
  blend[1] = 1;
14049
14074
  blend[3] = 0.08;
14050
14075
  }
14051
- if (inventory.powerups.has(PowerupId.Rebreather)) {
14076
+ if (inventory.powerups.has("rebreather" /* Rebreather */)) {
14052
14077
  blend[0] = 0.4;
14053
14078
  blend[1] = 1;
14054
14079
  blend[2] = 0.4;
@@ -14352,6 +14377,7 @@ export {
14352
14377
  WEAPONS,
14353
14378
  WEAPON_ITEMS,
14354
14379
  WeaponId,
14380
+ WeaponStateEnum,
14355
14381
  WeaponType,
14356
14382
  addAmmo,
14357
14383
  addKey,
@@ -14402,7 +14428,6 @@ export {
14402
14428
  foundTarget,
14403
14429
  getAmmoItemDefinition,
14404
14430
  getWeaponState,
14405
- giveAmmo,
14406
14431
  giveAmmoItem,
14407
14432
  giveWeapon,
14408
14433
  hasAnyDamageFlag,
@@ -14434,7 +14459,6 @@ export {
14434
14459
  serializePlayerInventory,
14435
14460
  serializeRereleaseSave,
14436
14461
  setMovedir,
14437
- setPickup,
14438
14462
  spawnEntitiesFromText,
14439
14463
  spawnEntityFromDictionary,
14440
14464
  summarizeRereleaseSave,