1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-17 21:49:29 +08:00
Files
Alas/blcrack/cracker/cracker.hpp
2025-03-18 15:12:42 +08:00

133 lines
3.6 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>
namespace Lua {
using Table = sol::table;
using Object = sol::object;
using Function = sol::function;
using VariadicArgs = sol::variadic_args;
using StateView = sol::state_view;
}
enum {
GLOBAL_SHIP_PROPERTIES_CRACK,
SPECIFIC_SHIP_PROPERTIES_CRACK,
FAST_STAGE_MOVE_CRACK,
REMOVE_HARD_MODE_SHIP_PROPERTIES_LIMIT,
REMOVE_HARD_MODE_SHIP_TYPE_LIMIT,
FAKE_PLAYER_INFO,
NO_BB_ANIMATION,
NO_EMOTION_WARNING,
OPSI_FAST_MOVE,
};
class Cracker {
public:
using FunctionId = int;
using ShipId = 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;
};
public:
Cracker();
static Cracker& Instance();
void disable_all();
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();
bool is_enabled(FunctionId id);
bool is_disabled(FunctionId id);
void print_table_field(std::vector<std::string>& path);
private:
void enable_flag(FunctionId id);
void disable_flag(FunctionId id);
static void modify_ship_properties(Lua::Table& properties, const ShipProperties& new_properties);
static void clear_hard_mode_ship_properties_limit(Lua::Table& t);
std::map<FunctionId, bool> m_functions;
sol::state_view m_state;
struct {
Lua::Function Ship_getShipProperties;
double ChapterConst_ShipStepDuration;
double ChapterConst_ShipStepQuickPlayScale;
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;
double WorldConst_BaseMoveDuration;
} m_original;
FakePlayerInfo m_fake_player_info;
ShipProperties m_globle_ship_properties;
std::map<ShipId, ShipProperties> m_specific_ship_properties;
};
#endif //CRACKER_HPP