Add random defaults 1.7.2, some other internal stuff

This commit is contained in:
Milxnor
2023-04-26 23:22:22 -04:00
parent be0873d5d7
commit 4c19144b0f
10 changed files with 139 additions and 89 deletions

View File

@@ -929,20 +929,19 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena
if (!PlayerStateAthena) if (!PlayerStateAthena)
return Athena_HandleStartingNewPlayerOriginal(GameMode, NewPlayerActor); return Athena_HandleStartingNewPlayerOriginal(GameMode, NewPlayerActor);
if (Globals::bNoMCP || Engine_Version == 416) static auto CharacterPartsOffset = PlayerStateAthena->GetOffset("CharacterParts", false);
{ static auto CustomCharacterPartsStruct = FindObject<UStruct>("/Script/FortniteGame.CustomCharacterParts");
static auto CharacterPartsOffset = PlayerStateAthena->GetOffset("CharacterParts", false); auto CharacterParts = PlayerStateAthena->GetPtr<__int64>("CharacterParts");
static auto CustomCharacterPartsStruct = FindObject<UStruct>("/Script/FortniteGame.CustomCharacterParts");
static auto PartsOffset = FindOffsetStruct("/Script/FortniteGame.CustomCharacterParts", "Parts", false);
auto Parts = (UObject**)(__int64(CharacterParts) + PartsOffset); // UCustomCharacterPart* Parts[0x6]
static auto CustomCharacterPartClass = FindObject<UClass>("/Script/FortniteGame.CustomCharacterPart");
if (Globals::bNoMCP)
{
if (CharacterPartsOffset != -1) // && CustomCharacterPartsStruct) if (CharacterPartsOffset != -1) // && CustomCharacterPartsStruct)
{ {
auto CharacterParts = PlayerStateAthena->GetPtr<__int64>("CharacterParts");
static auto PartsOffset = FindOffsetStruct("/Script/FortniteGame.CustomCharacterParts", "Parts", false);
auto Parts = (UObject**)(__int64(CharacterParts) + PartsOffset); // UCustomCharacterPart* Parts[0x6]
static auto CustomCharacterPartClass = FindObject<UClass>("/Script/FortniteGame.CustomCharacterPart");
static auto headPart = LoadObject("/Game/Characters/CharacterParts/Female/Medium/Heads/F_Med_Head1.F_Med_Head1", CustomCharacterPartClass); static auto headPart = LoadObject("/Game/Characters/CharacterParts/Female/Medium/Heads/F_Med_Head1.F_Med_Head1", CustomCharacterPartClass);
static auto bodyPart = LoadObject("/Game/Characters/CharacterParts/Female/Medium/Bodies/F_Med_Soldier_01.F_Med_Soldier_01", CustomCharacterPartClass); static auto bodyPart = LoadObject("/Game/Characters/CharacterParts/Female/Medium/Bodies/F_Med_Soldier_01.F_Med_Soldier_01", CustomCharacterPartClass);
static auto backpackPart = LoadObject("/Game/Characters/CharacterParts/Backpacks/NoBackpack.NoBackpack", CustomCharacterPartClass); static auto backpackPart = LoadObject("/Game/Characters/CharacterParts/Backpacks/NoBackpack.NoBackpack", CustomCharacterPartClass);

View File

@@ -1,13 +1,13 @@
#pragma once #pragma once
#include "FortGameModePvPBase.h" #include "FortGameModePvPBase.h"
// #include "FortPlayerControllerAthena.h"
#include "FortGameStateAthena.h" #include "FortGameStateAthena.h"
#include "KismetStringLibrary.h" #include "KismetStringLibrary.h"
#include "reboot.h" #include "reboot.h"
#include "BuildingSMActor.h" #include "BuildingSMActor.h"
#include "FortSafeZoneIndicator.h" #include "FortSafeZoneIndicator.h"
#include "GameplayStatics.h" #include "GameplayStatics.h"
#include "FortItemDefinition.h"
struct FAircraftFlightInfo struct FAircraftFlightInfo
{ {
@@ -158,6 +158,11 @@ static void ShowFoundation(AActor* BuildingFoundation, bool bShow = true)
{ {
UGameplayStatics::UnloadStreamLevel(GetWorld(), LevelToStream, FLatentActionInfo(), false); UGameplayStatics::UnloadStreamLevel(GetWorld(), LevelToStream, FLatentActionInfo(), false);
} */ } */
// real
BuildingFoundation->FlushNetDormancy();
BuildingFoundation->ForceNetUpdate();
} }
static void StreamLevel(const std::string& LevelName, FVector Location = {}) static void StreamLevel(const std::string& LevelName, FVector Location = {})
@@ -210,6 +215,12 @@ public:
return (AFortGameStateAthena*)GetGameState(); return (AFortGameStateAthena*)GetGameState();
} }
TArray<FItemAndCount>& GetStartingItems() // really in zone
{
static auto StartingItemsOffset = GetOffset("StartingItems");
return Get<TArray<FItemAndCount>>(StartingItemsOffset);
}
FName RedirectLootTier(const FName& LootTier); FName RedirectLootTier(const FName& LootTier);
UClass* GetVehicleClassOverride(UClass* DefaultClass); UClass* GetVehicleClassOverride(UClass* DefaultClass);

View File

@@ -44,24 +44,6 @@ enum class EFortInventoryType : unsigned char
MAX = 3, MAX = 3,
}; };
struct FItemAndCount
{
private:
int Count; // 0x0000(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic)
unsigned char UnknownData00[0x4]; // 0x0004(0x0004) MISSED OFFSET
UFortItemDefinition* Item; // 0x0008(0x0008) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic)
public:
int& GetCount()
{
return Count;
}
UFortItemDefinition*& GetItem()
{
return Item;
}
};
struct FItemGuidAndCount struct FItemGuidAndCount
{ {
public: public:

View File

@@ -25,3 +25,21 @@ public:
return Class; return Class;
} }
}; };
struct FItemAndCount
{
private:
int Count; // 0x0000(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic)
unsigned char UnknownData00[0x4]; // 0x0004(0x0004) MISSED OFFSET
UFortItemDefinition* Item; // 0x0008(0x0008) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic)
public:
int& GetCount()
{
return Count;
}
UFortItemDefinition*& GetItem()
{
return Item;
}
};

View File

@@ -123,7 +123,7 @@ void AFortPlayerController::ApplyCosmeticLoadout()
return; return;
} }
auto CosmeticLoadout = this->GetCosmeticLoadout(); auto CosmeticLoadout = GetCosmeticLoadoutOffset() != -1 ? this->GetCosmeticLoadout() : nullptr;
if (CosmeticLoadout) if (CosmeticLoadout)
{ {
@@ -168,6 +168,11 @@ void AFortPlayerController::ApplyCosmeticLoadout()
} }
} }
} }
else
{
static auto HeroTypeOffset = PlayerStateAsFort->GetOffset("HeroType");
ApplyHID(PawnAsFort, PlayerStateAsFort->Get(HeroTypeOffset));
}
PlayerStateAsFort->ForceNetUpdate(); PlayerStateAsFort->ForceNetUpdate();
PawnAsFort->ForceNetUpdate(); PawnAsFort->ForceNetUpdate();

View File

@@ -66,16 +66,22 @@ public:
return Get<AFortPawn*>(MyFortPawnOffset); return Get<AFortPawn*>(MyFortPawnOffset);
} }
FFortAthenaLoadout* GetCosmeticLoadout() int GetCosmeticLoadoutOffset()
{ {
static auto CosmeticLoadoutPCOffset = this->GetOffset("CosmeticLoadoutPC", false); static auto CosmeticLoadoutPCOffset = this->GetOffset("CosmeticLoadoutPC", false);
if (CosmeticLoadoutPCOffset == -1) if (CosmeticLoadoutPCOffset == -1)
CosmeticLoadoutPCOffset = this->GetOffset("CustomizationLoadout"); CosmeticLoadoutPCOffset = this->GetOffset("CustomizationLoadout", false);
if (CosmeticLoadoutPCOffset == -1) if (CosmeticLoadoutPCOffset == -1)
return nullptr; return -1;
return CosmeticLoadoutPCOffset;
}
FFortAthenaLoadout* GetCosmeticLoadout()
{
static auto CosmeticLoadoutPCOffset = GetCosmeticLoadoutOffset();
auto CosmeticLoadout = this->GetPtr<FFortAthenaLoadout>(CosmeticLoadoutPCOffset); auto CosmeticLoadout = this->GetPtr<FFortAthenaLoadout>(CosmeticLoadoutPCOffset);
return CosmeticLoadout; return CosmeticLoadout;

View File

@@ -8,6 +8,59 @@
#include "AthenaMarkerComponent.h" #include "AthenaMarkerComponent.h"
#include "FortVolume.h" #include "FortVolume.h"
static void ApplyHID(AFortPlayerPawn* Pawn, UObject* HeroDefinition)
{
using UFortHeroSpecialization = UObject;
static auto SpecializationsOffset = HeroDefinition->GetOffset("Specializations");
auto& Specializations = HeroDefinition->Get<TArray<TSoftObjectPtr<UFortHeroSpecialization>>>(SpecializationsOffset);
auto PlayerState = Pawn->GetPlayerState();
for (int i = 0; i < Specializations.Num(); i++)
{
auto& SpecializationSoft = Specializations.at(i);
static auto FortHeroSpecializationClass = FindObject<UClass>("/Script/FortniteGame.FortHeroSpecialization");
auto Specialization = SpecializationSoft.Get(FortHeroSpecializationClass, true);
if (Specialization)
{
static auto Specialization_CharacterPartsOffset = Specialization->GetOffset("CharacterParts");
auto& CharacterParts = Specialization->Get<TArray<TSoftObjectPtr<UObject>>>(Specialization_CharacterPartsOffset);
static auto CustomCharacterPartClass = FindObject<UClass>("/Script/FortniteGame.CustomCharacterPart");
/* if (bUseServerChoosePart)
{
for (int z = 0; z < CharacterParts.Num(); z++)
{
Pawn->ServerChoosePart((EFortCustomPartType)z, CharacterParts.at(z).Get(CustomCharacterPartClass, true));
}
continue; // hm?
} */
bool aa;
TArray<UObject*> CharacterPartsaa;
for (int z = 0; z < CharacterParts.Num(); z++)
{
auto& CharacterPartSoft = CharacterParts.at(z, GetSoftObjectSize());
auto CharacterPart = CharacterPartSoft.Get(CustomCharacterPartClass, true);
CharacterPartsaa.Add(CharacterPart);
continue;
}
UFortKismetLibrary::ApplyCharacterCosmetics(GetWorld(), CharacterPartsaa, PlayerState, &aa);
CharacterPartsaa.Free();
}
}
}
static bool ApplyCID(AFortPlayerPawn* Pawn, UObject* CID, bool bUseServerChoosePart = false) static bool ApplyCID(AFortPlayerPawn* Pawn, UObject* CID, bool bUseServerChoosePart = false)
{ {
if (!CID) if (!CID)
@@ -46,57 +99,9 @@ static bool ApplyCID(AFortPlayerPawn* Pawn, UObject* CID, bool bUseServerChooseP
static auto HeroDefinitionOffset = CID->GetOffset("HeroDefinition"); static auto HeroDefinitionOffset = CID->GetOffset("HeroDefinition");
auto HeroDefinition = CID->Get(HeroDefinitionOffset); auto HeroDefinition = CID->Get(HeroDefinitionOffset);
using UFortHeroSpecialization = UObject; ApplyHID(Pawn, HeroDefinition);
static auto SpecializationsOffset = HeroDefinition->GetOffset("Specializations"); // static auto HeroTypeOffset = PlayerState->GetOffset("HeroType");
auto& Specializations = HeroDefinition->Get<TArray<TSoftObjectPtr<UFortHeroSpecialization>>>(SpecializationsOffset);
auto PlayerState = Pawn->GetPlayerState();
for (int i = 0; i < Specializations.Num(); i++)
{
auto& SpecializationSoft = Specializations.at(i);
static auto FortHeroSpecializationClass = FindObject<UClass>("/Script/FortniteGame.FortHeroSpecialization");
auto Specialization = SpecializationSoft.Get(FortHeroSpecializationClass, true);
if (Specialization)
{
static auto Specialization_CharacterPartsOffset = Specialization->GetOffset("CharacterParts");
auto& CharacterParts = Specialization->Get<TArray<TSoftObjectPtr<UObject>>>(Specialization_CharacterPartsOffset);
static auto CustomCharacterPartClass = FindObject<UClass>("/Script/FortniteGame.CustomCharacterPart");
/* if (bUseServerChoosePart)
{
for (int z = 0; z < CharacterParts.Num(); z++)
{
Pawn->ServerChoosePart((EFortCustomPartType)z, CharacterParts.at(z).Get(CustomCharacterPartClass, true));
}
continue; // hm?
} */
bool aa;
TArray<UObject*> CharacterPartsaa;
for (int z = 0; z < CharacterParts.Num(); z++)
{
auto& CharacterPartSoft = CharacterParts.at(z);
auto CharacterPart = CharacterPartSoft.Get(CustomCharacterPartClass, true);
CharacterPartsaa.Add(CharacterPart);
continue;
}
UFortKismetLibrary::ApplyCharacterCosmetics(GetWorld(), CharacterPartsaa, PlayerState, &aa);
CharacterPartsaa.Free();
}
}
static auto HeroTypeOffset = PlayerState->GetOffset("HeroType");
// PlayerState->Get(HeroTypeOffset) = HeroDefinition; // PlayerState->Get(HeroTypeOffset) = HeroDefinition;
return true; return true;

View File

@@ -90,12 +90,12 @@ APawn* AGameModeBase::SpawnDefaultPawnForHook(AGameModeBase* GameMode, AControll
{ {
// TODO Check Playlist->bRequirePickaxeInStartingInventory // TODO Check Playlist->bRequirePickaxeInStartingInventory
auto CosmeticLoadout = NewPlayerAsAthena->GetCosmeticLoadout(); auto CosmeticLoadout = NewPlayerAsAthena->GetCosmeticLoadoutOffset() != -1 ? NewPlayerAsAthena->GetCosmeticLoadout() : nullptr;
// LOG_INFO(LogDev, "CosmeticLoadout: {}", __int64(CosmeticLoadout)); // LOG_INFO(LogDev, "CosmeticLoadout: {}", __int64(CosmeticLoadout));
auto CosmeticLoadoutPickaxe = CosmeticLoadout ? CosmeticLoadout->GetPickaxe() : nullptr; auto CosmeticLoadoutPickaxe = CosmeticLoadout ? CosmeticLoadout->GetPickaxe() : nullptr;
// LOG_INFO(LogDev, "CosmeticLoadoutPickaxe: {}", __int64(CosmeticLoadoutPickaxe)); // LOG_INFO(LogDev, "CosmeticLoadoutPickaxe: {}", __int64(CosmeticLoadoutPickaxe));
// LOG_INFO(LogDev, "CosmeticLoadoutPickaxe Name: {}", CosmeticLoadoutPickaxe ? CosmeticLoadoutPickaxe->GetFullName() : "InvalidObject"); // LOG_INFO(LogDev, "CosmeticLoadoutPickaxe Name: {}", CosmeticLoadoutPickaxe ? CosmeticLoadoutPickaxe->GetFullName() : "InvalidObject");
static auto WeaponDefinitionOffset = FindOffsetStruct("/Script/FortniteGame.AthenaPickaxeItemDefinition", "WeaponDefinition"); static auto WeaponDefinitionOffset = FindOffsetStruct("/Script/FortniteGame.AthenaPickaxeItemDefinition", "WeaponDefinition", false);
auto PickaxeDefinition = CosmeticLoadoutPickaxe ? CosmeticLoadoutPickaxe->Get<UFortItemDefinition*>(WeaponDefinitionOffset) auto PickaxeDefinition = CosmeticLoadoutPickaxe ? CosmeticLoadoutPickaxe->Get<UFortItemDefinition*>(WeaponDefinitionOffset)
: FindObject<UFortItemDefinition>(L"/Game/Athena/Items/Weapons/WID_Harvest_Pickaxe_Athena_C_T01.WID_Harvest_Pickaxe_Athena_C_T01"); : FindObject<UFortItemDefinition>(L"/Game/Athena/Items/Weapons/WID_Harvest_Pickaxe_Athena_C_T01.WID_Harvest_Pickaxe_Athena_C_T01");

View File

@@ -53,3 +53,8 @@ public:
} }
} }
}; };
static inline int GetSoftObjectSize()
{
return Engine_Version == 416 ? sizeof(TAssetPtr<void>) : sizeof(TSoftObjectPtr<void>);
}

View File

@@ -100,7 +100,26 @@ void __fastcall ApplyHomebaseEffectsOnPlayerSetupHook(
{ {
LOG_INFO(LogDev, "Old hero: {}", Hero ? Hero->GetFullName() : "InvalidObject"); LOG_INFO(LogDev, "Old hero: {}", Hero ? Hero->GetFullName() : "InvalidObject");
auto HeroType = FindObject<UFortItemDefinition>("/Game/Athena/Heroes/HID_030_Athena_Commando_M_Halloween.HID_030_Athena_Commando_M_Halloween"); UFortItemDefinition* HeroType = FindObject<UFortItemDefinition>("/Game/Athena/Heroes/HID_030_Athena_Commando_M_Halloween.HID_030_Athena_Commando_M_Halloween");
if (Fortnite_Version == 1.72)
{
auto AllHeroTypes = GetAllObjectsOfClass(FindObject<UClass>("/Script/FortniteGame.FortHeroType"));
std::vector<UFortItemDefinition*> AthenaHeroTypes;
for (int i = 0; i < AllHeroTypes.size(); i++)
{
auto CurrentHeroType = (UFortItemDefinition*)AllHeroTypes.at(i);
if (CurrentHeroType->GetPathName().starts_with("/Game/Athena/Heroes/"))
AthenaHeroTypes.push_back(CurrentHeroType);
}
if (AthenaHeroTypes.size())
{
HeroType = AthenaHeroTypes.at(std::rand() % AthenaHeroTypes.size());
}
}
static auto ItemDefinitionOffset = Hero->GetOffset("ItemDefinition"); static auto ItemDefinitionOffset = Hero->GetOffset("ItemDefinition");
Hero->Get<UFortItemDefinition*>(ItemDefinitionOffset) = HeroType; Hero->Get<UFortItemDefinition*>(ItemDefinitionOffset) = HeroType;
@@ -359,7 +378,7 @@ DWORD WINAPI Main(LPVOID)
if (Engine_Version < 420) if (Engine_Version < 420)
{ {
auto ApplyHomebaseEffectsOnPlayerSetupAddr = Memcury::Scanner::FindPattern("40 55 53 57 41 54 41 56 41 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 45 00 4C 8B BD ? ? ? ? 49").Get(); auto ApplyHomebaseEffectsOnPlayerSetupAddr = Memcury::Scanner::FindPattern("40 55 53 57 41 54 41 56 41 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 45 00 4C 8B").Get();
Hooking::MinHook::Hook((PVOID)ApplyHomebaseEffectsOnPlayerSetupAddr, ApplyHomebaseEffectsOnPlayerSetupHook, (PVOID*)&ApplyHomebaseEffectsOnPlayerSetupOriginal); Hooking::MinHook::Hook((PVOID)ApplyHomebaseEffectsOnPlayerSetupAddr, ApplyHomebaseEffectsOnPlayerSetupHook, (PVOID*)&ApplyHomebaseEffectsOnPlayerSetupOriginal);
} }