Custom characters intigration and plugin switches.

Custom characters plugin.
true/false switch in settings for
character chooser and custom characters. (defaulty true)
Fixed path of bcs_plugin.
Removed duplicate of bcs plugin.
This commit is contained in:
pranav-1711 2022-03-20 19:41:59 +05:30
parent 837af6666b
commit 6ad7972a4b
7 changed files with 63 additions and 128 deletions

View file

@ -433,16 +433,7 @@
}, },
"Plugins": { "Plugins": {
"plugins.Init": { "plugins.Init": {
"enabled": true "enabled": true
},
"plugins.CharacterChooser.HeySmoothy": {
"enabled": true
},
"plugins.bombsquadhttpapi.HeySmoothy": {
"enabled": false
},
"plugins.importcustomcharacters.HeySmoothy": {
"enabled": false
} }
}, },
"Port": 43210, "Port": 43210,

View file

@ -86,6 +86,12 @@ def bootstraping():
if settings["ballistica_web"]["enable"]: if settings["ballistica_web"]["enable"]:
from plugins import bcs_plugin from plugins import bcs_plugin
bcs_plugin.enable() 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 # import features
if settings["whitelist"]: if settings["whitelist"]:

View file

@ -346,15 +346,9 @@ def _update_text(self) -> None:
self._text_node.text = text self._text_node.text = text
# ba_meta export plugin def enable() -> None:
class HeySmoothy(ba.Plugin): _lobby.Chooser.__init__=__init__
_lobby.Chooser._set_ready=_set_ready
def __init__(self):
_lobby.Chooser.__init__=__init__
_lobby.Chooser._set_ready=_set_ready
_lobby.Chooser._update_text=_update_text
_lobby.Chooser.handlemessage=handlemessage
_lobby.Chooser._update_text=_update_text
_lobby.Chooser.handlemessage=handlemessage

View file

@ -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': "<in-lobby>", '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")

View file

@ -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 __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import os
import ba,_ba import ba
from bastd.actor.playerspaz import PlayerSpaz import _ba
from bastd.actor.scoreboard import Scoreboard
from bastd.actor.spazappearance import Appearance
from tools.file_handle import OpenJson
if TYPE_CHECKING: if TYPE_CHECKING:
from typing import Any, Type, List, Dict, Tuple, Union, Sequence, Optional pass
import os,json
from bastd.actor.spazappearance import *
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): if not os.path.isdir(path):
t = Appearance(name.split(".")[0]) os.makedirs(path)
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']
files=os.listdir(path)
# ba_meta export plugin for file in files:
class HeySmoothy(ba.Plugin): if file.endswith(".json"):
with OpenJson(path + file) as json_file:
def __init__(self): character = json_file.load()
register_character(file,character)
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)

View file

@ -49,6 +49,12 @@
"ballistica_web": { "ballistica_web": {
"enable":false "enable":false
}, },
"character_chooser":{
"enable":true
},
"custom_characters": {
"enable":true
},
"elPatronPowerups":{ "elPatronPowerups":{
"enable":true, "enable":true,
"settings":{"Powers Gravity": true, "settings":{"Powers Gravity": true,