diff --git a/resource/tasks/Roguelike/base.json b/resource/tasks/Roguelike/base.json index fbf3cea6c6..5837841ebc 100644 --- a/resource/tasks/Roguelike/base.json +++ b/resource/tasks/Roguelike/base.json @@ -60,13 +60,14 @@ "RoguelikeCustom-HijackRoles": { "algorithm": "OcrDetect", "text": [], - "roi": [54, 356, 1172, 183] + "roi": [54, 356, 1172, 183], + "postDelay": 1000 }, "RoguelikeCustom-HijackSquad": { "algorithm": "OcrDetect", "text": [], "roi": [0, 383, 1280, 142], - "postDelay": 800, + "postDelay": 1000, "ocrReplace": [["蓝图测绘分.*", "蓝图测绘分队"]] }, "RoguelikeFoldartalSlowlySwipeToTheUp": { diff --git a/src/MaaCore/Task/Roguelike/RoguelikeCustomStartTaskPlugin.cpp b/src/MaaCore/Task/Roguelike/RoguelikeCustomStartTaskPlugin.cpp index 4458faf4cf..684e328bc6 100644 --- a/src/MaaCore/Task/Roguelike/RoguelikeCustomStartTaskPlugin.cpp +++ b/src/MaaCore/Task/Roguelike/RoguelikeCustomStartTaskPlugin.cpp @@ -134,7 +134,7 @@ bool asst::RoguelikeCustomStartTaskPlugin::hijack_squad() .run(); } - constexpr size_t SwipeTimes = 7; + constexpr size_t SwipeTimes = 2; for (size_t i = 0; i != SwipeTimes; ++i) { if (need_exit()) { return false; @@ -190,19 +190,34 @@ bool asst::RoguelikeCustomStartTaskPlugin::hijack_reward() bool asst::RoguelikeCustomStartTaskPlugin::hijack_roles() { - auto image = ctrler()->get_image(); - OCRer analyzer(image); - analyzer.set_task_info("RoguelikeCustom-HijackRoles"); - analyzer.set_required({ m_customs[RoguelikeCustomType::Roles] }); + constexpr size_t SwipeTimes = 2; + const std::string& required_role = m_customs[RoguelikeCustomType::Roles]; - if (!analyzer.analyze()) { - return false; + for (size_t i = 0; i != SwipeTimes; ++i) { + if (need_exit()) { + return false; + } + + auto image = ctrler()->get_image(); + OCRer analyzer(image); + analyzer.set_task_info("RoguelikeCustom-HijackRoles"); + analyzer.set_required({ required_role }); + + if (analyzer.analyze()) { + const auto& rect = analyzer.get_result().front().rect; + ctrler()->click(rect); + return true; + } + + ProcessTask(*this, { "Roguelike@SquadSlowlySwipeToTheRight" }).run(); + sleep(Task.get("RoguelikeCustom-HijackRoles")->post_delay); } - const auto& rect = analyzer.get_result().front().rect; - ctrler()->click(rect); - return true; + + ProcessTask(*this, { "SwipeToTheLeft" }).run(); + return false; } + bool asst::RoguelikeCustomStartTaskPlugin::hijack_core_char() { static const std::unordered_map RoleOcrNameMap = {