quake2ts 0.0.479 → 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.
@@ -25845,16 +25845,16 @@ function dropFlag(flag, origin, game, context) {
25845
25845
  flag.owner = null;
25846
25846
  flag.solid = 1 /* Trigger */;
25847
25847
  flag.model = flag.flagTeam === "red" ? "players/male/flag1.md2" : "players/male/flag2.md2";
25848
- const time = context.timeSeconds ?? game.time;
25848
+ const time = context.timeSeconds;
25849
25849
  flag.nextthink = time + 30;
25850
- game.centerprintf?.(flag, `The ${flag.flagTeam} flag was dropped!`);
25851
- 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);
25852
25852
  }
25853
- function flagThink(self, context, game) {
25853
+ function flagThink(self, context) {
25854
25854
  const flag = self;
25855
25855
  if (flag.flagState === 2 /* DROPPED */) {
25856
- game.sound?.(flag, 0, "ctf/flagret.wav", 1, 1, 0);
25857
- 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!`);
25858
25858
  setFlagState(flag, 0 /* AT_BASE */, context);
25859
25859
  flag.origin = { ...flag.baseOrigin };
25860
25860
  flag.solid = 1 /* Trigger */;
@@ -25868,17 +25868,18 @@ function checkPlayerFlagDrop(player, sys) {
25868
25868
  const hasRedFlag = hasKey(player.client.inventory, "key_red_flag" /* RedFlag */);
25869
25869
  const hasBlueFlag = hasKey(player.client.inventory, "key_blue_flag" /* BlueFlag */);
25870
25870
  if (!hasRedFlag && !hasBlueFlag) return;
25871
+ let foundFlag = null;
25871
25872
  sys.forEachEntity((ent) => {
25872
25873
  const flag = ent;
25873
25874
  if ((flag.classname === "item_flag_team1" || flag.classname === "item_flag_team2") && flag.owner === player) {
25874
- const game = sys._game;
25875
- if (game) {
25876
- dropFlag(flag, player.origin, game, sys);
25877
- player.client.inventory.keys.delete("key_red_flag" /* RedFlag */);
25878
- player.client.inventory.keys.delete("key_blue_flag" /* BlueFlag */);
25879
- }
25875
+ foundFlag = flag;
25880
25876
  }
25881
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
+ }
25882
25883
  }
25883
25884
 
25884
25885
  // src/entities/player.ts