mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2026-08-15 13:04:30 +00:00
Merge pull request #23 from pranav-1711/public-server
Bugs fixes, lints, feature folder and updates.
This commit is contained in:
commit
5f798b797f
51 changed files with 366 additions and 918 deletions
4
dist/ba_data/python/ba/_activitytypes.py
vendored
4
dist/ba_data/python/ba/_activitytypes.py
vendored
|
|
@ -168,8 +168,8 @@ class ScoreScreenActivity(Activity[EmptyPlayer, EmptyTeam]):
|
|||
from bastd.actor.text import Text
|
||||
from ba import _language
|
||||
super().on_begin()
|
||||
from stats import mystats
|
||||
mystats.update(self._stats)
|
||||
import custom_hooks
|
||||
custom_hooks.score_screen_on_begin(self._stats)
|
||||
|
||||
# Pop up a 'press any button to continue' statement after our
|
||||
# min-view-time show a 'press any button to continue..'
|
||||
|
|
|
|||
4
dist/ba_data/python/ba/_coopsession.py
vendored
4
dist/ba_data/python/ba/_coopsession.py
vendored
|
|
@ -290,8 +290,8 @@ class CoopSession(Session):
|
|||
if (isinstance(activity,
|
||||
(JoinActivity, CoopScoreScreen, TransitionActivity))) or True:
|
||||
|
||||
from tools import TeamBalancer
|
||||
TeamBalancer.checkToExitCoop()
|
||||
from features import team_balancer
|
||||
team_balancer.checkToExitCoop()
|
||||
|
||||
if outcome == 'next_level':
|
||||
if self._next_game_instance is None:
|
||||
|
|
|
|||
4
dist/ba_data/python/ba/_map.py
vendored
4
dist/ba_data/python/ba/_map.py
vendored
|
|
@ -210,8 +210,8 @@ class Map(Actor):
|
|||
# Set various globals.
|
||||
gnode = _ba.getactivity().globalsnode
|
||||
import ba
|
||||
from tools import textonmap
|
||||
textonmap.textonmap()
|
||||
from features import text_on_map
|
||||
text_on_map.textonmap()
|
||||
|
||||
# Set area-of-interest bounds.
|
||||
aoi_bounds = self.get_def_bound_box('area_of_interest_bounds')
|
||||
|
|
|
|||
|
|
@ -72,7 +72,8 @@ class PlayerSpaz(Spaz):
|
|||
self._player = player
|
||||
self._drive_player_position()
|
||||
|
||||
modifyspaz.main(self, self.node, self._player)
|
||||
import custom_hooks
|
||||
custom_hooks.playerspaz_init(self, self.node, self._player)
|
||||
|
||||
# Overloads to tell the type system our return type based on doraise val.
|
||||
|
||||
|
|
|
|||
24
dist/ba_root/config.json
vendored
24
dist/ba_root/config.json
vendored
|
|
@ -432,15 +432,21 @@
|
|||
}
|
||||
},
|
||||
"Plugins": {
|
||||
"CharacterChooser.HeySmoothy": {
|
||||
"enabled": true
|
||||
},
|
||||
"bobmsquadhttpapi.HeySmoothy": {
|
||||
"enabled": false
|
||||
},
|
||||
"importcustomcharacters.HeySmoothy": {
|
||||
"enabled": true
|
||||
}
|
||||
"plugins.Init": {
|
||||
"enabled": true
|
||||
},
|
||||
"plugins.CharacterChooser.HeySmoothy": {
|
||||
"enabled": true
|
||||
},
|
||||
"plugins.bombsquadhttpapi.HeySmoothy": {
|
||||
"enabled": false
|
||||
},
|
||||
"plugins.importcustomcharacters.HeySmoothy": {
|
||||
"enabled": false
|
||||
},
|
||||
"plugins.wavedash.MikiWavedashTest": {
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
"Port": 43210,
|
||||
"Region Pings": {
|
||||
|
|
|
|||
|
|
@ -1,64 +0,0 @@
|
|||
""" store functions executed when chat command are called """
|
||||
import ba, _ba, json, random
|
||||
|
||||
from Currency.Handlers.bank_handler import *
|
||||
from Currency.Handlers.ba_get_player_data import *
|
||||
#from Currency.Handlers.cooldown_manager import *
|
||||
from Currency.Handlers.CLstr import CLstr, Errorstr
|
||||
from .fun import get_random_donator, get_random_cash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def balance_call(userid : str, clientid : int):
|
||||
open_account(userid)
|
||||
|
||||
users = get_bank_data()
|
||||
name = client_to_name(clientid)
|
||||
|
||||
PlayerData = get_player_data(userid)
|
||||
|
||||
balance = CLstr("English", "balance").format(str(name), str(PlayerData[0]), str(PlayerData[1]), str(PlayerData[2]))
|
||||
send(balance, clientid)
|
||||
|
||||
|
||||
|
||||
|
||||
def beg_call(userid : str, clientid : int):
|
||||
open_account(userid)
|
||||
earned = get_random_cash()
|
||||
|
||||
update_bank(userid, earned, "cash", type_only=True)
|
||||
cash = get_player_data(userid)[0]
|
||||
donator = get_random_donator()
|
||||
|
||||
send(CLstr("English", "beg").format(donator, earned, cash), clientid)
|
||||
|
||||
|
||||
|
||||
|
||||
def withdraw_call(userid : str, args : int, clientid : int):
|
||||
open_account(userid)
|
||||
withd = int(args[0])
|
||||
|
||||
if cheack_withd(userid, withd, clientid):
|
||||
return
|
||||
|
||||
update_bank(userid, withd)
|
||||
|
||||
send(CLstr("English", "withdraw").format(withd), clientid)
|
||||
|
||||
|
||||
|
||||
|
||||
def deposit_call(userid : str, args : int, clientid : int):
|
||||
open_account(userid)
|
||||
dep = int(args[0])
|
||||
|
||||
if cheack_cash_and_space(userid, dep, clientid):
|
||||
return
|
||||
|
||||
update_bank(userid, dep, "bank")
|
||||
|
||||
send(CLstr("English", "deposit").format(dep), clientid)
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
import random
|
||||
|
||||
donators_list = [
|
||||
'Eggs broke and',
|
||||
'pranav',
|
||||
'your mom',
|
||||
'saitama',
|
||||
'one simp',
|
||||
'idiot',
|
||||
'mr smoothy'
|
||||
]
|
||||
|
||||
def get_random_donator():
|
||||
return random.choice(donators_list)
|
||||
|
||||
def get_random_cash():
|
||||
return random.randrange(80)
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
""" check given command and executive the the cmd function from data functions"""
|
||||
|
||||
import ba, _ba
|
||||
from .Command_Objects.data_functions import *
|
||||
|
||||
|
||||
def on_command(cmd, args, accountid, clientid):
|
||||
|
||||
if cmd in ['coins', 'bal', 'balance', 'me']:
|
||||
balance_call(accountid, clientid)
|
||||
|
||||
elif cmd == 'beg':
|
||||
beg_call(accountid, clientid)
|
||||
|
||||
elif cmd in ['with', 'withdraw']:
|
||||
withdraw_call(accountid, args, clientid)
|
||||
|
||||
elif cmd in ['dep', 'deposite']:
|
||||
deposit_call(accountid, args, clientid)
|
||||
|
||||
12
dist/ba_root/mods/Currency/Data/bank.json
vendored
12
dist/ba_root/mods/Currency/Data/bank.json
vendored
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"None": {
|
||||
"cash": 3402,
|
||||
"bank_space": 100,
|
||||
"bank_cash": 10
|
||||
},
|
||||
"pb-IF4VAk4a": {
|
||||
"cash": 0,
|
||||
"bank_space": 100,
|
||||
"bank_cash": 0
|
||||
}
|
||||
}
|
||||
14
dist/ba_root/mods/Currency/Data/textes.json
vendored
14
dist/ba_root/mods/Currency/Data/textes.json
vendored
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"English": {
|
||||
"errors":{
|
||||
"short_space":"You don't have that much space",
|
||||
"short_ammount":"You don't have that much cash",
|
||||
"short_bank_cash":"you don't have that much money in bank",
|
||||
"bank_space_error":"get space in bank first"
|
||||
},
|
||||
"balance": "|| {} | Cash - {} | Bank- {}/{} ||",
|
||||
"beg":"{} gave you {} now you have {} coins",
|
||||
"deposit":"deposited {}",
|
||||
"withdraw": "withdrew {}"
|
||||
}
|
||||
}
|
||||
18
dist/ba_root/mods/Currency/Handlers/CLstr.py
vendored
18
dist/ba_root/mods/Currency/Handlers/CLstr.py
vendored
|
|
@ -1,18 +0,0 @@
|
|||
import ba, _ba, json
|
||||
|
||||
textes_path = _ba.env()['python_directory_user']+'/Currency/Data/textes.json'
|
||||
|
||||
|
||||
def CLstr(language, text):
|
||||
with open(textes_path, 'r') as f:
|
||||
textes = json.load(f)
|
||||
text = textes[language][text]
|
||||
return text
|
||||
|
||||
|
||||
def Errorstr(language, text):
|
||||
with open(textes_path, 'r') as f:
|
||||
textes = json.load(f)
|
||||
t = textes[language]["errors"][text]
|
||||
return t
|
||||
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
""" retruns information of given user using client_id """
|
||||
import ba, _ba
|
||||
|
||||
def client_to_account(client_id):
|
||||
rost = _ba.get_game_roster()
|
||||
for i in rost:
|
||||
if i['client_id'] == client_id:
|
||||
return i['account_id']
|
||||
return None
|
||||
|
||||
def client_to_name(client_id):
|
||||
rost = _ba.get_game_roster()
|
||||
for i in rost:
|
||||
if i['client_id'] == client_id:
|
||||
return i['players'][0]['name_full']
|
||||
return None
|
||||
|
||||
|
||||
def client_to_display_string(client_id):
|
||||
rost = _ba.get_game_roster()
|
||||
for i in rost:
|
||||
if i['client_id'] == client_id:
|
||||
return i['display_string']
|
||||
return None
|
||||
|
||||
|
||||
def send(msg, clientid):
|
||||
_ba.chatmessage(str(msg), clients=[clientid])
|
||||
_ba.screenmessage(str(msg), transient=True, clients=[clientid])
|
||||
|
||||
|
||||
|
||||
def senderror(msg, clientid):
|
||||
_ba.chatmessage(str(msg), clients=[clientid], sender_override = "Use[server]")
|
||||
_ba.screenmessage("Use[server] " + str(msg), transient=True, clients=[clientid])
|
||||
|
||||
|
||||
|
||||
105
dist/ba_root/mods/Currency/Handlers/bank_handler.py
vendored
105
dist/ba_root/mods/Currency/Handlers/bank_handler.py
vendored
|
|
@ -1,105 +0,0 @@
|
|||
""" helperfunctions for save lot of lines of code """
|
||||
import ba, _ba, json
|
||||
from .ba_get_player_data import send
|
||||
from .CLstr import Errorstr
|
||||
|
||||
bank_path = _ba.env()['python_directory_user']+'/Currency/Data/bank.json'
|
||||
|
||||
|
||||
|
||||
def get_bank_data():
|
||||
with open(bank_path, 'r') as f:
|
||||
users = json.load(f)
|
||||
return users
|
||||
|
||||
|
||||
|
||||
def get_player_data(accountid : str):
|
||||
users = get_bank_data()
|
||||
|
||||
cash = users[str(accountid)]["cash"]
|
||||
bank_space = users[str(accountid)]["bank_space"]
|
||||
bank_cash = users[str(accountid)]["bank_cash"]
|
||||
|
||||
PlayerData = cash, bank_cash, bank_space
|
||||
|
||||
return PlayerData
|
||||
|
||||
|
||||
|
||||
def commit(data):
|
||||
with open(bank_path, "w") as f:
|
||||
json.dump(data, f, indent=2)
|
||||
|
||||
|
||||
|
||||
def open_account(accountid : str):
|
||||
users = get_bank_data()
|
||||
|
||||
if str(accountid) in users:
|
||||
return False
|
||||
else:
|
||||
users[str(accountid)] = {}
|
||||
users[str(accountid)]["cash"] = 0
|
||||
users[str(accountid)]["bank_space"] = 100
|
||||
users[str(accountid)]["bank_cash"] = 0
|
||||
commit(users)
|
||||
return True
|
||||
|
||||
|
||||
|
||||
def update_bank(userid, ammount : int=0, type="cash", type_only=False):
|
||||
users = get_bank_data()
|
||||
|
||||
if type == "cash":
|
||||
users[str(userid)]["cash"] += ammount
|
||||
if type_only:
|
||||
commit(users)
|
||||
return
|
||||
users[str(userid)]["bank_cash"] -= ammount
|
||||
|
||||
commit(users)
|
||||
|
||||
if type == "bank":
|
||||
users[str(userid)]["cash"] -= ammount
|
||||
if type_only:
|
||||
commit(users)
|
||||
return
|
||||
users[str(userid)]["bank_cash"] += ammount
|
||||
|
||||
commit(users)
|
||||
|
||||
|
||||
|
||||
def cheack_cash_and_space(userid, ammount : int, clientid : int):
|
||||
users = get_bank_data()
|
||||
|
||||
cash_amt = users[str(userid)]["cash"]
|
||||
bank_cash = users[str(userid)]["bank_cash"]
|
||||
bank_space = users[str(userid)]["bank_space"]
|
||||
|
||||
|
||||
if bank_space < ammount:
|
||||
send(Errorstr("English", "short_space"), clientid)
|
||||
return True
|
||||
|
||||
if bank_space < bank_cash + ammount:
|
||||
send(Errorstr("English", "bank_space_error"), clientid)
|
||||
return True
|
||||
|
||||
if cash_amt < ammount:
|
||||
send(Errorstr("English", "short_ammount"), clientid)
|
||||
return True
|
||||
|
||||
|
||||
|
||||
def cheack_withd(userid, ammount : int, clientid : int):
|
||||
users = get_bank_data()
|
||||
bank_cash = users[str(userid)]["bank_cash"]
|
||||
|
||||
if bank_cash < ammount:
|
||||
send(Errorstr("English", "short_bank_cash"), clientid)
|
||||
return True
|
||||
|
||||
|
||||
|
||||
|
|
@ -1 +0,0 @@
|
|||
""" cooldown manager """"
|
||||
14
dist/ba_root/mods/Currency/__init__.py
vendored
14
dist/ba_root/mods/Currency/__init__.py
vendored
|
|
@ -1,14 +0,0 @@
|
|||
from .Commands import chat_commands
|
||||
from .Handlers.ba_get_player_data import client_to_account
|
||||
|
||||
|
||||
|
||||
def main(msg, client_id):
|
||||
command = msg.split(" ")[0]
|
||||
|
||||
if command.startswith("."):
|
||||
command = command.split(".")[1]
|
||||
arguments = msg.split(" ")[1:]
|
||||
accountid = client_to_account(client_id)
|
||||
|
||||
chat_commands.on_command(command, arguments, accountid, client_id)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
#
|
||||
"""Common bits of functionality shared between all efro projects.
|
||||
|
||||
Things in here should be hardened, highly type-safe, and well-covered by unit
|
||||
tests since they are widely used in live client and server code.
|
||||
"""
|
||||
|
||||
license : MIT, see LICENSE for more details.
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -59,10 +59,10 @@ def list(clientid):
|
|||
session = _ba.get_foreground_host_session()
|
||||
|
||||
|
||||
for i in session.sessionplayers:
|
||||
list += p.format(i.getname(icon = False),
|
||||
i.inputdevice.client_id, i.id)+"\n"
|
||||
|
||||
for index, player in enumerate(session.sessionplayers):
|
||||
list += p.format(player.getname(icon = False),
|
||||
player.inputdevice.client_id, index)+"\n"
|
||||
|
||||
send(list, clientid)
|
||||
|
||||
|
||||
|
|
|
|||
4
dist/ba_root/mods/chatHandle/__init__.py
vendored
4
dist/ba_root/mods/chatHandle/__init__.py
vendored
|
|
@ -1,7 +1,7 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
#
|
||||
"""Common bits of functionality shared between all efro projects.
|
||||
|
||||
Things in here should be hardened, highly type-safe, and well-covered by unit
|
||||
tests since they are widely used in live client and server code.
|
||||
|
||||
license : MIT, see LICENSE for more details.
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
import ba, _ba
|
||||
from serverData import serverdata
|
||||
from tools import profanity
|
||||
from features import profanity
|
||||
from tools import servercheck
|
||||
import time
|
||||
import setting
|
||||
from tools import Logger
|
||||
from tools import logger
|
||||
import _thread
|
||||
settings = setting.get_settings_data()
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ def filter(msg,pb_id,client_id):
|
|||
if len(msg)>5:
|
||||
smsgcount+=1
|
||||
if smsgcount>=3:
|
||||
Logger.log(pb_id+" | kicked for chat spam")
|
||||
logger.log(pb_id+" | kicked for chat spam")
|
||||
_ba.disconnect_client(client_id)
|
||||
smsgcount=0
|
||||
addWarn(pb_id,client_id)
|
||||
|
|
@ -64,7 +64,7 @@ def addWarn(pb_id,client_id):
|
|||
warn+=1
|
||||
if warn > settings["maxWarnCount"]:
|
||||
_ba.screenmessage(settings["afterWarnKickMsg"],color=(1,0,0),transient=True,clients=[client_id])
|
||||
Logger.log(pb_id+" | kicked for chat spam")
|
||||
logger.log(pb_id+" | kicked for chat spam")
|
||||
_ba.disconnect_client(client_id)
|
||||
_thread.start_new_thread(servercheck.reportSpam,(pb_id,))
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
#
|
||||
"""Common bits of functionality shared between all efro projects.
|
||||
|
||||
Things in here should be hardened, highly type-safe, and well-covered by unit
|
||||
tests since they are widely used in live client and server code.
|
||||
|
||||
license : MIT, see LICENSE for more details.
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
#
|
||||
"""Common bits of functionality shared between all efro projects.
|
||||
|
||||
Things in here should be hardened, highly type-safe, and well-covered by unit
|
||||
tests since they are widely used in live client and server code.
|
||||
|
||||
license : MIT, see LICENSE for more details.
|
||||
"""
|
||||
|
|
|
|||
4
dist/ba_root/mods/chatHandle/handlechat.py
vendored
4
dist/ba_root/mods/chatHandle/handlechat.py
vendored
|
|
@ -3,7 +3,7 @@
|
|||
from playersData import pdata
|
||||
from serverData import serverdata
|
||||
from chatHandle.ChatCommands import Main
|
||||
from tools import Logger, servercheck
|
||||
from tools import logger, servercheck
|
||||
from chatHandle.chatFilter import ChatFilter
|
||||
import ba, _ba
|
||||
import setting
|
||||
|
|
@ -38,7 +38,7 @@ def filter_chat_message(msg, client_id):
|
|||
if msg.startswith(",") and settings["allowTeamChat"]:
|
||||
return Main.QuickAccess(msg,client_id)
|
||||
|
||||
Logger.log(acid+" | "+displaystring+"|"+currentname+"| " +msg,"chat")
|
||||
logger.log(acid+" | "+displaystring+"|"+currentname+"| " +msg,"chat")
|
||||
|
||||
if acid in serverdata.clients and serverdata.clients[acid]["verified"]:
|
||||
|
||||
|
|
|
|||
14
dist/ba_root/mods/chatHandle/temporary.txt
vendored
14
dist/ba_root/mods/chatHandle/temporary.txt
vendored
|
|
@ -1,14 +0,0 @@
|
|||
###### remaining
|
||||
|
||||
|
||||
mute / unmute
|
||||
spaz
|
||||
me
|
||||
stats
|
||||
nv / dv
|
||||
replies for coamd like ' created role Pranav69 successfully'
|
||||
some dirt here there
|
||||
|
||||
|
||||
chat spam
|
||||
chat filter
|
||||
219
dist/ba_root/mods/custom_hooks.py
vendored
219
dist/ba_root/mods/custom_hooks.py
vendored
|
|
@ -1,182 +1,191 @@
|
|||
"""Custom hooks to pull of the in-game functions."""
|
||||
|
||||
# ba_meta require api 6
|
||||
# (see https://ballistica.net/wiki/meta-tag-system)
|
||||
|
||||
# pylint: disable=import-error
|
||||
# pylint: disable=import-outside-toplevel
|
||||
# pylint: disable=protected-access
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from datetime import datetime
|
||||
|
||||
import _thread
|
||||
import importlib
|
||||
import os
|
||||
import ba
|
||||
import _ba
|
||||
from chatHandle import handlechat
|
||||
import setting
|
||||
from tools import servercheck
|
||||
from tools import ServerUpdate
|
||||
import _thread
|
||||
from stats import mystats
|
||||
from datetime import datetime
|
||||
from ba import _activity
|
||||
|
||||
from typing import Optional, Any
|
||||
from spazmod import modifyspaz
|
||||
from bastd.activity import dualteamscore
|
||||
from bastd.activity import multiteamscore
|
||||
from bastd.activity import drawscore
|
||||
from bastd.actor.zoomtext import ZoomText
|
||||
from tools import TeamBalancer
|
||||
from bastd.activity.coopscore import CoopScoreScreen
|
||||
from ba import _hooks
|
||||
from tools import Logger
|
||||
|
||||
from bastd.activity import dualteamscore, multiteamscore, drawscore
|
||||
from bastd.activity.coopscore import CoopScoreScreen
|
||||
import setting
|
||||
|
||||
from chatHandle import handlechat
|
||||
from features import team_balancer, afk_check, fire_flies, dual_team_score as newdts
|
||||
from stats import mystats
|
||||
from spazmod import modifyspaz
|
||||
from tools import servercheck, ServerUpdate, logger
|
||||
from playersData import pdata
|
||||
|
||||
from tools import afk_check
|
||||
# from bastd.activity.multiteamvictory import
|
||||
from tools import fireflies
|
||||
if TYPE_CHECKING:
|
||||
from typing import Optional, Any
|
||||
|
||||
|
||||
settings = setting.get_settings_data()
|
||||
|
||||
def filter_chat_message(msg, client_id):
|
||||
|
||||
def filter_chat_message(msg: str, client_id: int) -> str | None:
|
||||
"""Returns all in game messages or None (ignore's message)."""
|
||||
return handlechat.filter_chat_message(msg, client_id)
|
||||
|
||||
|
||||
def on_app_launch():
|
||||
def on_app_launch() -> None:
|
||||
"""Runs when app is launched."""
|
||||
bootstraping()
|
||||
servercheck.checkserver().start()
|
||||
ServerUpdate.check()
|
||||
|
||||
if settings["afk_remover"]['enable']:
|
||||
afk_check.checkIdle().start()
|
||||
|
||||
|
||||
|
||||
#something
|
||||
|
||||
def score_screen_on_begin(_stats):
|
||||
pass
|
||||
#stats
|
||||
|
||||
def playerspaz_init(player):
|
||||
pass
|
||||
#add tag,rank,effect
|
||||
|
||||
def score_screen_on_begin(_stats: ba.Stats) -> None:
|
||||
"""Runs when score screen is displayed."""
|
||||
team_balancer.balanceTeams()
|
||||
mystats.update(_stats)
|
||||
|
||||
|
||||
def playerspaz_init(playerspaz: ba.Player, node: ba.Node, player: ba.Player):
|
||||
"""Runs when player is spawned on map."""
|
||||
modifyspaz.main(playerspaz, node, player)
|
||||
|
||||
|
||||
def bootstraping():
|
||||
|
||||
#_ba.disconnect_client=new_disconnect
|
||||
|
||||
"""Bootstarps the server."""
|
||||
# server related
|
||||
_ba.set_server_device_name(settings["HostDeviceName"])
|
||||
_ba.set_server_name(settings["HostName"])
|
||||
_ba.set_transparent_kickvote(settings["ShowKickVoteStarterName"])
|
||||
_ba.set_kickvote_msg_type(settings["KickVoteMsgType"])
|
||||
|
||||
# check for auto update stats
|
||||
_thread.start_new_thread(mystats.refreshStats,())
|
||||
|
||||
# import plugins
|
||||
if settings["elPatronPowerups"]["enable"]:
|
||||
from tools import elPatronPowerups
|
||||
from plugins import elPatronPowerups
|
||||
elPatronPowerups.enable()
|
||||
if settings["mikirogQuickTurn"]["enable"]:
|
||||
from tools import wavedash
|
||||
from plugins import wavedash # pylint: disable=unused-import
|
||||
|
||||
# import features
|
||||
if settings["whitelist"]:
|
||||
pdata.loadWhitelist()
|
||||
|
||||
import_discord_bot()
|
||||
import_games()
|
||||
import_dual_team_score()
|
||||
|
||||
|
||||
def import_discord_bot() -> None:
|
||||
"""Imports the discord bot."""
|
||||
if settings["discordbot"]["enable"]:
|
||||
from tools import discordbot
|
||||
discordbot.token=settings["discordbot"]["token"]
|
||||
discordbot.liveStatsChannelID=settings["discordbot"]["liveStatsChannelID"]
|
||||
discordbot.logsChannelID=settings["discordbot"]["logsChannelID"]
|
||||
discordbot.liveChat=settings["discordbot"]["liveChat"]
|
||||
discordbot.BsDataThread()
|
||||
discordbot.init()
|
||||
importgames()
|
||||
from features import discord_bot
|
||||
discord_bot.token=settings["discordbot"]["token"]
|
||||
discord_bot.liveStatsChannelID=settings["discordbot"]["liveStatsChannelID"]
|
||||
discord_bot.logsChannelID=settings["discordbot"]["logsChannelID"]
|
||||
discord_bot.liveChat=settings["discordbot"]["liveChat"]
|
||||
discord_bot.BsDataThread()
|
||||
discord_bot.init()
|
||||
|
||||
|
||||
def import_games():
|
||||
"""Imports the custom games from games directory."""
|
||||
games=os.listdir("ba_root/mods/games")
|
||||
for game in games:
|
||||
if game.endswith(".py") or game.endswith(".so"):
|
||||
importlib.import_module("games."+game.replace(".so","").replace(".py",""))
|
||||
|
||||
maps=os.listdir("ba_root/mods/maps")
|
||||
for _map in maps:
|
||||
if _map.endswith(".py") or _map.endswith(".so"):
|
||||
importlib.import_module("maps."+_map.replace(".so","").replace(".py",""))
|
||||
|
||||
def import_dual_team_score() -> None:
|
||||
"""Imports the dual team score."""
|
||||
if settings["newResultBoard"]:
|
||||
dualteamscore.TeamVictoryScoreScreenActivity= newdts.TeamVictoryScoreScreenActivity
|
||||
multiteamscore.MultiTeamScoreScreenActivity.show_player_scores = newdts.show_player_scores
|
||||
drawscore.DrawScoreScreenActivity=newdts.DrawScoreScreenActivity
|
||||
|
||||
|
||||
org_begin = ba._activity.Activity.on_begin
|
||||
|
||||
|
||||
def new_disconnect(clid,duration=120):
|
||||
print("new new_disconnect")
|
||||
_ba.ban_client(clid,duration)
|
||||
|
||||
org_begin=ba._activity.Activity.on_begin
|
||||
def new_begin(self):
|
||||
"""Runs when game is began."""
|
||||
org_begin(self)
|
||||
night_mode()
|
||||
|
||||
ba._activity.Activity.on_begin=new_begin
|
||||
|
||||
ba._activity.Activity.on_begin = new_begin
|
||||
|
||||
|
||||
org_end=ba._activity.Activity.end
|
||||
|
||||
def new_end(self,results:Any=None,delay:float=0.0,force:bool=False):
|
||||
act=_ba.get_foreground_host_activity()
|
||||
if isinstance(act,CoopScoreScreen):
|
||||
TeamBalancer.checkToExitCoop()
|
||||
|
||||
"""Runs when game is ended."""
|
||||
activity=_ba.get_foreground_host_activity()
|
||||
if isinstance(activity,CoopScoreScreen):
|
||||
team_balancer.checkToExitCoop()
|
||||
org_end(self,results,delay,force)
|
||||
|
||||
|
||||
ba._activity.Activity.end=new_end
|
||||
|
||||
|
||||
org_player_join=ba._activity.Activity.on_player_join
|
||||
|
||||
def on_player_join(self, player) -> None:
|
||||
TeamBalancer.on_player_join()
|
||||
"""Runs when player joins the game."""
|
||||
team_balancer.on_player_join()
|
||||
org_player_join(self,player)
|
||||
|
||||
ba._activity.Activity.on_player_join=on_player_join
|
||||
|
||||
|
||||
def night_mode() -> None:
|
||||
"""Checks the time and enables night mode."""
|
||||
|
||||
def night_mode():
|
||||
|
||||
if(settings['autoNightMode']['enable']):
|
||||
if settings['autoNightMode']['enable']:
|
||||
|
||||
start=datetime.strptime(settings['autoNightMode']['startTime'],"%H:%M")
|
||||
end=datetime.strptime(settings['autoNightMode']['endTime'],"%H:%M")
|
||||
now=datetime.now()
|
||||
|
||||
|
||||
if now.time() > start.time() or now.time() < end.time():
|
||||
activity = _ba.get_foreground_host_activity()
|
||||
|
||||
activity.globalsnode.tint = (0.5, 0.7, 1.0)
|
||||
|
||||
if settings['autoNightMode']['fireflies']:
|
||||
fireflies.factory(settings['autoNightMode']["fireflies_random_color"])
|
||||
fire_flies.factory(settings['autoNightMode']["fireflies_random_color"])
|
||||
|
||||
|
||||
|
||||
from tools import dualteamscore as newdts
|
||||
|
||||
if settings["newResultBoard"]:
|
||||
def kick_vote_started(started_by: str,started_to: str) -> None:
|
||||
"""Logs the kick vote."""
|
||||
logger.log(f"{started_by} started kick vote for {started_to}.")
|
||||
|
||||
|
||||
dualteamscore.TeamVictoryScoreScreenActivity= newdts.TeamVictoryScoreScreenActivity
|
||||
def on_kicked(account_id: str) -> None:
|
||||
"""Runs when someone is kicked by kickvote."""
|
||||
logger.log(f"{account_id} kicked by kickvotes.")
|
||||
|
||||
multiteamscore.MultiTeamScoreScreenActivity.show_player_scores = newdts.show_player_scores
|
||||
|
||||
drawscore.DrawScoreScreenActivity=newdts.DrawScoreScreenActivity
|
||||
|
||||
def scoreScreenBegin():
|
||||
TeamBalancer.balanceTeams()
|
||||
|
||||
|
||||
def kick_vote_started(by,to):
|
||||
Logger.log(by+" started kick vote for "+to)
|
||||
|
||||
_hooks.kick_vote_started=kick_vote_started
|
||||
|
||||
def on_kicked(id):
|
||||
Logger.log(id+" kicked by kickvotes")
|
||||
|
||||
_hooks.on_kicked=on_kicked
|
||||
|
||||
def on_kick_vote_end():
|
||||
Logger.log("Kick vote End")
|
||||
"""Runs when kickvote is ended."""
|
||||
logger.log("Kick vote End")
|
||||
|
||||
|
||||
|
||||
import os
|
||||
import importlib
|
||||
def importgames():
|
||||
games=os.listdir("ba_root/mods/games")
|
||||
for game in games:
|
||||
if game.endswith(".py") or game.endswith(".so"):
|
||||
importlib.import_module("games."+game.replace(".so","").replace(".py",""))
|
||||
maps=os.listdir("ba_root/mods/maps")
|
||||
for map in maps:
|
||||
if map.endswith(".py") or map.endswith(".so"):
|
||||
importlib.import_module("maps."+map.replace(".so","").replace(".py",""))
|
||||
|
||||
|
||||
|
||||
|
||||
_hooks.kick_vote_started=kick_vote_started
|
||||
_hooks.on_kicked=on_kicked
|
||||
|
|
|
|||
7
dist/ba_root/mods/features/__init__.py
vendored
Normal file
7
dist/ba_root/mods/features/__init__.py
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
"""Common bits of functionality shared between all efro projects.
|
||||
|
||||
Things in here should be hardened, highly type-safe, and well-covered by unit
|
||||
tests since they are widely used in live client and server code.
|
||||
|
||||
license : MIT, see LICENSE for more details.
|
||||
"""
|
||||
7
dist/ba_root/mods/games/__init__.py
vendored
7
dist/ba_root/mods/games/__init__.py
vendored
|
|
@ -0,0 +1,7 @@
|
|||
"""Common bits of functionality shared between all efro projects.
|
||||
|
||||
Things in here should be hardened, highly type-safe, and well-covered by unit
|
||||
tests since they are widely used in live client and server code.
|
||||
|
||||
license : MIT, see LICENSE for more details.
|
||||
"""
|
||||
7
dist/ba_root/mods/playersData/__init__.py
vendored
7
dist/ba_root/mods/playersData/__init__.py
vendored
|
|
@ -1,10 +1,7 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
#
|
||||
"""Common bits of functionality shared between all efro projects.
|
||||
|
||||
Things in here should be hardened, highly type-safe, and well-covered by unit
|
||||
tests since they are widely used in live client and server code.
|
||||
|
||||
license : MIT, see LICENSE for more details.
|
||||
"""
|
||||
|
||||
|
||||
score=69
|
||||
23
dist/ba_root/mods/plugins/__init__.py
vendored
Normal file
23
dist/ba_root/mods/plugins/__init__.py
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
"""Common bits of functionality shared between all efro projects.
|
||||
|
||||
Things in here should be hardened, highly type-safe, and well-covered by unit
|
||||
tests since they are widely used in live client and server code.
|
||||
|
||||
license : MIT, see LICENSE for more details.
|
||||
"""
|
||||
|
||||
# ba_meta require api 6
|
||||
# (see https://ballistica.net/wiki/meta-tag-system)
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import ba
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
# ba_meta export plugin
|
||||
class Init(ba.Plugin): # pylint: disable=too-few-public-methods
|
||||
"""Initializes all of the plugins in the directory."""
|
||||
168
dist/ba_root/mods/privateserver.backup
vendored
168
dist/ba_root/mods/privateserver.backup
vendored
|
|
@ -1,168 +0,0 @@
|
|||
"""
|
||||
Private Server whitelist by Mr.Smoothy
|
||||
|
||||
* don't dare to remove credits or I will bite you
|
||||
|
||||
GitHub : https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server
|
||||
"""
|
||||
|
||||
# ba_meta require api 6
|
||||
from __future__ import annotations
|
||||
from typing import TYPE_CHECKING
|
||||
from ba._enums import TimeType
|
||||
|
||||
import ba, json, _ba, time, datetime
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
|
||||
whitelist_on = True
|
||||
""" Change It By Chat Commands For By Editing Here """
|
||||
|
||||
|
||||
spectators = False
|
||||
""" False Means Spectating Not Allowed """
|
||||
|
||||
|
||||
whitelist = {}
|
||||
""" Dont change """
|
||||
|
||||
|
||||
lobbychecktime = 3
|
||||
"""
|
||||
Time in seconds, to check lobby players ... increase time ,for more time unwanted players can watch match
|
||||
Decrease time , kick them fast , but can also give some lagg to the server , adjust yourself acrd. to cpu power """
|
||||
|
||||
|
||||
admins = ['pb-JiNJARBaXEFBVF9HFkNXXF1EF0ZaRlZE']
|
||||
"""Dirty admin system , for now , until we get good working chat commands """
|
||||
|
||||
|
||||
def inWhiteList(id):
|
||||
global whitelist
|
||||
if id in whitelist:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
def addToWhitelist(id,displaystr):
|
||||
global whitelist
|
||||
if id not in whitelist:
|
||||
whitelist[id]=[displaystr]
|
||||
else:
|
||||
whitelist[id].append(displaystr)
|
||||
f=open("whitelist.json","w")
|
||||
json.dump(whitelist,f,indent=4)
|
||||
f.close()
|
||||
|
||||
def handlechat(msg,clientid):
|
||||
gg=_ba.get_game_roster()
|
||||
acc_id="LOL"
|
||||
if msg.startswith("/"):
|
||||
for clt in gg:
|
||||
if clt['client_id'] ==clientid:
|
||||
acc_id=clt['account_id']
|
||||
global admins
|
||||
if acc_id in admins:
|
||||
commands(acc_id ,msg)
|
||||
def handlerequest(player):
|
||||
if whitelist_on:
|
||||
if inWhiteList(player.get_account_id()):
|
||||
pass
|
||||
else:
|
||||
for clt in _ba.get_game_roster():
|
||||
if clt['account_id']==player.get_account_id():
|
||||
|
||||
f=open("loggs.txt",'a+')
|
||||
f.write("kicked for joining"+clt['account_id']+"\n")
|
||||
f.close()
|
||||
_ba.disconnect_client(clt['client_id'])
|
||||
|
||||
|
||||
|
||||
|
||||
def commands(acc_id,msg):
|
||||
global whitelist
|
||||
global whitelist_on
|
||||
global spectators
|
||||
cmnd=msg.split(" ")[0]
|
||||
|
||||
args=msg.split(" ")[1:]
|
||||
if cmnd=='/add' and args!=[]:
|
||||
|
||||
gg=_ba.get_game_roster()
|
||||
for clt in gg:
|
||||
if clt['client_id']==int(args[0]):
|
||||
|
||||
addToWhitelist(clt['account_id'],clt['display_string'])
|
||||
f=open("loggs.txt",'a+')
|
||||
f.write(acc_id+" added "+clt['account_id']+"\n")
|
||||
f.close()
|
||||
_ba.chatmessage(clt['display_string']+" whitelisted")
|
||||
if cmnd=='/whitelist':
|
||||
whitelist_on=whitelist_on==False
|
||||
if whitelist_on:
|
||||
_ba.chatmessage("WhiteList turned on")
|
||||
else:
|
||||
_ba.chatmessage("whitelist turned off")
|
||||
if cmnd=='/spectators':
|
||||
spectators=spectators==False
|
||||
if spectators:
|
||||
_ba.chatmessage("Spectators can watch now")
|
||||
else:
|
||||
_ba.chatmessage("Spectators will be kicked")
|
||||
|
||||
|
||||
|
||||
def dstrinWhiteList(dstr):
|
||||
global whitelist
|
||||
return any(dstr in chici for chici in whitelist.values())
|
||||
|
||||
|
||||
# ba_meta export plugin
|
||||
class private(ba.Plugin):
|
||||
"""My first ballistica plugin!"""
|
||||
|
||||
def __init__(self):
|
||||
global whitelist
|
||||
global whitelist_on
|
||||
global spectators
|
||||
global lobbychecktime
|
||||
|
||||
try:
|
||||
f=open("whitelist.json")
|
||||
dat=json.loads(f.read())
|
||||
whitelist=dat
|
||||
f.close()
|
||||
except:
|
||||
print("no whitelist detected , creating one")
|
||||
self.li={}
|
||||
self.li['pb-JiNJARBaXEFBVF9HFkNXXF1EF0ZaRlZE']=['smoothyki-id','mr.smoothy']
|
||||
f=open("whitelist.json",'w')
|
||||
json.dump(self.li,f,indent=4)
|
||||
f.close()
|
||||
if whitelist_on and not spectators:
|
||||
self.timerr=ba.Timer(lobbychecktime,self.checklobby,repeat=True,timetype=TimeType.REAL)
|
||||
def checklobby(self):
|
||||
global whitelist_on
|
||||
global whitelist
|
||||
global spectators
|
||||
if whitelist_on and not spectators:
|
||||
try:
|
||||
gg=_ba.get_game_roster()
|
||||
for clt in gg:
|
||||
if clt['account_id'] in whitelist and clt['account_id']!='' or clt['client_id']==-1:
|
||||
pass
|
||||
else:
|
||||
f=open("loggs.txt","a+")
|
||||
f.write("Kicked from lobby"+clt['account_id']+" "+clt['spec_string']+"\n")
|
||||
_ba.disconnect_client(clt['client_id'])
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
4
dist/ba_root/mods/serverData/__init__.py
vendored
4
dist/ba_root/mods/serverData/__init__.py
vendored
|
|
@ -1,7 +1,7 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
#
|
||||
"""Common bits of functionality shared between all efro projects.
|
||||
|
||||
Things in here should be hardened, highly type-safe, and well-covered by unit
|
||||
tests since they are widely used in live client and server code.
|
||||
|
||||
license : MIT, see LICENSE for more details.
|
||||
"""
|
||||
|
|
|
|||
57
dist/ba_root/mods/setting.py
vendored
57
dist/ba_root/mods/setting.py
vendored
|
|
@ -1,34 +1,43 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
import _ba, json
|
||||
"""Module to update `setting.json`."""
|
||||
|
||||
settings_path = _ba.env()["python_directory_user"]+"/setting.json"
|
||||
# ba_meta require api 6
|
||||
# (see https://ballistica.net/wiki/meta-tag-system)
|
||||
|
||||
settings=None
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from functools import lru_cache
|
||||
|
||||
import json
|
||||
import _ba
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def get_settings_data():
|
||||
global settings
|
||||
if settings==None:
|
||||
with open(settings_path, "r") as f:
|
||||
data = json.load(f)
|
||||
settings=data
|
||||
return settings
|
||||
else:
|
||||
|
||||
return settings
|
||||
SETTINGS_PATH = _ba.env().get("python_directory_user", "") + "/setting.json"
|
||||
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
def get_settings_data() -> dict:
|
||||
"""Returns the dictionary of settings related to the server.
|
||||
|
||||
def commit(data):
|
||||
with open(settings_path, "w") as f:
|
||||
json.dump(data, f, indent=4)
|
||||
Returns
|
||||
-------
|
||||
dict
|
||||
settings related to server
|
||||
"""
|
||||
with open(SETTINGS_PATH, mode="r", encoding="utf-8") as data:
|
||||
return json.load(data)
|
||||
|
||||
|
||||
def commit(data: dict) -> None:
|
||||
"""Commits the data in setting file.
|
||||
|
||||
def sendError(msg : str, client_id : int = None):
|
||||
if client_id == None:
|
||||
_ba.screenmessage(msg, color=(1,0,0))
|
||||
else:
|
||||
_ba.screenmessage(msg, color=(1,0,0), transient=True, clients=[client_id])
|
||||
|
||||
Parameters
|
||||
----------
|
||||
data : dict
|
||||
data to be commited
|
||||
"""
|
||||
with open(SETTINGS_PATH, mode="w", encoding="utf-8") as setting_file:
|
||||
json.dump(data, setting_file, indent=4)
|
||||
|
|
|
|||
7
dist/ba_root/mods/spazmod/__init__.py
vendored
Normal file
7
dist/ba_root/mods/spazmod/__init__.py
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
"""Common bits of functionality shared between all efro projects.
|
||||
|
||||
Things in here should be hardened, highly type-safe, and well-covered by unit
|
||||
tests since they are widely used in live client and server code.
|
||||
|
||||
license : MIT, see LICENSE for more details.
|
||||
"""
|
||||
15
dist/ba_root/mods/spazmod/effects.py
vendored
15
dist/ba_root/mods/spazmod/effects.py
vendored
|
|
@ -18,13 +18,24 @@ from bastd.actor.powerupbox import PowerupBoxFactory
|
|||
import ba,_ba,bastd,weakref,random,math,time,base64,os,json,setting
|
||||
from playersData import pdata
|
||||
from stats import mystats
|
||||
from tools import globalvars as gvar
|
||||
PlayerType = TypeVar('PlayerType', bound=ba.Player)
|
||||
TeamType = TypeVar('TeamType', bound=ba.Team)
|
||||
from ba._generated.enums import TimeType
|
||||
tt = ba.TimeType.SIM
|
||||
tf = ba.TimeFormat.MILLISECONDS
|
||||
|
||||
multicolor = {0:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),
|
||||
250:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),
|
||||
500:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),
|
||||
750:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),
|
||||
1000:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),
|
||||
1250:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),
|
||||
1500:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),
|
||||
1750:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),
|
||||
2000:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),
|
||||
2250:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),
|
||||
2500:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0))}
|
||||
|
||||
class SurroundBallFactory(object):
|
||||
def __init__(self):
|
||||
self.bonesTex = ba.gettexture("powerupCurse")
|
||||
|
|
@ -216,7 +227,7 @@ class Effect(ba.Actor):
|
|||
self.source_player.actor.node.addDeathAction(ba.Call(self.handlemessage,ba.DieMessage()))
|
||||
|
||||
def add_multicolor_effect(self):
|
||||
if spaz.node: ba.animate_array(spaz.node, 'color', 3, gvar.multicolor, True, timetype=tt, timeformat=tf)
|
||||
if spaz.node: ba.animate_array(spaz.node, 'color', 3, multicolor, True, timetype=tt, timeformat=tf)
|
||||
|
||||
def checkPlayerifDead(self):
|
||||
spaz = self.spazRef()
|
||||
|
|
|
|||
7
dist/ba_root/mods/stats/__init__.py
vendored
7
dist/ba_root/mods/stats/__init__.py
vendored
|
|
@ -0,0 +1,7 @@
|
|||
"""Common bits of functionality shared between all efro projects.
|
||||
|
||||
Things in here should be hardened, highly type-safe, and well-covered by unit
|
||||
tests since they are widely used in live client and server code.
|
||||
|
||||
license : MIT, see LICENSE for more details.
|
||||
"""
|
||||
1
dist/ba_root/mods/stats/mystats.py
vendored
1
dist/ba_root/mods/stats/mystats.py
vendored
|
|
@ -198,7 +198,6 @@ def update(score_set):
|
|||
store.
|
||||
"""
|
||||
# look at score-set entries to tally per-account kills for this round
|
||||
custom_hooks.scoreScreenBegin()
|
||||
|
||||
account_kills = {}
|
||||
account_deaths = {}
|
||||
|
|
|
|||
86
dist/ba_root/mods/tools/Logger.py
vendored
86
dist/ba_root/mods/tools/Logger.py
vendored
|
|
@ -1,86 +0,0 @@
|
|||
|
||||
import ba,_ba
|
||||
import datetime;
|
||||
import os
|
||||
import threading
|
||||
# ct stores current time
|
||||
|
||||
import setting
|
||||
settings = setting.get_settings_data()
|
||||
|
||||
if settings['discordbot']["enable"]:
|
||||
from tools import discordbot
|
||||
|
||||
|
||||
path=_ba.env()['python_directory_user']
|
||||
serverdata=os.path.join(path,"serverData" + os.sep)
|
||||
chats=[]
|
||||
joinlog=[]
|
||||
cmndlog=[]
|
||||
misclogs=[]
|
||||
|
||||
def log(msg,mtype='sys'):
|
||||
global chats,joinlog,cmndlog,misclogs
|
||||
|
||||
if settings['discordbot']["enable"]:
|
||||
m=msg.replace('||','|')
|
||||
discordbot.push_log("***"+mtype+":***"+m)
|
||||
|
||||
ct=datetime.datetime.now()
|
||||
msg=str(ct)+": "+msg +"\n"
|
||||
if mtype=='chat':
|
||||
chats.append(msg)
|
||||
if len(chats) >10:
|
||||
dumplogs(chats,"chat").start()
|
||||
chats=[]
|
||||
elif mtype=="playerjoin":
|
||||
joinlog.append(msg)
|
||||
if len(joinlog)>3:
|
||||
dumplogs(joinlog,"joinlog").start()
|
||||
joinlog=[]
|
||||
elif mtype=='chatcmd':
|
||||
cmndlog.append(msg)
|
||||
if len(cmndlog)>3:
|
||||
dumplogs(cmndlog,"cmndlog").start()
|
||||
cmndlog=[]
|
||||
|
||||
else:
|
||||
misclogs.append(msg)
|
||||
if len(misclogs)>5:
|
||||
dumplogs(misclogs,"sys").start()
|
||||
misclogs=[]
|
||||
|
||||
|
||||
class dumplogs(threading.Thread):
|
||||
def __init__(self,msg,mtype='sys'):
|
||||
threading.Thread.__init__(self)
|
||||
self.msg=msg
|
||||
self.type=mtype
|
||||
|
||||
def run(self):
|
||||
|
||||
|
||||
if self.type=='chat':
|
||||
|
||||
f=open(serverdata+"Chat Logs.log","a+")
|
||||
|
||||
|
||||
|
||||
elif self.type=='joinlog':
|
||||
f=open(serverdata+"joining.log","a+")
|
||||
|
||||
|
||||
elif self.type=='cmndlog':
|
||||
f=open(serverdata+"cmndusage.log","a+")
|
||||
|
||||
else:
|
||||
f=open(serverdata+"logs.log","a+")
|
||||
for m in self.msg:
|
||||
f.write(m)
|
||||
f.close()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
11
dist/ba_root/mods/tools/__init__.py
vendored
11
dist/ba_root/mods/tools/__init__.py
vendored
|
|
@ -1,14 +1,7 @@
|
|||
# Released under the MIT License. See LICENSE for details.
|
||||
#
|
||||
"""Common bits of functionality shared between all efro projects.
|
||||
|
||||
Things in here should be hardened, highly type-safe, and well-covered by unit
|
||||
tests since they are widely used in live client and server code.
|
||||
|
||||
license : MIT, see LICENSE for more details.
|
||||
"""
|
||||
|
||||
name="smoothy"
|
||||
|
||||
|
||||
|
||||
def log():
|
||||
print("i logged")
|
||||
|
|
|
|||
23
dist/ba_root/mods/tools/elPatronPowerups.py
vendored
23
dist/ba_root/mods/tools/elPatronPowerups.py
vendored
File diff suppressed because one or more lines are too long
8
dist/ba_root/mods/tools/globalvars.py
vendored
8
dist/ba_root/mods/tools/globalvars.py
vendored
|
|
@ -1,8 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Released under the MIT License. See LICENSE for details.
|
||||
# ba_meta require api 6
|
||||
|
||||
import ba,_ba,random
|
||||
|
||||
uni = {'\\c': '\\ue043','\\sh': '\\ue049','\\v':'\\ue04c', '\\h': '\\ue047', '\\z':'\\ue044', '\\n': '\\ue04b', '\\b': '\\ue04b', '\\d': '\\ue048', '\\s': '\\ue046', '\\f': '\\ue04f', '\\l': '\\ue00c', '\\g': '\\ue02c', '\\t': '\\ue02f', '\\i': '\\ue03a'}
|
||||
multicolor = {0:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),250:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),500:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),750:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),1000:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),1250:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),1500:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),1750:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),2000:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),2250:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0)),2500:((0+random.random()*3.0),(0+random.random()*3.0),(0+random.random()*3.0))}
|
||||
98
dist/ba_root/mods/tools/logger.py
vendored
Normal file
98
dist/ba_root/mods/tools/logger.py
vendored
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
"""Module to Keeps the log of multiple things."""
|
||||
|
||||
# ba_meta require api 6
|
||||
# (see https://ballistica.net/wiki/meta-tag-system)
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
import os
|
||||
import datetime
|
||||
import threading
|
||||
import setting
|
||||
import _ba
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
|
||||
SETTINGS = setting.get_settings_data()
|
||||
SERVER_DATA_PATH = os.path.join(
|
||||
_ba.env()["python_directory_user"], "serverData" + os.sep
|
||||
)
|
||||
|
||||
|
||||
if SETTINGS["discordbot"]["enable"]:
|
||||
from features import discord_bot
|
||||
|
||||
|
||||
@dataclass
|
||||
class RecentLogs:
|
||||
"""Saves the recent logs."""
|
||||
|
||||
chats: list[str] = field(default_factory=list)
|
||||
joinlog: list[str] = field(default_factory=list)
|
||||
cmndlog: list[str] = field(default_factory=list)
|
||||
misclogs: list[str] = field(default_factory=list)
|
||||
|
||||
|
||||
def log(msg: str, mtype: str = "sys") -> None:
|
||||
"""Cache and dumps the log."""
|
||||
logs = RecentLogs()
|
||||
|
||||
if SETTINGS["discordbot"]["enable"]:
|
||||
message = msg.replace("||", "|")
|
||||
discord_bot.push_log("***" + mtype + ":***" + message)
|
||||
|
||||
current_time = datetime.datetime.now()
|
||||
msg = f"{current_time} + : {msg} \n"
|
||||
|
||||
if mtype == "chat":
|
||||
logs.chats.append(msg)
|
||||
if len(logs.chats) > 10:
|
||||
dumplogs(logs.chats, "chat").start()
|
||||
logs.chats = []
|
||||
|
||||
elif mtype == "playerjoin":
|
||||
logs.joinlog.append(msg)
|
||||
if len(logs.joinlog) > 3:
|
||||
dumplogs(logs.joinlog, "joinlog").start()
|
||||
logs.joinlog = []
|
||||
|
||||
elif mtype == "chatcmd":
|
||||
logs.cmndlog.append(msg)
|
||||
if len(logs.cmndlog) > 3:
|
||||
dumplogs(logs.cmndlog, "cmndlog").start()
|
||||
logs.cmndlog = []
|
||||
|
||||
else:
|
||||
logs.misclogs.append(msg)
|
||||
if len(logs.misclogs) > 5:
|
||||
dumplogs(logs.misclogs, "sys").start()
|
||||
logs.misclogs = []
|
||||
|
||||
|
||||
class dumplogs(threading.Thread):
|
||||
"""Dumps the logs in the server data."""
|
||||
|
||||
def __init__(self, msg, mtype="sys"):
|
||||
super().__init__()
|
||||
self.msg = msg
|
||||
self.type = mtype
|
||||
|
||||
def run(self):
|
||||
|
||||
if self.type == "chat":
|
||||
log_path = SERVER_DATA_PATH + "Chat Logs.log"
|
||||
elif self.type == "joinlog":
|
||||
log_path = SERVER_DATA_PATH + "joining.log"
|
||||
elif self.type == "cmndlog":
|
||||
log_path = SERVER_DATA_PATH + "cmndusage.log"
|
||||
else:
|
||||
log_path = SERVER_DATA_PATH + "logs.log"
|
||||
|
||||
with open(log_path, mode="a+", encoding="utf-8") as file:
|
||||
for msg in self.msg:
|
||||
file.write(msg)
|
||||
0
dist/ba_root/mods/tools/logs.txt
vendored
0
dist/ba_root/mods/tools/logs.txt
vendored
18
dist/ba_root/mods/tools/servercheck.py
vendored
18
dist/ba_root/mods/tools/servercheck.py
vendored
|
|
@ -15,8 +15,8 @@ from ba._general import Call
|
|||
import threading
|
||||
import setting
|
||||
import _thread
|
||||
from tools import Logger
|
||||
from tools import profanity
|
||||
from tools import logger
|
||||
from features import profanity
|
||||
|
||||
# class ServerChecker:
|
||||
|
||||
|
|
@ -77,13 +77,13 @@ class checkserver(object):
|
|||
d_str=ros['display_string']
|
||||
d_str2=profanity.censor(d_str)
|
||||
try:
|
||||
Logger.log(d_str+"||"+ros["account_id"]+"|| joined server","playerjoin")
|
||||
logger.log(d_str+"||"+ros["account_id"]+"|| joined server","playerjoin")
|
||||
except:
|
||||
pass
|
||||
if d_str2!=d_str:
|
||||
_ba.screenmessage("Profanity in Id , change your ID and join back",color=(1,0,0),transient=True,clients=[ros['client_id']])
|
||||
try:
|
||||
Logger.log(d_str+"||"+ros["account_id"]+"|| kicked by profanity check","sys")
|
||||
logger.log(d_str+"||"+ros["account_id"]+"|| kicked by profanity check","sys")
|
||||
except:
|
||||
pass
|
||||
_ba.disconnect_client(ros['client_id'],1)
|
||||
|
|
@ -92,7 +92,7 @@ class checkserver(object):
|
|||
if settings["whitelist"] and ros["account_id"]!=None:
|
||||
if ros["account_id"] not in pdata.whitelist:
|
||||
_ba.screenmessage("Not in whitelist,contact admin",color=(1,0,0),transient=True,clients=[ros['client_id']])
|
||||
Logger.log(d_str+"||"+ros["account_id"]+" | kicked > not in whitelist")
|
||||
logger.log(d_str+"||"+ros["account_id"]+" | kicked > not in whitelist")
|
||||
_ba.disconnect_client(ros['client_id'])
|
||||
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ def on_player_join_server(pbid,player_data):
|
|||
rejoinCount+=1
|
||||
if rejoinCount >2:
|
||||
_ba.screenmessage("Joining too fast , slow down dude",color=(1,0,1),transient=True,clients=[clid])
|
||||
Logger.log(pbid+"|| kicked for joining too fast")
|
||||
logger.log(pbid+"|| kicked for joining too fast")
|
||||
_ba.disconnect_client(clid)
|
||||
|
||||
_thread.start_new_thread(reportSpam,(pbid,))
|
||||
|
|
@ -149,7 +149,7 @@ def on_player_join_server(pbid,player_data):
|
|||
if ros['account_id']==pbid:
|
||||
if not player_data["isBan"]:
|
||||
_ba.screenmessage("New Accounts not allowed here , come back later",color=(1,0,0), transient=True,clients=[ros['client_id']])
|
||||
Logger.log(pbid+" | kicked > reason:Banned account")
|
||||
logger.log(pbid+" | kicked > reason:Banned account")
|
||||
_ba.disconnect_client(ros['client_id'])
|
||||
|
||||
return
|
||||
|
|
@ -315,7 +315,7 @@ def save_age(age, pb_id,display_string):
|
|||
thread2.start()
|
||||
if get_account_age(age) < settings["minAgeToJoinInHours"]:
|
||||
msg="New Accounts not allowed to play here , come back tmrw."
|
||||
Logger.log(pb_id+"|| kicked > new account")
|
||||
logger.log(pb_id+"|| kicked > new account")
|
||||
_ba.pushcall(Call(kick_by_pb_id,pb_id,msg),from_other_thread=True)
|
||||
|
||||
def save_ids(ids,pb_id,display_string):
|
||||
|
|
@ -328,7 +328,7 @@ def save_ids(ids,pb_id,display_string):
|
|||
msg="Spoofed Id detected , Goodbye"
|
||||
_ba.pushcall(Call(kick_by_pb_id,pb_id,msg),from_other_thread=True)
|
||||
serverdata.clients[pb_id]["verified"]=False
|
||||
Logger.log(pb_id+"|| kicked , for using spoofed id "+display_string)
|
||||
logger.log(pb_id+"|| kicked , for using spoofed id "+display_string)
|
||||
else:
|
||||
serverdata.clients[pb_id]["verified"]=True
|
||||
|
||||
|
|
|
|||
124
dist/ba_root/mods/tools/wavedash.py
vendored
124
dist/ba_root/mods/tools/wavedash.py
vendored
|
|
@ -1,124 +0,0 @@
|
|||
"""Wavedash by TheMikirog
|
||||
|
||||
This is an early version of the plugin. Feedback appreciated!
|
||||
|
||||
"""
|
||||
|
||||
# ba_meta require api 6
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import ba
|
||||
import math
|
||||
import bastd
|
||||
from bastd.actor.spaz import Spaz
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
# ba_meta export plugin
|
||||
class MikiWavedashTest(ba.Plugin):
|
||||
|
||||
|
||||
class FootConnectMessage:
|
||||
"""Spaz started touching the ground"""
|
||||
|
||||
class FootDisconnectMessage:
|
||||
"""Spaz stopped touching the ground"""
|
||||
|
||||
def wavedash(self) -> None:
|
||||
if not self.node:
|
||||
return
|
||||
|
||||
isMoving = abs(self.node.move_up_down) >= 0.5 or abs(self.node.move_left_right) >= 0.5
|
||||
|
||||
if self._dead or not self.grounded or not isMoving:
|
||||
return
|
||||
|
||||
if self.node.knockout > 0.0 or self.frozen or self.node.hold_node:
|
||||
return
|
||||
|
||||
t_ms = ba.time(timeformat=ba.TimeFormat.MILLISECONDS)
|
||||
assert isinstance(t_ms, int)
|
||||
|
||||
if t_ms - self.last_wavedash_time_ms >= self._wavedash_cooldown:
|
||||
|
||||
move = [self.node.move_left_right, -self.node.move_up_down]
|
||||
vel = [self.node.velocity[0], self.node.velocity[2]]
|
||||
|
||||
move_length = math.hypot(move[0], move[1])
|
||||
vel_length = math.hypot(vel[0], vel[1])
|
||||
if vel_length < 1.25: return
|
||||
move_norm = [m/move_length for m in move]
|
||||
vel_norm = [v/vel_length for v in vel]
|
||||
dot = sum(x*y for x,y in zip(move_norm,vel_norm))
|
||||
turn_power = min(round(math.acos(dot) / math.pi,2)*1.3,1)
|
||||
if turn_power < 0.2: return
|
||||
|
||||
boost_power = math.sqrt(math.pow(vel[0],2) + math.pow(vel[1],2)) * 1.2
|
||||
boost_power = min(pow(boost_power,4),160)
|
||||
#print(boost_power * turn_power)
|
||||
|
||||
self.last_wavedash_time_ms = t_ms
|
||||
|
||||
# FX
|
||||
ba.emitfx(position=self.node.position,
|
||||
velocity=(vel[0]*0.5,-1,vel[1]*0.5),
|
||||
chunk_type='sweat',
|
||||
count=8,
|
||||
scale=boost_power / 160 * turn_power,
|
||||
spread=0.25);
|
||||
|
||||
# Boost itself
|
||||
pos = self.node.position
|
||||
for i in range(6):
|
||||
self.node.handlemessage('impulse',pos[0],-0.1+pos[1]+i*0.1,pos[2],
|
||||
0,0,0,
|
||||
boost_power * turn_power,
|
||||
boost_power * turn_power,0,0,
|
||||
move[0],0,move[1])
|
||||
|
||||
def new_spaz_init(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
|
||||
func(*args, **kwargs)
|
||||
|
||||
# args[0] = self
|
||||
args[0]._wavedash_cooldown = 30
|
||||
args[0].last_wavedash_time_ms = -9999
|
||||
args[0].grounded = 0
|
||||
|
||||
return wrapper
|
||||
bastd.actor.spaz.Spaz.__init__ = new_spaz_init(bastd.actor.spaz.Spaz.__init__)
|
||||
|
||||
def new_factory(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
func(*args, **kwargs)
|
||||
|
||||
args[0].roller_material.add_actions(
|
||||
conditions=('they_have_material', bastd.gameutils.SharedObjects.get().footing_material),
|
||||
actions=(('message', 'our_node', 'at_connect', MikiWavedashTest.FootConnectMessage),
|
||||
('message', 'our_node', 'at_disconnect', MikiWavedashTest.FootDisconnectMessage)))
|
||||
return wrapper
|
||||
bastd.actor.spazfactory.SpazFactory.__init__ = new_factory(bastd.actor.spazfactory.SpazFactory.__init__)
|
||||
|
||||
def new_handlemessage(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
if args[1] == MikiWavedashTest.FootConnectMessage:
|
||||
args[0].grounded += 1
|
||||
elif args[1] == MikiWavedashTest.FootDisconnectMessage:
|
||||
if args[0].grounded > 0: args[0].grounded -= 1
|
||||
|
||||
func(*args, **kwargs)
|
||||
return wrapper
|
||||
bastd.actor.spaz.Spaz.handlemessage = new_handlemessage(bastd.actor.spaz.Spaz.handlemessage)
|
||||
|
||||
def new_on_run(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
if args[0]._last_run_value < args[1] and args[1] > 0.8:
|
||||
MikiWavedashTest.wavedash(args[0])
|
||||
func(*args, **kwargs)
|
||||
return wrapper
|
||||
bastd.actor.spaz.Spaz.on_run = new_on_run(bastd.actor.spaz.Spaz.on_run)
|
||||
Loading…
Add table
Add a link
Reference in a new issue