#pragma once #include "reboot.h" #include "FortGameModeAthena.h" #include "GameplayStatics.h" #include "CurveTable.h" #include "KismetStringLibrary.h" #include "DataTableFunctionLibrary.h" #include "FortPlaysetItemDefinition.h" static inline void (*SetZoneToIndexOriginal)(AFortGameModeAthena* GameModeAthena, int OverridePhaseMaybeIDFK); static inline void SetZoneToIndexHook(AFortGameModeAthena* GameModeAthena, int OverridePhaseMaybeIDFK) { static auto ZoneDurationsOffset = Fortnite_Version >= 15 && Fortnite_Version < 18 ? 0x258 : std::floor(Fortnite_Version) >= 18 ? 0x248 : 0x1F8; // S13-S14 LOG_INFO(LogDev, "SetZoneToIndexHook!"); auto GameState = Cast(GameModeAthena->GetGameState()); LOG_INFO(LogDev, "GamePhaseStep: {}", (int)GameState->GetGamePhaseStep()); if (Globals::bLateGame) { static auto GameMode_SafeZonePhaseOffset = GameModeAthena->GetOffset("SafeZonePhase"); static auto GameState_SafeZonePhaseOffset = GameState->GetOffset("SafeZonePhase"); static int ahaaSafeZonePhase = 4; int NewSafeZonePhase = ahaaSafeZonePhase; // GameModeAthena->Get(GameMode_SafeZonePhaseOffset); const int OriginalOldSafeZonePhase = GameModeAthena->Get(GameMode_SafeZonePhaseOffset); if (NewSafeZonePhase < 4) { NewSafeZonePhase = 4; } LOG_INFO(LogDev, "Setting zone to: {} ({})", NewSafeZonePhase, OriginalOldSafeZonePhase); GameModeAthena->Get(GameMode_SafeZonePhaseOffset) = NewSafeZonePhase; GameState->Get(GameState_SafeZonePhaseOffset) = NewSafeZonePhase; ahaaSafeZonePhase++; } if (Fortnite_Version < 13) { SetZoneToIndexOriginal(GameModeAthena, OverridePhaseMaybeIDFK); return; } if (!GameState) return SetZoneToIndexOriginal(GameModeAthena, OverridePhaseMaybeIDFK); static auto SafeZoneIndicatorOffset = GameModeAthena->GetOffset("SafeZoneIndicator"); auto SafeZoneIndicator = GameModeAthena->Get(SafeZoneIndicatorOffset); if (!SafeZoneIndicator) { LOG_WARN(LogZone, "Invalid SafeZoneIndicator!"); return SetZoneToIndexOriginal(GameModeAthena, OverridePhaseMaybeIDFK); } static auto SafeZoneFinishShrinkTimeOffset = SafeZoneIndicator->GetOffset("SafeZoneFinishShrinkTime"); static auto SafeZoneStartShrinkTimeOffset = SafeZoneIndicator->GetOffset("SafeZoneStartShrinkTime"); static auto RadiusOffset = SafeZoneIndicator->GetOffset("Radius"); static auto SafeZonePhaseOffset = GameModeAthena->GetOffset("SafeZonePhase"); static auto MapInfoOffset = GameState->GetOffset("MapInfo"); auto MapInfo = GameState->Get(MapInfoOffset); if (!MapInfo) { LOG_WARN(LogZone, "Invalid MapInfo!") return SetZoneToIndexOriginal(GameModeAthena, OverridePhaseMaybeIDFK); } static auto SafeZoneDefinitionOffset = MapInfo->GetOffset("SafeZoneDefinition"); auto SafeZoneDefinition = MapInfo->GetPtr<__int64>(SafeZoneDefinitionOffset); LOG_INFO(LogDev, "SafeZoneDefinitionOffset: 0x{:x}", SafeZoneDefinitionOffset); static auto ZoneHoldDurationsOffset = ZoneDurationsOffset - 0x10; // fr auto& ZoneDurations = *(TArray*)(__int64(SafeZoneDefinition) + ZoneDurationsOffset); auto& ZoneHoldDurations = *(TArray*)(__int64(SafeZoneDefinition) + ZoneHoldDurationsOffset); static bool bFilledDurations = false; if (!bFilledDurations) { bFilledDurations = true; auto CurrentPlaylist = GameState->GetCurrentPlaylist(); UCurveTable* FortGameData = nullptr; static auto GameDataOffset = CurrentPlaylist->GetOffset("GameData"); FortGameData = CurrentPlaylist ? CurrentPlaylist->Get>(GameDataOffset).Get() : nullptr; if (!FortGameData) FortGameData = FindObject(L"/Game/Balance/AthenaGameData.AthenaGameData"); // LOG_INFO(LogDev, "FortGameData: {}", FortGameData ? FortGameData->GetFullName() : "InvalidObject"); auto ShrinkTimeFName = UKismetStringLibrary::Conv_StringToName(L"Default.SafeZone.ShrinkTime"); auto HoldTimeFName = UKismetStringLibrary::Conv_StringToName(L"Default.SafeZone.WaitTime"); FString ContextString; /* for (int i = 0; i < 10; i++) { LOG_INFO(LogDev, "[{}] Value {}", i, FortGameData->GetValueOfKey(FortGameData->GetKey(ShrinkTimeFName, i))); } */ /* for (float i = 0; i < 1.1; i += 0.1) { float res; UDataTableFunctionLibrary::EvaluateCurveTableRow(FortGameData, ShrinkTimeFName, i, ContextString, nullptr, &res); LOG_INFO(LogZone, "[{}] {}", i, res); } */ for (int i = 0; i < ZoneDurations.Num(); i++) { ZoneDurations.at(i) = FortGameData->GetValueOfKey(FortGameData->GetKey(ShrinkTimeFName, i)); } for (int i = 0; i < ZoneHoldDurations.Num(); i++) { ZoneHoldDurations.at(i) = FortGameData->GetValueOfKey(FortGameData->GetKey(HoldTimeFName, i)); } /* for (int i = 0; i < ZoneDurations.Num(); i++) { LOG_INFO(LogZone, "Move [{}] {}", i, ZoneDurations.at(i)); } for (int i = 0; i < ZoneHoldDurations.Num(); i++) { LOG_INFO(LogZone, "Hold [{}] {}", i, ZoneHoldDurations.at(i)); } */ } LOG_INFO(LogZone, "SafeZonePhase: {}", GameModeAthena->Get(SafeZonePhaseOffset)); LOG_INFO(LogZone, "OverridePhaseMaybeIDFK: {}", OverridePhaseMaybeIDFK); LOG_INFO(LogZone, "TimeSeconds: {}", UGameplayStatics::GetTimeSeconds(GetWorld())); SetZoneToIndexOriginal(GameModeAthena, OverridePhaseMaybeIDFK); LOG_INFO(LogZone, "SafeZonePhase After: {}", GameModeAthena->Get(SafeZonePhaseOffset)); float ZoneHoldDuration = 0; if (GameModeAthena->Get(SafeZonePhaseOffset) >= 0 && GameModeAthena->Get(SafeZonePhaseOffset) < ZoneHoldDurations.Num()) ZoneHoldDuration = ZoneHoldDurations.at(GameModeAthena->Get(SafeZonePhaseOffset)); SafeZoneIndicator->Get(SafeZoneStartShrinkTimeOffset) = GameState->GetServerWorldTimeSeconds() + ZoneHoldDuration; float ZoneDuration = 0; if (GameModeAthena->Get(SafeZonePhaseOffset) >= 0 && GameModeAthena->Get(SafeZonePhaseOffset) < ZoneDurations.Num()) ZoneDuration = ZoneDurations.at(GameModeAthena->Get(SafeZonePhaseOffset)); LOG_INFO(LogZone, "ZoneDuration: {}", ZoneDuration); LOG_INFO(LogZone, "Duration: {}", SafeZoneIndicator->Get(RadiusOffset)); SafeZoneIndicator->Get(SafeZoneFinishShrinkTimeOffset) = SafeZoneIndicator->Get(SafeZoneStartShrinkTimeOffset) + ZoneDuration; } static inline void ProcessEventHook(UObject* Object, UFunction* Function, void* Parameters) { if (!Object || !Function) return; if (Globals::bLogProcessEvent) { auto FunctionName = Function->GetName(); // UKismetSystemLibrary::GetPathName(Function).ToString(); auto FunctionFullName = Function->GetFullName(); auto ObjectName = Object->GetName(); if (!strstr(FunctionName.c_str(), ("EvaluateGraphExposedInputs")) && !strstr(FunctionName.c_str(), ("Tick")) && !strstr(FunctionName.c_str(), ("OnSubmixEnvelope")) && !strstr(FunctionName.c_str(), ("OnSubmixSpectralAnalysis")) && !strstr(FunctionName.c_str(), ("OnMouse")) && !strstr(FunctionName.c_str(), ("Pulse")) && !strstr(FunctionName.c_str(), ("BlueprintUpdateAnimation")) && !strstr(FunctionName.c_str(), ("BlueprintPostEvaluateAnimation")) && !strstr(FunctionName.c_str(), ("BlueprintModifyCamera")) && !strstr(FunctionName.c_str(), ("BlueprintModifyPostProcess")) && !strstr(FunctionName.c_str(), ("Loop Animation Curve")) && !strstr(FunctionName.c_str(), ("UpdateTime")) && !strstr(FunctionName.c_str(), ("GetMutatorByClass")) && !strstr(FunctionName.c_str(), ("UpdatePreviousPositionAndVelocity")) && !strstr(FunctionName.c_str(), ("IsCachedIsProjectileWeapon")) && !strstr(FunctionName.c_str(), ("LockOn")) && !strstr(FunctionName.c_str(), ("GetAbilityTargetingLevel")) && !strstr(FunctionName.c_str(), ("ReadyToEndMatch")) && !strstr(FunctionName.c_str(), ("ReceiveDrawHUD")) && !strstr(FunctionName.c_str(), ("OnUpdateDirectionalLightForTimeOfDay")) && !strstr(FunctionName.c_str(), ("GetSubtitleVisibility")) && !strstr(FunctionName.c_str(), ("GetValue")) && !strstr(FunctionName.c_str(), ("InputAxisKeyEvent")) && !strstr(FunctionName.c_str(), ("ServerTouchActiveTime")) && !strstr(FunctionName.c_str(), ("SM_IceCube_Blueprint_C")) && !strstr(FunctionName.c_str(), ("OnHovered")) && !strstr(FunctionName.c_str(), ("OnCurrentTextStyleChanged")) && !strstr(FunctionName.c_str(), ("OnButtonHovered")) && !strstr(FunctionName.c_str(), ("ExecuteUbergraph_ThreatPostProcessManagerAndParticleBlueprint")) && !strstr(FunctionName.c_str(), "PinkOatmeal") && !strstr(FunctionName.c_str(), "CheckForDancingAtFish") && !strstr(FunctionName.c_str(), ("UpdateCamera")) && !strstr(FunctionName.c_str(), ("GetMutatorContext")) && !strstr(FunctionName.c_str(), ("CanJumpInternal")) && !strstr(FunctionName.c_str(), ("OnDayPhaseChanged")) && !strstr(FunctionName.c_str(), ("Chime")) && !strstr(FunctionName.c_str(), ("ServerMove")) && !strstr(FunctionName.c_str(), ("OnVisibilitySetEvent")) && !strstr(FunctionName.c_str(), "ReceiveHit") && !strstr(FunctionName.c_str(), "ReadyToStartMatch") && !strstr(FunctionName.c_str(), "K2_GetComponentToWorld") && !strstr(FunctionName.c_str(), "ClientAckGoodMove") && !strstr(FunctionName.c_str(), "Prop_WildWest_WoodenWindmill_01") && !strstr(FunctionName.c_str(), "ContrailCheck") && !strstr(FunctionName.c_str(), "B_StockBattleBus_C") && !strstr(FunctionName.c_str(), "Subtitles.Subtitles_C.") && !strstr(FunctionName.c_str(), "/PinkOatmeal/PinkOatmeal_") && !strstr(FunctionName.c_str(), "BP_SpectatorPawn_C") && !strstr(FunctionName.c_str(), "FastSharedReplication") && !strstr(FunctionName.c_str(), "OnCollisionHitEffects") && !strstr(FunctionName.c_str(), "BndEvt__SkeletalMesh") && !strstr(FunctionName.c_str(), ".FortAnimInstance.AnimNotify_") && !strstr(FunctionName.c_str(), "OnBounceAnimationUpdate") && !strstr(FunctionName.c_str(), "ShouldShowSoundIndicator") && !strstr(FunctionName.c_str(), "Primitive_Structure_AmbAudioComponent_C") && !strstr(FunctionName.c_str(), "PlayStoppedIdleRotationAudio") && !strstr(FunctionName.c_str(), "UpdateOverheatCosmetics") && !strstr(FunctionName.c_str(), "StormFadeTimeline__UpdateFunc") && !strstr(FunctionName.c_str(), "BindVolumeEvents") && !strstr(FunctionName.c_str(), "UpdateStateEvent") && !strstr(FunctionName.c_str(), "VISUALS__UpdateFunc") && !strstr(FunctionName.c_str(), "Flash__UpdateFunc") && !strstr(FunctionName.c_str(), "SetCollisionEnabled") && !strstr(FunctionName.c_str(), "SetIntensity") && !strstr(FunctionName.c_str(), "Storm__UpdateFunc") && !strstr(FunctionName.c_str(), "CloudsTimeline__UpdateFunc") && !strstr(FunctionName.c_str(), "SetRenderCustomDepth") && !strstr(FunctionName.c_str(), "K2_UpdateCustomMovement") && !strstr(FunctionName.c_str(), "AthenaHitPointBar_C.Update") && !strstr(FunctionName.c_str(), "ExecuteUbergraph_Farm_WeatherVane_01") && !strstr(FunctionName.c_str(), "HandleOnHUDElementVisibilityChanged") && !strstr(FunctionName.c_str(), "ExecuteUbergraph_Fog_Machine") && !strstr(FunctionName.c_str(), "ReceiveBeginPlay") && !strstr(FunctionName.c_str(), "OnMatchStarted") && !strstr(FunctionName.c_str(), "CustomStateChanged") && !strstr(FunctionName.c_str(), "OnBuildingActorInitialized") && !strstr(FunctionName.c_str(), "OnWorldReady") && !strstr(FunctionName.c_str(), "OnAttachToBuilding") && !strstr(FunctionName.c_str(), "Clown Spinner") && !strstr(FunctionName.c_str(), "K2_GetActorLocation") && !strstr(FunctionName.c_str(), "GetViewTarget") && !strstr(FunctionName.c_str(), "GetAllActorsOfClass") && !strstr(FunctionName.c_str(), "OnUpdateMusic") && !strstr(FunctionName.c_str(), "Check Closest Point") && !strstr(FunctionName.c_str(), "OnSubtitleChanged__DelegateSignature") && !strstr(FunctionName.c_str(), "OnServerBounceCallback") && !strstr(FunctionName.c_str(), "BlueprintGetInteractionTime") && !strstr(FunctionName.c_str(), "OnServerStopCallback") && !strstr(FunctionName.c_str(), "Light Flash Timeline__UpdateFunc") && !strstr(FunctionName.c_str(), "MainFlightPath__UpdateFunc") && !strstr(FunctionName.c_str(), "PlayStartedIdleRotationAudio") && !strstr(FunctionName.c_str(), "BGA_Athena_FlopperSpawn_") && !strstr(FunctionName.c_str(), "CheckShouldDisplayUI") && !strstr(FunctionName.c_str(), "Timeline_0__UpdateFunc") && !strstr(FunctionName.c_str(), "ClientMoveResponsePacked") && !strstr(FunctionName.c_str(), "ExecuteUbergraph_B_Athena_FlopperSpawnWorld_Placement") && !strstr(FunctionName.c_str(), "Countdown__UpdateFunc") && !strstr(FunctionName.c_str(), "OnParachuteTrailUpdated") && !strstr(FunctionName.c_str(), "Moto FadeOut__UpdateFunc") && !strstr(FunctionName.c_str(), "ExecuteUbergraph_Apollo_GasPump_Valet") && !strstr(FunctionName.c_str(), "GetOverrideMeshMaterial") && !strstr(FunctionName.c_str(), "VendWobble__UpdateFunc") && !strstr(FunctionName.c_str(), "WaitForPawn") && !strstr(FunctionName.c_str(), "FragmentMovement__UpdateFunc") && !strstr(FunctionName.c_str(), "TrySetup") && !strstr(FunctionName.c_str(), "Fade Doused Smoke__UpdateFunc") && !strstr(FunctionName.c_str(), "SetPlayerToSkydive") && !strstr(FunctionName.c_str(), "BounceCar__UpdateFunc") && !strstr(FunctionName.c_str(), "BP_CalendarDynamicPOISelect") && !strstr(FunctionName.c_str(), "OnComponentHit_Event_0") && !strstr(FunctionName.c_str(), "HandleSimulatingComponentHit") && !strstr(FunctionName.c_str(), "CBGA_GreenGlop_WithGrav_C") && !strstr(FunctionName.c_str(), "WarmupCountdownEndTimeUpdated") && !strstr(FunctionName.c_str(), "BP_CanInteract") && !strstr(FunctionName.c_str(), "AthenaHitPointBar_C") && !strstr(FunctionName.c_str(), "ServerFireAIDirectorEvent") && !strstr(FunctionName.c_str(), "BlueprintThreadSafeUpdateAnimation") && !strstr(FunctionName.c_str(), "On Amb Zap Spawn") && !strstr(FunctionName.c_str(), "ServerSetPlayerCanDBNORevive") && !strstr(FunctionName.c_str(), "BGA_Petrol_Pickup_C") && !strstr(FunctionName.c_str(), "GetMutatorsForContextActor") && !strstr(FunctionName.c_str(), "GetControlRotation") && !strstr(FunctionName.c_str(), "K2_GetComponentLocation") && !strstr(FunctionName.c_str(), "MoveFromOffset__UpdateFunc") && !strstr(FunctionFullName.c_str(), "PinkOatmeal_GreenGlop_C") && !strstr(ObjectName.c_str(), "CBGA_GreenGlop_WithGrav_C") && !strstr(ObjectName.c_str(), "FlopperSpawn") && !strstr(FunctionFullName.c_str(), "GCNL_EnvCampFire_Fire_C") && !strstr(FunctionName.c_str(), "BlueprintGetAllHighlightableComponents") && !strstr(FunctionFullName.c_str(), "Primitive_Structure_AmbAudioComponent") && !strstr(FunctionName.c_str(), "ServerTriggerCombatEvent") && !strstr(FunctionName.c_str(), "SpinCubeTimeline__UpdateFunc") && !strstr(ObjectName.c_str(), "FortPhysicsObjectComponent") && !strstr(FunctionName.c_str(), "GetTextValue")) { LOG_INFO(LogDev, "Function called: {} with {}", FunctionFullName, ObjectName); } } return Object->ProcessEvent(Function, Parameters); }