mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 18:20:39 +08:00
fix: 更新一些操作的中文命名,当锚点不匹配时新增退出条件作为保护
This commit is contained in:
@@ -317,8 +317,8 @@ struct CheckInfo
|
||||
// 定义until操作需要的信息
|
||||
struct UntilInfo
|
||||
{
|
||||
TriggerInfo::Category mode; // all 全部命令执行完毕后才结束, any 只要有一个执行就结束
|
||||
std::vector<ActionPtr> candidate; // 备用的命令序列
|
||||
TriggerInfo::Category mode = TriggerInfo::Category::All; // all 全部命令执行完毕后才结束, any 只要有一个执行就结束
|
||||
std::vector<ActionPtr> candidate; // 备用的命令序列
|
||||
};
|
||||
|
||||
// 定义point操作需要的信息
|
||||
@@ -332,6 +332,8 @@ struct PointInfo
|
||||
int interval = 0;
|
||||
|
||||
std::chrono::steady_clock::time_point tNow;
|
||||
|
||||
SnapShot() = default;
|
||||
};
|
||||
|
||||
std::string target_code;
|
||||
@@ -340,6 +342,8 @@ struct PointInfo
|
||||
|
||||
std::vector<ActionPtr> then_actions; // 当条件满足时执行
|
||||
std::vector<ActionPtr> else_actions; // 当条件不满足时执行
|
||||
|
||||
PointInfo() = default;
|
||||
};
|
||||
|
||||
struct CheckIfStartOverInfo
|
||||
|
||||
@@ -217,13 +217,13 @@ bool asst::CopilotConfig::parse_action(const json::value& action_info, asst::bat
|
||||
{ "Check", ActionType::Check },
|
||||
{ "check", ActionType::Check },
|
||||
{ "CHECK", ActionType::Check },
|
||||
{ "检查", ActionType::Check },
|
||||
{ "确认", ActionType::Check },
|
||||
{ "分支", ActionType::Check },
|
||||
|
||||
{ "Until", ActionType::Until },
|
||||
{ "until", ActionType::Until },
|
||||
{ "UNTIL", ActionType::Until },
|
||||
{ "直到", ActionType::Until },
|
||||
{ "轮询", ActionType::Until },
|
||||
|
||||
{ "SavePoint", ActionType::SavePoint },
|
||||
{ "savepoint", ActionType::SavePoint },
|
||||
@@ -376,8 +376,11 @@ bool asst::CopilotConfig::parse_action(const json::value& action_info, asst::bat
|
||||
case ActionType::Until: {
|
||||
auto& until = action.payload.emplace<UntilInfo>();
|
||||
|
||||
// 必选字段
|
||||
until.mode = TriggerInfo::loadCategoryFrom(action_info.at("mode").as_string());
|
||||
// 可选字段
|
||||
if (auto t = action_info.find("mode")) {
|
||||
until.mode = TriggerInfo::loadCategoryFrom(t.value().as_string());
|
||||
}
|
||||
|
||||
switch (until.mode) {
|
||||
case TriggerInfo::Category::Any:
|
||||
case TriggerInfo::Category::All:
|
||||
@@ -387,8 +390,13 @@ bool asst::CopilotConfig::parse_action(const json::value& action_info, asst::bat
|
||||
break;
|
||||
}
|
||||
|
||||
// 必选字段,缺省值为0
|
||||
action.trigger.count = action_info.get("limit", 0);
|
||||
// 可选字段,缺省值为0
|
||||
if (auto t = action_info.find("limit")) {
|
||||
action.trigger.count = t.value().as_integer();
|
||||
}
|
||||
else if (action.trigger.count == TriggerInfo::DEACTIVE_COUNT) {
|
||||
action.trigger.count = 0;
|
||||
}
|
||||
|
||||
// 可选字段
|
||||
if (auto t = action_info.find("candidate_actions")) {
|
||||
|
||||
@@ -420,6 +420,12 @@ END_LOOP:;
|
||||
case ActionType::SyncPoint: {
|
||||
auto& info = action.getPayload<PointInfo>();
|
||||
|
||||
// 目标编码不匹配,退出
|
||||
if (!find_snap_shot(info.target_code)) {
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
|
||||
thread_local auto prev_frame_time = std::chrono::steady_clock::time_point {};
|
||||
static const auto min_frame_interval =
|
||||
std::chrono::milliseconds(Config.get_options().copilot_fight_screencap_interval);
|
||||
@@ -454,6 +460,12 @@ END_LOOP:;
|
||||
case ActionType::CheckPoint: {
|
||||
auto& info = action.getPayload<PointInfo>();
|
||||
|
||||
// 目标编码不匹配,退出
|
||||
if (!find_snap_shot(info.target_code)) {
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (check_point(info)) {
|
||||
size_t i = 0;
|
||||
for (; i < info.then_actions.size(); ++i) {
|
||||
@@ -1293,10 +1305,13 @@ auto asst::BattleProcessTask::gen_snap_shot() -> battle::copilot::PointInfo::Sna
|
||||
return shot;
|
||||
}
|
||||
|
||||
bool asst::BattleProcessTask::find_snap_shot(const std::string& code) const noexcept
|
||||
{
|
||||
return m_snap_shots.find(code) != m_snap_shots.cend();
|
||||
}
|
||||
|
||||
void asst::BattleProcessTask::save_snap_shot(const std::string& code)
|
||||
{
|
||||
using TriggerInfo = battle::copilot::TriggerInfo;
|
||||
|
||||
if (code.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,9 +68,8 @@ protected:
|
||||
void sleep_and_do_strategy(unsigned millisecond);
|
||||
|
||||
auto gen_snap_shot() -> battle::copilot::PointInfo::SnapShot;
|
||||
|
||||
bool find_snap_shot(const std::string& code) const noexcept;
|
||||
void save_snap_shot(const std::string& code);
|
||||
|
||||
auto get_snap_shot(const std::string& code) const noexcept -> battle::copilot::PointInfo::SnapShot const&;
|
||||
|
||||
virtual bool check_in_battle(const cv::Mat& reusable = cv::Mat(), bool weak = true) override;
|
||||
|
||||
Reference in New Issue
Block a user