From 54afb027d80564924f656da98a30b6cac0e41d5b Mon Sep 17 00:00:00 2001 From: 0O0o0oOoO00 <11174151+0O0o0oOoO00@users.noreply.github.com> Date: Sun, 16 Nov 2025 18:27:53 +0800 Subject: [PATCH] add: chapter skip precombat --- blcrack/cracker/cracker.cpp | 26 ++++++++++++++++++++++++++ blcrack/cracker/cracker.hpp | 6 ++++++ blcrack/cracker/server.cpp | 22 ++++++++++++++++++++++ blcrack/cracker/ui/ui.cpp | 1 + blcrack/http/cracker.http | 6 ++++++ config/template.json | 3 ++- module/config/argument/args.json | 4 ++++ module/config/argument/argument.yaml | 1 + module/config/config_generated.py | 1 + module/config/full_config_generated.py | 1 + module/config/i18n/en-US.json | 4 ++++ module/config/i18n/ja-JP.json | 4 ++++ module/config/i18n/zh-CN.json | 4 ++++ module/config/i18n/zh-TW.json | 4 ++++ module/luahook/api.py | 6 ++++++ module/luahook/crack.py | 7 +++++++ module/luahook/op.py | 6 ++++++ 17 files changed, 105 insertions(+), 1 deletion(-) diff --git a/blcrack/cracker/cracker.cpp b/blcrack/cracker/cracker.cpp index 258beb613..d77efa80a 100644 --- a/blcrack/cracker/cracker.cpp +++ b/blcrack/cracker/cracker.cpp @@ -247,6 +247,7 @@ void Cracker::disable_all() { disable_opsi_no_map_fog(); disable_skip_ship_gain_show(); disable_chapter_force_enable_auto_fight(); + disable_chapter_skip_precombat(); } void Cracker::enable_hooked_lua_function_trace() { @@ -257,6 +258,14 @@ void Cracker::disable_hooked_lua_function_trace() { DISABLE(HOOKED_LUA_FUNCTION_TRACE); } +void Cracker::enable_chapter_skip_precombat() { + ENABLE(CHAPTER_SKIP_PRECOMBAT); +} + +void Cracker::disable_chapter_skip_precombat() { + DISABLE(CHAPTER_SKIP_PRECOMBAT); +} + void Cracker::enable_chapter_force_enable_auto_fight() { ENABLE(CHAPTER_FORCE_ENABLE_AUTO_FIGHT); } @@ -578,11 +587,21 @@ void Cracker::load_lua_resources() { m_original.BaseUI_emit = m_state["BaseUI"]["emit"]; m_original.Chapter_CanActivateAutoFight = m_state["Chapter"]["CanActivateAutoFight"]; m_original.Chapter_IsAutoFight = m_state["Chapter"]["IsAutoFight"]; + m_original.Chapter_IsSkipPrecombat = m_state["Chapter"]["IsSkipPrecombat"]; } void Cracker::hook_all_lua_functions() { SPDLOG_INFO("Hook lua functions"); + // chapter_skip_precombat + m_state["Chapter"]["IsSkipPrecombat"] = [this](sol::this_state L, Lua::VariadicArgs args) -> Lua::Object { + CALLED(Chapter.IsSkipPrecombat); + if (!IS_ENABLED(CHAPTER_SKIP_PRECOMBAT)) { + return m_original.Chapter_IsSkipPrecombat(L, args); + } + return sol::make_object(L, true); + }; + // force_enable_auto_fight m_state["Chapter"]["CanActivateAutoFight"] = [this](sol::this_state L, Lua::VariadicArgs args) -> Lua::Object { CALLED(Chapter.CanActivateAutoFight); @@ -1235,6 +1254,7 @@ Cracker::Config Cracker::get_config() { SET_CONFIG_FLAG(OPSI_NO_MAP_FOG), SET_CONFIG_FLAG(SKIP_SHIP_GAIN_SHOW), SET_CONFIG_FLAG(CHAPTER_FORCE_ENABLE_AUTO_FIGHT), + SET_CONFIG_FLAG(CHAPTER_SKIP_PRECOMBAT), }, .globle_ship_properties = m_globle_ship_properties, .global_speedup_rate = static_cast(m_global_speedup_rate), @@ -1254,6 +1274,12 @@ void Cracker::apply_config(Config& config) { disable_hooked_lua_function_trace(); } + if(IS_CONFIG_ENABLED(CHAPTER_SKIP_PRECOMBAT)) { + enable_chapter_skip_precombat(); + } else { + disable_chapter_skip_precombat(); + } + if(IS_CONFIG_ENABLED(CHAPTER_FORCE_ENABLE_AUTO_FIGHT)) { enable_chapter_force_enable_auto_fight(); } else { diff --git a/blcrack/cracker/cracker.hpp b/blcrack/cracker/cracker.hpp index fc2998419..1143396ea 100644 --- a/blcrack/cracker/cracker.hpp +++ b/blcrack/cracker/cracker.hpp @@ -92,6 +92,7 @@ public: bool OPSI_NO_MAP_FOG = false; bool SKIP_SHIP_GAIN_SHOW = false; bool CHAPTER_FORCE_ENABLE_AUTO_FIGHT = false; + bool CHAPTER_SKIP_PRECOMBAT = false; } flag; ShipProperties globle_ship_properties; int global_speedup_rate = 1; @@ -130,6 +131,9 @@ public: void enable_hooked_lua_function_trace(); void disable_hooked_lua_function_trace(); + void enable_chapter_skip_precombat(); + void disable_chapter_skip_precombat(); + void enable_chapter_force_enable_auto_fight(); void disable_chapter_force_enable_auto_fight(); @@ -241,6 +245,7 @@ private: std::atomic OPSI_NO_MAP_FOG = false; std::atomic SKIP_SHIP_GAIN_SHOW = false; std::atomic CHAPTER_FORCE_ENABLE_AUTO_FIGHT = false; + std::atomic CHAPTER_SKIP_PRECOMBAT = false; } m_flag; struct { @@ -283,6 +288,7 @@ private: Lua::Function BaseUI_emit; Lua::Function Chapter_CanActivateAutoFight; Lua::Function Chapter_IsAutoFight; + Lua::Function Chapter_IsSkipPrecombat; } m_original; struct { Lua::Function Clone; diff --git a/blcrack/cracker/server.cpp b/blcrack/cracker/server.cpp index ec5c63da0..4e0fd237d 100644 --- a/blcrack/cracker/server.cpp +++ b/blcrack/cracker/server.cpp @@ -938,6 +938,28 @@ CrackerServer::CrackerServer() { CRACK_OK(); }); + Post("/enable_chapter_skip_precombat", [](const httplib::Request& req, httplib::Response& res) { + try { + Cracker::Instance().enable_chapter_skip_precombat(); + } catch (std::exception& e) { + SPDLOG_ERROR("Enable chapter skip precombat failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + + Post("/disable_chapter_skip_precombat", [](const httplib::Request& req, httplib::Response& res) { + try { + Cracker::Instance().disable_chapter_skip_precombat(); + } catch (std::exception& e) { + SPDLOG_ERROR("Disable chapter skip precombat failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + Post("/init", [](const httplib::Request& req, httplib::Response& res) { try { Cracker::Instance(); diff --git a/blcrack/cracker/ui/ui.cpp b/blcrack/cracker/ui/ui.cpp index 3cf4e3708..b3e0c599e 100644 --- a/blcrack/cracker/ui/ui.cpp +++ b/blcrack/cracker/ui/ui.cpp @@ -103,6 +103,7 @@ void CrackerUI::draw_menu() { ImGui::Checkbox("移除低心情警告", &CONFIG_FLAG(NO_EMOTION_WARNING)); ImGui::Checkbox("跳过战斗胜利庆祝", &CONFIG_FLAG(SKIP_BATTLE_CELEBRATE)); ImGui::Checkbox("章节图强制开启自动战斗", &CONFIG_FLAG(CHAPTER_FORCE_ENABLE_AUTO_FIGHT)); + ImGui::Checkbox("章节图跳过战前准备", &CONFIG_FLAG(CHAPTER_SKIP_PRECOMBAT)); ImGui::Checkbox("演习锁血", &CONFIG_FLAG(EXERCISE_GOD_MOD)); ImGui::TableNextColumn(); diff --git a/blcrack/http/cracker.http b/blcrack/http/cracker.http index eb0aed878..35d7959e0 100644 --- a/blcrack/http/cracker.http +++ b/blcrack/http/cracker.http @@ -191,6 +191,12 @@ POST http://{{Host}}:{{Port}}/enable_chapter_force_enable_auto_fight ### POST http://{{Host}}:{{Port}}/disable_chapter_force_enable_auto_fight +### +POST http://{{Host}}:{{Port}}/enable_chapter_skip_precombat + +### +POST http://{{Host}}:{{Port}}/disable_chapter_skip_precombat + ### POST http://{{Host}}:{{Port}}/is_alive diff --git a/config/template.json b/config/template.json index 3996be16e..7dc0c15ec 100644 --- a/config/template.json +++ b/config/template.json @@ -223,7 +223,8 @@ "OpsiForceAuto": false, "OpsiNoMapFog": false, "SkipShipGainShow": false, - "ChapterForceEnableAutoFight": false + "ChapterForceEnableAutoFight": false, + "ChapterSkipPrecombat": false }, "ShipProperty": { "Method": "disable", diff --git a/module/config/argument/args.json b/module/config/argument/args.json index 27c31efe1..ab91a0530 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -889,6 +889,10 @@ "ChapterForceEnableAutoFight": { "type": "checkbox", "value": false + }, + "ChapterSkipPrecombat": { + "type": "checkbox", + "value": false } }, "ShipProperty": { diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index caa7ca05c..fc19155e6 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -888,6 +888,7 @@ Misc: OpsiNoMapFog: false SkipShipGainShow: false ChapterForceEnableAutoFight: false + ChapterSkipPrecombat: false # ==================== Cheat ==================== PowerLimit: diff --git a/module/config/config_generated.py b/module/config/config_generated.py index 464daaa74..c5ba9813f 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -543,6 +543,7 @@ class GeneratedConfig: Misc_OpsiNoMapFog = False Misc_SkipShipGainShow = False Misc_ChapterForceEnableAutoFight = False + Misc_ChapterSkipPrecombat = False # Group `PowerLimit` PowerLimit_Enable = True diff --git a/module/config/full_config_generated.py b/module/config/full_config_generated.py index c53ac81ce..e6032c7d6 100644 --- a/module/config/full_config_generated.py +++ b/module/config/full_config_generated.py @@ -157,6 +157,7 @@ class FullGeneratedConfig: Hook_Misc_OpsiNoMapFog = None Hook_Misc_SkipShipGainShow = None Hook_Misc_ChapterForceEnableAutoFight = None + Hook_Misc_ChapterSkipPrecombat = None Hook_ShipProperty_Method = None Hook_ShipProperty_Factor = None Hook_ShipProperty_Armor = None diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index 593800e3b..73f988352 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -3132,6 +3132,10 @@ "ChapterForceEnableAutoFight": { "name": "Misc.ChapterForceEnableAutoFight.name", "help": "Misc.ChapterForceEnableAutoFight.help" + }, + "ChapterSkipPrecombat": { + "name": "Misc.ChapterSkipPrecombat.name", + "help": "Misc.ChapterSkipPrecombat.help" } }, "PowerLimit": { diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index e05b99cc1..9f55ee3d4 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -3132,6 +3132,10 @@ "ChapterForceEnableAutoFight": { "name": "Misc.ChapterForceEnableAutoFight.name", "help": "Misc.ChapterForceEnableAutoFight.help" + }, + "ChapterSkipPrecombat": { + "name": "Misc.ChapterSkipPrecombat.name", + "help": "Misc.ChapterSkipPrecombat.help" } }, "PowerLimit": { diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index c73e0429a..b153598ad 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -3132,6 +3132,10 @@ "ChapterForceEnableAutoFight": { "name": "章节图强制开启自动战斗", "help": "" + }, + "ChapterSkipPrecombat": { + "name": "章节图跳过战前准备", + "help": "" } }, "PowerLimit": { diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index ef01121d0..d15ae34dc 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -3132,6 +3132,10 @@ "ChapterForceEnableAutoFight": { "name": "Misc.ChapterForceEnableAutoFight.name", "help": "Misc.ChapterForceEnableAutoFight.help" + }, + "ChapterSkipPrecombat": { + "name": "Misc.ChapterSkipPrecombat.name", + "help": "Misc.ChapterSkipPrecombat.help" } }, "PowerLimit": { diff --git a/module/luahook/api.py b/module/luahook/api.py index 4d4ae2bdd..22d69208e 100644 --- a/module/luahook/api.py +++ b/module/luahook/api.py @@ -337,3 +337,9 @@ class CrackApi: def disable_chapter_force_enable_auto_fight(self): self.post("disable_chapter_force_enable_auto_fight") + + def enable_chapter_skip_precombat(self): + self.post("enable_chapter_skip_precombat") + + def disable_chapter_skip_precombat(self): + self.post("disable_chapter_skip_precombat") diff --git a/module/luahook/crack.py b/module/luahook/crack.py index e08e68046..bfd4bab8d 100644 --- a/module/luahook/crack.py +++ b/module/luahook/crack.py @@ -40,6 +40,7 @@ ALL_ENABLE_OPS = [ CrackOp.EnableOpsiNoMapFog, CrackOp.EnableSkipShipGainShow, CrackOp.EnableChapterForceEnableAutoFight, + CrackOp.EnableChapterSkipPrecombat, ] REMOTE_PORT = 23897 @@ -264,6 +265,11 @@ def do_crack_op(config: AzurLaneConfig, device: Device, ops: Union[Type[CrackOp. api.enable_chapter_force_enable_auto_fight() elif op == CrackOp.DisableChapterForceEnableAutoFight: api.disable_chapter_force_enable_auto_fight() + elif op == CrackOp.EnableChapterSkipPrecombat: + if full_config.Hook_Misc_ChapterForceEnableAutoFight: + api.enable_chapter_skip_precombat() + elif op == CrackOp.DisableChapterSkipPrecombat: + api.disable_chapter_skip_precombat() else: logger.error(f"Unsupported op: {op}") @@ -317,6 +323,7 @@ CHAPTER_CRACK_OPS = [ CrackOp.EnableNoDamage, CrackOp.EnableSkipShipGainShow, CrackOp.EnableChapterForceEnableAutoFight, + CrackOp.EnableChapterSkipPrecombat, ] diff --git a/module/luahook/op.py b/module/luahook/op.py index 6c75a4194..d644fcd3f 100644 --- a/module/luahook/op.py +++ b/module/luahook/op.py @@ -148,3 +148,9 @@ class CrackOp: class DisableChapterForceEnableAutoFight(Op): ... + + class EnableChapterSkipPrecombat(Op): + ... + + class DisableChapterSkipPrecombat(Op): + ...