Skip to content

Commit

Permalink
halloween mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Wokzy committed Oct 28, 2024
1 parent d11e7f7 commit eac84b3
Showing 3 changed files with 51 additions and 17 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
16 changes: 14 additions & 2 deletions constants.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

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,
in game this coefficients are multiplied by actual window size to get correct coordinates"""
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}}
49 changes: 34 additions & 15 deletions main.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit eac84b3

Please sign in to comment.