From 90d3c140fe32c8d56a3d2fdcb41260eaf7530e61 Mon Sep 17 00:00:00 2001 From: Lancarus <34369130+Lancarus@users.noreply.github.com> Date: Wed, 12 Jun 2024 18:22:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=9A=82=E5=81=9C?= =?UTF-8?q?=E6=94=BE=E6=8A=80=E8=83=BD=E5=92=8C=E6=9A=82=E5=81=9C=E6=92=A4?= =?UTF-8?q?=E9=80=80=20(#9348)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resource/tasks.json | 29 ++++++++++++++++++++++++++++ src/MaaCore/Task/BattleHelper.cpp | 32 ++++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/resource/tasks.json b/resource/tasks.json index 96fe9ba99e..84b70e78e8 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -9169,6 +9169,35 @@ ], "postDelay": 200 }, + "BattlePauseCancel": { + "algorithm": "JustReturn", + "action": "ClickRect", + "specificRect": [ + 1170, + 20, + 60, + 60 + ], + "postDelay": 50, + "next": [ + "BattlePauseCancelCheck", + "BattlePauseCancel" + ] + }, + "BattlePauseCancelCheck": { + "template": "BattleOfficiallyBegin.png", + "roi": [ + 1165, + 20, + 65, + 65 + ], + "maskRange": [ + 100, + 255 + ], + "action": "DoNothing" + }, "BattleCancelSelection": { "algorithm": "JustReturn", "action": "ClickRect", diff --git a/src/MaaCore/Task/BattleHelper.cpp b/src/MaaCore/Task/BattleHelper.cpp index fc675d5c0e..ca42ba4a32 100644 --- a/src/MaaCore/Task/BattleHelper.cpp +++ b/src/MaaCore/Task/BattleHelper.cpp @@ -390,7 +390,7 @@ bool asst::BattleHelper::deploy_oper( if (deploy_with_pause) { // m_inst_helper.ctrler()->press_esc(); - ProcessTask(this_task(), { "BattlePause" }).run(); + ProcessTask(this_task(), { "BattlePauseCancel" }).run(); } // for SSS, multiple operator may be deployed at the same location. @@ -556,8 +556,7 @@ bool asst::BattleHelper::do_strategic_action(const cv::Mat& reusable) bool asst::BattleHelper::use_all_ready_skill(const cv::Mat& reusable) { // TODO: 可配置延迟时间 - static constexpr auto min_frame_interval = - std::chrono::milliseconds(1000); + static constexpr auto min_frame_interval = std::chrono::milliseconds(1000); bool used = false; cv::Mat image = reusable.empty() ? m_inst_helper.ctrler()->get_image() : reusable; @@ -572,7 +571,10 @@ bool asst::BattleHelper::use_all_ready_skill(const cv::Mat& reusable) const auto now = std::chrono::steady_clock::now(); if (auto interval = now - last_use_time; min_frame_interval > interval) { - Log.debug(name, "use skill too fast, interval time:", std::chrono::duration_cast(interval)); + Log.debug( + name, + "use skill too fast, interval time:", + std::chrono::duration_cast(interval)); continue; } @@ -727,16 +729,33 @@ bool asst::BattleHelper::click_oper_on_battlefield(const Point& loc) bool asst::BattleHelper::click_retreat() { LogTraceFunction; + bool deploy_with_pause = ControlFeat::support( + m_inst_helper.ctrler()->support_features(), + ControlFeat::SWIPE_WITH_PAUSE); + if (deploy_with_pause) { + ProcessTask(this_task(), { "BattlePause" }).run(); + } // return ProcessTask(this_task(), { "BattleOperRetreatJustClick" }).run(); - return m_inst_helper.ctrler()->click(m_retreat_button_pos); + bool ret = m_inst_helper.ctrler()->click(m_retreat_button_pos); + + if (deploy_with_pause) { + ProcessTask(this_task(), { "BattlePauseCancel" }).run(); + } + return ret; } // TODO: use m_skill_button_pos bool asst::BattleHelper::click_skill(bool keep_waiting) { LogTraceFunction; + bool deploy_with_pause = ControlFeat::support( + m_inst_helper.ctrler()->support_features(), + ControlFeat::SWIPE_WITH_PAUSE); + if (!keep_waiting && deploy_with_pause) { + ProcessTask(this_task(), { "BattlePause" }).run(); + } ProcessTask skill_task( this_task(), { "BattleSkillReadyOnClick", @@ -753,6 +772,9 @@ bool asst::BattleHelper::click_skill(bool keep_waiting) if (!ret) { cancel_oper_selection(); } + if (deploy_with_pause) { + ProcessTask(this_task(), { "BattlePauseCancel" }).run(); + } return ret; } }