vh-bombsquad-modded-server-.../dist/ba_root/mods/features/text_on_map.py
2024-02-26 00:17:10 +05:30

252 lines
11 KiB
Python

# Released under the MIT License. See LICENSE for details.
""" TODO need to set coordinates of text node , move timer values to settings.json """
from ba._generated.enums import TimeType
import ba, _ba
import ba.internal
import setting
from stats import mystats
from datetime import datetime
import random
setti=setting.get_settings_data()
class textonmap:
def __init__(self):
data = setti['textonmap']
left = data['bottom left watermark']
top = data['top watermark']
nextMap=""
try:
nextMap=ba.internal.get_foreground_host_session().get_next_game_description().evaluate()
except:
pass
top = top.replace("@IP", _ba.our_ip).replace("@PORT", str(_ba.our_port))
self.index = 0
self.highlights = data['center highlights']["msg"]
self.left_watermark(left)
self.top_message(top)
self.nextGame(nextMap)
self.restart_msg()
if hasattr(_ba, "season_ends_in_days"):
# if _ba.season_ends_in_days < 9:
self.season_reset(_ba.season_ends_in_days)
if setti["leaderboard"]["enable"]:
self.leaderBoard()
self.timer = ba.timer(8.0, ba.Call(self.highlights_), repeat=True)
def highlights_(self):
if setti["textonmap"]['center highlights']["randomColor"]:
color=((0+random.random()*1.0),(0+random.random()*1.0),(0+random.random()*1.0))
else:
color=tuple(setti["textonmap"]["center highlights"]["color"])
node = _ba.newnode('text',
attrs={
'text': self.highlights[self.index],
'flatness': 1.0,
'h_align': 'center',
'v_attach':'bottom',
'scale':1,
'position':(0,138),
'color':(1,1,1)})
ba.animate_array(
node,
"color",
3,
{
0: (1,0,0),
0.2: (1,0.5,0),
0.4: (1,1,0),
0.6: (0,1,0),
0.8: (0,1,1),
1.0: (1,0,1),
1.2: (1,0,0),
},
loop=True,
)
self.delt = ba.timer(8.0,node.delete),
ba.animate(node,'scale', {0.0: 0, 0.2: 1, 7.8: 1, 8.0: 0})
self.index = int((self.index+1)%len(self.highlights))
def left_watermark(self, text):
node = _ba.newnode('text',
attrs={
'text': text,
'flatness': 1.0,
'h_align': 'left',
'v_attach':'bottom',
'h_attach':'left',
'scale':0.7,
'position':(25,95),
'color':(1,1,1)})
ba.animate_array(
node,
"color",
3,
{
0: (1,0,0),
0.2: (1,0.5,0),
0.4: (1,1,0),
0.6: (0,1,0),
0.8: (0,1,1),
1.0: (1,0,1),
1.2: (1,0,0),
},
loop=True,
)
node = _ba.newnode('text',
attrs={
'text':u'\ue043[\U0001F451] OWNER : VORTEX & HONOR \n\ue048[\U0001F6E0] MANAGED BY : TEAM VORTEX',
'flatness': 1.0,
'h_align': 'left',
'v_attach':'bottom',
'h_attach':'left',
'scale':0.7,
'position':(25,40),
'color':(1,1,1)
})
def nextGame(self,text):
node = _ba.newnode('text',
attrs={
'text':"Next : "+text ,
'flatness':0.4,
'h_align':'right',
'v_attach':'bottom',
'h_attach':'right',
'scale':0.7,
'position':(-25,5),
'color':(1,1,1)
})
def season_reset(self,text):
node = _ba.newnode('text',
attrs={
'text':" ",
'flatness':1.0,
'h_align':'right',
'v_attach':'bottom',
'h_attach':'right',
'scale':0.7,
'position':(-25,45),
'color':(1,0.5,0.7)
})
def restart_msg(self):
if hasattr(_ba,'restart_scheduled'):
_ba.get_foreground_host_activity().restart_msg = _ba.newnode('text',
attrs={
'text':"Server going to restart after this series.",
'flatness':1.0,
'h_align':'right',
'v_attach':'bottom',
'h_attach':'right',
'scale':0.3,
'position':(-25,40),
'color':(1,0.5,0.7)
})
def top_message(self, text):
node = _ba.newnode('text',
attrs={
'text': text,
'flatness': 1.0,
'h_align': 'center',
'v_attach':'top',
'scale':1.2,
'position':(0,-70),
'color':((0+random.random()*1.0),(0+random.random()*1.0),(0+random.random()*1.0))
})
node = _ba.newnode('text',
attrs={
'text':u'',
'flatness': 3.0,
'h_align': 'center',
'v_attach':'top',
'scale':2.0,
'position':(0,-67),
'color':(1,1,1)})
ba.animate_array(
node,
"color",
3,
{
0: (1,0,0),
1.2: (0,1,0),
2: (0,0,1),
3.1: (1,0,0),
},
loop=True,
)
ba.animate(node,'opacity', {0.0: 2.0, 2.0: 1.8, 4.0: 2.0, 6.0: 1.8, 8.0: 2.0, 10.0: 1.5, 12.0: 2.0, 14.0: 1.8, 16.0: 2.0, 18.0: 1.8, 20.0: 2.0, 22.0: 1.5, 24.0: 2.0, 26.0: 1.8, 28.0: 2.0, 30.0: 1.8, 32.0: 2.0, 34.0: 2.0, 36.0: 1.8, 38.0: 2.0, 40.0: 1.8, 42.0: 2.0, 44.0: 1.5, 46.0: 2.0, 48.0: 1.8, 50.0: 2.0, 52.0: 1.8, 54.0: 2.0, 56.0: 1.5, 58.0: 2.0, 60.0: 1.8, 62.0: 2.0, 64.0: 1.8, 66.0: 2.0})
node = _ba.newnode('text',
attrs={
'text':u'\ue048CONTACT OWNER FOR DETAILS & SUGGESTION\ue048\n\ue00cHAPPY BOMBSQUADING\ue00c',
'flatness': 3.0,
'h_align': 'center',
'v_attach':'top',
'scale':0.5,
'position':(0,-75),
'color':(1,1,1)
})
node = _ba.newnode('text',
attrs={
'text':u'\ue043Join Discord Server From Stats Button\ue043',
'flatness': 0.4,
'h_align': 'center',
'v_attach':'bottom',
'scale':0.7,
'position':(0,0),
'color':(1,1,1)})
ba.animate_array(
node,
"color",
3,
{
0: (1,0,0),
3: (0,1,0),
6: (0,0,1),
9: (1,0,0),
},
loop=True,
)
node = _ba.newnode('text',
attrs={
'text':u'\ue062| SCRIPT BY VORTEX |\ue062',
'flatness':1.0,
'h_align':'center',
'v_attach':'top',
'h_attach':'center',
'scale':0.75,
'position':(400,-35),
'color':(1,1,1)})
ba.animate_array(
node,
"color",
3,
{
0: (1,0,0),
0.2: (1,0.5,0),
0.4: (1,1,0),
0.6: (0,1,0),
0.8: (0,1,1),
1.0: (1,0,1),
1.2: (1,0,0),
},
loop=True,
)
def leaderBoard(self):
if len(mystats.top5Name) >2:
if setti["leaderboard"]["barsBehindName"]:
self.ss1=ba.newnode('image',attrs={'scale':(300,30),'texture':ba.gettexture('bar'),'position':(0,-80),'attach':'topRight','opacity':0.5,'color':(0.7,0.1,0)})
self.ss1=ba.newnode('image',attrs={'scale':(300,30),'texture':ba.gettexture('bar'),'position':(0,-115),'attach':'topRight','opacity':0.5,'color':(0.6,0.6,0.6)})
self.ss1=ba.newnode('image',attrs={'scale':(300,30),'texture':ba.gettexture('bar'),'position':(0,-150),'attach':'topRight','opacity':0.5,'color':(0.1,0.3,0.1)})
self.ss1a=ba.newnode('text',attrs={'text':"#\U0001F947 "+mystats.top5Name[0][:10]+"...",'flatness':1.0,'h_align':'left','h_attach':'right','v_attach':'top','v_align':'center','position':(-140,-80),'scale':0.7,'color':(0.7,0.4,0.3)})
self.ss1a=ba.newnode('text',attrs={'text':"#\U0001F948 "+mystats.top5Name[1][:10]+"...",'flatness':1.0,'h_align':'left','h_attach':'right','v_attach':'top','v_align':'center','position':(-140,-115),'scale':0.7,'color':(0.8,0.8,0.8)})
self.ss1a=ba.newnode('text',attrs={'text':"#\U0001F949 "+mystats.top5Name[2][:10]+"...",'flatness':1.0,'h_align':'left','h_attach':'right','v_attach':'top','v_align':'center','position':(-140,-150),'scale':0.7,'color':(0.2,0.6,0.2)})