-
Notifications
You must be signed in to change notification settings - Fork 0
/
cook.py
232 lines (176 loc) · 6.04 KB
/
cook.py
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
import mouse
import utils
import pyautogui
import numpy as np
from time import sleep
from time import time
bankInterfacePath = "Fletching/Interface/Bank Interface.png"
clayInterfacePath = "Cooking/clayInterface.png"
cookInterfacePath = "Cooking/cookInterface.png"
portableKeyPath = "Cooking/portableKey.png"
portableClickInterfacePath = "Cooking/portableClickInterface.png"
extendInterfacePath = "Cooking/extendInterface.png"
PRESET_KEY = '1'
PORTABLE_PRESET = '2'
SILVERHAWK_KEY = 'q'
def extendPortable(portableKeyCoordinates, extendInterfaceLocation, tries = 0):
(x, y, xT, yT) = portableKeyCoordinates
(x, y, xT, yT) = (5 + x//2, 5 + y//2, -5 + xT//2, -5 + yT//2)
if tries == 10:
print("Failed to extend portable")
return False
def moveToPortableKey():
mouse.moveRect(x, y, xT, yT)
sleepDuration = -1
while sleepDuration < 0:
sleepDuration = np.random.normal(0.2, 0.01)
sleep(sleepDuration)
pyautogui.click(button='right')
portableClickLocation = utils.Location()
succ = utils.performAction(moveToPortableKey,
utils.makeSuccess(portableClickLocation, portableClickInterfacePath, False))
if not succ:
print("Failed to right click portable key, retrying")
extendPortable(portableKeyCoordinates, extendInterfaceLocation, tries = tries + 1)
sleep(3)
(x, y, xT, yT) = utils.convert(portableClickLocation.getLoc())
(x, y, xT, yT) = (x//2, y//2, xT//2, yT//2)
mouse.moveRect(x, y, xT, yT, teleportRandom=False)
pyautogui.click()
sleep(3)
if not utils.checkLocation(extendInterfaceLocation, extendInterfacePath):
print("Failed to open extend interface, retrying")
extendPortable(portableKeyCoordinates, extendInterfaceLocation, tries = tries + 1)
sleepDuration = -1
while sleepDuration < 0:
sleepDuration = np.random.normal(0.2, 0.2)
utils.spamPress('1')
sleep(sleepDuration)
utils.spamPress('enter')
sleep(3)
if utils.checkLocation(extendInterfaceLocation, extendInterfacePath):
print("Failed to extend portable, retrying")
extendPortable(portableKeyCoordinates, extendInterfaceLocation, tries = tries + 1)
return True
def runBot():
extendInterfaceLocation = utils.Location()
bankLocation = utils.Location()
clayInterfaceLocation = utils.Location()
cookInterfaceLocation = utils.Location()
silverhawkLocation = utils.Location()
portableKeyCoordinates = None
sleep(2)
portableKeyCoordinates = utils.convert(pyautogui.locateOnScreen(portableKeyPath))
print(portableKeyCoordinates)
rangeCoordinates = utils.getBoundingRectangle()
bankCoordinates = utils.getBoundingRectangle()
silverhawkCoordinates = utils.getBoundingRectangle()
def openBank():
x, y, xT, yT = bankCoordinates
mouse.moveRect(x, y, xT, yT)
pyautogui.click()
def openRange():
x, y, xT, yT = rangeCoordinates
mouse.moveRect(x, y, xT, yT)
pyautogui.click()
def extendSilverhawk():
x, y, xT, yT = silverhawkCoordinates
mouse.moveRect(x, y, xT, yT)
pyautogui.click()
succ = extendPortable(portableKeyCoordinates, extendInterfaceLocation)
if not succ:
return
sleep(2)
utils.performAction(extendSilverhawk, lambda : True)
sleep(2)
portableTimer = time()
startTime = time()
while True:
if time() - portableTimer > 50 * 60:
succ = utils.performAction(openBank,
utils.makeSuccess(bankLocation, bankInterfacePath, False))
if not succ:
print("Failed to open bank")
return False
sleep(3)
succ = utils.performAction(utils.makeKeyPressAction(PORTABLE_PRESET),
utils.makeSuccess(bankLocation, bankInterfacePath, True))
if not succ:
print("Failed to withdraw preset")
return False
succ = extendPortable(portableKeyCoordinates, extendInterfaceLocation)
if not succ:
return
sleep(2)
utils.performAction(extendSilverhawk, lambda : True)
sleep(2)
portableTimer = time() - 30
if time() - startTime > 16 * 3600:
print("Returning after finishing")
return
succ = utils.performAction(openBank,
utils.makeSuccess(bankLocation, bankInterfacePath, False))
print("Opened bank...")
if not succ:
print("Failed to open bank")
return
sleep(1)
succ = utils.performAction(utils.makeKeyPressAction(PRESET_KEY),
utils.makeSuccess(bankLocation, bankInterfacePath, True))
print("Withdrew food...")
if not succ:
print("Failed to withdraw food")
return
sleep(1)
succ = utils.performAction(openRange,
utils.makeSuccess(clayInterfaceLocation, clayInterfacePath, False))
print("Clicked on portable...")
if not succ:
print("Failed to click on portable")
return
sleep(1)
succ = utils.performAction(utils.makeKeyPressAction('1'),
utils.makeSuccess(cookInterfaceLocation, cookInterfacePath, False))
print("Selected shaping clay...")
if not succ:
print("Failed to select shaping clay")
return
succ = utils.performAction(utils.makeKeyPressAction('space'),
utils.makeSuccess(cookInterfaceLocation, cookInterfacePath, True))
print("Started shaping clay...")
if not succ:
print("Failed to start shaping clay")
return
sleepDuration = -1
while sleepDuration < 0:
sleepDuration = np.random.normal(15.7, 0.6)
print(f"Sleeping {sleepDuration} seconds")
sleep(sleepDuration)
succ = utils.performAction(openRange,
utils.makeSuccess(clayInterfaceLocation, clayInterfacePath, False))
print("Clicked on portable...")
if not succ:
print("Failed to click on portable")
return
sleep(1)
succ = utils.performAction(utils.makeKeyPressAction('2'),
utils.makeSuccess(cookInterfaceLocation, cookInterfacePath, False))
print("Selected firing clay...")
if not succ:
print("Failed to select shaping clay")
return
succ = utils.performAction(utils.makeKeyPressAction('space'),
utils.makeSuccess(cookInterfaceLocation, cookInterfacePath, True))
print("Started firing clay...")
if not succ:
print("Failed to start shaping clay")
return
sleepDuration = -1
while sleepDuration < 0:
sleepDuration = np.random.normal(50, 1.2)
print(f"Sleeping {sleepDuration} seconds")
sleep(sleepDuration)
if __name__ == "__main__":
runBot()
failureCause = pyautogui.screenshot()
failureCause.save("/Users/kunaalsharma/Desktop/fuck.png")