diff --git a/blcrack/cracker/cracker.cpp b/blcrack/cracker/cracker.cpp index ea1f38e5b..258beb613 100644 --- a/blcrack/cracker/cracker.cpp +++ b/blcrack/cracker/cracker.cpp @@ -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()["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() != 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(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 { diff --git a/blcrack/cracker/cracker.hpp b/blcrack/cracker/cracker.hpp index 2a8bb4510..fc2998419 100644 --- a/blcrack/cracker/cracker.hpp +++ b/blcrack/cracker/cracker.hpp @@ -91,6 +91,7 @@ public: bool OPSI_FORCE_AUTO = false; bool OPSI_NO_MAP_FOG = false; bool SKIP_SHIP_GAIN_SHOW = false; + bool CHAPTER_FORCE_ENABLE_AUTO_FIGHT = false; } flag; ShipProperties globle_ship_properties; int global_speedup_rate = 1; @@ -129,6 +130,9 @@ public: void enable_hooked_lua_function_trace(); void disable_hooked_lua_function_trace(); + void enable_chapter_force_enable_auto_fight(); + void disable_chapter_force_enable_auto_fight(); + void enable_skip_ship_gain_show(); void disable_skip_ship_gain_show(); @@ -236,6 +240,7 @@ private: std::atomic OPSI_FORCE_AUTO = false; std::atomic OPSI_NO_MAP_FOG = false; std::atomic SKIP_SHIP_GAIN_SHOW = false; + std::atomic CHAPTER_FORCE_ENABLE_AUTO_FIGHT = false; } m_flag; struct { @@ -276,6 +281,8 @@ private: Lua::Function WorldMap_UpdateVisionFlag; Lua::Function NewBattleResultDisplayAwardPage_ShowShips; Lua::Function BaseUI_emit; + Lua::Function Chapter_CanActivateAutoFight; + Lua::Function Chapter_IsAutoFight; } m_original; struct { Lua::Function Clone; @@ -294,6 +301,9 @@ private: } AttributeType; std::string BattleResultMediator_GET_NEW_SHIP; std::string NewBattleResultMediator_GET_NEW_SHIP; + Lua::Function getProxy; + Lua::Table ChapterProxy; + Lua::Function ChapterProxy_GetChapterAutoFlag; } m_lua_res; std::atomic m_exercise_more_power_rate = 0.03; FakePlayerInfo m_fake_player_info; diff --git a/blcrack/cracker/server.cpp b/blcrack/cracker/server.cpp index 5212c4b26..ec5c63da0 100644 --- a/blcrack/cracker/server.cpp +++ b/blcrack/cracker/server.cpp @@ -916,6 +916,28 @@ CrackerServer::CrackerServer() { CRACK_OK(); }); + Post("/enable_chapter_force_enable_auto_fight", [](const httplib::Request& req, httplib::Response& res) { + try { + Cracker::Instance().enable_chapter_force_enable_auto_fight(); + } catch (std::exception& e) { + SPDLOG_ERROR("Enable chapter force enable auto fight failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + + Post("/disable_chapter_force_enable_auto_fight", [](const httplib::Request& req, httplib::Response& res) { + try { + Cracker::Instance().disable_chapter_force_enable_auto_fight(); + } catch (std::exception& e) { + SPDLOG_ERROR("Disable chapter force enable auto fight 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 899b6b103..6c833f16d 100644 --- a/blcrack/cracker/ui/ui.cpp +++ b/blcrack/cracker/ui/ui.cpp @@ -102,6 +102,7 @@ void CrackerUI::draw_menu() { ImGui::Checkbox("移除战列子弹时间", &CONFIG_FLAG(NO_BB_ANIMATION)); 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(EXERCISE_GOD_MOD)); ImGui::Checkbox("演习我方伤害增加 X %", &CONFIG_FLAG(EXERCISE_MORE_POWER)); diff --git a/blcrack/http/cracker.http b/blcrack/http/cracker.http index c35354137..eb0aed878 100644 --- a/blcrack/http/cracker.http +++ b/blcrack/http/cracker.http @@ -185,6 +185,12 @@ POST http://{{Host}}:{{Port}}/enable_skip_ship_gain_show ### POST http://{{Host}}:{{Port}}/disable_skip_ship_gain_show +### +POST http://{{Host}}:{{Port}}/enable_chapter_force_enable_auto_fight + +### +POST http://{{Host}}:{{Port}}/disable_chapter_force_enable_auto_fight + ### POST http://{{Host}}:{{Port}}/is_alive diff --git a/config/template.json b/config/template.json index c2d6969f0..3996be16e 100644 --- a/config/template.json +++ b/config/template.json @@ -222,7 +222,8 @@ "NoDamage": false, "OpsiForceAuto": false, "OpsiNoMapFog": false, - "SkipShipGainShow": false + "SkipShipGainShow": false, + "ChapterForceEnableAutoFight": false }, "ShipProperty": { "Method": "disable", diff --git a/module/config/argument/args.json b/module/config/argument/args.json index c2af930ba..27c31efe1 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -885,6 +885,10 @@ "SkipShipGainShow": { "type": "checkbox", "value": false + }, + "ChapterForceEnableAutoFight": { + "type": "checkbox", + "value": false } }, "ShipProperty": { diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index 41f5b8383..caa7ca05c 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -887,6 +887,7 @@ Misc: OpsiForceAuto: false OpsiNoMapFog: false SkipShipGainShow: false + ChapterForceEnableAutoFight: false # ==================== Cheat ==================== PowerLimit: diff --git a/module/config/config_generated.py b/module/config/config_generated.py index 87ec05c74..464daaa74 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -542,6 +542,7 @@ class GeneratedConfig: Misc_OpsiForceAuto = False Misc_OpsiNoMapFog = False Misc_SkipShipGainShow = False + Misc_ChapterForceEnableAutoFight = False # Group `PowerLimit` PowerLimit_Enable = True diff --git a/module/config/full_config_generated.py b/module/config/full_config_generated.py index f09877deb..c53ac81ce 100644 --- a/module/config/full_config_generated.py +++ b/module/config/full_config_generated.py @@ -156,6 +156,7 @@ class FullGeneratedConfig: Hook_Misc_OpsiForceAuto = None Hook_Misc_OpsiNoMapFog = None Hook_Misc_SkipShipGainShow = None + Hook_Misc_ChapterForceEnableAutoFight = 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 7f1b43d85..593800e3b 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -3128,6 +3128,10 @@ "SkipShipGainShow": { "name": "Misc.SkipShipGainShow.name", "help": "Misc.SkipShipGainShow.help" + }, + "ChapterForceEnableAutoFight": { + "name": "Misc.ChapterForceEnableAutoFight.name", + "help": "Misc.ChapterForceEnableAutoFight.help" } }, "PowerLimit": { diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index 1c31b34d2..e05b99cc1 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -3128,6 +3128,10 @@ "SkipShipGainShow": { "name": "Misc.SkipShipGainShow.name", "help": "Misc.SkipShipGainShow.help" + }, + "ChapterForceEnableAutoFight": { + "name": "Misc.ChapterForceEnableAutoFight.name", + "help": "Misc.ChapterForceEnableAutoFight.help" } }, "PowerLimit": { diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 99d07a09a..c73e0429a 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -3128,6 +3128,10 @@ "SkipShipGainShow": { "name": "跳过舰船获取展示", "help": "" + }, + "ChapterForceEnableAutoFight": { + "name": "章节图强制开启自动战斗", + "help": "" } }, "PowerLimit": { diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index a9bfd8105..ef01121d0 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -3128,6 +3128,10 @@ "SkipShipGainShow": { "name": "Misc.SkipShipGainShow.name", "help": "Misc.SkipShipGainShow.help" + }, + "ChapterForceEnableAutoFight": { + "name": "Misc.ChapterForceEnableAutoFight.name", + "help": "Misc.ChapterForceEnableAutoFight.help" } }, "PowerLimit": { diff --git a/module/luahook/api.py b/module/luahook/api.py index 763f17a35..4d4ae2bdd 100644 --- a/module/luahook/api.py +++ b/module/luahook/api.py @@ -331,3 +331,9 @@ class CrackApi: def disable_skip_ship_gain_show(self): self.post("disable_skip_ship_gain_show") + + def enable_chapter_force_enable_auto_fight(self): + self.post("enable_chapter_force_enable_auto_fight") + + def disable_chapter_force_enable_auto_fight(self): + self.post("disable_chapter_force_enable_auto_fight") diff --git a/module/luahook/crack.py b/module/luahook/crack.py index b145b7afe..e08e68046 100644 --- a/module/luahook/crack.py +++ b/module/luahook/crack.py @@ -39,6 +39,7 @@ ALL_ENABLE_OPS = [ CrackOp.EnableOpsiForceAuto, CrackOp.EnableOpsiNoMapFog, CrackOp.EnableSkipShipGainShow, + CrackOp.EnableChapterForceEnableAutoFight, ] REMOTE_PORT = 23897 @@ -258,6 +259,11 @@ def do_crack_op(config: AzurLaneConfig, device: Device, ops: Union[Type[CrackOp. api.enable_skip_ship_gain_show() elif op == CrackOp.DisableSkipShipGainShow: api.disable_skip_ship_gain_show() + elif op == CrackOp.EnableChapterForceEnableAutoFight: + if full_config.Hook_Misc_ChapterForceEnableAutoFight: + api.enable_chapter_force_enable_auto_fight() + elif op == CrackOp.DisableChapterForceEnableAutoFight: + api.disable_chapter_force_enable_auto_fight() else: logger.error(f"Unsupported op: {op}") @@ -310,6 +316,7 @@ CHAPTER_CRACK_OPS = [ CrackOp.EnableSkipBattleCelebrate, CrackOp.EnableNoDamage, CrackOp.EnableSkipShipGainShow, + CrackOp.EnableChapterForceEnableAutoFight, ] diff --git a/module/luahook/op.py b/module/luahook/op.py index 3e48d8ab3..6c75a4194 100644 --- a/module/luahook/op.py +++ b/module/luahook/op.py @@ -142,3 +142,9 @@ class CrackOp: class DisableSkipShipGainShow(Op): ... + + class EnableChapterForceEnableAutoFight(Op): + ... + + class DisableChapterForceEnableAutoFight(Op): + ...