Done with utilities. Need some testing on ultraparty and few fix on auto stunt and quick customgame

This commit is contained in:
brostosjoined 2024-01-16 15:06:45 +03:00
parent 39845e7b61
commit 77d16e63c7
19 changed files with 1221 additions and 1093 deletions

View file

@ -1,12 +1,15 @@
# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport)
# ba_meta require api 7
# ba_meta require api 8
from __future__ import annotations
from typing import TYPE_CHECKING
import ba
from ba import _map
from bastd.gameutils import SharedObjects
from bastd.maps import *
import babase
import bauiv1 as bui
import bascenev1 as bs
from bascenev1 import _map
from bascenev1lib.gameutils import SharedObjects
from bascenev1lib.maps import *
if TYPE_CHECKING:
pass
@ -48,7 +51,7 @@ class ForestMapData():
points['spawn2'] = (5.0, -2.0, -2.0) + (0.5, 1.0, 3.2)
class ForestMap(ba.Map):
class ForestMap(bs.Map):
defs = ForestMapData()
name = 'Forest'
@ -64,11 +67,11 @@ class ForestMap(ba.Map):
@classmethod
def on_preload(cls) -> any:
data: dict[str, any] = {
'model': ba.getmodel('natureBackground'),
'tex': ba.gettexture('natureBackgroundColor'),
'collide_model': ba.getcollidemodel('natureBackgroundCollide'),
'bgmodel': ba.getmodel('thePadBG'),
'bgtex': ba.gettexture('menuBG')
'mesh': bs.getmesh('natureBackground'),
'tex': bui.gettexture('natureBackgroundColor'),
'collision_mesh': bs.getcollisionmesh('natureBackgroundCollide'),
'bgmesh': bs.getmesh('thePadBG'),
'bgtex': bui.gettexture('menuBG')
}
return data
@ -76,27 +79,27 @@ class ForestMap(ba.Map):
super().__init__()
shared = SharedObjects.get()
self.node = ba.newnode(
self.node = bs.newnode(
'terrain',
delegate=self,
attrs={
'model': self.preloaddata['model'],
'mesh': self.preloaddata['mesh'],
'color_texture': self.preloaddata['tex'],
'collide_model': self.preloaddata['collide_model'],
'collide_mesh': self.preloaddata['collide_mesh'],
'materials': [shared.footing_material]
}
)
self.background = ba.newnode(
self.background = bs.newnode(
'terrain',
attrs={
'model': self.preloaddata['bgmodel'],
'mesh': self.preloaddata['bgmesh'],
'lighting': False,
'shadow': True,
'color_texture': self.preloaddata['bgtex']
}
)
gnode = ba.getactivity().globalsnode
gnode = bs.getactivity().globalsnode
gnode.tint = (1.0, 1.10, 1.15)
gnode.ambient_color = (0.9, 1.3, 1.1)
gnode.shadow_ortho = False
@ -104,7 +107,7 @@ class ForestMap(ba.Map):
gnode.vignette_inner = (0.95, 0.95, 0.99)
def is_point_near_edge(self,
point: ba.Vec3,
point: babase.Vec3,
running: bool = False) -> bool:
xpos = point.x
zpos = point.z
@ -117,5 +120,5 @@ class ForestMap(ba.Map):
# ba_meta export plugin
class EnableMe(ba.Plugin):
class EnableMe(babase.Plugin):
_map.register_map(ForestMap)

View file

@ -19,6 +19,7 @@
}
],
"versions": {
"1.0.1": null,
"1.0.0": {
"api_version": 7,
"commit_sha": "2454845",
@ -106,6 +107,7 @@
}
],
"versions": {
"1.0.1": null,
"1.0.0": {
"api_version": 7,
"commit_sha": "2fda676",
@ -125,6 +127,7 @@
}
],
"versions": {
"1.0.1": null,
"1.0.0": {
"api_version": 7,
"commit_sha": "2fda676",
@ -163,6 +166,7 @@
}
],
"versions": {
"1.0.1": null,
"1.0.0": {
"api_version": 7,
"commit_sha": "fed7c24",
@ -187,6 +191,7 @@
}
],
"versions": {
"1.0.1": null,
"1.0.0": {
"api_version": 7,
"commit_sha": "2fda676",
@ -206,6 +211,7 @@
}
],
"versions": {
"1.2.3": null,
"1.2.2": {
"api_version": 7,
"commit_sha": "7753b87",
@ -239,7 +245,7 @@
{
"name": "Rikko",
"email": "rikkolovescats@proton.me",
"discord": "Rikko#7383"
"discord": "rikkolovescats"
},
{
"name": "Vishal",
@ -299,7 +305,7 @@
{
"name": "Rikko",
"email": "rikkolovescats@proton.me",
"discord": "Rikko#7383"
"discord": "rikkolovescats"
}
],
"versions": {
@ -470,6 +476,7 @@
}
],
"versions": {
"1.0.1": null,
"1.0.0": {
"api_version": 7,
"commit_sha": "6acdea8",
@ -669,6 +676,7 @@
}
],
"versions": {
"4.0.1": null,
"4.0.0": {
"api_version": 7,
"commit_sha": "a23e8cd",
@ -684,10 +692,11 @@
{
"name": "TheMikirog",
"email": "",
"discord": "TheMikirog#1984"
"discord": "themikirog"
}
],
"versions": {
"3.0.1": null,
"3.0.0": {
"api_version": 7,
"commit_sha": "0841b9e",
@ -703,10 +712,11 @@
{
"name": "TheMikirog",
"email": "",
"discord": "TheMikirog#1984"
"discord": "themikirog"
}
],
"versions": {
"1.0.1": null,
"1.0.0": {
"api_version": 7,
"commit_sha": "0841b9e",
@ -722,10 +732,11 @@
{
"name": "TheMikirog",
"email": "",
"discord": "TheMikirog#1984"
"discord": "themikirog"
}
],
"versions": {
"1.0.1": null,
"1.0.0": {
"api_version": 7,
"commit_sha": "0841b9e",
@ -741,10 +752,11 @@
{
"name": "Cross Joy",
"email": "cross.joy.official@gmail.com",
"discord": "Cross Joy#0721"
"discord": "crossjoy"
}
],
"versions": {
"1.0.1": null,
"1.0.0": {
"api_version": 7,
"commit_sha": "800125c",
@ -760,7 +772,7 @@
{
"name": "Cross Joy",
"email": "cross.joy.official@gmail.com",
"discord": "Cross Joy#0721"
"discord": "crossjoy"
}
],
"versions": {
@ -809,10 +821,11 @@
{
"name": "TheMikirog",
"email": "",
"discord": "TheMikirog#1984"
"discord": "themikirog"
}
],
"versions": {
"1.0.1": null,
"1.0.0": {
"api_version": 7,
"commit_sha": "cb2d952",
@ -828,10 +841,11 @@
{
"name": "TheMikirog",
"email": "",
"discord": "TheMikirog#1984"
"discord": "themikirog"
}
],
"versions": {
"1.0.1": null,
"1.0.0": {
"api_version": 7,
"commit_sha": "05ffa9f",
@ -847,10 +861,11 @@
{
"name": "Rikko",
"email": "rikkolovescats@proton.me",
"discord": "Rikko#7383"
"discord": "rikkolovescats"
}
],
"versions": {
"1.0.1": null,
"1.0.0": {
"api_version": 7,
"commit_sha": "3221b3a",

View file

@ -1,15 +1,17 @@
# ba_meta require api 7
import ba
# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport)
# ba_meta require api 8
import babase
import bascenev1 as bs
original_getmodel = ba.getmodel
original_getmesh = bs.getmesh
def get_model_gracefully(model):
if model is not None:
return original_getmodel(model)
def get_mesh_gracefully(mesh):
if mesh is not None:
return original_getmesh(mesh)
# ba_meta export plugin
class Main(ba.Plugin):
class Main(babase.Plugin):
def on_app_running(self):
ba.getmodel = get_model_gracefully
bs.getmesh = get_mesh_gracefully

View file

@ -1,22 +1,25 @@
# ba_meta require api 7
# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport)
# ba_meta require api 8
# AutoStunt mod by - Mr.Smoothy x Rikko
# https://discord.gg/ucyaesh
# https://bombsquad.ga
# https://bombsquad-community.web.app/home
# Dont modify redistribute this plugin , if want to use features of this plugin in your mod write logic in seprate file
# and import this as module.
# If want to contribute in this original module, raise PR on github https://github.com/bombsquad-community/plugin-manager
import ba
import _ba
import bastd
from bastd.actor.text import Text
from bastd.actor.image import Image
from bastd.actor import spaz
from bastd.actor import playerspaz
from bastd.gameutils import SharedObjects
from bastd.actor.powerupbox import PowerupBoxFactory
from bastd.actor.spazfactory import SpazFactory
from bastd.game.elimination import EliminationGame
import babase
import bauiv1 as bui
import bascenev1 as bs
import _babase
import bascenev1lib
from bascenev1lib.actor.text import Text
from bascenev1lib.actor.image import Image
from bascenev1lib.actor import spaz
from bascenev1lib.actor import playerspaz
from bascenev1lib.gameutils import SharedObjects
from bascenev1lib.actor.powerupbox import PowerupBoxFactory
from bascenev1lib.actor.spazfactory import SpazFactory
from bascenev1lib.game.elimination import EliminationGame
import math
import json
import os
@ -26,12 +29,12 @@ from typing import Optional
CONTROLS_CENTER = (0, 0)
CONTROLS_SCALE = 1
BASE_STUNTS_DIRECTORY = os.path.join(_ba.env()["python_directory_user"], "CustomStunts")
BASE_STUNTS_DIRECTORY = os.path.join(_babase.env()["python_directory_user"], "CustomStunts")
PLAYERS_STUNT_INFO = {}
STUNT_CACHE = {}
original_on_begin = ba._activity.Activity.on_begin
original_chatmessage = _ba.chatmessage
original_on_begin = bs._activity.Activity.on_begin
original_chatmessage = bs.chatmessage
class ControlsUI:
@ -105,7 +108,7 @@ CONTROLS_UI_MAP = {
}
class NewSpaz(bastd.actor.spaz.Spaz):
class NewSpaz(bascenev1lib.actor.spaz.Spaz):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.move_map = {
@ -125,7 +128,7 @@ class NewSpaz(bastd.actor.spaz.Spaz):
}
class NewPlayerSpaz(bastd.actor.playerspaz.PlayerSpaz):
class NewPlayerSpaz(bascenev1lib.actor.playerspaz.PlayerSpaz):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.move_map = {
@ -150,7 +153,7 @@ class NewPlayerSpaz(bastd.actor.playerspaz.PlayerSpaz):
def _handle_action(self, action, value: Optional[float] = None) -> None:
if self.source_player.sessionplayer in PLAYERS_STUNT_INFO:
PLAYERS_STUNT_INFO[self.source_player.sessionplayer].append({
"time": ba.time() - self.source_player.recording_start_time,
"time": bs.time() - self.source_player.recording_start_time,
"move": {
"action": action,
"value": value,
@ -230,11 +233,11 @@ def handle_player_replay_end(player):
def get_player_from_client_id(client_id, activity=None):
activity = activity or _ba.get_foreground_host_activity()
activity = activity or bs.get_foreground_host_activity()
for player in activity.players:
if player.sessionplayer.inputdevice.client_id == client_id:
return player
raise ba.SessionPlayerNotFound()
raise bs.SessionPlayerNotFound()
def mirror(clieid):
@ -243,8 +246,8 @@ def mirror(clieid):
def capture(player):
with ba.Context(player.actor._activity()):
player.recording_start_time = ba.time()
with babase.ContextRef(player.actor._activity()):
player.recording_start_time = bs.time()
PLAYERS_STUNT_INFO[player.sessionplayer] = []
@ -266,33 +269,33 @@ def replay(player, stunt_name):
stunt = json.load(fin)
STUNT_CACHE[stunt_name] = stunt
except:
ba.screenmessage(f"{stunt_name} doesn't exists")
bui.screenmessage(f"{stunt_name} doesn't exists")
return
player.in_replay = True
with ba.Context(player.actor._activity()):
with babase.ContextRef(player.actor._activity()):
ControlsUI.display(player.actor._activity())
for move in stunt:
value = move["move"]["value"]
if value is None:
ba.timer(
bs.timer(
move["time"],
ba.Call(player.actor.move_map[move["move"]["action"]])
babase.Call(player.actor.move_map[move["move"]["action"]])
)
else:
ba.timer(
bs.timer(
move["time"],
ba.Call(player.actor.move_map[move["move"]["action"]], move["move"]["value"])
babase.Call(player.actor.move_map[move["move"]["action"]], move["move"]["value"])
)
last_move_time = move["time"]
time_to_hide_controls = last_move_time + 1
ba.timer(time_to_hide_controls, ba.Call(handle_player_replay_end, player))
bs.timer(time_to_hide_controls, babase.Call(handle_player_replay_end, player))
def spawn_mirror_spaz(player):
player.mirror_mode = True
with ba.Context(player.actor._activity()):
with babase.ContextRef(player.actor._activity()):
bot = spaz.Spaz(player.color, player.highlight, character=player.character).autoretain()
bot.handlemessage(ba.StandMessage(
bot.handlemessage(bs.StandMessage(
(player.actor.node.position[0], player.actor.node.position[1], player.actor.node.position[2]+1), 93))
bot.node.name = player.actor.node.name
bot.node.name_color = player.actor.node.name_color
@ -309,51 +312,51 @@ def ghost(player, stunt_name):
stunt = json.load(fin)
STUNT_CACHE[stunt_name] = stunt
except:
ba.screenmessage(f"{stunt_name} doesn't exists")
bui.screenmessage(f"{stunt_name} doesn't exists")
return
player.in_replay = True
with ba.Context(player.actor._activity()):
with babase.ContextRef(player.actor._activity()):
bot = spaz.Spaz((1, 0, 0), character="Spaz").autoretain()
bot.handlemessage(ba.StandMessage(player.actor.node.position, 93))
bot.handlemessage(bs.StandMessage(player.actor.node.position, 93))
give_ghost_power(bot)
ControlsUI.display(player.actor._activity())
for move in stunt:
value = move["move"]["value"]
if value is None:
ba.timer(
bs.timer(
move["time"],
ba.Call(bot.move_map[move["move"]["action"]])
babase.Call(bot.move_map[move["move"]["action"]])
)
ui_activation = CONTROLS_UI_MAP.get(move["move"]["action"])
if ui_activation:
ba.timer(
bs.timer(
move["time"],
ba.Call(ui_activation, player.actor._activity())
babase.Call(ui_activation, player.actor._activity())
)
else:
ba.timer(
bs.timer(
move["time"],
ba.Call(bot.move_map[move["move"]["action"]], move["move"]["value"])
babase.Call(bot.move_map[move["move"]["action"]], move["move"]["value"])
)
ui_activation = CONTROLS_UI_MAP.get(move["move"]["action"])
if ui_activation:
ba.timer(
bs.timer(
move["time"],
ba.Call(ui_activation, player.actor._activity(), move["move"]["value"])
babase.Call(ui_activation, player.actor._activity(), move["move"]["value"])
)
last_move_time = move["time"]
time_to_hide_controls = last_move_time + 1
ba.timer(time_to_hide_controls, ba.Call(handle_player_replay_end, player))
ba.timer(time_to_hide_controls, ba.Call(bot.node.delete))
bs.timer(time_to_hide_controls, babase.Call(handle_player_replay_end, player))
bs.timer(time_to_hide_controls, babase.Call(bot.node.delete))
def give_ghost_power(spaz):
spaz.node.invincible = True
shared = SharedObjects.get()
factory = SpazFactory.get()
ghost = ba.Material()
ghost = bs.Material()
# smoothy hecks
ghost.add_actions(
conditions=(('they_have_material', factory.spaz_material), 'or',
@ -397,7 +400,7 @@ def new_chatmessage(msg):
if command == "start":
capture(player)
_ba.chatmessage("Recording started for {}.".format(
bs.chatmessage("Recording started for {}.".format(
player.getname(),
))
return original_chatmessage(msg)
@ -406,28 +409,28 @@ def new_chatmessage(msg):
if command == "save":
if len(msg_splits) < 2:
ba.screenmessage("Enter name of stunt eg : *save bombjump")
bui.screenmessage("Enter name of stunt eg : *save bombjump")
return original_chatmessage(msg)
save(player, stunt_name)
_ba.chatmessage('Recording "{}" by {} saved.'.format(
bs.chatmessage('Recording "{}" by {} saved.'.format(
stunt_name,
player.getname(),
))
elif command == "stunt":
if len(msg_splits) < 2:
ba.screenmessage("Enter name of stunt eg : *stunt bombjump")
bui.screenmessage("Enter name of stunt eg : *stunt bombjump")
return original_chatmessage(msg)
replay(player, stunt_name)
_ba.chatmessage('Replaying "{}" on {}.'.format(
bs.chatmessage('Replaying "{}" on {}.'.format(
stunt_name,
player.getname(),
))
elif command == "learn":
if len(msg_splits) < 2:
ba.screenmessage("Enter name of stunt eg : *learn bombjump")
bui.screenmessage("Enter name of stunt eg : *learn bombjump")
return original_chatmessage(msg)
ghost(player, stunt_name)
_ba.chatmessage('Replaying "{}" on {}.'.format(
bs.chatmessage('Replaying "{}" on {}.'.format(
stunt_name,
player.getname(),
))
@ -473,25 +476,25 @@ def set_stick_image_position(self, x: float, y: float) -> None:
def on_begin(self, *args, **kwargs) -> None:
self._jump_image = Image(
ba.gettexture('buttonJump'),
bui.gettexture('buttonJump'),
position=(385, 160),
scale=(50, 50),
color=[0.1, 0.45, 0.1, 0]
)
self._pickup_image = Image(
ba.gettexture('buttonPickUp'),
bui.gettexture('buttonPickUp'),
position=(385, 240),
scale=(50, 50),
color=[0, 0.35, 0, 0]
)
self._punch_image = Image(
ba.gettexture('buttonPunch'),
bui.gettexture('buttonPunch'),
position=(345, 200),
scale=(50, 50),
color=[0.45, 0.45, 0, 0]
)
self._bomb_image = Image(
ba.gettexture('buttonBomb'),
bui.gettexture('buttonBomb'),
position=(425, 200),
scale=(50, 50),
color=[0.45, 0.1, 0.1, 0]
@ -499,10 +502,10 @@ def on_begin(self, *args, **kwargs) -> None:
self.stick_image_position_x = self.stick_image_position_y = 0.0
self._stick_base_position = p = (-328, 200)
self._stick_base_image_color = c2 = (0.25, 0.25, 0.25, 1.0)
self._stick_base_image = ba.newnode(
self._stick_base_image = bs.newnode(
'image',
attrs={
'texture': ba.gettexture('nub'),
'texture': bui.gettexture('nub'),
'absolute_scale': True,
'vr_depth': -40,
'position': p,
@ -511,9 +514,9 @@ def on_begin(self, *args, **kwargs) -> None:
})
self._stick_nub_position = p = (-328, 200)
self._stick_nub_image_color = c3 = (0.4, 0.4, 0.4, 1.0)
self._stick_nub_image = ba.newnode('image',
self._stick_nub_image = bs.newnode('image',
attrs={
'texture': ba.gettexture('nub'),
'texture': bui.gettexture('nub'),
'absolute_scale': True,
'position': p,
'scale': (110*0.6, 110*0.66),
@ -526,22 +529,22 @@ def on_begin(self, *args, **kwargs) -> None:
# ba_meta export plugin
class byHeySmoothy(ba.Plugin):
class byHeySmoothy(babase.Plugin):
def on_app_running(self):
_ba.set_party_icon_always_visible(True)
ba._activity.Activity.on_begin = on_begin
_ba.chatmessage = new_chatmessage
bastd.actor.playerspaz.PlayerSpaz = NewPlayerSpaz
bastd.actor.spaz.Spaz = NewSpaz
bui.set_party_icon_always_visible(True)
bs._activity.Activity.on_begin = on_begin
bs.chatmessage = new_chatmessage
bascenev1lib.actor.playerspaz.PlayerSpaz = NewPlayerSpaz
bascenev1lib.actor.spaz.Spaz = NewSpaz
# lets define a sample elimination game that can use super power of this plugin
# ba_meta export game
# ba_meta export bascenev1.GameActivity
class BroEliminaition(EliminationGame):
name = 'BroElimination'
description = 'Elimination Game with dual character control'
def spawn_player(self, player) -> ba.Actor:
def spawn_player(self, player) -> bs.Actor:
super().spawn_player(player)
spawn_mirror_spaz(player)

View file

@ -1,4 +1,5 @@
# ba_meta require api 7
# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport)
# ba_meta require api 8
"""
AutoRun by TheMikirog
@ -18,11 +19,13 @@ from __future__ import annotations
from typing import TYPE_CHECKING
# Let's import everything we need and nothing more.
import ba
import bastd
import babase
import bauiv1 as bui
import bascenev1 as bs
import bascenev1lib
import math
from ba._generated.enums import TimeType
from bastd.actor.spaz import Spaz
from babase._mgen.enums import TimeType
from bascenev1lib.actor.spaz import Spaz
if TYPE_CHECKING:
pass
@ -72,8 +75,7 @@ if TYPE_CHECKING:
# ba_meta export plugin
class AutoRun(ba.Plugin):
class AutoRun(babase.Plugin):
# During my research and prototyping I figured I'd have to do some linear algebgra.
# I didn't want to use libraries, since this is supposed to be a standalone mod.
# Because of this I made certain functions from scratch that are easily accessible.
@ -109,14 +111,13 @@ class AutoRun(ba.Plugin):
# Here I'm defining a new spaz init function that'll be replaced.
def new_init(func):
def wrapper(*args, **kwargs):
# Here's where we execute the original game's code, so it's not lost.
# We want to add our code at the end of the existing code, so our code goes under that.
func(*args, **kwargs)
# We define some variables that we need to keep track of.
# For future reference, if you see args[0] anywhere, that is "self" in the original function.
args[0].autorun_timer: ba.Timer | None = None
args[0].autorun_timer: bs.Timer | None = None
args[0].autorun_override = False
# We wanna do our auto run calculations when the player moves their analog stick to make it responsive.
@ -140,12 +141,14 @@ class AutoRun(ba.Plugin):
# Notice how it's the capital T Timer instead of the small letter.
# That's important, because big T returns a timer object we can manipulate.
# We need it assigned to a variable, because we have to delete it once it stops being relevant.
args[0].autorun_timer = ba.Timer(
0.1, spaz_autorun_update, timetype=TimeType.SIM, repeat=True)
args[0].autorun_timer = bs.Timer(0.1, spaz_autorun_update, repeat=True)
return wrapper
# Let's replace the original function with our modified version.
bastd.actor.spaz.Spaz.__init__ = new_init(bastd.actor.spaz.Spaz.__init__)
bascenev1lib.actor.spaz.Spaz.__init__ = new_init(
bascenev1lib.actor.spaz.Spaz.__init__
)
# This is the bulk of our mod. Our run_update function.
# The goal here is to change the self.node.run attribute of our character.
@ -170,8 +173,10 @@ class AutoRun(ba.Plugin):
movement_vector = [horizontal, vertical]
# Get our character's facing direction
facing_direction = (self.node.position[0] - self.node.position_forward[0],
self.node.position[2] - self.node.position_forward[2])
facing_direction = (
self.node.position[0] - self.node.position_forward[0],
self.node.position[2] - self.node.position_forward[2],
)
# We want our character's facing direction to be a normalized vector (magnitude of 1).
facing_direction = AutoRun.normalize(facing_direction)
@ -216,9 +221,11 @@ class AutoRun(ba.Plugin):
args[0].autorun_override = args[1]
# Here's our original unchanged function
func(*args, **kwargs)
return wrapper
# We replace the character running function with our modified version.
bastd.actor.spaz.Spaz.on_run = new_onrun(bastd.actor.spaz.Spaz.on_run)
bascenev1lib.actor.spaz.Spaz.on_run = new_onrun(bascenev1lib.actor.spaz.Spaz.on_run)
# There's two function that are called when our player pushes the analog stick - two for each axis.
# Here's for the vertical axis.
@ -229,9 +236,13 @@ class AutoRun(ba.Plugin):
# If we're not holding the run button and we're a player, run our auto run behavior.
if not args[0].autorun_override and args[0].source_player:
AutoRun.run_update(args[0])
return wrapper
# You get the idea.
bastd.actor.spaz.Spaz.on_move_up_down = new_updown(bastd.actor.spaz.Spaz.on_move_up_down)
bascenev1lib.actor.spaz.Spaz.on_move_up_down = new_updown(
bascenev1lib.actor.spaz.Spaz.on_move_up_down
)
# Let's do the same for our horizontal axis.
# Second verse same as the first.
@ -240,9 +251,12 @@ class AutoRun(ba.Plugin):
func(*args, **kwargs)
if not args[0].autorun_override and args[0].source_player:
AutoRun.run_update(args[0])
return wrapper
bastd.actor.spaz.Spaz.on_move_left_right = new_leftright(
bastd.actor.spaz.Spaz.on_move_left_right)
bascenev1lib.actor.spaz.Spaz.on_move_left_right = new_leftright(
bascenev1lib.actor.spaz.Spaz.on_move_left_right
)
# There's one downside to the looping timer - it runs constantly even if the player is dead.
# We don't want to waste computational power on something like that.
@ -250,10 +264,14 @@ class AutoRun(ba.Plugin):
def new_handlemessage(func):
def wrapper(*args, **kwargs):
# Only react to the death message.
if isinstance(args[1], ba.DieMessage):
if isinstance(args[1], bs.DieMessage):
# Kill the timer.
args[0].autorun_timer = None
# Original function.
func(*args, **kwargs)
return wrapper
bastd.actor.spaz.Spaz.handlemessage = new_handlemessage(bastd.actor.spaz.Spaz.handlemessage)
bascenev1lib.actor.spaz.Spaz.handlemessage = new_handlemessage(
bascenev1lib.actor.spaz.Spaz.handlemessage
)

View file

@ -1,4 +1,5 @@
# ba_meta require api 7
# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport)
# ba_meta require api 8
"""
Bomb Radius Visualizer by TheMikirog
@ -16,9 +17,11 @@ from __future__ import annotations
from typing import TYPE_CHECKING
# Let's import everything we need and nothing more.
import ba
import bastd
from bastd.actor.bomb import Bomb
import babase
import bauiv1 as bui
import bascenev1 as bs
import bascenev1lib
from bascenev1lib.actor.bomb import Bomb
if TYPE_CHECKING:
pass
@ -26,7 +29,7 @@ if TYPE_CHECKING:
# ba_meta export plugin
class BombRadiusVisualizer(ba.Plugin):
class BombRadiusVisualizer(babase.Plugin):
# We use a decorator to add extra code to existing code, increasing mod compatibility.
# Here I'm defining a new bomb init function that'll be replaced.
@ -44,7 +47,7 @@ class BombRadiusVisualizer(ba.Plugin):
# Let's make a new node that's just a circle. It's the some one used in the Target Practice minigame.
# This is going to make a slightly opaque red circle, signifying damaging area.
# We aren't defining the size, because we're gonna animate it shortly after.
args[0].radius_visualizer = ba.newnode('locator',
args[0].radius_visualizer = bs.newnode('locator',
# Remove itself when the bomb node dies.
owner=args[0].node,
attrs={
@ -59,14 +62,14 @@ class BombRadiusVisualizer(ba.Plugin):
# Let's do a fancy animation of that red circle growing into shape like a cartoon.
# We're gonna read our bomb's blast radius and use it to decide the size of our circle.
ba.animate_array(args[0].radius_visualizer, 'size', 1, {
bs.animate_array(args[0].radius_visualizer, 'size', 1, {
0.0: [0.0],
0.2: [args[0].blast_radius * 2.2],
0.25: [args[0].blast_radius * 2.0]
})
# Let's do a second circle, this time just the outline to where the damaging area ends.
args[0].radius_visualizer_circle = ba.newnode('locator',
args[0].radius_visualizer_circle = bs.newnode('locator',
# Remove itself when the bomb node dies.
owner=args[0].node,
attrs={
@ -81,7 +84,7 @@ class BombRadiusVisualizer(ba.Plugin):
args[0].node.connectattr('position', args[0].radius_visualizer_circle, 'position')
# Let's animate that circle too, but this time let's do the opacity.
ba.animate(
bs.animate(
args[0].radius_visualizer_circle, 'opacity', {
0: 0.0,
0.4: 0.1
@ -90,4 +93,4 @@ class BombRadiusVisualizer(ba.Plugin):
# Finally we """travel through the game files""" to replace the function we want with our own version.
# We transplant the old function's arguments into our version.
bastd.actor.bomb.Bomb.__init__ = new_bomb_init(bastd.actor.bomb.Bomb.__init__)
bascenev1lib.actor.bomb.Bomb.__init__ = new_bomb_init(bascenev1lib.actor.bomb.Bomb.__init__)

View file

@ -1,12 +1,22 @@
# Ported by brostos to api 8
# Tool used to make porting easier.(https://github.com/bombsquad-community/baport)
"""python 3.9 | chatcmd for a beutiful game - BombSquad OwO"""
# modded by IM_NOT_PRANAV#7874
# biggggggg thankssssssssssssss to FireFighter1037 for helping everything
# -*- coding: utf-8 -*-
# ba_meta require api 7
from _ba import env, get_foreground_host_activity, get_foreground_host_session, get_game_roster, get_chat_messages, set_party_icon_always_visible, chatmessage as cmsg, screenmessage as smsg
import ba
# Ported by brostos to api 8
# ba_meta require api 8
import threading
import time
from bascenev1 import get_foreground_host_activity, get_foreground_host_session, get_game_roster, get_chat_messages, chatmessage as cmsg
from bauiv1 import set_party_icon_always_visible, screenmessage as smsg
import babase
import bauiv1 as bui
import bascenev1 as bs
from bauiv1lib import mainmenu
# our prefix that what we starts cmds with
px = '/'
@ -17,7 +27,7 @@ px = '/'
class _cmds:
def _process_cmd():
set_party_icon_always_visible(True)
try:
messages = get_chat_messages()
if len(messages) > 1:
lastmsg = messages[len(messages)-1]
@ -27,6 +37,9 @@ class _cmds:
return _cmds._handle()
else:
pass
except:
pass
def _handle():
messages = get_chat_messages()
@ -137,17 +150,17 @@ class _cmds:
cmsg('could not found player')
elif m in [px+'quit', px+'restart']:
ba.quit()
babase.quit()
elif m in [px+'mute', px+'mutechat']:
cfg = ba.app.config
cfg = babase.app.config
cfg['Chat Muted'] = True
cfg.apply_and_commit()
cmsg('muted')
smsg(f'chat muted use {px}unmute and click on send to unmute')
elif m in [px+'unmute', px+'unmutechat']:
cfg = ba.app.config
cfg = babase.app.config
cfg['Chat Muted'] = False
cfg.apply_and_commit()
cmsg('un_muted')
@ -222,16 +235,16 @@ class _cmds:
elif n[0] == 'all':
for i in activity_players:
body = i.actor.node
if not body.torso_model == None:
body.head_model = None
body.torso_model = None
body.upper_arm_model = None
body.forearm_model = None
body.pelvis_model = None
body.hand_model = None
body.toes_model = None
body.upper_leg_model = None
body.lower_leg_model = None
if not body.torso_mesh == None:
body.head_mesh = None
body.torso_mesh = None
body.upper_arm_mesh = None
body.forearm_mesh = None
body.pelvis_mesh = None
body.hand_mesh = None
body.toes_mesh = None
body.upper_leg_mesh = None
body.lower_leg_mesh = None
body.style = 'cyborg'
cmsg('All invisible now Dont get cought')
else:
@ -239,16 +252,16 @@ class _cmds:
else:
body = activity_players[int(n[0])].actor.node
is_name = session_players[int(n[0])].getname()
if not body.torso_model == None:
body.head_model = None
body.torso_model = None
body.upper_arm_model = None
body.forearm_model = None
body.pelvis_model = None
body.hand_model = None
body.toes_model = None
body.upper_leg_model = None
body.lower_leg_model = None
if not body.torso_mesh == None:
body.head_mesh = None
body.torso_mesh = None
body.upper_arm_mesh = None
body.forearm_mesh = None
body.pelvis_mesh = None
body.hand_mesh = None
body.toes_mesh = None
body.upper_leg_mesh = None
body.lower_leg_mesh = None
body.style = 'cyborg'
cmsg(is_name+' using invisiblelity ')
else:
@ -260,8 +273,8 @@ class _cmds:
elif n[0] == 'all':
for i in activity_players:
body = i.actor.node
if not body.head_model == None:
body.head_model = None
if not body.head_mesh == None:
body.head_mesh = None
body.style = 'cyborg'
cmsg('headless ? xD')
else:
@ -269,8 +282,8 @@ class _cmds:
else:
body = activity_players[int(n[0])].actor.node
is_name = session_players[int(n[0])].getname()
if not body.head_model == None:
body.head_model = None
if not body.head_mesh == None:
body.head_mesh = None
body.style = 'cyborg'
cmsg(is_name+'is headless now xD')
else:
@ -282,16 +295,16 @@ class _cmds:
elif n[0] == 'all':
for i in activity_players:
body = i.actor.node
body.head_model = None
body.handlemessage(ba.PowerupMessage(poweruptype='punch'))
body.handlemessage(ba.PowerupMessage(poweruptype='shield'))
body.head_mesh = None
body.handlemessage(bs.PowerupMessage(poweruptype='punch'))
body.handlemessage(bs.PowerupMessage(poweruptype='shield'))
cmsg('dont creep out childs all will be scared')
else:
try:
body = activity_players[int(n[0])].actor.node
body.head_model = None
body.handlemessage(ba.PowerupMessage(poweruptype='punch'))
body.handlemessage(ba.PowerupMessage(poweruptype='shield'))
body.head_mesh = None
body.handlemessage(bs.PowerupMessage(poweruptype='punch'))
body.handlemessage(bs.PowerupMessage(poweruptype='shield'))
cmsg('dont creep out childs all will be scared')
except:
cmsg('could not found player to make')
@ -301,11 +314,11 @@ class _cmds:
cmsg(f'Use : {px}kill all or {px}kill number of list')
elif n[0] == 'all':
for i in activity_players:
i.actor.node.handlemessage(ba.DieMessage())
i.actor.node.handlemessage(bs.DieMessage())
cmsg('Killed all')
else:
is_name = session_players[int(n[0])].getname()
activity_players[int(n[0])].actor.node.handlemessage(ba.DieMessage())
activity_players[int(n[0])].actor.node.handlemessage(bs.DieMessage())
cmsg('Killed '+is_name)
elif m in [px+'heal', px+'heath']:
@ -313,12 +326,12 @@ class _cmds:
cmsg(f'Use: {px}heal all or {px}heal number of list')
elif n[0] == 'all':
for i in activity_players:
i.actor.node.handlemessage(ba.PowerupMessage(poweruptype='health'))
i.actor.node.handlemessage(bs.PowerupMessage(poweruptype='health'))
cmsg('Heald all')
else:
is_name = session_players[int(n[0])].getname()
activity_players[int(n[0])].actor.node.handlemessage(
ba.PowerupMessage(poweruptype='health'))
bs.PowerupMessage(poweruptype='health'))
cmsg('Heald '+is_name)
elif m in [px+'curse', px+'cur']:
@ -326,12 +339,12 @@ class _cmds:
cmsg(f'Use: {px}curse all or {px}curse number of list')
elif n[0] == 'all':
for i in activity_players:
i.actor.node.handlemessage(ba.PowerupMessage(poweruptype='curse'))
i.actor.node.handlemessage(bs.PowerupMessage(poweruptype='curse'))
cmsg('Cursed all')
else:
is_name = session_players[int(n[0])].getname()
activity_players[int(n[0])].actor.node.handlemessage(
ba.PowerupMessage(poweruptype='curse'))
bs.PowerupMessage(poweruptype='curse'))
cmsg('Cursed '+is_name)
elif m in [px+'sleep']:
@ -378,12 +391,12 @@ class _cmds:
cmsg(f'Use: {px}gloves all or {px}gloves number of list')
elif n[0] == 'all':
for i in activity_players:
i.actor.node.handlemessage(ba.PowerupMessage(poweruptype='punch'))
i.actor.node.handlemessage(bs.PowerupMessage(poweruptype='punch'))
cmsg('Free Gloves enjoy all')
else:
is_name = session_players[int(n[0])].getname()
activity_players[int(n[0])].actor.node.handlemessage(
ba.PowerupMessage(poweruptype='punch'))
bs.PowerupMessage(poweruptype='punch'))
cmsg(is_name+' using gloves')
elif m in [px+'shield', px+'protect']:
@ -391,12 +404,12 @@ class _cmds:
cmsg(f'Use: {px}shield all or {px}shield number of list')
elif n[0] == 'all':
for i in activity_players:
i.actor.node.handlemessage(ba.PowerupMessage(poweruptype='shield'))
i.actor.node.handlemessage(bs.PowerupMessage(poweruptype='shield'))
cmsg('Everyone enjoy free shield :)')
else:
is_name = session_players[int(n[0])].getname()
activity_players[int(n[0])].actor.node.handlemessage(
ba.PowerupMessage(poweruptype='shield'))
bs.PowerupMessage(poweruptype='shield'))
cmsg(is_name+' using shield')
elif m in [px+'freeze', px+'ice']:
@ -404,11 +417,11 @@ class _cmds:
cmsg(f'Use: {px}freeze all or {px}freeze number of list')
elif n[0] == 'all':
for i in activity_players:
i.actor.node.handlemessage(ba.FreezeMessage())
i.actor.node.handlemessage(bs.FreezeMessage())
cmsg('Freezed all')
else:
is_name = session_players[int(n[0])].getname()
activity_players[int(n[0])].actor.node.handlemessage(ba.FreezeMessage())
activity_players[int(n[0])].actor.node.handlemessage(bs.FreezeMessage())
cmsg('Un freezed '+is_name)
elif m in [px+'unfreeze', px+'thaw']:
@ -416,11 +429,11 @@ class _cmds:
cmsg(f'Use: {px}unfreeze/thaw all or {px}unfreeze/thaw number of list')
elif n[0] == 'all':
for i in activity_players:
i.actor.node.handlemessage(ba.ThawMessage())
i.actor.node.handlemessage(bs.ThawMessage())
cmsg('Un freezed all ')
else:
is_name = session_players[int(n[0])].getname()
activity_players[int(n[0])].actor.node.handlemessage(ba.ThawMessage())
activity_players[int(n[0])].actor.node.handlemessage(bs.ThawMessage())
cmsg('Un freezed '+is_name)
elif m in [px+'fall']:
@ -428,11 +441,11 @@ class _cmds:
cmsg(f'Use: {px}fall all or {px}fall number of list')
elif n[0] == 'all':
for i in activity_players:
i.actor.node.handlemessage(ba.StandMessage())
i.actor.node.handlemessage(bs.StandMessage())
cmsg('Felt everyone')
else:
is_name = session_players[int(n[0])].getname()
activity_players[int(n[0])].actor.node.handlemessage(ba.StandMessage())
activity_players[int(n[0])].actor.node.handlemessage(bs.StandMessage())
cmsg(is_name+' got felt')
elif m in [px+'celebrate', px+'celeb']:
@ -440,11 +453,11 @@ class _cmds:
cmsg(f'Use: {px}celebrate all or {px}celebrate number of list')
elif n[0] == 'all':
for i in activity_players:
i.actor.node.handlemessage(ba.CelebrateMessage())
i.actor.node.handlemessage(bs.CelebrateMessage())
cmsg('Celebrate all :)')
else:
is_name = session_players[int(n[0])].getname()
activity_players[int(n[0])].actor.node.handlemessage(ba.CelebrateMessage())
activity_players[int(n[0])].actor.node.handlemessage(bs.CelebrateMessage())
cmsg(is_name+' is celebrating bt why?')
elif m in [px+'fly']:
@ -531,13 +544,24 @@ class _cmds:
cmsg(u'\U0001F95A Nazz are past/present/future \U0001F95A')
cmsg(u'\U0001F95A everything is Nazz \U0001F95A')
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
bui.set_party_icon_always_visible(True)
# ba.timer(0.05, _update, repeat=True)
# bs.timer(0.05, _update, repeat=True)
def same():
ba.timer(0.5, _cmds._process_cmd, True)
# ba_meta export plugin
# bs.timer(0.5, _cmds._process_cmd, True)
_cmds._process_cmd()
# ba_meta export babase.Plugin
class _enableee(babase.Plugin):
timer = bs.AppTimer(0.5, same,repeat=True)
def on_app_running(self):
mainmenu.MainMenuWindow = NewMainMenuWindow
class _enableee(ba.Plugin):
same()

View file

@ -1,13 +1,16 @@
# ba_meta require api 7
# Porting to api 8 made easier by 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 ba
import babase
import bauiv1 as bui
import bascenev1 as bs
import random
from bastd.actor import bomb
from bascenev1lib.actor import bomb
if TYPE_CHECKING:
from typing import Sequence
@ -20,7 +23,7 @@ class NewBlast(bomb.Blast):
velocity: Sequence[float] = (0.0, 0.0, 0.0),
blast_radius: float = 2.0,
blast_type: str = 'normal',
source_player: ba.Player | None = None,
source_player: bs.Player | None = None,
hit_type: str = 'explosion',
hit_subtype: str = 'normal',
):
@ -29,7 +32,7 @@ class NewBlast(bomb.Blast):
scorch_radius = light_radius = self.radius
if self.blast_type == 'tnt':
scorch_radius *= 1.15
scorch = ba.newnode(
scorch = bs.newnode(
'scorch',
attrs={
'position': position,
@ -38,11 +41,11 @@ class NewBlast(bomb.Blast):
},
)
random_color = (random.random(), random.random(), random.random())
scorch.color = ba.safecolor(random_color)
ba.animate(scorch, 'presence', {3.000: 1, 13.000: 0})
ba.timer(13.0, scorch.delete)
scorch.color = babase.safecolor(random_color)
bs.animate(scorch, 'presence', {3.000: 1, 13.000: 0})
bs.timer(13.0, scorch.delete)
# ba_meta export plugin
class RandomColorsPlugin(ba.Plugin):
class RandomColorsPlugin(babase.Plugin):
bomb.Blast = NewBlast

View file

@ -1,12 +1,14 @@
# ba_meta require api 7
# Porting to api 8 made easier by 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 ba
from bastd.actor.spaz import Spaz
import babase
import bascenev1 as bs
from bascenev1lib.actor.spaz import Spaz
if TYPE_CHECKING:
from typing import Any
@ -16,19 +18,19 @@ Spaz.oldhandlemessage = Spaz.handlemessage
def handlemessage(self, msg: Any) -> Any:
if isinstance(msg, ba.DieMessage):
if isinstance(msg, bs.DieMessage):
if self.node:
self.node.color_texture = ba.gettexture('bonesColor')
self.node.color_mask_texture = ba.gettexture('bonesColorMask')
self.node.head_model = ba.getmodel('bonesHead')
self.node.torso_model = ba.getmodel('bonesTorso')
self.node.pelvis_model = ba.getmodel('bonesPelvis')
self.node.upper_arm_model = ba.getmodel('bonesUpperArm')
self.node.forearm_model = ba.getmodel('bonesForeArm')
self.node.hand_model = ba.getmodel('bonesHand')
self.node.upper_leg_model = ba.getmodel('bonesUpperLeg')
self.node.lower_leg_model = ba.getmodel('bonesLowerLeg')
self.node.toes_model = ba.getmodel('bonesToes')
self.node.color_texture = bs.gettexture('bonesColor')
self.node.color_mask_texture = bs.gettexture('bonesColorMask')
self.node.head_mesh = bs.getmesh('bonesHead')
self.node.torso_mesh = bs.getmesh('bonesTorso')
self.node.pelvis_mesh = bs.getmesh('bonesPelvis')
self.node.upper_arm_mesh = bs.getmesh('bonesUpperArm')
self.node.forearm_mesh = bs.getmesh('bonesForeArm')
self.node.hand_mesh = bs.getmesh('bonesHand')
self.node.upper_leg_mesh = bs.getmesh('bonesUpperLeg')
self.node.lower_leg_mesh = bs.getmesh('bonesLowerLeg')
self.node.toes_mesh = bs.getmesh('bonesToes')
self.node.style = 'bones'
self.oldhandlemessage(msg)
else:
@ -36,5 +38,5 @@ def handlemessage(self, msg: Any) -> Any:
# ba_meta export plugin
class CustomDeath(ba.Plugin):
class CustomDeath(babase.Plugin):
Spaz.handlemessage = handlemessage

View file

@ -1,3 +1,4 @@
# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport)
"""Disco Light Mod: V1.0
Made by Cross Joy"""
@ -5,7 +6,7 @@ Made by Cross Joy"""
# Can visit my github https://github.com/CrossJoy/Bombsquad-Modding
# You can contact me through discord:
# My Discord Id: Cross Joy#0721
# My Discord Id: crossjoy
# My BS Discord Server: https://discord.gg/JyBY6haARJ
@ -25,19 +26,22 @@ Made by Cross Joy"""
# Other clients/players can't use the commands.
# ----------------------------------------------------------------------------
# ba_meta require api 7
# ba_meta require api 8
from __future__ import annotations
from typing import TYPE_CHECKING
import ba
import _ba
from ba import _gameutils
from baenv import TARGET_BALLISTICA_BUILD as build_number
from bauiv1lib import mainmenu
import babase
import bauiv1 as bui
import bascenev1 as bs
import _babase
from bascenev1 import _gameutils, animate
import random
from ba import animate
if TYPE_CHECKING:
from typing import Sequence, Union
@ -51,38 +55,38 @@ def is_game_version_lower_than(version):
version is lower than the passed version. Useful for addressing
any breaking changes within game versions.
"""
game_version = tuple(map(int, ba.app.version.split(".")))
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 = ba.internal
# if is_game_version_lower_than("1.7.7"):
# ba_internal = _ba
# else:
# ba_internal = babase.internal
# Activate disco light.
def start():
activity = _ba.get_foreground_host_activity()
activity = bs.get_foreground_host_activity()
with ba.Context(activity):
with activity.context:
partyLight(True)
rainbow(activity)
# Deactivate disco light.
def stop():
activity = _ba.get_foreground_host_activity()
activity = bs.get_foreground_host_activity()
with ba.Context(activity):
with activity.context:
partyLight(False)
stop_rainbow(activity)
# Create and animate colorful spotlight.
def partyLight(switch=True):
from ba._nodeactor import NodeActor
from bascenev1._nodeactor import NodeActor
x_spread = 10
y_spread = 5
positions = [[-x_spread, -y_spread], [0, -y_spread], [0, y_spread],
@ -91,14 +95,14 @@ def partyLight(switch=True):
times = [0, 2700, 1000, 1800, 500, 1400]
# Store this on the current activity, so we only have one at a time.
activity = _ba.getactivity()
activity = bs.getactivity()
activity.camera_flash_data = [] # type: ignore
for i in range(6):
r = random.choice([0.5, 1])
g = random.choice([0.5, 1])
b = random.choice([0.5, 1])
light = NodeActor(
_ba.newnode('light',
bs.newnode('light',
attrs={
'position': (positions[i][0], 0, positions[i][1]),
'radius': 1.0,
@ -108,7 +112,7 @@ def partyLight(switch=True):
}))
sval = 1.87
iscale = 1.3
tcombine = _ba.newnode('combine',
tcombine = bs.newnode('combine',
owner=light.node,
attrs={
'size': 3,
@ -149,7 +153,7 @@ def partyLight(switch=True):
loop=True,
offset=times[i])
if not switch:
_ba.timer(0.1,
bs.timer(0.1,
light.node.delete)
activity.camera_flash_data.append(light) # type: ignore
@ -158,7 +162,7 @@ def partyLight(switch=True):
def rainbow(self) -> None:
"""Create RGB tint."""
c_existing = self.globalsnode.tint
cnode = _ba.newnode('combine',
cnode = bs.newnode('combine',
attrs={
'input0': c_existing[0],
'input1': c_existing[1],
@ -187,11 +191,14 @@ def rainbow(self) -> None:
# Revert to the original map tint.
def stop_rainbow(self):
"""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)
cnode = _ba.newnode('combine',
cnode = bs.newnode('combine',
attrs={
'input0': c_existing[0],
'input1': c_existing[1],
@ -249,11 +256,11 @@ def check_map_tint(map_name):
# Get the original game codes.
old_fcm = ba_internal.chatmessage
old_fcm = bs.chatmessage
# New chat func to add some commands to activate/deactivate the disco light.
def new_chat_message(msg: Union[str, ba.Lstr], clients: Sequence[int] = None,
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':
@ -261,13 +268,18 @@ def new_chat_message(msg: Union[str, ba.Lstr], clients: Sequence[int] = None,
if msg == '/disco off':
stop()
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
bui.set_party_icon_always_visible(True)
# Replace new chat func to the original game codes.
ba_internal.chatmessage = new_chat_message
if not ba_internal.is_party_icon_visible():
ba_internal.set_party_icon_always_visible(True)
bs.chatmessage = new_chat_message
# ba_meta export plugin
class ByCrossJoy(ba.Plugin):
def __init__(self): pass
class ByCrossJoy(babase.Plugin):
def on_app_running(self):
mainmenu.MainMenuWindow = NewMainMenuWindow

View file

@ -370,7 +370,7 @@ def get_event_loop(force_fresh=False):
def _generate_join_secret(self):
# resp = requests.get('https://legacy.ballistica.net/bsAccessCheck').text
connection_info = bs.get_connection_to_host_info_2()
connection_info = bs.get_connection_to_host_info() if build_number < 21697 else bs.get_connection_to_host_info_2()
if connection_info:
addr = _last_server_addr
port = _last_server_port
@ -870,7 +870,7 @@ class DiscordRP(babase.Plugin):
def update_status(self) -> None:
roster = bs.get_game_roster()
connection_info = bs.get_connection_to_host_info_2()
connection_info = bs.get_connection_to_host_info() if build_number < 21697 else bs.get_connection_to_host_info_2()
self.rpc_thread.large_image_key = "bombsquadicon"
self.rpc_thread.large_image_text = "BombSquad"
@ -963,7 +963,7 @@ class DiscordRP(babase.Plugin):
points = act._score
self.rpc_thread.details += f" ({points} points)"
elif isinstance(act, MeteorShowerGame):
with bs.ContextRef(act):
with act.context:
sec = bs.time() - act._timer.getstarttime()
secfmt = ""
if sec < 60:

View file

@ -1,29 +1,32 @@
# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport)
"""===========MAX_PLAYERS==========="""
# ba_meta require api 7
# ba_meta require api 8
# (see https://ballistica.net/wiki/meta-tag-system)
from __future__ import annotations
from typing import TYPE_CHECKING
import ba
import _ba
from ba._session import Session
from ba._coopsession import CoopSession, TEAM_COLORS, TEAM_NAMES
from ba._multiteamsession import MultiTeamSession
from bastd.ui.gather import GatherWindow
from bastd.ui.popup import PopupWindow
import babase
import bauiv1 as bui
import bascenev1 as bs
import _babase
from bascenev1._session import Session
from bascenev1._coopsession import CoopSession, TEAM_COLORS, TEAM_NAMES
from bascenev1._multiteamsession import MultiTeamSession
from bauiv1lib.gather import GatherWindow
from bauiv1lib.popup import PopupWindow
if TYPE_CHECKING:
from typing import List, Any, Optional, Sequence
cfg = ba.app.config
cfg = babase.app.config
cmp = {'coop_max_players': 4,
'teams_max_players': 8,
'ffa_max_players': 8}
lang = ba.app.lang.language
lang = bs.app.lang.language
if lang == 'Spanish':
title_text = 'Máximo de Jugadores'
title_short_text = 'Jugadores'
@ -41,7 +44,7 @@ else:
class ConfigNumberEdit:
def __init__(self,
parent: ba.Widget,
parent: bui.Widget,
position: Tuple[float, float],
value: int,
config: str,
@ -53,7 +56,7 @@ class ConfigNumberEdit:
self._config = config
textscale = 1.0
self.nametext = ba.textwidget(
self.nametext = bui.textwidget(
parent=parent,
position=(position[0], position[1]),
size=(100, 30),
@ -63,7 +66,7 @@ class ConfigNumberEdit:
h_align='left',
v_align='center',
scale=textscale)
self.valuetext = ba.textwidget(
self.valuetext = bui.textwidget(
parent=parent,
position=(position[0]+150, position[1]),
size=(60, 28),
@ -73,21 +76,21 @@ class ConfigNumberEdit:
v_align='center',
text=str(value),
padding=2)
self.minusbutton = ba.buttonwidget(
self.minusbutton = bui.buttonwidget(
parent=parent,
position=(position[0]+240, position[1]),
size=(28, 28),
label='-',
autoselect=True,
on_activate_call=ba.Call(self._down),
on_activate_call=babase.Call(self._down),
repeat=True)
self.plusbutton = ba.buttonwidget(
self.plusbutton = bui.buttonwidget(
parent=parent,
position=(position[0]+290, position[1]),
size=(28, 28),
label='+',
autoselect=True,
on_activate_call=ba.Call(self._up),
on_activate_call=babase.Call(self._up),
repeat=True)
def _up(self) -> None:
@ -99,7 +102,7 @@ class ConfigNumberEdit:
self._update_display()
def _update_display(self) -> None:
ba.textwidget(edit=self.valuetext, text=str(self._value))
bui.textwidget(edit=self.valuetext, text=str(self._value))
cfg['Config Max Players'][self._config] = self._value
cfg.apply_and_commit()
@ -108,7 +111,7 @@ class SettingsMaxPlayers(PopupWindow):
def __init__(self):
# pylint: disable=too-many-locals
uiscale = ba.app.ui.uiscale
uiscale = bui.app.ui_v1.uiscale
self._transitioning_out = False
self._width = 400
self._height = 220
@ -121,7 +124,7 @@ class SettingsMaxPlayers(PopupWindow):
scale=1.2,
bg_color=bg_color)
self._cancel_button = ba.buttonwidget(
self._cancel_button = bui.buttonwidget(
parent=self.root_widget,
position=(25, self._height - 40),
size=(50, 50),
@ -130,12 +133,12 @@ class SettingsMaxPlayers(PopupWindow):
color=bg_color,
on_activate_call=self._on_cancel_press,
autoselect=True,
icon=ba.gettexture('crossOut'),
icon=bui.gettexture('crossOut'),
iconscale=1.2)
ba.containerwidget(edit=self.root_widget,
bui.containerwidget(edit=self.root_widget,
cancel_button=self._cancel_button)
ba.textwidget(
bui.textwidget(
parent=self.root_widget,
position=(self._width * 0.5, self._height - 30),
size=(0, 0),
@ -144,7 +147,7 @@ class SettingsMaxPlayers(PopupWindow):
scale=0.8,
text=title_text,
maxwidth=200,
color=ba.app.ui.title_color)
color=bui.app.ui_v1.title_color)
posx = 33
posy = self._height
@ -176,37 +179,38 @@ class SettingsMaxPlayers(PopupWindow):
def _transition_out(self) -> None:
if not self._transitioning_out:
self._transitioning_out = True
ba.containerwidget(edit=self.root_widget, transition='out_scale')
bui.containerwidget(edit=self.root_widget, transition='out_scale')
def on_popup_cancel(self) -> None:
ba.playsound(ba.getsound('swish'))
bui.getsound('swish').play()
self._transition_out()
def __init__(self) -> None:
"""Instantiate a co-op mode session."""
# pylint: disable=cyclic-import
from ba._campaign import getcampaign
from bastd.activity.coopjoin import CoopJoinActivity
getcampaign = bui.app.classic.getcampaign
from bascenev1lib.activity.coopjoin import CoopJoinActivity
_ba.increment_analytics_count('Co-op session start')
app = _ba.app
_babase.increment_analytics_count('Co-op session start')
app = babase.app
classic = app.classic
# If they passed in explicit min/max, honor that.
# Otherwise defer to user overrides or defaults.
if 'min_players' in app.coop_session_args:
min_players = app.coop_session_args['min_players']
if 'min_players' in classic.coop_session_args:
min_players = classic.coop_session_args['min_players']
else:
min_players = 1
if 'max_players' in app.coop_session_args:
max_players = app.coop_session_args['max_players']
if 'max_players' in classic.coop_session_args:
max_players = classic.coop_session_args['max_players']
else:
max_players = app.config.get(
'Coop Game Max Players',
cfg['Config Max Players']['coop_max_players'])
# print('FIXME: COOP SESSION WOULD CALC DEPS.')
depsets: Sequence[ba.DependencySet] = []
depsets: Sequence[babase.DependencySet] = []
Session.__init__(self,
depsets,
@ -217,30 +221,30 @@ def __init__(self) -> None:
# Tournament-ID if we correspond to a co-op tournament (otherwise None)
self.tournament_id: Optional[str] = (
app.coop_session_args.get('tournament_id'))
classic.coop_session_args.get('tournament_id'))
self.campaign = getcampaign(app.coop_session_args['campaign'])
self.campaign_level_name: str = app.coop_session_args['level']
self.campaign = getcampaign(classic.coop_session_args['campaign'])
self.campaign_level_name: str = classic.coop_session_args['level']
self._ran_tutorial_activity = False
self._tutorial_activity: Optional[ba.Activity] = None
self._tutorial_activity: Optional[babase.Activity] = None
self._custom_menu_ui: List[Dict[str, Any]] = []
# Start our joining screen.
self.setactivity(_ba.newactivity(CoopJoinActivity))
self.setactivity(bs.newactivity(CoopJoinActivity))
self._next_game_instance: Optional[ba.GameActivity] = None
self._next_game_instance: Optional[bs.GameActivity] = None
self._next_game_level_name: Optional[str] = None
self._update_on_deck_game_instances()
def get_max_players(self) -> int:
"""Return max number of ba.Players allowed to join the game at once."""
"""Return max number of bs.Players allowed to join the game at once."""
if self.use_teams:
return _ba.app.config.get(
return _babase.app.config.get(
'Team Game Max Players',
cfg['Config Max Players']['teams_max_players'])
return _ba.app.config.get(
return _babase.app.config.get(
'Free-for-All Max Players',
cfg['Config Max Players']['ffa_max_players'])
@ -250,18 +254,18 @@ GatherWindow.__old_init__ = GatherWindow.__init__
def __gather_init__(self,
transition: Optional[str] = 'in_right',
origin_widget: ba.Widget = None):
origin_widget: bui.Widget = None):
self.__old_init__(transition, origin_widget)
def _do_max_players():
SettingsMaxPlayers()
self._max_players_button = ba.buttonwidget(
self._max_players_button = bui.buttonwidget(
parent=self._root_widget,
position=(self._width*0.72, self._height*0.91),
size=(220, 60),
scale=1.0,
color=(0.6, 0.0, 0.9),
icon=ba.gettexture('usersButton'),
icon=bui.gettexture('usersButton'),
iconscale=1.5,
autoselect=True,
label=title_short_text,
@ -290,11 +294,11 @@ def _save_state(self) -> None:
sel_name = 'TabContainer'
else:
raise ValueError(f'unrecognized selection: \'{sel}\'')
ba.app.ui.window_states[type(self)] = {
bui.app.ui_v1.window_states[type(self)] = {
'sel_name': sel_name,
}
except Exception:
ba.print_exception(f'Error saving state for {self}.')
babase.print_exception(f'Error saving state for {self}.')
def _restore_state(self) -> None:
@ -303,12 +307,12 @@ def _restore_state(self) -> None:
for tab in self._tabs.values():
tab.restore_state()
sel: Optional[ba.Widget]
winstate = ba.app.ui.window_states.get(type(self), {})
sel: Optional[bui.Widget]
winstate = bui.app.ui_v1.window_states.get(type(self), {})
sel_name = winstate.get('sel_name', None)
assert isinstance(sel_name, (str, type(None)))
current_tab = self.TabID.ABOUT
gather_tab_val = ba.app.config.get('Gather Tab')
gather_tab_val = babase.app.config.get('Gather Tab')
try:
stored_tab = enum_by_value(self.TabID, gather_tab_val)
if stored_tab in self._tab_row.tabs:
@ -331,35 +335,35 @@ def _restore_state(self) -> None:
sel = self._tab_row.tabs[sel_tab_id].button
else:
sel = self._tab_row.tabs[current_tab].button
ba.containerwidget(edit=self._root_widget, selected_child=sel)
bui.containerwidget(edit=self._root_widget, selected_child=sel)
except Exception:
ba.print_exception('Error restoring gather-win state.')
babase.print_exception('Error restoring gather-win state.')
# ba_meta export plugin
class MaxPlayersPlugin(ba.Plugin):
class MaxPlayersPlugin(babase.Plugin):
def has_settings_ui(self) -> bool:
return True
def show_settings_ui(self, source_widget: ba.Widget | None) -> None:
def show_settings_ui(self, source_widget: bui.Widget | None) -> None:
SettingsMaxPlayers()
if 'Config Max Players' in ba.app.config:
old_config = ba.app.config['Config Max Players']
if 'Config Max Players' in babase.app.config:
old_config = babase.app.config['Config Max Players']
for setting in cmp:
if setting not in old_config:
ba.app.config['Config Max Players'].update({setting: cmp[setting]})
babase.app.config['Config Max Players'].update({setting: cmp[setting]})
remove_list = []
for setting in old_config:
if setting not in cmp:
remove_list.append(setting)
for element in remove_list:
ba.app.config['Config Max Players'].pop(element)
babase.app.config['Config Max Players'].pop(element)
else:
ba.app.config['Config Max Players'] = cmp
ba.app.config.apply_and_commit()
babase.app.config['Config Max Players'] = cmp
babase.app.config.apply_and_commit()
CoopSession.__init__ = __init__
MultiTeamSession.get_max_players = get_max_players

View file

@ -1,16 +1,20 @@
# ba_meta require api 7
# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport)
# ba_meta require api 8
from __future__ import annotations
from typing import TYPE_CHECKING, cast
if TYPE_CHECKING:
from typing import Any, Sequence, Callable, List, Dict, Tuple, Optional, Union
import random
import ba
import _ba
from ba._map import Map
from bastd import mainmenu
from bastd.ui.party import PartyWindow
from bastd.gameutils import SharedObjects
import babase
import bauiv1 as bui
import bascenev1 as bs
import _babase
from bascenev1._map import Map
from bascenev1lib import mainmenu
from bauiv1lib.mainmenu import MainMenuWindow
from bauiv1lib.party import PartyWindow
from bascenev1lib.gameutils import SharedObjects
"""mood light plugin by ʟօʊքɢǟʀօʊ
type ml in chat or use plugin manager to open settings"""
@ -21,7 +25,7 @@ def Print(*args):
for arg in args:
a = str(arg)
out += a
ba.screenmessage(out)
bui.screenmessage(out)
def cprint(*args):
@ -29,26 +33,26 @@ def cprint(*args):
for arg in args:
a = str(arg)
out += a
_ba.chatmessage(out)
bs.chatmessage(out)
try:
Ldefault, Udefault = ba.app.config.get("moodlightingSettings")
Ldefault, Udefault = babase.app.config.get("moodlightingSettings")
except:
ba.app.config["moodlightingSettings"] = (15, 20)
Ldefault, Udefault = ba.app.config.get("moodlightingSettings")
babase.app.config["moodlightingSettings"] = (15, 20)
Ldefault, Udefault = babase.app.config.get("moodlightingSettings")
Print("settings up moodlight")
Print("Type ml in chat or use plugin manager to access settings")
try:
loop = ba.app.config.get("moodlightEnabled")
loop = babase.app.config.get("moodlightEnabled")
except:
ba.app.config["moodlightEnabled"] = True
ba.app.config.commit()
babase.app.config["moodlightEnabled"] = True
babase.app.config.commit()
loop = True
class SettingWindow(ba.Window):
class SettingWindow(bui.Window):
def __init__(self):
self.draw_ui()
@ -56,57 +60,57 @@ class SettingWindow(ba.Window):
global Ldefault, Udefault
try:
if Udefault >= 29 and self.selected == "upper":
ba.textwidget(edit=self.warn_text,
bui.textwidget(edit=self.warn_text,
text="Careful!You risk get blind beyond this point")
elif self.selected == "lower" and Ldefault >= -20 or self.selected == "upper" and Udefault <= 30:
ba.textwidget(edit=self.warn_text, text="")
bui.textwidget(edit=self.warn_text, text="")
if self.selected == "lower":
Ldefault += 1
ba.textwidget(edit=self.lower_text, text=str(Ldefault))
bui.textwidget(edit=self.lower_text, text=str(Ldefault))
elif self.selected == "upper":
Udefault += 1
ba.textwidget(edit=self.upper_text, text=str(Udefault))
bui.textwidget(edit=self.upper_text, text=str(Udefault))
except AttributeError:
ba.textwidget(edit=self.warn_text, text="Click on number to select it")
bui.textwidget(edit=self.warn_text, text="Click on number to select it")
def decrease_limit(self):
global Ldefault, Udefault
try:
if Ldefault <= -19 and self.selected == "lower":
ba.textwidget(edit=self.warn_text,
bui.textwidget(edit=self.warn_text,
text="DON'T BE AFRAID OF DARK,IT'S A PLACE WHERE YOU CAN HIDE")
elif (self.selected == "upper" and Udefault <= 30) or (self.selected == "lower" and Ldefault >= -20):
ba.textwidget(edit=self.warn_text, text="")
bui.textwidget(edit=self.warn_text, text="")
if self.selected == "lower":
Ldefault -= 1
ba.textwidget(edit=self.lower_text, text=str(Ldefault))
bui.textwidget(edit=self.lower_text, text=str(Ldefault))
elif self.selected == "upper":
Udefault -= 1
ba.textwidget(edit=self.upper_text, text=str(Udefault))
bui.textwidget(edit=self.upper_text, text=str(Udefault))
except AttributeError:
ba.textwidget(edit=self.warn_text, text="Click on number to select it")
bui.textwidget(edit=self.warn_text, text="Click on number to select it")
def on_text_click(self, selected):
self.selected = selected
if selected == "upper":
ba.textwidget(edit=self.upper_text, color=(0, 0, 1))
ba.textwidget(edit=self.lower_text, color=(1, 1, 1))
bui.textwidget(edit=self.upper_text, color=(0, 0, 1))
bui.textwidget(edit=self.lower_text, color=(1, 1, 1))
elif selected == "lower":
ba.textwidget(edit=self.lower_text, color=(0, 0, 1))
ba.textwidget(edit=self.upper_text, color=(1, 1, 1))
bui.textwidget(edit=self.lower_text, color=(0, 0, 1))
bui.textwidget(edit=self.upper_text, color=(1, 1, 1))
else:
Print("this should't happen from on_text_click")
def draw_ui(self):
self.uiscale = ba.app.ui.uiscale
self.uiscale = bui.app.ui_v1.uiscale
super().__init__(
root_widget=ba.containerwidget(
root_widget=bui.containerwidget(
size=(670, 670),
on_outside_click_call=self.close,
transition="in_right",))
moodlight_label = ba.textwidget(
moodlight_label = bui.textwidget(
parent=self._root_widget,
size=(200, 100),
position=(150, 550),
@ -117,7 +121,7 @@ class SettingWindow(ba.Window):
text="Mood light settings",
color=(0, 1, 0))
self.enable_button = ba.buttonwidget(
self.enable_button = bui.buttonwidget(
parent=self._root_widget,
position=(100, 470),
size=(90, 70),
@ -126,7 +130,7 @@ class SettingWindow(ba.Window):
label="DISABLE" if loop else "ENABLE",
on_activate_call=self.on_enableButton_press)
save_button = ba.buttonwidget(
save_button = bui.buttonwidget(
parent=self._root_widget,
position=(520, 470),
size=(90, 70),
@ -134,18 +138,18 @@ class SettingWindow(ba.Window):
label="SAVE",
on_activate_call=self.save_settings)
self.close_button = ba.buttonwidget(
self.close_button = bui.buttonwidget(
parent=self._root_widget,
position=(550, 590),
size=(35, 35),
icon=ba.gettexture("crossOut"),
icon=bui.gettexture("crossOut"),
icon_color=(1, 0.2, 0.2),
scale=2,
color=(1, 0.2, 0.2),
extra_touch_border_scale=5,
on_activate_call=self.close)
self.lower_text = ba.textwidget(
self.lower_text = bui.textwidget(
parent=self._root_widget,
size=(200, 100),
scale=2,
@ -157,7 +161,7 @@ class SettingWindow(ba.Window):
click_activate=True,
selectable=True)
lower_text_label = ba.textwidget(
lower_text_label = bui.textwidget(
parent=self._root_widget,
size=(200, 100),
position=(100, 150),
@ -165,7 +169,7 @@ class SettingWindow(ba.Window):
v_align="center",
text="Limit darkness")
self.upper_text = ba.textwidget(
self.upper_text = bui.textwidget(
parent=self._root_widget,
size=(200, 100),
scale=2,
@ -177,7 +181,7 @@ class SettingWindow(ba.Window):
click_activate=True,
selectable=True)
upper_text_label = ba.textwidget(
upper_text_label = bui.textwidget(
parent=self._root_widget,
size=(200, 100),
position=(400, 150),
@ -185,25 +189,25 @@ class SettingWindow(ba.Window):
v_align="center",
text="Limit brightness")
decrease_button = ba.buttonwidget(
decrease_button = bui.buttonwidget(
parent=self._root_widget,
position=(100, 100),
size=(5, 1),
scale=3.5,
extra_touch_border_scale=2.5,
icon=ba.gettexture("downButton"),
icon=bui.gettexture("downButton"),
on_activate_call=self.decrease_limit)
increase_button = ba.buttonwidget(
increase_button = bui.buttonwidget(
parent=self._root_widget,
position=(600, 100),
size=(5, 1),
scale=3.5,
extra_touch_border_scale=2.5,
icon=ba.gettexture("upButton"),
icon=bui.gettexture("upButton"),
on_activate_call=self.increase_limit)
self.warn_text = ba.textwidget(
self.warn_text = bui.textwidget(
parent=self._root_widget,
text="",
size=(400, 200),
@ -213,28 +217,28 @@ class SettingWindow(ba.Window):
maxwidth=600)
# ++++++++++++++++for keyboard navigation++++++++++++++++
ba.widget(edit=self.enable_button, up_widget=decrease_button,
bui.widget(edit=self.enable_button, up_widget=decrease_button,
down_widget=self.lower_text, left_widget=save_button, right_widget=save_button)
ba.widget(edit=save_button, up_widget=self.close_button, down_widget=self.upper_text,
bui.widget(edit=save_button, up_widget=self.close_button, down_widget=self.upper_text,
left_widget=self.enable_button, right_widget=self.enable_button)
ba.widget(edit=self.close_button, up_widget=increase_button, down_widget=save_button,
bui.widget(edit=self.close_button, up_widget=increase_button, down_widget=save_button,
left_widget=self.enable_button, right_widget=save_button)
ba.widget(edit=self.lower_text, up_widget=self.enable_button, down_widget=decrease_button,
bui.widget(edit=self.lower_text, up_widget=self.enable_button, down_widget=decrease_button,
left_widget=self.upper_text, right_widget=self.upper_text)
ba.widget(edit=self.upper_text, up_widget=save_button, down_widget=increase_button,
bui.widget(edit=self.upper_text, up_widget=save_button, down_widget=increase_button,
left_widget=self.lower_text, right_widget=self.lower_text)
ba.widget(edit=decrease_button, up_widget=self.lower_text, down_widget=self.enable_button,
bui.widget(edit=decrease_button, up_widget=self.lower_text, down_widget=self.enable_button,
left_widget=increase_button, right_widget=increase_button)
ba.widget(edit=increase_button, up_widget=self.upper_text, down_widget=self.close_button,
bui.widget(edit=increase_button, up_widget=self.upper_text, down_widget=self.close_button,
left_widget=decrease_button, right_widget=decrease_button)
# --------------------------------------------------------------------------------------------------
ba.textwidget(edit=self.upper_text, on_activate_call=ba.Call(self.on_text_click, "upper"))
ba.textwidget(edit=self.lower_text, on_activate_call=ba.Call(self.on_text_click, "lower"))
bui.textwidget(edit=self.upper_text, on_activate_call=babase.Call(self.on_text_click, "upper"))
bui.textwidget(edit=self.lower_text, on_activate_call=babase.Call(self.on_text_click, "lower"))
def on_enableButton_press(self):
global loop
loop = ba.app.config.get("moodlightEnabled")
loop = babase.app.config.get("moodlightEnabled")
if loop:
loop = False
label = "ENABLE"
@ -243,49 +247,54 @@ class SettingWindow(ba.Window):
loop = True
label = "DISABLE"
color = (1, 0, 0)
in_game = not isinstance(_ba.get_foreground_host_session(), mainmenu.MainMenuSession)
in_game = not isinstance(bs.get_foreground_host_session(), mainmenu.MainMenuSession)
if in_game:
Print("Restart level to apply")
ba.app.config["moodlightEnabled"] = loop
ba.app.config.commit()
ba.buttonwidget(edit=self.enable_button, label=label, color=color)
babase.app.config["moodlightEnabled"] = loop
babase.app.config.commit()
bui.buttonwidget(edit=self.enable_button, label=label, color=color)
def save_settings(self):
ba.app.config["moodlightingSettings"] = (Ldefault, Udefault)
ba.app.config.commit()
babase.app.config["moodlightingSettings"] = (Ldefault, Udefault)
babase.app.config.commit()
Print("settings saved")
self.close()
def close(self):
ba.containerwidget(edit=self._root_widget, transition="out_right",)
bui.containerwidget(edit=self._root_widget, transition="out_right",)
def new_chat_message(msg: Union[str, ba.Lstr], clients: Sequence[int] = None, sender_override: str = None):
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 == 'ml':
try:
global Ldefault, Udefault
Ldefault, Udefault = ba.app.config.get("moodlightingSettings")
Ldefault, Udefault = babase.app.config.get("moodlightingSettings")
SettingWindow()
cprint("Mood light settings opened")
except Exception as err:
Print(err, "-from new_chat_message")
class NewMainMenuWindow(MainMenuWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Display chat icon, but if user open/close gather it may disappear
bui.set_party_icon_always_visible(True)
old_fcm = _ba.chatmessage
_ba.chatmessage = new_chat_message
_ba.set_party_icon_always_visible(True)
old_fcm = bs.chatmessage
bs.chatmessage = new_chat_message
Map._old_init = Map.__init__
# ba_meta export plugin
class moodlight(ba.Plugin):
class moodlight(babase.Plugin):
def __init__(self):
pass
def on_app_running(self):
_ba.show_progress_bar()
_babase.show_progress_bar()
MainMenuWindow = NewMainMenuWindow
def show_settings_ui(self, source_widget):
SettingWindow()
@ -298,11 +307,11 @@ class moodlight(ba.Plugin):
def _new_init(self, vr_overlay_offset: Optional[Sequence[float]] = None) -> None:
self._old_init(vr_overlay_offset)
in_game = not isinstance(_ba.get_foreground_host_session(), mainmenu.MainMenuSession)
in_game = not isinstance(bs.get_foreground_host_session(), mainmenu.MainMenuSession)
if not in_game:
return
gnode = _ba.getactivity().globalsnode
gnode = bs.getactivity().globalsnode
default_tint = (1.100000023841858, 1.0, 0.8999999761581421)
transition_duration = 1.0 # for future improvements
@ -310,16 +319,16 @@ class moodlight(ba.Plugin):
if loop:
Range = (random.randrange(Ldefault, Udefault)/10, random.randrange(Ldefault,
Udefault)/10, random.randrange(Ldefault, Udefault)/10)
ba.animate_array(gnode, 'tint', 3, {
bs.animate_array(gnode, 'tint', 3, {
0.0: gnode.tint,
transition_duration: Range
})
else:
global timer
timer = None
ba.animate_array(gnode, "tint", 3, {0.0: gnode.tint, 0.4: default_tint})
bs.animate_array(gnode, "tint", 3, {0.0: gnode.tint, 0.4: default_tint})
global timer
timer = ba.Timer(0.3, changetint, repeat=True)
timer = bs.Timer(0.3, changetint, repeat=True)
Map.__init__ = _new_init

View file

@ -1,22 +1,25 @@
# ba_meta require api 7
# Porting to api 8 made easier by 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 ba
import _ba
from bastd.ui.play import PlayWindow
from bastd.ui.playlist.addgame import PlaylistAddGameWindow
from ba._freeforallsession import FreeForAllSession
from bastd.activity.multiteamjoin import MultiTeamJoinActivity
import babase
import bauiv1 as bui
import bascenev1 as bs
import _babase
from bauiv1lib.play import PlayWindow
from bauiv1lib.playlist.addgame import PlaylistAddGameWindow
from bascenev1._freeforallsession import FreeForAllSession
from bascenev1lib.activity.multiteamjoin import MultiTeamJoinActivity
if TYPE_CHECKING:
pass
lang = ba.app.lang.language
lang = bs.app.lang.language
if lang == 'Spanish':
custom_txt = 'personalizar...'
@ -24,30 +27,30 @@ else:
custom_txt = 'custom...'
if 'quick_game_button' in ba.app.config:
config = ba.app.config['quick_game_button']
if 'quick_game_button' in babase.app.config:
config = babase.app.config['quick_game_button']
else:
config = {'selected': None, 'config': None}
ba.app.config['quick_game_button'] = config
ba.app.config.commit()
babase.app.config['quick_game_button'] = config
babase.app.config.commit()
def start_game(session: ba.Session, fadeout: bool = True):
def start_game(session: bs.Session, fadeout: bool = True):
def callback():
if fadeout:
_ba.unlock_all_input()
_babase.unlock_all_input()
try:
_ba.new_host_session(session)
bs.new_host_session(session)
except Exception:
from bastd import mainmenu
ba.print_exception('exception running session', session)
from bascenev1lib import mainmenu
babase.print_exception('exception running session', session)
# Drop back into a main menu session.
_ba.new_host_session(mainmenu.MainMenuSession)
bs.new_host_session(mainmenu.MainMenuSession)
if fadeout:
_ba.fade_screen(False, time=0.25, endcall=callback)
_ba.lock_all_input()
_babase.fade_screen(False, time=0.25, endcall=callback)
_babase.lock_all_input()
else:
callback()
@ -56,7 +59,7 @@ class SimplePlaylist:
def __init__(self,
settings: dict,
gametype: type[ba.GameActivity]):
gametype: type[bs.GameActivity]):
self.settings = settings
self.gametype = gametype
@ -75,7 +78,7 @@ class CustomSession(FreeForAllSession):
# pylint: disable=cyclic-import
self.use_teams = False
self._tutorial_activity_instance = None
ba.Session.__init__(self, depsets=[],
bs.Session.__init__(self, depsets=[],
team_names=None,
team_colors=None,
min_players=1,
@ -89,12 +92,12 @@ class CustomSession(FreeForAllSession):
self._playlist = SimplePlaylist(self._config, self._gametype)
config['selected'] = self._gametype.__name__
config['config'] = self._config
ba.app.config.commit()
babase.app.config.commit()
# Get a game on deck ready to go.
self._current_game_spec: Optional[Dict[str, Any]] = None
self._next_game_spec: Dict[str, Any] = self._playlist.pull_next()
self._next_game: Type[ba.GameActivity] = (
self._next_game: Type[bs.GameActivity] = (
self._next_game_spec['resolved_type'])
# Go ahead and instantiate the next game we'll
@ -102,71 +105,71 @@ class CustomSession(FreeForAllSession):
self._instantiate_next_game()
# Start in our custom join screen.
self.setactivity(_ba.newactivity(MultiTeamJoinActivity))
self.setactivity(bs.newactivity(MultiTeamJoinActivity))
class SelectGameWindow(PlaylistAddGameWindow):
def __init__(self, transition: str = 'in_right'):
class EditController:
_sessiontype = ba.FreeForAllSession
_sessiontype = bs.FreeForAllSession
def get_session_type(self) -> Type[ba.Session]:
def get_session_type(self) -> Type[bs.Session]:
return self._sessiontype
self._editcontroller = EditController()
self._r = 'addGameWindow'
uiscale = ba.app.ui.uiscale
self._width = 750 if uiscale is ba.UIScale.SMALL else 650
x_inset = 50 if uiscale is ba.UIScale.SMALL else 0
self._height = (346 if uiscale is ba.UIScale.SMALL else
380 if uiscale is ba.UIScale.MEDIUM else 440)
top_extra = 30 if uiscale is ba.UIScale.SMALL else 20
uiscale = bui.app.ui_v1.uiscale
self._width = 750 if uiscale is babase.UIScale.SMALL else 650
x_inset = 50 if uiscale is babase.UIScale.SMALL else 0
self._height = (346 if uiscale is babase.UIScale.SMALL else
380 if uiscale is babase.UIScale.MEDIUM else 440)
top_extra = 30 if uiscale is babase.UIScale.SMALL else 20
self._scroll_width = 210
self._root_widget = ba.containerwidget(
self._root_widget = bui.containerwidget(
size=(self._width, self._height + top_extra),
transition=transition,
scale=(2.17 if uiscale is ba.UIScale.SMALL else
1.5 if uiscale is ba.UIScale.MEDIUM else 1.0),
stack_offset=(0, 1) if uiscale is ba.UIScale.SMALL else (0, 0))
scale=(2.17 if uiscale is babase.UIScale.SMALL else
1.5 if uiscale is babase.UIScale.MEDIUM else 1.0),
stack_offset=(0, 1) if uiscale is babase.UIScale.SMALL else (0, 0))
self._back_button = ba.buttonwidget(parent=self._root_widget,
self._back_button = bui.buttonwidget(parent=self._root_widget,
position=(58 + x_inset,
self._height - 53),
size=(165, 70),
scale=0.75,
text_scale=1.2,
label=ba.Lstr(resource='backText'),
label=babase.Lstr(resource='backText'),
autoselect=True,
button_type='back',
on_activate_call=self._back)
self._select_button = select_button = ba.buttonwidget(
self._select_button = select_button = bui.buttonwidget(
parent=self._root_widget,
position=(self._width - (172 + x_inset), self._height - 50),
autoselect=True,
size=(160, 60),
scale=0.75,
text_scale=1.2,
label=ba.Lstr(resource='selectText'),
label=babase.Lstr(resource='selectText'),
on_activate_call=self._add)
if ba.app.ui.use_toolbars:
ba.widget(edit=select_button,
right_widget=_ba.get_special_widget('party_button'))
if bui.app.ui_v1.use_toolbars:
bui.widget(edit=select_button,
right_widget=bui.get_special_widget('party_button'))
ba.textwidget(parent=self._root_widget,
bui.textwidget(parent=self._root_widget,
position=(self._width * 0.5, self._height - 28),
size=(0, 0),
scale=1.0,
text=ba.Lstr(resource=self._r + '.titleText'),
text=babase.Lstr(resource=self._r + '.titleText'),
h_align='center',
color=ba.app.ui.title_color,
color=bui.app.ui_v1.title_color,
maxwidth=250,
v_align='center')
v = self._height - 64
self._selected_title_text = ba.textwidget(
self._selected_title_text = bui.textwidget(
parent=self._root_widget,
position=(x_inset + self._scroll_width + 50 + 30, v - 15),
size=(0, 0),
@ -177,7 +180,7 @@ class SelectGameWindow(PlaylistAddGameWindow):
v_align='center')
v -= 30
self._selected_description_text = ba.textwidget(
self._selected_description_text = bui.textwidget(
parent=self._root_widget,
position=(x_inset + self._scroll_width + 50 + 30, v),
size=(0, 0),
@ -190,31 +193,31 @@ class SelectGameWindow(PlaylistAddGameWindow):
v = self._height - 60
self._scrollwidget = ba.scrollwidget(parent=self._root_widget,
self._scrollwidget = bui.scrollwidget(parent=self._root_widget,
position=(x_inset + 61,
v - scroll_height),
size=(self._scroll_width,
scroll_height),
highlight=False)
ba.widget(edit=self._scrollwidget,
bui.widget(edit=self._scrollwidget,
up_widget=self._back_button,
left_widget=self._back_button,
right_widget=select_button)
self._column: Optional[ba.Widget] = None
self._column: Optional[bui.Widget] = None
v -= 35
ba.containerwidget(edit=self._root_widget,
bui.containerwidget(edit=self._root_widget,
cancel_button=self._back_button,
start_button=select_button)
self._selected_game_type: Optional[Type[ba.GameActivity]] = None
self._selected_game_type: Optional[Type[bs.GameActivity]] = None
ba.containerwidget(edit=self._root_widget,
bui.containerwidget(edit=self._root_widget,
selected_child=self._scrollwidget)
self._game_types: list[type[ba.GameActivity]] = []
self._game_types: list[type[bs.GameActivity]] = []
# Get actual games loading in the bg.
ba.app.meta.load_exported_classes(ba.GameActivity,
babase.app.meta.load_exported_classes(bs.GameActivity,
self._on_game_types_loaded,
completion_cb_in_bg_thread=True)
@ -231,12 +234,12 @@ class SelectGameWindow(PlaylistAddGameWindow):
def _refresh(self,
select_get_more_games_button: bool = False,
selected: bool = None) -> None:
# from ba.internal import get_game_types
# from babase.internal import get_game_types
if self._column is not None:
self._column.delete()
self._column = ba.columnwidget(parent=self._scrollwidget,
self._column = bui.columnwidget(parent=self._scrollwidget,
border=2,
margin=0)
@ -244,11 +247,10 @@ class SelectGameWindow(PlaylistAddGameWindow):
def _doit() -> None:
if self._select_button:
ba.timer(0.1,
self._select_button.activate,
timetype=ba.TimeType.REAL)
bs.apptimer(0.1,
self._select_button.activate)
txt = ba.textwidget(parent=self._column,
txt = bui.textwidget(parent=self._column,
position=(0, 0),
size=(self._width - 88, 24),
text=gametype.get_display_string(),
@ -256,30 +258,30 @@ class SelectGameWindow(PlaylistAddGameWindow):
v_align='center',
color=(0.8, 0.8, 0.8, 1.0),
maxwidth=self._scroll_width * 0.8,
on_select_call=ba.Call(
on_select_call=babase.Call(
self._set_selected_game_type, gametype),
always_highlight=True,
selectable=True,
on_activate_call=_doit)
if i == 0:
ba.widget(edit=txt, up_widget=self._back_button)
bui.widget(edit=txt, up_widget=self._back_button)
self._get_more_games_button = ba.buttonwidget(
self._get_more_games_button = bui.buttonwidget(
parent=self._column,
autoselect=True,
label=ba.Lstr(resource=self._r + '.getMoreGamesText'),
label=babase.Lstr(resource=self._r + '.getMoreGamesText'),
color=(0.54, 0.52, 0.67),
textcolor=(0.7, 0.65, 0.7),
on_activate_call=self._on_get_more_games_press,
size=(178, 50))
if select_get_more_games_button:
ba.containerwidget(edit=self._column,
bui.containerwidget(edit=self._column,
selected_child=self._get_more_games_button,
visible_child=self._get_more_games_button)
def _add(self) -> None:
_ba.lock_all_input() # Make sure no more commands happen.
ba.timer(0.1, _ba.unlock_all_input, timetype=ba.TimeType.REAL)
_babase.lock_all_input() # Make sure no more commands happen.
bs.apptimer(0.1, _babase.unlock_all_input)
gameconfig = {}
if config['selected'] == self._selected_game_type.__name__:
if config['config']:
@ -297,13 +299,13 @@ class SelectGameWindow(PlaylistAddGameWindow):
CustomSession._gametype = self._selected_game_type
start_game(CustomSession)
else:
ba.app.ui.clear_main_menu_window(transition='out_right')
ba.app.ui.set_main_menu_window(
bui.app.ui_v1.clear_main_menu_window(transition='out_right')
bui.app.ui_v1.set_main_menu_window(
SelectGameWindow(transition='in_left').get_root_widget())
def _back(self) -> None:
ba.containerwidget(edit=self._root_widget, transition='out_right')
ba.app.ui.set_main_menu_window(
bui.containerwidget(edit=self._root_widget, transition='out_right')
bui.app.ui_v1.set_main_menu_window(
PlayWindow(transition='in_left').get_root_widget())
@ -318,11 +320,11 @@ def __init__(self, *args, **kwargs):
def do_quick_game() -> None:
self._save_state()
ba.containerwidget(edit=self._root_widget, transition='out_left')
ba.app.ui.set_main_menu_window(
bui.containerwidget(edit=self._root_widget, transition='out_left')
bui.app.ui_v1.set_main_menu_window(
SelectGameWindow().get_root_widget())
self._quick_game_button = ba.buttonwidget(
self._quick_game_button = bui.buttonwidget(
parent=self._root_widget,
position=(width - 55 - 120, height - 132),
autoselect=True,
@ -350,32 +352,32 @@ def states(self) -> None:
def _save_state(self) -> None:
swapped = {v: k for k, v in states(self).items()}
if self._root_widget.get_selected_child() in swapped:
ba.app.ui.window_states[
bui.app.ui_v1.window_states[
self.__class__.__name__] = swapped[
self._root_widget.get_selected_child()]
else:
ba.print_exception(f'Error saving state for {self}.')
babase.print_exception(f'Error saving state for {self}.')
def _restore_state(self) -> None:
if not hasattr(self, '_quick_game_button'):
return # ensure that our monkey patched init ran
if self.__class__.__name__ not in ba.app.ui.window_states:
ba.containerwidget(edit=self._root_widget,
if self.__class__.__name__ not in bui.app.ui_v1.window_states:
bui.containerwidget(edit=self._root_widget,
selected_child=self._coop_button)
return
sel = states(self).get(
ba.app.ui.window_states[self.__class__.__name__], None)
bui.app.ui_v1.window_states[self.__class__.__name__], None)
if sel:
ba.containerwidget(edit=self._root_widget, selected_child=sel)
bui.containerwidget(edit=self._root_widget, selected_child=sel)
else:
ba.containerwidget(edit=self._root_widget,
bui.containerwidget(edit=self._root_widget,
selected_child=self._coop_button)
ba.print_exception(f'Error restoring state for {self}.')
babase.print_exception(f'Error restoring state for {self}.')
# ba_meta export plugin
class QuickGamePlugin(ba.Plugin):
class QuickGamePlugin(babase.Plugin):
PlayWindow.__init__ = __init__
PlayWindow._save_state = _save_state
PlayWindow._restore_state = _restore_state

View file

@ -1,3 +1,4 @@
# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport)
"""
Quickturn by TheMikirog
@ -9,16 +10,18 @@
No Rights Reserved
"""
# ba_meta require api 7
# ba_meta require api 8
from __future__ import annotations
from typing import TYPE_CHECKING
import ba
import babase
import bauiv1 as bui
import bascenev1 as bs
import math
import bastd
from bastd.actor.spaz import Spaz
import bascenev1lib
from bascenev1lib.actor.spaz import Spaz
if TYPE_CHECKING:
pass
@ -26,7 +29,7 @@ if TYPE_CHECKING:
# ba_meta export plugin
class Quickturn(ba.Plugin):
class Quickturn(babase.Plugin):
class FootConnectMessage:
"""Spaz started touching the ground"""
@ -46,7 +49,7 @@ class Quickturn(ba.Plugin):
if self.node.knockout > 0.0 or self.frozen or self.node.hold_node:
return
t_ms = ba.time(timeformat=ba.TimeFormat.MILLISECONDS)
t_ms = bs.time() * 1000
assert isinstance(t_ms, int)
if t_ms - self.last_wavedash_time_ms >= self._wavedash_cooldown:
@ -77,7 +80,7 @@ class Quickturn(ba.Plugin):
self.last_wavedash_time_ms = t_ms
# FX
ba.emitfx(position=self.node.position,
bs.emitfx(position=self.node.position,
velocity=(vel[0]*0.5, -1, vel[1]*0.5),
chunk_type='spark',
count=5,
@ -104,7 +107,7 @@ class Quickturn(ba.Plugin):
args[0].grounded = 0
return wrapper
bastd.actor.spaz.Spaz.__init__ = new_spaz_init(bastd.actor.spaz.Spaz.__init__)
bascenev1lib.actor.spaz.Spaz.__init__ = new_spaz_init(bascenev1lib.actor.spaz.Spaz.__init__)
def new_factory(func):
def wrapper(*args, **kwargs):
@ -112,12 +115,12 @@ class Quickturn(ba.Plugin):
args[0].roller_material.add_actions(
conditions=('they_have_material',
bastd.gameutils.SharedObjects.get().footing_material),
bascenev1lib.gameutils.SharedObjects.get().footing_material),
actions=(('message', 'our_node', 'at_connect', Quickturn.FootConnectMessage),
('message', 'our_node', 'at_disconnect', Quickturn.FootDisconnectMessage)))
return wrapper
bastd.actor.spazfactory.SpazFactory.__init__ = new_factory(
bastd.actor.spazfactory.SpazFactory.__init__)
bascenev1lib.actor.spazfactory.SpazFactory.__init__ = new_factory(
bascenev1lib.actor.spazfactory.SpazFactory.__init__)
def new_handlemessage(func):
def wrapper(*args, **kwargs):
@ -129,7 +132,7 @@ class Quickturn(ba.Plugin):
func(*args, **kwargs)
return wrapper
bastd.actor.spaz.Spaz.handlemessage = new_handlemessage(bastd.actor.spaz.Spaz.handlemessage)
bascenev1lib.actor.spaz.Spaz.handlemessage = new_handlemessage(bascenev1lib.actor.spaz.Spaz.handlemessage)
def new_on_run(func):
def wrapper(*args, **kwargs):
@ -137,4 +140,4 @@ class Quickturn(ba.Plugin):
Quickturn.wavedash(args[0])
func(*args, **kwargs)
return wrapper
bastd.actor.spaz.Spaz.on_run = new_on_run(bastd.actor.spaz.Spaz.on_run)
bascenev1lib.actor.spaz.Spaz.on_run = new_on_run(bascenev1lib.actor.spaz.Spaz.on_run)

View file

@ -1,4 +1,5 @@
# ba_meta require api 7
# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport)
# ba_meta require api 8
"""
Ragdoll-B-Gone by TheMikirog
@ -18,11 +19,13 @@ from __future__ import annotations
from typing import TYPE_CHECKING
# Let's import everything we need and nothing more.
import ba
import bastd
import babase
import bauiv1 as bui
import bascenev1 as bs
import bascenev1lib
import random
from bastd.actor.spaz import Spaz
from bastd.actor.spazfactory import SpazFactory
from bascenev1lib.actor.spaz import Spaz
from bascenev1lib.actor.spazfactory import SpazFactory
if TYPE_CHECKING:
pass
@ -30,7 +33,7 @@ if TYPE_CHECKING:
# ba_meta export plugin
class RagdollBGone(ba.Plugin):
class RagdollBGone(babase.Plugin):
# We use a decorator to add extra code to existing code, increasing mod compatibility.
# Any gameplay altering mod should master the decorator!
@ -42,16 +45,16 @@ class RagdollBGone(ba.Plugin):
# We're working kind of blindly here, so it's good to have the original function
# open in a second window for argument reference.
def wrapper(*args, **kwargs):
if isinstance(args[1], ba.DieMessage): # Replace Spaz death behavior
if isinstance(args[1], bs.DieMessage): # Replace Spaz death behavior
# Here we play the gamey death noise in Co-op.
if not args[1].immediate:
if args[0].play_big_death_sound and not args[0]._dead:
ba.playsound(SpazFactory.get().single_player_death_sound)
SpazFactory.get().single_player_death_sound.play()
# If our Spaz dies by falling out of the map, we want to keep the ragdoll.
# Ragdolls don't impact gameplay if Spaz dies this way, so it's fine if we leave the behavior as is.
if args[1].how == ba.DeathType.FALL:
if args[1].how == bs.DeathType.FALL:
# The next two properties are all built-in, so their behavior can't be edited directly without touching the C++ layer.
# We can change their values though!
# "hurt" property is basically the health bar above the player and the blinking when low on health.
@ -61,7 +64,7 @@ class RagdollBGone(ba.Plugin):
# Again, this behavior is built in. We can only trigger it by setting "dead" to True.
args[0].node.dead = True
# After the death animation ends (which is around 2 seconds) let's remove the Spaz our of existence.
ba.timer(2.0, args[0].node.delete)
bs.timer(2.0, args[0].node.delete)
else:
# Here's our new behavior!
# The idea is to remove the Spaz node and make some sparks for extra flair.
@ -80,7 +83,7 @@ class RagdollBGone(ba.Plugin):
args[0].node.position[2])
# This function allows us to spawn particles like sparks and bomb shrapnel.
# We're gonna use sparks here.
ba.emitfx(position=pos, # Here we place our edited position.
bs.emitfx(position=pos, # Here we place our edited position.
velocity=args[0].node.velocity,
# Random amount of sparks between 2 and 5
count=random.randrange(2, 5),
@ -95,10 +98,10 @@ class RagdollBGone(ba.Plugin):
# Pick a random death noise
sound = death_sounds[random.randrange(len(death_sounds))]
# Play the sound where our Spaz is
ba.playsound(sound, position=args[0].node.position)
sound.play(position=args[0].node.position)
# Delete our Spaz node immediately.
# Removing stuff is weird and prone to errors, so we're gonna delay it.
ba.timer(0.001, args[0].node.delete)
bs.timer(0.001, args[0].node.delete)
# Let's mark our Spaz as dead, so he can't die again.
# Notice how we're targeting the Spaz and not it's node.
@ -116,4 +119,4 @@ class RagdollBGone(ba.Plugin):
# Finally we """travel through the game files""" to replace the function we want with our own version.
# We transplant the old function's arguments into our version.
bastd.actor.spaz.Spaz.handlemessage = new_handlemessage(bastd.actor.spaz.Spaz.handlemessage)
bascenev1lib.actor.spaz.Spaz.handlemessage = new_handlemessage(bascenev1lib.actor.spaz.Spaz.handlemessage)

View file

@ -1,17 +1,19 @@
# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport)
from __future__ import annotations
from typing import TYPE_CHECKING, TypeVar
import _ba
import ba
import ba.internal
import _babase
import babase
import bauiv1 as bui
import bascenev1 as bs
import random
from bastd.ui.gather.publictab import PublicGatherTab, PartyEntry, PingThread
from bauiv1lib.gather.publictab import PublicGatherTab, PartyEntry, PingThread
if TYPE_CHECKING:
from typing import Callable
ClassType = TypeVar('ClassType')
MethodType = TypeVar('Methodtype')
MethodType = TypeVar('MethodType')
def override(cls: ClassType) -> Callable[[MethodType], MethodType]:
@ -50,26 +52,26 @@ class NewPublicGatherTab(PublicGatherTab, PingThread):
v = c_height - 35
v -= 60
self._random_join_button = ba.buttonwidget(
self._random_join_button = bui.buttonwidget(
parent=self._container,
label='random',
size=(90, 45),
position=(710, v + 10),
on_activate_call=ba.WeakCall(self._join_random_server),
on_activate_call=bs.WeakCall(self._join_random_server),
)
ba.widget(edit=self._random_join_button, up_widget=self._host_text,
bui.widget(edit=self._random_join_button, up_widget=self._host_text,
left_widget=self._filter_text)
# We could place it somewhere under plugin settings which is kind of
# official way to customise plugins. Although it's too deep:
# Gather Window -> Main Menu -> Settings -> Advanced -(scroll)->
# Plugins -(scroll probably)-> RandomJoin Settings.
self._random_join_settings_button = ba.buttonwidget(
self._random_join_settings_button = bui.buttonwidget(
parent=self._container,
icon=ba.gettexture('settingsIcon'),
icon=bui.gettexture('settingsIcon'),
size=(40, 40),
position=(820, v + 13),
on_activate_call=ba.WeakCall(self._show_random_join_settings),
on_activate_call=bs.WeakCall(self._show_random_join_settings),
)
@override(PublicGatherTab)
@ -97,9 +99,9 @@ class NewPublicGatherTab(PublicGatherTab, PingThread):
and p.ping <= randomjoin.maximum_ping)))]
if not parties:
ba.screenmessage('No suitable servers found; wait',
bui.screenmessage('No suitable servers found; wait',
color=(1, 0, 0))
ba.playsound(ba.getsound('error'))
bui.getsound('error').play()
return
for party in parties:
@ -110,33 +112,33 @@ class NewPublicGatherTab(PublicGatherTab, PingThread):
party = random.choice(
[p for p in parties if p.name[:6] in name_prefixes])
ba.internal.connect_to_party(party.address, party.port)
bs.connect_to_party(party.address, party.port)
class RandomJoinSettingsPopup(ba.Window):
def __init__(self, origin_widget: ba.Widget) -> None:
class RandomJoinSettingsPopup(bui.Window):
def __init__(self, origin_widget: bui.Widget) -> None:
c_width = 600
c_height = 400
uiscale = ba.app.ui.uiscale
super().__init__(root_widget=ba.containerwidget(
uiscale = bui.app.ui_v1.uiscale
super().__init__(root_widget=bui.containerwidget(
scale=(
1.8
if uiscale is ba.UIScale.SMALL
if uiscale is babase.UIScale.SMALL
else 1.55
if uiscale is ba.UIScale.MEDIUM
if uiscale is babase.UIScale.MEDIUM
else 1.0
),
scale_origin_stack_offset=origin_widget.get_screen_space_center(),
stack_offset=(0, -10)
if uiscale is ba.UIScale.SMALL
if uiscale is babase.UIScale.SMALL
else (0, 15)
if uiscale is ba.UIScale.MEDIUM
if uiscale is babase.UIScale.MEDIUM
else (0, 0),
size=(c_width, c_height),
transition='in_scale',
))
ba.textwidget(
bui.textwidget(
parent=self._root_widget,
size=(0, 0),
h_align='center',
@ -149,7 +151,7 @@ class RandomJoinSettingsPopup(ba.Window):
)
v = c_height - 120
ba.textwidget(
bui.textwidget(
parent=self._root_widget,
size=(0, 0),
h_align='right',
@ -158,7 +160,7 @@ class RandomJoinSettingsPopup(ba.Window):
maxwidth=c_width * 0.3,
position=(c_width * 0.4, v),
)
self._maximum_ping_edit = ba.textwidget(
self._maximum_ping_edit = bui.textwidget(
parent=self._root_widget,
size=(c_width * 0.3, 40),
h_align='left',
@ -171,7 +173,7 @@ class RandomJoinSettingsPopup(ba.Window):
max_chars=4,
)
v -= 60
ba.textwidget(
bui.textwidget(
parent=self._root_widget,
size=(0, 0),
h_align='right',
@ -180,7 +182,7 @@ class RandomJoinSettingsPopup(ba.Window):
maxwidth=c_width * 0.3,
position=(c_width * 0.4, v),
)
self._minimum_players_edit = ba.textwidget(
self._minimum_players_edit = bui.textwidget(
parent=self._root_widget,
size=(c_width * 0.3, 40),
h_align='left',
@ -195,27 +197,27 @@ class RandomJoinSettingsPopup(ba.Window):
v -= 60
# Cancel button.
self.cancel_button = btn = ba.buttonwidget(
self.cancel_button = btn = bui.buttonwidget(
parent=self._root_widget,
label=ba.Lstr(resource='cancelText'),
label=babase.Lstr(resource='cancelText'),
size=(180, 60),
color=(1.0, 0.2, 0.2),
position=(40, 30),
on_activate_call=self._cancel,
autoselect=True,
)
ba.containerwidget(edit=self._root_widget, cancel_button=btn)
bui.containerwidget(edit=self._root_widget, cancel_button=btn)
# Save button.
self.savebtn = btn = ba.buttonwidget(
self.savebtn = btn = bui.buttonwidget(
parent=self._root_widget,
label=ba.Lstr(resource='saveText'),
label=babase.Lstr(resource='saveText'),
size=(180, 60),
position=(c_width - 200, 30),
on_activate_call=self._save,
autoselect=True,
)
ba.containerwidget(edit=self._root_widget, start_button=btn)
bui.containerwidget(edit=self._root_widget, start_button=btn)
def _save(self) -> None:
errored = False
@ -223,19 +225,19 @@ class RandomJoinSettingsPopup(ba.Window):
maximum_ping: int | None = None
try:
minimum_players = int(
ba.textwidget(query=self._minimum_players_edit))
bui.textwidget(query=self._minimum_players_edit))
except ValueError:
ba.screenmessage('"Minimum players" should be integer',
bui.screenmessage('"Minimum players" should be integer',
color=(1, 0, 0))
ba.playsound(ba.getsound('error'))
bui.getsound('error').play()
errored = True
try:
maximum_ping = int(
ba.textwidget(query=self._maximum_ping_edit))
bui.textwidget(query=self._maximum_ping_edit))
except ValueError:
ba.screenmessage('"Maximum ping" should be integer',
bui.screenmessage('"Maximum ping" should be integer',
color=(1, 0, 0))
ba.playsound(ba.getsound('error'))
bui.getsound('error').play()
errored = True
if errored:
return
@ -244,16 +246,16 @@ class RandomJoinSettingsPopup(ba.Window):
assert maximum_ping is not None
if minimum_players < 0:
ba.screenmessage('"Minimum players" should be at least 0',
bui.screenmessage('"Minimum players" should be at least 0',
color=(1, 0, 0))
ba.playsound(ba.getsound('error'))
bui.getsound('error').play()
errored = True
if maximum_ping <= 0:
ba.screenmessage('"Maximum ping" should be greater than 0',
bui.screenmessage('"Maximum ping" should be greater than 0',
color=(1, 0, 0))
ba.playsound(ba.getsound('error'))
ba.screenmessage('(use 9999 as dont-care value)',
bui.getsound('error').play()
bui.screenmessage('(use 9999 as dont-care value)',
color=(1, 0, 0))
errored = True
@ -264,15 +266,15 @@ class RandomJoinSettingsPopup(ba.Window):
randomjoin.minimum_players = minimum_players
randomjoin.commit_config()
ba.playsound(ba.getsound('shieldUp'))
bui.getsound('shieldUp').play()
self._transition_out()
def _cancel(self) -> None:
ba.playsound(ba.getsound('shieldDown'))
bui.getsound('shieldDown').play()
self._transition_out()
def _transition_out(self) -> None:
ba.containerwidget(edit=self._root_widget, transition='out_scale')
bui.containerwidget(edit=self._root_widget, transition='out_scale')
class RandomJoin:
@ -283,7 +285,7 @@ class RandomJoin:
self.load_config()
def load_config(self) -> None:
cfg = ba.app.config.get('Random Join', {
cfg = babase.app.config.get('Random Join', {
'maximum_ping': self.maximum_ping,
'minimum_players': self.minimum_players,
})
@ -291,25 +293,25 @@ class RandomJoin:
self.maximum_ping = cfg['maximum_ping']
self.minimum_players = cfg['minimum_players']
except KeyError:
ba.screenmessage('Error: RandomJoin config is broken, resetting..',
bui.screenmessage('Error: RandomJoin config is broken, resetting..',
color=(1, 0, 0), log=True)
ba.playsound(ba.getsound('error'))
bui.getsound('error').play()
self.commit_config()
def commit_config(self) -> None:
ba.app.config['Random Join'] = {
babase.app.config['Random Join'] = {
'maximum_ping': self.maximum_ping,
'minimum_players': self.minimum_players,
}
ba.app.config.commit()
babase.app.config.commit()
randomjoin = RandomJoin()
# ba_meta require api 7
# ba_meta export ba.Plugin
class RandomJoinPlugin(ba.Plugin):
# ba_meta require api 8
# ba_meta export babase.Plugin
class RandomJoinPlugin(babase.Plugin):
def on_app_running(self) -> None:
# I feel bad that all patching logic happens not here.
pass

View file

@ -1,4 +1,5 @@
# ba_meta require api 7
# Porting to api 8 made easier by baport.(https://github.com/bombsquad-community/baport)
# ba_meta require api 8
"""
TNT Respawn Text by TheMikirog
@ -16,11 +17,13 @@ from __future__ import annotations
from typing import TYPE_CHECKING
# Let's import everything we need and nothing more.
import ba
import bastd
import babase
import bauiv1 as bui
import bascenev1 as bs
import bascenev1lib
import math
import random
from bastd.actor.bomb import Bomb
from bascenev1lib.actor.bomb import Bomb
if TYPE_CHECKING:
pass
@ -40,7 +43,7 @@ if TYPE_CHECKING:
# ba_meta export plugin
class TNTRespawnText(ba.Plugin):
class TNTRespawnText(babase.Plugin):
# This clamping function will make sure a certain value can't go above or below a certain threshold.
# We're gonna need this functionality in just a bit.
@ -54,7 +57,7 @@ class TNTRespawnText(ba.Plugin):
def on_tnt_exploded(self):
self.tnt_has_callback = False
self._respawn_text.color = (1.0, 1.0, 1.0)
ba.animate(
bs.animate(
self._respawn_text,
'opacity',
{
@ -92,7 +95,7 @@ class TNTRespawnText(ba.Plugin):
respawn_text_position = (args[0]._position[0],
args[0]._position[1] - 0.4,
args[0]._position[2])
args[0]._respawn_text = ba.newnode(
args[0]._respawn_text = bs.newnode(
'text',
attrs={
'text': "", # we'll set the text later
@ -126,7 +129,7 @@ class TNTRespawnText(ba.Plugin):
args[0]._tnt.node.add_death_action(tnt_callback)
return wrapper
# Let's replace the original init function with our modified version.
bastd.actor.bomb.TNTSpawner.__init__ = new_init(bastd.actor.bomb.TNTSpawner.__init__)
bascenev1lib.actor.bomb.TNTSpawner.__init__ = new_init(bascenev1lib.actor.bomb.TNTSpawner.__init__)
# Our modified update function.
# This gets called every 1.1s. Check the TNTSpawner class in the game's code for details.
@ -165,7 +168,7 @@ class TNTRespawnText(ba.Plugin):
# Code goes here if we don't have a TNT box and we reached 100%.
if args[0]._tnt is None or args[0]._wait_time >= args[0]._respawn_time and args[0]._respawn_text:
# Animate the text "bounce" to draw attention
ba.animate(
bs.animate(
args[0]._respawn_text,
'scale',
{
@ -176,7 +179,7 @@ class TNTRespawnText(ba.Plugin):
},
)
# Fade the text away
ba.animate(
bs.animate(
args[0]._respawn_text,
'opacity',
{
@ -191,7 +194,7 @@ class TNTRespawnText(ba.Plugin):
args[0]._respawn_text.color = (1.0, 0.75, 0.5)
# Make some sparks to draw the eye.
ba.emitfx(
bs.emitfx(
position=args[0]._position,
count=int(5.0 + random.random() * 10),
scale=0.8,
@ -212,4 +215,4 @@ class TNTRespawnText(ba.Plugin):
return wrapper
# Let's replace the original update function with our modified version.
bastd.actor.bomb.TNTSpawner._update = new_update(bastd.actor.bomb.TNTSpawner._update)
bascenev1lib.actor.bomb.TNTSpawner._update = new_update(bascenev1lib.actor.bomb.TNTSpawner._update)

File diff suppressed because it is too large Load diff