2022-07-15 14:55:58 +05:30
#Made by your friend: Freaku / @[Just] Freak#4999
2022-02-06 11:45:13 +05:30
2022-03-16 08:57:34 +05:30
# Defines a simple plugin that allows you to:
2022-09-27 16:40:27 +05:30
### See any errors of your mods (if present) in folder BombSquad/console/logs.txt
### Get config contents
### Create/Delete sys
### Get 3D co-ordinate points in any Map!
2022-02-06 11:45:13 +05:30
2022-03-16 08:57:34 +05:30
2022-07-15 14:55:58 +05:30
# NOTE: Please perform the activities to log, if its a gamemode pls open and play it and then see logs. If its a window please touch buttons and then see logs
# and so on according to the mod you're working...
2022-03-16 08:57:34 +05:30
2022-07-15 14:55:58 +05:30
#Join BCS:
2022-03-16 08:57:34 +05:30
# https://discord.gg/ucyaesh
2022-07-15 14:55:58 +05:30
#My GitHub:
# https://github.com/Freaku17/BombSquad-Mods-byFreaku
2022-03-16 08:57:34 +05:30
2022-02-06 11:45:13 +05:30
########## INDEX ##########
'''
- Must READ
- For beginners
2022-03-16 08:57:34 +05:30
'''
2022-02-06 11:45:13 +05:30
# ----- MUST READ -----
'''
2022-03-16 08:57:34 +05:30
# I hope you know Python Programming Language and have seen Bombsquad's API, avaiable at
2022-02-06 11:45:13 +05:30
# https://ballistica.net/wiki
# else... its still fine :)
2022-03-16 08:57:34 +05:30
# Python is easiest language, hardly will take 1 week to learn (See YouTube tutorials)
2022-02-06 11:45:13 +05:30
# This mod is *genuinely* for Mobile Modders,
# in PC you can directly get these Terminal Errors in console.
# but sadly on mobile there's no way to view console.
2022-09-27 16:40:27 +05:30
# We can alternatively, use https://tools.ballistica.net/devices
# but it only works on V2 accounts (and if you link your GooglePlay and V2, and login with GooglePlay... it won't work)
2022-02-06 11:45:13 +05:30
# This is helpful for new Modders (who don't use PC)
# Also I'll ***HIGHLY*** suggest to not use this when other mods are installed
# As a TONS of other mods includes errors (which aren't fixed)
# Happy coding! 🔥
'''
# ----- For beginners -----
'''
2022-03-16 08:57:34 +05:30
# Use create_sys / delete_sys in Plugins
# and a Code Editor app (on Play Store)
2022-02-06 11:45:13 +05:30
2022-09-27 16:40:27 +05:30
# Then start playing (editing) those internal .py files
# Incase you face a black screen on launch (you made an error while editing those sys files)
# Delete the sys folder of folder Bombsquad/sys/{version} and re-open game
2022-03-16 08:57:34 +05:30
'''
2022-02-06 11:45:13 +05:30
2022-09-27 16:40:27 +05:30
# Sometimes you need someone for help
2022-07-15 14:55:58 +05:30
# I would suggest to join BCS: A lovely discord server (link at top)
2022-02-06 11:45:13 +05:30
2022-07-15 14:55:58 +05:30
# Aimed 4 Android modders!
2022-02-06 11:45:13 +05:30
2022-07-15 14:55:58 +05:30
# ba_meta require api 7
2022-03-16 08:57:34 +05:30
import _ba , ba , os
2022-09-27 16:40:27 +05:30
from efro . log import LogLevel
folder = _ba . env ( ) [ ' python_directory_user ' ] + " /console/ "
log_post = folder + ' logs.txt '
config_post = folder + ' config.txt '
2022-02-06 11:45:13 +05:30
def make_folder ( ) :
if not os . path . exists ( folder ) :
os . makedirs ( folder )
2022-09-27 16:40:27 +05:30
def make_config ( entry ) :
with open ( config_post , ' w+ ' ) as e :
e . write ( entry )
2022-03-16 08:57:34 +05:30
e . close ( )
2022-09-27 16:40:27 +05:30
def dump_cache_logs ( ) :
# Dumps all cache logs (including DEBUG ones)
for entry in ba . app . log_handler . get_cached ( ) . entries :
write_logs ( entry . message )
def make_logs ( entry ) :
if entry . level . value > = LogLevel . WARNING . value or entry . name in ( ' stdout ' , ' stderr ' ) :
write_logs ( entry . message )
def write_logs ( log ) :
print ( log , file = open ( log_post , ' a+ ' , encoding = ' utf-8 ' ) )
2022-03-16 08:57:34 +05:30
def make_sys ( ) :
path = _ba . app . python_directory_user + ' /sys/ ' + _ba . app . version
if not os . path . exists ( path ) :
2023-01-14 16:01:25 +05:30
import ba . modutils as utils
utils . create_user_system_scripts ( )
2022-07-15 14:55:58 +05:30
if _ba . app . platform == ' android ' :
if path . find ( ' /0/ ' ) :
path = path . split ( ' /0/ ' ) [ 1 ]
ba . screenmessage ( f ' Scripts created at { path } ' , color = ( 0 , 1 , 0 ) )
ba . screenmessage ( ' Restart BombSquad to use them ' , color = ( 0 , 1 , 0 ) )
2022-03-16 08:57:34 +05:30
ba . app . config [ ' Plugins ' ] [ __name__ + ' .create_sys ' ] [ ' enabled ' ] = False
ba . app . config . apply_and_commit ( )
2022-07-15 14:55:58 +05:30
else :
ba . screenmessage ( ' Cannot run ' + __name__ + ' .create_sys \n Scripts already exist :/ ' , color = ( 1 , 0 , 0 ) )
2022-03-16 08:57:34 +05:30
def yeet_sys ( ) :
path = _ba . app . python_directory_user + ' /sys/ ' + _ba . app . version
if os . path . exists ( path ) :
2023-01-14 16:01:25 +05:30
import ba . modutils as utils
utils . delete_user_system_scripts ( )
2022-07-15 14:55:58 +05:30
ba . screenmessage ( ' Scripts deleted! ' , color = ( 1 , 1 , 0 ) )
ba . screenmessage ( ' Restart BombSquad to use internal ' , color = ( 1 , 1 , 0 ) )
2022-03-16 08:57:34 +05:30
ba . app . config [ ' Plugins ' ] [ __name__ + ' .delete_sys ' ] [ ' enabled ' ] = False
ba . app . config . apply_and_commit ( )
2022-07-15 14:55:58 +05:30
else :
ba . screenmessage ( ' Cannot run ' + __name__ + ' .delete_sys \n No Scripts exist :/ ' , color = ( 1 , 0 , 0 ) )
def update_mods ( ) :
mods_folder = _ba . env ( ) [ ' python_directory_user ' ]
for mod in os . listdir ( mods_folder ) :
2022-07-15 15:10:28 +05:30
if mod . endswith ( ' .py ' ) and not mod == __name__ + ' .py ' :
2022-07-15 14:55:58 +05:30
data = open ( mods_folder + os . sep + mod ) . read ( )
2022-07-30 20:25:42 +05:30
data = data . replace ( ' # ' + ' ba_meta require api 6 ' , ' # ' + ' ba_meta require api 7 ' )
2022-07-15 15:02:12 +05:30
data = data . replace ( ' def on_app_launch(self) ' , ' def on_app_running(self) ' )
data = data . replace ( ' self.on_app_launch ' , ' self.on_app_running ' )
2022-07-15 14:55:58 +05:30
with open ( mods_folder + os . sep + mod , ' w ' ) as file :
file . write ( data )
file . close ( )
ba . screenmessage ( ' Updated mods to 1.7! ' , color = ( 0 , 1 , 0 ) )
ba . screenmessage ( ' All Mods are NOT guaranteed to work ' , color = ( 1 , 1 , 0 ) )
ba . app . config [ ' Plugins ' ] [ __name__ + ' .update_16mods_to_17 ' ] [ ' enabled ' ] = False
ba . app . config . apply_and_commit ( )
# ba_meta export plugin
class update_16mods_to_17 ( ba . Plugin ) :
def __init__ ( self ) :
update_mods ( )
2022-03-16 08:57:34 +05:30
2022-02-06 11:45:13 +05:30
# ba_meta export plugin
2022-03-16 08:57:34 +05:30
class get_logs ( ba . Plugin ) :
2022-07-15 14:55:58 +05:30
def __init__ ( self ) :
2022-02-06 11:45:13 +05:30
make_folder ( )
2022-09-27 16:40:27 +05:30
open ( log_post , ' w+ ' ) . close ( )
dump_cache_logs ( )
ba . app . log_handler . add_callback ( make_logs )
2022-03-16 08:57:34 +05:30
# ba_meta export plugin
class get_config ( ba . Plugin ) :
2022-07-15 14:55:58 +05:30
def __init__ ( self ) :
2022-09-27 16:40:27 +05:30
make_folder ( )
configs = ba . app . config_file_path
with open ( configs ) as f :
make_config ( f . read ( ) )
f . close ( )
2022-03-16 08:57:34 +05:30
# ba_meta export plugin
class create_sys ( ba . Plugin ) :
2022-07-15 14:55:58 +05:30
def __init__ ( self ) :
2022-09-27 16:40:27 +05:30
ba . timer ( 2.5 , make_sys )
2022-03-16 08:57:34 +05:30
# ba_meta export plugin
class delete_sys ( ba . Plugin ) :
2022-07-15 14:55:58 +05:30
def __init__ ( self ) :
2022-09-27 16:40:27 +05:30
ba . timer ( 3 , yeet_sys )
2022-07-15 14:55:58 +05:30
class Player ( ba . Player [ ' Team ' ] ) :
""" Our player type for this game. """
class Team ( ba . Team [ Player ] ) :
""" Our team type for this game. """
# ba_meta export game
class Terminal_get3Dpoint ( ba . TeamGameActivity [ Player , Team ] ) :
name = ' 3D co-ordinate point '
available_settings = [ ba . BoolSetting ( ' Boxes ' , default = False ) , ba . BoolSetting ( ' Points ' , default = False ) ]
description = ' Get 3D co-ordinate point of ANY map! '
def __init__ ( self , settings : dict ) :
super ( ) . __init__ ( settings )
self . _boxes = settings . get ( ' Boxes ' , False )
self . _points = settings . get ( ' Points ' , False )
@classmethod
def supports_session_type ( cls , sessiontype ) :
return ( issubclass ( sessiontype , ba . DualTeamSession ) or issubclass ( sessiontype , ba . FreeForAllSession ) )
@classmethod
def get_supported_maps ( cls , sessiontype ) :
# Support every single map registered to the game...
maps = [ ]
for map in _ba . app . maps :
maps . append ( map )
return maps
def on_begin ( self ) :
super ( ) . on_begin ( )
if self . _boxes :
self . spawn_boxes ( )
if self . _points :
self . spawn_points ( )
def spawn_boxes ( self ) :
for box in self . map . defs . boxes :
box_pt = self . map . defs . boxes [ box ]
box_locator = ba . newnode ( ' locator ' , attrs = { ' shape ' : ' box ' , ' position ' : ( box_pt [ 0 ] , box_pt [ 1 ] , box_pt [ 2 ] ) , ' color ' : ( 1 , 1 , 0 ) , ' opacity ' : 1 , ' draw_beauty ' : True , ' additive ' : False , ' size ' : ( box_pt [ 6 ] , box_pt [ 7 ] , box_pt [ 8 ] ) } )
mnode = ba . newnode ( ' math ' , owner = box_locator , attrs = { ' input1 ' : ( 0 , 0 , 0 ) , ' operation ' : ' add ' } )
box_locator . connectattr ( ' position ' , mnode , ' input2 ' )
box_text = ba . newnode ( ' text ' , owner = box_locator , attrs = { ' text ' : box , ' in_world ' : True , ' shadow ' : 0 , ' flatness ' : 0 , ' color ' : ( 1 , 1 , 1 ) , ' scale ' : 0.01 , ' h_align ' : ' center ' } )
mnode . connectattr ( ' output ' , box_text , ' position ' )
def spawn_points ( self ) :
for point in self . map . defs . points :
display_pt = self . map . defs . points [ point ]
if len ( display_pt ) == 6 :
point_locator = ba . newnode ( ' locator ' , attrs = { ' shape ' : ' box ' , ' position ' : ( display_pt [ 0 ] , display_pt [ 1 ] , display_pt [ 2 ] ) , ' color ' : ( 1 , 1 , 0 ) , ' opacity ' : 1 , ' draw_beauty ' : True , ' additive ' : False , ' size ' : ( display_pt [ 3 ] , display_pt [ 4 ] , display_pt [ 5 ] ) } )
elif len ( display_pt ) == 3 :
point_locator = ba . newnode ( ' locator ' , attrs = { ' shape ' : ' circle ' , ' position ' : ( display_pt [ 0 ] , display_pt [ 1 ] , display_pt [ 2 ] ) , ' color ' : ( 1 , 1 , 0 ) , ' opacity ' : 1 , ' draw_beauty ' : True , ' additive ' : False , ' drawShadow ' : False , ' size ' : ( 0.4 , 0.4 , 0.4 ) } )
else :
print ( ' Invalid entry of; ' , point , ' values given: ' , display_pt )
continue
mnode = ba . newnode ( ' math ' , owner = point_locator , attrs = { ' input1 ' : ( 0 , 0 , 0 ) , ' operation ' : ' add ' } )
point_locator . connectattr ( ' position ' , mnode , ' input2 ' )
point_text = ba . newnode ( ' text ' , owner = point_locator , attrs = { ' text ' : point , ' in_world ' : True , ' shadow ' : 1.0 , ' flatness ' : 1.0 , ' color ' : ( 0 , 0 , 0 ) , ' scale ' : 0.01 , ' h_align ' : ' center ' } )
mnode . connectattr ( ' output ' , point_text , ' position ' )
def end_game ( self ) :
results = ba . GameResults ( )
for team in self . teams :
results . set_team_score ( team , team . score )
self . end ( results = results )
def handlemessage ( self , msg ) :
if isinstance ( msg , ba . _messages . PlayerDiedMessage ) :
self . respawn_player ( msg . getplayer ( self . playertype ) , 1 )
else :
return super ( ) . handlemessage ( msg )
return None