bug fix , v2 account , node.changerotation, _ba.enable_2d_mode

This commit is contained in:
Ayush Saini 2022-10-02 17:13:03 +05:30
parent b110f8a12a
commit 66df21cd2e
12 changed files with 366 additions and 92 deletions

View file

@ -305,7 +305,7 @@ class DirectoryScan:
# If we find a module requiring a different api version, warn
# and ignore.
if required_api is not None and required_api <= CURRENT_API_VERSION:
if required_api is not None and required_api < CURRENT_API_VERSION:
self.results.warnings += (
f'Warning: {subpath} requires api {required_api} but'
f' we are running {CURRENT_API_VERSION}; ignoring module.')

View file

@ -105,7 +105,7 @@ def QuickAccess(msg, client_id):
name = i.getname(True)
for i in ba.internal.get_foreground_host_session().sessionplayers:
if i.sessionteam and teamid == i.sessionteam.id and i.inputdevice.client_id != client_id:
if hasattr(i, 'sessionteam') and i.sessionteam and teamid == i.sessionteam.id and i.inputdevice.client_id != client_id:
_ba.screenmessage(name + ":" + msg[1:], clients=[i.inputdevice.client_id],
color=(0.3, 0.6, 0.3), transient=True)
@ -118,7 +118,7 @@ def QuickAccess(msg, client_id):
return None
msgAr.insert(int(len(msgAr) / 2), "\n")
for player in _ba.get_foreground_host_activity().players:
if player.sessionplayer.inputdevice.client_id == client_id:
if player.sessionplayer.inputdevice.client_id == client_id and player.actor.exists() and hasattr(player.actor.node,"position"):
pos = player.actor.node.position
with _ba.Context(_ba.get_foreground_host_activity()):
popuptext.PopupText(" ".join(msgAr), (pos[0], pos[1] + 1, pos[2])).autoretain()

View file

@ -10,42 +10,42 @@ CommandAliases = ['inv', 'hl', 'creep', 'celeb', 'flo']
def ExcelCommand(command, arguments, clientid, accountid):
"""
Checks The Command And Run Function
Checks The Command And Run Function
Parameters:
command : str
arguments : str
clientid : int
accountid : int
command : str
arguments : str
clientid : int
accountid : int
Returns:
None
None
"""
if command=='speed':
speed(arguments)
elif command == 'fly':
fly(arguments)
elif command in ['inv', 'invisible']:
invi(arguments)
elif command in ['hl', 'headless']:
headless(arguments)
elif command in ['creepy', 'creep']:
creep(arguments)
elif command in ['celebrate', 'celeb']:
celeb(arguments)
elif command == 'spaz':
spaz(arguments)
elif command in ['floater','flo']:
floater(arguments,clientid)
def floater(arguments,clientid):
try:
@ -62,35 +62,35 @@ def speed(arguments):
return
else:
corelib.set_speed(float(arguments[0]))
def fly(arguments):
if arguments == [] or arguments == ['']:
return
elif arguments[0] == 'all':
activity = _ba.get_foreground_host_activity()
for players in activity.players:
if players.actor.node.fly != True:
players.actor.node.fly = True
players.actor.node.fly = True
else:
players.actor.node.fly = False
players.actor.node.fly = False
else:
try:
activity = _ba.get_foreground_host_activity()
player = int(arguments[0])
if activity.players[player].actor.node.fly != True:
activity.players[player].actor.node.fly = True
activity.players[player].actor.node.fly = True
else:
activity.players[player].actor.node.fly = False
activity.players[player].actor.node.fly = False
except:
return
@ -98,17 +98,17 @@ def fly(arguments):
def invi(arguments):
if arguments == [] or arguments == ['']:
return
elif arguments[0] == 'all':
activity = _ba.get_foreground_host_activity()
for i in activity.players:
body = i.actor.node
if body.torso_model != None:
if i.actor.exists() and i.actor.node.torso_model != None:
body = i.actor.node
body.head_model = None
body.torso_model = None
body.upper_arm_model = None
@ -120,12 +120,12 @@ def invi(arguments):
body.lower_leg_model = None
body.style = 'cyborg'
else:
player = int(arguments[0])
activity = _ba.get_foreground_host_activity()
body = activity.players[player].actor.node
if body.torso_model != None:
body.head_model = None
body.torso_model = None
@ -142,28 +142,28 @@ def invi(arguments):
def headless(arguments):
if arguments == [] or arguments == ['']:
return
elif arguments[0] == 'all':
activity = _ba.get_foreground_host_activity()
for players in activity.players:
node = players.actor.node
node = players.actor.node
if node.head_model != None:
node.head_model = None
node.style='cyborg'
else:
try:
player = int(arguments[0])
activity = _ba.get_foreground_host_activity()
node = activity.players[player].actor.node
if node.head_model != None:
node.head_model = None
node.style='cyborg'
@ -173,29 +173,29 @@ def headless(arguments):
def creep(arguments):
if arguments == [] or arguments == ['']:
return
elif arguments[0] == 'all':
activity = _ba.get_foreground_host_activity()
for players in activity.players:
node = players.actor.node
node = players.actor.node
if node.head_model != None:
node.head_model = None
node.head_model = None
node.handlemessage(ba.PowerupMessage(poweruptype='punch'))
node.handlemessage(ba.PowerupMessage(poweruptype='shield'))
else:
try:
player = int(arguments[0])
activity = _ba.get_foreground_host_activity()
node = activity.players[player].actor.node
if node.head_model != None:
node.head_model = None
node.handlemessage(ba.PowerupMessage(poweruptype='punch'))
@ -206,27 +206,27 @@ def creep(arguments):
def celeb(arguments):
if arguments == [] or arguments == ['']:
return
elif arguments[0] == 'all':
handlemsg_all(ba.CelebrateMessage())
else:
try:
player = int(arguments[0])
handlemsg(player, ba.CelebrateMessage())
except:
return
def spaz(arguments):
if arguments == [] or arguments == ['']:
return
return

View file

@ -6,7 +6,7 @@ import ba.internal
def send(msg, clientid):
"""Shortcut To Send Private Msg To Client"""
ba.internal.chatmessage(str(msg), clients=[clientid])
_ba.screenmessage(str(msg), transient=True, clients=[clientid])
@ -16,12 +16,10 @@ def send(msg, clientid):
def clientid_to_myself(clientid):
"""Return Player Index Of Self Player"""
session = ba.internal.get_foreground_host_session()
for i in range(len(session.sessionplayers)):
if session.sessionplayers[i].inputdevice.client_id == clientid:
return int(session.sessionplayers[i].id)
for i in _ba.get_foreground_host_activity().players:
if i.sessionplayer.inputdevice.client_id == clientid:
return i
@ -29,7 +27,7 @@ def clientid_to_myself(clientid):
def handlemsg(client, msg):
"""Handles Spaz Msg For Single Player"""
activity = _ba.get_foreground_host_activity()
activity.players[client].actor.node.handlemessage(msg)
@ -39,9 +37,9 @@ def handlemsg(client, msg):
def handlemsg_all(msg):
"""Handle Spaz message for all players in activity"""
activity = _ba.get_foreground_host_activity()
for i in activity.players:
i.actor.node.handlemessage(msg)

View file

@ -18,7 +18,7 @@ import time
import os
import ba
import _ba
import logging
from ba import _hooks
from bastd.activity import dualteamscore, multiteamscore, drawscore
from bastd.activity.coopscore import CoopScoreScreen
@ -72,7 +72,7 @@ def playerspaz_init(playerspaz: ba.Player, node: ba.Node, player: ba.Player):
def bootstraping():
"""Bootstarps the server."""
print("Bootstraping mods..")
logging.warning("Bootstraping mods...")
# server related
_ba.set_server_device_name(settings["HostDeviceName"])
_ba.set_server_name(settings["HostName"])
@ -83,7 +83,17 @@ def bootstraping():
_thread.start_new_thread(mystats.refreshStats, ())
pdata.load_cache()
_thread.start_new_thread(pdata.dump_cache, ())
if(settings["useV2Account"]):
from tools import account
if(ba.internal.get_v1_account_state()=='signed_in' and ba.internal.get_v1_account_type()=='V2'):
logging.debug("Account V2 is active")
else:
ba.internal.sign_out_v1()
logging.warning("Account V2 login started ...wait")
account.AccountUtil()
else:
ba.app.accounts_v2.set_primary_credentials(None)
ba.internal.sign_in_v1('Local')
# import plugins
if settings["elPatronPowerups"]["enable"]:
from plugins import elPatronPowerups

Binary file not shown.

Binary file not shown.

View file

@ -5,13 +5,41 @@ from typing import TYPE_CHECKING
import ba,_ba
from bastd.gameutils import SharedObjects
from bastd.actor.playerspaz import PlayerSpaz
import copy
if TYPE_CHECKING:
from typing import Any, List, Dict
class mapdefs:
points = {}
# noinspection PyDictCreation
boxes = {}
boxes['area_of_interest_bounds'] = (0.0, 1.185751251, 0.4326226188) + (
0.0, 0.0, 0.0) + (29.8180273, 11.57249038, 18.89134176)
boxes['edge_box'] = (-0.103873591, 0.4133341891, 0.4294651013) + (
0.0, 0.0, 0.0) + (22.48295719, 1.290242794, 8.990252454)
points['ffa_spawn1'] = (-0.08015551329, 0.02275111462,
-4.373674593) + (8.895057015, 1.0, 0.444350722)
points['ffa_spawn2'] = (-0.08015551329, 0.02275111462,
4.076288941) + (8.895057015, 1.0, 0.444350722)
points['flag1'] = (-10.99027878, 0.05744967453, 0.1095578275)
points['flag2'] = (11.01486398, 0.03986567039, 0.1095578275)
points['flag_default'] = (-0.1001374046, 0.04180340146, 0.1095578275)
boxes['goal1'] = (12.22454533, 1.0,
0.1087926362) + (0.0, 0.0, 0.0) + (2.0, 2.0, 12.97466313)
boxes['goal2'] = (-12.15961605, 1.0,
0.1097860203) + (0.0, 0.0, 0.0) + (2.0, 2.0, 13.11856424)
boxes['map_bounds'] = (0.0, 1.185751251, 0.4326226188) + (0.0, 0.0, 0.0) + (
42.09506485, 22.81173179, 29.76723155)
points['powerup_spawn1'] = (5.414681236, 0.9515026107, -5.037912441)
points['powerup_spawn2'] = (-5.555402285, 0.9515026107, -5.037912441)
points['powerup_spawn3'] = (5.414681236, 0.9515026107, 5.148223181)
points['powerup_spawn4'] = (-5.737266365, 0.9515026107, 5.148223181)
points['spawn1'] = (-10.03866341, 0.02275111462, 0.0) + (0.5, 1.0, 4.0)
points['spawn2'] = (9.823107149, 0.01092306765, 0.0) + (0.5, 1.0, 4.0)
points['tnt1'] = (-0.08421587483, 0.9515026107, -0.7762602271)
class WoodenFloor(ba.Map):
"""Stadium map for football games."""
from bastd.mapdata import football_stadium as defs
defs = mapdefs
defs.points['spawn1'] = (-12.03866341, 0.02275111462, 0.0) + (0.5, 1.0, 4.0)
defs.points['spawn2'] = (12.823107149, 0.01092306765, 0.0) + (0.5, 1.0, 4.0)
name = 'Wooden Floor'
@ -28,7 +56,7 @@ class WoodenFloor(ba.Map):
@classmethod
def on_preload(cls) -> Any:
data: dict[str, Any] = {
'model_bg': ba.getmodel('doomShroomBG'),
'bg_vr_fill_model': ba.getmodel('natureBackgroundVRFill'),
'collide_model': ba.getcollidemodel('bridgitLevelCollide'),
@ -79,20 +107,166 @@ class WoodenFloor(ba.Map):
xpos = (point.x - box_position[0]) / box_scale[0]
zpos = (point.z - box_position[2]) / box_scale[2]
return xpos < -0.5 or xpos > 0.5 or zpos < -0.5 or zpos > 0.5
def map_extend(self):
pass
# p=[-6,-4.3,-2.6,-0.9,0.8,2.5,4.2,5.9]
# q=[-4,-2.3,-0.6,1.1,2.8,4.5,6.2]
# for i in p:
# for j in q:
# self.create_ramp(i,j)
# self.create_ramp(10.9)
# self.ground()
def ground(self):
shared = SharedObjects.get()
self._real_wall_material=ba.Material()
self._real_wall_material.add_actions(
actions=(
('modify_part_collision', 'collide', True),
('modify_part_collision', 'physical', True)
))
self.mat = ba.Material()
self.mat.add_actions(
actions=( ('modify_part_collision','physical',False),
('modify_part_collision','collide',False))
)
spaz_collide_mat=ba.Material()
spaz_collide_mat.add_actions(
conditions=('they_have_material',shared.player_material),
actions=(
('modify_part_collision', 'collide', True),
( 'call','at_connect',ba.Call(self._handle_player_collide )),
),
)
pos=(0,0.1,-5)
self.main_region=ba.newnode('region',attrs={'position': pos,'scale': (21,0.001,20),'type': 'box','materials': [shared.footing_material,self._real_wall_material,spaz_collide_mat]})
def create_ramp_111(self,x,z):
# print("creating pad ar x "+str(x)+" and z"+str(z))
try:
_ba.prop_axis(1,0,0)
except:
pass
shared = SharedObjects.get()
self._real_wall_material=ba.Material()
self._real_wall_material.add_actions(
actions=(
('modify_part_collision', 'collide', True),
('modify_part_collision', 'physical', True)
))
self.mat = ba.Material()
self.mat.add_actions(
actions=( ('modify_part_collision','physical',False),
('modify_part_collision','collide',False))
)
spaz_collide_mat=ba.Material()
# spaz_collide_mat.add_actions(
# conditions=('they_have_material',shared.player_material),
# actions=(
# ('modify_part_collision', 'collide', True),
# ( 'call','at_connect',ba.Call(self._handle_player_pad_collide,real )),
# ),
# )
pos=(x,0,z)
ud_1_r=ba.newnode('region',attrs={'position': pos,'scale': (1.5,1,1.5),'type': 'box','materials': [shared.footing_material,self._real_wall_material ]})
node = ba.newnode('prop',
owner=ud_1_r,
attrs={
'model':ba.getmodel('image1x1'),
'light_model':ba.getmodel('powerupSimple'),
'position':(2,7,2),
'body':'puck',
'shadow_size':0.0,
'velocity':(0,0,0),
'color_texture':ba.gettexture('tnt'),
'model_scale':1.5,
'reflection_scale':[1.5],
'materials':[self.mat, shared.object_material,shared.footing_material],
'density':9000000000
})
mnode = ba.newnode('math',
owner=ud_1_r,
attrs={
'input1': (0, 0.6, 0),
'operation': 'add'
})
ud_1_r.connectattr('position', mnode, 'input2')
mnode.connectattr('output', node, 'position')
# base / bottom ====================================
# pos=(0.0, 2.004164695739746, -3.3991328477859497)
# self.ud_2_r=ba.newnode('region',attrs={'position': pos,'scale': (2,1,2),'type': 'box','materials': [shared.footing_material,self._real_wall_material,spaz_collide_mat ]})
# self.node2 = ba.newnode('prop',
# owner=self.ud_2_r,
# attrs={
# 'model':ba.getmodel('bridgitLevelBottom'),
# 'light_model':ba.getmodel('powerupSimple'),
# 'position':(2,7,2),
# 'body':'puck',
# 'shadow_size':0.0,
# 'velocity':(0,0,0),
# 'color_texture':ba.gettexture('bridgitLevelColor'),
# 'reflection_scale':[1.5],
# 'materials':[self.mat, shared.object_material,shared.footing_material],
# 'density':9000000000
# })
# mnode = ba.newnode('math',
# owner=self.ud_2_r,
# attrs={
# 'input1': (0, -1.8, 0),
# 'operation': 'add'
# })
# self.ud_2_r.connectattr('position', mnode, 'input2')
# mnode.connectattr('output', self.node2, 'position')
# /// region to stand long bar ===============
# pos=(-9.67+loc,0.1,0+z_marg)
# self.left_region=ba.newnode('region',attrs={'position': pos,'scale': (2.4,0.7,3.2),'type': 'box','materials': [shared.footing_material,self._real_wall_material,spaz_collide_mat ]})
# pos=(-5.67+loc,0.1,0+z_marg)
# self.center_region=ba.newnode('region',attrs={'position': pos,'scale': (8,0.7,1),'type': 'box','materials': [shared.footing_material,self._real_wall_material,spaz_collide_mat ]})
# pos=(-1.3+loc,0.1,0+z_marg)
# self.right_region=ba.newnode('region',attrs={'position': pos,'scale': (2.4,0.7,3.2),'type': 'box','materials': [shared.footing_material,self._real_wall_material,spaz_collide_mat ]})
def _handle_player_collide(self):
try:
player = ba.getcollision().opposingnode.getdelegate(
PlayerSpaz, True)
except ba.NotFoundError:
return
if player.is_alive():
player.shatter(True)
ba._map.register_map(WoodenFloor)
ba._map.register_map(WoodenFloor)

View file

@ -1,12 +1,12 @@
{
"whitelist": false,
"useV2Account": false,
"ChatCommands": {
"BrodcastCommand": true
},
"textonmap": {
"top watermark": "Welcome to server \nip 192.168.0.1",
"bottom left watermark": "Owner : <owner-name> \nEditor : <bablu>\nScripts : BCS1.7",
"bottom left watermark": "Owner : <owner-name> \nEditor : <bablu>\nScripts : BCS1.7.10",
"center highlights":{
"color":[1,0,0],
"randomColor":true,

View file

@ -248,7 +248,8 @@ class Effect(ba.Actor):
ba.animate_array(self.scorchNode,"color",3,{0:self.scorchNode.color,500:color}, timetype=tt, timeformat=tf)
else:
self.scorchTimer = None
self.scorchNode.delete()
if hasattr(self,"scorchNode"):
self.scorchNode.delete()
self.handlemessage(ba.DieMessage())
def neonLightSwitch(self,shine,Highlight,NameColor):

91
dist/ba_root/mods/tools/account.py vendored Normal file
View file

@ -0,0 +1,91 @@
# ba_meta require api 6
from __future__ import annotations
import ba
import bacommon.cloud
import logging
from efro.error import CommunicationError
STATUS_CHECK_INTERVAL_SECONDS = 2.0
class AccountUtil:
def __init__(self):
self._proxyid: str | None = None
self._proxykey: str | None = None
if(ba.internal.get_v1_account_state() == 'signed_out'):
ba.app.cloud.send_message_cb(bacommon.cloud.LoginProxyRequestMessage(),
on_response=ba.Call(self._on_proxy_request_response))
else:
logging.error("Signout old account first")
def _on_proxy_request_response(self, response: bacommon.cloud.LoginProxyRequestResponse | Exception) -> None:
if isinstance(response, Exception):
logging.error("error occured")
logging.critical("Falling back to V1 account")
ba.internal.sign_in_v1('Local')
return
address = ba.internal.get_master_server_address(
version=2) + response.url
logging.debug("copy this url to your browser : " +address)
self._proxyid = response.proxyid
self._proxykey = response.proxykey
ba.timer(STATUS_CHECK_INTERVAL_SECONDS,
ba.Call(self._ask_for_status))
def _ask_for_status(self) -> None:
assert self._proxyid is not None
assert self._proxykey is not None
ba.app.cloud.send_message_cb(
bacommon.cloud.LoginProxyStateQueryMessage(
proxyid=self._proxyid, proxykey=self._proxykey),
on_response=ba.Call(self._got_status))
def _got_status(
self, response: bacommon.cloud.LoginProxyStateQueryResponse | Exception
) -> None:
# For now, if anything goes wrong on the server-side, just abort
# with a vague error message. Can be more verbose later if need be.
if (isinstance(response, bacommon.cloud.LoginProxyStateQueryResponse)
and response.state is response.State.FAIL):
logging.error("error occured ..terminating login request")
logging.critical("Falling back to V1 account")
ba.internal.sign_in_v1('Local')
# If we got a token, set ourself as signed in. Hooray!
if (isinstance(response, bacommon.cloud.LoginProxyStateQueryResponse)
and response.state is response.State.SUCCESS):
assert response.credentials is not None
ba.app.accounts_v2.set_primary_credentials(response.credentials)
logging.info("Logged in as: "+ba.internal.get_v1_account_display_string())
# As a courtesy, tell the server we're done with this proxy
# so it can clean up (not a huge deal if this fails)
assert self._proxyid is not None
try:
ba.app.cloud.send_message_cb(
bacommon.cloud.LoginProxyCompleteMessage(
proxyid=self._proxyid),
on_response=ba.Call(self._proxy_complete_response))
except CommunicationError:
pass
except Exception:
logging.warning(
'Unexpected error sending login-proxy-complete message',
exc_info=True)
return
# If we're still waiting, ask again soon.
if (isinstance(response, Exception)
or response.state is response.State.WAITING):
ba.timer(STATUS_CHECK_INTERVAL_SECONDS,
ba.Call(self._ask_for_status))
# ba_meta export plugin
# class AccountV2(ba.Plugin):
# def __init__(self):
# if(ba.internal.get_v1_account_state()=='signed_in' and ba.internal.get_v1_account_type()=='V2'):
# logging.debug("Account V2 is active")
# else:
# ba.internal.sign_out_v1()
# logging.warning("Account V2 login started ...wait")
# AccountUtil()

Binary file not shown.