-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpybot.py
More file actions
226 lines (193 loc) · 5.7 KB
/
Copy pathpybot.py
File metadata and controls
226 lines (193 loc) · 5.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# Ubuntu: sudo apt install scrot python3-tk python3-dev python3-pip
# pip3 install pyautogui opencv-python
import time
import pyautogui as py
from PIL import Image
from random import randrange
from os import listdir
# # TO ADD # #
# - Logout if no blankrune (and maybe no food?)
# - Battlelist detection
# # # # # # # #
# Your setup
client = 'medivia/'
delay = 0.5
fishing = False
fishdelay = 3
use_roh = False
### spell then runeloop int ###
#spell = ["encurso magni", 4] # HMM
# spell = ["encurso ignis, 4"] # Fireball
spell = ["encurso magni ignis", 4] # GFB
#spell = ["encuro vita", 4] # UH
#spell = ["encurso vita virtus", 2] # SD
#spell = ["encreo mas amplio", 2] # Explo
# Dont edit
mx = 0
my = 0
wx, hx = py.size()
py.FAILSAFE = False
# Actuals Functions
def findimage(image):
global mx, my
image = "images/" + client + image + ".png"
try:
mx, my = py.locateCenterOnScreen(image, confidence=0.95)
print("Found: " + image)
return True
except:
return False
def freehand():
print("Removing object from right hand")
if findimage('helmet'):
sx = mx+35
sy = my+55
py.click(sx, sy)
time.sleep(1)
py.dragTo(wx/2-100, hx/2, delay*3, button='left')
time.sleep(delay)
def pickup_spear():
print("Picking up spears")
if findimage('helmet'):
sx = mx+35
sy = my+55
py.click(wx/2, hx/2+60)
py.keyDown('ctrl')
time.sleep(1)
py.dragTo(sx, sy, delay, button='left')
py.keyUp('ctrl')
time.sleep(delay)
def makerune(handx, handy):
if findimage('blankrune'):
rune_x, rune_y = mx, my
py.click(x=rune_x, y=rune_y)
time.sleep(delay)
py.dragTo(handx, handy, delay, button='left')
time.sleep(delay)
py.write(spell[0], interval=0.01)
time.sleep(delay)
py.press('enter')
time.sleep(delay+0.5)
py.dragTo(rune_x, rune_y, delay, button='left')
time.sleep(delay)
def checkmana():
if findimage('health'):
mana90 = py.screenshot(region=(mx+110, my+32, 35, 15))
colors = mana90.getcolors()
for color in colors:
if (color[1] == (114, 96, 255, 255)) or (color[1] == (114, 96, 255)):
return True
print("No mana.")
return False
def eatfood():
# Eat all foods in the food directory
food_path = "images/" + client + "foods"
foods = listdir(food_path)
had_food = 0
for food in foods:
food_img = "foods/"+food[:-4]
if findimage(food_img):
had_food = 1
py.click(x=mx, y=my, button='right', clicks=5, interval=0.5)
time.sleep(delay)
break
if had_food == 0:
print("need to find food")
def killdwarf():
print("Killing Dwarfs")
mark=1
while True:
time.sleep(delay)
if findimage('dwarf_attack'):
time.sleep(2)
eatfood()
elif findimage('dwarf_attack2'):
time.sleep(2)
elif findimage('dwarf2'):
py.click(x=mx+30, y=(my+5))
time.sleep(delay)
elif findimage('dwarf'):
py.click(x=mx+30, y=(my+5))
time.sleep(delay)
py.write("incuro", interval=0.01)
time.sleep(delay)
py.press('enter')
else:
print("No dwarfs, walking")
if mark == 6:
mark = 1
mark_str = "marks/" + str(mark)
if findimage(mark_str):
py.click(x=mx, y=my)
time.sleep(10) # Allow for walking. Smarter way?
mark += 1
def fish():
print("Fishing ...\n")
base_x = 680; base_y = 785
length_x = 1090; length_y = 400
#water = py.screenshot(region=(base_x, base_y, length_x, length_y))
#water.save('/home/botter/PyBot/water.png')
for _ in range(0,50):
if findimage("fishingrod"):
py.click(mx, my)
time.sleep(0.05)
py.click(mx, my, button='right')
time.sleep(0.1)
py.click(base_x+randrange(length_x), base_y+randrange(length_y))
time.sleep(randrange(fishdelay))
else:
print("No fishingrod")
time.sleep(10)
def check_roh():
if findimage('helmet'):
rmx = mx-42+4 # ring middle x
rmy = my+88+4 # ring middle y
ring = py.screenshot(region=(mx-42, my+88, 9, 9))
colors = ring.getcolors()
if len(colors) < 20: # no roh, put new on
print("No ROH, putting one on if I can find one.")
if findimage('roh'):
py.click(mx, my)
time.sleep(1)
py.dragTo(rmx, rmy, delay*3, button='left')
time.sleep(delay)
else:
print("Already using ROH.")
# Main loop
print("Your script is running...\n")
# ------ Make Runes ------
try:
while True:
if checkmana():
if not findimage('handR'):
freehand()
findimage('handR')
handx, handy = mx, my
for _ in range(0,spell[1]):
makerune(handx, handy)
eatfood()
else:
if use_roh:
check_roh()
if fishing:
fish()
else:
time.sleep(20+randrange(180))
eatfood()
except KeyboardInterrupt:
print('Interrupted, exiting.')
# ------ Only Eat ------
# while True:
# print("Eating now..\n")
# eatfood()
# time.sleep(60*10)
# ------ Train Distance ------
# while True:
# pickup_spear()
# if checkmana():
# py.write("incuro", interval=0.01)
# time.sleep(delay)
# py.press('enter')
# time.sleep(delay)
# eatfood()
# time.sleep(15)