mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-11-07 17:36:00 +00:00
Update disco_light.py
Update to ver 2.1
This commit is contained in:
parent
5bce0885d8
commit
617e75c0bf
1 changed files with 166 additions and 221 deletions
|
|
@ -1,12 +1,11 @@
|
||||||
# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport)
|
"""Disco Light Mod: V2.1
|
||||||
"""Disco Light Mod: V1.0
|
|
||||||
Made by Cross Joy"""
|
Made by Cross Joy"""
|
||||||
|
|
||||||
# If anyone who wanna help me on giving suggestion/ fix bugs/ creating PR,
|
# If anyone who wanna help me on giving suggestion/ fix bugs/ creating PR,
|
||||||
# Can visit my github https://github.com/CrossJoy/Bombsquad-Modding
|
# Can visit my github https://github.com/CrossJoy/Bombsquad-Modding
|
||||||
|
|
||||||
# You can contact me through discord:
|
# You can contact me through discord:
|
||||||
# My Discord Id: crossjoy
|
# My Discord Id: Cross Joy#0721
|
||||||
# My BS Discord Server: https://discord.gg/JyBY6haARJ
|
# My BS Discord Server: https://discord.gg/JyBY6haARJ
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -19,11 +18,16 @@ Made by Cross Joy"""
|
||||||
|
|
||||||
|
|
||||||
# Coop and multiplayer compatible.
|
# Coop and multiplayer compatible.
|
||||||
# Work on any 1.7 ver.
|
# Work on any 1.7.20+ ver.
|
||||||
|
|
||||||
# Note:
|
# Note:
|
||||||
# The plugin commands only works on the host with the plugin activated.
|
# The plugin commands only works on the host with the plugin activated.
|
||||||
# Other clients/players can't use the commands.
|
# Other clients/players can't use the commands.
|
||||||
|
|
||||||
|
# v2.1
|
||||||
|
# - Enhance compatibility with other mods
|
||||||
|
# - Tint change when /disco off will be more dynamic.
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
# ba_meta require api 8
|
# ba_meta require api 8
|
||||||
|
|
@ -33,60 +37,40 @@ from __future__ import annotations
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from baenv import TARGET_BALLISTICA_BUILD as build_number
|
import bascenev1 as bs
|
||||||
from bauiv1lib import mainmenu
|
|
||||||
import babase
|
import babase
|
||||||
import bauiv1 as bui
|
import bauiv1 as bui
|
||||||
import bascenev1 as bs
|
from bascenev1 import _gameutils
|
||||||
import _babase
|
|
||||||
from bascenev1 import _gameutils, animate
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
from bascenev1 import animate
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing import Sequence, Union
|
from typing import Sequence, Union
|
||||||
|
|
||||||
# Check game ver.
|
|
||||||
|
|
||||||
|
class DiscoLight:
|
||||||
|
|
||||||
def is_game_version_lower_than(version):
|
def __init__(self):
|
||||||
"""
|
activity = bs.get_foreground_host_activity()
|
||||||
Returns a boolean value indicating whether the current game
|
self.globalnodes = activity.globalsnode.tint
|
||||||
version is lower than the passed version. Useful for addressing
|
|
||||||
any breaking changes within game versions.
|
|
||||||
"""
|
|
||||||
game_version = tuple(map(int, babase.app.version if build_number <
|
|
||||||
21282 else babase.app.env.split(".")))
|
|
||||||
version = tuple(map(int, version.split(".")))
|
|
||||||
return game_version < version
|
|
||||||
|
|
||||||
|
|
||||||
# if is_game_version_lower_than("1.7.7"):
|
|
||||||
# ba_internal = _ba
|
|
||||||
# else:
|
|
||||||
# ba_internal = babase.internal
|
|
||||||
|
|
||||||
|
|
||||||
# Activate disco light.
|
# Activate disco light.
|
||||||
def start():
|
def start(self):
|
||||||
activity = bs.get_foreground_host_activity()
|
activity = bs.get_foreground_host_activity()
|
||||||
|
|
||||||
with activity.context:
|
with activity.context:
|
||||||
partyLight(True)
|
self.partyLight(True)
|
||||||
rainbow(activity)
|
self.rainbow(activity)
|
||||||
|
|
||||||
|
|
||||||
# Deactivate disco light.
|
# Deactivate disco light.
|
||||||
def stop():
|
def stop(self):
|
||||||
activity = bs.get_foreground_host_activity()
|
activity = bs.get_foreground_host_activity()
|
||||||
|
|
||||||
with activity.context:
|
with activity.context:
|
||||||
partyLight(False)
|
self.partyLight(False)
|
||||||
stop_rainbow(activity)
|
self.stop_rainbow(activity)
|
||||||
|
|
||||||
|
|
||||||
# Create and animate colorful spotlight.
|
# Create and animate colorful spotlight.
|
||||||
def partyLight(switch=True):
|
def partyLight(self, switch=True):
|
||||||
from bascenev1._nodeactor import NodeActor
|
from bascenev1._nodeactor import NodeActor
|
||||||
x_spread = 10
|
x_spread = 10
|
||||||
y_spread = 5
|
y_spread = 5
|
||||||
|
|
@ -105,7 +89,8 @@ def partyLight(switch=True):
|
||||||
light = NodeActor(
|
light = NodeActor(
|
||||||
bs.newnode('light',
|
bs.newnode('light',
|
||||||
attrs={
|
attrs={
|
||||||
'position': (positions[i][0], 0, positions[i][1]),
|
'position': (
|
||||||
|
positions[i][0], 0, positions[i][1]),
|
||||||
'radius': 1.0,
|
'radius': 1.0,
|
||||||
'lights_volumes': False,
|
'lights_volumes': False,
|
||||||
'height_attenuated': False,
|
'height_attenuated': False,
|
||||||
|
|
@ -158,16 +143,15 @@ def partyLight(switch=True):
|
||||||
light.node.delete)
|
light.node.delete)
|
||||||
activity.camera_flash_data.append(light) # type: ignore
|
activity.camera_flash_data.append(light) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
# Create RGB tint.
|
# Create RGB tint.
|
||||||
def rainbow(self) -> None:
|
def rainbow(self, activity) -> None:
|
||||||
"""Create RGB tint."""
|
"""Create RGB tint."""
|
||||||
c_existing = self.globalsnode.tint
|
|
||||||
cnode = bs.newnode('combine',
|
cnode = bs.newnode('combine',
|
||||||
attrs={
|
attrs={
|
||||||
'input0': c_existing[0],
|
'input0': self.globalnodes[0],
|
||||||
'input1': c_existing[1],
|
'input1': self.globalnodes[1],
|
||||||
'input2': c_existing[2],
|
'input2': self.globalnodes[2],
|
||||||
'size': 3
|
'size': 3
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -186,18 +170,14 @@ def rainbow(self) -> None:
|
||||||
4.0: 0.2, 5.0: 1.0, 6.0: 1.0,
|
4.0: 0.2, 5.0: 1.0, 6.0: 1.0,
|
||||||
7.0: 0.2}, loop=True)
|
7.0: 0.2}, loop=True)
|
||||||
|
|
||||||
cnode.connectattr('output', self.globalsnode, 'tint')
|
cnode.connectattr('output', activity.globalsnode, 'tint')
|
||||||
|
|
||||||
|
|
||||||
# Revert to the original map tint.
|
# Revert to the original map tint.
|
||||||
def stop_rainbow(self):
|
def stop_rainbow(self, activity):
|
||||||
"""Revert to the original map tint."""
|
"""Revert to the original map tint."""
|
||||||
try:
|
c_existing = activity.globalsnode.tint
|
||||||
c_existing = self.globalsnode.tint
|
# map_name = activity.map.getname()
|
||||||
map_name = self.map.getname()
|
tint = self.globalnodes
|
||||||
tint = check_map_tint(map_name)
|
|
||||||
except:
|
|
||||||
tint = (1, 1, 1)
|
|
||||||
|
|
||||||
cnode = bs.newnode('combine',
|
cnode = bs.newnode('combine',
|
||||||
attrs={
|
attrs={
|
||||||
|
|
@ -211,77 +191,42 @@ def stop_rainbow(self):
|
||||||
_gameutils.animate(cnode, 'input1', {0: c_existing[1], 1.0: tint[1]})
|
_gameutils.animate(cnode, 'input1', {0: c_existing[1], 1.0: tint[1]})
|
||||||
_gameutils.animate(cnode, 'input2', {0: c_existing[2], 1.0: tint[2]})
|
_gameutils.animate(cnode, 'input2', {0: c_existing[2], 1.0: tint[2]})
|
||||||
|
|
||||||
cnode.connectattr('output', self.globalsnode, 'tint')
|
cnode.connectattr('output', activity.globalsnode, 'tint')
|
||||||
|
|
||||||
|
|
||||||
# Check map name
|
|
||||||
def check_map_tint(map_name):
|
|
||||||
if map_name in 'Hockey Stadium':
|
|
||||||
tint = (1.2, 1.3, 1.33)
|
|
||||||
elif map_name in 'Football Stadium':
|
|
||||||
tint = (1.3, 1.2, 1.0)
|
|
||||||
elif map_name in 'Bridgit':
|
|
||||||
tint = (1.1, 1.2, 1.3)
|
|
||||||
elif map_name in 'Big G':
|
|
||||||
tint = (1.1, 1.2, 1.3)
|
|
||||||
elif map_name in 'Roundabout':
|
|
||||||
tint = (1.0, 1.05, 1.1)
|
|
||||||
elif map_name in 'Monkey Face':
|
|
||||||
tint = (1.1, 1.2, 1.2)
|
|
||||||
elif map_name in 'Zigzag':
|
|
||||||
tint = (1.0, 1.15, 1.15)
|
|
||||||
elif map_name in 'The Pad':
|
|
||||||
tint = (1.1, 1.1, 1.0)
|
|
||||||
elif map_name in 'Lake Frigid':
|
|
||||||
tint = (0.8, 0.9, 1.3)
|
|
||||||
elif map_name in 'Crag Castle':
|
|
||||||
tint = (1.15, 1.05, 0.75)
|
|
||||||
elif map_name in 'Tower D':
|
|
||||||
tint = (1.15, 1.11, 1.03)
|
|
||||||
elif map_name in 'Happy Thoughts':
|
|
||||||
tint = (1.3, 1.23, 1.0)
|
|
||||||
elif map_name in 'Step Right Up':
|
|
||||||
tint = (1.2, 1.1, 1.0)
|
|
||||||
elif map_name in 'Doom Shroom':
|
|
||||||
tint = (0.82, 1.10, 1.15)
|
|
||||||
elif map_name in 'Courtyard':
|
|
||||||
tint = (1.2, 1.17, 1.1)
|
|
||||||
elif map_name in 'Rampage':
|
|
||||||
tint = (1.2, 1.1, 0.97)
|
|
||||||
elif map_name in 'Tip Top':
|
|
||||||
tint = (0.8, 0.9, 1.3)
|
|
||||||
else:
|
|
||||||
tint = (1, 1, 1)
|
|
||||||
|
|
||||||
return tint
|
|
||||||
|
|
||||||
|
|
||||||
# Get the original game codes.
|
|
||||||
old_fcm = bs.chatmessage
|
|
||||||
|
|
||||||
|
|
||||||
# New chat func to add some commands to activate/deactivate the disco light.
|
# New chat func to add some commands to activate/deactivate the disco light.
|
||||||
def new_chat_message(msg: Union[str, babase.Lstr], clients: Sequence[int] = None,
|
def new_chat_message(func):
|
||||||
sender_override: str = None):
|
def wrapper(*args, **kwargs):
|
||||||
old_fcm(msg, clients, sender_override)
|
func(*args, **kwargs)
|
||||||
if msg == '/disco':
|
activity = bs.get_foreground_host_activity()
|
||||||
start()
|
with activity.context:
|
||||||
if msg == '/disco off':
|
try:
|
||||||
stop()
|
if not activity.disco_light:
|
||||||
|
activity.disco_light = DiscoLight()
|
||||||
|
except:
|
||||||
|
activity.disco_light = DiscoLight()
|
||||||
|
if args[0] == '/disco':
|
||||||
|
activity.disco_light.start()
|
||||||
|
elif args[0] == '/disco off':
|
||||||
|
activity.disco_light.stop()
|
||||||
|
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
class NewMainMenuWindow(mainmenu.MainMenuWindow):
|
def new_begin(func):
|
||||||
def __init__(self, *args, **kwargs):
|
"""Runs when game is began."""
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
# Display chat icon, but if user open/close gather it may disappear
|
def wrapper(*args, **kwargs):
|
||||||
|
func(*args, **kwargs)
|
||||||
bui.set_party_icon_always_visible(True)
|
bui.set_party_icon_always_visible(True)
|
||||||
|
|
||||||
|
return wrapper
|
||||||
# Replace new chat func to the original game codes.
|
|
||||||
bs.chatmessage = new_chat_message
|
|
||||||
|
|
||||||
|
|
||||||
# ba_meta export plugin
|
# ba_meta export plugin
|
||||||
class ByCrossJoy(babase.Plugin):
|
class ByCrossJoy(babase.Plugin):
|
||||||
def on_app_running(self):
|
def __init__(self):
|
||||||
mainmenu.MainMenuWindow = NewMainMenuWindow
|
# Replace new chat func to the original game codes.
|
||||||
|
bs.chatmessage = new_chat_message(bs.chatmessage)
|
||||||
|
bs._activity.Activity.on_begin = new_begin(
|
||||||
|
bs._activity.Activity.on_begin)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue