feat: 增加暂停放技能和暂停撤退 (#9348)

This commit is contained in:
Lancarus
2024-06-12 18:22:52 +08:00
committed by GitHub
parent f2ca2e48aa
commit 90d3c140fe
2 changed files with 56 additions and 5 deletions

View File

@@ -390,7 +390,7 @@ bool asst::BattleHelper::deploy_oper(
if (deploy_with_pause) {
// m_inst_helper.ctrler()->press_esc();
ProcessTask(this_task(), { "BattlePause" }).run();
ProcessTask(this_task(), { "BattlePauseCancel" }).run();
}
// for SSS, multiple operator may be deployed at the same location.
@@ -556,8 +556,7 @@ bool asst::BattleHelper::do_strategic_action(const cv::Mat& reusable)
bool asst::BattleHelper::use_all_ready_skill(const cv::Mat& reusable)
{
// TODO: 可配置延迟时间
static constexpr auto min_frame_interval =
std::chrono::milliseconds(1000);
static constexpr auto min_frame_interval = std::chrono::milliseconds(1000);
bool used = false;
cv::Mat image = reusable.empty() ? m_inst_helper.ctrler()->get_image() : reusable;
@@ -572,7 +571,10 @@ bool asst::BattleHelper::use_all_ready_skill(const cv::Mat& reusable)
const auto now = std::chrono::steady_clock::now();
if (auto interval = now - last_use_time; min_frame_interval > interval) {
Log.debug(name, "use skill too fast, interval time:", std::chrono::duration_cast<std::chrono::milliseconds>(interval));
Log.debug(
name,
"use skill too fast, interval time:",
std::chrono::duration_cast<std::chrono::milliseconds>(interval));
continue;
}
@@ -727,16 +729,33 @@ bool asst::BattleHelper::click_oper_on_battlefield(const Point& loc)
bool asst::BattleHelper::click_retreat()
{
LogTraceFunction;
bool deploy_with_pause = ControlFeat::support(
m_inst_helper.ctrler()->support_features(),
ControlFeat::SWIPE_WITH_PAUSE);
if (deploy_with_pause) {
ProcessTask(this_task(), { "BattlePause" }).run();
}
// return ProcessTask(this_task(), { "BattleOperRetreatJustClick" }).run();
return m_inst_helper.ctrler()->click(m_retreat_button_pos);
bool ret = m_inst_helper.ctrler()->click(m_retreat_button_pos);
if (deploy_with_pause) {
ProcessTask(this_task(), { "BattlePauseCancel" }).run();
}
return ret;
}
// TODO: use m_skill_button_pos
bool asst::BattleHelper::click_skill(bool keep_waiting)
{
LogTraceFunction;
bool deploy_with_pause = ControlFeat::support(
m_inst_helper.ctrler()->support_features(),
ControlFeat::SWIPE_WITH_PAUSE);
if (!keep_waiting && deploy_with_pause) {
ProcessTask(this_task(), { "BattlePause" }).run();
}
ProcessTask skill_task(
this_task(),
{ "BattleSkillReadyOnClick",
@@ -753,6 +772,9 @@ bool asst::BattleHelper::click_skill(bool keep_waiting)
if (!ret) {
cancel_oper_selection();
}
if (deploy_with_pause) {
ProcessTask(this_task(), { "BattlePauseCancel" }).run();
}
return ret;
}
}