2025-11-01 00:23:46 +08:00
|
|
|
#ifndef CRACKER_HPP
|
|
|
|
|
#define CRACKER_HPP
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <optional>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <sol/state_view.hpp>
|
|
|
|
|
#include <sol/variadic_args.hpp>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <atomic>
|
|
|
|
|
#include <json/json.h>
|
|
|
|
|
|
|
|
|
|
#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 {
|
|
|
|
|
int armor = -1;
|
|
|
|
|
int speed = -1;
|
|
|
|
|
int antiaircraft = -1;
|
|
|
|
|
int oxy_recovery_bench = -1;
|
|
|
|
|
int torpedo = -1;
|
|
|
|
|
int hit = -1;
|
|
|
|
|
int sonarRange = -1;
|
|
|
|
|
int attack_duration = -1;
|
|
|
|
|
int raid_distance = -1;
|
|
|
|
|
int oxy_recovery_surface = -1;
|
|
|
|
|
int oxy_recovery = -1;
|
|
|
|
|
int dodge = -1;
|
|
|
|
|
int luck = -1;
|
|
|
|
|
int reload = -1;
|
|
|
|
|
int oxy_cost = -1;
|
|
|
|
|
int durability = -1;
|
|
|
|
|
int air = -1;
|
|
|
|
|
int oxy_max = -1;
|
|
|
|
|
int cannon = -1;
|
|
|
|
|
int 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 {
|
2025-11-16 15:04:04 +08:00
|
|
|
bool HOOKED_LUA_FUNCTION_TRACE = false;
|
2025-11-01 00:23:46 +08:00
|
|
|
bool GLOBAL_SHIP_PROPERTIES_CRACK = false;
|
|
|
|
|
bool FAST_STAGE_MOVE_CRACK = false;
|
|
|
|
|
bool REMOVE_HARD_MODE_SHIP_PROPERTIES_LIMIT = false;
|
|
|
|
|
bool REMOVE_HARD_MODE_SHIP_TYPE_LIMIT = false;
|
|
|
|
|
bool FAKE_PLAYER_INFO = false;
|
|
|
|
|
bool NO_BB_ANIMATION = false;
|
|
|
|
|
bool NO_EMOTION_WARNING = false;
|
|
|
|
|
bool OPSI_FAST_MOVE = false;
|
|
|
|
|
bool GG_FACTOR = false;
|
|
|
|
|
bool GLOBAL_SPEEDUP = false;
|
|
|
|
|
bool EXERCISE_GOD_MOD = false;
|
|
|
|
|
bool EXERCISE_MORE_POWER = false;
|
|
|
|
|
bool FAST_WAVE = false;
|
|
|
|
|
bool MONSTER_KILL_SELF = false;
|
|
|
|
|
bool SKIP_BATTLE_CELEBRATE = false;
|
|
|
|
|
bool BETTER_GLOBAL_SPEEDUP = false;
|
|
|
|
|
bool NO_DAMAGE = false;
|
|
|
|
|
bool ALL_SKIN = false;
|
2025-11-01 23:39:40 +08:00
|
|
|
bool OPSI_FORCE_AUTO = false;
|
|
|
|
|
bool OPSI_NO_MAP_FOG = false;
|
2025-11-16 16:20:45 +08:00
|
|
|
bool SKIP_SHIP_GAIN_SHOW = false;
|
2025-11-16 18:04:18 +08:00
|
|
|
bool CHAPTER_FORCE_ENABLE_AUTO_FIGHT = false;
|
2025-11-16 18:27:53 +08:00
|
|
|
bool CHAPTER_SKIP_PRECOMBAT = false;
|
2025-11-16 19:38:48 +08:00
|
|
|
bool CHAPTER_AUTO_NEXT_BATTLE = false;
|
2025-11-16 20:30:15 +08:00
|
|
|
bool CHAPTER_AUTO_AMBUSH = false;
|
2025-11-18 18:12:20 +08:00
|
|
|
bool CHAPTER_AUTO_CLEAR = false;
|
2025-11-01 00:23:46 +08:00
|
|
|
} flag;
|
|
|
|
|
ShipProperties globle_ship_properties;
|
|
|
|
|
int global_speedup_rate = 1;
|
|
|
|
|
int gg_factor = 1;
|
|
|
|
|
int exercise_more_power_rate = 1;
|
|
|
|
|
int better_global_speedup_rate = 1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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<ShipId, ShipInfo> scan_dock();
|
|
|
|
|
std::map<StorageItemId, StorageItemCount> scan_storage();
|
|
|
|
|
|
|
|
|
|
std::optional<ShipInfo> get_ship_info(ShipId ship_id);
|
|
|
|
|
std::optional<StorageItemCount> get_storage_item_count(StorageItemId item_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void disable_all();
|
|
|
|
|
|
2025-11-16 15:04:04 +08:00
|
|
|
void enable_hooked_lua_function_trace();
|
|
|
|
|
void disable_hooked_lua_function_trace();
|
|
|
|
|
|
2025-11-18 18:12:20 +08:00
|
|
|
void enable_chapter_auto_clear();
|
|
|
|
|
void disable_chapter_auto_clear();
|
|
|
|
|
|
2025-11-16 18:27:53 +08:00
|
|
|
void enable_chapter_skip_precombat();
|
|
|
|
|
void disable_chapter_skip_precombat();
|
|
|
|
|
|
2025-11-16 19:38:48 +08:00
|
|
|
void enable_chapter_auto_next_battle();
|
|
|
|
|
void disable_chapter_auto_next_battle();
|
|
|
|
|
|
2025-11-16 18:04:18 +08:00
|
|
|
void enable_chapter_force_enable_auto_fight();
|
|
|
|
|
void disable_chapter_force_enable_auto_fight();
|
|
|
|
|
|
2025-11-16 20:30:15 +08:00
|
|
|
void enable_chapter_auto_ambush();
|
|
|
|
|
void disable_chapter_auto_ambush();
|
|
|
|
|
|
2025-11-16 16:20:45 +08:00
|
|
|
void enable_skip_ship_gain_show();
|
|
|
|
|
void disable_skip_ship_gain_show();
|
|
|
|
|
|
2025-11-01 23:39:40 +08:00
|
|
|
void enable_opsi_force_auto();
|
|
|
|
|
void disable_opsi_force_auto();
|
|
|
|
|
|
|
|
|
|
void enable_opsi_no_map_fog();
|
|
|
|
|
void disable_opsi_no_map_fog();
|
|
|
|
|
|
2025-11-01 00:23:46 +08:00
|
|
|
void enable_all_skin();
|
|
|
|
|
void disable_all_skin();
|
|
|
|
|
|
|
|
|
|
void enable_no_damage();
|
|
|
|
|
void disable_no_damage();
|
|
|
|
|
|
|
|
|
|
void enable_better_global_speedup();
|
|
|
|
|
void update_better_global_speedup_rate(double rate);
|
|
|
|
|
void disable_better_global_speedup();
|
|
|
|
|
|
|
|
|
|
void enable_skip_battle_celebrate();
|
|
|
|
|
void disable_skip_battle_celebrate();
|
|
|
|
|
|
|
|
|
|
void enable_monster_kill_self();
|
|
|
|
|
void disable_monster_kill_self();
|
|
|
|
|
|
|
|
|
|
void enable_fast_wave();
|
|
|
|
|
void disable_fast_wave();
|
|
|
|
|
|
|
|
|
|
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<std::string>& path);
|
|
|
|
|
void print_value(std::vector<std::string>& path);
|
|
|
|
|
|
|
|
|
|
Config get_config();
|
|
|
|
|
|
|
|
|
|
void apply_config(Config& config);
|
|
|
|
|
|
|
|
|
|
private:
|
2025-11-18 18:12:20 +08:00
|
|
|
void load_real_lua_func();
|
|
|
|
|
|
|
|
|
|
void mover_stop(sol::this_state& L);
|
|
|
|
|
void mover_go(sol::this_state& L, Lua::Table& view, Lua::Table& path);
|
|
|
|
|
void mover_step(sol::this_state& L);
|
|
|
|
|
|
|
|
|
|
bool my_ChapterConst_IsBossCell(sol::this_state& L, Lua::Table& cell);
|
|
|
|
|
|
|
|
|
|
int CntNonBoss(sol::this_state& L, Lua::Table& chap);
|
|
|
|
|
|
|
|
|
|
struct Cell {
|
|
|
|
|
int row;
|
|
|
|
|
int column;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::optional<Cell> NearestEnemy(sol::this_state& L, Lua::Table& chap, bool farming);
|
|
|
|
|
|
|
|
|
|
void my_LevelStageView_TryAutoFight(sol::this_state& L, Lua::VariadicArgs& args);
|
|
|
|
|
|
2025-11-01 00:23:46 +08:00
|
|
|
void load_lua_resources();
|
|
|
|
|
void hook_all_lua_functions();
|
|
|
|
|
|
|
|
|
|
void better_global_speedup_set_rate(double rate);
|
|
|
|
|
|
|
|
|
|
static void modify_ship_properties(Lua::Table& properties, const ShipProperties& new_properties);
|
|
|
|
|
static void clear_hard_mode_ship_properties_limit(Lua::Table& t);
|
|
|
|
|
|
|
|
|
|
struct {
|
2025-11-16 15:04:04 +08:00
|
|
|
std::atomic<bool> HOOKED_LUA_FUNCTION_TRACE = false;
|
2025-11-01 00:23:46 +08:00
|
|
|
std::atomic<bool> GLOBAL_SHIP_PROPERTIES_CRACK = false;
|
|
|
|
|
std::atomic<bool> FAST_STAGE_MOVE_CRACK = false;
|
|
|
|
|
std::atomic<bool> REMOVE_HARD_MODE_SHIP_PROPERTIES_LIMIT = false;
|
|
|
|
|
std::atomic<bool> REMOVE_HARD_MODE_SHIP_TYPE_LIMIT = false;
|
|
|
|
|
std::atomic<bool> FAKE_PLAYER_INFO = false;
|
|
|
|
|
std::atomic<bool> NO_BB_ANIMATION = false;
|
|
|
|
|
std::atomic<bool> NO_EMOTION_WARNING = false;
|
|
|
|
|
std::atomic<bool> OPSI_FAST_MOVE = false;
|
|
|
|
|
std::atomic<bool> GG_FACTOR = false;
|
|
|
|
|
std::atomic<bool> GLOBAL_SPEEDUP = false;
|
|
|
|
|
std::atomic<bool> EXERCISE_GOD_MOD = false;
|
|
|
|
|
std::atomic<bool> EXERCISE_MORE_POWER = false;
|
|
|
|
|
std::atomic<bool> FAST_WAVE = false;
|
|
|
|
|
std::atomic<bool> MONSTER_KILL_SELF = false;
|
|
|
|
|
std::atomic<bool> SKIP_BATTLE_CELEBRATE = false;
|
|
|
|
|
std::atomic<bool> BETTER_GLOBAL_SPEEDUP = false;
|
|
|
|
|
std::atomic<bool> NO_DAMAGE = false;
|
|
|
|
|
std::atomic<bool> ALL_SKIN = false;
|
2025-11-01 23:39:40 +08:00
|
|
|
std::atomic<bool> OPSI_FORCE_AUTO = false;
|
|
|
|
|
std::atomic<bool> OPSI_NO_MAP_FOG = false;
|
2025-11-16 16:20:45 +08:00
|
|
|
std::atomic<bool> SKIP_SHIP_GAIN_SHOW = false;
|
2025-11-16 18:04:18 +08:00
|
|
|
std::atomic<bool> CHAPTER_FORCE_ENABLE_AUTO_FIGHT = false;
|
2025-11-16 18:27:53 +08:00
|
|
|
std::atomic<bool> CHAPTER_SKIP_PRECOMBAT = false;
|
2025-11-16 19:38:48 +08:00
|
|
|
std::atomic<bool> CHAPTER_AUTO_NEXT_BATTLE = false;
|
2025-11-16 20:30:15 +08:00
|
|
|
std::atomic<bool> CHAPTER_AUTO_AMBUSH = false;
|
2025-11-18 18:12:20 +08:00
|
|
|
std::atomic<bool> CHAPTER_AUTO_CLEAR = false;
|
2025-11-01 00:23:46 +08:00
|
|
|
} m_flag;
|
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
Lua::Table player;
|
|
|
|
|
Lua::Table world;
|
|
|
|
|
Lua::Table dock;
|
|
|
|
|
Lua::Table storage;
|
|
|
|
|
} m_data_proxy;
|
|
|
|
|
int m_gg_factor = 1;
|
|
|
|
|
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;
|
|
|
|
|
Lua::Function ys_Battle_BattleDataFunction_GetDungeonTmpDataByID;
|
|
|
|
|
Lua::Function ys_Battle_BattleEnemyUnit_GetTemplate;
|
|
|
|
|
Lua::Function ys_Battle_BattleState_ExitBattle;
|
|
|
|
|
Lua::Function ys_Battle_BattleState_ScaleTimer;
|
|
|
|
|
Lua::Function ShipSkin_IsShareSkin;
|
|
|
|
|
Lua::Function ShipSkin_CanUseShareSkinForShip;
|
|
|
|
|
Lua::Function ShipSkinProxy_hasSkin;
|
|
|
|
|
Lua::Function ShipSkinProxy_hasNonLimitSkin;
|
|
|
|
|
Lua::Function pg_ConnectionMgr_Send;
|
|
|
|
|
Lua::Function Ship_getSkinId;
|
2025-11-01 23:39:40 +08:00
|
|
|
Lua::Function WorldMap_CanAutoFight;
|
|
|
|
|
Lua::Function WorldMap_UpdateVisionFlag;
|
2025-11-16 16:20:45 +08:00
|
|
|
Lua::Function NewBattleResultDisplayAwardPage_ShowShips;
|
|
|
|
|
Lua::Function BaseUI_emit;
|
2025-11-16 18:04:18 +08:00
|
|
|
Lua::Function Chapter_CanActivateAutoFight;
|
|
|
|
|
Lua::Function Chapter_IsAutoFight;
|
2025-11-16 18:27:53 +08:00
|
|
|
Lua::Function Chapter_IsSkipPrecombat;
|
2025-11-16 19:38:48 +08:00
|
|
|
Lua::Function Chapter_writeBack;
|
2025-11-16 20:30:15 +08:00
|
|
|
Lua::Function LevelStageView_tryAutoTrigger;
|
2025-11-18 18:12:20 +08:00
|
|
|
Lua::Function LevelStageView_TryAutoFight;
|
2025-11-01 00:23:46 +08:00
|
|
|
} m_original;
|
|
|
|
|
struct {
|
|
|
|
|
Lua::Function Clone;
|
|
|
|
|
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;
|
2025-11-16 16:20:45 +08:00
|
|
|
std::string BattleResultMediator_GET_NEW_SHIP;
|
|
|
|
|
std::string NewBattleResultMediator_GET_NEW_SHIP;
|
2025-11-16 18:04:18 +08:00
|
|
|
Lua::Function getProxy;
|
|
|
|
|
Lua::Table ChapterProxy;
|
|
|
|
|
Lua::Function ChapterProxy_GetChapterAutoFlag;
|
2025-11-16 19:38:48 +08:00
|
|
|
Lua::Function ChapterProxy_SetChapterAutoFlag;
|
2025-11-16 20:30:15 +08:00
|
|
|
Lua::Function Chapter_getChapterCell;
|
|
|
|
|
Lua::Function LevelStageView_emit;
|
2025-11-18 18:12:20 +08:00
|
|
|
Lua::Function Chapter_emit;
|
|
|
|
|
int ChapterConst_OpMove;
|
|
|
|
|
int ChapterConst_CellFlagActive;
|
|
|
|
|
Lua::Function ChapterConst_IsEnemyAttach;
|
|
|
|
|
std::string LevelMediator2_ON_OP;
|
|
|
|
|
Lua::Function Timer_New;
|
|
|
|
|
Lua::Function Timer_Start;
|
|
|
|
|
Lua::Function ChapterConst_IsBossCell;
|
|
|
|
|
int ChapterConst_CellFlagDisabled;
|
|
|
|
|
Lua::Function Chapter_checkAnyInteractive;
|
|
|
|
|
Lua::Function Chapter_GetFleetOfDuty;
|
|
|
|
|
Lua::Function Chapter_findPath;
|
|
|
|
|
int ChapterConst_SubjectPlayer;
|
2025-11-01 00:23:46 +08:00
|
|
|
} m_lua_res;
|
2025-11-18 18:12:20 +08:00
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
Lua::Function Chapter_IsAutoFight;
|
|
|
|
|
Lua::Function LevelStageView_tryAutoTrigger;
|
|
|
|
|
} m_real_func;
|
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
std::optional<Lua::Table> path;
|
|
|
|
|
int idx = 1;
|
|
|
|
|
bool moving = false;
|
|
|
|
|
int stepSize = 3;
|
|
|
|
|
int currentStepSize = 3;
|
|
|
|
|
int lastTargetIdx = 0;
|
|
|
|
|
std::optional<Lua::Table> lastMoveStartP;
|
|
|
|
|
double interval = 0.5;
|
|
|
|
|
std::optional<Lua::Table> view;
|
|
|
|
|
} m_mover;
|
|
|
|
|
|
2025-11-01 00:23:46 +08:00
|
|
|
std::atomic<double> m_exercise_more_power_rate = 0.03;
|
|
|
|
|
FakePlayerInfo m_fake_player_info;
|
|
|
|
|
ShipProperties m_globle_ship_properties;
|
|
|
|
|
std::map<ShipId, ShipProperties> m_specific_ship_properties;
|
|
|
|
|
Timer m_global_speedup_timer;
|
|
|
|
|
std::atomic<float> m_global_speedup_rate = 1.0;
|
|
|
|
|
std::atomic<double> m_better_global_speedup_rate = 1.0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif //CRACKER_HPP
|