From d1defe0558f3d48e00a50493077e2f86d4534be0 Mon Sep 17 00:00:00 2001 From: TrialTemp Date: Fri, 5 Jan 2024 21:53:29 -0600 Subject: [PATCH 1/8] ctf fix implementation --- .../bascenev1lib/game/capturetheflag.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py b/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py index 4e5da2d6..4e615e23 100644 --- a/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py +++ b/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py @@ -519,6 +519,26 @@ class CaptureTheFlagGame(bs.TeamGameActivity[Player, Team]): if team.flag_return_touches < 0: logging.exception('CTF flag_return_touches < 0') + def _handle_death_flag_capture(self, player: Player) -> None: + """Handles flag values when a player dies or leaves the game.""" + # Don't do anything if the player hasn't touched the flag at all. + if not player.touching_own_flag: return + + team = player.team + # For each "point" our player has touched the flag (Could be multiple), + # deduct one from both our player and the flag's return touches variable. + for _ in range(player.touching_own_flag): + # Deduct + player.touching_own_flag -= 1 + team.flag_return_touches -= 1 + # Update our flag's timer accordingly (Prevents immediate resets in case there might be more people touching it). + if team.flag_return_touches == 0: + team.touch_return_timer = None + team.touch_return_timer_ticking = None + # Safety check, just to be sure! + if team.flag_return_touches < 0: + logging.exception('CTF flag_return_touches < 0') + def _flash_base(self, team: Team, length: float = 2.0) -> None: light = bs.newnode( 'light', @@ -579,6 +599,7 @@ class CaptureTheFlagGame(bs.TeamGameActivity[Player, Team]): def handlemessage(self, msg: Any) -> Any: if isinstance(msg, bs.PlayerDiedMessage): super().handlemessage(msg) # Augment standard behavior. + self._handle_death_flag_capture(msg.getplayer(Player)) self.respawn_player(msg.getplayer(Player)) elif isinstance(msg, FlagDiedMessage): @@ -605,3 +626,7 @@ class CaptureTheFlagGame(bs.TeamGameActivity[Player, Team]): else: super().handlemessage(msg) + + def on_player_leave(self, player: Player) -> None: + """Prevents leaving players from capturing their flag.""" + self._handle_death_flag_capture(player) From 33849603144f3bdd72771c018add1714bde09376 Mon Sep 17 00:00:00 2001 From: TrialTemp Date: Fri, 5 Jan 2024 22:05:36 -0600 Subject: [PATCH 2/8] preflight doing preflight things --- .../ba_data/python/bascenev1lib/game/capturetheflag.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py b/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py index 4e615e23..be8a5b44 100644 --- a/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py +++ b/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py @@ -522,12 +522,13 @@ class CaptureTheFlagGame(bs.TeamGameActivity[Player, Team]): def _handle_death_flag_capture(self, player: Player) -> None: """Handles flag values when a player dies or leaves the game.""" # Don't do anything if the player hasn't touched the flag at all. - if not player.touching_own_flag: return - + if not player.touching_own_flag: + return + team = player.team # For each "point" our player has touched the flag (Could be multiple), # deduct one from both our player and the flag's return touches variable. - for _ in range(player.touching_own_flag): + for _ in range(player.touching_own_flag): # Deduct player.touching_own_flag -= 1 team.flag_return_touches -= 1 From 71334c91e4eceb95d6ca52a9a33aa7cf1dd0c416 Mon Sep 17 00:00:00 2001 From: TrialTemp Date: Fri, 5 Jan 2024 22:08:24 -0600 Subject: [PATCH 3/8] Update CONTRIBUTORS.md --- CONTRIBUTORS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 8fccc544..534df263 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -50,3 +50,7 @@ ### Rikko - Created the original "reject_recently_left_players" plugin + +### Temp (3alTemp [TrialTemp]) +- Bug Fixer +- Cool QA fella from Discord \ No newline at end of file From 5d5b05a7d9e73e0bdf8315309570d6005ec7d786 Mon Sep 17 00:00:00 2001 From: TrialTemp Date: Fri, 5 Jan 2024 22:15:25 -0600 Subject: [PATCH 4/8] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c92ee54..9401f5e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ - Players now get points for killing bots with their own bombs by catching it and throwing it back at them. This is actually old logic but was disabled due to a logic flaw, but should be fixed now. (Thanks VinniTR!) +- Leaving the game or dying while touching your team's flag will no longer recover + & return it indefinitely in a teams game of Capture the Flag. (Thanks Temp!) ### 1.7.32 (build 21741, api 8, 2023-12-20) - Fixed a screen message that no one will ever see (Thanks vishal332008?...) From eb412ec8e1ef0c8a0357d73acf7f83cdc28792b6 Mon Sep 17 00:00:00 2001 From: TrialTemp Date: Sat, 6 Jan 2024 02:10:11 -0600 Subject: [PATCH 5/8] Long comments are now ILLEGAL --- .../ba_data/python/bascenev1lib/game/capturetheflag.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py b/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py index be8a5b44..edb6f898 100644 --- a/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py +++ b/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py @@ -526,13 +526,16 @@ class CaptureTheFlagGame(bs.TeamGameActivity[Player, Team]): return team = player.team - # For each "point" our player has touched the flag (Could be multiple), - # deduct one from both our player and the flag's return touches variable. + # For each "point" our player has touched theflag (Could be multiple), + # deduct one from both our player and + # the flag's return touches variable. for _ in range(player.touching_own_flag): # Deduct player.touching_own_flag -= 1 team.flag_return_touches -= 1 - # Update our flag's timer accordingly (Prevents immediate resets in case there might be more people touching it). + # Update our flag's timer accordingly + # (Prevents immediate resets in case + # there might be more people touching it). if team.flag_return_touches == 0: team.touch_return_timer = None team.touch_return_timer_ticking = None From 78ddc0b376faba79f48fa390031af89a64804cdd Mon Sep 17 00:00:00 2001 From: TrialTemp Date: Wed, 10 Jan 2024 14:40:15 -0600 Subject: [PATCH 6/8] made contributors desc consistent --- CONTRIBUTORS.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 534df263..626648a1 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -51,6 +51,5 @@ ### Rikko - Created the original "reject_recently_left_players" plugin -### Temp (3alTemp [TrialTemp]) -- Bug Fixer -- Cool QA fella from Discord \ No newline at end of file +### Temp (3alTemp) +- Modder & Bug Fixer \ No newline at end of file From b057a371baf335a483f76880b1d4b6c4218456b6 Mon Sep 17 00:00:00 2001 From: TrialTemp Date: Thu, 25 Jan 2024 16:31:12 -0600 Subject: [PATCH 7/8] hrm --- src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py b/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py index 267d8dd3..0e67426f 100644 --- a/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py +++ b/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py @@ -24,7 +24,7 @@ from bascenev1lib.actor.flag import ( ) if TYPE_CHECKING: - from typing import Any, Sequence + from typing import Any, Sequence, override class CTFFlag(Flag): @@ -643,6 +643,7 @@ class CaptureTheFlagGame(bs.TeamGameActivity[Player, Team]): else: super().handlemessage(msg) + @override def on_player_leave(self, player: Player) -> None: """Prevents leaving players from capturing their flag.""" self._handle_death_flag_capture(player) From 8f35aa8450c63a5b9cb606e7f6f2c26f9ee639f5 Mon Sep 17 00:00:00 2001 From: TrialTemp Date: Fri, 1 Mar 2024 19:53:46 -0600 Subject: [PATCH 8/8] I think --- src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py b/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py index 0e67426f..316483f9 100644 --- a/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py +++ b/src/assets/ba_data/python/bascenev1lib/game/capturetheflag.py @@ -24,7 +24,7 @@ from bascenev1lib.actor.flag import ( ) if TYPE_CHECKING: - from typing import Any, Sequence, override + from typing import Any, Sequence class CTFFlag(Flag):