From 33b9593f941ea013a0b1c78be6a0d5372ad6899f Mon Sep 17 00:00:00 2001 From: Rafal Swierczek Date: Mon, 9 Oct 2023 13:37:42 +0100 Subject: [PATCH] Update Explosive & AI for Damage Implementation --- EndlessVendetta/Content/Gadgets/BP_Grenade.uasset | 4 ++-- .../HDRI/HDRI_Epic_Courtyard_Daylight.uasset | 2 +- .../StarterContent/Props/MaterialSphere.uasset | 4 ++-- .../EnemyAITest/D/CU/5S9SRVGAJUGQ0XXVI4GUXL.uasset | 3 +++ .../Source/EndlessVendetta/AI/AICharacter.cpp | 11 +++++++---- .../Source/EndlessVendetta/AI/AI_EnemyController.cpp | 8 ++++++++ .../GadgetSystem/GadgetClasses/Combat/Explosive.cpp | 3 +++ 7 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/D/CU/5S9SRVGAJUGQ0XXVI4GUXL.uasset diff --git a/EndlessVendetta/Content/Gadgets/BP_Grenade.uasset b/EndlessVendetta/Content/Gadgets/BP_Grenade.uasset index 92db3563..b1f7c397 100644 --- a/EndlessVendetta/Content/Gadgets/BP_Grenade.uasset +++ b/EndlessVendetta/Content/Gadgets/BP_Grenade.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3b5b0aa3f0b0da4c979843a761e655ef147058bb43079f24e4ef358532a7d5cf -size 49595 +oid sha256:0973ba2e3915d82c77975bb8899e2edebcca3eac00001b2d43dc28e63c7070a0 +size 48239 diff --git a/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset b/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset index a76d9a83..61bd566f 100644 --- a/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset +++ b/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:35965626ed27917622aa4630a23b7a047248cb9b9b0e66e1843969c4b1e0aadb +oid sha256:dfac21de443880cedc47810366aca5797b08fd32f183ad2f0494feef24f7147b size 66790690 diff --git a/EndlessVendetta/Content/StarterContent/Props/MaterialSphere.uasset b/EndlessVendetta/Content/StarterContent/Props/MaterialSphere.uasset index 413bf4e9..56bddfc9 100644 --- a/EndlessVendetta/Content/StarterContent/Props/MaterialSphere.uasset +++ b/EndlessVendetta/Content/StarterContent/Props/MaterialSphere.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:000a98212651fd0d1c6804c7636e5e4614f710bd1a19a87b394f13dda3bcbc17 -size 47710 +oid sha256:3a8777c01491888bba9f40eda9d2bed76a611f0e80f75917501ce69c1a321342 +size 47333 diff --git a/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/D/CU/5S9SRVGAJUGQ0XXVI4GUXL.uasset b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/D/CU/5S9SRVGAJUGQ0XXVI4GUXL.uasset new file mode 100644 index 00000000..34744f75 --- /dev/null +++ b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/D/CU/5S9SRVGAJUGQ0XXVI4GUXL.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:69dcd1314353f09d4f12cc1a2a2ced8540f035585740d097a179bb332d850779 +size 4545 diff --git a/EndlessVendetta/Source/EndlessVendetta/AI/AICharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/AI/AICharacter.cpp index 9135da93..8e976d0a 100644 --- a/EndlessVendetta/Source/EndlessVendetta/AI/AICharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/AI/AICharacter.cpp @@ -3,12 +3,14 @@ #include "AICharacter.h" -#include "AI_CompanionController.h" +#include "AI_EnemyController.h" #include "Components/CapsuleComponent.h" #include "Engine/DamageEvents.h" #include "GameFramework/CharacterMovementComponent.h" #include "Perception/AIPerceptionStimuliSourceComponent.h" #include "Perception/AISense_Sight.h" +#include "BehaviorTree/BlackboardComponent.h" +#include "Blueprint/AIBlueprintHelperLibrary.h" // Sets default values @@ -48,12 +50,13 @@ float AAICharacter::TakeDamage(const float DamageAmount, FDamageEvent const& Dam CurrentHealth -= DamageAmount; if (CurrentHealth <= 0) { + if (!IsValid(this)) return 0.0f; CurrentHealth = 0; UE_LOG(LogTemp, Display, TEXT("%s is dead"), *CharacterName.ToString()); - const AAI_CompanionController* AIController = Cast(GetController()); - AIController->GetBrainComponent()->StopLogic(*CharacterName.ToString() + FString(" is dead")); - + /*const AAI_EnemyController* AIController = Cast(GetController()); + AIController->GetBrainComponent()->StopLogic(" is dead");*/ + this->Tags.Add(FName("Dead")); //Ragdoll DetachFromControllerPendingDestroy(); UCapsuleComponent* CapsuleComp = GetCapsuleComponent(); diff --git a/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.cpp b/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.cpp index 864586e4..3f343fa2 100644 --- a/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/AI/AI_EnemyController.cpp @@ -36,6 +36,14 @@ void AAI_EnemyController::OnPossess(APawn* InPawn) UBlackboardComponent* TempBlackboardPtr; UseBlackboard(BehaviorTree->BlackboardAsset, TempBlackboardPtr); Blackboard = TempBlackboardPtr; + if (IsValid(EnemyCharacter->GetPatrolPath())) + { + Blackboard->SetValueAsBool("IsPatroling", true); + } + else + { + Blackboard->SetValueAsBool("IsPatroling", false); + } RunBehaviorTree(BehaviorTree); } } diff --git a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Combat/Explosive.cpp b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Combat/Explosive.cpp index 4476d8d4..71262298 100644 --- a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Combat/Explosive.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Combat/Explosive.cpp @@ -5,6 +5,8 @@ #include "CollisionDebugDrawingPublic.h" #include "Kismet/KismetMathLibrary.h" +#include "Engine/DamageEvents.h" +#include "EndlessVendetta/AI/AICharacter.h" // Sets default values AExplosive::AExplosive() @@ -69,6 +71,7 @@ void AExplosive::Explosion() } // When merged, call philips take damage function here UE_LOG(LogTemp, Warning, TEXT("A shrapnel piece hit %s, dealing %f damage"), *OutHit.GetActor()->GetName(), DamageToApply); + Cast(OutHit.GetActor())->TakeDamage(DamageToApply, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this); } } PlayExplosionEffects();