diff --git a/resource/tasks/tasks.json b/resource/tasks/tasks.json index 72931fd80a..99cf2dc916 100644 --- a/resource/tasks/tasks.json +++ b/resource/tasks/tasks.json @@ -3805,6 +3805,24 @@ "roi": [1165, 20, 65, 65], "maskRange": [100, 255] }, + "BattleGiveUp": { + "algorithm": "JustReturn", + "action": "ClickRect", + "specificRect": [52, 28, 54, 53], + "next": ["BattleGiveUpConfirm"] + }, + "BattleGiveUpConfirm": { + "algorithm": "OcrDetect", + "action": "ClickSelf", + "text": ["放弃", "行动"], + "roi": [813, 538, 294, 74], + "next": ["BattleGiveUpMissionFailed"] + }, + "BattleGiveUpMissionFailed": { + "algorithm": "JustReturn", + "action": "ClickRect", + "specificRect": [0, 0, 1280, 720] + }, "BattleCancelSelection": { "algorithm": "JustReturn", "action": "ClickRect", diff --git a/src/MaaCore/Common/AsstBattleDef.h b/src/MaaCore/Common/AsstBattleDef.h index 9cf878ffcf..b463dd6530 100644 --- a/src/MaaCore/Common/AsstBattleDef.h +++ b/src/MaaCore/Common/AsstBattleDef.h @@ -195,6 +195,7 @@ enum class ActionType BulletTime, // 使用 1/5 的速度 Output, // 仅输出,什么都不操作,界面上也不显示 SkillDaemon, // 什么都不做,有技能开技能,直到战斗结束 + GiveUp, // 放弃行动 /* for TRN */ MoveCamera, // 引航者试炼,移动镜头 diff --git a/src/MaaCore/Config/Miscellaneous/CopilotConfig.cpp b/src/MaaCore/Config/Miscellaneous/CopilotConfig.cpp index 74f74e0c92..59cda1717c 100644 --- a/src/MaaCore/Config/Miscellaneous/CopilotConfig.cpp +++ b/src/MaaCore/Config/Miscellaneous/CopilotConfig.cpp @@ -169,6 +169,13 @@ std::vector asst::CopilotConfig::parse_actions(co { "摆完挂机", ActionType::SkillDaemon }, { "开摆", ActionType::SkillDaemon }, + { "GiveUp", ActionType::GiveUp }, + { "giveup", ActionType::GiveUp }, + { "GIVEUP", ActionType::GiveUp }, + { "Giveup", ActionType::GiveUp }, + { "放弃", ActionType::GiveUp }, + { "放弃行动", ActionType::GiveUp }, + { "MoveCamera", ActionType::MoveCamera }, { "movecamera", ActionType::MoveCamera }, { "MOVECAMERA", ActionType::MoveCamera }, diff --git a/src/MaaCore/Task/BattleHelper.cpp b/src/MaaCore/Task/BattleHelper.cpp index 12fd74e79e..f2db27d1d2 100644 --- a/src/MaaCore/Task/BattleHelper.cpp +++ b/src/MaaCore/Task/BattleHelper.cpp @@ -956,6 +956,19 @@ bool asst::BattleHelper::move_camera(const std::pair& delta) return update_deployment(true); } +bool asst::BattleHelper::give_up() +{ + LogTraceFunction; + if (!m_in_battle) { + Log.error("Not in battle, cannot give up"); + return false; + } + + ProcessTask(this_task(), { "BattleGiveUp" }).run(); + check_in_battle(); + return true; +} + std::string asst::BattleHelper::analyze_detail_page_oper_name(const cv::Mat& image) { const auto& replace_task = Task.get("CharsNameOcrReplace"); diff --git a/src/MaaCore/Task/BattleHelper.h b/src/MaaCore/Task/BattleHelper.h index 9d552db543..b4b067cdf8 100644 --- a/src/MaaCore/Task/BattleHelper.h +++ b/src/MaaCore/Task/BattleHelper.h @@ -92,6 +92,7 @@ protected: int max_distance = INT_MAX, double radian = 0); bool move_camera(const std::pair& delta); + bool give_up(); std::string analyze_detail_page_oper_name(const cv::Mat& image); std::optional get_oper_rect_on_deployment(const std::string& name) const; diff --git a/src/MaaCore/Task/Miscellaneous/BattleProcessTask.cpp b/src/MaaCore/Task/Miscellaneous/BattleProcessTask.cpp index 130359ae56..dff60d73fb 100644 --- a/src/MaaCore/Task/Miscellaneous/BattleProcessTask.cpp +++ b/src/MaaCore/Task/Miscellaneous/BattleProcessTask.cpp @@ -262,6 +262,11 @@ bool asst::BattleProcessTask::do_action(const battle::copilot::Action& action, s case ActionType::SkillDaemon: ret = wait_until_end(); break; + + case ActionType::GiveUp: + ret = give_up(); + break; + default: ret = do_derived_action(action, index); break; @@ -288,11 +293,12 @@ void asst::BattleProcessTask::notify_action(const battle::copilot::Action& actio { ActionType::Deploy, "Deploy" }, { ActionType::UseSkill, "UseSkill" }, { ActionType::Retreat, "Retreat" }, - { ActionType::SkillDaemon, "SkillDaemon" }, - { ActionType::SwitchSpeed, "SwitchSpeed" }, { ActionType::SkillUsage, "SkillUsage" }, + { ActionType::SwitchSpeed, "SwitchSpeed" }, { ActionType::BulletTime, "BulletTime" }, { ActionType::Output, "Output" }, + { ActionType::SkillDaemon, "SkillDaemon" }, + { ActionType::GiveUp, "GiveUp" }, { ActionType::MoveCamera, "MoveCamera" }, { ActionType::DrawCard, "DrawCard" }, { ActionType::CheckIfStartOver, "CheckIfStartOver" }, diff --git a/src/MaaWpfGui/Models/Copilot/CopilotModel.cs b/src/MaaWpfGui/Models/Copilot/CopilotModel.cs index 7a960bcb11..ece4d06886 100644 --- a/src/MaaWpfGui/Models/Copilot/CopilotModel.cs +++ b/src/MaaWpfGui/Models/Copilot/CopilotModel.cs @@ -157,6 +157,7 @@ public class CopilotModel : CopilotBase /// "Output" - 打印 /// "SkillDaemon" - 摆完挂机 /// "MoveCamera" - 移动镜头 + /// "GiveUp" - 放弃行动 /// /// [JsonProperty("type")]