quake2ts 0.0.291 → 0.0.292

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 (45) hide show
  1. package/package.json +1 -1
  2. package/packages/client/dist/browser/index.global.js +3 -3
  3. package/packages/client/dist/browser/index.global.js.map +1 -1
  4. package/packages/client/dist/cjs/index.cjs +2 -0
  5. package/packages/client/dist/cjs/index.cjs.map +1 -1
  6. package/packages/client/dist/esm/index.js +2 -0
  7. package/packages/client/dist/esm/index.js.map +1 -1
  8. package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
  9. package/packages/engine/dist/browser/index.global.js +1 -1
  10. package/packages/engine/dist/browser/index.global.js.map +1 -1
  11. package/packages/engine/dist/cjs/index.cjs +1 -0
  12. package/packages/engine/dist/cjs/index.cjs.map +1 -1
  13. package/packages/engine/dist/esm/index.js +1 -0
  14. package/packages/engine/dist/esm/index.js.map +1 -1
  15. package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
  16. package/packages/game/dist/browser/index.global.js +4 -3
  17. package/packages/game/dist/browser/index.global.js.map +1 -1
  18. package/packages/game/dist/cjs/index.cjs +116 -4
  19. package/packages/game/dist/cjs/index.cjs.map +1 -1
  20. package/packages/game/dist/esm/index.js +116 -4
  21. package/packages/game/dist/esm/index.js.map +1 -1
  22. package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
  23. package/packages/game/dist/types/entities/entity.d.ts +1 -0
  24. package/packages/game/dist/types/entities/entity.d.ts.map +1 -1
  25. package/packages/game/dist/types/entities/system.d.ts +7 -0
  26. package/packages/game/dist/types/entities/system.d.ts.map +1 -1
  27. package/packages/game/dist/types/entities/targets.d.ts.map +1 -1
  28. package/packages/game/dist/types/imports.d.ts +1 -0
  29. package/packages/game/dist/types/imports.d.ts.map +1 -1
  30. package/packages/game/dist/types/index.d.ts +2 -0
  31. package/packages/game/dist/types/index.d.ts.map +1 -1
  32. package/packages/game/dist/types/save/rerelease.d.ts.map +1 -1
  33. package/packages/game/dist/types/save/save.d.ts.map +1 -1
  34. package/packages/server/dist/index.cjs +4 -1
  35. package/packages/server/dist/index.js +4 -1
  36. package/packages/shared/dist/browser/index.global.js +1 -1
  37. package/packages/shared/dist/browser/index.global.js.map +1 -1
  38. package/packages/shared/dist/cjs/index.cjs +1 -0
  39. package/packages/shared/dist/cjs/index.cjs.map +1 -1
  40. package/packages/shared/dist/esm/index.js +1 -0
  41. package/packages/shared/dist/esm/index.js.map +1 -1
  42. package/packages/shared/dist/tsconfig.tsbuildinfo +1 -1
  43. package/packages/shared/dist/types/protocol/configstrings.d.ts +1 -0
  44. package/packages/shared/dist/types/protocol/configstrings.d.ts.map +1 -1
  45. package/packages/tools/dist/tsconfig.tsbuildinfo +1 -1
@@ -823,6 +823,7 @@ var init_esm = __esm({
823
823
  ConfigStringIndex2[ConfigStringIndex2["SkyAxis"] = 3] = "SkyAxis";
824
824
  ConfigStringIndex2[ConfigStringIndex2["SkyRotate"] = 4] = "SkyRotate";
825
825
  ConfigStringIndex2[ConfigStringIndex2["StatusBar"] = 5] = "StatusBar";
826
+ ConfigStringIndex2[ConfigStringIndex2["HealthBarName"] = 55] = "HealthBarName";
826
827
  ConfigStringIndex2[ConfigStringIndex2["CONFIG_N64_PHYSICS"] = 56] = "CONFIG_N64_PHYSICS";
827
828
  ConfigStringIndex2[ConfigStringIndex2["CONFIG_CTF_TEAMS"] = 57] = "CONFIG_CTF_TEAMS";
828
829
  ConfigStringIndex2[ConfigStringIndex2["CONFIG_COOP_RESPAWN_STRING"] = 58] = "CONFIG_COOP_RESPAWN_STRING";
@@ -2434,6 +2435,7 @@ var Entity = class {
2434
2435
  this.renderfx = 0;
2435
2436
  this.health = 0;
2436
2437
  this.max_health = 0;
2438
+ this.spawn_count = 0;
2437
2439
  this.takedamage = false;
2438
2440
  this.dmg = 0;
2439
2441
  this.radius_dmg = 0;
@@ -2583,6 +2585,7 @@ var Entity = class {
2583
2585
  this.renderfx = 0;
2584
2586
  this.health = 0;
2585
2587
  this.max_health = 0;
2588
+ this.spawn_count = 0;
2586
2589
  this.takedamage = false;
2587
2590
  this.dmg = 0;
2588
2591
  this.speed = 0;
@@ -2676,6 +2679,7 @@ var ENTITY_FIELD_METADATA = [
2676
2679
  { name: "renderfx", type: "int", save: true },
2677
2680
  { name: "health", type: "int", save: true },
2678
2681
  { name: "max_health", type: "int", save: true },
2682
+ { name: "spawn_count", type: "int", save: true },
2679
2683
  { name: "takedamage", type: "boolean", save: true },
2680
2684
  { name: "dmg", type: "int", save: true },
2681
2685
  { name: "speed", type: "float", save: true },
@@ -3865,6 +3869,7 @@ var EntitySystem = class {
3865
3869
  this.random = createRandomGenerator();
3866
3870
  this.currentTimeSeconds = 0;
3867
3871
  this.frameNumber = 0;
3872
+ this.spawnCount = 0;
3868
3873
  // Persistent state for cross-level logic
3869
3874
  this.crossLevelFlags = 0;
3870
3875
  this.crossUnitFlags = 0;
@@ -3903,6 +3908,8 @@ var EntitySystem = class {
3903
3908
  unicast: () => {
3904
3909
  },
3905
3910
  configstring: () => {
3911
+ },
3912
+ serverCommand: () => {
3906
3913
  }
3907
3914
  };
3908
3915
  this.imports = { ...defaultImports, ...imports };
@@ -3924,6 +3931,10 @@ var EntitySystem = class {
3924
3931
  sound2EntityFrame: 0,
3925
3932
  sightClient: null
3926
3933
  };
3934
+ this.level = {
3935
+ next_auto_save: 0,
3936
+ health_bar_entities: [null, null, null, null]
3937
+ };
3927
3938
  }
3928
3939
  get rng() {
3929
3940
  return this.random;
@@ -3972,6 +3983,8 @@ var EntitySystem = class {
3972
3983
  }
3973
3984
  spawn() {
3974
3985
  const ent = this.pool.spawn();
3986
+ this.spawnCount++;
3987
+ ent.spawn_count = this.spawnCount;
3975
3988
  ent.timestamp = this.currentTimeSeconds;
3976
3989
  return ent;
3977
3990
  }
@@ -4203,13 +4216,22 @@ var EntitySystem = class {
4203
4216
  sightClientIndex: this.targetAwareness.sightClient?.index ?? null
4204
4217
  },
4205
4218
  crossLevelFlags: this.crossLevelFlags,
4206
- crossUnitFlags: this.crossUnitFlags
4219
+ crossUnitFlags: this.crossUnitFlags,
4220
+ level: {
4221
+ next_auto_save: this.level.next_auto_save,
4222
+ health_bar_entities: [null, null, null, null]
4223
+ // Transient
4224
+ }
4207
4225
  };
4208
4226
  }
4209
4227
  restore(snapshot, callbackRegistry) {
4210
4228
  this.currentTimeSeconds = snapshot.timeSeconds;
4211
4229
  this.crossLevelFlags = snapshot.crossLevelFlags ?? 0;
4212
4230
  this.crossUnitFlags = snapshot.crossUnitFlags ?? 0;
4231
+ if (snapshot.level) {
4232
+ this.level = { ...snapshot.level };
4233
+ this.level.health_bar_entities = [null, null, null, null];
4234
+ }
4213
4235
  this.pool.restore(snapshot.pool);
4214
4236
  const indexToEntity = /* @__PURE__ */ new Map();
4215
4237
  for (const entity of this.pool) {
@@ -5601,6 +5623,82 @@ function registerTargetSpawns(registry) {
5601
5623
  entity.movedir = { x: start, y: end, z: slope };
5602
5624
  }
5603
5625
  });
5626
+ registry.register("target_music", (entity, { entities, keyValues }) => {
5627
+ entity.sounds = keyValues.sounds ? parseInt(keyValues.sounds) : 0;
5628
+ entity.use = (self) => {
5629
+ entities.imports.configstring(ConfigStringIndex.CdTrack, `${self.sounds}`);
5630
+ };
5631
+ });
5632
+ registry.register("target_autosave", (entity, context) => {
5633
+ entity.use = (self) => {
5634
+ const saveTime = 60;
5635
+ if (context.entities.timeSeconds - context.entities.level.next_auto_save > saveTime) {
5636
+ context.entities.imports.serverCommand("autosave\n");
5637
+ context.entities.level.next_auto_save = context.entities.timeSeconds;
5638
+ }
5639
+ };
5640
+ });
5641
+ registry.register("target_healthbar", (entity, { entities, warn, free }) => {
5642
+ entity.use = (self) => {
5643
+ const target = entities.pickTarget(self.target);
5644
+ if (!target || self.health !== target.spawn_count) {
5645
+ if (target) {
5646
+ warn(`${self.classname}: target ${target.classname} changed from what it used to be`);
5647
+ } else {
5648
+ warn(`${self.classname}: no target`);
5649
+ }
5650
+ entities.free(self);
5651
+ return;
5652
+ }
5653
+ const level = entities.level;
5654
+ let found = false;
5655
+ for (let i = 0; i < 4; i++) {
5656
+ if (!level.health_bar_entities[i]) {
5657
+ self.enemy = target;
5658
+ level.health_bar_entities[i] = self;
5659
+ entities.imports.configstring(ConfigStringIndex.HealthBarName, self.message || "");
5660
+ found = true;
5661
+ break;
5662
+ }
5663
+ }
5664
+ if (!found) {
5665
+ warn(`${self.classname}: too many health bars`);
5666
+ entities.free(self);
5667
+ }
5668
+ };
5669
+ entity.think = (self) => {
5670
+ const target = entities.pickTarget(self.target);
5671
+ if (!target || !(target.svflags & 4 /* Monster */)) {
5672
+ if (target) {
5673
+ warn(`${self.classname}: target ${target.classname} does not appear to be a monster`);
5674
+ }
5675
+ entities.free(self);
5676
+ return;
5677
+ }
5678
+ const level = entities.level;
5679
+ if (level.health_bar_entities) {
5680
+ let registered = false;
5681
+ for (let i = 0; i < 4; i++) {
5682
+ if (level.health_bar_entities[i] === self) {
5683
+ registered = true;
5684
+ break;
5685
+ }
5686
+ }
5687
+ if (!registered) {
5688
+ for (let i = 0; i < 4; i++) {
5689
+ if (!level.health_bar_entities[i]) {
5690
+ level.health_bar_entities[i] = self;
5691
+ entities.imports.configstring(ConfigStringIndex.HealthBarName, self.message || "");
5692
+ break;
5693
+ }
5694
+ }
5695
+ }
5696
+ }
5697
+ self.health = target.spawn_count;
5698
+ self.nextthink = entities.timeSeconds + 0.1;
5699
+ };
5700
+ entity.nextthink = entities.timeSeconds + 0.1;
5701
+ });
5604
5702
  }
5605
5703
 
5606
5704
  // src/entities/triggers.ts
@@ -17850,7 +17948,11 @@ function parseEntitySnapshot(raw) {
17850
17948
  thinks: parseThinkEntries(snapshot.thinks),
17851
17949
  awareness: parseAwareness(snapshot.awareness),
17852
17950
  crossLevelFlags: ensureNumberOrDefault(snapshot.crossLevelFlags, "entities.crossLevelFlags", 0),
17853
- crossUnitFlags: ensureNumberOrDefault(snapshot.crossUnitFlags, "entities.crossUnitFlags", 0)
17951
+ crossUnitFlags: ensureNumberOrDefault(snapshot.crossUnitFlags, "entities.crossUnitFlags", 0),
17952
+ level: {
17953
+ next_auto_save: 0,
17954
+ health_bar_entities: [null, null, null, null]
17955
+ }
17854
17956
  };
17855
17957
  }
17856
17958
  function parseCvars(raw) {
@@ -18214,7 +18316,11 @@ function buildEntitySnapshot(entities, levelTimeSeconds, capacityHint) {
18214
18316
  thinks: [],
18215
18317
  awareness: dummyAwareness,
18216
18318
  crossLevelFlags: 0,
18217
- crossUnitFlags: 0
18319
+ crossUnitFlags: 0,
18320
+ level: {
18321
+ next_auto_save: 0,
18322
+ health_bar_entities: [null, null, null, null]
18323
+ }
18218
18324
  };
18219
18325
  }
18220
18326
  function buildLevelState(level) {
@@ -19125,6 +19231,8 @@ function createGame(imports, engine, options) {
19125
19231
  });
19126
19232
  const configstring = imports.configstring || (() => {
19127
19233
  });
19234
+ const serverCommand = imports.serverCommand || (() => {
19235
+ });
19128
19236
  const linkentity = imports.linkentity;
19129
19237
  const wrappedLinkEntity = (ent) => {
19130
19238
  ent.absmin = {
@@ -19148,7 +19256,8 @@ function createGame(imports, engine, options) {
19148
19256
  linkentity: wrappedLinkEntity,
19149
19257
  multicast,
19150
19258
  unicast,
19151
- configstring
19259
+ configstring,
19260
+ serverCommand
19152
19261
  };
19153
19262
  const entities = new EntitySystem(engine, systemImports, gravity, void 0, void 0, deathmatch);
19154
19263
  entities._game = {
@@ -19416,6 +19525,9 @@ function createGame(imports, engine, options) {
19416
19525
  configstring(index, value) {
19417
19526
  configstring(index, value);
19418
19527
  },
19528
+ serverCommand(cmd) {
19529
+ serverCommand(cmd);
19530
+ },
19419
19531
  get time() {
19420
19532
  return levelClock.current.timeSeconds;
19421
19533
  },