Am sad and feel bad.
This commit is contained in:
@@ -84,41 +84,42 @@ void UAuraAttributeSet::PreAttributeChange(const FGameplayAttribute& Attribute,
|
||||
|
||||
void UAuraAttributeSet::SetEffectProperties(const FGameplayEffectModCallbackData& Data, FEffectProperties& Props) const
|
||||
{
|
||||
if (Data.EvaluatedData.Attribute == GetHealthAttribute())
|
||||
// Source = causer of the effect, Target = target of the effect (owner of this AS)
|
||||
|
||||
Props.EffectContextHandle = Data.EffectSpec.GetContext();
|
||||
Props.SourceASC = Props.EffectContextHandle.GetOriginalInstigatorAbilitySystemComponent();
|
||||
|
||||
if (IsValid(Props.SourceASC) && Props.SourceASC->AbilityActorInfo.IsValid() &&
|
||||
Props.SourceASC->AbilityActorInfo->AvatarActor.IsValid())
|
||||
{
|
||||
// Source = Causer of the effect, Target = target of the effect (Owner of this Attribute Set)
|
||||
Props.EffectContextHandle = Data.EffectSpec.GetContext();
|
||||
Props.SourceASC = Props.EffectContextHandle.GetOriginalInstigatorAbilitySystemComponent();
|
||||
|
||||
if (IsValid(Props.SourceASC) && Props.SourceASC->AbilityActorInfo.IsValid() && Props.SourceASC->AbilityActorInfo.IsValid())
|
||||
Props.SourceAvatarActor = Props.SourceASC->AbilityActorInfo->AvatarActor.Get();
|
||||
Props.SourceController = CastChecked<APawn>(Props.SourceAvatarActor)->GetController();
|
||||
if (Props.SourceController == nullptr && Props.SourceAvatarActor != nullptr)
|
||||
{
|
||||
Props.SourceAvatarActor = Props.SourceASC->AbilityActorInfo->AvatarActor.Get();
|
||||
Props.SourceController = Props.SourceASC->AbilityActorInfo->PlayerController.Get();
|
||||
if (Props.SourceController == nullptr && Props.SourceAvatarActor != nullptr)
|
||||
if (const APawn* Pawn = Cast<APawn>(Props.SourceAvatarActor))
|
||||
{
|
||||
if (APawn* Pawn = Cast<APawn>(Props.SourceAvatarActor))
|
||||
{
|
||||
Props.SourceController = Pawn->GetController();
|
||||
}
|
||||
}
|
||||
if (Props.SourceController)
|
||||
{
|
||||
Props.SourceCharacter = Cast<ACharacter>(Props.SourceController->GetPawn());
|
||||
Props.SourceController = Pawn->GetController();
|
||||
}
|
||||
}
|
||||
if (Props.SourceController)
|
||||
{
|
||||
ACharacter* SourceCharacter = Cast<ACharacter>(Props.SourceController->GetPawn());
|
||||
}
|
||||
}
|
||||
//Get all the target actor
|
||||
|
||||
if (Data.Target.AbilityActorInfo.IsValid() && Data.Target.AbilityActorInfo->AvatarActor.IsValid())
|
||||
{
|
||||
Props.TargetAvatarActor = Data.Target.AbilityActorInfo->AvatarActor.Get();
|
||||
Props.TargetController = Data.Target.AbilityActorInfo->PlayerController.Get();
|
||||
Props.TargetController = CastChecked<APawn>(Props.TargetAvatarActor)->GetController();
|
||||
Props.TargetCharacter = Cast<ACharacter>(Props.TargetAvatarActor);
|
||||
Props.TargetASC = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(Props.TargetAvatarActor);
|
||||
|
||||
//UE_LOG(LogTemp, Warning, TEXT("Target Info - Actor: %s - Controller %s - Character %s - ASC %s"),
|
||||
// *Props.TargetAvatarActor->GetName(), *Props.TargetController->GetName(), *Props.TargetCharacter->GetName(), *Props.TargetASC->GetName());
|
||||
}
|
||||
}
|
||||
|
||||
void UAuraAttributeSet::PostGameplayEffectExecute(const struct FGameplayEffectModCallbackData& Data)
|
||||
void UAuraAttributeSet::PostGameplayEffectExecute(const FGameplayEffectModCallbackData& Data)
|
||||
{
|
||||
Super::PostGameplayEffectExecute(Data);
|
||||
|
||||
@@ -127,13 +128,11 @@ void UAuraAttributeSet::PostGameplayEffectExecute(const struct FGameplayEffectMo
|
||||
|
||||
if (Data.EvaluatedData.Attribute == GetHealthAttribute())
|
||||
{
|
||||
//if the value being modified is Health
|
||||
SetHealth(FMath::Clamp(GetHealth(), 0.f, GetMaxHealth()));
|
||||
|
||||
UE_LOG(LogTemp, Warning, TEXT("Changed Health on %s, Health: %f"), *Props.TargetAvatarActor->GetName(), GetHealth());
|
||||
}
|
||||
if (Data.EvaluatedData.Attribute == GetManaAttribute())
|
||||
{
|
||||
//If the value being modified is Mana
|
||||
SetMana(FMath::Clamp(GetMana(), 0.f, GetMaxMana()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user