mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-11-07 17:36:00 +00:00
Needs some testing
This commit is contained in:
parent
1bce1d7d76
commit
4719c3e718
23 changed files with 2124 additions and 1626 deletions
|
|
@ -1,3 +1,4 @@
|
|||
# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport)
|
||||
# Released under the MIT License. See LICENSE for details.
|
||||
#
|
||||
# By itsre3
|
||||
|
|
@ -6,39 +7,41 @@
|
|||
# Besides that, enjoy.......!!
|
||||
"""Provides the chosen-one mini-game."""
|
||||
|
||||
# ba_meta require api 7
|
||||
# ba_meta require api 8
|
||||
# (see https://ballistica.net/wiki/meta-tag-system)
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import ba
|
||||
from bastd.actor.flag import Flag
|
||||
from bastd.actor.playerspaz import PlayerSpaz
|
||||
from bastd.actor.scoreboard import Scoreboard
|
||||
from bastd.gameutils import SharedObjects
|
||||
import babase
|
||||
import bauiv1 as bui
|
||||
import bascenev1 as bs
|
||||
from bascenev1lib.actor.flag import Flag
|
||||
from bascenev1lib.actor.playerspaz import PlayerSpaz
|
||||
from bascenev1lib.actor.scoreboard import Scoreboard
|
||||
from bascenev1lib.gameutils import SharedObjects
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any, Type, List, Dict, Optional, Sequence, Union
|
||||
|
||||
|
||||
class Player(ba.Player['Team']):
|
||||
class Player(bs.Player['Team']):
|
||||
"""Our player type for this game."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.chosen_light: Optional[ba.NodeActor] = None
|
||||
self.chosen_light: Optional[bs.NodeActor] = None
|
||||
|
||||
|
||||
class Team(ba.Team[Player]):
|
||||
class Team(bs.Team[Player]):
|
||||
"""Our team type for this game."""
|
||||
|
||||
def __init__(self, time_remaining: int) -> None:
|
||||
self.time_remaining = time_remaining
|
||||
|
||||
|
||||
# ba_meta export game
|
||||
class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
||||
# ba_meta export bascenev1.GameActivity
|
||||
class InvicibleOneGame(bs.TeamGameActivity[Player, Team]):
|
||||
"""
|
||||
Game involving trying to remain the one 'invisible one'
|
||||
for a set length of time while everyone else tries to
|
||||
|
|
@ -49,15 +52,15 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
|||
description = ('Be the invisible one for a length of time to win.\n'
|
||||
'Kill the invisible one to become it.')
|
||||
available_settings = [
|
||||
ba.IntSetting(
|
||||
bs.IntSetting(
|
||||
'Invicible One Time',
|
||||
min_value=10,
|
||||
default=30,
|
||||
increment=10,
|
||||
),
|
||||
ba.BoolSetting('Invicible one is lazy', default=True),
|
||||
ba.BoolSetting('Night mode', default=False),
|
||||
ba.IntChoiceSetting(
|
||||
bs.BoolSetting('Invicible one is lazy', default=True),
|
||||
bs.BoolSetting('Night mode', default=False),
|
||||
bs.IntChoiceSetting(
|
||||
'Time Limit',
|
||||
choices=[
|
||||
('None', 0),
|
||||
|
|
@ -69,7 +72,7 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
|||
],
|
||||
default=0,
|
||||
),
|
||||
ba.FloatChoiceSetting(
|
||||
bs.FloatChoiceSetting(
|
||||
'Respawn Times',
|
||||
choices=[
|
||||
('Shorter', 0.25),
|
||||
|
|
@ -80,35 +83,35 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
|||
],
|
||||
default=1.0,
|
||||
),
|
||||
ba.BoolSetting('Epic Mode', default=False),
|
||||
bs.BoolSetting('Epic Mode', default=False),
|
||||
]
|
||||
scoreconfig = ba.ScoreConfig(label='Time Held')
|
||||
scoreconfig = bs.ScoreConfig(label='Time Held')
|
||||
|
||||
@classmethod
|
||||
def get_supported_maps(cls, sessiontype: Type[ba.Session]) -> List[str]:
|
||||
return ba.getmaps('keep_away')
|
||||
def get_supported_maps(cls, sessiontype: Type[bs.Session]) -> List[str]:
|
||||
return bs.app.classic.getmaps('keep_away')
|
||||
|
||||
def __init__(self, settings: dict):
|
||||
super().__init__(settings)
|
||||
self._scoreboard = Scoreboard()
|
||||
self._invicible_one_player: Optional[Player] = None
|
||||
self._swipsound = ba.getsound('swip')
|
||||
self._countdownsounds: Dict[int, ba.Sound] = {
|
||||
10: ba.getsound('announceTen'),
|
||||
9: ba.getsound('announceNine'),
|
||||
8: ba.getsound('announceEight'),
|
||||
7: ba.getsound('announceSeven'),
|
||||
6: ba.getsound('announceSix'),
|
||||
5: ba.getsound('announceFive'),
|
||||
4: ba.getsound('announceFour'),
|
||||
3: ba.getsound('announceThree'),
|
||||
2: ba.getsound('announceTwo'),
|
||||
1: ba.getsound('announceOne')
|
||||
self._swipsound = bs.getsound('swip')
|
||||
self._countdownsounds: Dict[int, babase.Sound] = {
|
||||
10: bs.getsound('announceTen'),
|
||||
9: bs.getsound('announceNine'),
|
||||
8: bs.getsound('announceEight'),
|
||||
7: bs.getsound('announceSeven'),
|
||||
6: bs.getsound('announceSix'),
|
||||
5: bs.getsound('announceFive'),
|
||||
4: bs.getsound('announceFour'),
|
||||
3: bs.getsound('announceThree'),
|
||||
2: bs.getsound('announceTwo'),
|
||||
1: bs.getsound('announceOne')
|
||||
}
|
||||
self._flag_spawn_pos: Optional[Sequence[float]] = None
|
||||
self._reset_region_material: Optional[ba.Material] = None
|
||||
self._reset_region_material: Optional[bs.Material] = None
|
||||
self._flag: Optional[Flag] = None
|
||||
self._reset_region: Optional[ba.Node] = None
|
||||
self._reset_region: Optional[bs.Node] = None
|
||||
self._epic_mode = bool(settings['Epic Mode'])
|
||||
self._invicible_one_time = int(settings['Invicible One Time'])
|
||||
self._time_limit = float(settings['Time Limit'])
|
||||
|
|
@ -117,13 +120,13 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
|||
|
||||
# Base class overrides
|
||||
self.slow_motion = self._epic_mode
|
||||
self.default_music = (ba.MusicType.EPIC
|
||||
if self._epic_mode else ba.MusicType.CHOSEN_ONE)
|
||||
self.default_music = (bs.MusicType.EPIC
|
||||
if self._epic_mode else bs.MusicType.CHOSEN_ONE)
|
||||
|
||||
def get_instance_description(self) -> Union[str, Sequence]:
|
||||
return 'Show your invisibility powers.'
|
||||
|
||||
def create_team(self, sessionteam: ba.SessionTeam) -> Team:
|
||||
def create_team(self, sessionteam: bs.SessionTeam) -> Team:
|
||||
return Team(time_remaining=self._invicible_one_time)
|
||||
|
||||
def on_team_join(self, team: Team) -> None:
|
||||
|
|
@ -143,13 +146,13 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
|||
Flag.project_stand(self._flag_spawn_pos)
|
||||
self._set_invicible_one_player(None)
|
||||
if self._night_mode:
|
||||
gnode = ba.getactivity().globalsnode
|
||||
gnode = bs.getactivity().globalsnode
|
||||
gnode.tint = (0.4, 0.4, 0.4)
|
||||
|
||||
pos = self._flag_spawn_pos
|
||||
ba.timer(1.0, call=self._tick, repeat=True)
|
||||
bs.timer(1.0, call=self._tick, repeat=True)
|
||||
|
||||
mat = self._reset_region_material = ba.Material()
|
||||
mat = self._reset_region_material = bs.Material()
|
||||
mat.add_actions(
|
||||
conditions=(
|
||||
'they_have_material',
|
||||
|
|
@ -159,11 +162,11 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
|||
('modify_part_collision', 'collide', True),
|
||||
('modify_part_collision', 'physical', False),
|
||||
('call', 'at_connect',
|
||||
ba.WeakCall(self._handle_reset_collide)),
|
||||
bs.WeakCall(self._handle_reset_collide)),
|
||||
),
|
||||
)
|
||||
|
||||
self._reset_region = ba.newnode('region',
|
||||
self._reset_region = bs.newnode('region',
|
||||
attrs={
|
||||
'position': (pos[0], pos[1] + 0.75,
|
||||
pos[2]),
|
||||
|
|
@ -185,24 +188,24 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
|||
|
||||
# Attempt to get a Player controlling a Spaz that we hit.
|
||||
try:
|
||||
player = ba.getcollision().opposingnode.getdelegate(
|
||||
player = bs.getcollision().opposingnode.getdelegate(
|
||||
PlayerSpaz, True).getplayer(Player, True)
|
||||
except ba.NotFoundError:
|
||||
except bs.NotFoundError:
|
||||
return
|
||||
|
||||
if player.is_alive():
|
||||
self._set_invicible_one_player(player)
|
||||
|
||||
def _flash_flag_spawn(self) -> None:
|
||||
light = ba.newnode('light',
|
||||
light = bs.newnode('light',
|
||||
attrs={
|
||||
'position': self._flag_spawn_pos,
|
||||
'color': (1, 1, 1),
|
||||
'radius': 0.3,
|
||||
'height_attenuated': False
|
||||
})
|
||||
ba.animate(light, 'intensity', {0: 0, 0.25: 0.5, 0.5: 0}, loop=True)
|
||||
ba.timer(1.0, light.delete)
|
||||
bs.animate(light, 'intensity', {0: 0, 0.25: 0.5, 0.5: 0}, loop=True)
|
||||
bs.timer(1.0, light.delete)
|
||||
|
||||
def _tick(self) -> None:
|
||||
|
||||
|
|
@ -212,7 +215,7 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
|||
|
||||
# This shouldn't happen, but just in case.
|
||||
if not player.is_alive():
|
||||
ba.print_error('got dead player as chosen one in _tick')
|
||||
babase.print_error('got dead player as chosen one in _tick')
|
||||
self._set_invicible_one_player(None)
|
||||
else:
|
||||
scoring_team = player.team
|
||||
|
|
@ -229,9 +232,7 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
|||
|
||||
# announce numbers we have sounds for
|
||||
if scoring_team.time_remaining in self._countdownsounds:
|
||||
ba.playsound(
|
||||
self._countdownsounds[scoring_team.time_remaining])
|
||||
|
||||
self._countdownsounds[scoring_team.time_remaining].play()
|
||||
# Winner!
|
||||
if scoring_team.time_remaining <= 0:
|
||||
self.end_game()
|
||||
|
|
@ -242,11 +243,11 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
|||
# (Chosen-one player ceasing to exist should
|
||||
# trigger on_player_leave which resets chosen-one)
|
||||
if self._invicible_one_player is not None:
|
||||
ba.print_error('got nonexistent player as chosen one in _tick')
|
||||
babase.print_error('got nonexistent player as chosen one in _tick')
|
||||
self._set_invicible_one_player(None)
|
||||
|
||||
def end_game(self) -> None:
|
||||
results = ba.GameResults()
|
||||
results = bs.GameResults()
|
||||
for team in self.teams:
|
||||
results.set_team_score(team,
|
||||
self._invicible_one_time - team.time_remaining)
|
||||
|
|
@ -256,7 +257,7 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
|||
existing = self._get_invicible_one_player()
|
||||
if existing:
|
||||
existing.chosen_light = None
|
||||
ba.playsound(self._swipsound)
|
||||
self._swipsound.play()
|
||||
if not player:
|
||||
assert self._flag_spawn_pos is not None
|
||||
self._flag = Flag(color=(1, 0.9, 0.2),
|
||||
|
|
@ -266,7 +267,7 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
|||
|
||||
# Create a light to highlight the flag;
|
||||
# this will go away when the flag dies.
|
||||
ba.newnode('light',
|
||||
bs.newnode('light',
|
||||
owner=self._flag.node,
|
||||
attrs={
|
||||
'position': self._flag_spawn_pos,
|
||||
|
|
@ -287,18 +288,18 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
|||
if self._invicible_one_is_lazy:
|
||||
player.actor.connect_controls_to_player(
|
||||
enable_punch=False, enable_pickup=False, enable_bomb=False)
|
||||
if player.actor.node.torso_model != None:
|
||||
if player.actor.node.torso_mesh != None:
|
||||
player.actor.node.color_mask_texture = None
|
||||
player.actor.node.color_texture = None
|
||||
player.actor.node.head_model = None
|
||||
player.actor.node.torso_model = None
|
||||
player.actor.node.upper_arm_model = None
|
||||
player.actor.node.forearm_model = None
|
||||
player.actor.node.pelvis_model = None
|
||||
player.actor.node.toes_model = None
|
||||
player.actor.node.upper_leg_model = None
|
||||
player.actor.node.lower_leg_model = None
|
||||
player.actor.node.hand_model = None
|
||||
player.actor.node.head_mesh = None
|
||||
player.actor.node.torso_mesh = None
|
||||
player.actor.node.upper_arm_mesh = None
|
||||
player.actor.node.forearm_mesh = None
|
||||
player.actor.node.pelvis_mesh = None
|
||||
player.actor.node.toes_mesh = None
|
||||
player.actor.node.upper_leg_mesh = None
|
||||
player.actor.node.lower_leg_mesh = None
|
||||
player.actor.node.hand_mesh = None
|
||||
player.actor.node.style = 'cyborg'
|
||||
invi_sound = []
|
||||
player.actor.node.jump_sounds = invi_sound
|
||||
|
|
@ -311,7 +312,7 @@ class InvicibleOneGame(ba.TeamGameActivity[Player, Team]):
|
|||
player.actor.node.name = ''
|
||||
|
||||
def handlemessage(self, msg: Any) -> Any:
|
||||
if isinstance(msg, ba.PlayerDiedMessage):
|
||||
if isinstance(msg, bs.PlayerDiedMessage):
|
||||
# Augment standard behavior.
|
||||
super().handlemessage(msg)
|
||||
player = msg.getplayer(Player)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue