[ci] auto-format

This commit is contained in:
brostosjoined 2024-01-24 11:26:19 +00:00 committed by github-actions[bot]
parent da505cd56b
commit 36673fc368
8 changed files with 1204 additions and 1124 deletions

View file

@ -305,7 +305,8 @@ class EggGame(bs.TeamGameActivity[Player, Team]):
'materials': (self._fake_wall_material, )
})))
pos = (0, 0.1, -5)
self.main_ground=bs.newnode('region',attrs={'position': pos,'scale': (25,0.001,22),'type': 'box','materials': [self.main_ground_material]})
self.main_ground = bs.newnode('region', attrs={'position': pos, 'scale': (
25, 0.001, 22), 'type': 'box', 'materials': [self.main_ground_material]})
self._update_scoreboard()
self._chant_sound.play()
@ -326,6 +327,7 @@ class EggGame(bs.TeamGameActivity[Player, Team]):
def _kill_puck(self) -> None:
self._puck = None
def _handle_egg_collision(self) -> None:
no = bs.getcollision().opposingnode
@ -335,7 +337,6 @@ class EggGame(bs.TeamGameActivity[Player, Team]):
if source_player == None or pos[0] < -8 or not source_player.node.exists():
return
try:
col = source_player.team.color
self.flagg = Flag(pos, touchable=False, color=col).autoretain()
@ -344,7 +345,6 @@ class EggGame(bs.TeamGameActivity[Player, Team]):
distance = math.sqrt(pow(player_pos[0]-pos[0], 2) + pow(player_pos[2]-pos[2], 2))
dis_mark = bs.newnode('text',
attrs={
@ -371,8 +371,8 @@ class EggGame(bs.TeamGameActivity[Player, Team]):
except ():
pass
def spawn_player(self, player: Player) -> bs.Actor:
def spawn_player(self, player: Player) -> bs.Actor:
zoo = random.randrange(-4, 5)
pos = (-11.204887390136719, 0.2998693287372589, zoo)
@ -383,6 +383,7 @@ class EggGame(bs.TeamGameActivity[Player, Team]):
# Prevent controlling of characters before the start of the race.
return spaz
def _handle_score(self) -> None:
"""A point has been scored."""
@ -481,6 +482,7 @@ class EggGame(bs.TeamGameActivity[Player, Team]):
# bs.animate(light, 'intensity', {0.0: 0, 0.25: 1, 0.5: 0}, loop=True)
# bs.timer(1.0, light.delete)
pass
def _spawn_puck(self) -> None:
# self._swipsound.play()
# self._whistle_sound.play()

View file

@ -1002,7 +1002,6 @@ class RaceGame(bs.TeamGameActivity[Player, Team]):
bs.timer(1.6, bs.WeakCall(self._bomb, 'impact',
(-1.5, 5, 0), (0, 0, 0), 1.0, 1.0, (0, 20, 3)), repeat=True)
bs.timer(1.6, bs.WeakCall(self._bomb, 'sticky',
(-1, 5, -8), (0, 10, 0), 1.0, 1.0), repeat=True)
bs.timer(1.6, bs.WeakCall(self._bomb, 'sticky',

View file

@ -17,9 +17,11 @@ from bascenev1lib.actor.onscreentimer import OnScreenTimer
if TYPE_CHECKING:
from typing import Any, Sequence, Optional, List, Dict, Type, Type
class _GotTouched():
pass
class UFO(bs.Actor):
def __init__(self, pos: float = (0, 0, 0)):
@ -43,15 +45,19 @@ class UFO(bs.Actor):
self.ufo_collide = None
def create_target(self):
if not self.node.exists(): return
if not self.node.exists():
return
self.dis = []
shared = SharedObjects.get()
try:
def pass_():
self.regs.clear()
bs.timer(3875*0.001, self.move)
try: bs.timer(3277*0.001, lambda: Bomb(velocity=(0,0,0), position=(self.target[0], self.node.position[1]-0.43999, self.target[2]), bomb_type='impact').autoretain().arm())
except: pass
try:
bs.timer(3277*0.001, lambda: Bomb(velocity=(0, 0, 0), position=(
self.target[0], self.node.position[1]-0.43999, self.target[2]), bomb_type='impact').autoretain().arm())
except:
pass
key = bs.Material()
key.add_actions(
conditions=('they_have_material', shared.object_material),
@ -60,7 +66,8 @@ class UFO(bs.Actor):
('modify_part_collision', 'physical', False),
('call', 'at_connect', pass_()),
))
except: pass
except:
pass
self.regs.append(bs.NodeActor(bs.newnode('region',
attrs={
'position': self.target,
@ -69,25 +76,32 @@ class UFO(bs.Actor):
'materials': [key]})))
def move(self):
if not self.node.exists(): return
if not self.node.exists():
return
try:
self.create_target()
for j in bs.getnodes():
n = j.getdelegate(object)
if j.getnodetype() == 'prop' and isinstance(n, TileFloor):
if n.node.exists(): self.dis.append(n.node)
if n.node.exists():
self.dis.append(n.node)
self.r = random.randint(0, len(self.dis)-1)
self.target = (self.dis[self.r].position[0], self.node.position[1], self.dis[self.r].position[2])
self.target = (self.dis[self.r].position[0],
self.node.position[1], self.dis[self.r].position[2])
bs.animate_array(self.node, 'position', 3, {
0: self.node.position,
3.0: self.target})
except: pass
except:
pass
def handlemessage(self, msg):
if isinstance(msg, bs.DieMessage):
self.node.delete()
elif isinstance(msg ,bs.OutOfBoundsMessage): self.handlemessage(bs.DieMessage())
else: super().handlemessage(msg)
elif isinstance(msg, bs.OutOfBoundsMessage):
self.handlemessage(bs.DieMessage())
else:
super().handlemessage(msg)
class TileFloor(bs.Actor):
@ -98,8 +112,10 @@ class TileFloor(bs.Actor):
self.pos = pos
self.scale = 1.5
self.mat, self.mat2, self.test = bs.Material(), bs.Material(), bs.Material()
self.mat.add_actions(conditions=('we_are_older_than', 1), actions=(('modify_part_collision', 'collide', False)))
self.mat2.add_actions(conditions=('we_are_older_than', 1), actions=(('modify_part_collision', 'collide', True)))
self.mat.add_actions(conditions=('we_are_older_than', 1),
actions=(('modify_part_collision', 'collide', False)))
self.mat2.add_actions(conditions=('we_are_older_than', 1),
actions=(('modify_part_collision', 'collide', True)))
self.test.add_actions(
conditions=('they_have_material', BombFactory.get().bomb_material),
actions=(
@ -125,6 +141,7 @@ class TileFloor(bs.Actor):
'type': 'box',
'materials': [get_mat.footing_material, self.mat2]
})
def handlemessage(self, msg):
if isinstance(msg, bs.DieMessage):
self.node.delete()
@ -132,58 +149,78 @@ class TileFloor(bs.Actor):
elif isinstance(msg, _GotTouched):
def do(): self.handlemessage(bs.DieMessage())
bs.timer(0.1, do)
else: super().handlemessage(msg)
else:
super().handlemessage(msg)
class defs():
points = boxes = {}
boxes['area_of_interest_bounds'] = (-1.3440, 1.185751251, 3.7326226188) + (
0.0, 0.0, 0.0) + (29.8180273, 15.57249038, 22.93859993)
boxes['map_bounds'] = (0.0, 2.585751251, 0.4326226188) + (0.0, 0.0, 0.0) + (29.09506485, 15.81173179, 33.76723155)
boxes['map_bounds'] = (0.0, 2.585751251, 0.4326226188) + (0.0, 0.0,
0.0) + (29.09506485, 15.81173179, 33.76723155)
class DummyMapForGame(bs.Map):
defs, name = defs(), 'Tile Lands'
@classmethod
def get_play_types(cls) -> List[str]:
return []
@classmethod
def get_preview_texture_name(cls) -> str:
return 'achievementCrossHair'
@classmethod
def on_preload(cls) -> Any:
data: Dict[str, Any] = {'bg_1': bs.gettexture('rampageBGColor'),'bg_2': bs.gettexture('rampageBGColor2'),'bg_mesh_1': bs.getmesh('rampageBG'),'bg_mesh_2': bs.getmesh('rampageBG2'),}
data: Dict[str, Any] = {'bg_1': bs.gettexture('rampageBGColor'), 'bg_2': bs.gettexture(
'rampageBGColor2'), 'bg_mesh_1': bs.getmesh('rampageBG'), 'bg_mesh_2': bs.getmesh('rampageBG2'), }
return data
def __init__(self) -> None:
super().__init__()
self.bg1 = bs.newnode('terrain',attrs={'mesh': self.preloaddata['bg_mesh_1'],'lighting': False,'background': True,'color_texture': self.preloaddata['bg_2']})
self.bg2 = bs.newnode('terrain',attrs={ 'mesh': self.preloaddata['bg_mesh_2'], 'lighting': False,'background': True, 'color_texture': self.preloaddata['bg_2']})
self.bg1 = bs.newnode('terrain', attrs={
'mesh': self.preloaddata['bg_mesh_1'], 'lighting': False, 'background': True, 'color_texture': self.preloaddata['bg_2']})
self.bg2 = bs.newnode('terrain', attrs={
'mesh': self.preloaddata['bg_mesh_2'], 'lighting': False, 'background': True, 'color_texture': self.preloaddata['bg_2']})
a = bs.getactivity().globalsnode
a.tint, a.ambient_color, a.vignette_outer, a.vignette_inner = (1.2, 1.1, 0.97), (1.3, 1.2, 1.03), (0.62, 0.64, 0.69), (0.97, 0.95, 0.93)
a.tint, a.ambient_color, a.vignette_outer, a.vignette_inner = (
1.2, 1.1, 0.97), (1.3, 1.2, 1.03), (0.62, 0.64, 0.69), (0.97, 0.95, 0.93)
class DummyMapForGame2(bs.Map):
defs, name = defs(), 'Tile Lands Night'
@classmethod
def get_play_types(cls) -> List[str]:
return []
@classmethod
def get_preview_texture_name(cls) -> str:
return 'achievementCrossHair'
@classmethod
def on_preload(cls) -> Any:
data: Dict[str, Any] = {'bg_1': bs.gettexture('menuBG'),'bg_2': bs.gettexture('menuBG'),'bg_mesh_1': bs.getmesh('thePadBG'),'bg_mesh_2': bs.getmesh('thePadBG'),}
data: Dict[str, Any] = {'bg_1': bs.gettexture('menuBG'), 'bg_2': bs.gettexture(
'menuBG'), 'bg_mesh_1': bs.getmesh('thePadBG'), 'bg_mesh_2': bs.getmesh('thePadBG'), }
return data
def __init__(self) -> None:
super().__init__()
self.bg1 = bs.newnode('terrain',attrs={'mesh': self.preloaddata['bg_mesh_1'],'lighting': False,'background': True,'color_texture': self.preloaddata['bg_2']})
self.bg2 = bs.newnode('terrain',attrs={ 'mesh': self.preloaddata['bg_mesh_2'], 'lighting': False,'background': True, 'color_texture': self.preloaddata['bg_2']})
self.bg1 = bs.newnode('terrain', attrs={
'mesh': self.preloaddata['bg_mesh_1'], 'lighting': False, 'background': True, 'color_texture': self.preloaddata['bg_2']})
self.bg2 = bs.newnode('terrain', attrs={
'mesh': self.preloaddata['bg_mesh_2'], 'lighting': False, 'background': True, 'color_texture': self.preloaddata['bg_2']})
a = bs.getactivity().globalsnode
a.tint, a.ambient_color, a.vignette_outer, a.vignette_inner = (0.5, 0.7, 1.27), (2.5, 2.5, 2.5), (0.62, 0.64, 0.69), (0.97, 0.95, 0.93)
a.tint, a.ambient_color, a.vignette_outer, a.vignette_inner = (
0.5, 0.7, 1.27), (2.5, 2.5, 2.5), (0.62, 0.64, 0.69), (0.97, 0.95, 0.93)
bs._map.register_map(DummyMapForGame)
bs._map.register_map(DummyMapForGame2)
class Player(bs.Player['Team']):
"""Our player type for this game."""
@ -215,9 +252,11 @@ class UFOAttackGame(bs.TeamGameActivity[Player, Team]):
# Print messages when players die (since its meaningful in this game).
announce_player_deaths = True
@classmethod
def get_supported_maps(cls, sessiontype: Type[bs.Session]) -> List[str]:
return ['Tile Lands', 'Tile Lands Night']
@classmethod
def supports_session_type(cls, sessiontype: Type[bs.Session]) -> bool:
return (issubclass(sessiontype, bs.DualTeamSession)
@ -237,7 +276,8 @@ class UFOAttackGame(bs.TeamGameActivity[Player, Team]):
if self._epic_mode else bs.MusicType.SURVIVAL)
if bool(settings["Display Map Area Dimension"]):
self.game_name = "UFO Attack " + "(" + str(self.col) + "x" + str(self.row) + ")"
else: self.game_name = "UFO Attack"
else:
self.game_name = "UFO Attack"
if self._epic_mode:
self.slow_motion = True
@ -280,7 +320,8 @@ class UFOAttackGame(bs.TeamGameActivity[Player, Team]):
if a.getnodetype() == 'prop' and isinstance(g, TileFloor):
dis.append(g.node)
r = random.randint(0, len(dis)-1)
spaz = self.spawn_player_spaz(player, position=(dis[r].position[0], dis[r].position[1]+1.005958, dis[r].position[2]))
spaz = self.spawn_player_spaz(player, position=(
dis[r].position[0], dis[r].position[1]+1.005958, dis[r].position[2]))
spaz.connect_controls_to_player(enable_punch=False,
enable_bomb=False,
enable_run=self.bool1,
@ -288,6 +329,7 @@ class UFOAttackGame(bs.TeamGameActivity[Player, Team]):
enable_pickup=False)
spaz.play_big_death_sound = True
return spaz
def handlemessage(self, msg: Any) -> Any:
if isinstance(msg, bs.PlayerDiedMessage):
super().handlemessage(msg)

View file

@ -176,6 +176,7 @@ class Team(bs.Team[Player]):
self.survival_seconds: Optional[int] = None
self.spawn_order: List[Player] = []
lang = bs.app.lang.language
if lang == 'Spanish':
description = 'Mantente en la zona segura.'
@ -187,6 +188,8 @@ else:
kill_timer = 'Kill timer: '
# ba_meta export bascenev1.GameActivity
class SafeZoneGame(bs.TeamGameActivity[Player, Team]):
"""Game type where last player(s) left alive win."""
@ -362,10 +365,14 @@ class SafeZoneGame(bs.TeamGameActivity[Player, Team]):
def spawn_zone(self):
self.zone_pos = (random.randrange(-10, 10), 0.05, random.randrange(-5, 5))
self.zone = bs.newnode('locator',attrs={'shape':'circle','position':self.zone_pos,'color':(1, 1, 0),'opacity':0.8,'draw_beauty':True,'additive':False,'drawShadow':False})
self.zone_limit = bs.newnode('locator',attrs={'shape':'circleOutline','position':self.zone_pos,'color':(1, 0.2, 0.2),'opacity':0.8,'draw_beauty':True,'additive':False,'drawShadow':False})
bs.animate_array(self.zone, 'size', 1,{0:[0], 0.3:[self.get_players_count()*0.85], 0.35:[self.get_players_count()*0.8]})
bs.animate_array(self.zone_limit, 'size', 1,{0:[0], 0.3:[self.get_players_count()*1.2], 0.35:[self.get_players_count()*0.95]})
self.zone = bs.newnode('locator', attrs={'shape': 'circle', 'position': self.zone_pos, 'color': (
1, 1, 0), 'opacity': 0.8, 'draw_beauty': True, 'additive': False, 'drawShadow': False})
self.zone_limit = bs.newnode('locator', attrs={'shape': 'circleOutline', 'position': self.zone_pos, 'color': (
1, 0.2, 0.2), 'opacity': 0.8, 'draw_beauty': True, 'additive': False, 'drawShadow': False})
bs.animate_array(self.zone, 'size', 1, {0: [0], 0.3: [
self.get_players_count()*0.85], 0.35: [self.get_players_count()*0.8]})
bs.animate_array(self.zone_limit, 'size', 1, {0: [0], 0.3: [
self.get_players_count()*1.2], 0.35: [self.get_players_count()*0.95]})
self.last_players_count = self.get_players_count()
bs.getsound('laserReverse').play()
self.start_timer()
@ -380,11 +387,15 @@ class SafeZoneGame(bs.TeamGameActivity[Player, Team]):
bs.timer(1, self.spawn_zone)
def move_zone(self):
if self.zone_pos[0] > 0: x = random.randrange(0,10)
else: x = random.randrange(-10,0)
if self.zone_pos[0] > 0:
x = random.randrange(0, 10)
else:
x = random.randrange(-10, 0)
if self.zone_pos[2] > 0: y = random.randrange(0,5)
else: y = random.randrange(-5,0)
if self.zone_pos[2] > 0:
y = random.randrange(0, 5)
else:
y = random.randrange(-5, 0)
new_pos = (x, 0.05, y)
bs.animate_array(self.zone, 'position', 3, {0: self.zone.position, 8: new_pos})
@ -418,8 +429,10 @@ class SafeZoneGame(bs.TeamGameActivity[Player, Team]):
def check_players(self):
if self._time_remaining <= 0:
self.stop_timer()
bs.animate_array(self.zone, 'size', 1,{0:[self.last_players_count*0.8], 1.4:[self.last_players_count*0.8],1.5:[0]})
bs.animate_array(self.zone_limit, 'size', 1,{0:[self.last_players_count*0.95], 1.45:[self.last_players_count*0.95],1.5:[0]})
bs.animate_array(self.zone, 'size', 1, {
0: [self.last_players_count*0.8], 1.4: [self.last_players_count*0.8], 1.5: [0]})
bs.animate_array(self.zone_limit, 'size', 1, {
0: [self.last_players_count*0.95], 1.45: [self.last_players_count*0.95], 1.5: [0]})
bs.timer(1.5, self.delete_zone)
for player in self.players:
if not player.actor is None:
@ -654,10 +667,14 @@ class SafeZoneGame(bs.TeamGameActivity[Player, Team]):
spaz._charge_speed = self._get_bot_speed(spaz_type)
def add_bot(self, pos=None):
if pos == 'left': position = (-11,0,random.randrange(-5,5))
elif pos == 'right': position = (11,0,random.randrange(-5,5))
else: position = pos
self._bots.spawn_bot(self.get_random_bot(),pos=position,spawn_time=1,on_spawn_call=babase.Call(self._on_bot_spawn))
if pos == 'left':
position = (-11, 0, random.randrange(-5, 5))
elif pos == 'right':
position = (11, 0, random.randrange(-5, 5))
else:
position = pos
self._bots.spawn_bot(self.get_random_bot(), pos=position, spawn_time=1,
on_spawn_call=babase.Call(self._on_bot_spawn))
def move_bot(self, bot):
p = bot.node.position

View file

@ -18,6 +18,8 @@ if TYPE_CHECKING:
Spaz._old_init = Spaz.__init__
def __init__(self,
color: Sequence[float] = (1.0, 1.0, 1.0),
highlight: Sequence[float] = (0.5, 0.5, 0.5),
@ -31,6 +33,7 @@ def __init__(self,
can_accept_powerups, powerups_expire, demo_mode)
if self.source_player:
self.equip_shields()
def animate_shield():
if not self.shield:
return
@ -41,6 +44,7 @@ def __init__(self,
bs.timer(0.2, animate_shield, repeat=True)
self.impact_scale = 0
def equip_shields(self, decay: bool = False) -> None:
"""
Give this spaz a nice energy shield.

View file

@ -52,18 +52,22 @@ Configs = {
}
# Useful global fucntions
def setconfigs() -> None:
"""
Set required defualt configs for mod
"""
cnfg = babase.app.config
profiles = cnfg['Player Profiles']
if not "TagConf" in cnfg: cnfg["TagConf"] = {}
if not "TagConf" in cnfg:
cnfg["TagConf"] = {}
for p in profiles:
if not p in cnfg["TagConf"]:
cnfg["TagConf"][str(p)] = Configs
babase.app.config.apply_and_commit()
def getanimcolor(name: str) -> dict:
"""
Returns dictnary of colors with prefective time -> {seconds: (r, g, b)}
@ -80,6 +84,7 @@ def getanimcolor(name: str) -> dict:
}
return animcolor
def gethostname() -> str:
"""
Return player name, by using -1 only host can use tags.
@ -94,11 +99,14 @@ def gethostname() -> str:
return '__account__'
return name
# Dummy functions for extend functionality for class object
PlayerSpaz.init = PlayerSpaz.__init__
EditProfileWindow.init = EditProfileWindow.__init__
# PlayerSpaz object at -> bascenev1lib.actor.playerspaz
def NewPlayerSzapInit(self,
player: bs.Player,
color: Sequence[float] = (1.0, 1.0, 1.0),
@ -112,7 +120,8 @@ def NewPlayerSzapInit(self,
cnfg = babase.app.config["TagConf"]
if cnfg[str(self.curname)]["enabletag"]:
# Tag node
self.mnode = bs.newnode('math', owner=self.node, attrs={'input1': (0, 1.5, 0),'operation': 'add'})
self.mnode = bs.newnode('math', owner=self.node, attrs={
'input1': (0, 1.5, 0), 'operation': 'add'})
self.node.connectattr('torso_position', self.mnode, 'input2')
tagtext = cnfg[str(self.curname)]["tag"]
@ -138,7 +147,8 @@ def NewPlayerSzapInit(self,
if cnfg[str(self.curname)]["animtag"]:
kys = getanimcolor(self.curname)
bs.animate_array(node=self.Tag, attr='color', size=3, keys=kys, loop=True)
except Exception: pass
except Exception:
pass
def NewEditProfileWindowInit(self,
@ -168,6 +178,7 @@ def NewEditProfileWindowInit(self,
text_scale=1.2,
on_activate_call=babase.Call(_on_tagwinbtn_press, self))
def _on_tagwinbtn_press(self):
"""
Calls tag config window passes all paramisters
@ -558,7 +569,8 @@ class CustomConfigNumberEdit:
self._update_display()
if self._callback:
self._callback(self._value)
babase.app.config[self._configkey[0]][self._configkey[1]][self._configkey[2]] = float(str(f'{self._value:.1f}'))
babase.app.config[self._configkey[0]][self._configkey[1]
][self._configkey[2]] = float(str(f'{self._value:.1f}'))
babase.app.config.apply_and_commit()
def _update_display(self) -> None:

View file

@ -12,13 +12,17 @@ from bascenev1lib.gameutils import SharedObjects
if TYPE_CHECKING:
pass
class BombPickupMessage:
""" message says that someone pick up the dropped bomb """
# for bs.FreezeMessage
freeze: bool = True
# ba_meta export plugin
class Plugin(babase.Plugin):
# there are two ways to ignore our team player hits