forked from bombsquad-community/plugin-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheat_menu.py
358 lines (302 loc) · 12.4 KB
/
cheat_menu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
# Ported by brostos to api 8
# Tool used to make porting easier.(https://github.com/bombsquad-community/baport)
"""CheatMenu | now cheat much as you can haha!! please eric sir dont kill me
Credits To:
Pranav"Modder"= Creator of the mod.
Emily"Skin and Modder"= Code and Mod Ideas.(pls dont be angry) :"(
And Me(Edited): Well Litterally Nothing lol.
Important Note From the Creator: "I apreciate any kind of modification. So feel free to use or edit code or change credit string.... no problem.
this mod uses activity loop cheacks if change in config and update it on our player node"
Really Awesome servers:
Bombsquad Consultancy Service - https://discord.gg/2RKd9QQdQY.
bombspot - https://discord.gg/ucyaesh.
cyclones - https://discord.gg/pJXxkbQ7kH.
"""
from __future__ import annotations
__author__ = 'egg'
__version__ = 1.0
import babase
import bauiv1 as bui
import bascenev1 as bs
import _babase
from baenv import TARGET_BALLISTICA_BUILD as build_number
from bauiv1lib.settings.allsettings import AllSettingsWindow
from bascenev1lib.actor.spaz import Spaz
from typing import (
Text,
Tuple,
Optional,
Union,
get_args
)
type
# Default Confings/Settings
CONFIG = "CheatMenu"
APPCONFIG = babase.app.config
Configs = {
"Unlimited Heath": False,
"SpeedBoots": False,
"Fly": False,
"SuperPunch": False,
"ImpactOnly": False,
"StickyOnly": False,
"IceOnly": False,
"Infinite Bombs": False,
"More Are Coming": False,
"Credits": False,
}
def setconfigs() -> None:
"""Set required defualt configs for mod"""
if CONFIG not in APPCONFIG:
APPCONFIG[str(CONFIG)] = Configs
for c in Configs:
if c not in APPCONFIG[str(CONFIG)]:
APPCONFIG[str(CONFIG)][str(c)] = Configs[str(c)]
else:
pass
APPCONFIG.apply_and_commit()
def update_config(config: str, change: any):
"""update's given value in json config file of pluguin"""
APPCONFIG[str(CONFIG)][str(config)] = change
APPCONFIG.apply_and_commit()
# ba_meta require api 8
# ba_meta export plugin
class Plugin(babase.Plugin):
def on_app_running(self) -> None:
if babase.app.build_number if build_number < 21282 else babase.app.env.build_number:
setconfigs()
self.overwrite()
else:
babase.screenmessage(f'{__name__} only works on api 8')
def overwrite(self) -> None:
AllSettingsWindow.init = AllSettingsWindow.__init__
AllSettingsWindow.__init__ = AllSettingsWindowInit
# creating Cheat button, start button
def AllSettingsWindowInit(self, transition: str = 'in_right', origin_widget: bui.Widget = None):
self.init(transition)
uiscale = bui.app.ui_v1.uiscale
btn_width = 720 if uiscale is babase.UIScale.SMALL else 400
btn_height = 380
self.cheat_menu_btn = bui.buttonwidget(
parent=self._root_widget,
autoselect=True,
position=(btn_width, btn_height),
size=(105, 50),
icon=bui.gettexture('settingsIcon'),
label='Cheats',
button_type='square',
text_scale=1.2,
on_activate_call=babase.Call(
on_cheat_menu_btn_press, self))
# on cheat button press call Window
def on_cheat_menu_btn_press(self):
bui.containerwidget(edit=self._root_widget,
transition='out_scale')
bui.app.ui_v1.set_main_menu_window(
CheatMenuWindow(
transition='in_right').get_root_widget(), from_window=self._root_widget)
class CheatMenuWindow(bui.Window):
def __init__(self,
transition: Optional[str] = 'in_right') -> None:
# background window, main widget parameters
uiscale = bui.app.ui_v1.uiscale
self._width = 870.0 if uiscale is babase.UIScale.SMALL else 670.0
self._height = (390.0 if uiscale is babase.UIScale.SMALL else
450.0 if uiscale is babase.UIScale.MEDIUM else 520.0)
extra_x = 100 if uiscale is babase.UIScale.SMALL else 0
self.extra_x = extra_x
top_extra = 20 if uiscale is babase.UIScale.SMALL else 0
# scroll widget parameters
self._scroll_width = self._width - (100 + 2 * extra_x)
self._scroll_height = self._height - 115.0
self._sub_width = self._scroll_width * 0.95
self._sub_height = 640.0
self._spacing = 32
self._extra_button_spacing = self._spacing * 2.5
super().__init__(
root_widget=bui.containerwidget(
size=(self._width, self._height),
transition=transition,
scale=(2.06 if uiscale is babase.UIScale.SMALL else
1.4 if uiscale is babase.UIScale.MEDIUM else 1.0)))
# back button widget
self._back_button = bui.buttonwidget(
parent=self._root_widget,
autoselect=True,
position=(52 + self.extra_x,
self._height - 60 - top_extra),
size=(60, 60),
scale=0.8,
label=babase.charstr(babase.SpecialChar.BACK),
button_type='backSmall',
on_activate_call=self._back)
bui.containerwidget(edit=self._root_widget,
cancel_button=self._back_button)
# window title, apears in top center of window
self._title_text = bui.textwidget(
parent=self._root_widget,
position=(0, self._height - 40 - top_extra),
size=(self._width, 25),
text='Cheat Menu',
color=bui.app.ui_v1.title_color,
scale=1.2,
h_align='center',
v_align='top')
self._scrollwidget = bui.scrollwidget(
parent=self._root_widget,
position=(50 + extra_x, 50 - top_extra),
simple_culling_v=20.0,
highlight=False,
size=(self._scroll_width,
self._scroll_height),
selection_loops_to_parent=True)
bui.widget(edit=self._scrollwidget,
right_widget=self._scrollwidget)
# subcontainer represents scroll widget and used as parent
self._subcontainer = bui.containerwidget(
parent=self._scrollwidget,
size=(self._sub_width,
self._sub_height),
background=False,
selection_loops_to_parent=True)
v = self._sub_height - 35
v -= self._spacing * 1.2
conf = APPCONFIG[str(CONFIG)]
for checkbox in Configs:
bui.checkboxwidget(
parent=self._subcontainer,
autoselect=True,
position=(25.0, v),
size=(40, 40),
text=checkbox,
textcolor=(0.8, 0.8, 0.8),
value=APPCONFIG[CONFIG][checkbox],
on_value_change_call=babase.Call(
self.update, checkbox),
scale=1.4,
maxwidth=430)
v -= 70
def update(self, config: str, change) -> None:
"""Change config and get our sounds
Args:
config: str
change: any
"""
try:
if change == True and config == "Fly":
bui.screenmessage("Some maps may not work good for flying",
color=(1, 0, 0))
update_config(config, change)
bui.getsound('gunCocking').play()
except Exception:
bui.screenmessage("error", color=(1, 0, 0))
bui.getsound('error').play()
try:
if change == True and config == "SuperPunch":
bui.screenmessage("SuperPunch Activated",
color=(1, 0, 0))
elif change == False and config == "SuperPunch":
bui.screenmessage("Super Punch Deactivated",
color=(0.5, 0, 0))
update_config(config, change)
bui.getsound('gunCocking').play()
except Exception:
bui.screenmessage("error", color=(1, 0, 0))
bui.getsound('spazOw').play()
try:
if change == True and config == "IceOnly":
bui.screenmessage("Ice Bombs Activated",
color=(0.1, 1, 1))
elif change == False and config == "IceOnly":
bui.screenmessage("Ice Bombs Deactivated",
color=(1, 0, 0))
update_config(config, change)
bui.getsound('gunCocking').play()
except Exception:
bui.screenmessage("error", color=(1, 0, 0))
bui.getsound('spazOw').play()
try:
if change == True and config == "StickyOnly":
bui.screenmessage("Sticky Bombs Activated",
color=(0, 1, 0))
elif change == False and config == "StickyOnly":
bui.screenmessage("Sticky Bombs Deactivated",
color=(1, 0, 0))
update_config(config, change)
bui.getsound('gunCocking').play()
except Exception:
bui.screenmessage("error", color=(1, 0, 0))
bui.getsound('spazOw').play()
try:
if change == True and config == "ImpactOnly":
bui.screenmessage("Impact Bombs Activated",
color=(0.5, 0.5, 0.5))
elif change == False and config == "ImpactOnly":
bui.screenmessage("Impact Bombs Deactivated",
color=(1, 0, 0))
update_config(config, change)
bui.getsound('gunCocking').play()
except Exception:
bui.screenmessage("error", color=(1, 0, 0))
bui.getsound('spazOw').play()
try:
if change == True and config == "More Are Coming":
bui.screenmessage("Check out https://discord.gg/2RKd9QQdQY For More Mods",
color=(4, 9, 2))
update_config(config, change)
bui.getsound('gunCocking').play()
except Exception:
bui.screenmessage("error", color=(1, 0, 0))
bui.getsound('cheer').play()
try:
if change == True and config == "Credits":
bui.screenmessage("To Pranav Made The Mod and Emily For Ideas, Thx",
color=(4, 9, 2))
update_config(config, change)
bui.getsound('gunCocking').play()
except Exception:
bui.screenmessage("error", color=(1, 0, 0))
bui.getsound('cheer').play()
def _back(self) -> None:
"""Kill the window and get back to previous one
"""
bui.containerwidget(edit=self._root_widget,
transition='out_scale')
bui.app.ui_v1.set_main_menu_window(
AllSettingsWindow(
transition='in_left').get_root_widget(), from_window=self._root_widget)
def ishost():
session = bs.get_foreground_host_session()
with session.context:
for player in session.sessionplayers:
if player.inputdevice.client_id == -1:
return True
def activity_loop():
if bs.get_foreground_host_activity() is not None:
activity = bs.get_foreground_host_activity()
with activity.context:
for player in activity.players:
if not ishost() or not player.actor:
return
config = APPCONFIG[CONFIG]
player.actor.node.invincible = config["Unlimited Heath"]
player.actor.node.fly = config["Fly"]
player.actor.node.hockey = config["SpeedBoots"]
if config["SuperPunch"]:
player.actor._punch_power_scale = 2
elif not config["SuperPunch"]:
player.actor._punch_power_scale = 1.2
if config["IceOnly"]:
player.actor.bomb_type = 'ice'
elif not config["IceOnly"]:
player.actor.bomb_type = 'normal'
player.actor.bomb_count = 1
if config["ImpactOnly"]:
player.actor.bomb_type = 'impact'
player.actor.bomb_count = 1
if config["StickyOnly"]:
player.actor.bomb_type = 'sticky'
player.actor.bomb_count = 1
if config["Infinite Bombs"]:
player.actor.bomb_count = 100
timer = babase.AppTimer(2, activity_loop, repeat=True)