mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-11-07 17:36:00 +00:00
Update request from bombsquaders
This commit is contained in:
parent
bfb5d25467
commit
e01840c83d
13 changed files with 4602 additions and 1 deletions
81
plugins/utilities/InfinityShield.py
Normal file
81
plugins/utilities/InfinityShield.py
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
# Ported to api 8 by brostos using baport.(https://github.com/bombsquad-community/baport)
|
||||
# ba_meta require api 8
|
||||
# (see https://ballistica.net/wiki/meta-tag-system)
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import babase
|
||||
import bauiv1 as bui
|
||||
import bascenev1 as bs
|
||||
import random
|
||||
from bascenev1lib.actor.spaz import Spaz
|
||||
from bascenev1lib.actor.spazfactory import SpazFactory
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
|
||||
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),
|
||||
character: str = 'Spaz',
|
||||
source_player: bs.Player = None,
|
||||
start_invincible: bool = True,
|
||||
can_accept_powerups: bool = True,
|
||||
powerups_expire: bool = False,
|
||||
demo_mode: bool = False):
|
||||
self._old_init(color,highlight,character,source_player,start_invincible,
|
||||
can_accept_powerups,powerups_expire,demo_mode)
|
||||
if self.source_player:
|
||||
self.equip_shields()
|
||||
def animate_shield():
|
||||
if not self.shield:
|
||||
return
|
||||
bs.animate_array(self.shield, 'color', 3, {
|
||||
0.0: self.shield.color,
|
||||
0.2: (random.random(), random.random(), random.random())
|
||||
})
|
||||
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.
|
||||
"""
|
||||
|
||||
if not self.node:
|
||||
babase.print_error('Can\'t equip shields; no node.')
|
||||
return
|
||||
|
||||
factory = SpazFactory.get()
|
||||
if self.shield is None:
|
||||
self.shield = bs.newnode('shield',
|
||||
owner=self.node,
|
||||
attrs={
|
||||
'color': (0.3, 0.2, 2.0),
|
||||
'radius': 1.3
|
||||
})
|
||||
self.node.connectattr('position_center', self.shield, 'position')
|
||||
self.shield_hitpoints = self.shield_hitpoints_max = 650
|
||||
self.shield_decay_rate = factory.shield_decay_rate if decay else 0
|
||||
self.shield.hurt = 0
|
||||
factory.shield_up_sound.play(1.0, position=self.node.position)
|
||||
|
||||
if self.impact_scale == 0:
|
||||
return
|
||||
|
||||
if self.shield_decay_rate > 0:
|
||||
self.shield_decay_timer = bs.Timer(0.5,
|
||||
bs.WeakCall(self.shield_decay),
|
||||
repeat=True)
|
||||
# So user can see the decay.
|
||||
self.shield.always_show_health_bar = True
|
||||
|
||||
|
||||
# ba_meta export plugin
|
||||
class InfinityShieldPlugin(babase.Plugin):
|
||||
Spaz.__init__ = __init__
|
||||
Spaz.equip_shields = equip_shields
|
||||
50
plugins/utilities/OnlyNight.py
Normal file
50
plugins/utilities/OnlyNight.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# Ported by brostos to api 8
|
||||
# Tool used to make porting easier.(https://github.com/bombsquad-community/baport)
|
||||
"""Only Night."""
|
||||
|
||||
# ba_meta require api 8
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import babase
|
||||
import bascenev1 as bs
|
||||
from bascenev1._gameactivity import GameActivity
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
|
||||
# ba_meta export plugin
|
||||
class OnlyNight(babase.Plugin):
|
||||
GameActivity.old_on_transition_in = GameActivity.on_transition_in
|
||||
|
||||
def new_on_transition_in(self) -> None:
|
||||
self.old_on_transition_in()
|
||||
gnode = bs.getactivity().globalsnode
|
||||
if self.map.getname() in [
|
||||
"Monkey Face",
|
||||
"Rampage",
|
||||
"Roundabout",
|
||||
"Step Right Up",
|
||||
"Tip Top",
|
||||
"Zigzag",
|
||||
"The Pad",
|
||||
]:
|
||||
gnode.tint = (0.4, 0.4, 0.4)
|
||||
elif self.map.getname() in [
|
||||
"Big G",
|
||||
"Bridgit",
|
||||
"Courtyard",
|
||||
"Crag Castle",
|
||||
"Doom Shroom",
|
||||
"Football Stadium",
|
||||
"Happy Thoughts",
|
||||
"Hockey Stadium",
|
||||
]:
|
||||
gnode.tint = (0.5, 0.5, 0.5)
|
||||
else:
|
||||
gnode.tint = (0.3, 0.3, 0.3)
|
||||
|
||||
GameActivity.on_transition_in = new_on_transition_in
|
||||
565
plugins/utilities/Tag.py
Normal file
565
plugins/utilities/Tag.py
Normal file
|
|
@ -0,0 +1,565 @@
|
|||
# Ported by brostos to api 8
|
||||
# Tool used to make porting easier.(https://github.com/bombsquad-community/baport)
|
||||
"""
|
||||
I apreciate any kind of modification. So feel free to use or edit code or change credit string.... no problem.
|
||||
|
||||
really awsome servers:
|
||||
Bombsquad Consultancy Service - https://discord.gg/2RKd9QQdQY
|
||||
bombspot - https://discord.gg/ucyaesh
|
||||
cyclones - https://discord.gg/pJXxkbQ7kH
|
||||
|
||||
how to use:
|
||||
Account -> PlayerProfile -> Edit(new profile -> edit)
|
||||
Open profile you like (every profile has dirrent tags, settings (Configs))
|
||||
enable tag for profile you like, edit tag you want. enable cool flashy animation
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
from bauiv1lib.profile.edit import EditProfileWindow
|
||||
from bauiv1lib.colorpicker import ColorPicker
|
||||
from bauiv1lib.popup import PopupMenu
|
||||
from bascenev1lib.actor.playerspaz import PlayerSpaz
|
||||
from baenv import TARGET_BALLISTICA_BUILD as build_number
|
||||
import babase
|
||||
import bauiv1 as bui
|
||||
import bascenev1 as bs
|
||||
import _babase
|
||||
|
||||
from typing import (
|
||||
Tuple,
|
||||
Optional,
|
||||
Sequence,
|
||||
Union,
|
||||
Callable,
|
||||
Any,
|
||||
List,
|
||||
cast
|
||||
)
|
||||
|
||||
__version__ = 2.0
|
||||
__author__ = "pranav1711#2006"
|
||||
|
||||
|
||||
# Default Confings/Settings
|
||||
Configs = {
|
||||
"enabletag": False,
|
||||
"tag": "",
|
||||
"scale": "medium",
|
||||
"opacity": 1.0,
|
||||
"shadow": 0.0,
|
||||
"animtag": False,
|
||||
"frequency": 0.5
|
||||
}
|
||||
|
||||
# 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"] = {}
|
||||
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)}
|
||||
"""
|
||||
freq = babase.app.config['TagConf'][str(name)]['frequency']
|
||||
s1 = 0.0
|
||||
s2 = s1 + freq
|
||||
s3 = s2 + freq
|
||||
|
||||
animcolor = {
|
||||
s1: (1,0,0),
|
||||
s2: (0,1,0),
|
||||
s3: (0,0,1)
|
||||
}
|
||||
return animcolor
|
||||
|
||||
def gethostname() -> str:
|
||||
"""
|
||||
Return player name, by using -1 only host can use tags.
|
||||
"""
|
||||
session = bs.get_foreground_host_session()
|
||||
with session.context:
|
||||
for player in session.sessionplayers:
|
||||
if player.inputdevice.client_id == -1:
|
||||
name = player.getname(full=True, icon=False)
|
||||
break
|
||||
if name == bui.app.plus.get_v1_account_name:
|
||||
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),
|
||||
highlight: Sequence[float] = (0.5, 0.5, 0.5),
|
||||
character: str = 'Spaz',
|
||||
powerups_expire: bool = True) -> None:
|
||||
self.init(player, color, highlight, character, powerups_expire)
|
||||
self.curname = gethostname()
|
||||
|
||||
try:
|
||||
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.node.connectattr('torso_position', self.mnode, 'input2')
|
||||
|
||||
tagtext = cnfg[str(self.curname)]["tag"]
|
||||
opacity = cnfg[str(self.curname)]["opacity"]
|
||||
shadow = cnfg[str(self.curname)]["shadow"]
|
||||
sl = cnfg[str(self.curname)]["scale"]
|
||||
scale = 0.01 if sl == 'mediam' else 0.009 if not sl == 'large' else 0.02
|
||||
|
||||
self.Tag = bs.newnode(
|
||||
type='text',
|
||||
owner=self.node,
|
||||
attrs={
|
||||
'text': str(tagtext),
|
||||
'in_world': True,
|
||||
'shadow': shadow,
|
||||
'color': (0,0,0),
|
||||
'scale': scale,
|
||||
'opacity': opacity,
|
||||
'flatness': 1.0,
|
||||
'h_align': 'center'})
|
||||
self.mnode.connectattr('output', self.Tag, 'position')
|
||||
|
||||
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
|
||||
|
||||
|
||||
def NewEditProfileWindowInit(self,
|
||||
existing_profile: Optional[str],
|
||||
in_main_menu: bool,
|
||||
transition: str = 'in_right') -> None:
|
||||
"""
|
||||
New boilerplate for editprofilewindow, addeds button to call TagSettings window
|
||||
"""
|
||||
self.existing_profile = existing_profile
|
||||
self.in_main_menu = in_main_menu
|
||||
self.init(existing_profile, in_main_menu, transition)
|
||||
|
||||
v = self._height - 115.0
|
||||
x_inset = self._x_inset
|
||||
b_width = 50
|
||||
b_height = 30
|
||||
|
||||
self.tagwinbtn = bui.buttonwidget(
|
||||
parent=self._root_widget,
|
||||
autoselect=True,
|
||||
position=(505 + x_inset, v - 38 - 15),
|
||||
size=(b_width, b_height),
|
||||
color=(0.6, 0.5, 0.6),
|
||||
label='Tag',
|
||||
button_type='square',
|
||||
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
|
||||
"""
|
||||
bui.containerwidget(edit=self._root_widget, transition='out_scale')
|
||||
bui.app.ui_v1.set_main_menu_window(
|
||||
TagWindow(self.existing_profile,
|
||||
self.in_main_menu,
|
||||
self._name,
|
||||
transition='in_right').get_root_widget(), from_window=self._root_widget)
|
||||
|
||||
|
||||
# ba_meta require api 8
|
||||
# ba_meta export plugin
|
||||
class Tag(babase.Plugin):
|
||||
def __init__(self) -> None:
|
||||
"""
|
||||
Tag above actor player head, replacing PlayerSpaz class for getting actor,
|
||||
using EditProfileWindow for UI.
|
||||
"""
|
||||
if _babase.env().get("build_number",0) >= 20327:
|
||||
setconfigs()
|
||||
self.Replace()
|
||||
|
||||
def Replace(self) -> None:
|
||||
"""
|
||||
Replacing bolierplates no harm to relative funtionality only extending
|
||||
"""
|
||||
PlayerSpaz.__init__ = NewPlayerSzapInit
|
||||
EditProfileWindow.__init__ = NewEditProfileWindowInit
|
||||
|
||||
|
||||
class TagWindow(bui.Window):
|
||||
|
||||
def __init__(self,
|
||||
existing_profile: Optional[str],
|
||||
in_main_menu: bool,
|
||||
profilename: str,
|
||||
transition: Optional[str] = 'in_right'):
|
||||
self.existing_profile = existing_profile
|
||||
self.in_main_menu = in_main_menu
|
||||
self.profilename = profilename
|
||||
|
||||
uiscale = bui.app.ui_v1.uiscale
|
||||
self._width = 870.0 if uiscale is babase.UIScale.SMALL else 670.0
|
||||
self._height = (390.0 if uiscale is babase.UIScale.SMALL else
|
||||
450.0 if uiscale is babase.UIScale.MEDIUM else 520.0)
|
||||
extra_x = 100 if uiscale is babase.UIScale.SMALL else 0
|
||||
self.extra_x = extra_x
|
||||
top_extra = 20 if uiscale is babase.UIScale.SMALL else 0
|
||||
|
||||
super().__init__(
|
||||
root_widget=bui.containerwidget(
|
||||
size=(self._width, self._height),
|
||||
transition=transition,
|
||||
scale=(2.06 if uiscale is babase.UIScale.SMALL else
|
||||
1.4 if uiscale is babase.UIScale.MEDIUM else 1.0)))
|
||||
|
||||
self._back_button = bui.buttonwidget(
|
||||
parent=self._root_widget,
|
||||
autoselect=True,
|
||||
selectable=False, # FIXME: when press a in text field it selets to button
|
||||
position=(52 + self.extra_x, self._height - 60),
|
||||
size=(60, 60),
|
||||
scale=0.8,
|
||||
label=babase.charstr(babase.SpecialChar.BACK),
|
||||
button_type='backSmall',
|
||||
on_activate_call=self._back)
|
||||
bui.containerwidget(edit=self._root_widget, cancel_button=self._back_button)
|
||||
|
||||
self._save_button = bui.buttonwidget(
|
||||
parent=self._root_widget,
|
||||
position=(self._width - (177 + extra_x),
|
||||
self._height - 60),
|
||||
size=(155, 60),
|
||||
color=(0, 0.7, 0.5),
|
||||
autoselect=True,
|
||||
selectable=False, # FIXME: when press a in text field it selets to button
|
||||
scale=0.8,
|
||||
label=babase.Lstr(resource='saveText'),
|
||||
on_activate_call=self.on_save)
|
||||
bui.widget(edit=self._save_button, left_widget=self._back_button)
|
||||
bui.widget(edit=self._back_button, right_widget=self._save_button)
|
||||
bui.containerwidget(edit=self._root_widget, start_button=self._save_button)
|
||||
|
||||
self._title_text = bui.textwidget(
|
||||
parent=self._root_widget,
|
||||
position=(0, self._height - 52 - top_extra),
|
||||
size=(self._width, 25),
|
||||
text='Tag',
|
||||
color=bui.app.ui_v1.title_color,
|
||||
scale=1.5,
|
||||
h_align='center',
|
||||
v_align='top')
|
||||
|
||||
self._scroll_width = self._width - (100 + 2 * extra_x)
|
||||
self._scroll_height = self._height - 115.0
|
||||
self._sub_width = self._scroll_width * 0.95
|
||||
self._sub_height = 724.0
|
||||
self._spacing = 32
|
||||
self._extra_button_spacing = self._spacing * 2.5
|
||||
|
||||
self._scrollwidget = bui.scrollwidget(
|
||||
parent=self._root_widget,
|
||||
position=(50 + extra_x, 50),
|
||||
simple_culling_v=20.0,
|
||||
highlight=False,
|
||||
size=(self._scroll_width,
|
||||
self._scroll_height),
|
||||
selection_loops_to_parent=True)
|
||||
bui.widget(edit=self._scrollwidget, right_widget=self._scrollwidget)
|
||||
|
||||
self._subcontainer = bui.containerwidget(
|
||||
parent=self._scrollwidget,
|
||||
size=(self._sub_width,
|
||||
self._sub_height),
|
||||
background=False,
|
||||
selection_loops_to_parent=True)
|
||||
|
||||
v = self._sub_height - 35
|
||||
v -= self._spacing * 1.2
|
||||
|
||||
self._prof = babase.app.config["TagConf"][self.profilename]
|
||||
self.enabletagcb = bui.checkboxwidget(
|
||||
parent=self._subcontainer,
|
||||
autoselect=False,
|
||||
position=(10.0, v + 30),
|
||||
size=(10, 10),
|
||||
text='Enable Tag',
|
||||
textcolor=(0.8, 0.8, 0.8),
|
||||
value=self._prof['enabletag'],
|
||||
on_value_change_call=babase.Call(self.change_val, [f'{self.profilename}', 'enabletag']),
|
||||
scale=1.1 if uiscale is babase.UIScale.SMALL else 1.5,
|
||||
maxwidth=430)
|
||||
|
||||
self.tag_text = bui.textwidget(
|
||||
parent=self._subcontainer,
|
||||
text='Tag',
|
||||
position=(25.0, v - 30),
|
||||
flatness=1.0,
|
||||
scale=1.55,
|
||||
maxwidth=430,
|
||||
h_align='center',
|
||||
v_align='center',
|
||||
color=(0.8, 0.8, 0.8))
|
||||
|
||||
self.tagtextfield = bui.textwidget(
|
||||
parent=self._subcontainer,
|
||||
position=(100.0, v - 45),
|
||||
size=(350, 50),
|
||||
text=self._prof["tag"],
|
||||
h_align='center',
|
||||
v_align='center',
|
||||
max_chars=16,
|
||||
autoselect=True,
|
||||
editable=True,
|
||||
padding=4,
|
||||
color=(0.9, 0.9, 0.9, 1.0))
|
||||
|
||||
self.tag_color_text = bui.textwidget(
|
||||
parent=self._subcontainer,
|
||||
text='Color',
|
||||
position=(40.0, v - 80),
|
||||
flatness=1.0,
|
||||
scale=1.25,
|
||||
maxwidth=430,
|
||||
h_align='center',
|
||||
v_align='center',
|
||||
color=(0.8, 0.8, 0.8))
|
||||
|
||||
self.tag_scale_text = bui.textwidget(
|
||||
parent=self._subcontainer,
|
||||
text='Scale',
|
||||
position=(40.0, v - 130),
|
||||
flatness=1.0,
|
||||
scale=1.25,
|
||||
maxwidth=430,
|
||||
h_align='center',
|
||||
v_align='center',
|
||||
color=(0.8, 0.8, 0.8))
|
||||
|
||||
self.tag_scale_button = PopupMenu(
|
||||
parent=self._subcontainer,
|
||||
position=(330.0, v - 145),
|
||||
width=150,
|
||||
autoselect=True,
|
||||
on_value_change_call=bs.WeakCall(self._on_menu_choice),
|
||||
choices=['large', 'medium', 'small'],
|
||||
button_size=(150, 50),
|
||||
#choices_display=('large', 'medium', 'small'),
|
||||
current_choice=self._prof["scale"])
|
||||
|
||||
CustomConfigNumberEdit(
|
||||
parent=self._subcontainer,
|
||||
position=(40.0, v - 180),
|
||||
xoffset=65,
|
||||
displayname='Opacity',
|
||||
configkey=['TagConf', f'{self.profilename}', 'opacity'],
|
||||
changesound=False,
|
||||
minval=0.5,
|
||||
maxval=2.0,
|
||||
increment=0.1,
|
||||
textscale=1.25)
|
||||
|
||||
CustomConfigNumberEdit(
|
||||
parent=self._subcontainer,
|
||||
position=(40.0, v - 230),
|
||||
xoffset=65,
|
||||
displayname='Shadow',
|
||||
configkey=['TagConf', f'{self.profilename}', 'shadow'],
|
||||
changesound=False,
|
||||
minval=0.0,
|
||||
maxval=2.0,
|
||||
increment=0.1,
|
||||
textscale=1.25)
|
||||
|
||||
self.enabletaganim = bui.checkboxwidget(
|
||||
parent=self._subcontainer,
|
||||
autoselect=True,
|
||||
position=(10.0, v - 280),
|
||||
size=(10, 10),
|
||||
text='Animate tag',
|
||||
textcolor=(0.8, 0.8, 0.8),
|
||||
value=self._prof['enabletag'],
|
||||
on_value_change_call=babase.Call(self.change_val, [f'{self.profilename}', 'animtag']),
|
||||
scale=1.1 if uiscale is babase.UIScale.SMALL else 1.5,
|
||||
maxwidth=430)
|
||||
|
||||
CustomConfigNumberEdit(
|
||||
parent=self._subcontainer,
|
||||
position=(40.0, v - 330),
|
||||
xoffset=65,
|
||||
displayname='Frequency',
|
||||
configkey=['TagConf', f'{self.profilename}', 'frequency'],
|
||||
changesound=False,
|
||||
minval=0.1,
|
||||
maxval=5.0,
|
||||
increment=0.1,
|
||||
textscale=1.25)
|
||||
|
||||
def _back(self) -> None:
|
||||
"""
|
||||
transit window into back window
|
||||
"""
|
||||
bui.containerwidget(edit=self._root_widget,
|
||||
transition='out_scale')
|
||||
bui.app.ui_v1.set_main_menu_window(EditProfileWindow(
|
||||
self.existing_profile,
|
||||
self.in_main_menu,
|
||||
transition='in_left').get_root_widget(), from_window=self._root_widget)
|
||||
|
||||
def change_val(self, config: List[str], val: bool) -> None:
|
||||
"""
|
||||
chamges the value of check boxes
|
||||
"""
|
||||
cnfg = babase.app.config["TagConf"]
|
||||
try:
|
||||
cnfg[config[0]][config[1]] = val
|
||||
bui.getsound('gunCocking').play()
|
||||
except Exception:
|
||||
bui.screenmessage("error", color=(1,0,0))
|
||||
bui.getsound('error').play()
|
||||
babase.app.config.apply_and_commit()
|
||||
|
||||
def _on_menu_choice(self, choice: str):
|
||||
"""
|
||||
Changes the given choice in configs
|
||||
"""
|
||||
cnfg = babase.app.config["TagConf"][self.profilename]
|
||||
cnfg["scale"] = choice
|
||||
babase.app.config.apply_and_commit()
|
||||
|
||||
def on_save(self):
|
||||
"""
|
||||
Gets the text in text field of tag and then save it
|
||||
"""
|
||||
text: str = cast(str, bui.textwidget(query=self.tagtextfield))
|
||||
profile = babase.app.config["TagConf"][self.profilename]
|
||||
if not text == "" or not text.strip():
|
||||
profile['tag'] = text
|
||||
babase.app.config.apply_and_commit()
|
||||
bui.getsound('gunCocking').play()
|
||||
else:
|
||||
bui.screenmessage(f"please define tag", color=(1,0,0))
|
||||
bui.getsound('error').play()
|
||||
|
||||
bui.containerwidget(edit=self._root_widget,
|
||||
transition='out_scale')
|
||||
bui.app.ui_v1.set_main_menu_window(EditProfileWindow(
|
||||
self.existing_profile,
|
||||
self.in_main_menu,
|
||||
transition='in_left').get_root_widget(), from_window=self._root_widget)
|
||||
|
||||
|
||||
class CustomConfigNumberEdit:
|
||||
"""A set of controls for editing a numeric config value.
|
||||
|
||||
It will automatically save and apply the config when its
|
||||
value changes.
|
||||
|
||||
Attributes:
|
||||
|
||||
nametext
|
||||
The text widget displaying the name.
|
||||
|
||||
valuetext
|
||||
The text widget displaying the current value.
|
||||
|
||||
minusbutton
|
||||
The button widget used to reduce the value.
|
||||
|
||||
plusbutton
|
||||
The button widget used to increase the value.
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
parent: bui.Widget,
|
||||
configkey: List[str],
|
||||
position: Tuple[float, float],
|
||||
minval: float = 0.0,
|
||||
maxval: float = 100.0,
|
||||
increment: float = 1.0,
|
||||
callback: Callable[[float], Any] = None,
|
||||
xoffset: float = 0.0,
|
||||
displayname: Union[str, babase.Lstr] = None,
|
||||
changesound: bool = True,
|
||||
textscale: float = 1.0):
|
||||
self._minval = minval
|
||||
self._maxval = maxval
|
||||
self._increment = increment
|
||||
self._callback = callback
|
||||
self._configkey = configkey
|
||||
self._value = babase.app.config[configkey[0]][configkey[1]][configkey[2]]
|
||||
|
||||
self.nametext = bui.textwidget(
|
||||
parent=parent,
|
||||
position=position,
|
||||
size=(100, 30),
|
||||
text=displayname,
|
||||
maxwidth=160 + xoffset,
|
||||
color=(0.8, 0.8, 0.8, 1.0),
|
||||
h_align='left',
|
||||
v_align='center',
|
||||
scale=textscale)
|
||||
|
||||
self.valuetext = bui.textwidget(
|
||||
parent=parent,
|
||||
position=(246 + xoffset, position[1]),
|
||||
size=(60, 28),
|
||||
editable=False,
|
||||
color=(0.3, 1.0, 0.3, 1.0),
|
||||
h_align='right',
|
||||
v_align='center',
|
||||
text=str(self._value),
|
||||
padding=2)
|
||||
|
||||
self.minusbutton = bui.buttonwidget(
|
||||
parent=parent,
|
||||
position=(330 + xoffset, position[1]),
|
||||
size=(28, 28),
|
||||
label='-',
|
||||
autoselect=True,
|
||||
on_activate_call=babase.Call(self._down),
|
||||
repeat=True,
|
||||
enable_sound=changesound)
|
||||
|
||||
self.plusbutton = bui.buttonwidget(parent=parent,
|
||||
position=(380 + xoffset, position[1]),
|
||||
size=(28, 28),
|
||||
label='+',
|
||||
autoselect=True,
|
||||
on_activate_call=babase.Call(self._up),
|
||||
repeat=True,
|
||||
enable_sound=changesound)
|
||||
|
||||
bui.uicleanupcheck(self, self.nametext)
|
||||
self._update_display()
|
||||
|
||||
def _up(self) -> None:
|
||||
self._value = min(self._maxval, self._value + self._increment)
|
||||
self._changed()
|
||||
|
||||
def _down(self) -> None:
|
||||
self._value = max(self._minval, self._value - self._increment)
|
||||
self._changed()
|
||||
|
||||
def _changed(self) -> None:
|
||||
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.apply_and_commit()
|
||||
|
||||
def _update_display(self) -> None:
|
||||
bui.textwidget(edit=self.valuetext, text=f'{self._value:.1f}')
|
||||
108
plugins/utilities/disable_friendly_fire.py
Normal file
108
plugins/utilities/disable_friendly_fire.py
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
# Ported to api 8 by brostos using baport.(https://github.com/bombsquad-community/baport)
|
||||
# ba_meta require api 8
|
||||
from __future__ import annotations
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import babase
|
||||
import bauiv1 as bui
|
||||
import bascenev1 as bs
|
||||
import bascenev1lib
|
||||
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
|
||||
# either change playerspaz handlemessage or change spaz handlemessage
|
||||
def playerspaz_new_handlemessage(func: fuction) -> fuction:
|
||||
def wrapper(*args, **kwargs):
|
||||
global freeze
|
||||
|
||||
# only run if session is dual team
|
||||
if isinstance(args[0].activity.session, bs.DualTeamSession):
|
||||
# when spaz got hurt by any reason this statement is runs.
|
||||
if isinstance(args[1], bs.HitMessage):
|
||||
our_team_players: list[type(args[0]._player)]
|
||||
|
||||
# source_player
|
||||
attacker = args[1].get_source_player(type(args[0]._player))
|
||||
|
||||
# our team payers
|
||||
our_team_players = args[0]._player.team.players.copy()
|
||||
|
||||
if len(our_team_players) > 0:
|
||||
|
||||
# removing our self
|
||||
our_team_players.remove(args[0]._player)
|
||||
|
||||
# if we honding teammate or if we have a shield, do hit.
|
||||
for player in our_team_players:
|
||||
if player.actor.exists() and args[0]._player.actor.exists():
|
||||
if args[0]._player.actor.node.hold_node == player.actor.node or args[0]._player.actor.shield:
|
||||
our_team_players.remove(player)
|
||||
break
|
||||
|
||||
if attacker in our_team_players:
|
||||
freeze = False
|
||||
return None
|
||||
else:
|
||||
freeze = True
|
||||
|
||||
# if ice_bomb blast hits any spaz this statement runs.
|
||||
elif isinstance(args[1], bs.FreezeMessage):
|
||||
if not freeze:
|
||||
freeze = True # use it and reset it
|
||||
return None
|
||||
|
||||
# orignal unchanged code goes here
|
||||
func(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
# replace original fuction to modified function
|
||||
bascenev1lib.actor.playerspaz.PlayerSpaz.handlemessage = playerspaz_new_handlemessage(
|
||||
bascenev1lib.actor.playerspaz.PlayerSpaz.handlemessage)
|
||||
|
||||
# let's add a message when bomb is pick by player
|
||||
def bombfact_new_init(func: function) -> function:
|
||||
def wrapper(*args):
|
||||
|
||||
func(*args) # original code
|
||||
|
||||
args[0].bomb_material.add_actions(
|
||||
conditions=('they_have_material', SharedObjects.get().pickup_material),
|
||||
actions=('message', 'our_node', 'at_connect', BombPickupMessage()),
|
||||
)
|
||||
return wrapper
|
||||
|
||||
# you get the idea
|
||||
bascenev1lib.actor.bomb.BombFactory.__init__ = bombfact_new_init(
|
||||
bascenev1lib.actor.bomb.BombFactory.__init__)
|
||||
|
||||
def bomb_new_handlemessage(func: function) -> function:
|
||||
def wrapper(*args, **kwargs):
|
||||
# only run if session is dual team
|
||||
if isinstance(args[0].activity.session, bs.DualTeamSession):
|
||||
if isinstance(args[1], BombPickupMessage):
|
||||
# get the pickuper and assign the pickuper to the source_player(attacker) of bomb blast
|
||||
for player in args[0].activity.players:
|
||||
if player.actor.exists():
|
||||
if player.actor.node.hold_node == args[0].node:
|
||||
args[0]._source_player = player
|
||||
break
|
||||
|
||||
func(*args, **kwargs) # original
|
||||
|
||||
return wrapper
|
||||
|
||||
bascenev1lib.actor.bomb.Bomb.handlemessage = bomb_new_handlemessage(
|
||||
bascenev1lib.actor.bomb.Bomb.handlemessage)
|
||||
Loading…
Add table
Add a link
Reference in a new issue