quake2ts 0.0.429 → 0.0.430

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.
@@ -12661,6 +12661,18 @@ var NetworkMessageParser = class _NetworkMessageParser {
12661
12661
  }
12662
12662
  };
12663
12663
 
12664
+ // src/demo/analysis.ts
12665
+ var DemoEventType = /* @__PURE__ */ ((DemoEventType2) => {
12666
+ DemoEventType2[DemoEventType2["WeaponFire"] = 0] = "WeaponFire";
12667
+ DemoEventType2[DemoEventType2["DamageDealt"] = 1] = "DamageDealt";
12668
+ DemoEventType2[DemoEventType2["DamageReceived"] = 2] = "DamageReceived";
12669
+ DemoEventType2[DemoEventType2["Pickup"] = 3] = "Pickup";
12670
+ DemoEventType2[DemoEventType2["Death"] = 4] = "Death";
12671
+ DemoEventType2[DemoEventType2["Spawn"] = 5] = "Spawn";
12672
+ DemoEventType2[DemoEventType2["PlayerInfo"] = 6] = "PlayerInfo";
12673
+ return DemoEventType2;
12674
+ })(DemoEventType || {});
12675
+
12664
12676
  // src/demo/analyzer.ts
12665
12677
  var DemoAnalyzer = class {
12666
12678
  constructor(buffer) {
@@ -12679,6 +12691,8 @@ var DemoAnalyzer = class {
12679
12691
  this.playerStats = /* @__PURE__ */ new Map();
12680
12692
  // By playerNum
12681
12693
  this.weaponStats = /* @__PURE__ */ new Map();
12694
+ // By entity ID
12695
+ this.activeEntities = /* @__PURE__ */ new Set();
12682
12696
  this.buffer = buffer;
12683
12697
  }
12684
12698
  analyze() {
@@ -12714,9 +12728,28 @@ var DemoAnalyzer = class {
12714
12728
  onSpawnBaseline: (entity) => {
12715
12729
  },
12716
12730
  onFrame: (frame) => {
12731
+ const currentFrameEntities = /* @__PURE__ */ new Set();
12732
+ if (frame.packetEntities && frame.packetEntities.entities) {
12733
+ for (const ent of frame.packetEntities.entities) {
12734
+ currentFrameEntities.add(ent.number);
12735
+ if (!this.activeEntities.has(ent.number)) {
12736
+ this.recordEvent({
12737
+ type: 5 /* Spawn */,
12738
+ frame: currentFrameIndex,
12739
+ time: currentTime,
12740
+ entityId: ent.number,
12741
+ position: { x: ent.origin.x, y: ent.origin.y, z: ent.origin.z },
12742
+ description: `Entity ${ent.number} spawned`
12743
+ });
12744
+ }
12745
+ }
12746
+ }
12747
+ this.activeEntities = currentFrameEntities;
12748
+ if (frame.playerState && this.header) {
12749
+ }
12717
12750
  },
12718
12751
  onPrint: (level, msg) => {
12719
- if (msg.includes("died") || msg.includes("killed")) {
12752
+ if (msg.includes("died") || msg.includes("killed") || msg.includes("suicide")) {
12720
12753
  this.summary.totalDeaths++;
12721
12754
  this.recordEvent({
12722
12755
  type: 4 /* Death */,
@@ -12725,6 +12758,14 @@ var DemoAnalyzer = class {
12725
12758
  description: msg.trim()
12726
12759
  });
12727
12760
  }
12761
+ if (msg.startsWith("You got the ")) {
12762
+ this.recordEvent({
12763
+ type: 3 /* Pickup */,
12764
+ frame: currentFrameIndex,
12765
+ time: currentTime,
12766
+ description: msg.trim()
12767
+ });
12768
+ }
12728
12769
  },
12729
12770
  onCenterPrint: () => {
12730
12771
  },
@@ -12765,6 +12806,10 @@ var DemoAnalyzer = class {
12765
12806
  description: `Took ${ind.damage} damage`
12766
12807
  });
12767
12808
  this.summary.damageReceived += ind.damage;
12809
+ if (this.header) {
12810
+ const pStats = this.getOrCreatePlayerStats(this.header.playerNum);
12811
+ pStats.damageReceived += ind.damage;
12812
+ }
12768
12813
  }
12769
12814
  }
12770
12815
  };
@@ -12792,7 +12837,9 @@ var DemoAnalyzer = class {
12792
12837
  header: this.header,
12793
12838
  configStrings: this.configStrings,
12794
12839
  serverInfo: this.serverInfo,
12795
- statistics: this.statistics
12840
+ statistics: this.statistics,
12841
+ playerStats: this.playerStats,
12842
+ weaponStats: this.weaponStats
12796
12843
  };
12797
12844
  }
12798
12845
  handleWeaponFire(ent, weapon, frame, time) {
@@ -12806,6 +12853,8 @@ var DemoAnalyzer = class {
12806
12853
  });
12807
12854
  const count = this.summary.weaponUsage.get(weapon) || 0;
12808
12855
  this.summary.weaponUsage.set(weapon, count + 1);
12856
+ const wStats = this.getOrCreateWeaponStat(ent, weapon);
12857
+ wStats.shotsFired++;
12809
12858
  }
12810
12859
  recordEvent(event) {
12811
12860
  this.events.push(event);
@@ -12818,8 +12867,44 @@ var DemoAnalyzer = class {
12818
12867
  }
12819
12868
  }
12820
12869
  }
12870
+ getOrCreatePlayerStats(playerNum) {
12871
+ let stats = this.playerStats.get(playerNum);
12872
+ if (!stats) {
12873
+ stats = {
12874
+ kills: 0,
12875
+ deaths: 0,
12876
+ damageDealt: 0,
12877
+ damageReceived: 0,
12878
+ suicides: 0
12879
+ };
12880
+ this.playerStats.set(playerNum, stats);
12881
+ }
12882
+ return stats;
12883
+ }
12884
+ getOrCreateWeaponStat(entityId, weaponId) {
12885
+ let statsList = this.weaponStats.get(entityId);
12886
+ if (!statsList) {
12887
+ statsList = [];
12888
+ this.weaponStats.set(entityId, statsList);
12889
+ }
12890
+ let stat = statsList.find((s) => s.weaponId === weaponId);
12891
+ if (!stat) {
12892
+ stat = { weaponId, shotsFired: 0, hits: 0, kills: 0 };
12893
+ statsList.push(stat);
12894
+ }
12895
+ return stat;
12896
+ }
12821
12897
  };
12822
12898
 
12899
+ // src/demo/camera.ts
12900
+ var DemoCameraMode = /* @__PURE__ */ ((DemoCameraMode2) => {
12901
+ DemoCameraMode2[DemoCameraMode2["FirstPerson"] = 0] = "FirstPerson";
12902
+ DemoCameraMode2[DemoCameraMode2["ThirdPerson"] = 1] = "ThirdPerson";
12903
+ DemoCameraMode2[DemoCameraMode2["Free"] = 2] = "Free";
12904
+ DemoCameraMode2[DemoCameraMode2["Follow"] = 3] = "Follow";
12905
+ return DemoCameraMode2;
12906
+ })(DemoCameraMode || {});
12907
+
12823
12908
  // src/demo/playback.ts
12824
12909
  var PlaybackState = /* @__PURE__ */ ((PlaybackState2) => {
12825
12910
  PlaybackState2[PlaybackState2["Stopped"] = 0] = "Stopped";
@@ -12855,6 +12940,12 @@ var DemoPlaybackController = class {
12855
12940
  this.cachedConfigStrings = null;
12856
12941
  this.cachedServerInfo = null;
12857
12942
  this.cachedStatistics = null;
12943
+ this.cachedPlayerStats = null;
12944
+ this.cachedWeaponStats = null;
12945
+ // Camera State
12946
+ this.cameraMode = 0 /* FirstPerson */;
12947
+ this.thirdPersonDistance = 80;
12948
+ this.thirdPersonOffset = { x: 0, y: 0, z: 0 };
12858
12949
  }
12859
12950
  setHandler(handler) {
12860
12951
  this.handler = handler;
@@ -12877,6 +12968,8 @@ var DemoPlaybackController = class {
12877
12968
  this.cachedConfigStrings = null;
12878
12969
  this.cachedServerInfo = null;
12879
12970
  this.cachedStatistics = null;
12971
+ this.cachedPlayerStats = null;
12972
+ this.cachedWeaponStats = null;
12880
12973
  }
12881
12974
  play() {
12882
12975
  if (this.reader && this.state !== 1 /* Playing */) {
@@ -13228,6 +13321,14 @@ var DemoPlaybackController = class {
13228
13321
  this.ensureAnalysis();
13229
13322
  return this.cachedStatistics;
13230
13323
  }
13324
+ getPlayerStatistics(playerIndex) {
13325
+ this.ensureAnalysis();
13326
+ return this.cachedPlayerStats?.get(playerIndex) || null;
13327
+ }
13328
+ getWeaponStatistics(entityId) {
13329
+ this.ensureAnalysis();
13330
+ return this.cachedWeaponStats?.get(entityId) || null;
13331
+ }
13231
13332
  ensureAnalysis() {
13232
13333
  if (!this.cachedEvents && this.buffer) {
13233
13334
  const analyzer = new DemoAnalyzer(this.buffer);
@@ -13238,8 +13339,22 @@ var DemoPlaybackController = class {
13238
13339
  this.cachedConfigStrings = result.configStrings;
13239
13340
  this.cachedServerInfo = result.serverInfo;
13240
13341
  this.cachedStatistics = result.statistics;
13342
+ this.cachedPlayerStats = result.playerStats;
13343
+ this.cachedWeaponStats = result.weaponStats;
13241
13344
  }
13242
13345
  }
13346
+ setCameraMode(mode) {
13347
+ this.cameraMode = mode;
13348
+ }
13349
+ getCameraMode() {
13350
+ return this.cameraMode;
13351
+ }
13352
+ setThirdPersonDistance(distance) {
13353
+ this.thirdPersonDistance = distance;
13354
+ }
13355
+ setThirdPersonOffset(offset) {
13356
+ this.thirdPersonOffset = offset;
13357
+ }
13243
13358
  };
13244
13359
 
13245
13360
  // src/demo/recorder.ts
@@ -13689,6 +13804,9 @@ export {
13689
13804
  ConfigStringRegistry,
13690
13805
  Cvar,
13691
13806
  CvarRegistry,
13807
+ DemoAnalyzer,
13808
+ DemoCameraMode,
13809
+ DemoEventType,
13692
13810
  DemoPlaybackController,
13693
13811
  DemoReader,
13694
13812
  DemoRecorder,