quake2ts 0.0.478 → 0.0.480

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.
@@ -25644,23 +25644,31 @@ function PlayerNoise(who, where, type, context) {
25644
25644
  noise.origin = { ...where };
25645
25645
  context.linkentity(noise);
25646
25646
  const awareness = context.targetAwareness;
25647
- if (!awareness) return;
25648
- if (type === PNOISE_WEAPON) {
25649
- if (awareness.soundEntity === noise) {
25650
- awareness.soundEntityFrame = awareness.frameNumber;
25651
- } else {
25652
- awareness.sound2Entity = awareness.soundEntity;
25653
- awareness.sound2EntityFrame = awareness.soundEntityFrame;
25654
- awareness.soundEntity = noise;
25655
- awareness.soundEntityFrame = awareness.frameNumber;
25656
- }
25657
- } else if (type === PNOISE_SELF) {
25658
- if (awareness.sightEntity === noise) {
25659
- awareness.sightEntityFrame = awareness.frameNumber;
25660
- } else {
25661
- awareness.sightClient = noise;
25647
+ if (awareness) {
25648
+ if (type === PNOISE_WEAPON) {
25649
+ if (awareness.soundEntity === noise) {
25650
+ awareness.soundEntityFrame = awareness.frameNumber;
25651
+ } else {
25652
+ awareness.sound2Entity = awareness.soundEntity;
25653
+ awareness.sound2EntityFrame = awareness.soundEntityFrame;
25654
+ awareness.soundEntity = noise;
25655
+ awareness.soundEntityFrame = awareness.frameNumber;
25656
+ }
25657
+ } else if (type === PNOISE_SELF) {
25658
+ if (awareness.sightEntity === noise) {
25659
+ awareness.sightEntityFrame = awareness.frameNumber;
25660
+ } else {
25661
+ awareness.sightClient = noise;
25662
+ }
25662
25663
  }
25663
25664
  }
25665
+ if (type === PNOISE_SELF || type === PNOISE_WEAPON) {
25666
+ who.client.sound_entity = noise;
25667
+ who.client.sound_entity_time = context.timeSeconds;
25668
+ } else {
25669
+ who.client.sound2_entity = noise;
25670
+ who.client.sound2_entity_time = context.timeSeconds;
25671
+ }
25664
25672
  }
25665
25673
 
25666
25674
  // src/entities/player.ts
@@ -25837,16 +25845,16 @@ function dropFlag(flag, origin, game, context) {
25837
25845
  flag.owner = null;
25838
25846
  flag.solid = 1 /* Trigger */;
25839
25847
  flag.model = flag.flagTeam === "red" ? "players/male/flag1.md2" : "players/male/flag2.md2";
25840
- const time = context.timeSeconds ?? game.time;
25848
+ const time = context.timeSeconds;
25841
25849
  flag.nextthink = time + 30;
25842
- game.centerprintf?.(flag, `The ${flag.flagTeam} flag was dropped!`);
25843
- flag.think = (selfEntity, ctx) => flagThink(selfEntity, ctx, game);
25850
+ context.engine.centerprintf?.(flag, `The ${flag.flagTeam} flag was dropped!`);
25851
+ flag.think = (selfEntity, ctx) => flagThink(selfEntity, ctx);
25844
25852
  }
25845
- function flagThink(self, context, game) {
25853
+ function flagThink(self, context) {
25846
25854
  const flag = self;
25847
25855
  if (flag.flagState === 2 /* DROPPED */) {
25848
- game.sound?.(flag, 0, "ctf/flagret.wav", 1, 1, 0);
25849
- game.centerprintf?.(flag, `The ${flag.flagTeam} flag returned to base!`);
25856
+ context.sound(flag, 0, "ctf/flagret.wav", 1, 1, 0);
25857
+ context.engine.centerprintf?.(flag, `The ${flag.flagTeam} flag returned to base!`);
25850
25858
  setFlagState(flag, 0 /* AT_BASE */, context);
25851
25859
  flag.origin = { ...flag.baseOrigin };
25852
25860
  flag.solid = 1 /* Trigger */;
@@ -25860,17 +25868,18 @@ function checkPlayerFlagDrop(player, sys) {
25860
25868
  const hasRedFlag = hasKey(player.client.inventory, "key_red_flag" /* RedFlag */);
25861
25869
  const hasBlueFlag = hasKey(player.client.inventory, "key_blue_flag" /* BlueFlag */);
25862
25870
  if (!hasRedFlag && !hasBlueFlag) return;
25871
+ let foundFlag = null;
25863
25872
  sys.forEachEntity((ent) => {
25864
25873
  const flag = ent;
25865
25874
  if ((flag.classname === "item_flag_team1" || flag.classname === "item_flag_team2") && flag.owner === player) {
25866
- const game = sys._game;
25867
- if (game) {
25868
- dropFlag(flag, player.origin, game, sys);
25869
- player.client.inventory.keys.delete("key_red_flag" /* RedFlag */);
25870
- player.client.inventory.keys.delete("key_blue_flag" /* BlueFlag */);
25871
- }
25875
+ foundFlag = flag;
25872
25876
  }
25873
25877
  });
25878
+ if (foundFlag) {
25879
+ dropFlag(foundFlag, player.origin, null, sys);
25880
+ player.client.inventory.keys.delete("key_red_flag" /* RedFlag */);
25881
+ player.client.inventory.keys.delete("key_blue_flag" /* BlueFlag */);
25882
+ }
25874
25883
  }
25875
25884
 
25876
25885
  // src/entities/player.ts