mirror of
https://github.com/Milxnor/Project-Reboot-3.0.git
synced 2026-01-13 10:52:22 +01:00
add 2.2
code consistency, added 2.2, added cheat op and deop, proper loot tiers according to playlist, improved performance
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#include "SoftObjectPtr.h"
|
||||
#include "FortGameModeAthena.h"
|
||||
#include "GameplayStatics.h"
|
||||
#include "FortVehicleItemDefinition.h"
|
||||
#include "FortDagwoodVehicle.h"
|
||||
|
||||
// Vehicle class name changes multiple times across versions, so I made it it's own file.
|
||||
|
||||
@@ -84,6 +86,8 @@ static inline void ServerVehicleUpdate(UObject* Context, FFrame& Stack, void* Re
|
||||
Mesh->ProcessEvent(K2_SetWorldTransformFn, K2_SetWorldTransformParams);
|
||||
// Mesh->bComponentToWorldUpdated = true;
|
||||
|
||||
// VirtualFree(K2_SetWorldTransformParams, 0, MEM_RELEASE);
|
||||
|
||||
struct { FVector NewVel; bool bAddToCurrent; FName BoneName; }
|
||||
UPrimitiveComponent_SetPhysicsLinearVelocity_Params{
|
||||
*(FVector*)(__int64(State) + LinearVelocityOffset),
|
||||
@@ -104,24 +108,50 @@ static inline void ServerVehicleUpdate(UObject* Context, FFrame& Stack, void* Re
|
||||
|
||||
static inline void AddVehicleHook()
|
||||
{
|
||||
static auto FortAthenaVehicleDefault = FindObject("/Script/FortniteGame.Default__FortAthenaVehicle");
|
||||
static auto FortPhysicsPawnDefault = FindObject("/Script/FortniteGame.Default__FortPhysicsPawn");
|
||||
static auto FortAthenaVehicleDefault = FindObject(L"/Script/FortniteGame.Default__FortAthenaVehicle");
|
||||
static auto FortPhysicsPawnDefault = FindObject(L"/Script/FortniteGame.Default__FortPhysicsPawn");
|
||||
|
||||
if (FortPhysicsPawnDefault)
|
||||
{
|
||||
Hooking::MinHook::Hook(FortPhysicsPawnDefault, FindObject<UFunction>("/Script/FortniteGame.FortPhysicsPawn.ServerMove") ?
|
||||
FindObject<UFunction>("/Script/FortniteGame.FortPhysicsPawn.ServerMove") : FindObject<UFunction>("/Script/FortniteGame.FortPhysicsPawn.ServerUpdatePhysicsParams"),
|
||||
Hooking::MinHook::Hook(FortPhysicsPawnDefault, FindObject<UFunction>(L"/Script/FortniteGame.FortPhysicsPawn.ServerMove") ?
|
||||
FindObject<UFunction>(L"/Script/FortniteGame.FortPhysicsPawn.ServerMove") : FindObject<UFunction>(L"/Script/FortniteGame.FortPhysicsPawn.ServerUpdatePhysicsParams"),
|
||||
ServerVehicleUpdate, nullptr, false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Hooking::MinHook::Hook(FortAthenaVehicleDefault, FindObject<UFunction>("/Script/FortniteGame.FortAthenaVehicle.ServerUpdatePhysicsParams"),
|
||||
Hooking::MinHook::Hook(FortAthenaVehicleDefault, FindObject<UFunction>(L"/Script/FortniteGame.FortAthenaVehicle.ServerUpdatePhysicsParams"),
|
||||
ServerVehicleUpdate, nullptr, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
struct FVehicleWeightedDef
|
||||
{
|
||||
public:
|
||||
static UStruct* GetStruct()
|
||||
{
|
||||
static auto Struct = FindObject<UStruct>(L"/Script/FortniteGame.VehicleWeightedDef");
|
||||
return Struct;
|
||||
}
|
||||
|
||||
static int GetStructSize() { return GetStruct()->GetPropertiesSize(); }
|
||||
|
||||
TSoftObjectPtr<UFortVehicleItemDefinition>* GetVehicleItemDef()
|
||||
{
|
||||
static auto VehicleItemDefOffset = FindOffsetStruct("/Script/FortniteGame.VehicleWeightedDef", "VehicleItemDef");
|
||||
return (TSoftObjectPtr<UFortVehicleItemDefinition>*)(__int64(this) + VehicleItemDefOffset);
|
||||
}
|
||||
|
||||
FScalableFloat* GetWeight()
|
||||
{
|
||||
static auto WeightOffset = FindOffsetStruct("/Script/FortniteGame.VehicleWeightedDef", "Weight");
|
||||
return (FScalableFloat*)(__int64(this) + WeightOffset);
|
||||
}
|
||||
};
|
||||
|
||||
static inline AActor* SpawnVehicleFromSpawner(AActor* VehicleSpawner)
|
||||
{
|
||||
bool bDebugSpawnVehicles = false;
|
||||
|
||||
auto GameMode = Cast<AFortGameModeAthena>(GetWorld()->GetGameMode());
|
||||
|
||||
FTransform SpawnTransform{};
|
||||
@@ -130,7 +160,7 @@ static inline AActor* SpawnVehicleFromSpawner(AActor* VehicleSpawner)
|
||||
SpawnTransform.Scale3D = { 1, 1, 1 };
|
||||
|
||||
static auto VehicleClassOffset = VehicleSpawner->GetOffset("VehicleClass", false);
|
||||
static auto BGAClass = FindObject<UClass>("/Script/Engine.BlueprintGeneratedClass");
|
||||
static auto BGAClass = FindObject<UClass>(L"/Script/Engine.BlueprintGeneratedClass");
|
||||
|
||||
if (VehicleClassOffset != -1) // 10.40 and below?
|
||||
{
|
||||
@@ -144,6 +174,9 @@ static inline AActor* SpawnVehicleFromSpawner(AActor* VehicleSpawner)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (bDebugSpawnVehicles)
|
||||
LOG_INFO(LogDev, "Spawning Vehicle: {}", StrongVehicleClass->GetPathName());
|
||||
|
||||
return GetWorld()->SpawnActor<AActor>(StrongVehicleClass, SpawnTransform, CreateSpawnParameters(ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn));
|
||||
}
|
||||
|
||||
@@ -152,28 +185,55 @@ static inline AActor* SpawnVehicleFromSpawner(AActor* VehicleSpawner)
|
||||
if (FortVehicleItemDefOffset == -1)
|
||||
return nullptr;
|
||||
|
||||
auto& SoftFortVehicleItemDef = VehicleSpawner->Get<TSoftObjectPtr<UFortItemDefinition>>(FortVehicleItemDefOffset);
|
||||
auto StrongFortVehicleItemDef = SoftFortVehicleItemDef.Get(nullptr, true);
|
||||
auto& SoftFortVehicleItemDef = VehicleSpawner->Get<TSoftObjectPtr<UFortVehicleItemDefinition>>(FortVehicleItemDefOffset);
|
||||
UFortVehicleItemDefinition* VIDToSpawn = nullptr;
|
||||
|
||||
if (!StrongFortVehicleItemDef)
|
||||
if (SoftFortVehicleItemDef.SoftObjectPtr.ObjectID.AssetPathName.ComparisonIndex.Value == 0)
|
||||
{
|
||||
static auto FortVehicleItemDefVariantsOffset = VehicleSpawner->GetOffset("FortVehicleItemDefVariants");
|
||||
|
||||
if (FortVehicleItemDefVariantsOffset != -1)
|
||||
{
|
||||
TArray<FVehicleWeightedDef>& FortVehicleItemDefVariants = VehicleSpawner->Get<TArray<FVehicleWeightedDef>>(FortVehicleItemDefVariantsOffset);
|
||||
|
||||
if (FortVehicleItemDefVariants.size() > 0)
|
||||
{
|
||||
VIDToSpawn = FortVehicleItemDefVariants.at(0, FVehicleWeightedDef::GetStructSize()).GetVehicleItemDef()->Get(UFortVehicleItemDefinition::StaticClass(), true); // TODO (Milxnor) Implement the weight
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
VIDToSpawn = SoftFortVehicleItemDef.Get(UFortVehicleItemDefinition::StaticClass(), true);
|
||||
}
|
||||
|
||||
if (!VIDToSpawn)
|
||||
{
|
||||
std::string FortVehicleItemDefObjectName = SoftFortVehicleItemDef.SoftObjectPtr.ObjectID.AssetPathName.ComparisonIndex.Value == 0 ? "InvalidName" : SoftFortVehicleItemDef.SoftObjectPtr.ObjectID.AssetPathName.ToString();
|
||||
LOG_WARN(LogVehicles, "Failed to load vehicle item definition: {}", FortVehicleItemDefObjectName);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static auto VehicleActorClassOffset = StrongFortVehicleItemDef->GetOffset("VehicleActorClass");
|
||||
auto& SoftVehicleActorClass = StrongFortVehicleItemDef->Get<TSoftObjectPtr<UClass>>(VehicleActorClassOffset);
|
||||
auto StrongVehicleActorClass = SoftVehicleActorClass.Get(BGAClass, true);
|
||||
UClass* StrongVehicleActorClass = VIDToSpawn->GetVehicleActorClass();
|
||||
|
||||
if (!StrongVehicleActorClass)
|
||||
{
|
||||
std::string VehicleActorClassObjectName = SoftVehicleActorClass.SoftObjectPtr.ObjectID.AssetPathName.ComparisonIndex.Value == 0 ? "InvalidName" : SoftVehicleActorClass.SoftObjectPtr.ObjectID.AssetPathName.ToString();
|
||||
std::string VehicleActorClassObjectName = VIDToSpawn->GetVehicleActorClassSoft()->SoftObjectPtr.ObjectID.AssetPathName.ComparisonIndex.Value == 0 ? "InvalidName" : VIDToSpawn->GetVehicleActorClassSoft()->SoftObjectPtr.ObjectID.AssetPathName.ToString();
|
||||
LOG_WARN(LogVehicles, "Failed to load vehicle actor class: {}", VehicleActorClassObjectName);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return GetWorld()->SpawnActor<AActor>(StrongVehicleActorClass, SpawnTransform, CreateSpawnParameters(ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn));
|
||||
if (bDebugSpawnVehicles)
|
||||
LOG_INFO(LogDev, "Spawning Vehicle (VID): {}", StrongVehicleActorClass->GetPathName());
|
||||
|
||||
auto NewVehicle = GetWorld()->SpawnActor<AActor>(StrongVehicleActorClass, SpawnTransform, CreateSpawnParameters(ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn));
|
||||
|
||||
if (auto FortDagwoodVehicle = Cast<AFortDagwoodVehicle>(NewVehicle)) // carrr
|
||||
{
|
||||
FortDagwoodVehicle->SetFuel(100);
|
||||
}
|
||||
|
||||
return NewVehicle;
|
||||
}
|
||||
|
||||
static inline void SpawnVehicles2()
|
||||
|
||||
Reference in New Issue
Block a user