mirror of
https://github.com/0O0o0oOoO00/Alas.git
synced 2026-05-14 14:19:25 +08:00
add: chapter force enable auto fight
This commit is contained in:
@@ -246,6 +246,7 @@ void Cracker::disable_all() {
|
||||
disable_opsi_force_auto();
|
||||
disable_opsi_no_map_fog();
|
||||
disable_skip_ship_gain_show();
|
||||
disable_chapter_force_enable_auto_fight();
|
||||
}
|
||||
|
||||
void Cracker::enable_hooked_lua_function_trace() {
|
||||
@@ -256,6 +257,14 @@ void Cracker::disable_hooked_lua_function_trace() {
|
||||
DISABLE(HOOKED_LUA_FUNCTION_TRACE);
|
||||
}
|
||||
|
||||
void Cracker::enable_chapter_force_enable_auto_fight() {
|
||||
ENABLE(CHAPTER_FORCE_ENABLE_AUTO_FIGHT);
|
||||
}
|
||||
|
||||
void Cracker::disable_chapter_force_enable_auto_fight() {
|
||||
DISABLE(CHAPTER_FORCE_ENABLE_AUTO_FIGHT);
|
||||
}
|
||||
|
||||
void Cracker::enable_skip_ship_gain_show() {
|
||||
ENABLE(SKIP_SHIP_GAIN_SHOW);
|
||||
}
|
||||
@@ -533,6 +542,9 @@ void Cracker::load_lua_resources() {
|
||||
};
|
||||
m_lua_res.BattleResultMediator_GET_NEW_SHIP = m_state["BattleResultMediator"]["GET_NEW_SHIP"];
|
||||
m_lua_res.NewBattleResultMediator_GET_NEW_SHIP = m_state["NewBattleResultMediator"]["GET_NEW_SHIP"];
|
||||
m_lua_res.getProxy = m_state["getProxy"];
|
||||
m_lua_res.ChapterProxy = m_state["ChapterProxy"];
|
||||
m_lua_res.ChapterProxy_GetChapterAutoFlag = m_state["ChapterProxy"]["GetChapterAutoFlag"];
|
||||
|
||||
SPDLOG_INFO("Load lua functions");
|
||||
m_original.GetBattleCheckResult = m_state["GetBattleCheckResult"];
|
||||
@@ -564,11 +576,44 @@ void Cracker::load_lua_resources() {
|
||||
m_original.WorldMap_UpdateVisionFlag = m_state["WorldMap"]["UpdateVisionFlag"];
|
||||
m_original.NewBattleResultDisplayAwardPage_ShowShips = m_state["NewBattleResultDisplayAwardPage"]["ShowShips"];
|
||||
m_original.BaseUI_emit = m_state["BaseUI"]["emit"];
|
||||
m_original.Chapter_CanActivateAutoFight = m_state["Chapter"]["CanActivateAutoFight"];
|
||||
m_original.Chapter_IsAutoFight = m_state["Chapter"]["IsAutoFight"];
|
||||
}
|
||||
|
||||
void Cracker::hook_all_lua_functions() {
|
||||
SPDLOG_INFO("Hook lua functions");
|
||||
|
||||
// force_enable_auto_fight
|
||||
m_state["Chapter"]["CanActivateAutoFight"] = [this](sol::this_state L, Lua::VariadicArgs args) -> Lua::Object {
|
||||
CALLED(Chapter.CanActivateAutoFight);
|
||||
if (!IS_ENABLED(CHAPTER_FORCE_ENABLE_AUTO_FIGHT)) {
|
||||
return m_original.Chapter_CanActivateAutoFight(L, args);
|
||||
}
|
||||
return sol::make_object(L, true);
|
||||
};
|
||||
|
||||
m_state["Chapter"]["IsAutoFight"] = [this](sol::this_state L, Lua::VariadicArgs args) -> Lua::Object {
|
||||
CALLED(Chapter.IsAutoFight);
|
||||
if (!IS_ENABLED(CHAPTER_FORCE_ENABLE_AUTO_FIGHT)) {
|
||||
return m_original.Chapter_IsAutoFight(L, args);
|
||||
}
|
||||
|
||||
Lua::Object chapter_proxy = m_lua_res.getProxy(L, m_lua_res.ChapterProxy);
|
||||
|
||||
int id = args[0].as<Lua::Table>()["id"];
|
||||
Lua::Object flag = m_lua_res.ChapterProxy_GetChapterAutoFlag(L, chapter_proxy, id);
|
||||
|
||||
auto flag_type = flag.get_type();
|
||||
if (flag_type == sol::type::nil) {
|
||||
return sol::make_object(L, true);
|
||||
} else if (flag_type == sol::type::number) {
|
||||
return sol::make_object(L, flag.as<int>() != 0);
|
||||
} else {
|
||||
return sol::make_object(L, false);
|
||||
}
|
||||
return sol::make_object(L, false);
|
||||
};
|
||||
|
||||
// skip_ship_gain_show
|
||||
m_state["NewBattleResultDisplayAwardPage"]["ShowShips"] = [this](sol::this_state L, Lua::VariadicArgs args) {
|
||||
CALLED(NewBattleResultDisplayAwardPage.ShowShips);
|
||||
@@ -1189,6 +1234,7 @@ Cracker::Config Cracker::get_config() {
|
||||
SET_CONFIG_FLAG(OPSI_FORCE_AUTO),
|
||||
SET_CONFIG_FLAG(OPSI_NO_MAP_FOG),
|
||||
SET_CONFIG_FLAG(SKIP_SHIP_GAIN_SHOW),
|
||||
SET_CONFIG_FLAG(CHAPTER_FORCE_ENABLE_AUTO_FIGHT),
|
||||
},
|
||||
.globle_ship_properties = m_globle_ship_properties,
|
||||
.global_speedup_rate = static_cast<int>(m_global_speedup_rate),
|
||||
@@ -1208,6 +1254,12 @@ void Cracker::apply_config(Config& config) {
|
||||
disable_hooked_lua_function_trace();
|
||||
}
|
||||
|
||||
if(IS_CONFIG_ENABLED(CHAPTER_FORCE_ENABLE_AUTO_FIGHT)) {
|
||||
enable_chapter_force_enable_auto_fight();
|
||||
} else {
|
||||
disable_chapter_force_enable_auto_fight();
|
||||
}
|
||||
|
||||
if(IS_CONFIG_ENABLED(SKIP_SHIP_GAIN_SHOW)) {
|
||||
enable_skip_ship_gain_show();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user