diff --git a/assets/resource/pipeline/combat/combat.json b/assets/resource/pipeline/combat/combat.json deleted file mode 100644 index a74b4f2..0000000 --- a/assets/resource/pipeline/combat/combat.json +++ /dev/null @@ -1,391 +0,0 @@ -{ - "$schema": "../../pipeline.schema.json", - "CombatForward": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Swipe", - "begin": [ - 127, - 550, - 50, - 50 - ], - "end": [ - 149, - 466, - 6, - 7 - ], - "duration": 500, - "pre_delay": 0, - "post_delay": 50 - }, - "CombatBackward": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Swipe", - "begin": [ - 127, - 550, - 50, - 50 - ], - "end": [ - 149, - 684, - 6, - 7 - ], - "duration": 500, - "pre_delay": 0, - "post_delay": 50 - }, - "CombatLeft": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Swipe", - "begin": [ - 127, - 550, - 50, - 50 - ], - "end": [ - 36, - 572, - 7, - 6 - ], - "duration": 500, - "pre_delay": 0, - "post_delay": 50 - }, - "CombatRight": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Swipe", - "begin": [ - 127, - 550, - 50, - 50 - ], - "end": [ - 261, - 572, - 7, - 6 - ], - "duration": 500, - "pre_delay": 0, - "post_delay": 50 - }, - "CombatLeftForward": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Swipe", - "begin": [ - 127, - 550, - 50, - 50 - ], - "end": [ - 70, - 493, - 5, - 5 - ], - "duration": 500, - "pre_delay": 0, - "post_delay": 50 - }, - "CombatRightForward": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Swipe", - "begin": [ - 127, - 550, - 50, - 50 - ], - "end": [ - 229, - 493, - 5, - 5 - ], - "duration": 500, - "pre_delay": 0, - "post_delay": 50 - }, - "CombatLeftBackward": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Swipe", - "begin": [ - 127, - 550, - 50, - 50 - ], - "end": [ - 70, - 652, - 5, - 5 - ], - "duration": 500, - "pre_delay": 0, - "post_delay": 50 - }, - "CombatRightBackward": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Swipe", - "begin": [ - 127, - 550, - 50, - 50 - ], - "end": [ - 229, - 652, - 5, - 5 - ], - "duration": 500, - "pre_delay": 0, - "post_delay": 50 - }, - "CombatBasicATK": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Click", - "target": [ - 1146, - 606, - 82, - 64 - ], - "pre_delay": 0, - "post_delay": 200 - }, - "CombatBasicATKCharge": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Custom", - "custom_action": "BasicATKChargeBase", - "pre_delay": 0, - "post_delay": 100 - }, - "CombatEvade": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Click", - "target": [ - 971, - 608, - 79, - 62 - ], - "pre_delay": 0, - "post_delay": 150 - }, - "CombatUltimate": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Click", - "target": [ - 1145, - 424, - 82, - 74 - ], - "pre_delay": 0, - "post_delay": 150 - }, - "CombatUltimateCharge": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Custom", - "custom_action": "UltimateChargeBase", - "pre_delay": 0, - "post_delay": 100 - }, - "CombatWeaponSkill": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Click", - "target": [ - 977, - 444, - 69, - 64 - ], - "pre_delay": 0, - "post_delay": 150 - }, - "CombatELFSkill": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Click", - "target": [ - 857, - 515, - 63, - 53 - ], - "pre_delay": 0, - "post_delay": 150 - }, - "CombatExtraSkill": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Click", - "target": [ - 980, - 294, - 64, - 49 - ], - "pre_delay": 0, - "post_delay": 100 - }, - "CombatQTE1": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Click", - "target": [ - 1157, - 113, - 73, - 51 - ], - "pre_delay": 0, - "post_delay": 150 - }, - "CombatQTE2": { - "recognition": "TemplateMatch", - "template": "Combat/StopCombat.png", - "roi": [ - 0, - 0, - 136, - 140 - ], - "action": "Click", - "target": [ - 1160, - 261, - 70, - 56 - ], - "pre_delay": 0, - "post_delay": 150 - } -} \ No newline at end of file diff --git a/source/cli/CMakeLists.txt b/source/cli/CMakeLists.txt index 8f1f4af..c066601 100644 --- a/source/cli/CMakeLists.txt +++ b/source/cli/CMakeLists.txt @@ -18,6 +18,8 @@ add_executable(MAABH3_CLI CustomAction/CustomAction.h CustomAction/CustomAction.cpp CustomAction/CustomActionRegistry.h + CustomAction/RandomPointGenerator.h + CustomAction/RandomPointGenerator.cpp ) target_link_libraries(MAABH3_CLI PRIVATE MaaFramework MaaToolKit) diff --git a/source/cli/CustomAction/Combat.cpp b/source/cli/CustomAction/Combat.cpp index f17c7bc..8fdad33 100644 --- a/source/cli/CustomAction/Combat.cpp +++ b/source/cli/CustomAction/Combat.cpp @@ -1,94 +1,93 @@ #include "Combat.h" -MaaBool combat_forward(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, - [[maybe_unused]] MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, - [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) +void combat_move(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView custom_action_param, + int32_t target_x, int32_t target_y, int32_t target_w, int32_t target_h) { - MaaSyncContextRunTask(sync_context, "CombatForward", MaaTaskParam_Empty); - return true; + RandomPointGenerator generator; + int32_t x1, y1, x2, y2; + generator.generate_point(127, 550, 50, 50, x1, y1); + generator.generate_point(target_x, target_y, target_w, target_h, x2, y2); + + MaaSyncContextTouchDown(sync_context, 0, x1, y1, 0); + MaaSyncContextTouchMove(sync_context, 0, x2, y2, 0); + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + MaaSyncContextTouchUp(sync_context, 0); } -MaaBool combat_backward(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, - [[maybe_unused]] MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, - [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) +MaaBool combat_move_forward(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, + MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, + [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatBackward", MaaTaskParam_Empty); + combat_move(sync_context, custom_action_param, 149, 466, 6, 7); return true; } -MaaBool combat_left(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, - [[maybe_unused]] MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, - [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) +MaaBool combat_move_backward(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, + MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, + [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatLeft", MaaTaskParam_Empty); + combat_move(sync_context, custom_action_param, 149, 684, 6, 7); return true; } -MaaBool combat_right(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, - [[maybe_unused]] MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, - [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) +MaaBool combat_move_left(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, + MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, + [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatRight", MaaTaskParam_Empty); + combat_move(sync_context, custom_action_param, 36, 572, 7, 6); return true; } -MaaBool combat_left_forward(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, - [[maybe_unused]] MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, - [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) +MaaBool combat_move_right(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, + MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, + [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatLeftForward", MaaTaskParam_Empty); + combat_move(sync_context, custom_action_param, 261, 572, 7, 6); return true; } -MaaBool combat_right_forward(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, - [[maybe_unused]] MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, - [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) +MaaBool combat_move_left_forward(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, + MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, + [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatRightForward", MaaTaskParam_Empty); + combat_move(sync_context, custom_action_param, 70, 493, 5, 5); return true; } -MaaBool combat_left_backward(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, - [[maybe_unused]] MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, - [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) +MaaBool combat_move_right_forward(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, + MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, + [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatLeftBackward", MaaTaskParam_Empty); + combat_move(sync_context, custom_action_param, 229, 493, 5, 5); return true; } -MaaBool combat_right_backward(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, - [[maybe_unused]] MaaStringView custom_action_param, - [[maybe_unused]] MaaRectHandle cur_box, [[maybe_unused]] MaaStringView cur_rec_detail, - [[maybe_unused]] MaaTransparentArg arg) +MaaBool combat_move_left_backward(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, + MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, + [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatRightBackward", MaaTaskParam_Empty); + combat_move(sync_context, custom_action_param, 70, 652, 5, 5); return true; } -MaaBool combat_basic_ATK(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, - [[maybe_unused]] MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, - [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) +MaaBool combat_move_right_backward(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, + MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, + [[maybe_unused]] MaaStringView cur_rec_detail, + [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatBasicATK", MaaTaskParam_Empty); + combat_move(sync_context, custom_action_param, 229, 652, 5, 5); return true; } -MaaBool combat_basic_ATK_charge_base(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, - [[maybe_unused]] MaaStringView custom_action_param, - [[maybe_unused]] MaaRectHandle cur_box, - [[maybe_unused]] MaaStringView cur_rec_detail, - [[maybe_unused]] MaaTransparentArg arg) +MaaBool combat_basic_ATK(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, + [[maybe_unused]] MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, + [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - std::random_device rd; - std::mt19937 rng(rd()); - std::uniform_int_distribution uni_x(1146, 1228); - std::uniform_int_distribution uni_y(606, 670); - int32_t x = uni_x(rng); - int32_t y = uni_y(rng); + RandomPointGenerator generator; + int32_t x, y; + generator.generate_point(1146, 606, 82, 64, x, y); - MaaSyncContextTouchDown(sync_context, 0, x, y, 0); - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - MaaSyncContextTouchUp(sync_context, 0); + MaaSyncContextClick(sync_context, x, y); return true; } @@ -97,7 +96,13 @@ MaaBool combat_basic_ATK_charge(MaaSyncContextHandle sync_context, [[maybe_unuse [[maybe_unused]] MaaRectHandle cur_box, [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatBasicATKCharge", MaaTaskParam_Empty); + RandomPointGenerator generator; + int32_t x, y; + generator.generate_point(1146, 606, 82, 64, x, y); + + MaaSyncContextTouchDown(sync_context, 0, x, y, 0); + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + MaaSyncContextTouchUp(sync_context, 0); return true; } @@ -105,7 +110,11 @@ MaaBool combat_evade(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStri [[maybe_unused]] MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatEvade", MaaTaskParam_Empty); + RandomPointGenerator generator; + int32_t x, y; + generator.generate_point(971, 608, 79, 62, x, y); + + MaaSyncContextClick(sync_context, x, y); return true; } @@ -113,26 +122,11 @@ MaaBool combat_ultimate(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaS [[maybe_unused]] MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatUltimate", MaaTaskParam_Empty); - return true; -} - -MaaBool combat_ultimate_charge_base(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStringView task_name, - [[maybe_unused]] MaaStringView custom_action_param, - [[maybe_unused]] MaaRectHandle cur_box, - [[maybe_unused]] MaaStringView cur_rec_detail, - [[maybe_unused]] MaaTransparentArg arg) -{ - std::random_device rd; - std::mt19937 rng(rd()); - std::uniform_int_distribution uni_x(1145, 1227); - std::uniform_int_distribution uni_y(424, 498); - int32_t x = uni_x(rng); - int32_t y = uni_y(rng); + RandomPointGenerator generator; + int32_t x, y; + generator.generate_point(1145, 424, 82, 74, x, y); - MaaSyncContextTouchDown(sync_context, 0, x, y, 0); - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - MaaSyncContextTouchUp(sync_context, 0); + MaaSyncContextClick(sync_context, x, y); return true; } @@ -141,7 +135,13 @@ MaaBool combat_ultimate_charge(MaaSyncContextHandle sync_context, [[maybe_unused [[maybe_unused]] MaaRectHandle cur_box, [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatUltimateCharge", MaaTaskParam_Empty); + RandomPointGenerator generator; + int32_t x, y; + generator.generate_point(1145, 424, 82, 74, x, y); + + MaaSyncContextTouchDown(sync_context, 0, x, y, 0); + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + MaaSyncContextTouchUp(sync_context, 0); return true; } @@ -149,7 +149,11 @@ MaaBool combat_weapon_skill(MaaSyncContextHandle sync_context, [[maybe_unused]] [[maybe_unused]] MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatWeaponSkill", MaaTaskParam_Empty); + RandomPointGenerator generator; + int32_t x, y; + generator.generate_point(977, 444, 69, 64, x, y); + + MaaSyncContextClick(sync_context, x, y); return true; } @@ -157,7 +161,11 @@ MaaBool combat_ELF_skill(MaaSyncContextHandle sync_context, [[maybe_unused]] Maa [[maybe_unused]] MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatELFSkill", MaaTaskParam_Empty); + RandomPointGenerator generator; + int32_t x, y; + generator.generate_point(857, 515, 63, 53, x, y); + + MaaSyncContextClick(sync_context, x, y); return true; } @@ -165,7 +173,11 @@ MaaBool combat_extra_skill(MaaSyncContextHandle sync_context, [[maybe_unused]] M [[maybe_unused]] MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatExtraSkill", MaaTaskParam_Empty); + RandomPointGenerator generator; + int32_t x, y; + generator.generate_point(980, 294, 64, 49, x, y); + + MaaSyncContextClick(sync_context, x, y); return true; } @@ -173,7 +185,11 @@ MaaBool combat_QTE1(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStrin [[maybe_unused]] MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatQTE1", MaaTaskParam_Empty); + RandomPointGenerator generator; + int32_t x, y; + generator.generate_point(1157, 113, 73, 51, x, y); + + MaaSyncContextClick(sync_context, x, y); return true; } @@ -181,6 +197,10 @@ MaaBool combat_QTE2(MaaSyncContextHandle sync_context, [[maybe_unused]] MaaStrin [[maybe_unused]] MaaStringView custom_action_param, [[maybe_unused]] MaaRectHandle cur_box, [[maybe_unused]] MaaStringView cur_rec_detail, [[maybe_unused]] MaaTransparentArg arg) { - MaaSyncContextRunTask(sync_context, "CombatQTE2", MaaTaskParam_Empty); + RandomPointGenerator generator; + int32_t x, y; + generator.generate_point(1160, 261, 70, 56, x, y); + + MaaSyncContextClick(sync_context, x, y); return true; } \ No newline at end of file diff --git a/source/cli/CustomAction/Combat.h b/source/cli/CustomAction/Combat.h index 2a3ddda..a4efe25 100644 --- a/source/cli/CustomAction/Combat.h +++ b/source/cli/CustomAction/Combat.h @@ -2,36 +2,41 @@ #include #include +#include #include #include "MaaFramework/Task/MaaSyncContext.h" -MaaBool combat_forward(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView custom_action_param, - MaaRectHandle cur_box, MaaStringView cur_rec_detail, MaaTransparentArg arg); -MaaBool combat_backward(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView custom_action_param, - MaaRectHandle cur_box, MaaStringView cur_rec_detail, MaaTransparentArg arg); -MaaBool combat_left(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView custom_action_param, - MaaRectHandle cur_box, MaaStringView cur_rec_detail, MaaTransparentArg arg); -MaaBool combat_right(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView custom_action_param, - MaaRectHandle cur_box, MaaStringView cur_rec_detail, MaaTransparentArg arg); -MaaBool combat_left_forward(MaaSyncContextHandle sync_context, MaaStringView task_name, +#include "RandomPointGenerator.h" + +void combat_move(MaaSyncContextHandle sync_context, MaaStringView custom_action_param, int32_t target_x, + int32_t target_y, int32_t target_w, int32_t target_h); + +MaaBool combat_move_forward(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView custom_action_param, MaaRectHandle cur_box, MaaStringView cur_rec_detail, MaaTransparentArg arg); -MaaBool combat_right_forward(MaaSyncContextHandle sync_context, MaaStringView task_name, - MaaStringView custom_action_param, MaaRectHandle cur_box, MaaStringView cur_rec_detail, - MaaTransparentArg arg); -MaaBool combat_left_backward(MaaSyncContextHandle sync_context, MaaStringView task_name, +MaaBool combat_move_backward(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView custom_action_param, MaaRectHandle cur_box, MaaStringView cur_rec_detail, MaaTransparentArg arg); -MaaBool combat_right_backward(MaaSyncContextHandle sync_context, MaaStringView task_name, - MaaStringView custom_action_param, MaaRectHandle cur_box, MaaStringView cur_rec_detail, - MaaTransparentArg arg); +MaaBool combat_move_left(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView custom_action_param, + MaaRectHandle cur_box, MaaStringView cur_rec_detail, MaaTransparentArg arg); +MaaBool combat_move_right(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView custom_action_param, + MaaRectHandle cur_box, MaaStringView cur_rec_detail, MaaTransparentArg arg); +MaaBool combat_move_left_forward(MaaSyncContextHandle sync_context, MaaStringView task_name, + MaaStringView custom_action_param, MaaRectHandle cur_box, MaaStringView cur_rec_detail, + MaaTransparentArg arg); +MaaBool combat_move_right_forward(MaaSyncContextHandle sync_context, MaaStringView task_name, + MaaStringView custom_action_param, MaaRectHandle cur_box, + MaaStringView cur_rec_detail, MaaTransparentArg arg); +MaaBool combat_move_left_backward(MaaSyncContextHandle sync_context, MaaStringView task_name, + MaaStringView custom_action_param, MaaRectHandle cur_box, + MaaStringView cur_rec_detail, MaaTransparentArg arg); +MaaBool combat_move_right_backward(MaaSyncContextHandle sync_context, MaaStringView task_name, + MaaStringView custom_action_param, MaaRectHandle cur_box, + MaaStringView cur_rec_detail, MaaTransparentArg arg); MaaBool combat_basic_ATK(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView custom_action_param, MaaRectHandle cur_box, MaaStringView cur_rec_detail, MaaTransparentArg arg); -MaaBool combat_basic_ATK_charge_base(MaaSyncContextHandle sync_context, MaaStringView task_name, - MaaStringView custom_action_param, MaaRectHandle cur_box, - MaaStringView cur_rec_detail, MaaTransparentArg arg); MaaBool combat_basic_ATK_charge(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView custom_action_param, MaaRectHandle cur_box, MaaStringView cur_rec_detail, MaaTransparentArg arg); @@ -39,9 +44,6 @@ MaaBool combat_evade(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaRectHandle cur_box, MaaStringView cur_rec_detail, MaaTransparentArg arg); MaaBool combat_ultimate(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView custom_action_param, MaaRectHandle cur_box, MaaStringView cur_rec_detail, MaaTransparentArg arg); -MaaBool combat_ultimate_charge_base(MaaSyncContextHandle sync_context, MaaStringView task_name, - MaaStringView custom_action_param, MaaRectHandle cur_box, - MaaStringView cur_rec_detail, MaaTransparentArg arg); MaaBool combat_ultimate_charge(MaaSyncContextHandle sync_context, MaaStringView task_name, MaaStringView custom_action_param, MaaRectHandle cur_box, MaaStringView cur_rec_detail, MaaTransparentArg arg); diff --git a/source/cli/CustomAction/CustomActionRegistry.h b/source/cli/CustomAction/CustomActionRegistry.h index f1e62c8..196df58 100644 --- a/source/cli/CustomAction/CustomActionRegistry.h +++ b/source/cli/CustomAction/CustomActionRegistry.h @@ -5,20 +5,18 @@ void custom_action_init(CustomActionRegistrar& registrar) { - registrar.add_action("Forward", combat_forward); - registrar.add_action("Backward", combat_backward); - registrar.add_action("Left", combat_left); - registrar.add_action("Right", combat_right); - registrar.add_action("LeftForward", combat_left_forward); - registrar.add_action("RightForward", combat_right_forward); - registrar.add_action("LeftBackward", combat_left_backward); - registrar.add_action("RightBackward", combat_right_backward); + registrar.add_action("Forward", combat_move_forward); + registrar.add_action("Backward", combat_move_backward); + registrar.add_action("Left", combat_move_left); + registrar.add_action("Right", combat_move_right); + registrar.add_action("LeftForward", combat_move_left_forward); + registrar.add_action("RightForward", combat_move_right_forward); + registrar.add_action("LeftBackward", combat_move_left_backward); + registrar.add_action("RightBackward", combat_move_right_backward); registrar.add_action("BasicATK", combat_basic_ATK); - registrar.add_action("BasicATKChargeBase", combat_basic_ATK_charge_base); registrar.add_action("BasicATKCharge", combat_basic_ATK_charge); registrar.add_action("Evade", combat_evade); registrar.add_action("Ultimate", combat_ultimate); - registrar.add_action("UltimateChargeBase", combat_ultimate_charge_base); registrar.add_action("UltimateCharge", combat_ultimate_charge); registrar.add_action("WeaponSkill", combat_weapon_skill); registrar.add_action("ELFSkill", combat_ELF_skill); diff --git a/source/cli/CustomAction/RandomPointGenerator.cpp b/source/cli/CustomAction/RandomPointGenerator.cpp new file mode 100644 index 0000000..2059dab --- /dev/null +++ b/source/cli/CustomAction/RandomPointGenerator.cpp @@ -0,0 +1,11 @@ +#include "RandomPointGenerator.h" + +RandomPointGenerator::RandomPointGenerator() : rng_(std::random_device{}()) {} + +void RandomPointGenerator::generate_point(int32_t x, int32_t y, int32_t w, int32_t h, int32_t& rx, int32_t& ry) +{ + std::uniform_int_distribution uni_x(x, x + w); + std::uniform_int_distribution uni_y(y, y + h); + rx = uni_x(rng_); + ry = uni_y(rng_); +} \ No newline at end of file diff --git a/source/cli/CustomAction/RandomPointGenerator.h b/source/cli/CustomAction/RandomPointGenerator.h new file mode 100644 index 0000000..9953b73 --- /dev/null +++ b/source/cli/CustomAction/RandomPointGenerator.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +class RandomPointGenerator +{ +public: + RandomPointGenerator(); + ~RandomPointGenerator() = default; + +public: + void generate_point(int32_t x, int32_t y, int32_t w, int32_t h, int32_t& rx, int32_t& ry); + +private: + std::mt19937 rng_; +}; \ No newline at end of file