Bim bam boom

This commit is contained in:
Gray
2024-03-23 17:40:45 -04:00
parent 1cb5a17247
commit 68ae6d81cb
7 changed files with 84 additions and 84 deletions

View File

@@ -125,7 +125,7 @@ public:
static UClass* StaticClass() static UClass* StaticClass()
{ {
static auto Class = FindObject<UClass>("/Script/FortniteGame.FortAthenaMutator_InventoryOverride"); static auto Class = FindObject<UClass>(L"/Script/FortniteGame.FortAthenaMutator_InventoryOverride");
return Class; return Class;
} }
}; };

View File

@@ -1439,78 +1439,80 @@ void AFortPlayerController::ClientOnPawnDiedHook(AFortPlayerController* PlayerCo
bool bIsRespawningAllowed = GameState->IsRespawningAllowed(DeadPlayerState); bool bIsRespawningAllowed = GameState->IsRespawningAllowed(DeadPlayerState);
if (!bIsRespawningAllowed) bool bDropInventory = true;
{
bool bDropInventory = true;
LoopMutators([&](AFortAthenaMutator* Mutator) LoopMutators([&](AFortAthenaMutator* Mutator)
{
if (auto FortAthenaMutator_InventoryOverride = Cast<AFortAthenaMutator_InventoryOverride>(Mutator))
{
if (FortAthenaMutator_InventoryOverride->GetDropAllItemsOverride(DeadPlayerState->GetTeamIndex()) == EAthenaLootDropOverride::ForceKeep)
{
bDropInventory = false;
}
}
}
);
if (bDropInventory)
{ {
auto WorldInventory = PlayerController->GetWorldInventory(); if (auto FortAthenaMutator_InventoryOverride = Cast<AFortAthenaMutator_InventoryOverride>(Mutator))
if (WorldInventory)
{ {
auto& ItemInstances = WorldInventory->GetItemList().GetItemInstances(); if (FortAthenaMutator_InventoryOverride->GetDropAllItemsOverride(DeadPlayerState->GetTeamIndex()) == EAthenaLootDropOverride::ForceKeep)
std::vector<std::pair<FGuid, int>> GuidAndCountsToRemove;
for (int i = 0; i < ItemInstances.Num(); ++i)
{ {
auto ItemInstance = ItemInstances.at(i); bDropInventory = false;
// LOG_INFO(LogDev, "[{}/{}] CurrentItemInstance {}", i, ItemInstances.Num(), __int64(ItemInstance));
if (!ItemInstance)
continue;
auto ItemEntry = ItemInstance->GetItemEntry();
auto WorldItemDefinition = Cast<UFortWorldItemDefinition>(ItemEntry->GetItemDefinition());
// LOG_INFO(LogDev, "[{}/{}] WorldItemDefinition {}", i, ItemInstances.Num(), WorldItemDefinition ? WorldItemDefinition->GetFullName() : "InvalidObject");
if (!WorldItemDefinition)
continue;
auto ShouldBeDropped = WorldItemDefinition->CanBeDropped(); // WorldItemDefinition->ShouldDropOnDeath();
// LOG_INFO(LogDev, "[{}/{}] ShouldBeDropped {}", i, ItemInstances.Num(), ShouldBeDropped);
if (!ShouldBeDropped)
continue;
PickupCreateData CreateData;
CreateData.bToss = true;
CreateData.ItemEntry = ItemEntry;
CreateData.SourceType = EFortPickupSourceTypeFlag::GetPlayerValue();
CreateData.Source = EFortPickupSpawnSource::GetPlayerEliminationValue();
CreateData.SpawnLocation = DeathLocation;
AFortPickup::SpawnPickup(CreateData);
GuidAndCountsToRemove.push_back({ ItemEntry->GetItemGuid(), ItemEntry->GetCount() });
// WorldInventory->RemoveItem(ItemEntry->GetItemGuid(), nullptr, ItemEntry->GetCount());
} }
for (auto& Pair : GuidAndCountsToRemove)
{
WorldInventory->RemoveItem(Pair.first, nullptr, Pair.second, true);
}
WorldInventory->Update();
} }
} }
);
if (bDropInventory
&& !bIsRespawningAllowed
)
{
auto WorldInventory = PlayerController->GetWorldInventory();
if (WorldInventory)
{
auto& ItemInstances = WorldInventory->GetItemList().GetItemInstances();
std::vector<std::pair<FGuid, int>> GuidAndCountsToRemove;
for (int i = 0; i < ItemInstances.Num(); ++i)
{
auto ItemInstance = ItemInstances.at(i);
// LOG_INFO(LogDev, "[{}/{}] CurrentItemInstance {}", i, ItemInstances.Num(), __int64(ItemInstance));
if (!ItemInstance)
continue;
auto ItemEntry = ItemInstance->GetItemEntry();
auto WorldItemDefinition = Cast<UFortWorldItemDefinition>(ItemEntry->GetItemDefinition());
// LOG_INFO(LogDev, "[{}/{}] WorldItemDefinition {}", i, ItemInstances.Num(), WorldItemDefinition ? WorldItemDefinition->GetFullName() : "InvalidObject");
if (!WorldItemDefinition)
continue;
auto ShouldBeDropped = WorldItemDefinition->CanBeDropped(); // WorldItemDefinition->ShouldDropOnDeath();
// LOG_INFO(LogDev, "[{}/{}] ShouldBeDropped {}", i, ItemInstances.Num(), ShouldBeDropped);
if (!ShouldBeDropped)
continue;
PickupCreateData CreateData;
CreateData.bToss = true;
CreateData.ItemEntry = ItemEntry;
CreateData.SourceType = EFortPickupSourceTypeFlag::GetPlayerValue();
CreateData.Source = EFortPickupSpawnSource::GetPlayerEliminationValue();
CreateData.SpawnLocation = DeathLocation;
AFortPickup::SpawnPickup(CreateData);
GuidAndCountsToRemove.push_back({ ItemEntry->GetItemGuid(), ItemEntry->GetCount() });
// WorldInventory->RemoveItem(ItemEntry->GetItemGuid(), nullptr, ItemEntry->GetCount());
}
for (auto& Pair : GuidAndCountsToRemove)
{
WorldInventory->RemoveItem(Pair.first, nullptr, Pair.second, true);
}
WorldInventory->Update();
}
}
if (!bIsRespawningAllowed)
{
auto GameMode = Cast<AFortGameModeAthena>(GetWorld()->GetGameMode()); auto GameMode = Cast<AFortGameModeAthena>(GetWorld()->GetGameMode());
LOG_INFO(LogDev, "PlayersLeft: {} IsDBNO: {}", GameState->GetPlayersLeft(), DeadPawn->IsDBNO()); LOG_INFO(LogDev, "PlayersLeft: {} IsDBNO: {}", GameState->GetPlayersLeft(), DeadPawn->IsDBNO());

View File

@@ -9,6 +9,7 @@
#include "FortAthenaMutator_GG.h" #include "FortAthenaMutator_GG.h"
#include "FortAthenaMutator_InventoryOverride.h" #include "FortAthenaMutator_InventoryOverride.h"
#include "calendar.h" #include "calendar.h"
#include "hooking.h"
void AGameModeBase::RestartPlayerAtTransform(AController* NewPlayer, FTransform SpawnTransform) void AGameModeBase::RestartPlayerAtTransform(AController* NewPlayer, FTransform SpawnTransform)
{ {
@@ -120,33 +121,29 @@ APawn* AGameModeBase::SpawnDefaultPawnForHook(AGameModeBase* GameMode, AControll
static auto DefaultPawnClassOffset = GameMode->GetOffset("DefaultPawnClass"); static auto DefaultPawnClassOffset = GameMode->GetOffset("DefaultPawnClass");
GameMode->Get<UClass*>(DefaultPawnClassOffset) = PawnClass; GameMode->Get<UClass*>(DefaultPawnClassOffset) = PawnClass;
bool bUseSpawnActor = false; #if 1
static auto SpawnDefaultPawnAtTransformFn = FindObject<UFunction>(L"/Script/Engine.GameModeBase.SpawnDefaultPawnAtTransform"); static auto SpawnDefaultPawnAtTransformFn = FindObject<UFunction>(L"/Script/Engine.GameModeBase.SpawnDefaultPawnAtTransform");
FTransform SpawnTransform = StartSpot->GetTransform(); FTransform SpawnTransform = StartSpot->GetTransform();
APawn* NewPawn = nullptr;
if (bUseSpawnActor) struct { AController* NewPlayer; FTransform SpawnTransform; APawn* ReturnValue; }
{ AGameModeBase_SpawnDefaultPawnAtTransform_Params{ NewPlayer, SpawnTransform };
NewPawn = GetWorld()->SpawnActor<APawn>(PawnClass, SpawnTransform, CreateSpawnParameters(ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn));
}
else
{
struct { AController* NewPlayer; FTransform SpawnTransform; APawn* ReturnValue; }
AGameModeBase_SpawnDefaultPawnAtTransform_Params{ NewPlayer, SpawnTransform };
LOG_INFO(LogDev, "Calling SpawnDefaultPawnAtTransformFn!"); LOG_INFO(LogDev, "Calling SpawnDefaultPawnAtTransformFn!");
GameMode->ProcessEvent(SpawnDefaultPawnAtTransformFn, &AGameModeBase_SpawnDefaultPawnAtTransform_Params); GameMode->ProcessEvent(SpawnDefaultPawnAtTransformFn, &AGameModeBase_SpawnDefaultPawnAtTransform_Params);
LOG_INFO(LogDev, "Finished SpawnDefaultPawnAtTransformFn!"); LOG_INFO(LogDev, "Finished SpawnDefaultPawnAtTransformFn!");
NewPawn = AGameModeBase_SpawnDefaultPawnAtTransform_Params.ReturnValue; auto NewPawn = AGameModeBase_SpawnDefaultPawnAtTransform_Params.ReturnValue;
} #else
#endif
if (!NewPawn) if (!NewPawn)
{
LOG_WARN(LogPlayer, "Failed to spawn pawn!");
return nullptr; return nullptr;
}
bool bIsRespawning = false; // reel bool bIsRespawning = false; // reel

View File

@@ -137,7 +137,7 @@ public:
} }
} }
// LOG_INFO(LogDev, "Failed to find Key!!!"); LOG_INFO(LogDev, "Failed to find Key!!!");
if (wasSuccessful) if (wasSuccessful)
*wasSuccessful = false; *wasSuccessful = false;

View File

@@ -111,7 +111,7 @@ static inline AFortAthenaMutator_Bots* SpawnBotMutator() //sets up all the class
auto GameMode = Cast<AFortGameModeAthena>(GetWorld()->GetGameMode()); auto GameMode = Cast<AFortGameModeAthena>(GetWorld()->GetGameMode());
static auto BGAClass = FindObject<UClass>(L"/Script/Engine.BlueprintGeneratedClass"); static auto BGAClass = FindObject<UClass>(L"/Script/Engine.BlueprintGeneratedClass");
static auto PhoebeMutatorClass = LoadObject<UClass>(L"/Game/Athena/AI/Phoebe/BP_Phoebe_Mutator.BP_Phoebe_Mutator_C", BGAClass); auto PhoebeMutatorClass = LoadObject<UClass>(L"/Game/Athena/AI/Phoebe/BP_Phoebe_Mutator.BP_Phoebe_Mutator_C", BGAClass);
if (!PhoebeMutatorClass) if (!PhoebeMutatorClass)
{ {

View File

@@ -819,6 +819,7 @@ DWORD WINAPI Main(LPVOID)
} }
LOG_INFO(LogInit, "Initializing Project Reboot!"); LOG_INFO(LogInit, "Initializing Project Reboot!");
LOG_INFO(LogDev, "Built on {} {}", __DATE__, __TIME__);
Addresses::SetupVersion(); Addresses::SetupVersion();
@@ -915,7 +916,6 @@ DWORD WINAPI Main(LPVOID)
Hooking::MinHook::Hook((PVOID)Addresses::KickPlayer, (PVOID)AGameSession::KickPlayerHook, (PVOID*)&AGameSession::KickPlayerOriginal); Hooking::MinHook::Hook((PVOID)Addresses::KickPlayer, (PVOID)AGameSession::KickPlayerHook, (PVOID*)&AGameSession::KickPlayerOriginal);
LOG_INFO(LogDev, "Built on {} {}", __DATE__, __TIME__);
LOG_INFO(LogDev, "Size: 0x{:x}", sizeof(TMap<FName, void*>)); LOG_INFO(LogDev, "Size: 0x{:x}", sizeof(TMap<FName, void*>));
Hooking::MinHook::Hook((PVOID)Addresses::ActorGetNetMode, (PVOID)GetNetModeHook2, nullptr); Hooking::MinHook::Hook((PVOID)Addresses::ActorGetNetMode, (PVOID)GetNetModeHook2, nullptr);

View File

@@ -23,6 +23,7 @@ namespace Globals
extern inline bool bStartedListening = false; extern inline bool bStartedListening = false;
extern inline bool bAutoRestart = false; // doesnt work fyi extern inline bool bAutoRestart = false; // doesnt work fyi
extern inline bool bFillVendingMachines = true; extern inline bool bFillVendingMachines = true;
extern inline bool bPrivateIPsAreOperator = true;
extern inline int AmountOfListens = 0; // TODO: Switch to this for LastNum extern inline int AmountOfListens = 0; // TODO: Switch to this for LastNum
extern inline bool bDeveloperMode = false; extern inline bool bDeveloperMode = false;
} }