forked from slyautomation/osrs_basic_botting_functions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclay_beginner_money_maker.py
More file actions
341 lines (301 loc) · 10.4 KB
/
clay_beginner_money_maker.py
File metadata and controls
341 lines (301 loc) · 10.4 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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
from PIL import ImageGrab
import core
import cv2
import numpy as np
global hwnd
global iflag
global icoord
import functions
from functions import Image_count
from functions import screen_Image
from functions import Image_to_Text
from functions import resizeImage
from functions import find_Object_precise
from functions import random_combat
from functions import random_quests
from functions import random_skills
from functions import random_inventory
from functions import random_breaks
import time
import random
import pyautogui
global hwnd
global iflag
global icoord
iflag = False
global newTime_break
newTime_break = False
global timer
global timer_break
global ibreak
def random_break(start, c):
global newTime_break
startTime = time.time()
# 1200 = 20 minutes
a = random.randrange(0, 4)
if startTime - start > c:
options[a]()
newTime_break = True
def randomizer(timer_breaks, ibreaks):
global newTime_break
global timer_break
global ibreak
random_break(timer_breaks, ibreaks)
if newTime_break == True:
timer_break = timer()
ibreak = random.randrange(600, 2000)
newTime_break = False
# b = random.uniform(4, 5)
def timer():
startTime = time.time()
return startTime
def random_pause():
b = random.uniform(20, 250)
print('pausing for ' + str(b) + ' seconds')
time.sleep(b)
newTime_break = True
options = {0: random_inventory,
1: random_combat,
2: random_skills,
3: random_quests,
4: random_pause}
def rim_minetobank():
c = random.uniform(14, 15)
x = 45
y = 5
while Image_Rec_single('rim_mine_spot1.png', 'rim mining spot', x, y, 0.7, 'left') != True:
print('finding 1st step to bank')
time.sleep(c)
print('1st step to bank')
c = random.uniform(9, 10)
x = 10
y = 1
while Image_Rec_single('port_sarim_jewl.png', 'To Port Sarmin Jewlery', x, y, 0.7, 'left') != True:
print('finding 2nd step to bank')
time.sleep(c)
print('2nd step to bank')
c = random.uniform(9, 10)
x = 52
y = -25
while Image_Rec_single('port_sarim_jewl.png', 'To Port Sarmin Jewlery', x, y, 0.7, 'left') != True:
print("finding 3rd step to bank")
time.sleep(c)
print('3rd step to bank')
c = random.uniform(11, 12)
x = 75
y = 25
while Image_Rec_single('port_sarim_spot_water.png', 'To Port Sarmin Watery', x, y, 0.7, 'left') != True:
print("finding 4th step to bank")
time.sleep(c)
print('4th step to bank')
b = random.uniform(0.175, 0.677)
x = random.randrange(750, 755)
print('x: ', x)
y = random.randrange(175, 180)
print('y: ', y)
c = random.uniform(10, 12)
pyautogui.click(x, y, 1, duration=b, button='left')
time.sleep(c)
print('5th step to bank')
b = random.uniform(0.175, 0.677)
x = random.randrange(750, 755) # 1755,1765
print('x: ', x)
y = random.randrange(140, 145) # 175,185
print('y: ', y)
c = random.uniform(9, 10)
pyautogui.click(x, y, 1, duration=b, button='left')
print('last step to bank')
time.sleep(c)
c = random.uniform(2.1, 3)
find_banker()
print('finding deposit box')
time.sleep(c)
depositbox()
print('finished deposit end of function')
c = random.uniform(1, 5)
time.sleep(c)
def rim_minetoclay():
print('start of function')
b = random.uniform(0.175, 0.677)
x = random.randrange(710, 725)
print('x: ', x)
y = random.randrange(50, 60)
print('y: ', y)
c = random.uniform(10, 12)
pyautogui.click(x, y, 1, duration=b, button='left')
time.sleep(c)
print('1st step to mining clay')
c = random.uniform(11, 12)
x = -5
y = -10
while Image_Rec_single('clay_deposit_spot2.png', 'To Port Sarmin Watery', x, y, 0.9, 'left') != True:
Image_Rec_single('clay_deposit_spot1.png', 'To Port Sarmin Watery', x, y, 0.9, 'left')
Image_Rec_single('clay_deposit_spot3.png', 'To Port Sarmin Watery', x, y, 0.9, 'left')
print('finding 2nd clay mine step')
time.sleep(c)
print('2nd step to mine clay')
c = random.uniform(11, 12)
x = 0
y = 40
while Image_Rec_single('port_sarim_spot_water.png', 'To Port Sarmin Watery', x, y, 0.7, 'left') != True:
print('finding 2nd clay mine step')
time.sleep(c)
print('2nd step to mine clay')
c = random.uniform(9, 10)
x = -15
y = -10
while Image_Rec_single('port_sarim_jewl.png', 'To Port Sarmin Jewlery', x, y, 0.7, 'left') != True:
print('finding 3rd clay mine step')
time.sleep(c)
print('3rd step to mine clay')
c = random.uniform(9, 10)
x = -50
y = 30
while Image_Rec_single('port_sarim_jewl.png', 'To Port Sarmin Jewlery', x, y, 0.7, 'left') != True:
print('finding 4th clay mine step')
time.sleep(c)
print('4th step to mine clay')
c = random.uniform(14, 15)
x = -8
y = 33
while Image_Rec_single('rim_mine_spot1.png', 'rim mining spot', x, y, 0.7, 'left') != True:
print('finding 5th clay mine step')
time.sleep(c)
print('5th step to mine clay')
def find_banker():
find_Object_precise(0, 5, 0, 0, 610, 775) # red
def depositbox():
c = random.uniform(3.5, 4.5)
b = random.uniform(0.25, 0.65)
x = random.randrange(370, 390) # 950,960
print('x: ', x)
y = random.randrange(440, 460) # 490,500
print('y: ', y)
pyautogui.moveTo(x, y, duration=b)
b = random.uniform(0.1, 0.19)
pyautogui.click(duration=b)
print('depositing clay')
def Image_Rec_single(image, event, iwidth, iheight, threshold, clicker, ispace=5):
global icoord
global iflag
screen_Image(0, 0, 860, 820)
img_rgb = cv2.imread('screenshot.png')
# print('screenshot taken')
img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
template = cv2.imread(image, 0)
w, h = template.shape[::-1]
pt = None
# print('getting match requirements')
res = cv2.matchTemplate(img_gray, template, cv2.TM_CCOEFF_NORMED)
threshold = threshold
loc = np.where(res >= threshold)
# print('determine loc and threshold')
# if len(loc[0]) == 0:
# exit()
iflag = False
event = event
for pt in zip(*loc[::-1]):
cv2.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0, 0, 255), 2)
# print('result of pt')
if pt is None:
iflag = False
# print(event, 'Not Found...')
else:
iflag = True
# cv2.imwrite('res.png', img_rgb)
# print(event, 'Found...')
x = random.randrange(iwidth, iwidth + ispace)
y = random.randrange(iheight, iheight + ispace)
icoord = pt[0] + x
icoord = (icoord, pt[1] + y)
b = random.uniform(0.2, 0.7)
pyautogui.moveTo(icoord, duration=b)
b = random.uniform(0.1, 0.3)
pyautogui.click(icoord, duration=b, button=clicker)
return iflag
def Miner_Image_quick():
left = 150
top = 150
right = 600
bottom = 750
im = ImageGrab.grab(bbox=(left, top, right, bottom))
im.save('miner_img.png', 'png')
def findarea_single(ore, cropx=150, cropy=150):
Miner_Image_quick()
image = cv2.imread(r"miner_img.png")
# B, G, R
#--------------------- ADD OBJECTS -------------------
tin = ([103, 86, 65], [145, 133, 128])
copper = ([35, 70, 120], [65, 110, 170])
coal = ([20, 30, 30], [30, 50, 50])
iron = ([15, 20, 40], [25, 40, 70])
iron2 = ([17, 20, 42], [25, 38, 70])
clay = ([50, 105, 145], [60, 125, 165])
red = ([0, 0, 180], [80, 80, 255])
green = ([0, 180, 0], [80, 255, 80])
amber = ([0, 160, 160], [80, 255, 255])
# --------------------- ADD OBJECTS -------------------
ore_list = [tin, copper, coal, iron, iron2, clay, red, green, amber]
boundaries = [ore_list[ore]]
# loop over the boundaries
for (lower, upper) in boundaries:
# create NumPy arrays from the boundaries
lower = np.array(lower, dtype="uint8")
upper = np.array(upper, dtype="uint8")
# find the colors within the specified boundaries and apply
# the mask
mask = cv2.inRange(image, lower, upper)
output = cv2.bitwise_and(image, image, mask=mask)
ret, thresh = cv2.threshold(mask, 40, 255, 0)
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
if len(contours) != 0:
# find the biggest countour (c) by the area
c = max(contours, key=cv2.contourArea)
x, y, w, h = cv2.boundingRect(c)
x = random.randrange(x + 5, x + max(w - 5, 6)) + cropx # 950,960
print('x: ', x)
y = random.randrange(y + 5, y + max(h - 5, 6)) + cropy # 490,500
print('y: ', y)
b = random.uniform(0.1, 0.2)
pyautogui.moveTo(x, y, duration=b)
b = random.uniform(0.02, 0.07)
pyautogui.click(duration=b)
def count_gems():
return Image_count('gem_icon.png')
def count_geo():
return Image_count('geo_icon.png')
def count_gems2():
return Image_count('gem_icon2.png')
def inv_count(name):
return Image_count(name + '_ore.png')
def moneymaker_clay(Take_Human_Break=False):
j = 0
while j < 10:
randomizer(timer_break, ibreak)
r = random.uniform(0.1, 1)
inventory = int(inv_count('clay')) + int(count_gems()) + int(count_gems2()) + int(count_geo())
print('ore: ', int(inventory), "| gems: ", int(count_gems() + count_gems2()), "| clues: ", int(count_geo()))
if inventory > 27:
random_breaks(0.2, 0.7)
rim_minetobank()
rim_minetoclay()
resizeImage()
mined_text = Image_to_Text('thresh', 'textshot.png')
if mined_text.lower() != 'mining' and mined_text.lower() != 'mininq':
print('not mining')
findarea_single(6)
if Take_Human_Break:
c = random.triangular(0.05, 30, 0.5)
time.sleep(c)
#rim_minetoclay()
#rim_minetobank()
#"""
resizeImage()
x = random.randrange(100, 250)
y = random.randrange(400, 500)
pyautogui.click(x, y, button='right')
ibreak = random.randrange(300, 2000)
print('will break in ' + str(ibreak / 60) + ' minutes')
timer_break = timer()
moneymaker_clay(True)
#"""