Don't drink and code.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "AbilitySystem/AuraAbilitySystemLibrary.h"
|
||||
|
||||
#include "Game/AuraGameMode.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "Player/AuraPlayerState.h"
|
||||
#include "UI/WidgetController/AuraWidgetController.h"
|
||||
@@ -40,3 +41,29 @@ UAttributeMenuWidgetController* UAuraAbilitySystemLibrary::GetAttributeMenuWidge
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void UAuraAbilitySystemLibrary::InitializeDefaultAttributes(const UObject* WorldContextObject, ECharacterClass CharacterClass, float Level, UAbilitySystemComponent* ASC)
|
||||
{
|
||||
AAuraGameMode* AuraGameMode = Cast<AAuraGameMode>(UGameplayStatics::GetGameMode(WorldContextObject));
|
||||
if (AuraGameMode == nullptr) return;
|
||||
|
||||
const AActor* AvatarActor = ASC->GetAvatarActor();
|
||||
|
||||
UCharacterClassInfo* CharacterClassInfo = AuraGameMode->CharacterClassInfo;
|
||||
const FCharacterClassDefaultInfo ClassDefaultInfo = CharacterClassInfo->GetClassDefaultInfo(CharacterClass);
|
||||
|
||||
FGameplayEffectContextHandle PrimaryAttributesContextHandle = ASC->MakeEffectContext();
|
||||
PrimaryAttributesContextHandle.AddSourceObject(AvatarActor);
|
||||
const FGameplayEffectSpecHandle PrimaryAttributesSpecHandle = ASC->MakeOutgoingSpec(ClassDefaultInfo.PrimaryAttributes, Level, PrimaryAttributesContextHandle);
|
||||
ASC->ApplyGameplayEffectSpecToSelf(*PrimaryAttributesSpecHandle.Data.Get());
|
||||
|
||||
FGameplayEffectContextHandle SecondaryAttributesContextHandle = ASC->MakeEffectContext();
|
||||
SecondaryAttributesContextHandle.AddSourceObject(AvatarActor);
|
||||
const FGameplayEffectSpecHandle SecondaryAttributesSpecHandle = ASC->MakeOutgoingSpec(CharacterClassInfo->SecondaryAttributes, Level, SecondaryAttributesContextHandle);
|
||||
ASC->ApplyGameplayEffectSpecToSelf(*SecondaryAttributesSpecHandle.Data.Get());
|
||||
|
||||
FGameplayEffectContextHandle VitalAttributesContextHandle = ASC->MakeEffectContext();
|
||||
VitalAttributesContextHandle.AddSourceObject(AvatarActor);
|
||||
const FGameplayEffectSpecHandle VitalAttributesSpecHandle = ASC->MakeOutgoingSpec(CharacterClassInfo->VitalAttributes, Level, VitalAttributesContextHandle);
|
||||
ASC->ApplyGameplayEffectSpecToSelf(*VitalAttributesSpecHandle.Data.Get());
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "AbilitySystem/AuraAttributeSet.h"
|
||||
|
||||
#include "AbilitySystemBlueprintLibrary.h"
|
||||
#include "AudioMixerBlueprintLibrary.h"
|
||||
#include "GameplayEffectExtension.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "Net/UnrealNetwork.h"
|
||||
@@ -129,12 +130,23 @@ void UAuraAttributeSet::PostGameplayEffectExecute(const FGameplayEffectModCallba
|
||||
if (Data.EvaluatedData.Attribute == GetHealthAttribute())
|
||||
{
|
||||
SetHealth(FMath::Clamp(GetHealth(), 0.f, GetMaxHealth()));
|
||||
UE_LOG(LogTemp, Warning, TEXT("Changed Health on %s, Health: %f"), *Props.TargetAvatarActor->GetName(), GetHealth());
|
||||
//UE_LOG(LogTemp, Warning, TEXT("Changed Health on %s, Health: %f"), *Props.TargetAvatarActor->GetName(), GetHealth());
|
||||
}
|
||||
if (Data.EvaluatedData.Attribute == GetManaAttribute())
|
||||
{
|
||||
SetMana(FMath::Clamp(GetMana(), 0.f, GetMaxMana()));
|
||||
}
|
||||
if (Data.EvaluatedData.Attribute == GetIncomingDamageAttribute())
|
||||
{
|
||||
const float LocalIncomingDamage = GetIncomingDamage();
|
||||
SetIncomingDamage(0.f);
|
||||
if (LocalIncomingDamage > 0.f)
|
||||
{
|
||||
const float NewHealth = GetHealth()-LocalIncomingDamage;
|
||||
SetHealth(FMath::Clamp(NewHealth, 0, GetMaxHealth()));
|
||||
const bool bFatal = NewHealth <= 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*On_Rep for each stat
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "AbilitySystemBlueprintLibrary.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "AuraGameplayTags.h"
|
||||
#include "Actor/AuraProjectile.h"
|
||||
#include "Interact/CombatInterface.h"
|
||||
|
||||
@@ -42,9 +43,15 @@ void UAuraProjectileSpell::SpawnProjectile(const FVector ProjectileTargetLocatio
|
||||
|
||||
const UAbilitySystemComponent* SourceASC = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(GetAvatarActorFromActorInfo());
|
||||
const FGameplayEffectSpecHandle SpecHandle = SourceASC->MakeOutgoingSpec(DamageEffectClass, GetAbilityLevel(), SourceASC->MakeEffectContext());
|
||||
|
||||
const FAuraGameplayTags GameplayTags = FAuraGameplayTags::Get();
|
||||
const float ScaledDamage = Damage.GetValueAtLevel((GetAbilityLevel()));
|
||||
UAbilitySystemBlueprintLibrary::AssignTagSetByCallerMagnitude(SpecHandle, GameplayTags.Damage, ScaledDamage);
|
||||
|
||||
|
||||
Projectile->DamageEffectSpecHandle = SpecHandle;
|
||||
|
||||
UE_LOG(LogTemp,Warning,TEXT("Projectile - SourceASC %s - DamageEffectClass %s"), *SourceASC->GetName(), *DamageEffectClass->GetName());
|
||||
UE_LOG(LogTemp,Warning,TEXT("ScaledDamage %f"),ScaledDamage);
|
||||
Projectile->FinishSpawning(SpawnTransform);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ void AAuraProjectile::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent,
|
||||
{
|
||||
if (UAbilitySystemComponent* TargetASC = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(OtherActor))
|
||||
{
|
||||
UE_LOG(LogTemp,Warning,TEXT("Projectile - TargetASC %s - OtherActor %s"), *TargetASC->GetName(), *OtherActor->GetName());
|
||||
//UE_LOG(LogTemp,Warning,TEXT("Projectile - TargetASC %s - OtherActor %s"), *TargetASC->GetName(), *OtherActor->GetName());
|
||||
TargetASC->ApplyGameplayEffectSpecToSelf(*DamageEffectSpecHandle.Data.Get());
|
||||
}
|
||||
Destroy();
|
||||
|
||||
@@ -49,5 +49,8 @@ void FAuraGameplayTags::InitializeNativeGameplayTags()
|
||||
GameplayTags.Input_InputTag_E = UGameplayTagsManager::Get().AddNativeGameplayTag(FName("Input.InputTag.E"), FString("Input Tag - Input E"));
|
||||
GameplayTags.Input_InputTag_Shift = UGameplayTagsManager::Get().AddNativeGameplayTag(FName("Input.InputTag.Shift"), FString("Input Tag - Input Shift"));
|
||||
|
||||
|
||||
GameplayTags.Damage = UGameplayTagsManager::Get().AddNativeGameplayTag(FName("Damage"), FString("Setting Damage"));
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "Character/AuraEnemy.h"
|
||||
|
||||
#include "AbilitySystem/AuraAbilitySystemComponent.h"
|
||||
#include "AbilitySystem/AuraAbilitySystemLibrary.h"
|
||||
#include "AbilitySystem/AuraAttributeSet.h"
|
||||
#include "Aura/Aura.h"
|
||||
#include "Components/WidgetComponent.h"
|
||||
@@ -73,4 +74,9 @@ void AAuraEnemy::InitAbilityActorInfo()
|
||||
Cast<UAuraAbilitySystemComponent>(AbilitySystemComponent)->AbilityActorInfoSet();
|
||||
|
||||
InitializeDefaultAttributes();
|
||||
}
|
||||
}
|
||||
|
||||
void AAuraEnemy::InitializeDefaultAttributes() const
|
||||
{
|
||||
UAuraAbilitySystemLibrary::InitializeDefaultAttributes(this, CharacterClass, Level, AbilitySystemComponent);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user