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.
@@ -46,6 +46,9 @@ __export(index_exports, {
46
46
  ConfigStringRegistry: () => ConfigStringRegistry,
47
47
  Cvar: () => Cvar,
48
48
  CvarRegistry: () => CvarRegistry,
49
+ DemoAnalyzer: () => DemoAnalyzer,
50
+ DemoCameraMode: () => DemoCameraMode,
51
+ DemoEventType: () => DemoEventType,
49
52
  DemoPlaybackController: () => DemoPlaybackController,
50
53
  DemoReader: () => DemoReader,
51
54
  DemoRecorder: () => DemoRecorder,
@@ -12864,6 +12867,18 @@ var NetworkMessageParser = class _NetworkMessageParser {
12864
12867
  }
12865
12868
  };
12866
12869
 
12870
+ // src/demo/analysis.ts
12871
+ var DemoEventType = /* @__PURE__ */ ((DemoEventType2) => {
12872
+ DemoEventType2[DemoEventType2["WeaponFire"] = 0] = "WeaponFire";
12873
+ DemoEventType2[DemoEventType2["DamageDealt"] = 1] = "DamageDealt";
12874
+ DemoEventType2[DemoEventType2["DamageReceived"] = 2] = "DamageReceived";
12875
+ DemoEventType2[DemoEventType2["Pickup"] = 3] = "Pickup";
12876
+ DemoEventType2[DemoEventType2["Death"] = 4] = "Death";
12877
+ DemoEventType2[DemoEventType2["Spawn"] = 5] = "Spawn";
12878
+ DemoEventType2[DemoEventType2["PlayerInfo"] = 6] = "PlayerInfo";
12879
+ return DemoEventType2;
12880
+ })(DemoEventType || {});
12881
+
12867
12882
  // src/demo/analyzer.ts
12868
12883
  var DemoAnalyzer = class {
12869
12884
  constructor(buffer) {
@@ -12882,6 +12897,8 @@ var DemoAnalyzer = class {
12882
12897
  this.playerStats = /* @__PURE__ */ new Map();
12883
12898
  // By playerNum
12884
12899
  this.weaponStats = /* @__PURE__ */ new Map();
12900
+ // By entity ID
12901
+ this.activeEntities = /* @__PURE__ */ new Set();
12885
12902
  this.buffer = buffer;
12886
12903
  }
12887
12904
  analyze() {
@@ -12917,9 +12934,28 @@ var DemoAnalyzer = class {
12917
12934
  onSpawnBaseline: (entity) => {
12918
12935
  },
12919
12936
  onFrame: (frame) => {
12937
+ const currentFrameEntities = /* @__PURE__ */ new Set();
12938
+ if (frame.packetEntities && frame.packetEntities.entities) {
12939
+ for (const ent of frame.packetEntities.entities) {
12940
+ currentFrameEntities.add(ent.number);
12941
+ if (!this.activeEntities.has(ent.number)) {
12942
+ this.recordEvent({
12943
+ type: 5 /* Spawn */,
12944
+ frame: currentFrameIndex,
12945
+ time: currentTime,
12946
+ entityId: ent.number,
12947
+ position: { x: ent.origin.x, y: ent.origin.y, z: ent.origin.z },
12948
+ description: `Entity ${ent.number} spawned`
12949
+ });
12950
+ }
12951
+ }
12952
+ }
12953
+ this.activeEntities = currentFrameEntities;
12954
+ if (frame.playerState && this.header) {
12955
+ }
12920
12956
  },
12921
12957
  onPrint: (level, msg) => {
12922
- if (msg.includes("died") || msg.includes("killed")) {
12958
+ if (msg.includes("died") || msg.includes("killed") || msg.includes("suicide")) {
12923
12959
  this.summary.totalDeaths++;
12924
12960
  this.recordEvent({
12925
12961
  type: 4 /* Death */,
@@ -12928,6 +12964,14 @@ var DemoAnalyzer = class {
12928
12964
  description: msg.trim()
12929
12965
  });
12930
12966
  }
12967
+ if (msg.startsWith("You got the ")) {
12968
+ this.recordEvent({
12969
+ type: 3 /* Pickup */,
12970
+ frame: currentFrameIndex,
12971
+ time: currentTime,
12972
+ description: msg.trim()
12973
+ });
12974
+ }
12931
12975
  },
12932
12976
  onCenterPrint: () => {
12933
12977
  },
@@ -12968,6 +13012,10 @@ var DemoAnalyzer = class {
12968
13012
  description: `Took ${ind.damage} damage`
12969
13013
  });
12970
13014
  this.summary.damageReceived += ind.damage;
13015
+ if (this.header) {
13016
+ const pStats = this.getOrCreatePlayerStats(this.header.playerNum);
13017
+ pStats.damageReceived += ind.damage;
13018
+ }
12971
13019
  }
12972
13020
  }
12973
13021
  };
@@ -12995,7 +13043,9 @@ var DemoAnalyzer = class {
12995
13043
  header: this.header,
12996
13044
  configStrings: this.configStrings,
12997
13045
  serverInfo: this.serverInfo,
12998
- statistics: this.statistics
13046
+ statistics: this.statistics,
13047
+ playerStats: this.playerStats,
13048
+ weaponStats: this.weaponStats
12999
13049
  };
13000
13050
  }
13001
13051
  handleWeaponFire(ent, weapon, frame, time) {
@@ -13009,6 +13059,8 @@ var DemoAnalyzer = class {
13009
13059
  });
13010
13060
  const count = this.summary.weaponUsage.get(weapon) || 0;
13011
13061
  this.summary.weaponUsage.set(weapon, count + 1);
13062
+ const wStats = this.getOrCreateWeaponStat(ent, weapon);
13063
+ wStats.shotsFired++;
13012
13064
  }
13013
13065
  recordEvent(event) {
13014
13066
  this.events.push(event);
@@ -13021,8 +13073,44 @@ var DemoAnalyzer = class {
13021
13073
  }
13022
13074
  }
13023
13075
  }
13076
+ getOrCreatePlayerStats(playerNum) {
13077
+ let stats = this.playerStats.get(playerNum);
13078
+ if (!stats) {
13079
+ stats = {
13080
+ kills: 0,
13081
+ deaths: 0,
13082
+ damageDealt: 0,
13083
+ damageReceived: 0,
13084
+ suicides: 0
13085
+ };
13086
+ this.playerStats.set(playerNum, stats);
13087
+ }
13088
+ return stats;
13089
+ }
13090
+ getOrCreateWeaponStat(entityId, weaponId) {
13091
+ let statsList = this.weaponStats.get(entityId);
13092
+ if (!statsList) {
13093
+ statsList = [];
13094
+ this.weaponStats.set(entityId, statsList);
13095
+ }
13096
+ let stat = statsList.find((s) => s.weaponId === weaponId);
13097
+ if (!stat) {
13098
+ stat = { weaponId, shotsFired: 0, hits: 0, kills: 0 };
13099
+ statsList.push(stat);
13100
+ }
13101
+ return stat;
13102
+ }
13024
13103
  };
13025
13104
 
13105
+ // src/demo/camera.ts
13106
+ var DemoCameraMode = /* @__PURE__ */ ((DemoCameraMode2) => {
13107
+ DemoCameraMode2[DemoCameraMode2["FirstPerson"] = 0] = "FirstPerson";
13108
+ DemoCameraMode2[DemoCameraMode2["ThirdPerson"] = 1] = "ThirdPerson";
13109
+ DemoCameraMode2[DemoCameraMode2["Free"] = 2] = "Free";
13110
+ DemoCameraMode2[DemoCameraMode2["Follow"] = 3] = "Follow";
13111
+ return DemoCameraMode2;
13112
+ })(DemoCameraMode || {});
13113
+
13026
13114
  // src/demo/playback.ts
13027
13115
  var PlaybackState = /* @__PURE__ */ ((PlaybackState2) => {
13028
13116
  PlaybackState2[PlaybackState2["Stopped"] = 0] = "Stopped";
@@ -13058,6 +13146,12 @@ var DemoPlaybackController = class {
13058
13146
  this.cachedConfigStrings = null;
13059
13147
  this.cachedServerInfo = null;
13060
13148
  this.cachedStatistics = null;
13149
+ this.cachedPlayerStats = null;
13150
+ this.cachedWeaponStats = null;
13151
+ // Camera State
13152
+ this.cameraMode = 0 /* FirstPerson */;
13153
+ this.thirdPersonDistance = 80;
13154
+ this.thirdPersonOffset = { x: 0, y: 0, z: 0 };
13061
13155
  }
13062
13156
  setHandler(handler) {
13063
13157
  this.handler = handler;
@@ -13080,6 +13174,8 @@ var DemoPlaybackController = class {
13080
13174
  this.cachedConfigStrings = null;
13081
13175
  this.cachedServerInfo = null;
13082
13176
  this.cachedStatistics = null;
13177
+ this.cachedPlayerStats = null;
13178
+ this.cachedWeaponStats = null;
13083
13179
  }
13084
13180
  play() {
13085
13181
  if (this.reader && this.state !== 1 /* Playing */) {
@@ -13431,6 +13527,14 @@ var DemoPlaybackController = class {
13431
13527
  this.ensureAnalysis();
13432
13528
  return this.cachedStatistics;
13433
13529
  }
13530
+ getPlayerStatistics(playerIndex) {
13531
+ this.ensureAnalysis();
13532
+ return this.cachedPlayerStats?.get(playerIndex) || null;
13533
+ }
13534
+ getWeaponStatistics(entityId) {
13535
+ this.ensureAnalysis();
13536
+ return this.cachedWeaponStats?.get(entityId) || null;
13537
+ }
13434
13538
  ensureAnalysis() {
13435
13539
  if (!this.cachedEvents && this.buffer) {
13436
13540
  const analyzer = new DemoAnalyzer(this.buffer);
@@ -13441,8 +13545,22 @@ var DemoPlaybackController = class {
13441
13545
  this.cachedConfigStrings = result.configStrings;
13442
13546
  this.cachedServerInfo = result.serverInfo;
13443
13547
  this.cachedStatistics = result.statistics;
13548
+ this.cachedPlayerStats = result.playerStats;
13549
+ this.cachedWeaponStats = result.weaponStats;
13444
13550
  }
13445
13551
  }
13552
+ setCameraMode(mode) {
13553
+ this.cameraMode = mode;
13554
+ }
13555
+ getCameraMode() {
13556
+ return this.cameraMode;
13557
+ }
13558
+ setThirdPersonDistance(distance) {
13559
+ this.thirdPersonDistance = distance;
13560
+ }
13561
+ setThirdPersonOffset(offset) {
13562
+ this.thirdPersonOffset = offset;
13563
+ }
13446
13564
  };
13447
13565
 
13448
13566
  // src/demo/recorder.ts
@@ -13893,6 +14011,9 @@ function createEngine(imports) {
13893
14011
  ConfigStringRegistry,
13894
14012
  Cvar,
13895
14013
  CvarRegistry,
14014
+ DemoAnalyzer,
14015
+ DemoCameraMode,
14016
+ DemoEventType,
13896
14017
  DemoPlaybackController,
13897
14018
  DemoReader,
13898
14019
  DemoRecorder,