spectaterrrr

This commit is contained in:
Gray
2024-03-19 14:43:57 -04:00
parent 5bfe3a6179
commit 0a9191b854
7 changed files with 53 additions and 48 deletions

View File

@@ -9,7 +9,7 @@ struct FGameplayEffectApplicationInfoHard
public:
static UStruct* GetStruct()
{
static auto GameplayEffectApplicationInfoHardStruct = FindObject<UStruct>("/Script/FortniteGame.GameplayEffectApplicationInfoHard");
static auto GameplayEffectApplicationInfoHardStruct = FindObject<UStruct>(L"/Script/FortniteGame.GameplayEffectApplicationInfoHard");
return GameplayEffectApplicationInfoHardStruct;
}
@@ -55,7 +55,7 @@ public:
auto GrantedGameplayEffects = GetGrantedGameplayEffects();
for (int i = 0; i < GrantedGameplayEffects->Num(); i++)
for (int i = 0; i < GrantedGameplayEffects->Num(); ++i)
{
auto& EffectToGrant = GrantedGameplayEffects->at(i, FGameplayEffectApplicationInfoHard::GetStructSize());
@@ -76,7 +76,7 @@ public:
{
auto GameplayAbilities = GetGameplayAbilities();
for (int i = 0; i < GameplayAbilities->Num(); i++)
for (int i = 0; i < GameplayAbilities->Num(); ++i)
{
UClass* AbilityClass = GameplayAbilities->At(i);
@@ -93,7 +93,7 @@ public:
static UClass* StaticClass()
{
static auto Class = FindObject<UClass>("/Script/FortniteGame.FortAbilitySet");
static auto Class = FindObject<UClass>(L"/Script/FortniteGame.FortAbilitySet");
return Class;
}
};

View File

@@ -1122,13 +1122,15 @@ void AFortPlayerController::ServerPlayEmoteItemHook(AFortPlayerController* Playe
return;
UObject* AbilityToUse = nullptr;
bool bShouldBeAbilityToUse = false;
static auto AthenaSprayItemDefinitionClass = FindObject<UClass>(L"/Script/FortniteGame.AthenaSprayItemDefinition");
static auto AthenaToyItemDefinitionClass = FindObject<UClass>(L"/Script/FortniteGame.AthenaToyItemDefinition");
static auto BGAClass = FindObject<UClass>(L"/Script/Engine.BlueprintGeneratedClass");
if (EmoteAsset->IsA(AthenaSprayItemDefinitionClass))
{
static auto SprayGameplayAbilityDefault = FindObject(L"/Game/Abilities/Sprays/GAB_Spray_Generic.Default__GAB_Spray_Generic_C");
auto SprayGameplayAbilityDefault = FindObject(L"/Game/Abilities/Sprays/GAB_Spray_Generic.Default__GAB_Spray_Generic_C");
AbilityToUse = SprayGameplayAbilityDefault;
}
@@ -1137,8 +1139,6 @@ void AFortPlayerController::ServerPlayEmoteItemHook(AFortPlayerController* Playe
static auto ToySpawnAbilityOffset = EmoteAsset->GetOffset("ToySpawnAbility");
auto& ToySpawnAbilitySoft = EmoteAsset->Get<TSoftObjectPtr<UClass>>(ToySpawnAbilityOffset);
static auto BGAClass = FindObject<UClass>(L"/Script/Engine.BlueprintGeneratedClass");
auto ToySpawnAbility = ToySpawnAbilitySoft.Get(BGAClass, true);
if (ToySpawnAbility)
@@ -1204,6 +1204,11 @@ void AFortPlayerController::ServerPlayEmoteItemHook(AFortPlayerController* Playe
}
}
void AFortPlayerController::ServerPlaySprayItemHook(AFortPlayerController* PlayerController, UAthenaSprayItemDefinition* SprayAsset)
{
PlayerController->ServerPlayEmoteItemHook(PlayerController, SprayAsset);
}
uint8 ToDeathCause(const FGameplayTagContainer& TagContainer, bool bWasDBNO = false, AFortPawn* Pawn = nullptr)
{
static auto ToDeathCauseFn = FindObject<UFunction>(L"/Script/FortniteGame.FortPlayerStateAthena.ToDeathCause");
@@ -1259,27 +1264,6 @@ uint8 ToDeathCause(const FGameplayTagContainer& TagContainer, bool bWasDBNO = fa
return sub_7FF7AB499410(TagContainer, bWasDBNO);
}
DWORD WINAPI SpectateThread(LPVOID PC)
{
auto PlayerController = (UObject*)PC;
if (!PlayerController->IsValidLowLevel())
return 0;
auto SpectatingPC = Cast<AFortPlayerControllerAthena>(PlayerController);
if (!SpectatingPC)
return 0;
Sleep(3000);
LOG_INFO(LogDev, "Spectate!");
SpectatingPC->SpectateOnDeath();
return 0;
}
DWORD WINAPI RestartThread(LPVOID)
{
// We should probably use unreal engine's timing system for this.
@@ -1602,26 +1586,25 @@ void AFortPlayerController::ClientOnPawnDiedHook(AFortPlayerController* PlayerCo
// LOG_INFO(LogDev, "KillerPlayerState->Place: {}", KillerPlayerState ? KillerPlayerState->GetPlace() : -1);
}
}
if (Fortnite_Version < 6) // Spectating (is this the actual build or is it like 6.10 when they added it auto).
if (Fortnite_Version < 6) // Spectating (is this the actual build or is it like 6.10 when they added it auto).
{
if (GameState->GetGamePhase() > EAthenaGamePhase::Warmup)
{
if (GameState->GetGamePhase() > EAthenaGamePhase::Warmup)
static auto bAllowSpectateAfterDeathOffset = GameMode->GetOffset("bAllowSpectateAfterDeath");
bool bAllowSpectate = GameMode->Get<bool>(bAllowSpectateAfterDeathOffset);
LOG_INFO(LogDev, "bAllowSpectate: {}", bAllowSpectate);
if (bAllowSpectate)
{
static auto bAllowSpectateAfterDeathOffset = GameMode->GetOffset("bAllowSpectateAfterDeath");
LOG_INFO(LogDev, "Starting Spectating!");
bool bAllowSpectate = GameMode->Get<bool>(bAllowSpectateAfterDeathOffset);
static auto PlayerToSpectateOnDeathOffset = PlayerController->GetOffset("PlayerToSpectateOnDeath");
PlayerController->Get<APawn*>(PlayerToSpectateOnDeathOffset) = KillerPawn;
LOG_INFO(LogDev, "bAllowSpectate: {}", bAllowSpectate);
if (bAllowSpectate)
{
LOG_INFO(LogDev, "Starting Spectating!");
static auto PlayerToSpectateOnDeathOffset = PlayerController->GetOffset("PlayerToSpectateOnDeath");
PlayerController->Get<APawn*>(PlayerToSpectateOnDeathOffset) = KillerPawn;
CreateThread(0, 0, SpectateThread, (LPVOID)PlayerController, 0, 0);
}
UKismetSystemLibrary::K2_SetTimer(PlayerController, L"SpectateOnDeath", 5.f, false); // Soo proper its scary
}
}
}

View File

@@ -89,6 +89,8 @@ enum class EInteractionBeingAttempted : uint8
EInteractionBeingAttempted_MAX = 3,
};
using UAthenaSprayItemDefinition = UObject;
class AFortPlayerController : public APlayerController
{
public:
@@ -210,6 +212,7 @@ public:
static void ServerDropAllItemsHook(AFortPlayerController* PlayerController, UFortItemDefinition* IgnoreItemDef);
static void ServerAttemptInventoryDropHook(AFortPlayerController* PlayerController, FGuid ItemGuid, int Count);
static void ServerPlaySprayItemHook(AFortPlayerController* PlayerController, UAthenaSprayItemDefinition* SprayAsset);
static void ServerPlayEmoteItemHook(AFortPlayerController* PlayerController, UObject* EmoteAsset);
static void ClientOnPawnDiedHook(AFortPlayerController* PlayerController, void* DeathReport);

View File

@@ -106,6 +106,24 @@ public:
KismetSystemLibrary->ProcessEvent(fn, &UKismetSystemLibrary_ExecuteConsoleCommand_Params);
}
static FTimerHandle K2_SetTimer(UObject* Object, FString FunctionName, float Time, bool bLooping)
{
struct {
UObject* Object;
FString FunctionName;
float Time;
bool bLooping;
FTimerHandle ret;
} K2_SetTimer_Params{Object, FunctionName, Time, bLooping};
static auto KismetSystemLibrary = FindObject("/Script/Engine.Default__KismetSystemLibrary");
static auto K2_SetTimerFn = FindObject<UFunction>("/Script/Engine.KismetSystemLibrary.K2_SetTimer");
KismetSystemLibrary->ProcessEvent(K2_SetTimerFn, &K2_SetTimer_Params);
return K2_SetTimer_Params.ret;
}
static bool LineTraceSingle(UObject* WorldContextObject, FVector Start, FVector End, ETraceTypeQuery TraceChannel, bool bTraceComplex,
TArray<AActor*> ActorsToIgnore, EDrawDebugTrace DrawDebugType, bool bIgnoreSelf, FLinearColor TraceColor, FLinearColor TraceHitColor,
float DrawTime, FHitResult** OutHit)

View File

@@ -79,8 +79,6 @@ void UWorld::Listen()
FString Error;
LOG_INFO(LogNet, "Calling InitListen!");
AWorldSettings* WorldSettings = GetWorldSettings();
const bool bReuseAddressAndPort = false; // WorldSettings ? WorldSettings->bReuseAddressAndPort : false;
@@ -90,8 +88,6 @@ void UWorld::Listen()
return;
}
LOG_INFO(LogNet, "Called InitListen!");
const bool bLanSpeed = false;
if (!bLanSpeed && (NewNetDriver->GetMaxInternetClientRate() < NewNetDriver->GetMaxClientRate()) && (NewNetDriver->GetMaxInternetClientRate() > 2500))

View File

@@ -1265,6 +1265,8 @@ DWORD WINAPI Main(LPVOID)
AFortPlayerController::ServerExecuteInventoryItemHook, nullptr, false);
Hooking::MinHook::Hook(FortPlayerControllerAthenaDefault, FindObject<UFunction>(L"/Script/FortniteGame.FortPlayerController.ServerPlayEmoteItem"),
AFortPlayerController::ServerPlayEmoteItemHook, nullptr, false);
Hooking::MinHook::Hook(FortPlayerControllerAthenaDefault, FindObject<UFunction>(L"/Script/FortniteGame.FortPlayerController.ServerPlaySprayItem"),
AFortPlayerController::ServerPlaySprayItemHook, nullptr, false); // S4 explain yourself
Hooking::MinHook::Hook(FortPlayerControllerAthenaDefault, FindObject<UFunction>(L"/Script/FortniteGame.FortPlayerController.ServerRepairBuildingActor"),
AFortPlayerController::ServerRepairBuildingActorHook, nullptr, false);
Hooking::MinHook::Hook(FortPlayerControllerAthenaDefault, FindObject<UFunction>(L"/Script/FortniteGame.FortPlayerController.ServerCreateBuildingActor"),

View File

@@ -95,8 +95,11 @@ uint64 FindGIsClient()
if (bIsScuffedByte)
{
if (Bytes[2] == 0x74) // DIE 4.5 (todo check length of entire instruction)
if (*(Memcury::ASM::MNEMONIC*)(Addr.Get() - i + 2) == 0x74) // DIE 4.5 (todo check length of entire instruction)
{
LOG_INFO(LogDev, "Found broken byte, skipping!");
continue;
}
}
if (!PickedByte)