├── README.md └── colorbot ├── arduino-contact.ino ├── grabber.py └── main.py /README.md: -------------------------------------------------------------------------------- 1 | # Overwatch2-colorbot-cheats 2 | Triggerbot and aimbot made for overwatch two. Set your enemy outline to purple. Code was partially taken from Unknown cheats then greatly modified. Uses Arduino Leonardo as mouse bypass. 3 | -------------------------------------------------------------------------------- /colorbot/arduino-contact.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int dx; 4 | int dy; 5 | int dxn; 6 | int dyn; 7 | int index = 0; 8 | int num_size = 0; 9 | 10 | 11 | int jump = 127; 12 | 13 | void setup() 14 | { 15 | Mouse.begin(); 16 | Serial.begin(115200); 17 | Serial.setTimeout(0); 18 | Serial.println("Start"); 19 | 20 | } 21 | 22 | void loop() 23 | { 24 | if (Serial.available()) 25 | { 26 | 27 | String data = Serial.readString(); 28 | if (data == "shoot") 29 | { 30 | Mouse.click(); 31 | } 32 | 33 | else if (data.substring(0, 6) == "silent") 34 | { 35 | data.remove(0, 6); 36 | index = 0; 37 | num_size = data.indexOf(":", index); 38 | dx = data.substring(index, num_size).toInt(); 39 | data.remove(0, num_size + 1); 40 | dy = data.toInt(); 41 | dxn = dx * -1; 42 | dyn = dy * -1; 43 | 44 | if (dx > 0) 45 | { 46 | while (dx > 127) 47 | { 48 | dx -= 127; 49 | Mouse.move(127, 0); 50 | } 51 | Mouse.move(dx, 0); 52 | } 53 | else if (dx < 0) 54 | { 55 | while (dx < -127) 56 | { 57 | dx += 127; 58 | Mouse.move(-127, 0); 59 | } 60 | Mouse.move(dx, 0); 61 | } 62 | if (dy >= 0) 63 | { 64 | while (dy > 127) 65 | { 66 | dy -= 127; 67 | Mouse.move(0, 127); 68 | } 69 | Mouse.move(0, dy); 70 | } 71 | else if (dy <= 0) 72 | { 73 | while (dy < -127) 74 | { 75 | dy += 127; 76 | Mouse.move(0, -127); 77 | } 78 | Mouse.move(0, dy); 79 | } 80 | Mouse.click(); 81 | if (dxn > 0) 82 | { 83 | while (dxn > 127) 84 | { 85 | dxn -= 127; 86 | Mouse.move(127, 0); 87 | } 88 | Mouse.move(dxn, 0); 89 | } 90 | else if (dxn < 0) 91 | { 92 | while (dxn < -127) 93 | { 94 | dxn += 127; 95 | Mouse.move(-127, 0); 96 | } 97 | Mouse.move(dxn, 0); 98 | } 99 | if (dyn > 0) 100 | { 101 | while (dyn > 127) 102 | { 103 | dyn -= 127; 104 | Mouse.move(0, 127); 105 | } 106 | Mouse.move(0, dyn); 107 | } 108 | else if (dyn < 0) 109 | { 110 | while (dyn < -127) 111 | { 112 | dyn += 127; 113 | Mouse.move(0, -127); 114 | } 115 | Mouse.move(0, dyn); 116 | } 117 | } 118 | 119 | else 120 | { 121 | index = 0; 122 | num_size = data.indexOf(":", index); 123 | dx = data.substring(index, num_size).toInt(); 124 | data.remove(0, num_size + 1); 125 | dy = data.toInt(); 126 | // Serial.println(dx+":"+dy); 127 | if (dx > 0) 128 | { 129 | while (dx > jump) 130 | { 131 | dx -= jump; 132 | Mouse.move(jump, 0); 133 | } 134 | Mouse.move(dx, 0); 135 | } 136 | else if (dx < 0) 137 | { 138 | while (dx < -jump) 139 | { 140 | dx += jump; 141 | Mouse.move(-jump, 0); 142 | } 143 | Mouse.move(dx, 0); 144 | } 145 | if (dy >= 0) 146 | { 147 | while (dy > jump) 148 | { 149 | dy -= jump; 150 | Mouse.move(0, jump); 151 | } 152 | Mouse.move(0, dy); 153 | } 154 | else if (dy <= 0) 155 | { 156 | while (dy < -jump) 157 | { 158 | dy += jump; 159 | Mouse.move(0, -jump); 160 | } 161 | Mouse.move(0, dy); 162 | } 163 | 164 | } 165 | } 166 | 167 | } -------------------------------------------------------------------------------- /colorbot/grabber.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | from mss import mss 3 | import numpy as np 4 | 5 | 6 | 7 | class Grabber: 8 | def __init__(self) -> None: 9 | 10 | # self.lower = np.array([139, 96, 129], np.uint8) 11 | # self.upper = np.array([169, 255, 255], np.uint8) 12 | # self.lower = np.array([139, 95, 154], np.uint8) 13 | # self.upper = np.array([153, 255, 255], np.uint8) 14 | 15 | 16 | # self.lower = np.array([139, 96, 129], np.uint8) 17 | # self.upper = np.array([169, 255, 255], np.uint8) 18 | self.lower = np.array([139, 96, 139], np.uint8) 19 | self.upper = np.array([157, 255, 255], np.uint8) 20 | def find_dimensions(self, scale,witdh,height): 21 | """Calculates constants required for the bot.""" 22 | region = (int(witdh/2-witdh/scale/2),int(height/2-height/scale/2),int(witdh/2+witdh/scale/2),int(height/2+height/scale/2)) 23 | x,y,width,height = region 24 | self.box_middle_x = int((width-x)/2) 25 | self.box_middle_y = int((height-y)/2) 26 | self.dimensions = region 27 | 28 | def process_frame(self, frame): 29 | """Performs operations on a frame to improve contour detection.""" 30 | hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) 31 | processed = cv2.inRange(hsv, self.lower, self.upper) 32 | processed = cv2.morphologyEx(processed, cv2.MORPH_CLOSE, np.ones((10, 10), np.uint8)) 33 | dilatation_size = 2 34 | dilation_shape = cv2.MORPH_RECT 35 | element = cv2.getStructuringElement(dilation_shape, (2 * dilatation_size + 1, 2 * dilatation_size + 1), 36 | (dilatation_size, dilatation_size)) 37 | processed = cv2.dilate(processed, element) 38 | # processed = cv2.blur(processed, (1, 1)) 39 | return processed 40 | def detect_contours(self, frame, minimum_size): 41 | """Returns contours larger then a specified size in a frame.""" 42 | contours, hierarchy = cv2.findContours(frame, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) 43 | large_contours = [] 44 | if len(contours) != 0: 45 | for i in contours: 46 | if cv2.contourArea(i) > minimum_size: 47 | large_contours.append(i) 48 | return large_contours 49 | def scale_contour(self,cnt, scale:float): 50 | M = cv2.moments(cnt) 51 | cx = int(M['m10']/M['m00']) 52 | cy = int(M['m01']/M['m00']) 53 | 54 | cnt_norm = cnt - [cx, cy] 55 | cnt_scaled = cnt_norm * scale 56 | cnt_scaled = cnt_scaled + [cx, cy] 57 | cnt_scaled = cnt_scaled.astype(np.int32) 58 | 59 | return cnt_scaled 60 | def on_target(self, contour): 61 | """Returns x- and y- coordinates of the center of the largest contour.""" 62 | for c in contour: 63 | cont = self.scale_contour(c,0.85) 64 | test = cv2.pointPolygonTest(cont,(self.box_middle_x,self.box_middle_y),False) 65 | if test >= 0: 66 | return True 67 | return False 68 | def compute_centroid(self, contour): 69 | """Returns x- and y- coordinates of the center of the largest contour.""" 70 | c = max(contour, key=cv2.contourArea) 71 | rectangle = np.int0(cv2.boxPoints(cv2.minAreaRect(c))) 72 | new_box = [] 73 | for point in rectangle: 74 | point_x = point[0] 75 | point_y = point[1] 76 | new_box.append([round(point_x, -1), round(point_y, -1)]) 77 | M = cv2.moments(np.array(new_box)) 78 | if M['m00']: 79 | center_x = (M['m10'] / M['m00']) 80 | center_y = (M['m01'] / M['m00']) 81 | x = -(self.box_middle_x - center_x) 82 | y = -(self.box_middle_y - center_y) 83 | return [], x, y 84 | -------------------------------------------------------------------------------- /colorbot/main.py: -------------------------------------------------------------------------------- 1 | 2 | from grabber import * 3 | import time 4 | import dxcam 5 | import keyboard 6 | import serial 7 | import threading 8 | import time 9 | def cooldown(cooldown_bool,wait): 10 | #cooldown threed for toggels or cooldowns 11 | time.sleep(wait) 12 | cooldown_bool[0] = True 13 | 14 | 15 | MONITOR_SCALE = 3 #fov 16 | serialcomm = serial.Serial('COM3',115200, timeout = 0)#com port for arduino 17 | grabber = Grabber() 18 | grabber.find_dimensions(MONITOR_SCALE,1920,1080) 19 | aim_bot_toggle = [True] 20 | aim_bot = False 21 | trigger_bot_toggle = [True] 22 | trigger_bot = False 23 | camera = dxcam.create(device_idx=0, output_idx=0, output_color= "BGRA") 24 | camera.start(region=grabber.dimensions,target_fps=200) 25 | start_time = time.time() 26 | h = 1 27 | counter = 0 28 | while True: 29 | 30 | # print(grabber.dimensions) 31 | og = camera.get_latest_frame() 32 | frame = grabber.process_frame(og) 33 | contours = grabber.detect_contours(frame, 100) 34 | counter+= 1 35 | if(time.time() - start_time) > h: 36 | fps = "fps:"+ str(int(counter/(time.time() - start_time))) 37 | print(fps) 38 | counter = 0 39 | start_time = time.time() 40 | if keyboard.is_pressed('`'): 41 | if aim_bot_toggle[0] == True: 42 | aim_bot = not aim_bot 43 | print(aim_bot) 44 | aim_bot_toggle[0] = False 45 | thread = threading.Thread(target=cooldown, args=(aim_bot_toggle,0.2,)) 46 | thread.start() 47 | if keyboard.is_pressed('alt'): 48 | if trigger_bot_toggle[0] == True: 49 | trigger_bot = not trigger_bot 50 | print(trigger_bot) 51 | trigger_bot_toggle[0] = False 52 | thread = threading.Thread(target=cooldown, args=(trigger_bot_toggle,0.2,)) 53 | thread.start() 54 | if contours: 55 | try: 56 | rec, x, y = grabber.compute_centroid(contours) 57 | if aim_bot: 58 | data = f"{int(x/4)}:{int(y/4)}" 59 | serialcomm.write(data.encode()) 60 | if trigger_bot and grabber.on_target(contours): 61 | serialcomm.write("shoot".encode()) 62 | except: 63 | print("",end="") 64 | 65 | 66 | 67 | # cv2.drawContours(og, contours, -1, (0, 0, 0), 2) 68 | 69 | # cv2.imshow('frame', og) 70 | # if (cv2.waitKey(1) & 0xFF) == ord('q'): 71 | # cv2.destroyAllWindows() 72 | # exit() 73 | 74 | 75 | --------------------------------------------------------------------------------