quake2ts 0.0.489 → 0.0.491

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.
@@ -10570,6 +10570,49 @@ function setFlagState(flag, newState, context) {
10570
10570
  flag.flagState = newState;
10571
10571
  }
10572
10572
 
10573
+ // src/modes/ctf/capture.ts
10574
+ function checkCapture(flag, player, game, context) {
10575
+ if (!player.client) return false;
10576
+ const playerTeam = player.client.team || "red";
10577
+ if (flag.flagTeam !== playerTeam) {
10578
+ return false;
10579
+ }
10580
+ if (flag.flagState !== 0 /* AT_BASE */) {
10581
+ return false;
10582
+ }
10583
+ const enemyFlagKey = playerTeam === "red" ? "key_blue_flag" /* BlueFlag */ : "key_red_flag" /* RedFlag */;
10584
+ if (hasKey(player.client.inventory, enemyFlagKey)) {
10585
+ return captureFlag(flag, player, game, context);
10586
+ }
10587
+ return false;
10588
+ }
10589
+ function captureFlag(ownFlag, player, game, context) {
10590
+ if (!player.client) return false;
10591
+ const playerTeam = player.client.team || "red";
10592
+ const enemyTeam = playerTeam === "red" ? "blue" : "red";
10593
+ if (player.client.score !== void 0) {
10594
+ player.client.score += 5;
10595
+ } else {
10596
+ player.client.score = 5;
10597
+ }
10598
+ game.sound?.(player, 0, "ctf/flagcap.wav", 1, 1, 0);
10599
+ game.centerprintf?.(player, "You captured the flag!");
10600
+ const enemyFlagKey = playerTeam === "red" ? "key_blue_flag" /* BlueFlag */ : "key_red_flag" /* RedFlag */;
10601
+ player.client.inventory.keys.delete(enemyFlagKey);
10602
+ context.forEachEntity((ent) => {
10603
+ const flag = ent;
10604
+ if ((flag.classname === "item_flag_team1" || flag.classname === "item_flag_team2") && flag.flagTeam === enemyTeam) {
10605
+ setFlagState(flag, 0 /* AT_BASE */, context);
10606
+ flag.origin = { ...flag.baseOrigin };
10607
+ flag.solid = 1 /* Trigger */;
10608
+ flag.owner = null;
10609
+ flag.model = flag.flagTeam === "red" ? "players/male/flag1.md2" : "players/male/flag2.md2";
10610
+ flag.svflags &= ~1;
10611
+ }
10612
+ });
10613
+ return true;
10614
+ }
10615
+
10573
10616
  // src/modes/ctf/flag.ts
10574
10617
  function createFlagPickupEntity(game, flagItem) {
10575
10618
  const isRed = flagItem.team === "red";
@@ -10604,6 +10647,9 @@ function createFlagPickupEntity(game, flagItem) {
10604
10647
  const sameTeam = self.flagTeam === playerTeam;
10605
10648
  if (sameTeam) {
10606
10649
  if (self.flagState === 0 /* AT_BASE */) {
10650
+ if (checkCapture(self, other, game, game.entities)) {
10651
+ return;
10652
+ }
10607
10653
  return;
10608
10654
  }
10609
10655
  if (self.flagState === 2 /* DROPPED */) {