forked from slyautomation/osrs_basic_botting_functions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrafting.py
More file actions
186 lines (153 loc) · 5.15 KB
/
crafting.py
File metadata and controls
186 lines (153 loc) · 5.15 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
import pyautogui
import random
import time
import functions
import pytesseract
from functions import Image_count
from functions import skill_lvl_up
from functions import spaces
from functions import pick_item
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
from functions import find_Object_precise
from functions import exit_bank
from functions import Image_Rec_single
from functions import deposit_secondItem
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
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract'
iflag = False
options = {0: random_inventory,
1: random_combat,
2: random_skills,
3: random_quests,
4: random_pause}
def pick_gold_bars():
pick_item(1751 - 1280, 123) # pick in bank
random_breaks(0.5, 1.5)
def pick_sapphires():
pick_item(1751 - 1280, 123) # pick in bank
random_breaks(0.5, 1.5)
pick_item(1703 - 1280, 159) # pick in bank
random_breaks(0.5, 1.5)
def pick_silver_bars():
pick_item(1751 - 1280, 198) # 375 # pick in bank
random_breaks(0.5, 1.5)
def bank_spot_edgville():
find_Object_precise(1, 5, 0, 0, 860, 775) # green
def craft_spot_edgville():
find_Object_precise(0, 5, 0, 0, 860, 775) # red
def craft_gold_ring():
pick_item(1389 - 1280, 277) # 375
random_breaks(0.5, 1.5)
def craft_sapphire_ring():
pick_item(1439 - 1280, 277) # 375
random_breaks(0.5, 1.5)
def craft_bar_items(num, type, craft_item, run_time_minutes=360):
# run_time_minutes 6hrs by default
t_end = time.time() + 60 * run_time_minutes
while time.time() < t_end or num <= 0:
if type == 2:
j = round((num) / 13) + 1
else:
j = round((num) / 27) + 1
pick_options = {0: pick_gold_bars,
1: pick_silver_bars,
2: pick_sapphires
}
craft_options = {'gold_ring': craft_gold_ring,
'sapphire_ring': craft_sapphire_ring,
}
barlist = ['gold_bar.png', 'silver_bar.png', 'gold_bar.png']
while j > 0:
invent = invent_enabled()
print(invent)
if invent == 0:
pyautogui.press('esc')
bank_spot_edgville()
bank = get_bank_craft_items(type)
random_breaks(9.5, 11)
while bank == 0:
bank = get_bank_craft_items(type)
random_breaks(0.05, 0.2)
inv = Image_count(barlist[type]) # 0 or 1
craft_spot_edgville()
random_breaks(9.5, 11)
craft_options[craft_item]()
while inv > 0:
if skill_lvl_up() != 0:
print('level up')
random_breaks(0.2, 3)
pyautogui.press('space')
random_breaks(0.1, 3)
pyautogui.press('space')
a = random.randrange(0, 2)
# print(a)
spaces(a)
craft_spot_edgville()
random_breaks(1, 2)
craft_options[craft_item]()
inv = Image_count(barlist[type])
print(inv)
j -= 1
num = j
print("number of crafting left:", num)
random_breaks(0.4, 0.8)
def invent_enabled():
return Image_count('inventory_enabled.png', threshold=0.9)
def get_bank_craft_items(type):
bank = Image_count('bank_deposit.png', 0.75)
print("bank deposit open:", bank)
pick_options = {0: pick_gold_bars,
1: pick_silver_bars,
2: pick_sapphires
}
if bank > 0:
deposit_secondItem()
random_breaks(0.3, 0.5)
pick_options[type]()
exit_bank()
return bank
else:
print("bank inventory not found")
bank_spot_edgville()
return bank
# run_time_minutes 6hrs by default
if __name__ == "__main__":
craft_bar_items(2000, 0, 'gold_ring', run_time_minutes=360)