1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-14 14:19:25 +08:00

add: chapter auto next battle

This commit is contained in:
0O0o0oOoO00
2025-11-16 19:38:48 +08:00
parent 54afb027d8
commit 30c00628f8
17 changed files with 120 additions and 1 deletions

View File

@@ -248,6 +248,7 @@ void Cracker::disable_all() {
disable_skip_ship_gain_show();
disable_chapter_force_enable_auto_fight();
disable_chapter_skip_precombat();
disable_chapter_auto_next_battle();
}
void Cracker::enable_hooked_lua_function_trace() {
@@ -266,6 +267,14 @@ void Cracker::disable_chapter_skip_precombat() {
DISABLE(CHAPTER_SKIP_PRECOMBAT);
}
void Cracker::enable_chapter_auto_next_battle() {
ENABLE(CHAPTER_AUTO_NEXT_BATTLE);
}
void Cracker::disable_chapter_auto_next_battle() {
DISABLE(CHAPTER_AUTO_NEXT_BATTLE);
}
void Cracker::enable_chapter_force_enable_auto_fight() {
ENABLE(CHAPTER_FORCE_ENABLE_AUTO_FIGHT);
}
@@ -554,6 +563,7 @@ void Cracker::load_lua_resources() {
m_lua_res.getProxy = m_state["getProxy"];
m_lua_res.ChapterProxy = m_state["ChapterProxy"];
m_lua_res.ChapterProxy_GetChapterAutoFlag = m_state["ChapterProxy"]["GetChapterAutoFlag"];
m_lua_res.ChapterProxy_SetChapterAutoFlag = m_state["ChapterProxy"]["SetChapterAutoFlag"];
SPDLOG_INFO("Load lua functions");
m_original.GetBattleCheckResult = m_state["GetBattleCheckResult"];
@@ -588,11 +598,34 @@ void Cracker::load_lua_resources() {
m_original.Chapter_CanActivateAutoFight = m_state["Chapter"]["CanActivateAutoFight"];
m_original.Chapter_IsAutoFight = m_state["Chapter"]["IsAutoFight"];
m_original.Chapter_IsSkipPrecombat = m_state["Chapter"]["IsSkipPrecombat"];
m_original.Chapter_writeBack = m_state["Chapter"]["writeBack"];
}
void Cracker::hook_all_lua_functions() {
SPDLOG_INFO("Hook lua functions");
// chapter_auto_next_battle
m_state["Chapter"]["writeBack"] = [this](sol::this_state L, Lua::VariadicArgs args) {
CALLED(Chapter.writeBack);
if (!IS_ENABLED(CHAPTER_AUTO_NEXT_BATTLE)) {
m_original.Chapter_writeBack(L, args);
return;
}
m_original.Chapter_writeBack(L, args);
bool is_win = args[1];
if (!is_win) {
return;
}
Lua::Table self = args[0];
Lua::Object chapter_proxy = m_lua_res.getProxy(L, m_lua_res.ChapterProxy);
int id = self["id"];
m_lua_res.ChapterProxy_SetChapterAutoFlag(L, chapter_proxy, id, true);
};
// chapter_skip_precombat
m_state["Chapter"]["IsSkipPrecombat"] = [this](sol::this_state L, Lua::VariadicArgs args) -> Lua::Object {
CALLED(Chapter.IsSkipPrecombat);
@@ -1255,6 +1288,7 @@ Cracker::Config Cracker::get_config() {
SET_CONFIG_FLAG(SKIP_SHIP_GAIN_SHOW),
SET_CONFIG_FLAG(CHAPTER_FORCE_ENABLE_AUTO_FIGHT),
SET_CONFIG_FLAG(CHAPTER_SKIP_PRECOMBAT),
SET_CONFIG_FLAG(CHAPTER_AUTO_NEXT_BATTLE),
},
.globle_ship_properties = m_globle_ship_properties,
.global_speedup_rate = static_cast<int>(m_global_speedup_rate),
@@ -1286,6 +1320,12 @@ void Cracker::apply_config(Config& config) {
disable_chapter_force_enable_auto_fight();
}
if(IS_CONFIG_ENABLED(CHAPTER_AUTO_NEXT_BATTLE)) {
enable_chapter_auto_next_battle();
} else {
disable_chapter_auto_next_battle();
}
if(IS_CONFIG_ENABLED(SKIP_SHIP_GAIN_SHOW)) {
enable_skip_ship_gain_show();
} else {