This commit is contained in:
brostosjoined 2024-02-01 11:58:22 +03:00
commit 35d4e45915
2 changed files with 542 additions and 493 deletions

View file

@ -70,7 +70,8 @@ class BotChaseGame(bs.TeamGameActivity[Player, Team]):
@classmethod @classmethod
def supports_session_type(cls, sessiontype: Type[bs.Session]) -> bool: def supports_session_type(cls, sessiontype: Type[bs.Session]) -> bool:
return (issubclass(sessiontype, bs.FreeForAllSession) or issubclass(sessiontype, bs.DualTeamSession) or issubclass(sessiontype, bs.CoopSession)) # Coop session unused # Coop session unused
return (issubclass(sessiontype, bs.FreeForAllSession) or issubclass(sessiontype, bs.DualTeamSession) or issubclass(sessiontype, bs.CoopSession))
def __init__(self, settings: dict): def __init__(self, settings: dict):
super().__init__(settings) super().__init__(settings)
@ -136,8 +137,10 @@ class BotChaseGame(bs.TeamGameActivity[Player, Team]):
def on_begin(self) -> None: def on_begin(self) -> None:
super().on_begin() super().on_begin()
self._bots.spawn_bot(MrSpazBot, pos=(random.choice([1, -1, 2, -2]), 1.34, random.choice([1, -1, 2, -2])), spawn_time=2.0) self._bots.spawn_bot(MrSpazBot, pos=(random.choice(
self._bots.spawn_bot(MrSpazBot, pos=(random.choice([1, -1, 2, -2]), 1.34, random.choice([1, -1, 2, -2])), spawn_time=2.0) [1, -1, 2, -2]), 1.34, random.choice([1, -1, 2, -2])), spawn_time=2.0)
self._bots.spawn_bot(MrSpazBot, pos=(random.choice(
[1, -1, 2, -2]), 1.34, random.choice([1, -1, 2, -2])), spawn_time=2.0)
self._timer = OnScreenTimer() self._timer = OnScreenTimer()
self._timer.start() self._timer.start()
@ -167,7 +170,8 @@ class BotChaseGame(bs.TeamGameActivity[Player, Team]):
return None return None
def _spawn_this_bot(self) -> None: def _spawn_this_bot(self) -> None:
self._bots.spawn_bot(MrSpazBot, pos=(random.choice([1, -1, 2, -2]), 1.34, random.choice([1, -1, 2, -2])), spawn_time=2.0) self._bots.spawn_bot(MrSpazBot, pos=(random.choice(
[1, -1, 2, -2]), 1.34, random.choice([1, -1, 2, -2])), spawn_time=2.0)
def _check_end_game(self) -> None: def _check_end_game(self) -> None:
living_team_count = 0 living_team_count = 0

View file

@ -37,14 +37,17 @@ import random
def getData(data): def getData(data):
return babase.app.config["colorsMod"][data] return babase.app.config["colorsMod"][data]
def getRandomColor(): def getRandomColor():
c = random.choice(getData("colors")) c = random.choice(getData("colors"))
return c return c
def doColorMenu(self): def doColorMenu(self):
bui.containerwidget(edit=self._root_widget, transition='out_left') bui.containerwidget(edit=self._root_widget, transition='out_left')
openWindow() openWindow()
def updateButton(self): def updateButton(self):
color = (random.random(), random.random(), random.random()) color = (random.random(), random.random(), random.random())
try: try:
@ -52,6 +55,7 @@ def updateButton(self):
except Exception: except Exception:
self._timer = None self._timer = None
newConfig = {"colorPlayer": True, newConfig = {"colorPlayer": True,
"higlightPlayer": False, "higlightPlayer": False,
"namePlayer": False, "namePlayer": False,
@ -72,9 +76,11 @@ newConfig = {"colorPlayer":True,
"colors": [color for color in get_player_colors()], "colors": [color for color in get_player_colors()],
} }
def getDefaultSettings(): def getDefaultSettings():
return newConfig return newConfig
def getTranslation(text): def getTranslation(text):
actLan = bs.app.lang.language actLan = bs.app.lang.language
colorsModsLan = { colorsModsLan = {
@ -260,7 +266,6 @@ class ColorsMod(babase.Plugin):
babase.app.config["colorsMod"] = newConfig babase.app.config["colorsMod"] = newConfig
babase.app.config.apply_and_commit() babase.app.config.apply_and_commit()
# MainMenuActivity.oldMakeWord = MainMenuActivity._make_word # MainMenuActivity.oldMakeWord = MainMenuActivity._make_word
# def newMakeWord(self, word: str, # def newMakeWord(self, word: str,
# x: float, # x: float,
@ -279,6 +284,7 @@ class ColorsMod(babase.Plugin):
#### GAME MODIFICATIONS #### #### GAME MODIFICATIONS ####
# ESCUDO DE COLORES # ESCUDO DE COLORES
def new_equip_shields(self, decay: bool = False) -> None: def new_equip_shields(self, decay: bool = False) -> None:
if not self.node: if not self.node:
babase.print_error('Can\'t equip shields; no node.') babase.print_error('Can\'t equip shields; no node.')
@ -297,8 +303,10 @@ class ColorsMod(babase.Plugin):
if self.shield_decay_rate > 0: if self.shield_decay_rate > 0:
self.shield_decay_timer = bs.Timer(0.5, bs.WeakCall(self.shield_decay), repeat=True) self.shield_decay_timer = bs.Timer(0.5, bs.WeakCall(self.shield_decay), repeat=True)
self.shield.always_show_health_bar = True self.shield.always_show_health_bar = True
def changeColor(): def changeColor():
if self.shield is None: return if self.shield is None:
return
if getData("shieldColor"): if getData("shieldColor"):
self.shield.color = c = getRandomColor() self.shield.color = c = getRandomColor()
self._shieldTimer = bs.Timer(getData("timeDelay") / 1000, changeColor, repeat=True) self._shieldTimer = bs.Timer(getData("timeDelay") / 1000, changeColor, repeat=True)
@ -306,13 +314,15 @@ class ColorsMod(babase.Plugin):
# BOTS DE COLORES # BOTS DE COLORES
SpazBot.oldBotInit = SpazBot.__init__ SpazBot.oldBotInit = SpazBot.__init__
def newBotInit(self, *args, **kwargs): def newBotInit(self, *args, **kwargs):
self.oldBotInit(*args, **kwargs) self.oldBotInit(*args, **kwargs)
s = 1 s = 1
if getData("glowBots"): if getData("glowBots"):
s = getData("glowScale") s = getData("glowScale")
self.node.highlight = (self.node.highlight[0]*s,self.node.highlight[1]*s,self.node.highlight[2]*s) self.node.highlight = (self.node.highlight[0]*s,
self.node.highlight[1]*s, self.node.highlight[2]*s)
def changeColor(): def changeColor():
if self.is_alive(): if self.is_alive():
@ -324,6 +334,7 @@ class ColorsMod(babase.Plugin):
# BANDERA DE COLORES # BANDERA DE COLORES
Flag.oldFlagInit = Flag.__init__ Flag.oldFlagInit = Flag.__init__
def newFlaginit(self, position: Sequence[float] = (0.0, 1.0, 0.0), def newFlaginit(self, position: Sequence[float] = (0.0, 1.0, 0.0),
color: Sequence[float] = (1.0, 1.0, 1.0), color: Sequence[float] = (1.0, 1.0, 1.0),
materials: Sequence[bs.Material] = None, materials: Sequence[bs.Material] = None,
@ -336,7 +347,8 @@ class ColorsMod(babase.Plugin):
if getData("flag"): if getData("flag"):
c = getRandomColor() c = getRandomColor()
self.node.color = (c[0]*1.2, c[1]*1.2, c[2]*1.2) self.node.color = (c[0]*1.2, c[1]*1.2, c[2]*1.2)
else: return else:
return
if touchable: if touchable:
self._timer = bs.Timer(getData("timeDelay") / 1000, cC, repeat=True) self._timer = bs.Timer(getData("timeDelay") / 1000, cC, repeat=True)
@ -344,6 +356,7 @@ class ColorsMod(babase.Plugin):
# JUGADORES DE COLORES # JUGADORES DE COLORES
PlayerSpaz.oldInit = PlayerSpaz.__init__ PlayerSpaz.oldInit = PlayerSpaz.__init__
def newInit(self, player: bs.Player, def newInit(self, player: bs.Player,
color: Sequence[float] = (1.0, 1.0, 1.0), color: Sequence[float] = (1.0, 1.0, 1.0),
highlight: Sequence[float] = (0.5, 0.5, 0.5), highlight: Sequence[float] = (0.5, 0.5, 0.5),
@ -369,8 +382,10 @@ class ColorsMod(babase.Plugin):
s3 = getData("glowScale") s3 = getData("glowScale")
self.node.color = (self.node.color[0]*s, self.node.color[1]*s, self.node.color[2]*s) self.node.color = (self.node.color[0]*s, self.node.color[1]*s, self.node.color[2]*s)
self.node.highlight = (self.node.highlight[0]*s2,self.node.highlight[1]*s2,self.node.highlight[2]*s2) self.node.highlight = (
self.node.name_color = (self.node.name_color[0]*s3,self.node.name_color[1]*s3,self.node.name_color[2]*s3) self.node.highlight[0]*s2, self.node.highlight[1]*s2, self.node.highlight[2]*s2)
self.node.name_color = (
self.node.name_color[0]*s3, self.node.name_color[1]*s3, self.node.name_color[2]*s3)
def changeColor(): def changeColor():
if self.is_alive(): if self.is_alive():
@ -388,11 +403,13 @@ class ColorsMod(babase.Plugin):
# EXPLOSIONES DE COLORES # EXPLOSIONES DE COLORES
bomb.Blast.oldBlastInit = bomb.Blast.__init__ bomb.Blast.oldBlastInit = bomb.Blast.__init__
def newBlastInit(self, position: Sequence[float] = (0.0, 1.0, 0.0), velocity: Sequence[float] = (0.0, 0.0, 0.0), def newBlastInit(self, position: Sequence[float] = (0.0, 1.0, 0.0), velocity: Sequence[float] = (0.0, 0.0, 0.0),
blast_radius: float = 2.0, blast_type: str = 'normal', source_player: bs.Player = None, blast_radius: float = 2.0, blast_type: str = 'normal', source_player: bs.Player = None,
hit_type: str = 'explosion', hit_subtype: str = 'normal'): hit_type: str = 'explosion', hit_subtype: str = 'normal'):
self.oldBlastInit(position, velocity, blast_radius, blast_type, source_player, hit_type, hit_subtype) self.oldBlastInit(position, velocity, blast_radius, blast_type,
source_player, hit_type, hit_subtype)
if getData("xplotionColor"): if getData("xplotionColor"):
c = getRandomColor() c = getRandomColor()
@ -405,16 +422,21 @@ class ColorsMod(babase.Plugin):
scl *= 3.0 scl *= 3.0
for i in range(2): for i in range(2):
scorch = bs.newnode('scorch',attrs={'position':self.node.position, 'size':scorch_radius*0.5,'big':(self.blast_type == 'tnt')}) scorch = bs.newnode('scorch', attrs={
if self.blast_type == 'ice': scorch.color =(1,1,1.5) 'position': self.node.position, 'size': scorch_radius*0.5, 'big': (self.blast_type == 'tnt')})
else: scorch.color = c if self.blast_type == 'ice':
scorch.color = (1, 1, 1.5)
else:
scorch.color = c
if getData("xplotionColor"): if getData("xplotionColor"):
if getData("delScorch"): if getData("delScorch"):
bs.animate(scorch, "presence", {3: 1, 13: 0}) bs.animate(scorch, "presence", {3: 1, 13: 0})
bs.Timer(13, scorch.delete) bs.Timer(13, scorch.delete)
if self.blast_type == 'ice': return if self.blast_type == 'ice':
light = bs.newnode('light', attrs={ 'position': position,'volume_intensity_scale': 10.0,'color': c}) return
light = bs.newnode('light', attrs={'position': position,
'volume_intensity_scale': 10.0, 'color': c})
iscale = 1.6 iscale = 1.6
bs.animate(light, 'intensity', { bs.animate(light, 'intensity', {
@ -460,7 +482,8 @@ class ProfilesWindow(popup.PopupWindow):
accountName: Optional[str] accountName: Optional[str]
if bui.app.plus.get_v1_account_state() == 'signed_in': if bui.app.plus.get_v1_account_state() == 'signed_in':
accountName = bui.app.plus.get_v1_account_display_string() accountName = bui.app.plus.get_v1_account_display_string()
else: accountName = None else:
accountName = None
# subHeight += (len(items)*45) # subHeight += (len(items)*45)
# creates our _root_widget # creates our _root_widget
@ -480,7 +503,6 @@ class ProfilesWindow(popup.PopupWindow):
iconscale=1.2) iconscale=1.2)
bui.containerwidget(edit=self.root_widget, cancel_button=self._cancel_button) bui.containerwidget(edit=self.root_widget, cancel_button=self._cancel_button)
self._title_text = bui.textwidget(parent=self.root_widget, self._title_text = bui.textwidget(parent=self.root_widget,
position=(self._width * 0.5, self._height - 20), position=(self._width * 0.5, self._height - 20),
size=(0, 0), size=(0, 0),
@ -534,7 +556,8 @@ class ProfilesWindow(popup.PopupWindow):
self._activeProfiles.append(self._selected) self._activeProfiles.append(self._selected)
babase.app.config["colorsMod"]["activeProfiles"] = self._activeProfiles babase.app.config["colorsMod"]["activeProfiles"] = self._activeProfiles
babase.app.config.apply_and_commit() babase.app.config.apply_and_commit()
else: bs.broadcastmessage(getTranslation('nothing_selected')) else:
bs.broadcastmessage(getTranslation('nothing_selected'))
def removeProfile(self): def removeProfile(self):
if self._selected is not None: if self._selected is not None:
@ -542,13 +565,17 @@ class ProfilesWindow(popup.PopupWindow):
self._activeProfiles.remove(self._selected) self._activeProfiles.remove(self._selected)
babase.app.config["colorsMod"]["activeProfiles"] = self._activeProfiles babase.app.config["colorsMod"]["activeProfiles"] = self._activeProfiles
babase.app.config.apply_and_commit() babase.app.config.apply_and_commit()
else: print('not found') else:
else: bs.broadcastmessage(getTranslation('nothing_selected')) print('not found')
else:
bs.broadcastmessage(getTranslation('nothing_selected'))
def select(self, name, m): def select(self, name, m):
self._selected = name self._selected = name
if m == 0: self.removeProfile() if m == 0:
else: self.addProfile() self.removeProfile()
else:
self.addProfile()
def _on_cancel_press(self) -> None: def _on_cancel_press(self) -> None:
self._transition_out() self._transition_out()
@ -572,7 +599,7 @@ class ColorsMenu(PopupWindow):
self._scrollWidth = self._width*0.85 self._scrollWidth = self._width*0.85
self._scrollHeight = self._height - 120 self._scrollHeight = self._height - 120
self._subWidth = self._scrollWidth*0.95; self._subWidth = self._scrollWidth*0.95
self._subHeight = 200 self._subHeight = 200
self._current_tab = getData('actab') self._current_tab = getData('actab')
@ -601,7 +628,8 @@ class ColorsMenu(PopupWindow):
position=(50, height-60), size=(120, 50), position=(50, height-60), size=(120, 50),
scale=0.8, text_scale=1.2, label=babase.Lstr(resource='backText'), scale=0.8, text_scale=1.2, label=babase.Lstr(resource='backText'),
button_type='back', on_activate_call=self._back) button_type='back', on_activate_call=self._back)
bui.buttonwidget(edit=self._backButton, button_type='backSmall',size=(50, 50),label=babase.charstr(babase.SpecialChar.BACK)) bui.buttonwidget(edit=self._backButton, button_type='backSmall', size=(
50, 50), label=babase.charstr(babase.SpecialChar.BACK))
bui.containerwidget(edit=self._root_widget, cancel_button=b) bui.containerwidget(edit=self._root_widget, cancel_button=b)
self._nextButton = bui.buttonwidget(parent=self._root_widget, autoselect=True, self._nextButton = bui.buttonwidget(parent=self._root_widget, autoselect=True,
@ -626,7 +654,8 @@ class ColorsMenu(PopupWindow):
[3, getTranslation('info_tab')], [3, getTranslation('info_tab')],
] ]
self._scrollwidget = sc = bui.scrollwidget(parent=self._root_widget,size=(self._subWidth,self._scrollHeight),border_opacity=0.3, highlight=False, position=((width*0.5)-(self._scrollWidth*0.47),50),capture_arrows=True,) self._scrollwidget = sc = bui.scrollwidget(parent=self._root_widget, size=(
self._subWidth, self._scrollHeight), border_opacity=0.3, highlight=False, position=((width*0.5)-(self._scrollWidth*0.47), 50), capture_arrows=True,)
bui.widget(edit=sc, left_widget=self._prevButton) bui.widget(edit=sc, left_widget=self._prevButton)
bui.widget(edit=sc, right_widget=self._nextButton) bui.widget(edit=sc, right_widget=self._nextButton)
@ -639,7 +668,8 @@ class ColorsMenu(PopupWindow):
position=(h, 20), size=(20, 20), position=(h, 20), size=(20, 20),
scale=1.2, label='', scale=1.2, label='',
color=(0.3, 0.9, 0.3), color=(0.3, 0.9, 0.3),
on_activate_call=babase.Call(self._setTab,self.tabs[i][0]), on_activate_call=babase.Call(
self._setTab, self.tabs[i][0]),
texture=bui.gettexture('nub')) texture=bui.gettexture('nub'))
self.tabButtons.append(tabButton) self.tabButtons.append(tabButton)
h += 50 h += 50
@ -648,13 +678,17 @@ class ColorsMenu(PopupWindow):
def nextTabContainer(self): def nextTabContainer(self):
tab = babase.app.config['colorsMod']['actab'] tab = babase.app.config['colorsMod']['actab']
if tab == 2: self._setTab(0) if tab == 2:
else: self._setTab(tab+1) self._setTab(0)
else:
self._setTab(tab+1)
def prevTabContainer(self): def prevTabContainer(self):
tab = babase.app.config['colorsMod']['actab'] tab = babase.app.config['colorsMod']['actab']
if tab == 0: self._setTab(2) if tab == 0:
else: self._setTab(tab-1) self._setTab(2)
else:
self._setTab(tab-1)
def _setTab(self, tab): def _setTab(self, tab):
@ -747,7 +781,8 @@ class ColorsMenu(PopupWindow):
v2 -= (50+180) v2 -= (50+180)
self._previewImage = bui.imagewidget(parent=c, position=(self._subWidth*0.72-100, v2), size=(200, 200), self._previewImage = bui.imagewidget(parent=c, position=(self._subWidth*0.72-100, v2), size=(200, 200),
mask_texture=bui.gettexture('characterIconMask'), tint_texture=tintTex, mask_texture=bui.gettexture('characterIconMask'), tint_texture=tintTex,
texture=tex, mesh_transparent=bui.getmesh('image1x1'), texture=tex, mesh_transparent=bui.getmesh(
'image1x1'),
tint_color=(tc[0]*gs, tc[1]*gs, tc[2]*gs), tint2_color=(t2c[0]*gs, t2c[1]*gs, t2c[2]*gs)) tint_color=(tc[0]*gs, tc[1]*gs, tc[2]*gs), tint2_color=(t2c[0]*gs, t2c[1]*gs, t2c[2]*gs))
self._colorTimer = bui.AppTimer(getData("timeDelay") / 1000, self._colorTimer = bui.AppTimer(getData("timeDelay") / 1000,
@ -911,14 +946,17 @@ class ColorsMenu(PopupWindow):
on_activate_call=bs.WeakCall(self.removeColor, colours[i])) on_activate_call=bs.WeakCall(self.removeColor, colours[i]))
else: else:
w = bui.buttonwidget( w = bui.buttonwidget(
parent= self._tabContainer, position=(x,y), size=bttnSize,color=(0.5, 0.4, 0.6), parent=self._tabContainer, position=(
x, y), size=bttnSize, color=(0.5, 0.4, 0.6),
autoselect=False, label="", texture=bui.gettexture('frameInset')) autoselect=False, label="", texture=bui.gettexture('frameInset'))
if i == l: if i == l:
bui.buttonwidget(edit=w,on_activate_call=bs.WeakCall(self._makePicker,w),label="+") bui.buttonwidget(edit=w, on_activate_call=bs.WeakCall(
self._makePicker, w), label="+")
if cont % 4 == 0: if cont % 4 == 0:
x = sp x = sp
y -= ((bttnSize[0]) + 10) y -= ((bttnSize[0]) + 10)
else: x += (bttnSize[0]) + 13 else:
x += (bttnSize[0]) + 13
cont += 1 cont += 1
def addColor(self, color): def addColor(self, color):
@ -926,7 +964,8 @@ class ColorsMenu(PopupWindow):
babase.app.config["colorsMod"]["colors"].append(color) babase.app.config["colorsMod"]["colors"].append(color)
babase.app.config.apply_and_commit() babase.app.config.apply_and_commit()
self._setTab(0) self._setTab(0)
else: bs.broadcastmessage(getTranslation('color_already')) else:
bs.broadcastmessage(getTranslation('color_already'))
def removeColor(self, color): def removeColor(self, color):
if color is not None: if color is not None:
@ -935,9 +974,12 @@ class ColorsMenu(PopupWindow):
babase.app.config["colorsMod"]["colors"].remove(color) babase.app.config["colorsMod"]["colors"].remove(color)
babase.app.config.apply_and_commit() babase.app.config.apply_and_commit()
self._setTab(0) self._setTab(0)
else: print('not found') else:
else: bs.broadcastmessage("Min. 2 colors", color=(0, 1, 0)) print('not found')
else: bs.broadcastmessage(getTranslation('nothing_selected')) else:
bs.broadcastmessage("Min. 2 colors", color=(0, 1, 0))
else:
bs.broadcastmessage(getTranslation('nothing_selected'))
def _makePicker(self, origin): def _makePicker(self, origin):
baseScale = 2.05 if babase.UIScale.SMALL else 1.6 if babase.UIScale.MEDIUM else 1.0 baseScale = 2.05 if babase.UIScale.SMALL else 1.6 if babase.UIScale.MEDIUM else 1.0
@ -946,7 +988,8 @@ class ColorsMenu(PopupWindow):
offset=(baseScale * (-100), 0), initial_color=initial_color, delegate=self, tag='color') offset=(baseScale * (-100), 0), initial_color=initial_color, delegate=self, tag='color')
def color_picker_closing(self, picker): def color_picker_closing(self, picker):
if not self._root_widget.exists(): return if not self._root_widget.exists():
return
tag = picker.get_tag() tag = picker.get_tag()
def color_picker_selected_color(self, picker, color): def color_picker_selected_color(self, picker, color):
@ -972,8 +1015,10 @@ class ColorsMenu(PopupWindow):
def _updatePreview(self): def _updatePreview(self):
gs = gs2 = getData("glowScale") gs = gs2 = getData("glowScale")
if not getData("glowColor"): gs =1 if not getData("glowColor"):
if not getData("glowHighlight"): gs2 =1 gs = 1
if not getData("glowHighlight"):
gs2 = 1
c = (1, 1, 1) c = (1, 1, 1)
if getData("colorPlayer"): if getData("colorPlayer"):