3434from random import random
3535
3636
37- __author__ : str = 'R3nzTheCodeGOD'
38- __version__ : str = 'v2.0.1 '
37+ __author__ = 'R3nzTheCodeGOD'
38+ __version__ = 'v2.0.2 '
3939
4040
41- S_HEIGHT , S_WIDTH = ImageGrab .grab ().size
42- GRABZONE : int = 5
43- TRIGGER_KEY : str = 'shift'
44- SWITCH_KEY : str = 'ctrl + tab'
45- GRABZONE_KEY_UP : str = 'ctrl + up'
46- GRABZONE_KEY_DOWN : str = 'ctrl + down'
47- mods : tuple = ('0.3s Delay' , '0.2s Delay' , '0.1s Delay' , 'No Delay Full-Auto' )
41+ S_HEIGHT , S_WIDTH = ImageGrab .grab ().size
42+ GRABZONE = 0x5
43+ TRIGGER_KEY = 'shift'
44+ SWITCH_KEY = 'ctrl + tab'
45+ GRABZONE_KEY_UP = 'ctrl + up'
46+ GRABZONE_KEY_DOWN = 'ctrl + down'
47+ MODS = ('0.3s Delay' , '0.25s Delay' , '0.2s Delay' , '0.15s Delay' , '0.1s Delay' , 'No Delay Full-Auto' )
4848
4949
5050class FoundEnemy (Exception ):
5151 pass
5252
5353
5454class TriggerBot :
55+
5556 def __init__ (self ) -> None :
56- self ._mode : int = 2
57- self ._last_reac : int = 0
57+ self ._mode = 0x1
58+ self ._last_reac = 0x0
59+
60+
61+ def switch (self ) -> None :
62+ Beep (0xC8 , 0x64 )
63+ if self ._mode != 0x5 : self ._mode += 0x1
64+ else : self ._mode = 0x0
5865
59- def switch (self ):
60- if self ._mode != 3 : self ._mode += 1
61- else : self ._mode = 0
62- if self ._mode == 0 : Beep (200 , 100 )
63- elif self ._mode == 1 : Beep (200 , 100 ), Beep (200 , 100 )
64- elif self ._mode == 2 : Beep (200 , 100 ), Beep (200 , 100 ), Beep (200 , 100 )
65- elif self ._mode == 3 : Beep (200 , 100 ), Beep (200 , 100 ), Beep (200 , 100 ), Beep (200 , 100 )
6666
6767 def color_check (self , red : int , green : int , blue : int ) -> bool :
68- if green >= 190 : return False
69- if green >= 140 : return abs (red - blue ) <= 8 and red - green >= 50 and blue - green >= 50 and red >= 105 and blue >= 105
70- return abs (red - blue ) <= 13 and red - green >= 60 and blue - green >= 60 and red >= 110 and blue >= 100
68+ if green >= 0xAA : return False
69+ if green >= 0x78 : return abs (red - blue ) <= 0x8 and red - green >= 0x32 and blue - green >= 0x32 and red >= 0x69 and blue >= 0x69
70+
71+ return abs (red - blue ) <= 0xD and red - green >= 0x3C and blue - green >= 0x3C and red >= 0x6E and blue >= 0x64
72+
7173
7274 def grab (self ) -> Image :
7375 with mss () as sct :
74- bbox : tuple = (int (S_HEIGHT / 2 - GRABZONE ), int (S_WIDTH / 2 - GRABZONE ), int (S_HEIGHT / 2 + GRABZONE ), int (S_WIDTH / 2 + GRABZONE ))
75- sct_img = sct .grab (bbox )
76+ bbox = (int (S_HEIGHT / 0x2 - GRABZONE ), int (S_WIDTH / 0x2 - GRABZONE ), int (S_HEIGHT / 0x2 + GRABZONE ), int (S_WIDTH / 0x2 + GRABZONE ))
77+ sct_img = sct .grab (bbox )
7678 return Image .frombytes ('RGB' , sct_img .size , sct_img .bgra , 'raw' , 'BGRX' )
7779
80+
7881 def scan (self ) -> None :
79- start_time : float = perf_counter ()
80- pmap : Image = self .grab ()
82+ start_time = perf_counter ()
83+ pmap = self .grab ()
8184
8285 try :
83- for x in range (0 , GRABZONE * 2 ):
84- for y in range (0 , GRABZONE * 2 ):
86+ for x in range (0x0 , GRABZONE * 0x2 ):
87+ for y in range (0x0 , GRABZONE * 0x2 ):
8588 r , g , b = pmap .getpixel ((x , y ))
8689 if self .color_check (r , g , b ): raise FoundEnemy
8790
8891 except FoundEnemy :
89- self ._last_reac = int ((perf_counter () - start_time ) * 1000 )
90- windll .user32 .mouse_event (2 , 0 , 0 , 0 , 0 ), windll .user32 .mouse_event (4 , 0 , 0 , 0 , 0 )
92+ self ._last_reac = int ((perf_counter () - start_time ) * 0x3E8 )
93+ windll .user32 .mouse_event (0x2 , 0x0 , 0x0 , 0x0 , 0x0 ), windll .user32 .mouse_event (0x4 , 0x0 , 0x0 , 0x0 , 0x0 )
9194
92- if self ._mode == 0 : sleep (0.3 )
93- elif self ._mode == 1 : sleep (0.2 )
94- elif self ._mode == 2 : sleep (0.1 )
95- elif self ._mode == 3 : pass
95+ if self ._mode == 0x0 : sleep (0.3 )
96+ elif self ._mode == 0x1 : sleep (0.25 )
97+ elif self ._mode == 0x2 : sleep (0.2 )
98+ elif self ._mode == 0x3 : sleep (0.15 )
99+ elif self ._mode == 0x4 : sleep (0.1 )
100+ elif self ._mode == 0x5 : pass
96101
97102
98103def print_banner (bot : TriggerBot ) -> None :
@@ -103,30 +108,36 @@ def print_banner(bot: TriggerBot) -> None:
103108 print ('Mode Change Key :' , Fore .YELLOW + SWITCH_KEY + Style .RESET_ALL )
104109 print ('Grab Zone Change Key :' , Fore .YELLOW + GRABZONE_KEY_UP + '/' + GRABZONE_KEY_DOWN + Style .RESET_ALL )
105110 print ('===== Information ====' )
106- print ('Mode :' , Fore .CYAN + mods [bot ._mode ] + Style .RESET_ALL )
107- print ('Grab Zone :' , Fore .CYAN + str (GRABZONE ) + 'x' + str (GRABZONE ) + Style .RESET_ALL )
111+ print ('Mode :' , Fore .CYAN + MODS [bot ._mode ] + Style .RESET_ALL )
112+ print ('Grab Zone :' , Fore .CYAN + str (GRABZONE ) + 'x' + str (GRABZONE ) + Style .RESET_ALL )
108113 print ('Trigger Status :' , Fore .GREEN + f'Hold down the "{ TRIGGER_KEY } " key' + Style .RESET_ALL )
109- print ('Last React Time :' , Fore .CYAN + str (bot ._last_reac ) + Style .RESET_ALL + ' ms (' + str ((bot ._last_reac )/ (GRABZONE * GRABZONE )) + 'ms/pix)' )
114+ print ('Last React Time :' , Fore .CYAN + str (bot ._last_reac ) + Style .RESET_ALL + ' ms (' + str ((bot ._last_reac ) / (GRABZONE * GRABZONE )) + 'ms/pix)' )
110115
111116
112117if __name__ == "__main__" :
113- _hash : str = sha256 (f'{ random ()} ' .encode ('utf-8' )).hexdigest ()
118+ _hash = sha256 (f'{ random ()} ' .encode ('utf-8' )).hexdigest ()
114119 print (_hash ), system (f'title { _hash } ' ), sleep (0.5 ), init (), system ('@echo off' ), system ('cls' )
115120 bot = TriggerBot ()
116121 print_banner (bot )
117122
118- while True :
119- if is_pressed (SWITCH_KEY ): bot .switch (), print_banner (bot )
123+ while 0x1 :
124+ if is_pressed (SWITCH_KEY ):
125+ bot .switch ()
126+ print_banner (bot )
127+ continue
120128
121129 if is_pressed (GRABZONE_KEY_UP ):
122- GRABZONE += 1
123- print_banner (bot ), Beep (400 , 100 )
130+ GRABZONE += 0x1
131+ print_banner (bot ), Beep (0x190 , 0x64 )
132+ continue
124133
125134 if is_pressed (GRABZONE_KEY_DOWN ):
126- if GRABZONE != 1 : GRABZONE -= 1
127- print_banner (bot ), Beep (300 , 100 )
135+ if GRABZONE != 0x1 : GRABZONE -= 0x1
136+ print_banner (bot ), Beep (0x12C , 0x64 )
137+ continue
128138
129139 if is_pressed (TRIGGER_KEY ):
130140 bot .scan (), print_banner (bot )
141+ continue
131142
132- sleep (0.001 ) # [Fix input lag] Contributing: https://github.com/atakanhr
143+ sleep (0.001 )
0 commit comments