mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-01 12:25:53 +08:00
commit
abac38a542
@ -29,6 +29,8 @@
|
||||
brostos!).
|
||||
- Fixes a bug where Meteor Shower could make the game-end bell sound twice
|
||||
(Thanks 3alTemp!).
|
||||
- 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 3alTemp!)
|
||||
|
||||
### 1.7.32 (build 21741, api 8, 2023-12-20)
|
||||
- Fixed a screen message that no one will ever see (Thanks vishal332008?...)
|
||||
|
||||
@ -529,6 +529,30 @@ 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 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).
|
||||
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',
|
||||
@ -591,6 +615,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):
|
||||
@ -617,3 +642,8 @@ 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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user