diff --git a/dist/ba_root/mods/filelock.py b/dist/ba_data/python-site-packages/filelock.py similarity index 100% rename from dist/ba_root/mods/filelock.py rename to dist/ba_data/python-site-packages/filelock.py diff --git a/dist/ba_root/config.json b/dist/ba_root/config.json index 4b2f3d6..ac7e2f9 100644 --- a/dist/ba_root/config.json +++ b/dist/ba_root/config.json @@ -433,16 +433,7 @@ }, "Plugins": { "plugins.Init": { - "enabled": true - }, - "plugins.CharacterChooser.HeySmoothy": { - "enabled": true - }, - "plugins.bombsquadhttpapi.HeySmoothy": { - "enabled": false - }, - "plugins.importcustomcharacters.HeySmoothy": { - "enabled": false + "enabled": true } }, "Port": 43210, diff --git a/dist/ba_root/mods/custom_characters/chiku.json b/dist/ba_root/mods/custom_characters/chiku.json new file mode 100644 index 0000000..0f109c4 --- /dev/null +++ b/dist/ba_root/mods/custom_characters/chiku.json @@ -0,0 +1,43 @@ +{ + "color_mask": "aliColorMask", + "color_texture": "aliColor", + "head": "aliHead", + "hand": "neoSpazHand", + "torso": "jackTorso", + "pelvis": "neoSpazTorso", + "upper_arm": "pixieUpperArm", + "forearm": "cyborgForeArm", + "upper_leg": "jackUpperLeg", + "lower_leg": "neoSpazLowerLeg", + "toes_model": "melToes", + "jump_sounds": [ + "spazJump01", + "spazJump02", + "spazJump03", + "spazJump04" + ], + "attack_sounds": [ + "spazAttack01", + "spazAttack02", + "spazAttack03", + "spazAttack04" + ], + "impact_sounds": [ + "spazImpact01", + "spazImpact02", + "spazImpact03", + "spazImpact04" + ], + "death_sounds": [ + "spazDeath01" + ], + "pickup_sounds": [ + "spazPickup01" + ], + "fall_sounds": [ + "spazFall01" + ], + "icon_texture": "neoSpazIcon", + "icon_mask_texture": "neoSpazIconColorMask", + "style": "female" +} \ No newline at end of file diff --git a/dist/ba_root/mods/custom_characters/pixie.json b/dist/ba_root/mods/custom_characters/pixie.json new file mode 100644 index 0000000..52f9d22 --- /dev/null +++ b/dist/ba_root/mods/custom_characters/pixie.json @@ -0,0 +1,43 @@ +{ + "color_mask": "pixieColorMask", + "color_texture": "pixieColor", + "head": "pixieHead", + "hand": "pixieHand", + "torso": "pixieTorso", + "pelvis": "pixiePelvis", + "upper_arm": "wizardUpperArm", + "forearm": "wizardForeArm", + "upper_leg": "bunnyUpperLeg", + "lower_leg": "pixieLowerLeg", + "toes_model": "pixieToes", + "jump_sounds": [ + "spazJump01", + "spazJump02", + "spazJump03", + "spazJump04" + ], + "attack_sounds": [ + "spazAttack01", + "spazAttack02", + "spazAttack03", + "spazAttack04" + ], + "impact_sounds": [ + "spazImpact01", + "spazImpact02", + "spazImpact03", + "spazImpact04" + ], + "death_sounds": [ + "spazDeath01" + ], + "pickup_sounds": [ + "spazPickup01" + ], + "fall_sounds": [ + "spazFall01" + ], + "icon_texture": "neoSpazIcon", + "icon_mask_texture": "neoSpazIconColorMask", + "style": "pixie" +} \ No newline at end of file diff --git a/dist/ba_root/mods/custom_characters/wizardzoe.json b/dist/ba_root/mods/custom_characters/wizardzoe.json new file mode 100644 index 0000000..31c85ca --- /dev/null +++ b/dist/ba_root/mods/custom_characters/wizardzoe.json @@ -0,0 +1,43 @@ +{ + "color_mask": "zoeColorMask", + "color_texture": "zoeColor", + "head": "zoeHead", + "hand": "pixieHand", + "torso": "kronkTorso", + "pelvis": "bearPelvis", + "upper_arm": "cyborgUpperArm", + "forearm": "wizardForeArm", + "upper_leg": "agentUpperLeg", + "lower_leg": "wizardLowerLeg", + "toes_model": "melToes", + "jump_sounds": [ + "spazJump01", + "spazJump02", + "spazJump03", + "spazJump04" + ], + "attack_sounds": [ + "spazAttack01", + "spazAttack02", + "spazAttack03", + "spazAttack04" + ], + "impact_sounds": [ + "spazImpact01", + "spazImpact02", + "spazImpact03", + "spazImpact04" + ], + "death_sounds": [ + "spazDeath01" + ], + "pickup_sounds": [ + "spazPickup01" + ], + "fall_sounds": [ + "spazFall01" + ], + "icon_texture": "neoSpazIcon", + "icon_mask_texture": "neoSpazIconColorMask", + "style": "female" +} \ No newline at end of file diff --git a/dist/ba_root/mods/custom_hooks.py b/dist/ba_root/mods/custom_hooks.py index 4a960c0..e3d7219 100644 --- a/dist/ba_root/mods/custom_hooks.py +++ b/dist/ba_root/mods/custom_hooks.py @@ -84,8 +84,14 @@ def bootstraping(): from plugins import color_explosion color_explosion.enable() if settings["ballistica_web"]["enable"]: - import bcs_plugin + from plugins import bcs_plugin bcs_plugin.enable() + if settings["character_chooser"]["enable"]: + from plugins import CharacterChooser + CharacterChooser.enable() + if settings["custom_characters"]["enable"]: + from plugins import importcustomcharacters + importcustomcharacters.enable() # import features if settings["whitelist"]: diff --git a/dist/ba_root/mods/playersData/pdata.py b/dist/ba_root/mods/playersData/pdata.py index d25a716..9d08479 100644 --- a/dist/ba_root/mods/playersData/pdata.py +++ b/dist/ba_root/mods/playersData/pdata.py @@ -11,7 +11,7 @@ import os import _thread from serverData import serverdata -from file_handle import OpenJson +from tools.file_handle import OpenJson import _ba # pylint: disable=import-error diff --git a/dist/ba_root/mods/plugins/CharacterChooser.py b/dist/ba_root/mods/plugins/CharacterChooser.py index c24eae3..7d14fd5 100644 --- a/dist/ba_root/mods/plugins/CharacterChooser.py +++ b/dist/ba_root/mods/plugins/CharacterChooser.py @@ -346,15 +346,9 @@ def _update_text(self) -> None: self._text_node.text = text -# ba_meta export plugin -class HeySmoothy(ba.Plugin): - - def __init__(self): - _lobby.Chooser.__init__=__init__ - _lobby.Chooser._set_ready=_set_ready - - _lobby.Chooser._update_text=_update_text - _lobby.Chooser.handlemessage=handlemessage - - +def enable() -> None: + _lobby.Chooser.__init__=__init__ + _lobby.Chooser._set_ready=_set_ready + _lobby.Chooser._update_text=_update_text + _lobby.Chooser.handlemessage=handlemessage diff --git a/dist/ba_root/mods/bcs_plugin.py b/dist/ba_root/mods/plugins/bcs_plugin.py similarity index 100% rename from dist/ba_root/mods/bcs_plugin.py rename to dist/ba_root/mods/plugins/bcs_plugin.py diff --git a/dist/ba_root/mods/plugins/bombsquadhttpapi.py b/dist/ba_root/mods/plugins/bombsquadhttpapi.py deleted file mode 100644 index df36c0a..0000000 --- a/dist/ba_root/mods/plugins/bombsquadhttpapi.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -# coding: utf-8 - -# ba_meta require api 6 -import ba,_ba -import json - -# for flask app ================== -import os -import flask - -from flask import request , jsonify -import _thread - - - -stats=[{},[],{"cpu":0,"ram":0}] - -class livestats(object): - def __init__(self): - self.timer=ba.Timer(5,ba.Call(self.getinfo),timetype=ba.TimeType.REAL,repeat=True) - - def getinfo(self): - liveplayer={} - global stats - for i in _ba.get_game_roster(): - id=json.loads(i['spec_string'])["n"] - try: - liveplayer[id]={'name': i['players'][0]['name_full'], - 'clientid':i['client_id']} - except: - liveplayer[id]-{'name': "", 'clientid':i['client_id']} - stats[0] = liveplayer - stats[1] = _ba.get_chat_messages() - # stats[2]["cpu"]= p.cpu_percent() - # stats[2]["ram"]=p.virtual_memory().percent - - -livestats() - -#========= flask app ============ -os.environ['FLASK_APP']='bombsquadflaskapp.py' -os.environ['FLASK_ENV']= 'development' - -app = flask.Flask(_name_) -app.config["DEBUG"]=False - -@app.route("/",methods=['GET']) -def home(): - return "any message here" - -@app.route('/live',methods=['GET']) -def livestat(): - return jsonify(stats) - -# ba_meta export plugin -class HeySmoothy(ba.Plugin): - def __init__(self): - flask=_thread.start_new_thread(app.run,("0,0,0,0",80,False)) - - print("flask service") \ No newline at end of file diff --git a/dist/ba_root/mods/plugins/importcustomcharacters.py b/dist/ba_root/mods/plugins/importcustomcharacters.py index b47af3b..1d5eb99 100644 --- a/dist/ba_root/mods/plugins/importcustomcharacters.py +++ b/dist/ba_root/mods/plugins/importcustomcharacters.py @@ -1,60 +1,59 @@ -# ba_meta require api 6 +"""Module to update `setting.json`.""" +# ba_meta require api 6 +# (see https://ballistica.net/wiki/meta-tag-system) from __future__ import annotations from typing import TYPE_CHECKING +import os -import ba,_ba -from bastd.actor.playerspaz import PlayerSpaz -from bastd.actor.scoreboard import Scoreboard +import ba +import _ba + +from bastd.actor.spazappearance import Appearance +from tools.file_handle import OpenJson if TYPE_CHECKING: - from typing import Any, Type, List, Dict, Tuple, Union, Sequence, Optional - -import os,json -from bastd.actor.spazappearance import * + pass +def register_character(name: str, char: dict) -> None: + """Registers the character in the game.""" + t = Appearance(name.split(".")[0]) + t.color_texture = char['color_texture'] + t.color_mask_texture = char['color_mask'] + t.default_color = (0.6, 0.6, 0.6) + t.default_highlight = (0, 1, 0) + t.icon_texture = char['icon_texture'] + t.icon_mask_texture = char['icon_mask_texture'] + t.head_model = char['head'] + t.torso_model = char['torso'] + t.pelvis_model = char['pelvis'] + t.upper_arm_model = char['upper_arm'] + t.forearm_model = char['forearm'] + t.hand_model = char['hand'] + t.upper_leg_model = char['upper_leg'] + t.lower_leg_model = char['lower_leg'] + t.toes_model = char['toes_model'] + t.jump_sounds = char['jump_sounds'] + t.attack_sounds = char['attack_sounds'] + t.impact_sounds = char['impact_sounds'] + t.death_sounds = char['death_sounds'] + t.pickup_sounds = char['pickup_sounds'] + t.fall_sounds = char['fall_sounds'] + t.style = char['style'] +def enable() -> None: + path=os.path.join(_ba.env()["python_directory_user"],"custom_characters" + os.sep) -def registercharacter(name,char): - t = Appearance(name.split(".")[0]) - t.color_texture = char['color_texture'] - t.color_mask_texture = char['color_mask'] - t.default_color = (0.6, 0.6, 0.6) - t.default_highlight = (0, 1, 0) - t.icon_texture = char['icon_texture'] - t.icon_mask_texture = char['icon_mask_texture'] - t.head_model = char['head'] - t.torso_model = char['torso'] - t.pelvis_model = char['pelvis'] - t.upper_arm_model = char['upper_arm'] - t.forearm_model = char['forearm'] - t.hand_model = char['hand'] - t.upper_leg_model = char['upper_leg'] - t.lower_leg_model = char['lower_leg'] - t.toes_model = char['toes_model'] - t.jump_sounds = char['jump_sounds'] - t.attack_sounds = char['attack_sounds'] - t.impact_sounds = char['impact_sounds'] - t.death_sounds = char['death_sounds'] - t.pickup_sounds = char['pickup_sounds'] - t.fall_sounds = char['fall_sounds'] - t.style = char['style'] + if not os.path.isdir(path): + os.makedirs(path) + files=os.listdir(path) -# ba_meta export plugin -class HeySmoothy(ba.Plugin): - - def __init__(self): - - - path=os.path.join(_ba.env()["python_directory_user"],"CustomCharacters" + os.sep) - if not os.path.isdir(path): - os.makedirs(path) - files=os.listdir(path) - for file in files: - with open(path+file, 'r') as f: - character = json.load(f) - registercharacter(file,character) \ No newline at end of file + for file in files: + if file.endswith(".json"): + with OpenJson(path + file) as json_file: + character = json_file.load() + register_character(file,character) diff --git a/dist/ba_root/mods/setting.json b/dist/ba_root/mods/setting.json index affaf81..87f1b0b 100644 --- a/dist/ba_root/mods/setting.json +++ b/dist/ba_root/mods/setting.json @@ -49,6 +49,12 @@ "ballistica_web": { "enable":false }, + "character_chooser":{ + "enable":true + }, + "custom_characters": { + "enable":true + }, "elPatronPowerups":{ "enable":true, "settings":{"Powers Gravity": true, diff --git a/dist/ba_root/mods/file_handle.py b/dist/ba_root/mods/tools/file_handle.py similarity index 100% rename from dist/ba_root/mods/file_handle.py rename to dist/ba_root/mods/tools/file_handle.py