-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathstatus.py
145 lines (115 loc) · 4.21 KB
/
status.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
import cv2 as cv
from time import sleep
import bimage
import bmath
import settings
def loading_screen():
sleep(10)
# Loading screen.
# print('Loading screen...')
# count = 0
# # Wait until the inventory image appears. This will mean player is connected.
# for i in range(0, 100):
# loc = bimage.search_object(dir='icons\\',
# name='inventory_button',
# method=cv.TM_CCORR_NORMED,
# hl=1,
# threshold=0.4,
# top_left=settings.client.navigation['top_left'],
# size=settings.client.navigation['window_size'])
# if loc:
# count += 1
# if count >= 10:
# break
# if count >= 10:
# return True
# return False
return True
def hud(name, threshold=20):
loc = bimage.search_object(dir='icons\\hud\\',
name=name,
method=cv.TM_SQDIFF,
hl=0,
threshold=threshold,
top_left=settings.client.navigation['top_left'],
size=settings.client.navigation['window_size'])
if loc:
return True
return False
def in_character_selection():
# Check if in character selection.
loc = bimage.search_object(dir='icons\\',
name='character_selection',
method=cv.TM_SQDIFF_NORMED,
hl=1,
threshold=0.5,
top_left=settings.client.navigation['top_left'],
size=settings.client.navigation['window_size'])
if loc:
return True
return False
def is_stuck():
hp = get_hp()
stuck = False
if len(settings.client.hp_history) > 0:
stuck = hp > settings.client.hp_history[-1]
if hp == 100 or stuck:
while len(settings.client.hp_history) <= 5:
settings.client.hp_history.append(get_hp())
sleep(1)
if len(settings.client.hp_history) < 5:
settings.client.hp_history.append(hp)
print('HP History:', settings.client.hp_history)
elif len(settings.client.hp_history) >= 5:
print('HP History:', settings.client.hp_history)
same_hp = 0
for i in range(1, len(settings.client.hp_history)):
if settings.client.hp_history[i] >= settings.client.hp_history[i - 1]:
same_hp += 1
if same_hp > 3:
print('Stuck.')
settings.client.count_stuck += 1
return True
return False
def kicked():
loc = bimage.search_object(dir='icons',
name='login',
method=cv.TM_SQDIFF,
hl=0,
threshold=20,
top_left=settings.client.navigation['top_left'],
size=settings.client.navigation['window_size'])
if loc:
return True
return False
def dead():
loc = bimage.search_object(dir='icons',
name='revive',
method=cv.TM_SQDIFF_NORMED,
hl=0,
threshold=0.2,
top_left=settings.client.navigation['top_left'],
size=settings.client.navigation['window_size'])
if loc:
return True
return False
def get_hp():
top_left = settings.get_value_by_name(settings.relative_values, 'top-left').value
hp = settings.get_value_by_name(settings.relative_values, 'hp').value
pos = bmath.get_relative(top_left, settings.client.navigation['top_left'], hp)
size = settings.get_value_by_name(settings.relative_values, 'hp-rectangle').value
text = bimage.get_text(point=pos, size=size, pars='--psm 8 --oem 1 -c tessedit_char_whitelist=0123456789%')
# Fix imperfections to fit the expected values.
text = bmath.fix_hp(text)
return text
def is_farming():
loc = bimage.search_object(dir='icons\\',
name='questionmark',
method=cv.TM_SQDIFF_NORMED,
hl=0,
threshold=0.2,
top_left=settings.client.navigation['top_left'],
size=settings.client.navigation['window_size'])
if loc:
return True
return False