diff --git a/resource/tasks.json b/resource/tasks.json index d5bb44312d..0abd2050b0 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -4595,17 +4595,22 @@ 600, 60 ], - "rectMove": [ - 50, - 0, - 150, - 60 - ], "maskRange": [ 1, 255 ] }, + "BattleKills": { + "algorithm": "OcrDetect", + "text": [ + ], + "roi": [ + 50, + 0, + 100, + 40 + ] + }, "BattleCostData": { "algorithm": "OcrDetect", "text": [], @@ -4644,10 +4649,6 @@ -110, 90, 90 - ], - "next": [ - "BattleSkillReadyOnClick", - "Stop" ] }, "BattleSkillStopOnClick": { @@ -4664,23 +4665,19 @@ -110, 90, 90 - ], - "next": [ - "BattleSkillStopOnClick", - "Stop" ] }, "BattleUseOper": { "algorithm": "JustReturn", - "preDelay": 500, + "preDelay": 200, "rearDelay": 0, "Doc": "pre 是从点击干员,到干员信息弹出来等待的时间;rear 是干员上场,到设置朝向之间等待的时间" }, "BattleSwipeOper": { "algorithm": "JustReturn", - "preDelay": 1000, - "rearDelay": 300, - "Doc": "pre 是将干员滑动到场上的 duration;rear 是设置干员朝向滑动的 duration" + "preDelay": 10000, + "rearDelay": 100, + "Doc": "pre 是将干员滑动到场上的 duration 系数;rear 是设置干员朝向滑动的 duration" }, "BattleOpersFlag": { "templThreshold": 0.85, @@ -4989,25 +4986,9 @@ 40 ] }, - "BattleUseSkillBegin": { - "algorithm": "JustReturn", - "action": "DoNothing", - "rearDelay": 1000, - "next": [ - "BattleUseSkill" - ] - }, "BattleUseSkill": { - "algorithm": "OcrDetect", - "text": [ - "角色" - ], - "roi": [ - 900, - 500, - 380, - 150 - ], + "algorithm": "JustReturn", + "rearDelay": 100, "action": "ClickRect", "specificRect": [ 820, @@ -5016,25 +4997,9 @@ 90 ] }, - "BattleOperRetreatBegin": { - "algorithm": "JustReturn", - "rearDelay": 500, - "next": [ - "BattleOperRetreat" - ] - }, "BattleOperRetreat": { - "algorithm": "OcrDetect", - "text": [ - "角色" - ], - "roi": [ - 900, - 500, - 380, - 150 - ], - "rearDelay": 500, + "algorithm": "JustReturn", + "rearDelay": 100, "action": "ClickRect", "specificRect": [ 563, diff --git a/src/MeoAssistant/BattleImageAnalyzer.cpp b/src/MeoAssistant/BattleImageAnalyzer.cpp index 75deef6198..93e53e3a7b 100644 --- a/src/MeoAssistant/BattleImageAnalyzer.cpp +++ b/src/MeoAssistant/BattleImageAnalyzer.cpp @@ -4,8 +4,7 @@ #include "MultiMatchImageAnalyzer.h" #include "MatchImageAnalyzer.h" -#include "OcrImageAnalyzer.h" -#include "OcrWithPreprocessImageAnalyzer.h" +#include "OcrWithFlagTemplImageAnalyzer.h" #include "HashImageAnalyzer.h" #include "Logger.hpp" #include "TaskData.h" @@ -430,20 +429,14 @@ bool asst::BattleImageAnalyzer::hp_analyze() bool asst::BattleImageAnalyzer::kills_analyze() { - const auto task_ptr = Task.get("BattleKillsFlag"); - MatchImageAnalyzer flag_analzyer(m_image); - flag_analzyer.set_task_info(task_ptr); - if (!flag_analzyer.analyze()) { - return false; - } + OcrWithFlagTemplImageAnalyzer kills_analyzer(m_image); + kills_analyzer.set_task_info("BattleKillsFlag", "BattleKills"); + kills_analyzer.set_replace( + std::dynamic_pointer_cast(Task.get("NumberOcrReplace"))->replace_map); - auto kills_roi = flag_analzyer.get_result().rect.move(task_ptr->rect_move); - OcrImageAnalyzer kills_analyzer(m_image); - kills_analyzer.set_roi(kills_roi); if (!kills_analyzer.analyze()) { return false; } - kills_analyzer.sort_result_by_score(); std::string kills_text; size_t pos = std::string::npos; diff --git a/src/MeoAssistant/BattleProcessTask.cpp b/src/MeoAssistant/BattleProcessTask.cpp index 1575f21838..c1db41a417 100644 --- a/src/MeoAssistant/BattleProcessTask.cpp +++ b/src/MeoAssistant/BattleProcessTask.cpp @@ -124,7 +124,6 @@ bool asst::BattleProcessTask::analyze_opers_preview() } auto draw_future = std::async(std::launch::async, [&]() { - //#ifdef ASST_DEBUG auto draw = image.clone(); for (const auto& [loc, info] : m_normal_tile_info) { std::string text = "( " + std::to_string(loc.x) + ", " + std::to_string(loc.y) + " )"; @@ -136,12 +135,14 @@ bool asst::BattleProcessTask::analyze_opers_preview() auto opers = oper_analyzer.get_opers(); + Rect cur_rect; + int click_delay = Task.get("BattleUseOper")->pre_delay; for (size_t i = 0; i != opers.size(); ++i) { const auto& cur_oper = oper_analyzer.get_opers(); size_t offset = opers.size() > cur_oper.size() ? opers.size() - cur_oper.size() : 0; - m_ctrler->click(cur_oper.at(i - offset).rect); - - sleep(Task.get("BattleUseOper")->pre_delay); + cur_rect = cur_oper.at(i - offset).rect; + m_ctrler->click(cur_rect); + sleep(click_delay); image = m_ctrler->get_image(); @@ -185,8 +186,10 @@ bool asst::BattleProcessTask::analyze_opers_preview() } draw_future.wait(); + + m_ctrler->click(cur_rect); + sleep(click_delay); battle_pause(); - cancel_selection(); return true; } @@ -270,8 +273,9 @@ bool asst::BattleProcessTask::update_opers_info(const cv::Mat& image) oper_name = name_analyzer.get_result().front().text; } m_group_to_oper_mapping[oper_name] = BattleDeployOper{ oper_name }; + m_ctrler->click(cur_oper.rect); + sleep(Task.get("BattleUseOper")->pre_delay); battle_pause(); - cancel_selection(); } else { oper_name = matched_iter->first; @@ -381,7 +385,9 @@ bool asst::BattleProcessTask::wait_condition(const BattleAction& action) if (need_exit()) { return false; } - image = m_ctrler->get_image(); + if (image.empty()) { + image = m_ctrler->get_image(); + } BattleImageAnalyzer analyzer(image); analyzer.set_target(BattleImageAnalyzer::Target::Kills); if (analyzer.analyze()) { @@ -393,6 +399,7 @@ bool asst::BattleProcessTask::wait_condition(const BattleAction& action) try_possible_skill(image); std::this_thread::yield(); + image = m_ctrler->get_image(); } // 部署干员还有额外等待费用够或 CD 转好 @@ -402,7 +409,9 @@ bool asst::BattleProcessTask::wait_condition(const BattleAction& action) if (need_exit()) { return false; } - image = m_ctrler->get_image(); + if (image.empty()) { + image = m_ctrler->get_image(); + } update_opers_info(image); if (auto iter = m_cur_opers_info.find(name); @@ -412,6 +421,7 @@ bool asst::BattleProcessTask::wait_condition(const BattleAction& action) try_possible_skill(image); std::this_thread::yield(); + image = m_ctrler->get_image(); }; } if (image.empty()) { @@ -440,7 +450,12 @@ bool asst::BattleProcessTask::oper_deploy(const BattleAction& action) Point placed_point = m_side_tile_info[action.location].pos; Rect placed_rect{ placed_point.x ,placed_point.y, 1, 1 }; - m_ctrler->swipe(oper_rect, placed_rect, swipe_oper_task_ptr->pre_delay); + int dist = static_cast( + std::sqrt( + (std::abs(placed_point.x - oper_rect.x) << 1) + + (std::abs(placed_point.y - oper_rect.y) << 1))); + int duration = static_cast(swipe_oper_task_ptr->pre_delay / 1000.0 * dist); // 随便取的一个系数 + m_ctrler->swipe(oper_rect, placed_rect, duration, true, 0); sleep(use_oper_task_ptr->rear_delay); @@ -468,7 +483,7 @@ bool asst::BattleProcessTask::oper_deploy(const BattleAction& action) end_point.y = std::max(0, end_point.y); end_point.y = std::min(end_point.y, WindowHeightDefault); - m_ctrler->swipe(placed_point, end_point, swipe_oper_task_ptr->rear_delay); + m_ctrler->swipe(placed_point, end_point, swipe_oper_task_ptr->rear_delay, true, 100); } m_used_opers[iter->first] = BattleDeployInfo{ @@ -578,8 +593,3 @@ bool asst::BattleProcessTask::battle_speedup() { return ProcessTask(*this, { "BattleSpeedUp" }).run(); } - -bool asst::BattleProcessTask::cancel_selection() -{ - return ProcessTask(*this, { "BattleCancelSelection" }).run(); -} diff --git a/src/MeoAssistant/BattleProcessTask.h b/src/MeoAssistant/BattleProcessTask.h index 3b44c1ca27..0e6a3400a4 100644 --- a/src/MeoAssistant/BattleProcessTask.h +++ b/src/MeoAssistant/BattleProcessTask.h @@ -22,7 +22,6 @@ namespace asst virtual bool get_stage_info(); bool battle_pause(); bool battle_speedup(); - bool cancel_selection(); // 取消选择干员 bool analyze_opers_preview(); bool update_opers_info(const cv::Mat& image);