feat: 为自动作战添加 放弃行动

This commit is contained in:
晓丶梦丶仁
2025-06-30 01:08:02 +08:00
parent 8805d1a3f1
commit 92d85f56df
7 changed files with 49 additions and 2 deletions

View File

@@ -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",

View File

@@ -195,6 +195,7 @@ enum class ActionType
BulletTime, // 使用 1/5 的速度
Output, // 仅输出,什么都不操作,界面上也不显示
SkillDaemon, // 什么都不做,有技能开技能,直到战斗结束
GiveUp, // 放弃行动
/* for TRN */
MoveCamera, // 引航者试炼,移动镜头

View File

@@ -169,6 +169,13 @@ std::vector<asst::battle::copilot::Action> 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 },

View File

@@ -956,6 +956,19 @@ bool asst::BattleHelper::move_camera(const std::pair<double, double>& 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<OcrTaskInfo>("CharsNameOcrReplace");

View File

@@ -92,6 +92,7 @@ protected:
int max_distance = INT_MAX,
double radian = 0);
bool move_camera(const std::pair<double, double>& delta);
bool give_up();
std::string analyze_detail_page_oper_name(const cv::Mat& image);
std::optional<Rect> get_oper_rect_on_deployment(const std::string& name) const;

View File

@@ -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" },

View File

@@ -157,6 +157,7 @@ public class CopilotModel : CopilotBase
/// <item>"Output" - 打印</item>
/// <item>"SkillDaemon" - 摆完挂机</item>
/// <item>"MoveCamera" - 移动镜头</item>
/// <item>"GiveUp" - 放弃行动</item>
/// </list>
/// </summary>
[JsonProperty("type")]