Skip to content

Commit eac84b3

Browse files
committed
halloween mode
1 parent d11e7f7 commit eac84b3

File tree

3 files changed

+51
-17
lines changed

3 files changed

+51
-17
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
___
33
A simple autoclicker for blum drop mini-game on python (autoclicker collects **$dogs**)
44

5+
### Halloween mode:
6+
- run `main.py --halloween` to enable halloween mode (bot will collect pumpkins)
7+
58
## Usage
69
- Start tg app, then `main.py` and press play
710
- DO NOT CLOSE GAME WINDOW BEFORE GAME IS FINISHED

constants.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
1+
import sys
22

33
"""On different devices app size is also different,
44
so i located triggers on mine and devided it by window size on my pc,
55
in game this coefficients are multiplied by actual window size to get correct coordinates"""
66
DEV_SCREEN_SIZE_CONST = (402, 712)
77

88
APPLICATION_NAME = 'TelegramDesktop'
9-
COLOR_TRIGGERS = {
9+
DEFAULT_COLOR_TRIGGER = {
1010
"red":{"min":90, "max":255},
1111
"green":{"min":220, "max":255},
1212
"blue":{"min":5, "max":55}}
@@ -20,3 +20,15 @@
2020

2121
#Dogs drop
2222
DOGS_WHITE_COLOR_RANGE = (238, 256)
23+
DOGS_DROP_TOGGLE = '--disable-dogs' not in sys.argv
24+
25+
# Halloween
26+
HALLOWEEN_MODE = '--halloween' in sys.argv
27+
HALLOWEEN_COLOR_TRIGGER = {
28+
"red":{"min":220, "max":240},
29+
"green":{"min":95, "max":130},
30+
"blue":{"min":35, "max":55}}
31+
BOMB_COLOR_TRIGGER = {
32+
"red":{"min":125, "max":140},
33+
"green":{"min":125, "max":135},
34+
"blue":{"min":125, "max":135}}

main.py

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
from prepare_app import prepare_app
1313
from constants import (
1414
APPLICATION_TRIGGER,
15-
COLOR_TRIGGERS,
15+
DEFAULT_COLOR_TRIGGER,
1616
PIXELS_PER_ITERATION,
1717
NEW_GAME_TRIGGER_POS,
1818
AVG_GAME_DURATION,
1919
DOGS_WHITE_COLOR_RANGE,
20+
DOGS_DROP_TOGGLE,
21+
HALLOWEEN_MODE,
22+
BOMB_COLOR_TRIGGER,
23+
HALLOWEEN_COLOR_TRIGGER,
2024
)
2125

2226

@@ -44,21 +48,33 @@ def check_running(frame, application_bbox) -> bool:
4448

4549
def check_object(frame, x:int, y:int) -> bool:
4650
""" Finding dropping objects by color """
47-
if COLOR_TRIGGERS['red']['min'] <= frame[y][x][0] <= COLOR_TRIGGERS['red']['max']:
48-
if COLOR_TRIGGERS['green']['min'] <= frame[y][x][1] <= COLOR_TRIGGERS['green']['max']:
49-
# print(frame[y][x])
50-
if COLOR_TRIGGERS['blue']['min'] <= frame[y][x][2] <= COLOR_TRIGGERS['blue']['max']:
51-
return True
5251

53-
#DOGS DROP
54-
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]:
55-
counter = 0
56-
for i in range(-1, 2):
57-
for j in range(-4, 2):
58-
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])
52+
def _check_color_trigger(color_trigger):
53+
if color_trigger['red']['min'] <= frame[y][x][0] <= color_trigger['red']['max']:
54+
if color_trigger['green']['min'] <= frame[y][x][1] <= color_trigger['green']['max']:
55+
# print(frame[y][x])
56+
if color_trigger['blue']['min'] <= frame[y][x][2] <= color_trigger['blue']['max']:
57+
return True
58+
return False
5959

60-
if counter >= 10:
60+
if HALLOWEEN_MODE:
61+
if _check_color_trigger(HALLOWEEN_COLOR_TRIGGER) or _check_color_trigger(BOMB_COLOR_TRIGGER):
6162
return True
63+
else:
64+
if _check_color_trigger(DEFAULT_COLOR_TRIGGER):
65+
return True
66+
67+
#DOGS DROP
68+
69+
if DOGS_DROP_TOGGLE:
70+
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]:
71+
counter = 0
72+
for i in range(-1, 2):
73+
for j in range(-4, 2):
74+
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])
75+
76+
if counter >= 10:
77+
return True
6278

6379

6480
return False
@@ -81,7 +97,10 @@ def main():
8197

8298
amount_of_games = 1
8399
if len(sys.argv) > 1:
84-
amount_of_games = int(sys.argv[1])
100+
for arg in sys.argv:
101+
if arg.isnumeric():
102+
amount_of_games = int(arg)
103+
break
85104

86105
camera = dxcam.create()
87106
camera.start(target_fps=60)
@@ -129,7 +148,7 @@ def main():
129148
mouse.move(x, y, absolute=True)
130149
mouse.click(button='left')
131150

132-
wait_running_game(camera, timeout = 5.5)
151+
wait_running_game(camera, timeout = 12.5)
133152

134153
camera.stop()
135154

0 commit comments

Comments
 (0)