prevent player from damaging team member
This commit is contained in:
BIN
Content/Maps/GameLevel.umap
LFS
BIN
Content/Maps/GameLevel.umap
LFS
Binary file not shown.
@@ -205,6 +205,15 @@ void ACCharacter::ReSpawn()
|
||||
GetCharacterMovement()->SetMovementMode(MOVE_Walking);
|
||||
GetMesh()->GetAnimInstance()->StopAllMontages(0.f);
|
||||
SetStatusGaugeEnabled(true);
|
||||
|
||||
if (HasAuthority() && GetController())
|
||||
{
|
||||
if (const auto StartSpot { GetController()->StartSpot }; StartSpot.IsValid())
|
||||
{
|
||||
SetActorTransform(StartSpot->GetActorTransform());
|
||||
}
|
||||
}
|
||||
|
||||
if (CAbilitySystemComponent)
|
||||
{
|
||||
CAbilitySystemComponent->ApplyFullStatEffect();
|
||||
|
||||
@@ -15,11 +15,14 @@ UAnimInstance* UCGameplayAbility::GetOwnerAnimInstance() const
|
||||
}
|
||||
|
||||
TArray<FHitResult> UCGameplayAbility::GetHitResultFromSweepLocationTargetData(
|
||||
const FGameplayAbilityTargetDataHandle& TargetDataHandle, float SphereSweepRadius, bool bDrawDebug,
|
||||
bool bIgnoreSelf) const
|
||||
const FGameplayAbilityTargetDataHandle& TargetDataHandle, float SphereSweepRadius, ETeamAttitude::Type TargetTeam,
|
||||
bool bDrawDebug, bool bIgnoreSelf) const
|
||||
{
|
||||
TArray<FHitResult> OutResults;
|
||||
TSet<AActor*> HitActors;
|
||||
|
||||
const auto OwnerTeamInterface{Cast<IGenericTeamAgentInterface>(GetAvatarActorFromActorInfo())};
|
||||
|
||||
for (const auto TargetData : TargetDataHandle.Data)
|
||||
{
|
||||
const FVector StartLoc{TargetData->GetOrigin().GetTranslation()};
|
||||
@@ -49,6 +52,12 @@ TArray<FHitResult> UCGameplayAbility::GetHitResultFromSweepLocationTargetData(
|
||||
for (const auto Result : Results)
|
||||
{
|
||||
if (HitActors.Contains(Result.GetActor())) continue;
|
||||
|
||||
if (OwnerTeamInterface)
|
||||
{
|
||||
const auto OtherActorTeamAttitude{OwnerTeamInterface->GetTeamAttitudeTowards(*Result.GetActor())};
|
||||
if (OtherActorTeamAttitude != TargetTeam) continue;
|
||||
}
|
||||
HitActors.Add(Result.GetActor());
|
||||
OutResults.Add(Result);
|
||||
}
|
||||
|
||||
@@ -152,9 +152,7 @@ void UGA_Combo::DoDamage(FGameplayEventData Data)
|
||||
auto HitResults{
|
||||
GetHitResultFromSweepLocationTargetData(
|
||||
Data.TargetData,
|
||||
TargetSweepSphereRadius,
|
||||
false,
|
||||
true
|
||||
TargetSweepSphereRadius
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
@@ -34,8 +34,7 @@ AActor* ACGameMode::FindNextStartSpotForTeam(const FGenericTeamId& TeamId) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
auto World{GetWorld()};
|
||||
for (TActorIterator<APlayerStart> It(World); It; ++It)
|
||||
for (TActorIterator<APlayerStart> It{GetWorld()}; It; ++It)
|
||||
{
|
||||
if (It->PlayerStartTag == *StartSpotTag)
|
||||
{
|
||||
|
||||
@@ -3,12 +3,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GenericTeamAgentInterface.h"
|
||||
#include "Abilities/GameplayAbility.h"
|
||||
#include "CGameplayAbility.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class CRUNCH_API UCGameplayAbility : public UGameplayAbility
|
||||
{
|
||||
@@ -17,6 +15,8 @@ class CRUNCH_API UCGameplayAbility : public UGameplayAbility
|
||||
protected:
|
||||
UAnimInstance* GetOwnerAnimInstance() const;
|
||||
TArray<FHitResult> GetHitResultFromSweepLocationTargetData(const FGameplayAbilityTargetDataHandle& TargetDataHandle,
|
||||
float SphereSweepRadius = 30.f, bool bDrawDebug = false,
|
||||
float SphereSweepRadius = 30.f,
|
||||
ETeamAttitude::Type TargetTeam = ETeamAttitude::Hostile,
|
||||
bool bDrawDebug = false,
|
||||
bool bIgnoreSelf = true) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user