From dda9c9d017caeedfd04f5a7e092bf58aeed1f7f7 Mon Sep 17 00:00:00 2001 From: status102 Date: Sun, 12 Nov 2023 12:50:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?revert:=20=E5=9B=9E=E8=B0=83=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E5=B9=B2=E5=91=98=E6=9C=9D=E5=90=91=E6=BB=91=E5=8A=A8?= =?UTF-8?q?=E8=B7=9D=E7=A6=BB=E4=B8=BA400=EF=BC=8C=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E6=BB=91=E5=8A=A8duration=E4=B8=BA100=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=A1=A5=E5=81=BF=E8=B7=9D=E7=A6=BB=E4=B8=8A=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resource/tasks.json | 6 ++++-- src/MaaCore/Task/BattleHelper.cpp | 16 +++++++++++----- src/MaaCore/Task/BattleHelper.h | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/resource/tasks.json b/resource/tasks.json index 43c19129ef..0c8cc9986d 100644 --- a/resource/tasks.json +++ b/resource/tasks.json @@ -8175,9 +8175,10 @@ "BattleSwipeOper": { "algorithm": "JustReturn", "preDelay": 400, - "postDelay": 170, + "postDelay": 100, "Doc": "pre 是将干员滑动到场上的 duration 系数;post 是设置干员朝向滑动的 duration", "specialParams": [ + 400, 200, 2, 0, @@ -8185,6 +8186,7 @@ ], "specialParamsDoc": [ "设置朝向时的滑动距离", + "补偿距离上限", "滑动初速度(平均速度是固定的,初速度快末速度慢相当于一直减速)", "滑动末速度", "将干员滑动到场上的 最小滑动 duration" @@ -15998,4 +16000,4 @@ "Stop" ] } -} \ No newline at end of file +} diff --git a/src/MaaCore/Task/BattleHelper.cpp b/src/MaaCore/Task/BattleHelper.cpp index db6c5887d7..e627d79a5f 100644 --- a/src/MaaCore/Task/BattleHelper.cpp +++ b/src/MaaCore/Task/BattleHelper.cpp @@ -295,14 +295,14 @@ bool asst::BattleHelper::deploy_oper(const std::string& name, const Point& loc, // 1000 是随便取的一个系数,把整数的 pre_delay 转成小数用的 int duration = static_cast(dist / 1000.0 * swipe_oper_task_ptr->pre_delay); // 时间太短了的压根放不上去,故意加长一点 - if (int min_duration = swipe_oper_task_ptr->special_params.at(3); duration < min_duration) { + if (int min_duration = swipe_oper_task_ptr->special_params.at(4); duration < min_duration) { duration = min_duration; } bool deploy_with_pause = ControlFeat::support(m_inst_helper.ctrler()->support_features(), ControlFeat::SWIPE_WITH_PAUSE); Point oper_point(oper_rect.x + oper_rect.width / 2, oper_rect.y + oper_rect.height / 2); - m_inst_helper.ctrler()->swipe(oper_point, target_point, duration, false, swipe_oper_task_ptr->special_params.at(1), - swipe_oper_task_ptr->special_params.at(2), deploy_with_pause); + m_inst_helper.ctrler()->swipe(oper_point, target_point, duration, false, swipe_oper_task_ptr->special_params.at(2), + swipe_oper_task_ptr->special_params.at(3), deploy_with_pause); // 拖动干员朝向 if (direction != DeployDirection::None) { @@ -323,7 +323,8 @@ bool asst::BattleHelper::deploy_oper(const std::string& name, const Point& loc, // 经粗略测算,方向区域倾斜大概是 1/5 const static auto radian = -std::atan(0.2); - fix_swipe_out_of_limit(target_point, end_point, scale_size.first, scale_size.second, radian); + fix_swipe_out_of_limit(target_point, end_point, scale_size.first, scale_size.second, + swipe_oper_task_ptr->special_params.at(1), radian); m_inst_helper.sleep(use_oper_task_ptr->post_delay); m_inst_helper.ctrler()->swipe(target_point, end_point, swipe_oper_task_ptr->post_delay); @@ -649,7 +650,8 @@ bool asst::BattleHelper::cancel_oper_selection() return ProcessTask(this_task(), { "BattleCancelSelection" }).run(); } -void asst::BattleHelper::fix_swipe_out_of_limit(Point& p1, Point& p2, int width, int height, double radian) +void asst::BattleHelper::fix_swipe_out_of_limit(Point& p1, Point& p2, int width, int height, int max_distance, + double radian) { Point direct = Point::zero(); int distance = 0; @@ -690,6 +692,10 @@ void asst::BattleHelper::fix_swipe_out_of_limit(Point& p1, Point& p2, int width, static_cast(std::get<1>(adjust_scale) / adjust_more * distance), }; + if (auto distance = Point::distance(adjust, { 0, 0 }); distance > max_distance) { + adjust = adjust * static_cast(max_distance / distance); + } + Log.info(__FUNCTION__, "swipe end_point out of limit, start:", p1, ", end:", p2, ", adjust:", adjust); p1 += adjust; p2 += adjust; diff --git a/src/MaaCore/Task/BattleHelper.h b/src/MaaCore/Task/BattleHelper.h index 186a2ba675..3b7d1d721e 100644 --- a/src/MaaCore/Task/BattleHelper.h +++ b/src/MaaCore/Task/BattleHelper.h @@ -62,7 +62,7 @@ namespace asst bool click_skill(bool keep_waiting = true); // 这个是带识别的,转好了才点 bool cancel_oper_selection(); // 修正终点超出范围的滑动,纠正时是否需要顺时针旋转 - void fix_swipe_out_of_limit(Point& p1, Point& p2, int width, int height, double radian = 0); + void fix_swipe_out_of_limit(Point& p1, Point& p2, int width, int height, int max_distance = INT_MAX, double radian = 0); bool move_camera(const std::pair& delta); std::string analyze_detail_page_oper_name(const cv::Mat& image); From d8312b672b76e130b20346b89dd138e4c3dde3f6 Mon Sep 17 00:00:00 2001 From: status102 Date: Sun, 12 Nov 2023 13:20:37 +0800 Subject: [PATCH 2/2] fix --- src/MaaCore/Task/BattleHelper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MaaCore/Task/BattleHelper.cpp b/src/MaaCore/Task/BattleHelper.cpp index e627d79a5f..7e1ee44fce 100644 --- a/src/MaaCore/Task/BattleHelper.cpp +++ b/src/MaaCore/Task/BattleHelper.cpp @@ -692,8 +692,8 @@ void asst::BattleHelper::fix_swipe_out_of_limit(Point& p1, Point& p2, int width, static_cast(std::get<1>(adjust_scale) / adjust_more * distance), }; - if (auto distance = Point::distance(adjust, { 0, 0 }); distance > max_distance) { - adjust = adjust * static_cast(max_distance / distance); + if (auto point_distance = Point::distance(adjust, { 0, 0 }); point_distance > max_distance) { + adjust = adjust * static_cast(max_distance / point_distance); } Log.info(__FUNCTION__, "swipe end_point out of limit, start:", p1, ", end:", p2, ", adjust:", adjust);