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.
- package/package.json +1 -1
- package/packages/client/dist/browser/index.global.js +13 -13
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/cjs/index.cjs +88 -28
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +88 -28
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/client/dist/types/cgameBridge.d.ts +12 -1
- package/packages/client/dist/types/cgameBridge.d.ts.map +1 -1
- package/packages/client/dist/types/demo/handler.d.ts +1 -0
- package/packages/client/dist/types/demo/handler.d.ts.map +1 -1
- package/packages/client/dist/types/index.d.ts.map +1 -1
- package/packages/engine/dist/browser/index.global.js.map +1 -1
- package/packages/engine/dist/cjs/index.cjs.map +1 -1
- package/packages/engine/dist/esm/index.js.map +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/types/index.d.ts +1 -1
- package/packages/engine/dist/types/index.d.ts.map +1 -1
- package/packages/game/dist/browser/index.global.js +2 -2
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs +106 -2
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +106 -2
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/entities/playerStats.d.ts +3 -0
- package/packages/game/dist/types/entities/playerStats.d.ts.map +1 -0
- package/packages/game/dist/types/index.d.ts.map +1 -1
|
@@ -710,6 +710,35 @@ var TempEntity = /* @__PURE__ */ ((TempEntity2) => {
|
|
|
710
710
|
TempEntity2[TempEntity2["EXPLOSION2_NL"] = 63] = "EXPLOSION2_NL";
|
|
711
711
|
return TempEntity2;
|
|
712
712
|
})(TempEntity || {});
|
|
713
|
+
var PlayerStat = /* @__PURE__ */ ((PlayerStat2) => {
|
|
714
|
+
PlayerStat2[PlayerStat2["STAT_HEALTH_ICON"] = 0] = "STAT_HEALTH_ICON";
|
|
715
|
+
PlayerStat2[PlayerStat2["STAT_HEALTH"] = 1] = "STAT_HEALTH";
|
|
716
|
+
PlayerStat2[PlayerStat2["STAT_AMMO_ICON"] = 2] = "STAT_AMMO_ICON";
|
|
717
|
+
PlayerStat2[PlayerStat2["STAT_AMMO"] = 3] = "STAT_AMMO";
|
|
718
|
+
PlayerStat2[PlayerStat2["STAT_ARMOR_ICON"] = 4] = "STAT_ARMOR_ICON";
|
|
719
|
+
PlayerStat2[PlayerStat2["STAT_ARMOR"] = 5] = "STAT_ARMOR";
|
|
720
|
+
PlayerStat2[PlayerStat2["STAT_SELECTED_ICON"] = 6] = "STAT_SELECTED_ICON";
|
|
721
|
+
PlayerStat2[PlayerStat2["STAT_PICKUP_ICON"] = 7] = "STAT_PICKUP_ICON";
|
|
722
|
+
PlayerStat2[PlayerStat2["STAT_PICKUP_STRING"] = 8] = "STAT_PICKUP_STRING";
|
|
723
|
+
PlayerStat2[PlayerStat2["STAT_TIMER_ICON"] = 9] = "STAT_TIMER_ICON";
|
|
724
|
+
PlayerStat2[PlayerStat2["STAT_TIMER"] = 10] = "STAT_TIMER";
|
|
725
|
+
PlayerStat2[PlayerStat2["STAT_HELPICON"] = 11] = "STAT_HELPICON";
|
|
726
|
+
PlayerStat2[PlayerStat2["STAT_SELECTED_ITEM"] = 12] = "STAT_SELECTED_ITEM";
|
|
727
|
+
PlayerStat2[PlayerStat2["STAT_LAYOUTS"] = 13] = "STAT_LAYOUTS";
|
|
728
|
+
PlayerStat2[PlayerStat2["STAT_FRAGS"] = 14] = "STAT_FRAGS";
|
|
729
|
+
PlayerStat2[PlayerStat2["STAT_FLASHES"] = 15] = "STAT_FLASHES";
|
|
730
|
+
PlayerStat2[PlayerStat2["STAT_CHASE"] = 16] = "STAT_CHASE";
|
|
731
|
+
PlayerStat2[PlayerStat2["STAT_SPECTATOR"] = 17] = "STAT_SPECTATOR";
|
|
732
|
+
PlayerStat2[PlayerStat2["STAT_WEAPONS_OWNED_1"] = 18] = "STAT_WEAPONS_OWNED_1";
|
|
733
|
+
PlayerStat2[PlayerStat2["STAT_WEAPONS_OWNED_2"] = 19] = "STAT_WEAPONS_OWNED_2";
|
|
734
|
+
PlayerStat2[PlayerStat2["STAT_AMMO_INFO_START"] = 20] = "STAT_AMMO_INFO_START";
|
|
735
|
+
return PlayerStat2;
|
|
736
|
+
})(PlayerStat || {});
|
|
737
|
+
function G_SetAmmoStat(val) {
|
|
738
|
+
if (val > 511) return 511;
|
|
739
|
+
if (val < 0) return 0;
|
|
740
|
+
return val;
|
|
741
|
+
}
|
|
713
742
|
var entityFlags_exports = {};
|
|
714
743
|
__export(entityFlags_exports, {
|
|
715
744
|
U_ANGLE1: () => U_ANGLE1,
|
|
@@ -12617,6 +12646,81 @@ function player_think(self, sys) {
|
|
|
12617
12646
|
sys.scheduleThink(self, self.nextthink);
|
|
12618
12647
|
}
|
|
12619
12648
|
|
|
12649
|
+
// src/entities/playerStats.ts
|
|
12650
|
+
var WEAPON_WHEEL_ORDER = [
|
|
12651
|
+
WeaponId.Blaster,
|
|
12652
|
+
WeaponId.Shotgun,
|
|
12653
|
+
WeaponId.SuperShotgun,
|
|
12654
|
+
WeaponId.Machinegun,
|
|
12655
|
+
WeaponId.Chaingun,
|
|
12656
|
+
WeaponId.GrenadeLauncher,
|
|
12657
|
+
WeaponId.RocketLauncher,
|
|
12658
|
+
WeaponId.HyperBlaster,
|
|
12659
|
+
WeaponId.Railgun,
|
|
12660
|
+
WeaponId.BFG10K
|
|
12661
|
+
];
|
|
12662
|
+
var AMMO_WHEEL_ORDER = [
|
|
12663
|
+
AmmoType.Shells,
|
|
12664
|
+
AmmoType.Bullets,
|
|
12665
|
+
AmmoType.Cells,
|
|
12666
|
+
AmmoType.Rockets,
|
|
12667
|
+
AmmoType.Slugs
|
|
12668
|
+
];
|
|
12669
|
+
var POWERUP_TIMERS = [
|
|
12670
|
+
{ id: PowerupId.QuadDamage, priority: 1 },
|
|
12671
|
+
{ id: PowerupId.Invulnerability, priority: 2 },
|
|
12672
|
+
{ id: PowerupId.EnviroSuit, priority: 3 },
|
|
12673
|
+
{ id: PowerupId.Rebreather, priority: 4 },
|
|
12674
|
+
{ id: PowerupId.Silencer, priority: 5 }
|
|
12675
|
+
];
|
|
12676
|
+
function populatePlayerStats(player, timeSeconds) {
|
|
12677
|
+
if (!player.client) return [];
|
|
12678
|
+
const inventory = player.client.inventory;
|
|
12679
|
+
const statArray = new Array(32).fill(0);
|
|
12680
|
+
statArray[PlayerStat.STAT_HEALTH] = player.health;
|
|
12681
|
+
if (inventory.armor) {
|
|
12682
|
+
statArray[PlayerStat.STAT_ARMOR] = inventory.armor.armorCount;
|
|
12683
|
+
}
|
|
12684
|
+
let weaponBits = 0;
|
|
12685
|
+
for (let i = 0; i < WEAPON_WHEEL_ORDER.length; i++) {
|
|
12686
|
+
const weaponId = WEAPON_WHEEL_ORDER[i];
|
|
12687
|
+
if (inventory.ownedWeapons.has(weaponId)) {
|
|
12688
|
+
weaponBits |= 1 << i;
|
|
12689
|
+
}
|
|
12690
|
+
}
|
|
12691
|
+
statArray[PlayerStat.STAT_WEAPONS_OWNED_1] = weaponBits & 65535;
|
|
12692
|
+
statArray[PlayerStat.STAT_WEAPONS_OWNED_2] = weaponBits >> 16 & 65535;
|
|
12693
|
+
statArray[PlayerStat.STAT_AMMO] = 0;
|
|
12694
|
+
if (inventory.currentWeapon) {
|
|
12695
|
+
const weaponItem = Object.values(WEAPON_ITEMS).find((item) => item.weaponId === inventory.currentWeapon);
|
|
12696
|
+
if (weaponItem && weaponItem.ammoType) {
|
|
12697
|
+
statArray[PlayerStat.STAT_AMMO] = inventory.ammo.counts[weaponItem.ammoType] || 0;
|
|
12698
|
+
}
|
|
12699
|
+
}
|
|
12700
|
+
for (let i = 0; i < AMMO_WHEEL_ORDER.length; i++) {
|
|
12701
|
+
const ammoType = AMMO_WHEEL_ORDER[i];
|
|
12702
|
+
const count = inventory.ammo.counts[ammoType] || 0;
|
|
12703
|
+
statArray[PlayerStat.STAT_AMMO_INFO_START + i] = G_SetAmmoStat(count);
|
|
12704
|
+
}
|
|
12705
|
+
let bestTime = Infinity;
|
|
12706
|
+
let bestPowerup = null;
|
|
12707
|
+
const nowMs = timeSeconds * 1e3;
|
|
12708
|
+
for (const { id } of POWERUP_TIMERS) {
|
|
12709
|
+
const expiresAt = inventory.powerups.get(id);
|
|
12710
|
+
if (expiresAt && expiresAt > nowMs) {
|
|
12711
|
+
if (expiresAt < bestTime) {
|
|
12712
|
+
bestTime = expiresAt;
|
|
12713
|
+
bestPowerup = id;
|
|
12714
|
+
}
|
|
12715
|
+
}
|
|
12716
|
+
}
|
|
12717
|
+
if (bestPowerup && bestTime !== Infinity) {
|
|
12718
|
+
const remainingSeconds = Math.ceil((bestTime - nowMs) / 1e3);
|
|
12719
|
+
statArray[PlayerStat.STAT_TIMER] = remainingSeconds;
|
|
12720
|
+
}
|
|
12721
|
+
return statArray;
|
|
12722
|
+
}
|
|
12723
|
+
|
|
12620
12724
|
// src/combat/specialDamage.ts
|
|
12621
12725
|
var ZERO2 = { x: 0, y: 0, z: 0 };
|
|
12622
12726
|
var EnvironmentalFlags = /* @__PURE__ */ ((EnvironmentalFlags2) => {
|
|
@@ -13033,7 +13137,7 @@ function createGame(imports, engine, options) {
|
|
|
13033
13137
|
// TODO
|
|
13034
13138
|
damageIndicators: [],
|
|
13035
13139
|
// Stubs for new PlayerState fields
|
|
13036
|
-
stats: [],
|
|
13140
|
+
stats: player ? populatePlayerStats(player, levelClock.current.timeSeconds) : [],
|
|
13037
13141
|
kick_angles: ZERO_VEC38,
|
|
13038
13142
|
gunoffset: ZERO_VEC38,
|
|
13039
13143
|
gunangles: ZERO_VEC38,
|
|
@@ -13072,7 +13176,7 @@ function createGame(imports, engine, options) {
|
|
|
13072
13176
|
viewAngles: player.angles,
|
|
13073
13177
|
blend: [0, 0, 0, 0],
|
|
13074
13178
|
// Stubs
|
|
13075
|
-
stats:
|
|
13179
|
+
stats: populatePlayerStats(player, levelClock.current.timeSeconds),
|
|
13076
13180
|
kick_angles: ZERO_VEC38,
|
|
13077
13181
|
gunoffset: ZERO_VEC38,
|
|
13078
13182
|
gunangles: ZERO_VEC38,
|