From 5b095c9d40fa32e59c1b44fcb749bdfae83731ee Mon Sep 17 00:00:00 2001 From: mslxl Date: Fri, 18 Mar 2022 12:18:33 +0800 Subject: [PATCH 1/8] =?UTF-8?q?fix.=20=E6=9E=81=E7=AB=AF=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E4=B8=8B=E6=97=A0=E6=B3=95=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E5=85=AC=E6=8B=9B=E5=B9=B6=E8=BF=9B=E5=85=A5=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resource/tasks.json | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/resource/tasks.json b/resource/tasks.json index a01c44cdeb..bbd78559ef 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -898,6 +898,26 @@ 255 ], "next": [ + "RecruitBeginLoading", + "RecruitBegin" + ] + }, + "RecruitBeginLoading": { + "algorithm": "OcrDetect", + "action": "doNothing", + "text": [ + "正在提交", + "反馈至神经" + ], + "roi": [ + 700, + 600, + 300, + 120 + ], + "next": [ + "RecruitBeginLoading", + "Recruit", "RecruitBegin" ] }, From e0b4c3671596f891c7abc94b8f597cd5940d8734 Mon Sep 17 00:00:00 2001 From: mslxl Date: Fri, 18 Mar 2022 13:15:45 +0800 Subject: [PATCH 2/8] =?UTF-8?q?fix.=20=E6=9E=81=E7=AB=AF=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E4=B8=8B=E6=97=A0=E6=B3=95=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=85=AC=E6=8B=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 点击聘用候选人后游戏进入漫长的加载,此时MAA会执行尝试RecruitSkip, RecruitSkipWithoutButton等一系列任务(大概会全失败吧)后开始基建任务,待游戏加载完成后进入开简历界面,这时MAA既无法点击SKIP按钮,也无法正常执行基建任务 --- resource/tasks.json | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/resource/tasks.json b/resource/tasks.json index bbd78559ef..35d0e591b1 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -932,6 +932,27 @@ 420 ], "next": [ + "RecruitFinishLoading", + "RecruitFinish", + "RecruitSkip", + "RecruitSkipWithoutButton" + ] + }, + "RecruitFinishLoading":{ + "algorithm": "OcrDetect", + "action": "doNothing", + "text": [ + "正在提交", + "反馈至神经" + ], + "roi": [ + 700, + 600, + 300, + 120 + ], + "next": [ + "RecruitFinishLoading", "RecruitFinish", "RecruitSkip", "RecruitSkipWithoutButton" @@ -1720,6 +1741,25 @@ 80 ], "next": [ + "RecruitConfirmLoading", + "RecruitFlag" + ] + }, + "RecruitConfirmLoading":{ + "algorithm": "OcrDetect", + "action": "doNothing", + "text": [ + "正在提交", + "反馈至神经" + ], + "roi": [ + 700, + 600, + 300, + 120 + ], + "next": [ + "RecruitConfirmLoading", "RecruitFlag" ] }, From 04739a01dcb68235aa43628d3a14b9704a0144b8 Mon Sep 17 00:00:00 2001 From: mslxl Date: Mon, 21 Mar 2022 00:41:37 +0800 Subject: [PATCH 3/8] =?UTF-8?q?fix.=20=E6=9E=81=E7=AB=AF=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E4=B8=8B=E6=97=A0=E6=B3=95=E4=BD=BF=E7=94=A8=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E6=97=A0=E4=BA=BA=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resource/tasks.json | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/resource/tasks.json b/resource/tasks.json index 35d0e591b1..3b4de73665 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -1965,6 +1965,27 @@ 150 ], "next": [ + "DroneConfirmLoading", + "DeliverableOrder", + "DroneAssist-Trade-Stop", + "DroneAssistMfg" + ] + }, + "DroneConfirmLoading": { + "algorithm": "OcrDetect", + "action": "doNothing", + "text": [ + "正在提交", + "反馈至神经" + ], + "roi": [ + 700, + 600, + 300, + 120 + ], + "next": [ + "DroneConfirmLoading", "DeliverableOrder", "DroneAssist-Trade-Stop", "DroneAssistMfg" From a729a045910dd176f7bea85830da1c6ba0606df2 Mon Sep 17 00:00:00 2001 From: mslxl Date: Mon, 21 Mar 2022 01:06:49 +0800 Subject: [PATCH 4/8] =?UTF-8?q?fix.=20=E6=9E=81=E7=AB=AF=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E4=B8=8B=E4=BC=A0=E9=80=92=E7=BA=BF=E7=B4=A2=E5=8D=A1=E4=BD=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原本在传递完一个线索后,会尝试传递下一个线索。在传递这个线索时,首先会在左侧选择它,然后在右边找能传的好友,找不到就翻页。由于方舟加载较慢,没有选中线索,右侧好友栏中找不到能传的对象,会不停的翻页后卡在最后一页。 --- resource/tasks.json | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/resource/tasks.json b/resource/tasks.json index 3b4de73665..eb080ba5d5 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -3117,6 +3117,25 @@ "ClueGiveTo1stConfirm" ] }, + "ClueGiveLoading": { + "algorithm": "OcrDetect", + "action": "doNothing", + "text": [ + "正在提交", + "反馈至神经" + ], + "roi": [ + 700, + 600, + 300, + 120 + ], + "next": [ + "ClueGiveLoading", + "SelectClue", + "CloseSendClue" + ] + }, "ClueGiveTo1st": { "template": "ClusCanBeSent.png", "action": "doNothing", @@ -3145,6 +3164,7 @@ 160 ], "next": [ + "ClueGiveLoading", "SelectClue", "CloseSendClue" ] @@ -3177,6 +3197,7 @@ 160 ], "next": [ + "ClueGiveLoading", "SelectClue", "CloseSendClue" ] @@ -3209,6 +3230,7 @@ 160 ], "next": [ + "ClueGiveLoading", "SelectClue", "CloseSendClue" ] @@ -3241,6 +3263,7 @@ 160 ], "next": [ + "ClueGiveLoading", "SelectClue", "CloseSendClue" ] From f4dd64fb6ced6262afdead7d7a67f1d533d7a959 Mon Sep 17 00:00:00 2001 From: MistEO Date: Mon, 21 Mar 2022 11:15:07 +0800 Subject: [PATCH 5/8] =?UTF-8?q?fix.=E4=BF=AE=E5=A4=8Dadb=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E5=AF=BC=E8=87=B4=E5=8D=A1=E4=BD=8F=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAssistant/Controller.cpp | 22 ++++++++++++++++------ src/MeoAssistant/Controller.h | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/MeoAssistant/Controller.cpp b/src/MeoAssistant/Controller.cpp index 9c0b41bf56..1fb93372d9 100644 --- a/src/MeoAssistant/Controller.cpp +++ b/src/MeoAssistant/Controller.cpp @@ -234,7 +234,7 @@ void asst::Controller::pipe_working_proc() m_cmd_queue.pop(); cmd_queue_lock.unlock(); // todo 判断命令是否执行成功 - call_command(cmd); + call_command(cmd, 20 * 1000); ++m_completed_id; } //else if (!m_thread_idle) { // 队列中没有任务,又不是闲置的时候,就去截图 @@ -398,14 +398,22 @@ bool asst::Controller::try_capture(const EmulatorInfo & info, bool without_handl // } //} -std::optional> asst::Controller::call_command(const std::string & cmd) +std::optional> asst::Controller::call_command(const std::string & cmd, int64_t timeout) { LogTraceFunction; + std::vector pipe_data; + static std::mutex pipe_mutex; std::unique_lock pipe_lock(pipe_mutex); - std::vector pipe_data; + auto start_time = std::chrono::steady_clock::now(); + auto check_timeout = [&]() -> bool { + return timeout && + timeout < std::chrono::duration_cast( + std::chrono::steady_clock::now() - start_time) + .count(); + }; #ifdef _WIN32 PROCESS_INFORMATION process_info = { 0 }; // 进程信息结构体 @@ -423,10 +431,12 @@ std::optional> asst::Controller::call_command(const s pipe_data.insert(pipe_data.end(), m_pipe_buffer.get(), m_pipe_buffer.get() + read_num); } } - } while (::WaitForSingleObject(process_info.hProcess, 0) == WAIT_TIMEOUT); + } while (::WaitForSingleObject(process_info.hProcess, 0) == WAIT_TIMEOUT && !check_timeout()); DWORD exit_ret = 255; - ::GetExitCodeProcess(process_info.hProcess, &exit_ret); + if (!check_timeout()) { + ::GetExitCodeProcess(process_info.hProcess, &exit_ret); + } ::CloseHandle(process_info.hProcess); ::CloseHandle(process_info.hThread); @@ -462,7 +472,7 @@ std::optional> asst::Controller::call_command(const s pipe_data.insert(pipe_data.end(), m_pipe_buffer.get(), m_pipe_buffer.get() + read_num); read_num = read(m_pipe_out[PIPE_READ], m_pipe_buffer.get(), PipeBuffSize); }; - } while (::waitpid(m_child, &exit_ret, WNOHANG) == 0); + } while (::waitpid(m_child, &exit_ret, WNOHANG) == 0 && !check_timeout()); } else { // failed to create child process diff --git a/src/MeoAssistant/Controller.h b/src/MeoAssistant/Controller.h index 0c06954a60..dbdf3df123 100644 --- a/src/MeoAssistant/Controller.h +++ b/src/MeoAssistant/Controller.h @@ -67,7 +67,7 @@ namespace asst bool connect_adb(const std::string& address); void pipe_working_proc(); - std::optional> call_command(const std::string& cmd); + std::optional> call_command(const std::string& cmd, int64_t timeout = 0); int push_cmd(const std::string& cmd); using DecodeFunc = std::function&)>; From a85211149ee1dab4e5970f5eaf4ffd95ec1ac57a Mon Sep 17 00:00:00 2001 From: mslxl Date: Mon, 21 Mar 2022 14:14:01 +0800 Subject: [PATCH 6/8] fix. typo --- src/MeoAssistant/AutoRecruitTask.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/MeoAssistant/AutoRecruitTask.cpp b/src/MeoAssistant/AutoRecruitTask.cpp index 38f766ae86..8a61da5b2c 100644 --- a/src/MeoAssistant/AutoRecruitTask.cpp +++ b/src/MeoAssistant/AutoRecruitTask.cpp @@ -108,25 +108,25 @@ bool asst::AutoRecruitTask::recruit_index(size_t index) bool asst::AutoRecruitTask::calc_and_recruit() { - RecruitTask recurit_task(m_callback, m_callback_arg, m_task_chain); - recurit_task.set_retry_times(m_retry_times); - recurit_task.set_param(m_select_level, true); + RecruitTask recruit_task(m_callback, m_callback_arg, m_task_chain); + recruit_task.set_retry_times(m_retry_times); + recruit_task.set_param(m_select_level, true); // 识别错误,放弃这个公招位,直接返回 - if (!recurit_task.run()) { + if (!recruit_task.run()) { callback(AsstMsg::SubTaskError, basic_info()); click_return_button(); return true; } - int maybe_level = recurit_task.get_maybe_level(); + int maybe_level = recruit_task.get_maybe_level(); if (need_exit()) { return false; } // 尝试刷新 if (m_need_refresh && maybe_level == 3 - && !recurit_task.get_has_special_tag() - && recurit_task.get_has_refresh()) { + && !recruit_task.get_has_special_tag() + && recruit_task.get_has_refresh()) { if (refresh()) { return calc_and_recruit(); } From 09daf2689cb7e4a0086d2930a0bdfae143e683dd Mon Sep 17 00:00:00 2001 From: mslxl Date: Mon, 21 Mar 2022 17:53:47 +0800 Subject: [PATCH 7/8] =?UTF-8?q?fix.=20=E6=9E=81=E7=AB=AF=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E4=B8=8B=E5=85=AC=E6=8B=9B=E4=B8=8D=E8=B0=83=E6=95=B4=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resource/tasks.json | 11 +++++++++++ src/MeoAssistant/AutoRecruitTask.cpp | 16 ++++++++++++++-- src/MeoAssistant/AutoRecruitTask.h | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/resource/tasks.json b/resource/tasks.json index 3b4de73665..06847837b2 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -1732,6 +1732,17 @@ "Stop" ] }, + "RecruitCheckTimeUnreduced":{ + "action": "Stop", + "template": "RecruitTimeReduce.png", + "Doc": "检查时间是不是没有调整过", + "roi": [ + 350, + 150, + 200, + 150 + ] + }, "RecruitConfirm": { "action": "clickSelf", "roi": [ diff --git a/src/MeoAssistant/AutoRecruitTask.cpp b/src/MeoAssistant/AutoRecruitTask.cpp index 8a61da5b2c..0fa9de580d 100644 --- a/src/MeoAssistant/AutoRecruitTask.cpp +++ b/src/MeoAssistant/AutoRecruitTask.cpp @@ -3,7 +3,6 @@ #include "Resource.h" #include "OcrImageAnalyzer.h" #include "Controller.h" -#include "RecruitImageAnalyzer.h" #include "ProcessTask.h" #include "RecruitTask.h" @@ -131,9 +130,16 @@ bool asst::AutoRecruitTask::calc_and_recruit() return calc_and_recruit(); } } + // 如果时间没调整过,那 tag 十有八九也没选,重新试一次 + // 造成时间没调的原因可见: https://github.com/MaaAssistantArknights/MaaAssistantArknights/pull/300#issuecomment-1073287984 + if (check_time_unreduced()) { + return calc_and_recruit(); + } + if (need_exit()) { return false; } + if (std::find(m_confirm_level.cbegin(), m_confirm_level.cend(), maybe_level) != m_confirm_level.cend()) { if (!confirm()) { return false; @@ -144,6 +150,12 @@ bool asst::AutoRecruitTask::calc_and_recruit() } return true; } +bool asst::AutoRecruitTask::check_time_unreduced() +{ + ProcessTask task(*this, {"RecruitCheckTimeUnreduced"}); + task.set_retry_times(1); + return task.run(); +} bool asst::AutoRecruitTask::check_recruit_home_page() { @@ -168,4 +180,4 @@ bool asst::AutoRecruitTask::refresh() { ProcessTask refresh_task(*this, { "RecruitRefresh" }); return refresh_task.run(); -} +} \ No newline at end of file diff --git a/src/MeoAssistant/AutoRecruitTask.h b/src/MeoAssistant/AutoRecruitTask.h index 6ab96df4da..727a294f2f 100644 --- a/src/MeoAssistant/AutoRecruitTask.h +++ b/src/MeoAssistant/AutoRecruitTask.h @@ -24,6 +24,7 @@ namespace asst bool recruit_index(size_t index); bool calc_and_recruit(); bool check_recruit_home_page(); + bool check_time_unreduced(); bool recruit_now(); bool confirm(); bool refresh(); From 89f30436bb96dfb4b5948737dd24e61ab7cff994 Mon Sep 17 00:00:00 2001 From: MistEO Date: Wed, 23 Mar 2022 11:23:30 +0800 Subject: [PATCH 8/8] =?UTF-8?q?docs.=E4=BF=AE=E5=A4=8D=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/309 https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/304 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3343da9ac8..98dcc72f57 100644 --- a/README.md +++ b/README.md @@ -120,9 +120,9 @@ MAA 的意思是 MAA Assistant Arknights ### API -- [C 接口](https://github.com/MaaAssistantArknights/MaaAssistantArknights/blob/dev/include/AsstCaller.h) -- [Python 接口](https://github.com/MaaAssistantArknights/MaaAssistantArknights/wiki/Python-%E6%8E%A5%E5%8F%A3) -- [Golang 接口](https://github.com/MaaAssistantArknights/MaaAssistantArknights/wiki/Golang-%E6%8E%A5%E5%8F%A3) +- [C 接口](include/AsstCaller.h):[集成示例](tools/TestCaller/main.cpp) +- [Python 接口](src/Python/interface.py):[集成示例](src/Python/sample.py) +- [Golang 接口](src/Golang/maa/):[集成示例](src/Golang/cli.go)(已停止维护 orz) - [回调消息协议](docs/回调消息协议.md) ## 声明