1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-14 16:09:25 +08:00
Files
Alas/blcrack/cracker/cracker.hpp
2025-11-01 23:39:40 +08:00

294 lines
9.0 KiB
C++

#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 {
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;
bool OPSI_FORCE_AUTO = false;
bool OPSI_NO_MAP_FOG = false;
} 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();
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();
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:
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 {
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;
std::atomic<bool> OPSI_FORCE_AUTO = false;
std::atomic<bool> OPSI_NO_MAP_FOG = false;
} 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;
Lua::Function WorldMap_CanAutoFight;
Lua::Function WorldMap_UpdateVisionFlag;
} 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;
} m_lua_res;
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