diff --git a/actions/default.json b/actions/default.json index 7574e23..c39fbeb 100644 --- a/actions/default.json +++ b/actions/default.json @@ -222,6 +222,12 @@ { "press": "esc" }, + { + "sleep": "1" + }, + { + "position": [1177, 672] + }, { "sleep": "2" }, @@ -429,9 +435,6 @@ }, { "position": [1680, 527] - }, - { - "sleep": 1 } ] }, diff --git a/actions/event.csv b/actions/event.csv index 86c7435..0370f1b 100644 --- a/actions/event.csv +++ b/actions/event.csv @@ -1,7 +1,7 @@ 事件名称,速刷选项,保守选项,回避选项 占卜,最近能发财,最近有危险,旅程会顺利 虫巢,不要随意押注,,深入虫巢 -超验之境,"点亮-离去","点亮-离去",战斗 +超验,"点亮-随机","点亮-随机",战斗 互动艺术,我加入你们-动作片,我加入你们-动作片, 电视购物频道,花费50宇宙碎片-离开这里,花费100宇宙碎片-你不感兴趣,损失40当前生命值 完美大挑战,走开,走开,花费 @@ -60,16 +60,19 @@ 星际和平公司升职记其二,派对-会议-培训,, 星际和平公司升职记其三,星际演讲,星际演讲, 星际和平公司升职记其四,获得2个1星方程,200-无尽权力, -咔嚓星际和平银行其一,走开,100, -咔嚓星际和平银行其二,取出-走开,走开, +星际和平银行其一,走开,100, +星际和平银行其二,取出-走开,走开, 孤独太空美虫模拟宇宙其一,舍弃100-祝福,,奇物 孤独太空美虫模拟宇宙其二,生命,随机奇物,拒绝 -萨里奥其一,全部角色各自损失,全部角色各自损失,舍弃1个奇物 -萨里奥其二,出来,出来, -萨里奥其三,让萨里出来,让萨里出来, +萨里其一,全部角色各自损失,全部角色各自损失,舍弃1个奇物 +萨里其二,出来,出来, +萨里其三,让萨里出来,让萨里出来, +里奥其一,全部角色各自损失,全部角色各自损失,舍弃1个奇物 +里奥其二,出来,出来, +里奥其三,让萨里出来,让萨里出来, 银河商人其一,100,,走开 银河忽悠其二,50,200,走开 银河好人其三,10,,走开 阮梅,就是-信仰星神,想要很多钱, 阮梅其二,就是-信仰星神,就是-信仰星神, -阮梅其三,一个突破想象力-给螺丝咕姆,一个突破想象力-给螺丝咕姆, +阮梅其三,想象力-给螺丝,想象力-给螺丝, diff --git a/diver.py b/diver.py index 412899e..7a54377 100644 --- a/diver.py +++ b/diver.py @@ -39,10 +39,9 @@ def __init__(self, debug=0, nums=-1, speed=0): self.floor = 0 self.allow_e = 1 self.count = self.my_cnt = 0 - if not hasattr(self, 'hot_init'): - self.debug = debug - self.nums = nums - self.speed = speed + self.debug = debug + self.nums = nums + self.speed = speed self.init_tm = time.time() self.area_now = None self.action_history = [] @@ -190,7 +189,7 @@ def read_csv(self, file_path, name): return data def clean_text(self, text, char=1): - symbols = r"[!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~鈥斺溾濃樷櫬烩炩β仿柯÷Bモ偓漏庐鈩⒙奥泵访椔堵р癩锛屻傦紒锛燂紱锛氾紙锛夈愩戙屻嶃娿嬨侊骏" + symbols = r"[!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~鈥斺溾濃樷櫬烩炩β仿柯÷Bモ偓漏庐鈩⒙奥泵访椔堵р癩锛屻傦紒锛燂紱锛氾紙锛夈愩戙屻嶃娿嬨侊骏 " if char: symbols += r"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" translator = str.maketrans('', '', symbols) @@ -228,11 +227,13 @@ def select_save(self): def close_and_exit(self, click=True): self.press('esc') - if self.debug: + if self.debug and self.floor < 13: with open('test.txt', 'a') as f: format_string = "%H:%M:%S" formatted_time = time.strftime(format_string, time.localtime()) f.write(formatted_time + '\n') + while 1: + time.sleep(1) time.sleep(2.5) self.init_floor() if not click: @@ -302,7 +303,7 @@ def find_portal(self, type=None): prefer_portal.update({'棣栭':4, '浼戞暣':4}) tm = time.time() text = self.ts.find_with_box([0,1920,0,540], forward=1, mode=2) - portal = {'score':-1,'nums':0} + portal = {'score':0,'nums':0,'type':''} for i in text: if ('鍖' in i['raw_text'] or '鍩' in i['raw_text']) and (i['box'][0] > 400 or i['box'][2] > 60): portal_type = self.get_text_type(i['raw_text'], prefer_portal) @@ -310,13 +311,12 @@ def find_portal(self, type=None): i.update({'score':prefer_portal[portal_type]+10*(portal_type==type), 'type':portal_type, 'nums':portal['nums']+1}) if i['score'] > portal['score']: portal = i + elif '鍐掗櫓' in i['raw_text']: + portal['nums'] += 1 ocr_time = time.time() - tm self.ocr_time_list = self.ocr_time_list[-5:] + [ocr_time] print(f'璇嗗埆鏃堕棿:{int(ocr_time*1000)}ms', text, portal) - if portal['score'] == -1: - return None - else: - return portal + return portal def sleep(self, tm=2): time.sleep(tm) @@ -334,10 +334,12 @@ def aim_portal(self, portal): return portal time.sleep(0.2) portal_after = self.find_portal(portal['type']) - if portal_after is None: - return portal - else: - portal = portal_after + if portal_after['score'] == 0: + self.press('w', 1) + portal_after = self.find_portal(portal['type']) + if portal_after['score'] == 0: + return portal + portal = portal_after return portal def forward_until(self, text_list=[], timeout=5, moving=0): @@ -356,6 +358,7 @@ def forward_until(self, text_list=[], timeout=5, moving=0): self.press('f') return 1 else: + tm += 0.7 keyops.keyDown('w') time.sleep(0.5) keyops.keyUp('w') @@ -368,7 +371,7 @@ def portal_opening_days(self, aimed=0, static=0, deep=0): return if deep == 0: self.portal_cnt += 1 - portal = None + portal = {'score':0,'nums':0,'type':''} moving = 0 if static: # win32api.mouse_event(win32con.MOUSEEVENTF_MOVE, 0, int(100 * self.multi * self.scale)) @@ -377,10 +380,10 @@ def portal_opening_days(self, aimed=0, static=0, deep=0): self.mouse_move(angle) time.sleep(0.2) portal = self.find_portal() - if portal is not None: + if portal['score']: break if self.floor in [1,2,4,5,6,7,9,10]: - if portal is not None and portal['nums'] == 1 and portal['score'] < 2: + if portal['nums'] == 1 and portal['score'] < 2: portal_pre = portal portal_type = portal['type'] bias = 0 @@ -389,24 +392,24 @@ def portal_opening_days(self, aimed=0, static=0, deep=0): bias += angles[i] time.sleep(0.2) portal_after = self.find_portal() - if portal_after is not None and portal_type != portal_after['type']: + if portal_after['score'] and portal_type != portal_after['type']: portal = portal_after break if portal['type'] == portal_type: portal = portal_pre self.mouse_move(-bias) tm = time.time() - while time.time() - tm < 5 + 2 * (portal is not None): + while time.time() - tm < 5 + 2 * (portal['score'] != 0): if aimed == 0: - if portal is None: + if portal['score'] == 0: portal = self.find_portal() else: - if self.forward_until([portal['type'] if portal else '鍖哄煙'], timeout=3, moving=moving): + if self.forward_until([portal['type'] if portal['score'] else '鍖哄煙'], timeout=3, moving=moving): self.init_floor() return else: moving = 0 - if portal is not None and not aimed: + if portal['score'] and not aimed: if moving: print('stop moving') keyops.keyUp('w') @@ -416,7 +419,7 @@ def portal_opening_days(self, aimed=0, static=0, deep=0): else: print('aiming...') tmp_portal = self.aim_portal(portal) - if tmp_portal is None: + if tmp_portal['score'] == 0: self.portal_opening_days(aimed=0, static=1, deep=deep+1) return else: @@ -424,7 +427,7 @@ def portal_opening_days(self, aimed=0, static=0, deep=0): aimed = 1 moving = 1 keyops.keyDown('w') - elif portal is None: + elif portal['score'] == 0: if not moving: keyops.keyDown('w') moving = 1 @@ -446,6 +449,7 @@ def event(self): tm = time.time() while time.time() - tm < 20: title_text = self.merge_text(self.ts.find_with_box([170, 850, 900, 1020], redundancy=0), char=0) + print(title_text) if event_id[0] == -1: for i, e in enumerate(self.event_prior): if e in title_text and len(e) > len(event_id[1]): @@ -453,6 +457,10 @@ def event(self): start = self.now_event == event_id[1] self.now_event = event_id[1] print('event_id:', event_id) + if self.debug and event_id[0] == -1: + print(self.ts.res) + while 1: + time.sleep(1) if '浜嬩欢' not in self.merge_text(self.ts.find_with_box([92, 195, 54, 88])): return @@ -523,9 +531,11 @@ def find_event_text(self, save=0): print('event_text:', text) for i in text: box = i['box'] - if 'ms' in i['raw_text'] or '鐘舵佹晥' in i['raw_text'] or len(i['raw_text']) < 2 \ + if 'ms' in i['raw_text'] or '鐘舵佹晥' in i['raw_text'] or len(i['raw_text']) < 2 or (box[0] > 1470 and box[2] < 75)\ or (box[0] > 1800 and box[2] < 120) or (box[0] > 1600 and box[2] > 290) or (box[1] < 400 and box[3] < 160): continue + if '?' not in i['raw_text'] and '锛' not in i['raw_text'] and len(self.clean_text(i['raw_text'], 1)) == 0: + continue w, h = box[1] - box[0], box[3] - box[2] if w < 40 or h > 40: continue @@ -553,17 +563,24 @@ def align_event(self, key, deep=0): if self.check_f(is_in=['浜嬩欢','濂栧姳','閬亣','浜ゆ槗']): self.press('f') return - elif self.check_f(is_in=['娣锋矊','鑽']): - self.press('f') - time.sleep(2.5) - self.run_static(action_list=['娣锋矊鑽'], skip_check=1) - tm = time.time() - while time.time() - tm < 3: - self.ts.forward(self.get_screen()) - res = self.run_static(action_list=['鐐瑰嚮绌虹櫧澶勫叧闂']) - if len(res): - tm = time.time() - return + # elif self.check_f(is_in=['娣锋矊','鑽']): + # self.press('f') + # time.sleep(2.5) + # self.run_static(action_list=['娣锋矊鑽'], skip_check=1) + # tm = time.time() + # while time.time() - tm < 3: + # self.ts.forward(self.get_screen()) + # res = self.run_static(action_list=['鐐瑰嚮绌虹櫧澶勫叧闂']) + # if len(res): + # tm = time.time() + # time.sleep(2) + # if deep == 0: + # self.align_event(key, deep+1) + # return + + if not event_text and key == 'a': + event_text = 950 + if event_text: if abs(event_text - 950) > 40: self.press(key,0.2) @@ -585,10 +602,8 @@ def align_event(self, key, deep=0): for _ in range(-sub): self.press('a',0.2) time.sleep(0.1) - self.forward_until(['浜嬩欢','濂栧姳','閬亣','浜ゆ槗'], timeout=3, moving=0) + self.forward_until(['浜嬩欢','濂栧姳','閬亣','浜ゆ槗'], timeout=2.5, moving=0) else: - if key == 'a': - return if deep < 3: self.press('w',[0,0.3,0.5][deep]) self.align_event(key, deep+1) @@ -698,10 +713,10 @@ def area(self): pyautogui.click() time.sleep(0.8) keyops.keyDown('w') - time.sleep(1.3) + time.sleep(1.6) self.press('d',0.4) keyops.keyUp('w') - time.sleep(1) + time.sleep(0.6) self.portal_opening_days(static=1) elif area_now == '棣栭': if self.floor == 13 and self.area_state > 0: @@ -711,8 +726,8 @@ def area(self): if self.area_state == 0: self.press('w',3) for c in config.skill_char: - if c in self.team_member and self.allow_e: - self.press(str(self.team_member[c]+1)) + if (c in self.team_member or c.isdigit()) and self.allow_e: + self.press(int(c) if c.isdigit() else str(self.team_member[c]+1)) time.sleep(0.8) self.check_dead() self.skill() @@ -775,7 +790,7 @@ def area(self): self.press('w', 0.5) self.portal_opening_days(static=1) elif area_now == '璐㈠瘜': - self.press('w',3) + self.press('w',2.7) pyautogui.click() time.sleep(0.6) keyops.keyDown('w') @@ -784,7 +799,8 @@ def area(self): self.press('a', 0.5) time.sleep(0.35) keyops.keyUp('w') - if self.find_portal() is None: + time.sleep(0.6) + if self.find_portal()['score'] == 0: self.press('a', 0.4) self.press('s', 0.7) self.press('w', 0.5) @@ -930,8 +946,6 @@ def on_key_press(self, event): self.stop() def start(self): - self.hot_init = 1 - self.__init__() self._stop = False keyboard.on_press(self.on_key_press) self.keys = KeyController(self) diff --git a/info_example.yml b/info_example.yml index 04a6ce4..f1ca160 100644 --- a/info_example.yml +++ b/info_example.yml @@ -32,14 +32,14 @@ config: # 浼犻侀棬浼樺厛绾э紝1-3锛3浠h〃浼樺厛绾ф渶楂橈紝1浠h〃浼樺厛绾ф渶浣 # 濡傞渶鑷畾涔夎灏唀nable_portal_prior璁句负1 # 鍙兘淇敼鏁板瓧锛屼笉瑕佷慨鏀瑰悕绉 - enable_portal_prior: 1 + enable_portal_prior: 0 portal_prior: 鍟嗗簵: 1 璐㈠瘜: 1 - 鎴樻枟: 1 - 閬亣: 1 + 鎴樻枟: 2 + 閬亣: 2 濂栧姳: 3 - 浜嬩欢: 1 + 浜嬩欢: 3 key_mapping: # 浜や簰閿紝鍙兘鏄崟涓瓧姣 diff --git a/utils/diver/config.py b/utils/diver/config.py index c2d91f5..1851d97 100644 --- a/utils/diver/config.py +++ b/utils/diver/config.py @@ -65,6 +65,9 @@ def update_skill(self, skill: List[str]): i = self.match[i] if i in self.all_list: self.skill_char.append(i) + elif i in ['1', '2', '3', '4']: + self.skill_char.append(i) + def read(self): if os.path.exists(os.path.join(self.abspath, self.text)): diff --git a/utils/diver/ocr.py b/utils/diver/ocr.py index 82fa91c..6de9a3c 100644 --- a/utils/diver/ocr.py +++ b/utils/diver/ocr.py @@ -120,10 +120,10 @@ def box_contain(self, box_out, box_in, redundancy): def find_with_box(self, box=None, redundancy=10, forward=0, mode=0): if forward and box is not None: self.forward(self.filter_non_white(self.father.get_screen()[box[2]:box[3],box[0]:box[1]], mode=mode)) - # if box[3]==540 or box[3] == 350: - # tm = str(int(time.time()*100)%1000000) - # cv.imwrite('img/'+tm+'.jpg',self.father.screen[box[2]:box[3],box[0]:box[1]]) - # cv.imwrite('img/'+tm+'w.jpg',self.filter_non_white(self.father.screen[box[2]:box[3],box[0]:box[1]])) + if box[3]==540 or box[3] == 350 and self.father.debug: + tm = str(int(time.time()*100)%1000000) + cv.imwrite('img/'+tm+'.jpg',self.father.screen[box[2]:box[3],box[0]:box[1]]) + cv.imwrite('img/'+tm+'w.jpg',self.filter_non_white(self.father.screen[box[2]:box[3],box[0]:box[1]])) ans = [] for res in self.res: if box is None: diff --git a/utils/log.py b/utils/log.py index 7358bac..58dc495 100644 --- a/utils/log.py +++ b/utils/log.py @@ -52,7 +52,8 @@ def set_debug(debug: bool = False): def my_print(*args, **kwargs): log.info(" ".join(map(str, args))) - print(*args, **kwargs) + if len(kwargs): + print(*args, **kwargs) def print_exc(): with io.StringIO() as buf, open("logs/error_log.txt", "a") as f: