diff --git a/resource/tasks.json b/resource/tasks.json index 9247a9619f..908513d2d8 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -766,19 +766,15 @@ "狮蝎" ], [ - "第草", - "苇草" + "扬师虫", + "狮蝎" ], [ "漂冬", "凛冬" ], [ - "韦草", - "苇草" - ], - [ - "笔草", + ".+草", "苇草" ], [ @@ -800,6 +796,10 @@ [ "研", "砾" + ], + [ + "紫雨", + "絮语" ] ] }, @@ -4492,19 +4492,15 @@ "落.+骑士", "落魄骑士" ], - [ - ".+爵的戏.+", - "鸭爵的戏剧" - ], [ "邪异因笼", "邪异囚笼" ] ], "roi": [ - 420, - 430, - 440, + 250, + 435, + 800, 100 ] }, @@ -4703,7 +4699,8 @@ 20, 60, 60 - ] + ], + "rearDelay": 100 }, "BattleCancelSelection": { "algorithm": "JustReturn", @@ -4774,6 +4771,7 @@ 210, 118 ], + "templThreshold": 0.7, "cache": false, "action": "ClickSelf", "rectMove": [ @@ -4809,7 +4807,7 @@ }, "BattleSwipeOper": { "algorithm": "JustReturn", - "preDelay": 15000, + "preDelay": 500, "rearDelay": 100, "Doc": "pre 是将干员滑动到场上的 duration 系数;rear 是设置干员朝向滑动的 duration" }, @@ -5088,19 +5086,14 @@ ] }, "Roguelike1BattleSpeedUp": { - "template": "BattleSpeedUp.png", - "action": "ClickSelf", - "roi": [ - 1025, - 0, - 149, - 153 - ], - "maskRange": [ - 100, - 255 - ], - "templThreshold": 0.95 + "algorithm": "JustReturn", + "action": "ClickRect", + "specificRect": [ + 1070, + 20, + 60, + 60 + ] }, "BattleSkillReady": { "roi": [ @@ -5499,7 +5492,7 @@ }, "BattleWaitingToLoad": { "algorithm": "JustReturn", - "rearDelay": 200 + "rearDelay": 1000 }, "Roguelike1CloseCollection": { "action": "ClickSelf", @@ -6418,15 +6411,16 @@ ] }, "Roguelike1InBattleFlag": { - "algorithm": "OcrDetect", - "text": [ - "角色" - ], + "template": "BattleOfficiallyBegin.png", "roi": [ - 900, - 500, - 380, - 150 + 1165, + 20, + 65, + 65 + ], + "maskRange": [ + 100, + 255 ], "action": "DoNothing", "rearDelay": 5000, diff --git a/src/MeoAssistant/BattleProcessTask.cpp b/src/MeoAssistant/BattleProcessTask.cpp index 846dab9ea8..3a64983666 100644 --- a/src/MeoAssistant/BattleProcessTask.cpp +++ b/src/MeoAssistant/BattleProcessTask.cpp @@ -474,12 +474,13 @@ 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 }; + Rect placed_rect{ placed_point.x ,placed_point.y, 0, 0 }; 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 * dist); // 随便取的一个系数 + (std::pow(std::abs(placed_point.x - oper_rect.x), 2)) + + (std::pow(std::abs(placed_point.y - oper_rect.y), 2)))); + // 1000 是随便取的一个系数,把整数的 pre_delay 转成小数用的 + int duration = static_cast(swipe_oper_task_ptr->pre_delay / 1000.0 * dist * log10(dist)); m_ctrler->swipe(oper_rect, placed_rect, duration, true, 0); sleep(use_oper_task_ptr->rear_delay); diff --git a/src/MeoAssistant/RoguelikeBattleTaskPlugin.cpp b/src/MeoAssistant/RoguelikeBattleTaskPlugin.cpp index cd10ecae8a..267f237a3b 100644 --- a/src/MeoAssistant/RoguelikeBattleTaskPlugin.cpp +++ b/src/MeoAssistant/RoguelikeBattleTaskPlugin.cpp @@ -46,8 +46,6 @@ bool asst::RoguelikeBattleTaskPlugin::_run() speed_up(); - constexpr static auto time_limit = std::chrono::minutes(10); - bool timeout = false; auto start_time = std::chrono::steady_clock::now(); while (!need_exit()) { @@ -55,7 +53,8 @@ bool asst::RoguelikeBattleTaskPlugin::_run() if (!auto_battle() && m_opers_used) { break; } - if (std::chrono::steady_clock::now() - start_time > time_limit) { + using namespace std::chrono_literals; + if (std::chrono::steady_clock::now() - start_time > 10min) { timeout = true; break; } @@ -85,7 +84,7 @@ bool asst::RoguelikeBattleTaskPlugin::get_stage_info() constexpr int StageNameRetryTimes = 50; for (int i = 0; i != StageNameRetryTimes; ++i) { cv::Mat image = m_ctrler->get_image(); - OcrImageAnalyzer name_analyzer(image); + OcrWithPreprocessImageAnalyzer name_analyzer(image); name_analyzer.set_task_info(stage_name_task_ptr); if (!name_analyzer.analyze()) { @@ -293,11 +292,11 @@ bool asst::RoguelikeBattleTaskPlugin::auto_battle() #endif Rect placed_rect(placed_point.x, placed_point.y, 1, 1); int dist = static_cast( - std::sqrt( - (std::abs(placed_point.x - opt_oper.rect.x) << 1) - + (std::abs(placed_point.y - opt_oper.rect.y) << 1))); - int duration = static_cast(swipe_oper_task_ptr->pre_delay / 800.0 * dist); // 随便取的一个系数 - m_ctrler->swipe(opt_oper.rect, placed_rect, duration, true, 0); + std::sqrt( + (std::pow(std::abs(placed_point.x - opt_oper.rect.x), 2)) + + (std::pow(std::abs(placed_point.y - opt_oper.rect.y), 2)))); + // 1000 是随便取的一个系数,把整数的 pre_delay 转成小数用的 + int duration = static_cast(swipe_oper_task_ptr->pre_delay / 1000.0 * dist * log10(dist)); m_ctrler->swipe(opt_oper.rect, placed_rect, duration, true, 0); sleep(use_oper_task_ptr->rear_delay); // 计算往哪边拖动(干员朝向) @@ -325,8 +324,7 @@ bool asst::RoguelikeBattleTaskPlugin::auto_battle() bool asst::RoguelikeBattleTaskPlugin::speed_up() { - ProcessTask task(*this, { "Roguelike1BattleSpeedUp" }); - return task.run(); + return ProcessTask(*this, { "Roguelike1BattleSpeedUp" }).run(); } bool asst::RoguelikeBattleTaskPlugin::use_skill(const asst::Rect& rect) @@ -406,7 +404,8 @@ bool asst::RoguelikeBattleTaskPlugin::try_possible_skill(const cv::Mat& image) continue; } m_ctrler->click(pos_rect); - used |= ProcessTask(*this, { "BattleSkillReadyOnClick" }).set_task_delay(0).run(); + sleep(Task.get("BattleUseOper")->pre_delay); + used |= ProcessTask(*this, { "BattleSkillReadyOnClick" }).run(); if (usage == BattleSkillUsage::Once) { m_status->set_number(status_key, static_cast(BattleSkillUsage::OnceUsed)); m_restore_status[status_key] = static_cast(BattleSkillUsage::Once); @@ -419,9 +418,8 @@ bool asst::RoguelikeBattleTaskPlugin::wait_start() { auto start_time = std::chrono::system_clock::now(); auto check_time = [&]() -> bool { - auto now = std::chrono::system_clock::now(); - auto diff = now - start_time; - return diff.count() > std::chrono::seconds(60).count(); + using namespace std::chrono_literals; + return std::chrono::system_clock::now() - start_time > 1min; }; MatchImageAnalyzer officially_begin_analyzer;