mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 09:50:40 +08:00
feat: 抄作业自动跳过战斗中剧情 (#6721)
This commit is contained in:
@@ -601,6 +601,10 @@
|
||||
[
|
||||
":",
|
||||
""
|
||||
],
|
||||
[
|
||||
"-2O",
|
||||
"-20"
|
||||
]
|
||||
],
|
||||
"roi": [
|
||||
@@ -7479,9 +7483,9 @@
|
||||
"action": "ClickSelf",
|
||||
"roi": [
|
||||
721,
|
||||
390,
|
||||
290,
|
||||
149,
|
||||
144
|
||||
244
|
||||
],
|
||||
"maskRange": [
|
||||
100,
|
||||
|
||||
@@ -392,6 +392,18 @@ bool asst::BattleHelper::check_pause_button(const cv::Mat& reusable)
|
||||
ret &= battle_result_opt && battle_result_opt->pause_button;
|
||||
return ret;
|
||||
}
|
||||
bool asst::BattleHelper::check_skip_plot_button(const cv::Mat& reusable)
|
||||
{
|
||||
cv::Mat image = reusable.empty() ? m_inst_helper.ctrler()->get_image() : reusable;
|
||||
|
||||
Matcher battle_plot_analyzer(image);
|
||||
battle_plot_analyzer.set_task_info("SkipThePreBattlePlot");
|
||||
bool ret = battle_plot_analyzer.analyze().has_value();
|
||||
if (ret) {
|
||||
ProcessTask(this_task(), { "SkipThePreBattlePlot" }).run();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool asst::BattleHelper::check_in_battle(const cv::Mat& reusable, bool weak)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,8 @@ namespace asst
|
||||
bool use_skill(const std::string& name, bool keep_waiting = true);
|
||||
bool use_skill(const Point& loc, bool keep_waiting = true);
|
||||
bool check_pause_button(const cv::Mat& reusable = cv::Mat());
|
||||
bool check_in_battle(const cv::Mat& reusable = cv::Mat(), bool weak = true);
|
||||
bool check_skip_plot_button(const cv::Mat& reusable = cv::Mat());
|
||||
virtual bool check_in_battle(const cv::Mat& reusable = cv::Mat(), bool weak = true);
|
||||
virtual bool wait_until_start(bool weak = true);
|
||||
bool wait_until_end(bool weak = true);
|
||||
bool use_all_ready_skill(const cv::Mat& reusable = cv::Mat());
|
||||
|
||||
@@ -92,9 +92,6 @@ bool asst::CopilotTask::set_params(const json::value& params)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool with_formation = params.get("formation", false);
|
||||
m_formation_task_ptr->set_enable(with_formation);
|
||||
|
||||
// 自动补信赖
|
||||
m_formation_task_ptr->set_add_trust(params.get("add_trust", false));
|
||||
m_formation_task_ptr->set_add_user_additional(params.get("add_user_additional", false));
|
||||
@@ -135,6 +132,10 @@ bool asst::CopilotTask::set_params(const json::value& params)
|
||||
m_navigate_task_ptr->set_tasks({ m_navigate_name + "@Copilot@StageNavigationBegin" });
|
||||
m_navigate_task_ptr->set_enable(need_navigate);
|
||||
|
||||
bool with_formation = params.get("formation", false);
|
||||
// 关卡名含有"TR"的为教学关,不需要编队
|
||||
m_formation_task_ptr->set_enable(with_formation && m_navigate_name.find("TR") == std::string::npos);
|
||||
|
||||
std::string support_unit_name = params.get("support_unit_name", std::string());
|
||||
m_formation_task_ptr->set_support_unit_name(std::move(support_unit_name));
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "Utils/Algorithm.hpp"
|
||||
#include "Utils/ImageIo.hpp"
|
||||
#include "Utils/Logger.hpp"
|
||||
#include "Vision/Battle/BattlefieldMatcher.h"
|
||||
#include "Vision/Matcher.h"
|
||||
#include "Vision/RegionOCRer.h"
|
||||
|
||||
@@ -336,7 +337,10 @@ bool asst::BattleProcessTask::wait_condition(const Action& action)
|
||||
const std::string& name = get_name_from_group(action.name);
|
||||
update_image_if_empty();
|
||||
while (!need_exit()) {
|
||||
if (!update_deployment(false, image)) {
|
||||
if (check_skip_plot_button(image)) {
|
||||
speed_up();
|
||||
}
|
||||
else if (!update_deployment(false, image)) {
|
||||
return false;
|
||||
}
|
||||
if (auto iter = m_cur_deployment_opers.find(name);
|
||||
@@ -375,3 +379,25 @@ void asst::BattleProcessTask::sleep_and_do_strategy(unsigned millisecond)
|
||||
std::this_thread::yield();
|
||||
}
|
||||
}
|
||||
|
||||
bool asst::BattleProcessTask::check_in_battle(const cv::Mat& reusable, bool weak)
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
cv::Mat image = reusable.empty() ? ctrler()->get_image() : reusable;
|
||||
|
||||
if (weak) {
|
||||
BattlefieldMatcher analyzer(image);
|
||||
auto result = analyzer.analyze();
|
||||
m_in_battle = result.has_value();
|
||||
if (m_in_battle && !result->pause_button) {
|
||||
if (check_skip_plot_button(image)) {
|
||||
speed_up();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_in_battle = check_pause_button(image);
|
||||
}
|
||||
return m_in_battle;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ namespace asst
|
||||
bool enter_bullet_time(const std::string& name, const Point& location);
|
||||
void sleep_and_do_strategy(unsigned millisecond);
|
||||
|
||||
virtual bool check_in_battle(const cv::Mat& reusable = cv::Mat(), bool weak = true) override;
|
||||
|
||||
battle::copilot::CombatData m_combat_data;
|
||||
std::unordered_map</*group*/ std::string, /*oper*/ std::string> m_oper_in_group;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user