Skip to content

Commit

Permalink
Upgrade to 4.20
Browse files Browse the repository at this point in the history
Updated source to 4.20
Added more includes where they were missing.
Added new Navigation system module
Replaced UT's mutator hack with simpler alternative.
  • Loading branch information
Tom Looman committed Jul 22, 2018
1 parent 4a6ee9a commit e819333
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 36 deletions.
Binary file modified SurvivalGame/Binaries/Win64/UE4Editor-SurvivalGame.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"VersionName" : "1.0",
"CreatedBy" : "Tom Looman",
"CreatedByURL" : "http://www.tomlooman.com",
"EngineVersion" : "4.18.0",
"EngineVersion" : "4.20.0",
"Description" : "My Extend Rifle Mod",
"Category" : "User Mod",
"EnabledByDefault" : true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"VersionName" : "1.0",
"CreatedBy" : "Tom Looman",
"CreatedByURL" : "http://www.tomlooman.com",
"EngineVersion" : "4.18.0",
"EngineVersion" : "4.20.0",
"Description" : "My Flashlight Mod",
"Category" : "User Mod",
"EnabledByDefault" : true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "BehaviorTree/BlackboardComponent.h"
/* This contains includes all key types like UBlackboardKeyType_Vector used below. */
#include "BehaviorTree/Blackboard/BlackboardKeyAllTypes.h"
#include "NavigationSystem.h"



Expand All @@ -29,7 +30,7 @@ EBTNodeResult::Type UBTTask_FindPatrolLocation::ExecuteTask(UBehaviorTreeCompone
const FVector SearchOrigin = MyWaypoint->GetActorLocation();

FNavLocation ResultLocation;
UNavigationSystem* NavSystem = UNavigationSystem::GetNavigationSystem(MyController);
UNavigationSystemV1* NavSystem = UNavigationSystemV1::GetNavigationSystem(MyController);
if (NavSystem && NavSystem->GetRandomPointInNavigableRadius(SearchOrigin, SearchRadius, ResultLocation))
{
/* The selected key should be "PatrolLocation" in the BehaviorTree setup */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool ASWeaponInstant::ShouldDealDamage(AActor* TestActor) const
{
if (GetNetMode() != NM_Client ||
TestActor->Role == ROLE_Authority ||
TestActor->bTearOff)
TestActor->GetTearOff())
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "SurvivalGame.h"
#include "SBaseCharacter.h"
#include "SGameMode.h"
#include "SCharacterMovementComponent.h"
#include "SDamageType.h"


ASBaseCharacter::ASBaseCharacter(const class FObjectInitializer& ObjectInitializer)
Expand Down Expand Up @@ -142,7 +144,7 @@ void ASBaseCharacter::OnDeath(float KillingDamage, FDamageEvent const& DamageEve
}

bReplicateMovement = false;
bTearOff = true;
TearOff();
bIsDying = true;

PlayHit(KillingDamage, DamageEvent, PawnInstigator, DamageCauser, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

#include "SurvivalGame.h"
#include "SCoopGameMode.h"
#include "NavigationSystem.h"
#include "SPlayerState.h"
#include "SCharacter.h"
#include "SGameState.h"



Expand Down Expand Up @@ -52,7 +56,7 @@ void ASCoopGameMode::RestartPlayer(class AController* NewPlayer)

/* Get a point on the nav mesh near the other player */
FNavLocation StartLocation;
UNavigationSystem* NavSystem = UNavigationSystem::GetNavigationSystem(this);
UNavigationSystemV1* NavSystem = UNavigationSystemV1::GetNavigationSystem(this);
if (NavSystem && NavSystem->GetRandomPointInNavigableRadius(SpawnOrigin, 250.0f, StartLocation))
{
// Try to create a pawn to use of the default class for this player
Expand Down
43 changes: 19 additions & 24 deletions SurvivalGame/Source/SurvivalGame/Private/World/SGameMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "SZombieCharacter.h"
#include "SPlayerStart.h"
#include "SMutator.h"
#include "SWeapon.h"


ASGameMode::ASGameMode(const FObjectInitializer& ObjectInitializer)
Expand Down Expand Up @@ -402,11 +403,6 @@ void ASGameMode::SpawnDefaultInventory(APawn* PlayerPawn)

void ASGameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
{
// HACK: workaround to inject CheckRelevance() into the BeginPlay sequence
UFunction* Func = AActor::GetClass()->FindFunctionByName(FName(TEXT("ReceiveBeginPlay")));
Func->FunctionFlags |= FUNC_Native;
Func->SetNativeFunc((Native)&ASGameMode::BeginPlayMutatorHack);

/* Spawn all mutators. */
for (int32 i = 0; i < MutatorClasses.Num(); i++)
{
Expand All @@ -418,6 +414,24 @@ void ASGameMode::InitGame(const FString& MapName, const FString& Options, FStrin
BaseMutator->InitGame(MapName, Options, ErrorMessage);
}

for (TActorIterator<AActor> It(GetWorld(), AActor::StaticClass()); It; ++It)
{
AActor* Actor = *It;
if (!Actor->IsPendingKill())
{
if (!Actor->IsA(ALevelScriptActor::StaticClass()) && !Actor->IsA(ASMutator::StaticClass()) && Actor->GetRootComponent() != nullptr &&
Actor->GetRootComponent()->Mobility != EComponentMobility::Static || (!Actor->IsA(AStaticMeshActor::StaticClass()) && !Actor->IsA(ALight::StaticClass())))
{
// a few type checks being AFTER the CheckRelevance() call is intentional; want mutators to be able to modify, but not outright destroy
if (!CheckRelevance(Actor) && !Actor->IsA(APlayerController::StaticClass()))
{
/* Actors are destroyed if they fail the relevance checks */
Actor->Destroy();
}
}
}
}

Super::InitGame(MapName, Options, ErrorMessage);
}

Expand All @@ -434,25 +448,6 @@ bool ASGameMode::CheckRelevance_Implementation(AActor* Other)
}


void ASGameMode::BeginPlayMutatorHack(FFrame& Stack, RESULT_DECL)
{
P_FINISH;

// WARNING: This function is called by every Actor in the level during his BeginPlay sequence. Meaning: 'this' is actually an AActor! Only do AActor things!
if (!IsA(ALevelScriptActor::StaticClass()) && !IsA(ASMutator::StaticClass()) &&
(RootComponent == NULL || RootComponent->Mobility != EComponentMobility::Static || (!IsA(AStaticMeshActor::StaticClass()) && !IsA(ALight::StaticClass()))))
{
ASGameMode* Game = GetWorld()->GetAuthGameMode<ASGameMode>();
// a few type checks being AFTER the CheckRelevance() call is intentional; want mutators to be able to modify, but not outright destroy
if (Game != NULL && Game != this && !Game->CheckRelevance((AActor*)this) && !IsA(APlayerController::StaticClass()))
{
/* Actors are destroyed if they fail the relevance checks (which moves through the gamemode specific check AND the chain of mutators) */
Destroy();
}
}
}


void ASGameMode::AddMutator(TSubclassOf<ASMutator> MutClass)
{
ASMutator* NewMut = GetWorld()->SpawnActor<ASMutator>(MutClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "SBotWaypoint.h"
#include "SZombieAIController.generated.h"

class UBehaviorTreeComponent;

/**
*
*/
Expand Down
6 changes: 2 additions & 4 deletions SurvivalGame/Source/SurvivalGame/Public/World/SGameMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "SMutator.h"
#include "SGameMode.generated.h"

class ASPlayerState;

/**
*
*/
Expand Down Expand Up @@ -153,8 +155,4 @@ class SURVIVALGAME_API ASGameMode : public AGameMode

/* Note: Functions flagged with BlueprintNativeEvent like above require _Implementation for a C++ implementation */
virtual bool CheckRelevance_Implementation(AActor* Other);

/* Hacked into ReceiveBeginPlay() so we can do mutator replacement of Actors and such */
void BeginPlayMutatorHack(FFrame& Stack, RESULT_DECL);

};
3 changes: 2 additions & 1 deletion SurvivalGame/Source/SurvivalGame/SurvivalGame.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public SurvivalGame(ReadOnlyTargetRules Target) : base(Target)
/* AIModule is not assigned by default, must be added when dealing with AI in your project */
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "AIModule",
/* Temporarily added GameplayTasks to workaround 4.12 compilation bug. */
"GameplayTasks" });
"GameplayTasks",
"NavigationSystem" });

PrivateDependencyModuleNames.AddRange(new string[] { });

Expand Down
2 changes: 1 addition & 1 deletion SurvivalGame/SurvivalGame.uproject
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"FileVersion": 3,
"EngineAssociation": "4.18",
"EngineAssociation": "4.20",
"Category": "",
"Description": "",
"Modules": [
Expand Down

0 comments on commit e819333

Please sign in to comment.