quake2ts 0.0.198 → 0.0.200

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 (29) hide show
  1. package/package.json +1 -1
  2. package/packages/client/dist/browser/index.global.js +13 -13
  3. package/packages/client/dist/browser/index.global.js.map +1 -1
  4. package/packages/client/dist/cjs/index.cjs +88 -28
  5. package/packages/client/dist/cjs/index.cjs.map +1 -1
  6. package/packages/client/dist/esm/index.js +88 -28
  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/cgameBridge.d.ts +12 -1
  10. package/packages/client/dist/types/cgameBridge.d.ts.map +1 -1
  11. package/packages/client/dist/types/demo/handler.d.ts +1 -0
  12. package/packages/client/dist/types/demo/handler.d.ts.map +1 -1
  13. package/packages/client/dist/types/index.d.ts.map +1 -1
  14. package/packages/engine/dist/browser/index.global.js.map +1 -1
  15. package/packages/engine/dist/cjs/index.cjs.map +1 -1
  16. package/packages/engine/dist/esm/index.js.map +1 -1
  17. package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
  18. package/packages/engine/dist/types/index.d.ts +1 -1
  19. package/packages/engine/dist/types/index.d.ts.map +1 -1
  20. package/packages/game/dist/browser/index.global.js +2 -2
  21. package/packages/game/dist/browser/index.global.js.map +1 -1
  22. package/packages/game/dist/cjs/index.cjs +106 -2
  23. package/packages/game/dist/cjs/index.cjs.map +1 -1
  24. package/packages/game/dist/esm/index.js +106 -2
  25. package/packages/game/dist/esm/index.js.map +1 -1
  26. package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
  27. package/packages/game/dist/types/entities/playerStats.d.ts +3 -0
  28. package/packages/game/dist/types/entities/playerStats.d.ts.map +1 -0
  29. package/packages/game/dist/types/index.d.ts.map +1 -1
@@ -876,6 +876,35 @@ var TempEntity = /* @__PURE__ */ ((TempEntity2) => {
876
876
  TempEntity2[TempEntity2["EXPLOSION2_NL"] = 63] = "EXPLOSION2_NL";
877
877
  return TempEntity2;
878
878
  })(TempEntity || {});
879
+ var PlayerStat = /* @__PURE__ */ ((PlayerStat2) => {
880
+ PlayerStat2[PlayerStat2["STAT_HEALTH_ICON"] = 0] = "STAT_HEALTH_ICON";
881
+ PlayerStat2[PlayerStat2["STAT_HEALTH"] = 1] = "STAT_HEALTH";
882
+ PlayerStat2[PlayerStat2["STAT_AMMO_ICON"] = 2] = "STAT_AMMO_ICON";
883
+ PlayerStat2[PlayerStat2["STAT_AMMO"] = 3] = "STAT_AMMO";
884
+ PlayerStat2[PlayerStat2["STAT_ARMOR_ICON"] = 4] = "STAT_ARMOR_ICON";
885
+ PlayerStat2[PlayerStat2["STAT_ARMOR"] = 5] = "STAT_ARMOR";
886
+ PlayerStat2[PlayerStat2["STAT_SELECTED_ICON"] = 6] = "STAT_SELECTED_ICON";
887
+ PlayerStat2[PlayerStat2["STAT_PICKUP_ICON"] = 7] = "STAT_PICKUP_ICON";
888
+ PlayerStat2[PlayerStat2["STAT_PICKUP_STRING"] = 8] = "STAT_PICKUP_STRING";
889
+ PlayerStat2[PlayerStat2["STAT_TIMER_ICON"] = 9] = "STAT_TIMER_ICON";
890
+ PlayerStat2[PlayerStat2["STAT_TIMER"] = 10] = "STAT_TIMER";
891
+ PlayerStat2[PlayerStat2["STAT_HELPICON"] = 11] = "STAT_HELPICON";
892
+ PlayerStat2[PlayerStat2["STAT_SELECTED_ITEM"] = 12] = "STAT_SELECTED_ITEM";
893
+ PlayerStat2[PlayerStat2["STAT_LAYOUTS"] = 13] = "STAT_LAYOUTS";
894
+ PlayerStat2[PlayerStat2["STAT_FRAGS"] = 14] = "STAT_FRAGS";
895
+ PlayerStat2[PlayerStat2["STAT_FLASHES"] = 15] = "STAT_FLASHES";
896
+ PlayerStat2[PlayerStat2["STAT_CHASE"] = 16] = "STAT_CHASE";
897
+ PlayerStat2[PlayerStat2["STAT_SPECTATOR"] = 17] = "STAT_SPECTATOR";
898
+ PlayerStat2[PlayerStat2["STAT_WEAPONS_OWNED_1"] = 18] = "STAT_WEAPONS_OWNED_1";
899
+ PlayerStat2[PlayerStat2["STAT_WEAPONS_OWNED_2"] = 19] = "STAT_WEAPONS_OWNED_2";
900
+ PlayerStat2[PlayerStat2["STAT_AMMO_INFO_START"] = 20] = "STAT_AMMO_INFO_START";
901
+ return PlayerStat2;
902
+ })(PlayerStat || {});
903
+ function G_SetAmmoStat(val) {
904
+ if (val > 511) return 511;
905
+ if (val < 0) return 0;
906
+ return val;
907
+ }
879
908
  var entityFlags_exports = {};
880
909
  __export2(entityFlags_exports, {
881
910
  U_ANGLE1: () => U_ANGLE1,
@@ -12783,6 +12812,81 @@ function player_think(self, sys) {
12783
12812
  sys.scheduleThink(self, self.nextthink);
12784
12813
  }
12785
12814
 
12815
+ // src/entities/playerStats.ts
12816
+ var WEAPON_WHEEL_ORDER = [
12817
+ WeaponId.Blaster,
12818
+ WeaponId.Shotgun,
12819
+ WeaponId.SuperShotgun,
12820
+ WeaponId.Machinegun,
12821
+ WeaponId.Chaingun,
12822
+ WeaponId.GrenadeLauncher,
12823
+ WeaponId.RocketLauncher,
12824
+ WeaponId.HyperBlaster,
12825
+ WeaponId.Railgun,
12826
+ WeaponId.BFG10K
12827
+ ];
12828
+ var AMMO_WHEEL_ORDER = [
12829
+ AmmoType.Shells,
12830
+ AmmoType.Bullets,
12831
+ AmmoType.Cells,
12832
+ AmmoType.Rockets,
12833
+ AmmoType.Slugs
12834
+ ];
12835
+ var POWERUP_TIMERS = [
12836
+ { id: PowerupId.QuadDamage, priority: 1 },
12837
+ { id: PowerupId.Invulnerability, priority: 2 },
12838
+ { id: PowerupId.EnviroSuit, priority: 3 },
12839
+ { id: PowerupId.Rebreather, priority: 4 },
12840
+ { id: PowerupId.Silencer, priority: 5 }
12841
+ ];
12842
+ function populatePlayerStats(player, timeSeconds) {
12843
+ if (!player.client) return [];
12844
+ const inventory = player.client.inventory;
12845
+ const statArray = new Array(32).fill(0);
12846
+ statArray[PlayerStat.STAT_HEALTH] = player.health;
12847
+ if (inventory.armor) {
12848
+ statArray[PlayerStat.STAT_ARMOR] = inventory.armor.armorCount;
12849
+ }
12850
+ let weaponBits = 0;
12851
+ for (let i = 0; i < WEAPON_WHEEL_ORDER.length; i++) {
12852
+ const weaponId = WEAPON_WHEEL_ORDER[i];
12853
+ if (inventory.ownedWeapons.has(weaponId)) {
12854
+ weaponBits |= 1 << i;
12855
+ }
12856
+ }
12857
+ statArray[PlayerStat.STAT_WEAPONS_OWNED_1] = weaponBits & 65535;
12858
+ statArray[PlayerStat.STAT_WEAPONS_OWNED_2] = weaponBits >> 16 & 65535;
12859
+ statArray[PlayerStat.STAT_AMMO] = 0;
12860
+ if (inventory.currentWeapon) {
12861
+ const weaponItem = Object.values(WEAPON_ITEMS).find((item) => item.weaponId === inventory.currentWeapon);
12862
+ if (weaponItem && weaponItem.ammoType) {
12863
+ statArray[PlayerStat.STAT_AMMO] = inventory.ammo.counts[weaponItem.ammoType] || 0;
12864
+ }
12865
+ }
12866
+ for (let i = 0; i < AMMO_WHEEL_ORDER.length; i++) {
12867
+ const ammoType = AMMO_WHEEL_ORDER[i];
12868
+ const count = inventory.ammo.counts[ammoType] || 0;
12869
+ statArray[PlayerStat.STAT_AMMO_INFO_START + i] = G_SetAmmoStat(count);
12870
+ }
12871
+ let bestTime = Infinity;
12872
+ let bestPowerup = null;
12873
+ const nowMs = timeSeconds * 1e3;
12874
+ for (const { id } of POWERUP_TIMERS) {
12875
+ const expiresAt = inventory.powerups.get(id);
12876
+ if (expiresAt && expiresAt > nowMs) {
12877
+ if (expiresAt < bestTime) {
12878
+ bestTime = expiresAt;
12879
+ bestPowerup = id;
12880
+ }
12881
+ }
12882
+ }
12883
+ if (bestPowerup && bestTime !== Infinity) {
12884
+ const remainingSeconds = Math.ceil((bestTime - nowMs) / 1e3);
12885
+ statArray[PlayerStat.STAT_TIMER] = remainingSeconds;
12886
+ }
12887
+ return statArray;
12888
+ }
12889
+
12786
12890
  // src/combat/specialDamage.ts
12787
12891
  var ZERO2 = { x: 0, y: 0, z: 0 };
12788
12892
  var EnvironmentalFlags = /* @__PURE__ */ ((EnvironmentalFlags2) => {
@@ -13199,7 +13303,7 @@ function createGame(imports, engine, options) {
13199
13303
  // TODO
13200
13304
  damageIndicators: [],
13201
13305
  // Stubs for new PlayerState fields
13202
- stats: [],
13306
+ stats: player ? populatePlayerStats(player, levelClock.current.timeSeconds) : [],
13203
13307
  kick_angles: ZERO_VEC38,
13204
13308
  gunoffset: ZERO_VEC38,
13205
13309
  gunangles: ZERO_VEC38,
@@ -13238,7 +13342,7 @@ function createGame(imports, engine, options) {
13238
13342
  viewAngles: player.angles,
13239
13343
  blend: [0, 0, 0, 0],
13240
13344
  // Stubs
13241
- stats: [],
13345
+ stats: populatePlayerStats(player, levelClock.current.timeSeconds),
13242
13346
  kick_angles: ZERO_VEC38,
13243
13347
  gunoffset: ZERO_VEC38,
13244
13348
  gunangles: ZERO_VEC38,