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: V1.0
|
||||
"""Disco Light Mod: V2.1
|
||||
Made by Cross Joy"""
|
||||
|
||||
# If anyone who wanna help me on giving suggestion/ fix bugs/ creating PR,
|
||||
# Can visit my github https://github.com/CrossJoy/Bombsquad-Modding
|
||||
|
||||
# You can contact me through discord:
|
||||
# My Discord Id: crossjoy
|
||||
# My Discord Id: Cross Joy#0721
|
||||
# My BS Discord Server: https://discord.gg/JyBY6haARJ
|
||||
|
||||
|
||||
|
|
@ -19,11 +18,16 @@ Made by Cross Joy"""
|
|||
|
||||
|
||||
# Coop and multiplayer compatible.
|
||||
# Work on any 1.7 ver.
|
||||
# Work on any 1.7.20+ ver.
|
||||
|
||||
# Note:
|
||||
# The plugin commands only works on the host with the plugin activated.
|
||||
# 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
|
||||
|
|
@ -33,60 +37,40 @@ from __future__ import annotations
|
|||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from baenv import TARGET_BALLISTICA_BUILD as build_number
|
||||
from bauiv1lib import mainmenu
|
||||
import bascenev1 as bs
|
||||
import babase
|
||||
import bauiv1 as bui
|
||||
import bascenev1 as bs
|
||||
import _babase
|
||||
from bascenev1 import _gameutils, animate
|
||||
from bascenev1 import _gameutils
|
||||
import random
|
||||
|
||||
from bascenev1 import animate
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Sequence, Union
|
||||
|
||||
# Check game ver.
|
||||
|
||||
class DiscoLight:
|
||||
|
||||
def is_game_version_lower_than(version):
|
||||
"""
|
||||
Returns a boolean value indicating whether the current game
|
||||
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
|
||||
|
||||
def __init__(self):
|
||||
activity = bs.get_foreground_host_activity()
|
||||
self.globalnodes = activity.globalsnode.tint
|
||||
|
||||
# Activate disco light.
|
||||
def start():
|
||||
def start(self):
|
||||
activity = bs.get_foreground_host_activity()
|
||||
|
||||
with activity.context:
|
||||
partyLight(True)
|
||||
rainbow(activity)
|
||||
|
||||
self.partyLight(True)
|
||||
self.rainbow(activity)
|
||||
|
||||
# Deactivate disco light.
|
||||
def stop():
|
||||
def stop(self):
|
||||
activity = bs.get_foreground_host_activity()
|
||||
|
||||
with activity.context:
|
||||
partyLight(False)
|
||||
stop_rainbow(activity)
|
||||
|
||||
self.partyLight(False)
|
||||
self.stop_rainbow(activity)
|
||||
|
||||
# Create and animate colorful spotlight.
|
||||
def partyLight(switch=True):
|
||||
def partyLight(self, switch=True):
|
||||
from bascenev1._nodeactor import NodeActor
|
||||
x_spread = 10
|
||||
y_spread = 5
|
||||
|
|
@ -105,7 +89,8 @@ def partyLight(switch=True):
|
|||
light = NodeActor(
|
||||
bs.newnode('light',
|
||||
attrs={
|
||||
'position': (positions[i][0], 0, positions[i][1]),
|
||||
'position': (
|
||||
positions[i][0], 0, positions[i][1]),
|
||||
'radius': 1.0,
|
||||
'lights_volumes': False,
|
||||
'height_attenuated': False,
|
||||
|
|
@ -158,16 +143,15 @@ def partyLight(switch=True):
|
|||
light.node.delete)
|
||||
activity.camera_flash_data.append(light) # type: ignore
|
||||
|
||||
|
||||
# Create RGB tint.
|
||||
def rainbow(self) -> None:
|
||||
def rainbow(self, activity) -> None:
|
||||
"""Create RGB tint."""
|
||||
c_existing = self.globalsnode.tint
|
||||
|
||||
cnode = bs.newnode('combine',
|
||||
attrs={
|
||||
'input0': c_existing[0],
|
||||
'input1': c_existing[1],
|
||||
'input2': c_existing[2],
|
||||
'input0': self.globalnodes[0],
|
||||
'input1': self.globalnodes[1],
|
||||
'input2': self.globalnodes[2],
|
||||
'size': 3
|
||||
})
|
||||
|
||||
|
|
@ -186,18 +170,14 @@ def rainbow(self) -> None:
|
|||
4.0: 0.2, 5.0: 1.0, 6.0: 1.0,
|
||||
7.0: 0.2}, loop=True)
|
||||
|
||||
cnode.connectattr('output', self.globalsnode, 'tint')
|
||||
|
||||
cnode.connectattr('output', activity.globalsnode, 'tint')
|
||||
|
||||
# Revert to the original map tint.
|
||||
def stop_rainbow(self):
|
||||
def stop_rainbow(self, activity):
|
||||
"""Revert to the original map tint."""
|
||||
try:
|
||||
c_existing = self.globalsnode.tint
|
||||
map_name = self.map.getname()
|
||||
tint = check_map_tint(map_name)
|
||||
except:
|
||||
tint = (1, 1, 1)
|
||||
c_existing = activity.globalsnode.tint
|
||||
# map_name = activity.map.getname()
|
||||
tint = self.globalnodes
|
||||
|
||||
cnode = bs.newnode('combine',
|
||||
attrs={
|
||||
|
|
@ -211,77 +191,42 @@ def stop_rainbow(self):
|
|||
_gameutils.animate(cnode, 'input1', {0: c_existing[1], 1.0: tint[1]})
|
||||
_gameutils.animate(cnode, 'input2', {0: c_existing[2], 1.0: tint[2]})
|
||||
|
||||
cnode.connectattr('output', self.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
|
||||
cnode.connectattr('output', activity.globalsnode, 'tint')
|
||||
|
||||
|
||||
# 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,
|
||||
sender_override: str = None):
|
||||
old_fcm(msg, clients, sender_override)
|
||||
if msg == '/disco':
|
||||
start()
|
||||
if msg == '/disco off':
|
||||
stop()
|
||||
def new_chat_message(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
func(*args, **kwargs)
|
||||
activity = bs.get_foreground_host_activity()
|
||||
with activity.context:
|
||||
try:
|
||||
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 __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
# Display chat icon, but if user open/close gather it may disappear
|
||||
def new_begin(func):
|
||||
"""Runs when game is began."""
|
||||
|
||||
def wrapper(*args, **kwargs):
|
||||
func(*args, **kwargs)
|
||||
bui.set_party_icon_always_visible(True)
|
||||
|
||||
|
||||
# Replace new chat func to the original game codes.
|
||||
bs.chatmessage = new_chat_message
|
||||
return wrapper
|
||||
|
||||
|
||||
# ba_meta export plugin
|
||||
class ByCrossJoy(babase.Plugin):
|
||||
def on_app_running(self):
|
||||
mainmenu.MainMenuWindow = NewMainMenuWindow
|
||||
def __init__(self):
|
||||
# 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