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.
@@ -9003,6 +9003,7 @@ var DemoAnalyzer = class {
9003
9003
  this.statistics = null;
9004
9004
  this.playerStats = /* @__PURE__ */ new Map();
9005
9005
  this.weaponStats = /* @__PURE__ */ new Map();
9006
+ this.activeEntities = /* @__PURE__ */ new Set();
9006
9007
  this.buffer = buffer;
9007
9008
  }
9008
9009
  analyze() {
@@ -9038,9 +9039,28 @@ var DemoAnalyzer = class {
9038
9039
  onSpawnBaseline: (entity) => {
9039
9040
  },
9040
9041
  onFrame: (frame) => {
9042
+ const currentFrameEntities = /* @__PURE__ */ new Set();
9043
+ if (frame.packetEntities && frame.packetEntities.entities) {
9044
+ for (const ent of frame.packetEntities.entities) {
9045
+ currentFrameEntities.add(ent.number);
9046
+ if (!this.activeEntities.has(ent.number)) {
9047
+ this.recordEvent({
9048
+ type: 5,
9049
+ frame: currentFrameIndex,
9050
+ time: currentTime,
9051
+ entityId: ent.number,
9052
+ position: { x: ent.origin.x, y: ent.origin.y, z: ent.origin.z },
9053
+ description: `Entity ${ent.number} spawned`
9054
+ });
9055
+ }
9056
+ }
9057
+ }
9058
+ this.activeEntities = currentFrameEntities;
9059
+ if (frame.playerState && this.header) {
9060
+ }
9041
9061
  },
9042
9062
  onPrint: (level, msg) => {
9043
- if (msg.includes("died") || msg.includes("killed")) {
9063
+ if (msg.includes("died") || msg.includes("killed") || msg.includes("suicide")) {
9044
9064
  this.summary.totalDeaths++;
9045
9065
  this.recordEvent({
9046
9066
  type: 4,
@@ -9049,6 +9069,14 @@ var DemoAnalyzer = class {
9049
9069
  description: msg.trim()
9050
9070
  });
9051
9071
  }
9072
+ if (msg.startsWith("You got the ")) {
9073
+ this.recordEvent({
9074
+ type: 3,
9075
+ frame: currentFrameIndex,
9076
+ time: currentTime,
9077
+ description: msg.trim()
9078
+ });
9079
+ }
9052
9080
  },
9053
9081
  onCenterPrint: () => {
9054
9082
  },
@@ -9089,6 +9117,10 @@ var DemoAnalyzer = class {
9089
9117
  description: `Took ${ind.damage} damage`
9090
9118
  });
9091
9119
  this.summary.damageReceived += ind.damage;
9120
+ if (this.header) {
9121
+ const pStats = this.getOrCreatePlayerStats(this.header.playerNum);
9122
+ pStats.damageReceived += ind.damage;
9123
+ }
9092
9124
  }
9093
9125
  }
9094
9126
  };
@@ -9116,7 +9148,9 @@ var DemoAnalyzer = class {
9116
9148
  header: this.header,
9117
9149
  configStrings: this.configStrings,
9118
9150
  serverInfo: this.serverInfo,
9119
- statistics: this.statistics
9151
+ statistics: this.statistics,
9152
+ playerStats: this.playerStats,
9153
+ weaponStats: this.weaponStats
9120
9154
  };
9121
9155
  }
9122
9156
  handleWeaponFire(ent, weapon, frame, time) {
@@ -9130,6 +9164,8 @@ var DemoAnalyzer = class {
9130
9164
  });
9131
9165
  const count = this.summary.weaponUsage.get(weapon) || 0;
9132
9166
  this.summary.weaponUsage.set(weapon, count + 1);
9167
+ const wStats = this.getOrCreateWeaponStat(ent, weapon);
9168
+ wStats.shotsFired++;
9133
9169
  }
9134
9170
  recordEvent(event) {
9135
9171
  this.events.push(event);
@@ -9142,6 +9178,33 @@ var DemoAnalyzer = class {
9142
9178
  }
9143
9179
  }
9144
9180
  }
9181
+ getOrCreatePlayerStats(playerNum) {
9182
+ let stats = this.playerStats.get(playerNum);
9183
+ if (!stats) {
9184
+ stats = {
9185
+ kills: 0,
9186
+ deaths: 0,
9187
+ damageDealt: 0,
9188
+ damageReceived: 0,
9189
+ suicides: 0
9190
+ };
9191
+ this.playerStats.set(playerNum, stats);
9192
+ }
9193
+ return stats;
9194
+ }
9195
+ getOrCreateWeaponStat(entityId, weaponId) {
9196
+ let statsList = this.weaponStats.get(entityId);
9197
+ if (!statsList) {
9198
+ statsList = [];
9199
+ this.weaponStats.set(entityId, statsList);
9200
+ }
9201
+ let stat = statsList.find((s) => s.weaponId === weaponId);
9202
+ if (!stat) {
9203
+ stat = { weaponId, shotsFired: 0, hits: 0, kills: 0 };
9204
+ statsList.push(stat);
9205
+ }
9206
+ return stat;
9207
+ }
9145
9208
  };
9146
9209
  var PlaybackState = /* @__PURE__ */ ((PlaybackState22) => {
9147
9210
  PlaybackState22[PlaybackState22["Stopped"] = 0] = "Stopped";
@@ -9169,6 +9232,11 @@ var DemoPlaybackController = class {
9169
9232
  this.cachedConfigStrings = null;
9170
9233
  this.cachedServerInfo = null;
9171
9234
  this.cachedStatistics = null;
9235
+ this.cachedPlayerStats = null;
9236
+ this.cachedWeaponStats = null;
9237
+ this.cameraMode = 0;
9238
+ this.thirdPersonDistance = 80;
9239
+ this.thirdPersonOffset = { x: 0, y: 0, z: 0 };
9172
9240
  }
9173
9241
  setHandler(handler) {
9174
9242
  this.handler = handler;
@@ -9194,6 +9262,8 @@ var DemoPlaybackController = class {
9194
9262
  this.cachedConfigStrings = null;
9195
9263
  this.cachedServerInfo = null;
9196
9264
  this.cachedStatistics = null;
9265
+ this.cachedPlayerStats = null;
9266
+ this.cachedWeaponStats = null;
9197
9267
  }
9198
9268
  play() {
9199
9269
  if (this.reader && this.state !== 1) {
@@ -9560,6 +9630,14 @@ var DemoPlaybackController = class {
9560
9630
  this.ensureAnalysis();
9561
9631
  return this.cachedStatistics;
9562
9632
  }
9633
+ getPlayerStatistics(playerIndex) {
9634
+ this.ensureAnalysis();
9635
+ return this.cachedPlayerStats?.get(playerIndex) || null;
9636
+ }
9637
+ getWeaponStatistics(entityId) {
9638
+ this.ensureAnalysis();
9639
+ return this.cachedWeaponStats?.get(entityId) || null;
9640
+ }
9563
9641
  ensureAnalysis() {
9564
9642
  if (!this.cachedEvents && this.buffer) {
9565
9643
  const analyzer = new DemoAnalyzer(this.buffer);
@@ -9570,8 +9648,22 @@ var DemoPlaybackController = class {
9570
9648
  this.cachedConfigStrings = result.configStrings;
9571
9649
  this.cachedServerInfo = result.serverInfo;
9572
9650
  this.cachedStatistics = result.statistics;
9651
+ this.cachedPlayerStats = result.playerStats;
9652
+ this.cachedWeaponStats = result.weaponStats;
9573
9653
  }
9574
9654
  }
9655
+ setCameraMode(mode) {
9656
+ this.cameraMode = mode;
9657
+ }
9658
+ getCameraMode() {
9659
+ return this.cameraMode;
9660
+ }
9661
+ setThirdPersonDistance(distance2) {
9662
+ this.thirdPersonDistance = distance2;
9663
+ }
9664
+ setThirdPersonOffset(offset) {
9665
+ this.thirdPersonOffset = offset;
9666
+ }
9575
9667
  };
9576
9668
  var DemoRecorder = class {
9577
9669
  // -1 means start of demo