This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
forked from Megant88/Fast-Valorant-Triggerbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
118 lines (95 loc) · 3.98 KB
/
main.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
import json, time, threading, keyboard,sys
import win32.win32api as win32api
from ctypes import WinDLL
import numpy as np
import dxcam
def exiting():
try:
exec(type((lambda: 0).__code__)(0, 0, 0, 0, 0, 0, b'\x053', (), (), (), '', '', 0, b''))
except:
try:
sys.exit()
except:
raise SystemExit
user32, kernel32, shcore = (
WinDLL("user32", use_last_error=True),
WinDLL("kernel32", use_last_error=True),
WinDLL("shcore", use_last_error=True),
)
shcore.SetProcessDpiAwareness(2)
WIDTH, HEIGHT = [user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)]
ZONE = 5
GRAB_ZONE = (
int(WIDTH / 2 - ZONE),
int(HEIGHT / 2 - ZONE),
int(WIDTH / 2 + ZONE),
int(HEIGHT / 2 + ZONE),
)
class triggerbot:
def __init__(self):
self.sct = dxcam.create(output_color='BGRA', output_idx=0)
self.triggerbot = False
self.triggerbot_toggle = True
self.exit_program = False
self.toggle_lock = threading.Lock()
with open('config.json') as json_file:
data = json.load(json_file)
try:
self.trigger_hotkey = int(data["trigger_hotkey"],16)
self.always_enabled = data["always_enabled"]
self.trigger_delay = data["trigger_delay"]
self.base_delay = data["base_delay"]
self.color_tolerance = data["color_tolerance"]
self.R, self.G, self.B = (250, 100, 250) # purple
except:
exiting()
def cooldown(self):
time.sleep(0.1)
with self.toggle_lock:
self.triggerbot_toggle = True
kernel32.Beep(440, 75), kernel32.Beep(700, 100) if self.triggerbot else kernel32.Beep(440, 75), kernel32.Beep(200, 100)
def searcherino(self):
img = np.array(self.sct.grab(GRAB_ZONE))
while img.any() == None:
img = np.array(self.sct.grab(GRAB_ZONE))
pixels = img.reshape(-1, 4)
color_mask = (
(pixels[:, 0] > self.R - self.color_tolerance) & (pixels[:, 0] < self.R + self.color_tolerance) &
(pixels[:, 1] > self.G - self.color_tolerance) & (pixels[:, 1] < self.G + self.color_tolerance) &
(pixels[:, 2] > self.B - self.color_tolerance) & (pixels[:, 2] < self.B + self.color_tolerance)
)
matching_pixels = pixels[color_mask]
if self.triggerbot and len(matching_pixels) > 0:
delay_percentage = self.trigger_delay / 100.0
actual_delay = self.base_delay + self.base_delay * delay_percentage
time.sleep(actual_delay)
keyboard.press_and_release("k")
def toggle(self):
if keyboard.is_pressed("f10"):
with self.toggle_lock:
if self.triggerbot_toggle:
self.triggerbot = not self.triggerbot
print(self.triggerbot)
self.triggerbot_toggle = False
threading.Thread(target=self.cooldown).start()
if keyboard.is_pressed("ctrl+shift+x"): # Check for the kkkkk keybind
self.exit_program = True
exiting()
def hold(self):
while True:
while win32api.GetAsyncKeyState(self.trigger_hotkey) < 0:
self.triggerbot = True
self.searcherino()
else:
time.sleep(0.1)
if keyboard.is_pressed("ctrl+shift+x"): # Check for the exit keybind
self.exit_program = True
exiting()
def starterino(self):
while not self.exit_program: # Keep running until the exit_program flag is True
if self.always_enabled == True:
self.toggle()
self.searcherino() if self.triggerbot else time.sleep(0.1)
else:
self.hold()
triggerbot().starterino()