diff --git a/blcrack/cracker/cracker.cpp b/blcrack/cracker/cracker.cpp index a2dd1c693..11f41dd39 100644 --- a/blcrack/cracker/cracker.cpp +++ b/blcrack/cracker/cracker.cpp @@ -252,6 +252,7 @@ void Cracker::disable_all() { disable_chapter_auto_next_battle(); disable_chapter_auto_ambush(); disable_chapter_auto_clear(); + disable_skip_story(); } void Cracker::enable_hooked_lua_function_trace() { @@ -262,6 +263,14 @@ void Cracker::disable_hooked_lua_function_trace() { DISABLE(HOOKED_LUA_FUNCTION_TRACE); } +void Cracker::enable_skip_story() { + ENABLE(SKIP_STORY); +} + +void Cracker::disable_skip_story() { + DISABLE(SKIP_STORY); +} + void Cracker::enable_chapter_auto_clear() { ENABLE(CHAPTER_AUTO_CLEAR); } @@ -635,11 +644,23 @@ void Cracker::load_lua_resources() { m_original.Chapter_writeBack = m_state["Chapter"]["writeBack"]; m_original.LevelStageView_tryAutoTrigger = m_state["LevelStageView"]["tryAutoTrigger"]; m_original.LevelStageView_TryAutoFight = m_state["LevelStageView"]["TryAutoFight"]; + m_original.Story_Ctor = m_state["Story"]["Ctor"]; } void Cracker::hook_all_lua_functions() { SPDLOG_INFO("Hook lua functions"); + // skip_story + m_state["Story"]["Ctor"] = [this](sol::this_state L, Lua::VariadicArgs args) { + CALLED(Story.Ctor); + m_original.Story_Ctor(L, args); + if (IS_ENABLED(SKIP_STORY)) { + Lua::Table self = args[0]; + self["skipAll"] = true; + self["isAuto"] = false; + } + }; + // chapter_auto_clear m_state["LevelStageView"]["TryAutoFight"] = [this](sol::this_state L, Lua::VariadicArgs args) { CALLED(LevelStageView.TryAutoFight); @@ -1374,6 +1395,7 @@ Cracker::Config Cracker::get_config() { SET_CONFIG_FLAG(CHAPTER_AUTO_NEXT_BATTLE), SET_CONFIG_FLAG(CHAPTER_AUTO_AMBUSH), SET_CONFIG_FLAG(CHAPTER_AUTO_CLEAR), + SET_CONFIG_FLAG(SKIP_STORY), }, .globle_ship_properties = m_globle_ship_properties, .global_speedup_rate = static_cast(m_global_speedup_rate), @@ -1393,6 +1415,12 @@ void Cracker::apply_config(Config& config) { disable_hooked_lua_function_trace(); } + if(IS_CONFIG_ENABLED(SKIP_STORY)) { + enable_skip_story(); + } else { + disable_skip_story(); + } + if(IS_CONFIG_ENABLED(CHAPTER_AUTO_CLEAR)) { enable_chapter_auto_clear(); } else { diff --git a/blcrack/cracker/cracker.hpp b/blcrack/cracker/cracker.hpp index 7baf56672..9d43d7bc8 100644 --- a/blcrack/cracker/cracker.hpp +++ b/blcrack/cracker/cracker.hpp @@ -96,6 +96,7 @@ public: bool CHAPTER_AUTO_NEXT_BATTLE = false; bool CHAPTER_AUTO_AMBUSH = false; bool CHAPTER_AUTO_CLEAR = false; + bool SKIP_STORY = false; } flag; ShipProperties globle_ship_properties; int global_speedup_rate = 1; @@ -134,6 +135,9 @@ public: void enable_hooked_lua_function_trace(); void disable_hooked_lua_function_trace(); + void enable_skip_story(); + void disable_skip_story(); + void enable_chapter_auto_clear(); void disable_chapter_auto_clear(); @@ -280,6 +284,7 @@ private: std::atomic CHAPTER_AUTO_NEXT_BATTLE = false; std::atomic CHAPTER_AUTO_AMBUSH = false; std::atomic CHAPTER_AUTO_CLEAR = false; + std::atomic SKIP_STORY = false; } m_flag; struct { @@ -326,6 +331,7 @@ private: Lua::Function Chapter_writeBack; Lua::Function LevelStageView_tryAutoTrigger; Lua::Function LevelStageView_TryAutoFight; + Lua::Function Story_Ctor; } m_original; struct { Lua::Function Clone; diff --git a/blcrack/cracker/server.cpp b/blcrack/cracker/server.cpp index ae93fd199..0c0f877ff 100644 --- a/blcrack/cracker/server.cpp +++ b/blcrack/cracker/server.cpp @@ -1026,6 +1026,28 @@ CrackerServer::CrackerServer() { CRACK_OK(); }); + Post("/enable_skip_story", [](const httplib::Request& req, httplib::Response& res) { + try { + Cracker::Instance().enable_skip_story(); + } catch (std::exception& e) { + SPDLOG_ERROR("Enable skip story failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + + Post("/disable_skip_story", [](const httplib::Request& req, httplib::Response& res) { + try { + Cracker::Instance().disable_skip_story(); + } catch (std::exception& e) { + SPDLOG_ERROR("Disable skip story 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 169f82961..f9853989b 100644 --- a/blcrack/cracker/ui/ui.cpp +++ b/blcrack/cracker/ui/ui.cpp @@ -106,6 +106,7 @@ void CrackerUI::draw_menu() { ImGui::Checkbox("章节图跳过战前准备", &CONFIG_FLAG(CHAPTER_SKIP_PRECOMBAT)); ImGui::Checkbox("演习锁血", &CONFIG_FLAG(EXERCISE_GOD_MOD)); ImGui::Checkbox("自动规避伏击", &CONFIG_FLAG(CHAPTER_AUTO_AMBUSH)); + ImGui::Checkbox("跳过剧情", &CONFIG_FLAG(SKIP_STORY)); ImGui::TableNextColumn(); ImGui::Checkbox("移除困难图属性限制", &CONFIG_FLAG(REMOVE_HARD_MODE_SHIP_PROPERTIES_LIMIT)); diff --git a/blcrack/http/cracker.http b/blcrack/http/cracker.http index d2c15015f..f3360158a 100644 --- a/blcrack/http/cracker.http +++ b/blcrack/http/cracker.http @@ -215,6 +215,12 @@ POST http://{{Host}}:{{Port}}/enable_chapter_auto_clear ### POST http://{{Host}}:{{Port}}/disable_chapter_auto_clear +### +POST http://{{Host}}:{{Port}}/enable_skip_story + +### +POST http://{{Host}}:{{Port}}/disable_skip_story + ### POST http://{{Host}}:{{Port}}/is_alive diff --git a/config/template.json b/config/template.json index c92982c67..3f3000b82 100644 --- a/config/template.json +++ b/config/template.json @@ -227,7 +227,8 @@ "ChapterSkipPrecombat": false, "ChapterAutoNextBattle": false, "ChapterAutoAmbush": false, - "ChapterAutoClear": false + "ChapterAutoClear": false, + "SkipStory": false }, "ShipProperty": { "Method": "disable", diff --git a/module/config/argument/args.json b/module/config/argument/args.json index 913a08b19..a1743f0dc 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -905,6 +905,10 @@ "ChapterAutoClear": { "type": "checkbox", "value": false + }, + "SkipStory": { + "type": "checkbox", + "value": false } }, "ShipProperty": { diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index 4176a5327..72a9431f4 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -893,6 +893,7 @@ Misc: ChapterAutoNextBattle: false ChapterAutoAmbush: false ChapterAutoClear: false + SkipStory: false # ==================== Cheat ==================== PowerLimit: diff --git a/module/config/config_generated.py b/module/config/config_generated.py index b735e96eb..a78d2752b 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -548,6 +548,7 @@ class GeneratedConfig: Misc_ChapterAutoNextBattle = False Misc_ChapterAutoAmbush = False Misc_ChapterAutoClear = False + Misc_SkipStory = False # Group `PowerLimit` PowerLimit_Enable = True diff --git a/module/config/full_config_generated.py b/module/config/full_config_generated.py index 14dc54b32..227cc23e6 100644 --- a/module/config/full_config_generated.py +++ b/module/config/full_config_generated.py @@ -161,6 +161,7 @@ class FullGeneratedConfig: Hook_Misc_ChapterAutoNextBattle = None Hook_Misc_ChapterAutoAmbush = None Hook_Misc_ChapterAutoClear = None + Hook_Misc_SkipStory = 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 091c6b9ad..f017c18a1 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -3152,6 +3152,10 @@ "ChapterAutoClear": { "name": "Misc.ChapterAutoClear.name", "help": "Misc.ChapterAutoClear.help" + }, + "SkipStory": { + "name": "Misc.SkipStory.name", + "help": "Misc.SkipStory.help" } }, "PowerLimit": { diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index ea07aa9a5..a7fdfd973 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -3152,6 +3152,10 @@ "ChapterAutoClear": { "name": "Misc.ChapterAutoClear.name", "help": "Misc.ChapterAutoClear.help" + }, + "SkipStory": { + "name": "Misc.SkipStory.name", + "help": "Misc.SkipStory.help" } }, "PowerLimit": { diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index b7e7e11ca..614f3b3ea 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -3152,6 +3152,10 @@ "ChapterAutoClear": { "name": "章节图自动开荒", "help": "" + }, + "SkipStory": { + "name": "跳过剧情", + "help": "" } }, "PowerLimit": { diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index adf722c0f..f9ad5c828 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -3152,6 +3152,10 @@ "ChapterAutoClear": { "name": "Misc.ChapterAutoClear.name", "help": "Misc.ChapterAutoClear.help" + }, + "SkipStory": { + "name": "Misc.SkipStory.name", + "help": "Misc.SkipStory.help" } }, "PowerLimit": { diff --git a/module/luahook/api.py b/module/luahook/api.py index 93991d489..206297ded 100644 --- a/module/luahook/api.py +++ b/module/luahook/api.py @@ -361,3 +361,9 @@ class CrackApi: def disable_chapter_auto_clear(self): self.post("disable_chapter_auto_clear") + + def enable_skip_story(self): + self.post("enable_skip_story") + + def disable_skip_story(self): + self.post("disable_skip_story") diff --git a/module/luahook/crack.py b/module/luahook/crack.py index 366d61f38..77a614eab 100644 --- a/module/luahook/crack.py +++ b/module/luahook/crack.py @@ -44,6 +44,7 @@ ALL_ENABLE_OPS = [ CrackOp.EnableChapterAutoNextBattle, CrackOp.EnableChapterAutoAmbush, CrackOp.EnableChapterAutoClear, + CrackOp.EnableSkipStory, ] REMOTE_PORT = 23897 @@ -288,6 +289,11 @@ def do_crack_op(config: AzurLaneConfig, device: Device, ops: Union[Type[CrackOp. api.enable_chapter_auto_clear() elif op == CrackOp.DisableChapterAutoClear: api.disable_chapter_auto_clear() + elif op == CrackOp.EnableSkipStory: + if full_config.Hook_Misc_SkipStory: + api.enable_skip_story() + elif op == CrackOp.DisableSkipStory: + api.disable_skip_story() else: logger.error(f"Unsupported op: {op}") @@ -345,6 +351,7 @@ CHAPTER_CRACK_OPS = [ CrackOp.EnableChapterAutoNextBattle, CrackOp.EnableChapterAutoAmbush, CrackOp.EnableChapterAutoClear, + CrackOp.EnableSkipStory, ] @@ -373,6 +380,7 @@ OPSI_CRACK_OPS = [ CrackOp.EnableOpsiForceAuto, CrackOp.EnableOpsiNoMapFog, CrackOp.EnableSkipShipGainShow, + CrackOp.EnableSkipStory, ] diff --git a/module/luahook/op.py b/module/luahook/op.py index 2087aadb3..f22fe1c00 100644 --- a/module/luahook/op.py +++ b/module/luahook/op.py @@ -172,3 +172,9 @@ class CrackOp: class DisableChapterAutoClear(Op): ... + + class EnableSkipStory(Op): + ... + + class DisableSkipStory(Op): + ...