From 61345d81261cce3ba3de5bcdbd32882cef2ce50a Mon Sep 17 00:00:00 2001 From: status102 <102887808+status102@users.noreply.github.com> Date: Tue, 12 May 2026 19:25:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=8A=A8=E6=88=98=E6=96=97?= =?UTF-8?q?=E5=89=A7=E6=83=85=E9=81=87=E5=88=B0=E5=89=A7=E6=83=85=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E7=BB=A7=E7=BB=AD=E6=97=B6,=20=E5=9B=9E=E9=80=80?= =?UTF-8?q?=E5=88=B0=E6=89=A7=E8=A1=8C=E4=BD=9C=E4=B8=9A=E6=AD=A5=E9=AA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resource/tasks/tasks.json | 6 ++-- src/MaaCore/Task/BattleHelper.cpp | 49 +++++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/resource/tasks/tasks.json b/resource/tasks/tasks.json index 25a5ce3a79..72b8417495 100644 --- a/resource/tasks/tasks.json +++ b/resource/tasks/tasks.json @@ -3685,11 +3685,13 @@ "next": ["EndOfPlot"] }, "BattleAvatarDialog": { - "doc": "战斗中带头像对话框, 类似于 SkipThePreBattlePlot(可见于画中人关卡) 的, 但是缺少 跳过 按钮", + "doc": "战斗中带头像对话框, 类似于 SkipThePreBattlePlot(可见于画中人关卡, 17章主线TR28) 的, 但是缺少 跳过 按钮", "action": "ClickSelf", "roi": [70, 30, 120, 30], + "maxTimes": 5, "next": ["BattleAvatarDialog", "Stop"], - "rectMove": [125, 20, 200, 60] + "rectMove": [125, 20, 200, 60], + "specialParams": [98] }, "EndOfPlot": { "roi": [520, 0, 243, 206], diff --git a/src/MaaCore/Task/BattleHelper.cpp b/src/MaaCore/Task/BattleHelper.cpp index 2977f2e0f5..b742799432 100644 --- a/src/MaaCore/Task/BattleHelper.cpp +++ b/src/MaaCore/Task/BattleHelper.cpp @@ -621,14 +621,39 @@ bool asst::BattleHelper::check_skip_plot_button(const cv::Mat& reusable) bool asst::BattleHelper::check_avatar_dialog(const cv::Mat& reusable) { cv::Mat image = reusable.empty() ? m_inst_helper.ctrler()->get_image() : reusable; - + const static auto& task = Task.get("BattleAvatarDialog"); + const static double threshold = task->special_params[0] / 100.0; Matcher battle_plot_analyzer(image); - battle_plot_analyzer.set_task_info("BattleAvatarDialog"); + battle_plot_analyzer.set_task_info(task); bool ret = battle_plot_analyzer.analyze().has_value(); - if (ret) { - ProcessTask(this_task(), { "BattleAvatarDialog" }).run(); + if (!ret) { + return false; } - return ret; + + ProcessTask(this_task(), { "BattleAvatarDialog" }).run(); + const auto match_rect = battle_plot_analyzer.get_result().rect.move(task->rect_move); + + cv::Mat image2 = m_inst_helper.ctrler()->get_image(); + int retry = 100; + while (!m_inst_helper.need_exit() && retry > 0) { + Matcher matcher(image2); + matcher.set_templ(make_roi(image, match_rect)); + matcher.set_roi(match_rect); + matcher.set_threshold(threshold); + matcher.set_method(MatchMethod::Ccoeff); + if (matcher.analyze()) { + LogInfo << __FUNCTION__ << "still in dialog, but not detected change, maybe need deploy or skill"; + break; + } + --retry; + ret = ProcessTask(this_task(), { "BattleAvatarDialog" }).run(); + if (!ret) { + break; + } + image = image2; + image2 = m_inst_helper.ctrler()->get_image(); + } + return true; } bool asst::BattleHelper::check_in_speedup(const cv::Mat& reusable) @@ -655,13 +680,13 @@ bool asst::BattleHelper::check_in_battle(const cv::Mat& reusable, bool weak) else if (check_avatar_dialog(image)) { if (m_in_speedup && !check_in_speedup()) { speed_up(); // 跳过剧情会退出2倍速 - m_inst_helper.sleep(Config.get_options().task_delay); - int times = 0; - while (times < 20 && !m_inst_helper.need_exit() && !check_in_speedup()) { - speed_up(); // 跳过剧情会退出2倍速 - m_inst_helper.sleep(Config.get_options().task_delay); - times++; - } + } + } + } + else if (m_in_battle && result->pause_button == BattlefieldMatcher::PauseStatus::Pausing) { + if (check_avatar_dialog(image)) { + if (m_in_speedup && !check_in_speedup()) { + speed_up(); // 跳过剧情会退出2倍速 } } }