diff --git a/blcrack/cracker/cracker.cpp b/blcrack/cracker/cracker.cpp index de903fa0d..c4105184d 100644 --- a/blcrack/cracker/cracker.cpp +++ b/blcrack/cracker/cracker.cpp @@ -240,6 +240,24 @@ void Cracker::disable_all() { disable_skip_battle_celebrate(); disable_better_global_speedup(); disable_no_damage(); + disable_opsi_force_auto(); + disable_opsi_no_map_fog(); +} + +void Cracker::enable_opsi_force_auto() { + ENABLE(OPSI_FORCE_AUTO); +} + +void Cracker::disable_opsi_force_auto() { + DISABLE(OPSI_FORCE_AUTO); +} + +void Cracker::enable_opsi_no_map_fog() { + ENABLE(OPSI_NO_MAP_FOG); +} + +void Cracker::disable_opsi_no_map_fog() { + DISABLE(OPSI_NO_MAP_FOG); } void Cracker::enable_all_skin() { @@ -514,9 +532,31 @@ void Cracker::load_lua_resources() { m_original.ShipSkinProxy_hasNonLimitSkin = m_state["ShipSkinProxy"]["hasNonLimitSkin"]; m_original.pg_ConnectionMgr_Send = m_state["pg"]["ConnectionMgr"]["Send"]; m_original.Ship_getSkinId = m_state["Ship"]["getSkinId"]; + m_original.WorldMap_CanAutoFight = m_state["WorldMap"]["CanAutoFight"]; + m_original.WorldMap_UpdateVisionFlag = m_state["WorldMap"]["UpdateVisionFlag"]; } void Cracker::hook_all_lua_functions() { + // opsi_force_auto + m_state["WorldMap"]["CanAutoFight"] = [this](sol::this_state L, Lua::VariadicArgs args) -> bool { + if (!IS_ENABLED(OPSI_FORCE_AUTO)) { + return m_original.WorldMap_CanAutoFight(L, args); + } + return true; + }; + + // opsi_no_map_fog + m_state["WorldMap"]["UpdateVisionFlag"] = [this](sol::this_state L, Lua::VariadicArgs args) { + if (!IS_ENABLED(OPSI_NO_MAP_FOG)) { + m_original.WorldMap_CanAutoFight(L, args); + return; + } + auto new_args = std::vector(); + new_args.push_back(args[0]); + new_args.push_back(sol::make_object(L, true)); + m_original.WorldMap_UpdateVisionFlag(L, sol::as_args(new_args)); + }; + // all_skin class AlwaysOn { public: @@ -1079,6 +1119,8 @@ Cracker::Config Cracker::get_config() { SET_CONFIG_FLAG(SKIP_BATTLE_CELEBRATE), SET_CONFIG_FLAG(BETTER_GLOBAL_SPEEDUP), SET_CONFIG_FLAG(NO_DAMAGE), + SET_CONFIG_FLAG(OPSI_FORCE_AUTO), + SET_CONFIG_FLAG(OPSI_NO_MAP_FOG), }, .globle_ship_properties = m_globle_ship_properties, .global_speedup_rate = static_cast(m_global_speedup_rate), @@ -1092,6 +1134,18 @@ Cracker::Config Cracker::get_config() { #define IS_CONFIG_ENABLED(n) config.flag.n void Cracker::apply_config(Config& config) { + if(IS_CONFIG_ENABLED(OPSI_FORCE_AUTO)) { + enable_opsi_force_auto(); + } else { + disable_opsi_force_auto(); + } + + if(IS_CONFIG_ENABLED(OPSI_NO_MAP_FOG)) { + enable_opsi_no_map_fog(); + } else { + disable_opsi_no_map_fog(); + } + if(IS_CONFIG_ENABLED(ALL_SKIN)) { enable_all_skin(); } else { diff --git a/blcrack/cracker/cracker.hpp b/blcrack/cracker/cracker.hpp index f6727e691..ff0cc9834 100644 --- a/blcrack/cracker/cracker.hpp +++ b/blcrack/cracker/cracker.hpp @@ -87,6 +87,8 @@ public: bool BETTER_GLOBAL_SPEEDUP = false; bool NO_DAMAGE = false; bool ALL_SKIN = false; + bool OPSI_FORCE_AUTO = false; + bool OPSI_NO_MAP_FOG = false; } flag; ShipProperties globle_ship_properties; int global_speedup_rate = 1; @@ -122,6 +124,12 @@ public: void disable_all(); + void enable_opsi_force_auto(); + void disable_opsi_force_auto(); + + void enable_opsi_no_map_fog(); + void disable_opsi_no_map_fog(); + void enable_all_skin(); void disable_all_skin(); @@ -216,6 +224,8 @@ private: std::atomic BETTER_GLOBAL_SPEEDUP = false; std::atomic NO_DAMAGE = false; std::atomic ALL_SKIN = false; + std::atomic OPSI_FORCE_AUTO = false; + std::atomic OPSI_NO_MAP_FOG = false; } m_flag; struct { @@ -252,6 +262,8 @@ private: Lua::Function ShipSkinProxy_hasNonLimitSkin; Lua::Function pg_ConnectionMgr_Send; Lua::Function Ship_getSkinId; + Lua::Function WorldMap_CanAutoFight; + Lua::Function WorldMap_UpdateVisionFlag; } m_original; struct { Lua::Function Clone; diff --git a/blcrack/cracker/server.cpp b/blcrack/cracker/server.cpp index 4a18b5238..1265022db 100644 --- a/blcrack/cracker/server.cpp +++ b/blcrack/cracker/server.cpp @@ -828,6 +828,50 @@ CrackerServer::CrackerServer() { CRACK_OK(); }); + Post("/enable_opsi_force_auto", [](const httplib::Request& req, httplib::Response& res) { + try { + Cracker::Instance().enable_opsi_force_auto(); + } catch (std::exception& e) { + SPDLOG_ERROR("Enable opsi force auto failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + + Post("/disable_opsi_force_auto", [](const httplib::Request& req, httplib::Response& res) { + try { + Cracker::Instance().disable_opsi_force_auto(); + } catch (std::exception& e) { + SPDLOG_ERROR("Disable opsi force auto failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + + Post("/enable_opsi_no_map_fog", [](const httplib::Request& req, httplib::Response& res) { + try { + Cracker::Instance().enable_opsi_no_map_fog(); + } catch (std::exception& e) { + SPDLOG_ERROR("Enable opsi no map fog failed: {}", e.what()); + res.status = 500; + return; + } + CRACK_OK(); + }); + + Post("/disable_opsi_no_map_fog", [](const httplib::Request& req, httplib::Response& res) { + try { + Cracker::Instance().disable_opsi_no_map_fog(); + } catch (std::exception& e) { + SPDLOG_ERROR("Disable opsi no map fog 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 1f6c1217d..54ac742c4 100644 --- a/blcrack/cracker/ui/ui.cpp +++ b/blcrack/cracker/ui/ui.cpp @@ -98,6 +98,7 @@ void CrackerUI::draw_menu() { ImGui::TableNextColumn(); ImGui::Checkbox("章节图快速移动", &CONFIG_FLAG(FAST_STAGE_MOVE_CRACK)); ImGui::Checkbox("大世界快速移动", &CONFIG_FLAG(OPSI_FAST_MOVE)); + ImGui::Checkbox("大世界强制自律", &CONFIG_FLAG(OPSI_FORCE_AUTO)); ImGui::Checkbox("移除战列子弹时间", &CONFIG_FLAG(NO_BB_ANIMATION)); ImGui::Checkbox("移除低心情警告", &CONFIG_FLAG(NO_EMOTION_WARNING)); ImGui::Checkbox("跳过战斗胜利庆祝", &CONFIG_FLAG(SKIP_BATTLE_CELEBRATE)); @@ -107,6 +108,7 @@ void CrackerUI::draw_menu() { ImGui::TableNextColumn(); ImGui::Checkbox("移除困难图属性限制", &CONFIG_FLAG(REMOVE_HARD_MODE_SHIP_PROPERTIES_LIMIT)); ImGui::Checkbox("移除困难图舰种限制", &CONFIG_FLAG(REMOVE_HARD_MODE_SHIP_TYPE_LIMIT)); + ImGui::Checkbox("大世界移除迷雾", &CONFIG_FLAG(OPSI_NO_MAP_FOG)); ImGui::Checkbox("快速出怪", &CONFIG_FLAG(FAST_WAVE)); ImGui::Checkbox("怪自杀", &CONFIG_FLAG(MONSTER_KILL_SELF)); ImGui::Checkbox("无伤害无击杀", &CONFIG_FLAG(NO_DAMAGE));