mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-20 10:57:45 +08:00
feat: 增加 hp 识别标志
This commit is contained in:
@@ -803,9 +803,12 @@
|
||||
"Doc": "base_sharp_task",
|
||||
"algorithm": "JustReturn"
|
||||
},
|
||||
"Roguelike@HpFlag": {
|
||||
"roi": [70, 0, 250, 70]
|
||||
},
|
||||
"Roguelike@HpRecognition": {
|
||||
"baseTask": "NumberOcrReplace",
|
||||
"Doc": "生命值识别,暂时是把整个框进去,估计会把后面的生命值也识别到,后面得改改",
|
||||
"Doc": "生命值识别",
|
||||
"text": [],
|
||||
"roi": [170, 30, 70, 30]
|
||||
},
|
||||
|
||||
BIN
resource/template/Roguelike/base/Roguelike@HpFlag.png
Normal file
BIN
resource/template/Roguelike/base/Roguelike@HpFlag.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
@@ -145,7 +145,7 @@ std::optional<std::string> asst::RoguelikeStageEncounterTaskPlugin::handle_singl
|
||||
|
||||
// 判断是否点击成功,成功进入对话后左上角的生命值会消失
|
||||
image = ctrler()->get_image();
|
||||
bool hp_disappeared = (hp(image) <= 0);
|
||||
bool hp_disappeared = (hp(image) < 0);
|
||||
// fallback 可变选项,临时处理,之后还得改成更通用的方式
|
||||
if (!hp_disappeared) {
|
||||
for (const auto& [total, item] : event.fallback_choices) {
|
||||
@@ -156,7 +156,7 @@ std::optional<std::string> asst::RoguelikeStageEncounterTaskPlugin::handle_singl
|
||||
}
|
||||
sleep(500);
|
||||
image = ctrler()->get_image();
|
||||
if (hp(image) <= 0) {
|
||||
if (hp(image) < 0) {
|
||||
Log.info("Fallback choice success");
|
||||
hp_disappeared = true;
|
||||
break;
|
||||
@@ -170,7 +170,7 @@ std::optional<std::string> asst::RoguelikeStageEncounterTaskPlugin::handle_singl
|
||||
ProcessTask(*this, { "Roguelike@StageEncounterJudgeClick" }).run();
|
||||
ProcessTask(*this, { "Roguelike@StageEncounterJudgeClick2" }).run();
|
||||
image = ctrler()->get_image();
|
||||
if (hp(image) > 0) {
|
||||
if (hp(image) >= 0) {
|
||||
Log.debug("HP gone, going to next_event:", event.next_event);
|
||||
return event.next_event;
|
||||
}
|
||||
@@ -200,7 +200,7 @@ std::optional<std::string> asst::RoguelikeStageEncounterTaskPlugin::handle_singl
|
||||
|
||||
sleep(500);
|
||||
image = ctrler()->get_image();
|
||||
if (hp(image) <= 0) {
|
||||
if (hp(image) < 0) {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
@@ -261,10 +261,15 @@ int asst::RoguelikeStageEncounterTaskPlugin::process_task(const Config::Roguelik
|
||||
return event.default_choose;
|
||||
}
|
||||
|
||||
int asst::RoguelikeStageEncounterTaskPlugin::hp(const cv::Mat& image)
|
||||
int asst::RoguelikeStageEncounterTaskPlugin::hp(const cv::Mat& image) const
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
if (!ProcessTask(*this, { "Roguelike@HpFlag" }).run()) {
|
||||
Log.info("Not found HpFlag");
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto task = Task.get<OcrTaskInfo>("Roguelike@HpRecognition");
|
||||
std::vector<std::pair<std::string, std::string>> merged_map;
|
||||
merged_map.insert(merged_map.end(), task->replace_map.begin(), task->replace_map.end());
|
||||
@@ -286,7 +291,7 @@ int asst::RoguelikeStageEncounterTaskPlugin::hp(const cv::Mat& image)
|
||||
|
||||
auto res_vec_opt = analyzer.analyze();
|
||||
if (!res_vec_opt) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hp_val;
|
||||
|
||||
@@ -22,6 +22,6 @@ protected:
|
||||
std::optional<std::string> handle_single_event(const std::string& event_name);
|
||||
static bool satisfies_condition(const Config::ChoiceRequire& requirement, int special_val);
|
||||
static int process_task(const Config::RoguelikeEvent& event, const int special_val);
|
||||
static int hp(const cv::Mat& image);
|
||||
int hp(const cv::Mat& image) const;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user