custom supplydrops and battlebus based on version

This commit is contained in:
max_the
2024-01-15 21:00:29 +01:00
parent b4ca8c9bfe
commit e76d5d8c2a
7 changed files with 167 additions and 48 deletions

View File

@@ -412,4 +412,9 @@ public:
return false;
}
inline InElementType& operator[](uint32 Index)
{
return Data[Index];
}
};

View File

@@ -35,6 +35,8 @@
#include "calendar.h"
#include "gui.h"
#include <random>
#include "TSubclassOf.h"
#include "FortAthenaSupplyDrop.h"
static UFortPlaylistAthena* GetPlaylistToUse()
{
@@ -188,6 +190,58 @@ void AFortGameModeAthena::StartAircraftPhase()
}
}
void AFortGameModeAthena::OverrideBattleBus(AFortGameStateAthena* GameState, UObject* OverrideBattleBusSkin)
{
if (!OverrideBattleBusSkin)
{
LOG_WARN(LogGame, "OverrideBattleBus not found! Equipping default battle bus.");
return;
}
static auto DefaultBattleBusOffset = GameState->GetOffset("DefaultBattleBus");
GameState->Get(DefaultBattleBusOffset) = OverrideBattleBusSkin;
static auto FortAthenaAircraftClass = FindObject<UClass>("/Script/FortniteGame.FortAthenaAircraft");
auto AllAircrafts = UGameplayStatics::GetAllActorsOfClass(GetWorld(), FortAthenaAircraftClass);
for (int i = 0; i < AllAircrafts.Num(); i++)
{
auto Aircraft = AllAircrafts.at(i);
static auto DefaultBusSkinOffset = Aircraft->GetOffset("DefaultBusSkin");
Aircraft->Get(DefaultBusSkinOffset) = OverrideBattleBusSkin;
static auto SpawnedCosmeticActorOffset = Aircraft->GetOffset("SpawnedCosmeticActor");
auto SpawnedCosmeticActor = Aircraft->Get<AActor*>(SpawnedCosmeticActorOffset);
if (SpawnedCosmeticActor)
{
static auto ActiveSkinOffset = SpawnedCosmeticActor->GetOffset("ActiveSkin");
SpawnedCosmeticActor->Get(ActiveSkinOffset) = OverrideBattleBusSkin;
}
}
}
void AFortGameModeAthena::OverrideSupplyDrop(AFortGameStateAthena* GameState, UClass* OverrideSupplyDropBusClass)
{
if (!OverrideSupplyDropBusClass)
{
LOG_WARN(LogGame, "OverrideSuppyDrop not found! Equipping default supply drop.");
return;
}
static auto MapInfoOffset = GameState->GetOffset("MapInfo");
auto MapInfo = GameState->Get<AFortAthenaMapInfo*>(MapInfoOffset);
static auto SupplyDropInfoListOffset = MapInfo->GetOffset("SupplyDropInfoList");
auto SupplyDropInfoList = MapInfo->Get<TArray<UFortSupplyDropInfo*>>(SupplyDropInfoListOffset);
static auto SupplyDropClassOffset = SupplyDropInfoList[0]->GetOffset("SupplyDropClass");
SupplyDropInfoList[0]->Get<TSubclassOf<AFortAthenaSupplyDrop*>>(SupplyDropClassOffset) = OverrideSupplyDropBusClass;
LOG_INFO(LogGame, "Overridden SupplyDropClass: {}", OverrideSupplyDropBusClass->GetFullName());
}
void AFortGameModeAthena::PauseSafeZone(bool bPaused)
{
auto GameState = GetGameStateAthena();
@@ -1145,6 +1199,39 @@ void AFortGameModeAthena::Athena_HandleStartingNewPlayerHook(AFortGameModeAthena
}
}
static auto BGAClass = FindObject<UClass>(L"/Script/Engine.BlueprintGeneratedClass");
static UObject* OverrideBattleBusSkin = nullptr;
static UClass* OverrideSupplyDropClass = LoadObject<UClass>(L"/Game/Athena/SupplyDrops/AthenaSupplyDrop.AthenaSupplyDrop_C", BGAClass);
if (Fortnite_Version == 1.11 || Fortnite_Version == 7.30 || Fortnite_Version == 11.31 || Fortnite_Version == 15.10 || Fortnite_Version == 19.10)
{
OverrideBattleBusSkin = FindObject(L"/Game/Athena/Items/Cosmetics/BattleBuses/BBID_WinterBus.BBID_WinterBus"); // Winterfest
OverrideSupplyDropClass = LoadObject<UClass>(L"/Game/Athena/SupplyDrops/AthenaSupplyDrop_Holiday.AthenaSupplyDrop_Holiday_C", BGAClass);
}
else if (Fortnite_Version == 5.10 || Fortnite_Version == 9.41 || Fortnite_Version == 14.20 || Fortnite_Version == 18.00)
{
OverrideBattleBusSkin = FindObject(L"/Game/Athena/Items/Cosmetics/BattleBuses/BBID_BirthdayBus2nd.BBID_BirthdayBus2nd"); // Birthday
OverrideSupplyDropClass = LoadObject<UClass>(L"/Game/Athena/SupplyDrops/AthenaSupplyDrop_BDay.AthenaSupplyDrop_BDay_C", BGAClass);
}
else if (Fortnite_Version == 1.8 || Fortnite_Version == 6.20 || Fortnite_Version == 6.21 || Fortnite_Version == 11.10 || Fortnite_Version == 14.40 || Fortnite_Version == 18.21)
{
OverrideBattleBusSkin = FindObject(L"/Game/Athena/Items/Cosmetics/BattleBuses/BBID_HalloweenBus.BBID_HalloweenBus"); // Fortnitemares
}
else if (Fortnite_Version >= 12.30 && Fortnite_Version <= 12.61)
{
OverrideBattleBusSkin = FindObject(L"/Game/Athena/Items/Cosmetics/BattleBuses/BBID_DonutBus.BBID_DonutBus"); // Deadpool
OverrideSupplyDropClass = LoadObject<UClass>(L"/Game/Athena/SupplyDrops/AthenaSupplyDrop_Donut.AthenaSupplyDrop_Donut_C", BGAClass);
}
else if (Fortnite_Version == 9.30)
{
OverrideBattleBusSkin = FindObject(L"/Game/Athena/Items/Cosmetics/BattleBuses/BBID_WorldCupBus.BBID_WorldCupBus"); // World Cup
}
if (OverrideBattleBusSkin)
OverrideBattleBus(GameState, OverrideBattleBusSkin);
OverrideSupplyDrop(GameState, OverrideSupplyDropClass);
// if (Engine_Version < 427)
{
static int LastNum69 = 19451;

View File

@@ -232,6 +232,11 @@ static void StreamLevel(const std::string& LevelName, FVector Location = {})
ShowFoundation(BuildingFoundation);
}
class UFortSupplyDropInfo : public UObject // UDataAsset
{
public:
};
class AFortGameModeAthena : public AFortGameModePvPBase
{
public:
@@ -269,6 +274,8 @@ public:
void PauseSafeZone(bool bPaused = true);
void StartAircraftPhase();
static void OverrideBattleBus(AFortGameStateAthena* GameState, UObject* OverrideBattleBusSkin);
static void OverrideSupplyDrop(AFortGameStateAthena* GameState, UClass* OverrideSupplyDropBusClass);
static void HandleSpawnRateForActorClass(UClass* ActorClass, float SpawnPercentage); // idk where to put
static void OnAircraftEnteredDropZoneHook(AFortGameModeAthena* GameModeAthena, AActor* Aircraft);

View File

@@ -471,6 +471,7 @@
<ClInclude Include="Text.h" />
<ClInclude Include="TimerManager.h" />
<ClInclude Include="Transform.h" />
<ClInclude Include="TSubclassOf.h" />
<ClInclude Include="Tuple.h" />
<ClInclude Include="TypeCompatibleBytes.h" />
<ClInclude Include="TypeWrapper.h" />

View File

@@ -960,6 +960,9 @@
<ClInclude Include="FortPlaylistAthena.h">
<Filter>FortniteGame\Source\FortniteGame\Public</Filter>
</ClInclude>
<ClInclude Include="TSubclassOf.h">
<Filter>Engine\Source\Runtime\Engine\Classes\Engine</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Engine">

View File

@@ -0,0 +1,63 @@
#pragma once
template<typename ClassType>
class TSubclassOf
{
class UClass* ClassPtr;
public:
TSubclassOf() = default;
inline TSubclassOf(UClass* Class)
: ClassPtr(Class)
{
}
inline UClass* Get()
{
return ClassPtr;
}
inline operator UClass* () const
{
return ClassPtr;
}
template<typename Target, typename = std::enable_if<std::is_base_of_v<Target, ClassType>, bool>::type>
inline operator TSubclassOf<Target>() const
{
return ClassPtr;
}
inline UClass* operator->()
{
return ClassPtr;
}
inline TSubclassOf& operator=(UClass* Class)
{
ClassPtr = Class;
return *this;
}
inline bool operator==(const TSubclassOf& Other) const
{
return ClassPtr == Other.ClassPtr;
}
inline bool operator!=(const TSubclassOf& Other) const
{
return ClassPtr != Other.ClassPtr;
}
inline bool operator==(UClass* Other) const
{
return ClassPtr == Other;
}
inline bool operator!=(UClass* Other) const
{
return ClassPtr != Other;
}
};

View File

@@ -819,54 +819,7 @@ static inline void MainUI()
auto GameMode = (AFortGameMode*)GetWorld()->GetGameMode();
auto GameState = Cast<AFortGameStateAthena>(GameMode->GetGameState());
AmountOfPlayersWhenBusStart = GameState->GetPlayersLeft(); // scuffed!!!!
if (Fortnite_Version == 1.11)
{
static auto OverrideBattleBusSkin = FindObject(L"/Game/Athena/Items/Cosmetics/BattleBuses/BBID_WinterBus.BBID_WinterBus");
LOG_INFO(LogDev, "OverrideBattleBusSkin: {}", __int64(OverrideBattleBusSkin));
if (OverrideBattleBusSkin)
{
static auto AssetManagerOffset = GetEngine()->GetOffset("AssetManager");
auto AssetManager = GetEngine()->Get(AssetManagerOffset);
if (AssetManager)
{
static auto AthenaGameDataOffset = AssetManager->GetOffset("AthenaGameData");
auto AthenaGameData = AssetManager->Get(AthenaGameDataOffset);
if (AthenaGameData)
{
static auto DefaultBattleBusSkinOffset = AthenaGameData->GetOffset("DefaultBattleBusSkin");
AthenaGameData->Get(DefaultBattleBusSkinOffset) = OverrideBattleBusSkin;
}
}
static auto DefaultBattleBusOffset = GameState->GetOffset("DefaultBattleBus");
GameState->Get(DefaultBattleBusOffset) = OverrideBattleBusSkin;
static auto FortAthenaAircraftClass = FindObject<UClass>("/Script/FortniteGame.FortAthenaAircraft");
auto AllAircrafts = UGameplayStatics::GetAllActorsOfClass(GetWorld(), FortAthenaAircraftClass);
for (int i = 0; i < AllAircrafts.Num(); i++)
{
auto Aircraft = AllAircrafts.at(i);
static auto DefaultBusSkinOffset = Aircraft->GetOffset("DefaultBusSkin");
Aircraft->Get(DefaultBusSkinOffset) = OverrideBattleBusSkin;
static auto SpawnedCosmeticActorOffset = Aircraft->GetOffset("SpawnedCosmeticActor");
auto SpawnedCosmeticActor = Aircraft->Get<AActor*>(SpawnedCosmeticActorOffset);
if (SpawnedCosmeticActor)
{
static auto ActiveSkinOffset = SpawnedCosmeticActor->GetOffset("ActiveSkin");
SpawnedCosmeticActor->Get(ActiveSkinOffset) = OverrideBattleBusSkin;
}
}
}
}
AmountOfPlayersWhenBusStart = GameState->GetPlayersLeft();
static auto WarmupCountdownEndTimeOffset = GameState->GetOffset("WarmupCountdownEndTime");
// GameState->Get<float>(WarmupCountdownEndTimeOffset) = UGameplayStatics::GetTimeSeconds(GetWorld()) + 10;