#ifndef CRACKER_HPP #define CRACKER_HPP #include #include #include #include #include #include #include #include #include #include "timer.hpp" namespace Lua { using Table = sol::table; using Object = sol::object; using Function = sol::function; using VariadicArgs = sol::variadic_args; using StateView = sol::state_view; } class Cracker { public: using FunctionId = int; using ShipId = int; using StorageItemId = int; using StorageItemCount = int; // -1 means disabled struct ShipProperties { double armor = -1; double speed = -1; double antiaircraft = -1; double oxy_recovery_bench = -1; double torpedo = -1; double hit = -1; double sonarRange = -1; double attack_duration = -1; double raid_distance = -1; double oxy_recovery_surface = -1; double oxy_recovery = -1; double dodge = -1; double luck = -1; double reload = -1; double oxy_cost = -1; double durability = -1; double air = -1; double oxy_max = -1; double cannon = -1; double antisub = -1; }; struct FakePlayerInfo { std::string name; std::string id; std::string level; }; struct ShipInfo { int config_id; int emotion; int rarity; int level; int exp; int curr_star; }; struct Config { struct { bool GLOBAL_SHIP_PROPERTIES_CRACK; bool FAST_STAGE_MOVE_CRACK; bool REMOVE_HARD_MODE_SHIP_PROPERTIES_LIMIT; bool REMOVE_HARD_MODE_SHIP_TYPE_LIMIT; bool NO_BB_ANIMATION; bool NO_EMOTION_WARNING; bool OPSI_FAST_MOVE; bool GG_FACTOR; bool GLOBAL_SPEEDUP; bool EXERCISE_GOD_MOD; bool EXERCISE_MORE_POWER; } flag; ShipProperties globle_ship_properties; float global_speedup_rate; double gg_factor; double exercise_more_power_rate; }; public: Cracker(); static Cracker& Instance(); int get_coin(); int get_oil(); int get_gems(); int get_level(); int get_exp(); int get_merit(); int get_guild_coin(); int get_design_prt(); int get_core_data(); int get_medal(); int get_pt(); int get_specialized_core(); int get_curr_action_point(); std::map scan_dock(); std::map scan_storage(); std::optional get_ship_info(ShipId ship_id); std::optional get_storage_item_count(StorageItemId item_id); void disable_all(); void enable_exercise_more_power(); void update_exercise_more_power_rate(double rate); void disable_exercise_more_power(); void enable_exercise_god_mode(); void disable_exercise_god_mode(); void enable_global_speedup(); void update_global_speedup_rate(float rate); void disable_global_speedup(); void enable_gg_factor(); void disable_gg_factor(); void update_gg_factor(double factor); void enable_opsi_fast_move(); void disable_opsi_fast_move(); void enable_no_emotion_warning(); void disable_no_emotion_warning(); void enable_no_bb_animation(); void disable_no_bb_animation(); void enable_fake_player(); void disable_fake_player(); void update_fake_player_info(const FakePlayerInfo& fake_info); void enable_remove_hard_mode_ship_type_limit(); void disable_remove_hard_mode_ship_type_limit(); void enable_remove_hard_mode_ship_properties_limit(); void disable_remove_hard_mode_ship_properties_limit(); void enable_fast_stage_move(); void disable_fast_stage_move(); void update_global_ship_properties(const ShipProperties& properties); void enable_global_ship_properties_crack(); void disable_global_ship_properties_crack(); void print_table_field(std::vector& path); void print_value(std::vector& path); Json::Value get_config_json(); void apply_config(Config& config); private: void load_lua_resources(); void hook_all_lua_functions(); static void modify_ship_properties(Lua::Table& properties, const ShipProperties& new_properties); static void clear_hard_mode_ship_properties_limit(Lua::Table& t); struct { std::atomic GLOBAL_SHIP_PROPERTIES_CRACK = false; std::atomic SPECIFIC_SHIP_PROPERTIES_CRACK = false; std::atomic FAST_STAGE_MOVE_CRACK = false; std::atomic REMOVE_HARD_MODE_SHIP_PROPERTIES_LIMIT = false; std::atomic REMOVE_HARD_MODE_SHIP_TYPE_LIMIT = false; std::atomic FAKE_PLAYER_INFO = false; std::atomic NO_BB_ANIMATION = false; std::atomic NO_EMOTION_WARNING = false; std::atomic OPSI_FAST_MOVE = false; std::atomic GG_FACTOR = false; std::atomic GLOBAL_SPEEDUP = false; std::atomic EXERCISE_GOD_MOD = false; std::atomic EXERCISE_MORE_POWER = false; } m_flag; struct { Lua::Table player; Lua::Table world; Lua::Table dock; Lua::Table storage; } m_data_proxy; double m_gg_factor = 1.0; sol::state_view m_state; struct { Lua::Function Ship_getShipProperties; Lua::Function WorldFleetSelectLayer_CheckValid; Lua::Function BossSingleBattleFleetSelectSubPanel_CheckValid; Lua::Function Chapter_IsEliteFleetLegal; Lua::Function Chapter_getConfig; Lua::Function PlayerVitaeDetailPage_UpdateInfo; Lua::Function ys_Battle_BattleManualWeaponAutoBot_SetActive; Lua::Function Ship_cosumeEnergy; Lua::Function Ship_getEnergy; Lua::Function Ship_intimacyAdditions; Lua::Function GetBattleCheckResult; Lua::Function FinishStageCommand_GeneralPackage; Lua::Function ys_Battle_BattleGateGuild_GeneralPackage; Lua::Function ys_Battle_BattleDataFunction_GetBuffTemplate; Lua::Function WorldConst_GetTerrainMoveStepDuration; } m_original; struct { Lua::Function Ship_getIntimacyLevel; Lua::Table pg_intimacy_template; struct { std::string Durability; std::string Cannon; std::string Torpedo; std::string AntiAircraft; std::string AntiSub; std::string Air; std::string Reload; std::string Hit; std::string Dodge; } AttributeType; } m_lua_res; std::atomic m_exercise_more_power_rate = 0.03; FakePlayerInfo m_fake_player_info; ShipProperties m_globle_ship_properties; std::map m_specific_ship_properties; Timer m_global_speedup_timer; std::atomic m_global_speedup_rate = 1.0; }; #endif //CRACKER_HPP