1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-14 08:49:24 +08:00
Files
Alas/module/luahook/op.py
2026-03-20 23:15:39 +08:00

528 lines
19 KiB
Python

from module.luahook.api import CrackApi
class CrackOp:
class Op:
def __init__(self, full_config, api):
self.full_config = full_config
self.api = api
def execute_with_pause(self):
...
def execute_without_pause(self):
self.execute_with_pause()
class EnableAll(Op):
...
class DisableAll(Op):
def execute_with_pause(self):
self.api.disable_all()
def execute_without_pause(self):
self.api.disable_all_without_pause()
class EnableHookedLuaFunctionTrace(Op):
def execute_with_pause(self):
if self.full_config.Hook_HookGeneral_HookedLuaFunctionTrace:
self.api.enable_hooked_lua_function_trace()
class DisableHookedLuaFunctionTrace(Op):
def execute_with_pause(self):
self.api.disable_hooked_lua_function_trace()
class EnableGlobalShipProperties(Op):
def execute_with_pause(self):
if self.full_config.Hook_ShipProperty_Method != "final_properties":
return
self.api.update_global_ship_properties(
CrackApi.ShipProperties(
armor=float(self.full_config.Hook_ShipProperty_Armor),
speed=float(self.full_config.Hook_ShipProperty_Speed),
antiaircraft=float(self.full_config.Hook_ShipProperty_AntiAircraft),
oxy_recovery_bench=float(self.full_config.Hook_ShipProperty_OxyRecoveryBench),
torpedo=float(self.full_config.Hook_ShipProperty_Torpedo),
hit=float(self.full_config.Hook_ShipProperty_Hit),
sonarRange=float(self.full_config.Hook_ShipProperty_SonarRange),
attack_duration=float(self.full_config.Hook_ShipProperty_AttackDuration),
raid_distance=float(self.full_config.Hook_ShipProperty_RaidDistance),
oxy_recovery_surface=float(self.full_config.Hook_ShipProperty_OxyRecoverySurface),
oxy_recovery=float(self.full_config.Hook_ShipProperty_OxyRecovery),
dodge=float(self.full_config.Hook_ShipProperty_Dodge),
luck=float(self.full_config.Hook_ShipProperty_Luck),
reload=float(self.full_config.Hook_ShipProperty_Reload),
oxy_cost=float(self.full_config.Hook_ShipProperty_OxyCost),
durability=float(self.full_config.Hook_ShipProperty_Durability),
air=float(self.full_config.Hook_ShipProperty_Air),
oxy_max=float(self.full_config.Hook_ShipProperty_OxyMax),
cannon=float(self.full_config.Hook_ShipProperty_Cannon),
antisub=float(self.full_config.Hook_ShipProperty_AntiSub),
)
)
self.api.enable_global_ship_properties_crack()
class DisableGlobalShipProperties(Op):
def execute_with_pause(self):
self.api.disable_global_ship_properties_crack()
class EnableChapterFastMove(Op):
def execute_with_pause(self):
if not self.full_config.Hook_Misc_ChapterMove:
return
self.api.enable_fast_stage_move()
def execute_without_pause(self):
if not self.full_config.Hook_Misc_ChapterMove:
return
self.api.enable_fast_stage_move_without_pause()
class DisableChapterFastMove(Op):
def execute_with_pause(self):
self.api.disable_fast_stage_move()
def execute_without_pause(self):
self.api.disable_fast_stage_move_without_pause()
class EnableOpsiFastMove(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_ChapterMove:
self.api.enable_opsi_fast_move()
class DisableOpsiFastMove(Op):
def execute_with_pause(self):
self.api.disable_opsi_fast_move()
class EnableRemoveHardModeShipPropertiesLimit(Op):
def execute_with_pause(self):
remove_method = self.full_config.Hook_Misc_RemoveHardMapLimit
if remove_method in ["remove_ship_properties_limit", "remove_both"]:
self.api.enable_remove_hard_mode_ship_properties_limit()
class DisableRemoveHardModeShipPropertiesLimit(Op):
def execute_with_pause(self):
self.api.disable_remove_hard_mode_ship_properties_limit()
class EnableRemoveHardModeShipTypeLimit(Op):
def execute_with_pause(self):
remove_method = self.full_config.Hook_Misc_RemoveHardMapLimit
if remove_method in ["remove_ship_type_limit", "remove_both"]:
self.api.enable_remove_hard_mode_ship_type_limit()
class DisableRemoveHardModeShipTypeLimit(Op):
def execute_with_pause(self):
self.api.disable_remove_hard_mode_ship_type_limit()
class EnableRemoveHardModeLimit(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_RemoveHardMapLimit != "remove_both":
return
self.api.enable_remove_hard_mode_limit()
class DisableRemoveHardModeLimit(Op):
def execute_with_pause(self):
self.api.disable_remove_hard_mode_limit()
class EnableFakePlayer(Op):
def execute_with_pause(self):
if not self.full_config.Hook_FakePlayer_Enable:
return
self.api.update_fake_player_info(
CrackApi.FakePlayerInfo(
name=str(self.full_config.Hook_FakePlayer_Name),
level=str(self.full_config.Hook_FakePlayer_Level),
id=str(self.full_config.Hook_FakePlayer_Id),
)
)
self.api.enable_fake_player()
class DisableFakePlayer(Op):
def execute_with_pause(self):
self.api.disable_fake_player()
class EnableGlobalSpeedup(Op):
def execute_with_pause(self):
rate = float(self.full_config.Hook_Misc_GlobalSpeedup)
if rate == 1.0:
return
self.api.update_global_speedup_rate(CrackApi.GlobalSpeedupRate(rate=rate))
self.api.enable_global_speedup()
class DisableGlobalSpeedup(Op):
def execute_with_pause(self):
self.api.disable_global_speedup()
class EnableBetterGlobalSpeedup(Op):
def execute_with_pause(self):
rate = self.full_config.Hook_Misc_BetterGlobalSpeedup
if rate == 1.0:
return
self.api.update_better_global_speedup_rate(CrackApi.BetterGlobalSpeedupRate(rate=rate))
self.api.enable_better_global_speedup()
def execute_without_pause(self):
rate = self.full_config.Hook_Misc_BetterGlobalSpeedup
if rate == 1.0:
return
self.api.update_better_global_speedup_rate_without_pause(CrackApi.BetterGlobalSpeedupRate(rate=rate))
self.api.enable_better_global_speedup_without_pause()
class DisableBetterGlobalSpeedup(Op):
def execute_with_pause(self):
self.api.disable_better_global_speedup()
def execute_without_pause(self):
self.api.disable_better_global_speedup_without_pause()
class EnableNoBBAnimation(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_NoBBAnimation:
self.api.enable_no_bb_animation()
class DisableNoBBAnimation(Op):
def execute_with_pause(self):
self.api.disable_no_bb_animation()
class EnableNoEmotionWarning(Op):
def execute_with_pause(self):
if not self.full_config.Hook_Misc_NoEmotionWarning:
return
self.api.enable_no_emotion_warning()
def execute_without_pause(self):
if not self.full_config.Hook_Misc_NoEmotionWarning:
return
self.api.enable_no_emotion_warning_without_pause()
class DisableNoEmotionWarning(Op):
def execute_with_pause(self):
self.api.disable_no_emotion_warning()
def execute_without_pause(self):
self.api.disable_no_emotion_warning_without_pause()
class IsAlive(Op):
def execute_with_pause(self):
self.api.is_alive()
class EnableGGFactor(Op):
def execute_with_pause(self):
if self.full_config.Hook_ShipProperty_Method != "gg_factor":
return
self.api.update_gg_factor(float(self.full_config.Hook_ShipProperty_Factor))
self.api.enable_gg_factor()
class DisableGGFactor(Op):
def execute_with_pause(self):
self.api.disable_gg_factor()
class EnableExerciseGodMod(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_ExerciseGodMod:
self.api.enable_exercise_god_mode()
class DisableExerciseGodMod(Op):
def execute_with_pause(self):
self.api.disable_exercise_god_mode()
class EnableExerciseMorePower(Op):
def execute_with_pause(self):
rate = float(self.full_config.Hook_Misc_ExerciseMorePower)
if rate == -1.0:
return
self.api.update_exercise_more_power_rate(CrackApi.ExerciseMorePowerRate(rate=rate))
self.api.enable_exercise_more_power()
class DisableExerciseMorePower(Op):
def execute_with_pause(self):
self.api.disable_exercise_more_power()
class EnableFastWave(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_FastWave:
self.api.enable_fast_wave()
class DisableFastWave(Op):
def execute_with_pause(self):
self.api.disable_fast_wave()
class EnableMonsterKillSelf(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_MonsterKillSelf:
self.api.enable_monster_kill_self()
class DisableMonsterKillSelf(Op):
def execute_with_pause(self):
self.api.disable_monster_kill_self()
class EnableSkipBattleCelebrate(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_SkipBattleCelebrate:
self.api.enable_skip_battle_celebrate()
def execute_without_pause(self):
if self.full_config.Hook_Misc_SkipBattleCelebrate:
self.api.enable_skip_battle_celebrate_without_pause()
class DisableSkipBattleCelebrate(Op):
def execute_with_pause(self):
self.api.disable_skip_battle_celebrate()
def execute_without_pause(self):
self.api.disable_skip_battle_celebrate_without_pause()
class EnableNoDamage(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_NoDamage:
self.api.enable_no_damage()
class DisableNoDamage(Op):
def execute_with_pause(self):
self.api.disable_no_damage()
class EnableOpsiForceAuto(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_OpsiForceAuto:
self.api.enable_opsi_force_auto()
class DisableOpsiForceAuto(Op):
def execute_with_pause(self):
self.api.disable_opsi_force_auto()
class EnableOpsiNoMapFog(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_OpsiNoMapFog:
self.api.enable_opsi_no_map_fog()
class DisableOpsiNoMapFog(Op):
def execute_with_pause(self):
self.api.disable_opsi_no_map_fog()
class EnableSkipShipGainShow(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_SkipShipGainShow:
self.api.enable_skip_ship_gain_show()
class DisableSkipShipGainShow(Op):
def execute_with_pause(self):
self.api.disable_skip_ship_gain_show()
class EnableChapterForceEnableAutoFight(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_ChapterForceEnableAutoFight:
self.api.enable_chapter_force_enable_auto_fight()
class DisableChapterForceEnableAutoFight(Op):
def execute_with_pause(self):
self.api.disable_chapter_force_enable_auto_fight()
class EnableChapterSkipPrecombat(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_ChapterSkipPrecombat:
self.api.enable_chapter_skip_precombat()
class DisableChapterSkipPrecombat(Op):
def execute_with_pause(self):
self.api.disable_chapter_skip_precombat()
class EnableChapterAutoNextBattle(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_ChapterAutoNextBattle:
self.api.enable_chapter_auto_next_battle()
class DisableChapterAutoNextBattle(Op):
def execute_with_pause(self):
self.api.disable_chapter_auto_next_battle()
class EnableChapterAutoAmbush(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_ChapterAutoAmbush:
self.api.enable_chapter_auto_ambush()
class DisableChapterAutoAmbush(Op):
def execute_with_pause(self):
self.api.disable_chapter_auto_ambush()
class EnableChapterAutoClear(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_ChapterAutoClear:
self.api.set_chapter_auto_clear_step_interval(CrackApi.ChapterAutoClearStepInterval(
interval=float(self.full_config.Hook_Misc_ChapterAutoClearStepInterval)))
self.api.enable_chapter_auto_clear()
class DisableChapterAutoClear(Op):
def execute_with_pause(self):
self.api.disable_chapter_auto_clear()
class EnableSkipStory(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_SkipStory:
self.api.enable_skip_story()
class DisableSkipStory(Op):
def execute_with_pause(self):
self.api.disable_skip_story()
class EnableInfiniteBattle(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_InfiniteBattle:
self.api.enable_infinite_battle()
class DisableInfiniteBattle(Op):
def execute_with_pause(self):
self.api.disable_infinite_battle()
class EnableSkipAirStrikeAnimation(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_SkipAirStrikeAnimation:
self.api.enable_skip_air_strike_animation()
class DisableSkipAirStrikeAnimation(Op):
def execute_with_pause(self):
self.api.disable_skip_air_strike_animation()
class EnableAutoOnceAgain(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_AutoOnceAgain:
self.api.enable_auto_once_again()
class DisableAutoOnceAgain(Op):
def execute_with_pause(self):
self.api.disable_auto_once_again()
class EnableAutoRetire(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_AutoRetire:
white_flagship_keep_count = self.full_config.Hook_Misc_AutoRetireKeepWhiteFlagshipCount
if white_flagship_keep_count != 0:
self.api.set_white_flagship_keep_count(CrackApi.AutoRetireKeepWhiteFlagshipCount(count=white_flagship_keep_count))
self.api.enable_auto_retire()
class DisableAutoRetire(Op):
def execute_with_pause(self):
self.api.disable_auto_retire()
class EnableSkipEnemyScan(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_SkipEnemyScan:
self.api.enable_skip_enemy_scan()
class DisableSkipEnemyScan(Op):
def execute_with_pause(self):
self.api.disable_skip_enemy_scan()
class EnableSkipBattleResult(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_SkipBattleResult:
self.api.enable_skip_battle_result()
class DisableSkipBattleResult(Op):
def execute_with_pause(self):
self.api.disable_skip_battle_result()
class EnableSkipEnterBattle(Op):
def execute_with_pause(self):
if self.full_config.Hook_Misc_SkipEnterBattle:
self.api.enable_skip_enter_battle()
def execute_without_pause(self):
if self.full_config.Hook_Misc_SkipEnterBattle:
self.api.enable_skip_enter_battle_without_pause()
class DisableSkipEnterBattle(Op):
def execute_with_pause(self):
self.api.disable_skip_enter_battle()
def execute_without_pause(self):
self.api.disable_skip_enter_battle_without_pause()
ALL_ENABLE_OPS = [
EnableHookedLuaFunctionTrace,
EnableGlobalShipProperties,
EnableChapterFastMove,
# EnableRemoveHardModeLimit,
EnableFakePlayer,
EnableNoBBAnimation,
EnableNoEmotionWarning,
EnableOpsiFastMove,
EnableRemoveHardModeShipTypeLimit,
EnableRemoveHardModeShipPropertiesLimit,
EnableGGFactor,
EnableGlobalSpeedup,
EnableBetterGlobalSpeedup,
EnableExerciseGodMod,
EnableExerciseMorePower,
EnableFastWave,
EnableMonsterKillSelf,
EnableSkipBattleCelebrate,
EnableNoDamage,
EnableOpsiForceAuto,
EnableOpsiNoMapFog,
EnableSkipShipGainShow,
EnableChapterForceEnableAutoFight,
EnableChapterSkipPrecombat,
EnableChapterAutoNextBattle,
EnableChapterAutoAmbush,
EnableChapterAutoClear,
EnableSkipStory,
EnableInfiniteBattle,
EnableSkipAirStrikeAnimation,
EnableAutoOnceAgain,
EnableAutoRetire,
EnableSkipEnemyScan,
EnableSkipBattleResult,
EnableSkipEnterBattle,
]
CHAPTER_CRACK_OPS = [
EnableHookedLuaFunctionTrace,
EnableChapterFastMove,
EnableNoBBAnimation,
EnableNoEmotionWarning,
EnableGlobalShipProperties,
EnableRemoveHardModeLimit,
EnableFakePlayer,
EnableGGFactor,
EnableGlobalSpeedup,
EnableBetterGlobalSpeedup,
EnableFastWave,
EnableMonsterKillSelf,
EnableSkipBattleCelebrate,
EnableNoDamage,
EnableSkipShipGainShow,
EnableChapterForceEnableAutoFight,
EnableChapterSkipPrecombat,
EnableChapterAutoNextBattle,
EnableChapterAutoAmbush,
EnableChapterAutoClear,
EnableSkipStory,
EnableInfiniteBattle,
EnableSkipAirStrikeAnimation,
EnableAutoOnceAgain,
EnableAutoRetire,
EnableSkipEnemyScan,
EnableSkipBattleResult,
EnableSkipEnterBattle,
]
OPSI_CRACK_OPS = [
EnableHookedLuaFunctionTrace,
EnableNoBBAnimation,
EnableOpsiFastMove,
EnableGlobalShipProperties,
EnableFakePlayer,
EnableGGFactor,
EnableGlobalSpeedup,
EnableBetterGlobalSpeedup,
EnableFastWave,
EnableMonsterKillSelf,
EnableSkipBattleCelebrate,
EnableNoDamage,
EnableOpsiForceAuto,
EnableOpsiNoMapFog,
EnableSkipShipGainShow,
EnableSkipStory,
EnableSkipBattleResult,
EnableSkipEnterBattle,
]