mirror of
https://github.com/0O0o0oOoO00/Alas.git
synced 2026-05-14 08:59: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 {
|
||||
|
||||
@@ -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<bool> OPSI_FORCE_AUTO = false;
|
||||
std::atomic<bool> OPSI_NO_MAP_FOG = false;
|
||||
std::atomic<bool> SKIP_SHIP_GAIN_SHOW = false;
|
||||
std::atomic<bool> 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<double> m_exercise_more_power_rate = 0.03;
|
||||
FakePlayerInfo m_fake_player_info;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -222,7 +222,8 @@
|
||||
"NoDamage": false,
|
||||
"OpsiForceAuto": false,
|
||||
"OpsiNoMapFog": false,
|
||||
"SkipShipGainShow": false
|
||||
"SkipShipGainShow": false,
|
||||
"ChapterForceEnableAutoFight": false
|
||||
},
|
||||
"ShipProperty": {
|
||||
"Method": "disable",
|
||||
|
||||
@@ -885,6 +885,10 @@
|
||||
"SkipShipGainShow": {
|
||||
"type": "checkbox",
|
||||
"value": false
|
||||
},
|
||||
"ChapterForceEnableAutoFight": {
|
||||
"type": "checkbox",
|
||||
"value": false
|
||||
}
|
||||
},
|
||||
"ShipProperty": {
|
||||
|
||||
@@ -887,6 +887,7 @@ Misc:
|
||||
OpsiForceAuto: false
|
||||
OpsiNoMapFog: false
|
||||
SkipShipGainShow: false
|
||||
ChapterForceEnableAutoFight: false
|
||||
|
||||
# ==================== Cheat ====================
|
||||
PowerLimit:
|
||||
|
||||
@@ -542,6 +542,7 @@ class GeneratedConfig:
|
||||
Misc_OpsiForceAuto = False
|
||||
Misc_OpsiNoMapFog = False
|
||||
Misc_SkipShipGainShow = False
|
||||
Misc_ChapterForceEnableAutoFight = False
|
||||
|
||||
# Group `PowerLimit`
|
||||
PowerLimit_Enable = True
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3128,6 +3128,10 @@
|
||||
"SkipShipGainShow": {
|
||||
"name": "Misc.SkipShipGainShow.name",
|
||||
"help": "Misc.SkipShipGainShow.help"
|
||||
},
|
||||
"ChapterForceEnableAutoFight": {
|
||||
"name": "Misc.ChapterForceEnableAutoFight.name",
|
||||
"help": "Misc.ChapterForceEnableAutoFight.help"
|
||||
}
|
||||
},
|
||||
"PowerLimit": {
|
||||
|
||||
@@ -3128,6 +3128,10 @@
|
||||
"SkipShipGainShow": {
|
||||
"name": "Misc.SkipShipGainShow.name",
|
||||
"help": "Misc.SkipShipGainShow.help"
|
||||
},
|
||||
"ChapterForceEnableAutoFight": {
|
||||
"name": "Misc.ChapterForceEnableAutoFight.name",
|
||||
"help": "Misc.ChapterForceEnableAutoFight.help"
|
||||
}
|
||||
},
|
||||
"PowerLimit": {
|
||||
|
||||
@@ -3128,6 +3128,10 @@
|
||||
"SkipShipGainShow": {
|
||||
"name": "跳过舰船获取展示",
|
||||
"help": ""
|
||||
},
|
||||
"ChapterForceEnableAutoFight": {
|
||||
"name": "章节图强制开启自动战斗",
|
||||
"help": ""
|
||||
}
|
||||
},
|
||||
"PowerLimit": {
|
||||
|
||||
@@ -3128,6 +3128,10 @@
|
||||
"SkipShipGainShow": {
|
||||
"name": "Misc.SkipShipGainShow.name",
|
||||
"help": "Misc.SkipShipGainShow.help"
|
||||
},
|
||||
"ChapterForceEnableAutoFight": {
|
||||
"name": "Misc.ChapterForceEnableAutoFight.name",
|
||||
"help": "Misc.ChapterForceEnableAutoFight.help"
|
||||
}
|
||||
},
|
||||
"PowerLimit": {
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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,
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -142,3 +142,9 @@ class CrackOp:
|
||||
|
||||
class DisableSkipShipGainShow(Op):
|
||||
...
|
||||
|
||||
class EnableChapterForceEnableAutoFight(Op):
|
||||
...
|
||||
|
||||
class DisableChapterForceEnableAutoFight(Op):
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user