Merge pull request #32 from pranav-1711/public-server

Custom Characters Integration.
This commit is contained in:
Ayush Saini 2022-03-20 21:05:00 +05:30 committed by GitHub
commit 5bbd62f74c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 194 additions and 130 deletions

View file

@ -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,

View file

@ -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"
}

View file

@ -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"
}

View file

@ -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"
}

View file

@ -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"]:

View file

@ -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

View file

@ -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

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 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)
for file in files:
if file.endswith(".json"):
with OpenJson(path + file) as json_file:
character = json_file.load()
register_character(file,character)

View file

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