From eac84b3cdd157aca20e2165eea1d77b876bf7754 Mon Sep 17 00:00:00 2001 From: Wokzy Date: Mon, 28 Oct 2024 21:12:49 +0700 Subject: [PATCH] halloween mode --- README.md | 3 +++ constants.py | 16 ++++++++++++++-- main.py | 49 ++++++++++++++++++++++++++++++++++--------------- 3 files changed, 51 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index b78a898..e949bf2 100755 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ ___ A simple autoclicker for blum drop mini-game on python (autoclicker collects **$dogs**) +### Halloween mode: + - run `main.py --halloween` to enable halloween mode (bot will collect pumpkins) + ## Usage - Start tg app, then `main.py` and press play - DO NOT CLOSE GAME WINDOW BEFORE GAME IS FINISHED diff --git a/constants.py b/constants.py index 7830c42..e1de960 100755 --- a/constants.py +++ b/constants.py @@ -1,4 +1,4 @@ - +import sys """On different devices app size is also different, so i located triggers on mine and devided it by window size on my pc, @@ -6,7 +6,7 @@ DEV_SCREEN_SIZE_CONST = (402, 712) APPLICATION_NAME = 'TelegramDesktop' -COLOR_TRIGGERS = { +DEFAULT_COLOR_TRIGGER = { "red":{"min":90, "max":255}, "green":{"min":220, "max":255}, "blue":{"min":5, "max":55}} @@ -20,3 +20,15 @@ #Dogs drop DOGS_WHITE_COLOR_RANGE = (238, 256) +DOGS_DROP_TOGGLE = '--disable-dogs' not in sys.argv + +# Halloween +HALLOWEEN_MODE = '--halloween' in sys.argv +HALLOWEEN_COLOR_TRIGGER = { + "red":{"min":220, "max":240}, + "green":{"min":95, "max":130}, + "blue":{"min":35, "max":55}} +BOMB_COLOR_TRIGGER = { + "red":{"min":125, "max":140}, + "green":{"min":125, "max":135}, + "blue":{"min":125, "max":135}} diff --git a/main.py b/main.py index 5e28602..b595af2 100755 --- a/main.py +++ b/main.py @@ -12,11 +12,15 @@ from prepare_app import prepare_app from constants import ( APPLICATION_TRIGGER, - COLOR_TRIGGERS, + DEFAULT_COLOR_TRIGGER, PIXELS_PER_ITERATION, NEW_GAME_TRIGGER_POS, AVG_GAME_DURATION, DOGS_WHITE_COLOR_RANGE, + DOGS_DROP_TOGGLE, + HALLOWEEN_MODE, + BOMB_COLOR_TRIGGER, + HALLOWEEN_COLOR_TRIGGER, ) @@ -44,21 +48,33 @@ def check_running(frame, application_bbox) -> bool: def check_object(frame, x:int, y:int) -> bool: """ Finding dropping objects by color """ - if COLOR_TRIGGERS['red']['min'] <= frame[y][x][0] <= COLOR_TRIGGERS['red']['max']: - if COLOR_TRIGGERS['green']['min'] <= frame[y][x][1] <= COLOR_TRIGGERS['green']['max']: - # print(frame[y][x]) - if COLOR_TRIGGERS['blue']['min'] <= frame[y][x][2] <= COLOR_TRIGGERS['blue']['max']: - return True - #DOGS DROP - if frame[y][x][0] == frame[y][x][1] == frame[y][x][2] and DOGS_WHITE_COLOR_RANGE[0] <= frame[y][x][0] <= DOGS_WHITE_COLOR_RANGE[1]: - counter = 0 - for i in range(-1, 2): - for j in range(-4, 2): - counter += (frame[y + j][x + i][0] == frame[y + j][x + i][1] == frame[y + j][x + i][2] and DOGS_WHITE_COLOR_RANGE[0] <= frame[y + j][x + i][0] <= DOGS_WHITE_COLOR_RANGE[1]) + def _check_color_trigger(color_trigger): + if color_trigger['red']['min'] <= frame[y][x][0] <= color_trigger['red']['max']: + if color_trigger['green']['min'] <= frame[y][x][1] <= color_trigger['green']['max']: + # print(frame[y][x]) + if color_trigger['blue']['min'] <= frame[y][x][2] <= color_trigger['blue']['max']: + return True + return False - if counter >= 10: + if HALLOWEEN_MODE: + if _check_color_trigger(HALLOWEEN_COLOR_TRIGGER) or _check_color_trigger(BOMB_COLOR_TRIGGER): return True + else: + if _check_color_trigger(DEFAULT_COLOR_TRIGGER): + return True + + #DOGS DROP + + if DOGS_DROP_TOGGLE: + if frame[y][x][0] == frame[y][x][1] == frame[y][x][2] and DOGS_WHITE_COLOR_RANGE[0] <= frame[y][x][0] <= DOGS_WHITE_COLOR_RANGE[1]: + counter = 0 + for i in range(-1, 2): + for j in range(-4, 2): + counter += (frame[y + j][x + i][0] == frame[y + j][x + i][1] == frame[y + j][x + i][2] and DOGS_WHITE_COLOR_RANGE[0] <= frame[y + j][x + i][0] <= DOGS_WHITE_COLOR_RANGE[1]) + + if counter >= 10: + return True return False @@ -81,7 +97,10 @@ def main(): amount_of_games = 1 if len(sys.argv) > 1: - amount_of_games = int(sys.argv[1]) + for arg in sys.argv: + if arg.isnumeric(): + amount_of_games = int(arg) + break camera = dxcam.create() camera.start(target_fps=60) @@ -129,7 +148,7 @@ def main(): mouse.move(x, y, absolute=True) mouse.click(button='left') - wait_running_game(camera, timeout = 5.5) + wait_running_game(camera, timeout = 12.5) camera.stop()