NewVersion

This commit is contained in:
AncientTale
2026-03-29 10:11:17 +03:00
commit 47d4e4755b
18099 changed files with 77925 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class AFPrototype : ModuleRules
{
public AFPrototype(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[]
{
"Core",
"CoreUObject",
"Engine",
"InputCore",
"EnhancedInput",
"GameplayAbilities",
"GameplayTags",
"GameplayTasks",
"AIModule"
});
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}
+6
View File
@@ -0,0 +1,6 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "AFPrototype.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, AFPrototype, "AFPrototype" );
+6
View File
@@ -0,0 +1,6 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
+630
View File
@@ -0,0 +1,630 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "AFCharacter.h"
#include "GAS/MyAbilitySystemComponent.h"
// Sets default values
AAFCharacter::AAFCharacter()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
// Create ability system component, and set it to be explicitly replicated
AbilitySystemComponent = CreateDefaultSubobject<UMyAbilitySystemComponent>("AbilitySystemComponent");
AbilitySystemComponent->SetIsReplicated(true);
// Create the attribute set, this replicates by default
AttributeSet = CreateDefaultSubobject<UAFAttributeSet>("AttributeSet");
CharacterLevel = 1;
}
int32 AAFCharacter::GetCharacterLevel() const
{
return CharacterLevel;
}
float AAFCharacter::GetHealth() const
{
if(!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetHealth();
}
float AAFCharacter::GetMaxHealth() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetMaxHealth();
}
float AAFCharacter::GetMana() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetMana();
}
float AAFCharacter::GetMaxMana() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetMaxMana();
}
float AAFCharacter::GetStamina() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetStamina();
}
float AAFCharacter::GetMaxStamina() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetMaxStamina();
}
float AAFCharacter::GetStagger() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetStagger();
}
float AAFCharacter::GetMaxStagger() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetMaxStagger();
}
float AAFCharacter::GetStun() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetStun() ;
}
float AAFCharacter::GetMaxStun() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetMaxStun();
}
float AAFCharacter::GetKnockdown() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetKnockdown();
}
float AAFCharacter::GetMaxKnockdown() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetMaxKnockdown();
}
float AAFCharacter::GetExperiencePoints() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetExperiencePoints();
}
float AAFCharacter::GetMaxExperiencePoints() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetMaxExperiencePoints();
}
float AAFCharacter::GetStormMana() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetStormMana();
}
float AAFCharacter::GetMaxStormMana() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetMaxStormMana();
}
float AAFCharacter::GetFormPoint() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetFormPoint();
}
float AAFCharacter::GetMaxFormPoint() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetMaxFormPoint();
}
float AAFCharacter::GetBrave() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetBrave();
}
float AAFCharacter::GetMaxBrave() const
{
if (!AttributeSet)
{
return 0.0f;
}
return AttributeSet->GetMaxBrave();
}
bool AAFCharacter::ActivateAbilitiesWithTag(FGameplayTagContainer AbilityTags, bool AllowRemoteActivation)
{
if (!AbilitySystemComponent)
{
return false;
}
return AbilitySystemComponent->TryActivateAbilitiesByTag(AbilityTags, AllowRemoteActivation);
}
bool AAFCharacter::ActivateMelleAbility(bool AllowRemoteActivation)
{
if (!AbilitySystemComponent || !MeleeAbilitySpecHandle.IsValid())
{
return false;
}
return AbilitySystemComponent->TryActivateAbility(MeleeAbilitySpecHandle);
}
void AAFCharacter::GetActiveAbilitiesWithTag(FGameplayTagContainer AbilityTags, TArray<UGameplayAbility*>& ActiveAbilities, bool MatchExactTag)
{
if (!AbilitySystemComponent)
{
return;
}
TArray<FGameplayAbilitySpec*> MatchingAbilities;
AbilitySystemComponent->GetActivatableGameplayAbilitySpecsByAllMatchingTags(AbilityTags, MatchingAbilities, MatchExactTag);
for (FGameplayAbilitySpec* Spec : MatchingAbilities)
{
TArray<UGameplayAbility*> AbilityInstances = Spec->GetAbilityInstances();
for (UGameplayAbility* ActiveAbility : AbilityInstances)
{
ActiveAbilities.Add(ActiveAbility);
}
}
}
void AAFCharacter::ApplyGameplayEffect(TSubclassOf<UGameplayEffect> GameplayEffect)
{
if (!AbilitySystemComponent || !GameplayEffect)
{
return;
}
FGameplayEffectContextHandle EffectContext = AbilitySystemComponent->MakeEffectContext();
EffectContext.AddSourceObject(this);
FGameplayEffectSpecHandle NewHandle = AbilitySystemComponent->MakeOutgoingSpec(GameplayEffect, CharacterLevel, EffectContext);
if (NewHandle.IsValid())
{
FActiveGameplayEffectHandle ActiveHandle = AbilitySystemComponent->ApplyGameplayEffectSpecToTarget(*NewHandle.Data.Get(), AbilitySystemComponent);
}
}
bool AAFCharacter::CanApplyGameplayEffect(TSubclassOf<UGameplayEffect> GameplayEffect)
{
if (!AbilitySystemComponent || !GameplayEffect)
{
return false;
}
FGameplayEffectContextHandle EffectContext = AbilitySystemComponent->MakeEffectContext();
EffectContext.AddSourceObject(this);
return AbilitySystemComponent->CanApplyAttributeModifiers(GameplayEffect->GetDefaultObject<UGameplayEffect>(), CharacterLevel, EffectContext);
}
bool AAFCharacter::EquipWeapon(AAFWeapon* Weapon, TEnumAsByte<EWeaponSlot> EquipSlot)
{
if (!Weapon)
{
return false;
}
switch (EquipSlot)
{
case EWeaponSlot::RightHand:
EquipRightHand(Weapon);
break;
case EWeaponSlot::LeftHand:
EquipLeftHand(Weapon);
break;
default:
break;
}
return true;
}
bool AAFCharacter::ActivateAbilityBySlot(TEnumAsByte<EAbilitySlot> AbilitySlot, bool AllowRemoteActivation)
{
if (!AbilitySystemComponent || !SlotAbilityHandles.Contains(AbilitySlot))
{
return false;
}
FGameplayAbilitySpecHandle* SpecHandle = SlotAbilityHandles.Find(AbilitySlot);
return AbilitySystemComponent->TryActivateAbility(FGameplayAbilitySpecHandle(*SpecHandle), AllowRemoteActivation);
}
// Called when the game starts or when spawned
void AAFCharacter::BeginPlay()
{
Super::BeginPlay();
}
void AAFCharacter::SetTestAbilies()
{
if (!AbilitySystemComponent)
{
return;
}
if (GetLocalRole() == ROLE_Authority)
{
for (TSubclassOf<UGameplayAbility>& TestAbility : TestAbilities)
{
AbilitySystemComponent->GiveAbility(FGameplayAbilitySpec(TestAbility, GetCharacterLevel(), INDEX_NONE, this));
}
}
}
void AAFCharacter::SetMeleeAbility()
{
if (!AbilitySystemComponent)
{
return;
}
MeleeAbilitySpecHandle = AbilitySystemComponent->GiveAbility(FGameplayAbilitySpec(MeleeAbility, GetCharacterLevel(), INDEX_NONE, this));
}
// Called every frame
void AAFCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void AAFCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
void AAFCharacter::PossessedBy(AController* NewController)
{
Super::PossessedBy(NewController);
TeamId = FGenericTeamId(Fraction);
if (!AbilitySystemComponent)
{
return;
}
if (EnableTestAbilities)
{
SetTestAbilies();
}
ApplyDefaultAttributesEffect();
SetMeleeAbility();
}
UAbilitySystemComponent* AAFCharacter::GetAbilitySystemComponent() const
{
return AbilitySystemComponent;
}
void AAFCharacter::HandleHealthChange(float DeltaValue, AActor* Causer)
{
OnHealthChanged(DeltaValue, Causer);
if (GetHealth() <= 0)
{
OnDead();
}
}
void AAFCharacter::HandleStaminaChange(float DeltaValue, AActor* Causer)
{
OnStaminaChanged(DeltaValue, Causer);
}
void AAFCharacter::HandleManaChange(float DeltaValue, AActor* Causer)
{
OnManaChanged(DeltaValue, Causer);
if (GetMana() >= 200)
{
OnOverload();
}
}
void AAFCharacter::HandleStaggerChange(float DeltaValue, AActor* Causer)
{
OnStaggerChanged(DeltaValue, Causer);
if (GetStagger() >= 100)
{
OnStaggered();
}
}
void AAFCharacter::HandleStunChange(float DeltaValue, AActor* Causer)
{
OnStunChanged(DeltaValue, Causer);
if (GetStun() >= 100)
{
OnStuned();
}
}
void AAFCharacter::HandleKnockdownChange(float DeltaValue, AActor* Causer)
{
OnKnockdownChanged(DeltaValue, Causer);
if (GetKnockdown() >= 100)
{
OnKnockdowned();
}
}
void AAFCharacter::HandleStormManaChange(float DeltaValue, AActor* Causer)
{
OnStormManaChanged(DeltaValue, Causer);
if (GetStormMana() >= 100)
{
OnStormOverload();
}
}
void AAFCharacter::HandleFormPointChange(float DeltaValue, AActor* Causer)
{
OnFormPointChanged(DeltaValue, Causer);
}
void AAFCharacter::HandleExperiencePointsChange(float DeltaValue)
{
OnXPChanged(DeltaValue);
}
void AAFCharacter::HandleBraveChange(float DeltaValue, AActor* Causer)
{
OnBraveChanged(DeltaValue, Causer);
}
void AAFCharacter::HandleCharacterLevelUp()
{
CharacterLevel += 1;
RemoveDefaultAttributesEffect();
ApplyDefaultAttributesEffect();
OnCharacterLevelUp();
}
void AAFCharacter::ApplyDefaultAttributesEffect()
{
FGameplayEffectContextHandle EffectContext = AbilitySystemComponent->MakeEffectContext();
EffectContext.AddSourceObject(this);
for (TSubclassOf<class UGameplayEffect>& DefaultEffect : DefaultAttributeEffects)
{
FGameplayEffectSpecHandle NewHandle = AbilitySystemComponent->MakeOutgoingSpec(DefaultEffect, CharacterLevel, EffectContext);
if (NewHandle.IsValid())
{
FActiveGameplayEffectHandle ActiveHandle = AbilitySystemComponent->ApplyGameplayEffectSpecToTarget(*NewHandle.Data.Get(), AbilitySystemComponent);
}
}
}
void AAFCharacter::RemoveDefaultAttributesEffect()
{
FGameplayEffectQuery Query;
Query.EffectSource = this;
AbilitySystemComponent->RemoveActiveEffects(Query);
}
void AAFCharacter::GetOwnedGameplayTags(FGameplayTagContainer& TagContainer) const
{
if(AbilitySystemComponent)
{
AbilitySystemComponent->GetOwnedGameplayTags(TagContainer);
}
}
FGenericTeamId AAFCharacter::GetGenericTeamId() const
{
return TeamId;
}
void AAFCharacter::ClearAbilitySlot(TEnumAsByte<EAbilitySlot> AbilitySlot)
{
if (SlotAbilityHandles.IsEmpty())
{
return;
}
if (SlotAbilityHandles.Contains(AbilitySlot))
{
FGameplayAbilitySpecHandle* SpecHandle = SlotAbilityHandles.Find(AbilitySlot);
AbilitySystemComponent->ClearAbility(*SpecHandle);
SlotAbilityHandles.Remove(AbilitySlot);
}
}
void AAFCharacter::AddAbilityToSlot(TSubclassOf<UGameplayAbility> NewAbility, TEnumAsByte<EAbilitySlot> AbilitySlot)
{
if (!AbilitySystemComponent)
{
return;
}
FGameplayAbilitySpecHandle SpecHandle = AbilitySystemComponent->GiveAbility(FGameplayAbilitySpec(NewAbility, GetCharacterLevel(), INDEX_NONE, this));
if (SpecHandle.IsValid())
{
SlotAbilityHandles.Add(AbilitySlot, SpecHandle);
}
}
void AAFCharacter::EquipRightHand(AAFWeapon* Weapon)
{
if (!AbilitySystemComponent || !Weapon)
{
return;
}
ClearAbilitySlot(EAbilitySlot::LightAttack);
ClearAbilitySlot(EAbilitySlot::HeavyAttack);
ClearAbilitySlot(EAbilitySlot::SpecialAttack);
ClearAbilitySlot(EAbilitySlot::SecondaryAbility);
ClearAbilitySlot(EAbilitySlot::DectosAbility);
ClearAbilitySlot(EAbilitySlot::SecondDectosAbility);
ClearAbilitySlot(EAbilitySlot::SpecAbility);
ClearAbilitySlot(EAbilitySlot::LightStaggerAttack);
ClearAbilitySlot(EAbilitySlot::HeavyStaggerAttack);
ClearAbilitySlot(EAbilitySlot::ManaAdd);
ClearAbilitySlot(EAbilitySlot::Dodge);
ClearAbilitySlot(EAbilitySlot::Roll);
ClearAbilitySlot(EAbilitySlot::Block);
ClearAbilitySlot(EAbilitySlot::Parry);
ClearAbilitySlot(EAbilitySlot::AirAttack);
ClearAbilitySlot(EAbilitySlot::Combo1);
ClearAbilitySlot(EAbilitySlot::Combo2);
ClearAbilitySlot(EAbilitySlot::Combo3);
ClearAbilitySlot(EAbilitySlot::Gimmick1);
ClearAbilitySlot(EAbilitySlot::Gimmick2);
AddAbilityToSlot(Weapon->LightAttackAbility, EAbilitySlot::LightAttack);
AddAbilityToSlot(Weapon->HeavyAttackAbility, EAbilitySlot::HeavyAttack);
AddAbilityToSlot(Weapon->SpecialAttackAbility, EAbilitySlot::SpecialAttack);
AddAbilityToSlot(Weapon->SecondaryAbility, EAbilitySlot::SecondaryAbility);
AddAbilityToSlot(Weapon->DectosAbility, EAbilitySlot::DectosAbility);
AddAbilityToSlot(Weapon->SecondaryAbility, EAbilitySlot::SecondDectosAbility);
AddAbilityToSlot(Weapon->DectosAbility, EAbilitySlot::SpecAbility);
AddAbilityToSlot(Weapon->LightStaggerAttackAbility, EAbilitySlot::LightStaggerAttack);
AddAbilityToSlot(Weapon->HeavyStaggerAttackAbility, EAbilitySlot::HeavyStaggerAttack);
AddAbilityToSlot(Weapon->ManaAddAbility, EAbilitySlot::ManaAdd);
AddAbilityToSlot(Weapon->DodgeAbility, EAbilitySlot::Dodge);
AddAbilityToSlot(Weapon->RollAbility, EAbilitySlot::Roll);
AddAbilityToSlot(Weapon->BlockAbility, EAbilitySlot::Block);
AddAbilityToSlot(Weapon->ParryAbility, EAbilitySlot::Parry);
AddAbilityToSlot(Weapon->AirAttackAbility, EAbilitySlot::AirAttack);
AddAbilityToSlot(Weapon->Combo1Ability, EAbilitySlot::Combo1);
AddAbilityToSlot(Weapon->Combo2Ability, EAbilitySlot::Combo2);
AddAbilityToSlot(Weapon->Combo3Ability, EAbilitySlot::Combo3);
AddAbilityToSlot(Weapon->Gimmick1Ability, EAbilitySlot::Gimmick1);
AddAbilityToSlot(Weapon->Gimmick2Ability, EAbilitySlot::Gimmick2);
}
void AAFCharacter::EquipLeftHand(AAFWeapon* Weapon)
{
if (!AbilitySystemComponent || !Weapon)
{
return;
}
ClearAbilitySlot(EAbilitySlot::LightAttack);
ClearAbilitySlot(EAbilitySlot::HeavyAttack);
ClearAbilitySlot(EAbilitySlot::SpecialAttack);
ClearAbilitySlot(EAbilitySlot::SecondaryAbility);
ClearAbilitySlot(EAbilitySlot::Dodge);
ClearAbilitySlot(EAbilitySlot::Block);
ClearAbilitySlot(EAbilitySlot::Parry);
ClearAbilitySlot(EAbilitySlot::Combo1);
ClearAbilitySlot(EAbilitySlot::Combo2);
ClearAbilitySlot(EAbilitySlot::Combo3);
AddAbilityToSlot(Weapon->LightAttackAbility, EAbilitySlot::LightAttack);
AddAbilityToSlot(Weapon->HeavyAttackAbility, EAbilitySlot::HeavyAttack);
AddAbilityToSlot(Weapon->SpecialAttackAbility, EAbilitySlot::SpecialAttack);
AddAbilityToSlot(Weapon->SecondaryAbility, EAbilitySlot::SecondaryAbility);
AddAbilityToSlot(Weapon->DodgeAbility, EAbilitySlot::Dodge);
AddAbilityToSlot(Weapon->BlockAbility, EAbilitySlot::Block);
AddAbilityToSlot(Weapon->ParryAbility, EAbilitySlot::Parry);
AddAbilityToSlot(Weapon->Combo1Ability, EAbilitySlot::Combo1);
AddAbilityToSlot(Weapon->Combo2Ability, EAbilitySlot::Combo2);
AddAbilityToSlot(Weapon->Combo3Ability, EAbilitySlot::Combo3);
}
+64
View File
@@ -0,0 +1,64 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "AFWeapon.h"
#include "GAS/MyAbilitySystemComponent.h"
#include <AFCharacter.h>
// Sets default values
AAFWeapon::AAFWeapon()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
AbilitySystemComponent = CreateDefaultSubobject< UMyAbilitySystemComponent>("AbilitySystemComponent");
AbilitySystemComponent->SetIsReplicated(true);
AttributeSet = CreateDefaultSubobject<UAfWeaponAttributeSet>("AttributeSet");
}
void AAFWeapon::ApplyWeaponEffects()
{
if(!AbilitySystemComponent || WeaponEffects.IsEmpty())
{
return;
}
FGameplayEffectContextHandle EffectContext = AbilitySystemComponent->MakeEffectContext();
EffectContext.AddSourceObject(this);
for (TSubclassOf<UGameplayEffect>GameplayEffect : WeaponEffects)
{
FGameplayEffectSpecHandle NewHandle = AbilitySystemComponent->MakeOutgoingSpec(GameplayEffect, WeaponLevel, EffectContext);
if (NewHandle.IsValid())
{
FActiveGameplayEffectHandle ActiveHandle = AbilitySystemComponent->ApplyGameplayEffectSpecToTarget(*NewHandle.Data.Get(), AbilitySystemComponent);
}
}
}
float AAFWeapon::GetBaseDamage()
{
return AttributeSet ? AttributeSet->GetBaseDamage() : 0.0f;
}
// Called when the game starts or when spawned
void AAFWeapon::BeginPlay()
{
Super::BeginPlay();
ApplyWeaponEffects();
}
// Called every frame
void AAFWeapon::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
UAbilitySystemComponent* AAFWeapon::GetAbilitySystemComponent() const
{
return AbilitySystemComponent;
}
@@ -0,0 +1,343 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "GAS/AFAttributeSet.h"
#include "Net/UnrealNetwork.h"
#include "GameplayEffect.h"
#include "GameplayEffectExtension.h"
#include "AFCharacter.h"
UAFAttributeSet::UAFAttributeSet()
{
}
void UAFAttributeSet::PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue)
{
Super::PreAttributeChange(Attribute, NewValue);
if (Attribute == GetMaxHealthAttribute())
{
AdjustAttributeForMaxChange(Health, MaxHealth, NewValue, GetHealthAttribute());
}
if (Attribute == GetMaxStaminaAttribute())
{
AdjustAttributeForMaxChange(Stamina, MaxStamina, NewValue, GetStaminaAttribute());
}
if (Attribute == GetMaxManaAttribute())
{
SetMana(0.f);
}
if (Attribute == GetMaxStaggerAttribute())
{
SetStagger(0.f);
}
if (Attribute == GetMaxStunAttribute())
{
SetStun(0.f);
}
if (Attribute == GetMaxKnockdownAttribute())
{
SetKnockdown(0.f);
}
if (Attribute == GetMaxExperiencePointsAttribute())
{
SetExperiencePoints(0.f);
}
if (Attribute == GetMaxStormManaAttribute())
{
SetStormMana(0.f);
}
if (Attribute == GetMaxFormPointAttribute())
{
SetFormPoint(0.f);
}
if (Attribute == GetMaxBraveAttribute())
{
AdjustAttributeForMaxChange(Brave, MaxBrave, NewValue, GetBraveAttribute());
}
}
void UAFAttributeSet::PostGameplayEffectExecute(const FGameplayEffectModCallbackData& Data)
{
Super::PostGameplayEffectExecute(Data);
float DeltaValue = 0;
if (Data.EvaluatedData.ModifierOp == EGameplayModOp::Additive)
{
DeltaValue = Data.EvaluatedData.Magnitude;
}
AActor* TargetActor = nullptr;
AAFCharacter* AFCharacter = nullptr;
if (Data.Target.AbilityActorInfo.IsValid() && Data.Target.AbilityActorInfo->AvatarActor.IsValid())
{
TargetActor = Data.Target.AbilityActorInfo->AvatarActor.Get();
AFCharacter = Cast<AAFCharacter>(TargetActor);
}
if (Data.EvaluatedData.Attribute == GetHealthAttribute())
{
SetHealth(FMath::Clamp(GetHealth(), 0.0f, GetMaxHealth()));
if (AFCharacter)
{
AFCharacter->HandleHealthChange(DeltaValue, Data.EffectSpec.GetContext().GetInstigator());
}
}
if (Data.EvaluatedData.Attribute == GetStaminaAttribute())
{
bool StaminaOverflow = GetStamina() > GetMaxStamina() ? FMath::IsNearlyEqual(GetStamina() - DeltaValue, GetMaxStamina()) : false;
SetStamina(FMath::Clamp(GetStamina(), 0.0f, GetMaxStamina()));
if (AFCharacter && !StaminaOverflow)
{
AFCharacter->HandleStaminaChange(DeltaValue, Data.EffectSpec.GetContext().GetInstigator());
}
}
if (Data.EvaluatedData.Attribute == GetManaAttribute())
{
SetMana(FMath::Clamp(GetMana(), 0.0f, GetMaxMana()));
if (AFCharacter)
{
AFCharacter->HandleManaChange(DeltaValue, Data.EffectSpec.GetContext().GetInstigator());
}
}
if (Data.EvaluatedData.Attribute == GetStaggerAttribute())
{
SetStagger(FMath::Clamp(GetStagger(), 0.0f, GetMaxStagger()));
if (AFCharacter)
{
AFCharacter->HandleStaggerChange(DeltaValue, Data.EffectSpec.GetContext().GetInstigator());
}
}
if (Data.EvaluatedData.Attribute == GetStunAttribute())
{
SetStun(FMath::Clamp(GetStun(), 0.0f, GetMaxStun()));
if (AFCharacter)
{
AFCharacter->HandleStunChange(DeltaValue, Data.EffectSpec.GetContext().GetInstigator());
}
}
if (Data.EvaluatedData.Attribute == GetKnockdownAttribute())
{
SetKnockdown(FMath::Clamp(GetKnockdown(), 0.0f, GetMaxKnockdown()));
if (AFCharacter)
{
AFCharacter->HandleKnockdownChange(DeltaValue, Data.EffectSpec.GetContext().GetInstigator());
}
}
if (Data.EvaluatedData.Attribute == GetExperiencePointsAttribute())
{
float Difference = GetExperiencePoints() - GetMaxExperiencePoints();
if (AFCharacter && Difference >= 0)
{
AFCharacter->HandleExperiencePointsChange(DeltaValue);
if (Difference >= 0)
{
AFCharacter->HandleCharacterLevelUp();
}
}
}
if (Data.EvaluatedData.Attribute == GetStormManaAttribute())
{
SetStormMana(FMath::Clamp(GetStormMana(), 0.0f, GetMaxStormMana()));
if (AFCharacter)
{
AFCharacter->HandleStormManaChange(DeltaValue, Data.EffectSpec.GetContext().GetInstigator());
}
}
if (Data.EvaluatedData.Attribute == GetFormPointAttribute())
{
SetFormPoint(FMath::Clamp(GetFormPoint(), 0.0f, GetMaxFormPoint()));
if (AFCharacter)
{
AFCharacter->HandleFormPointChange(DeltaValue, Data.EffectSpec.GetContext().GetInstigator());
}
}
if (Data.EvaluatedData.Attribute == GetBraveAttribute())
{
bool BraveOverflow = GetBrave() > GetMaxBrave() ? FMath::IsNearlyEqual(GetBrave() - DeltaValue, GetMaxBrave()) : false;
SetBrave(FMath::Clamp(GetBrave(), 0.0f, GetMaxBrave()));
if (AFCharacter && !BraveOverflow)
{
AFCharacter->HandleBraveChange(DeltaValue, Data.EffectSpec.GetContext().GetInstigator());
}
}
}
void UAFAttributeSet::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
DOREPLIFETIME(UAFAttributeSet, Health);
DOREPLIFETIME(UAFAttributeSet, MaxHealth);
DOREPLIFETIME(UAFAttributeSet, Mana);
DOREPLIFETIME(UAFAttributeSet, MaxMana);
DOREPLIFETIME(UAFAttributeSet, Stamina);
DOREPLIFETIME(UAFAttributeSet, MaxStamina);
DOREPLIFETIME(UAFAttributeSet, Stagger);
DOREPLIFETIME(UAFAttributeSet, MaxStagger);
DOREPLIFETIME(UAFAttributeSet, Stun);
DOREPLIFETIME(UAFAttributeSet, MaxStun);
DOREPLIFETIME(UAFAttributeSet, Knockdown);
DOREPLIFETIME(UAFAttributeSet, MaxKnockdown);
DOREPLIFETIME(UAFAttributeSet, ExperiencePoints);
DOREPLIFETIME(UAFAttributeSet, MaxExperiencePoints);
DOREPLIFETIME(UAFAttributeSet, StormMana);
DOREPLIFETIME(UAFAttributeSet, MaxStormMana);
DOREPLIFETIME(UAFAttributeSet, FormPoint);
DOREPLIFETIME(UAFAttributeSet, MaxFormPoint);
DOREPLIFETIME(UAFAttributeSet, BaseDamage);
DOREPLIFETIME(UAFAttributeSet, BaseResistance);
DOREPLIFETIME(UAFAttributeSet, EnergyDamage);
DOREPLIFETIME(UAFAttributeSet, EnergyResistance);
DOREPLIFETIME(UAFAttributeSet, Brave);
DOREPLIFETIME(UAFAttributeSet, MaxBrave);
}
void UAFAttributeSet::AdjustAttributeForMaxChange(FGameplayAttributeData& AffectedAttribute, const FGameplayAttributeData& MaxAttribute, float NewMaxValue, const FGameplayAttribute& AffectedAttributProperty)
{
UAbilitySystemComponent* AbilitySyestemComponent = GetOwningAbilitySystemComponent();
const float CurrentMaxValue = MaxAttribute.GetCurrentValue();
if (!FMath::IsNearlyEqual(CurrentMaxValue, NewMaxValue) && AbilitySyestemComponent)
{
AbilitySyestemComponent->ApplyModToAttributeUnsafe(AffectedAttributProperty, EGameplayModOp::Override, NewMaxValue);
}
}
void UAFAttributeSet::OnRep_Health(const FGameplayAttributeData& OldHealth)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, Health, OldHealth);
}
void UAFAttributeSet::OnRep_MaxHealth(const FGameplayAttributeData& OldMaxHealth)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, MaxHealth, OldMaxHealth);
}
void UAFAttributeSet::OnRep_Mana(const FGameplayAttributeData& OldMana)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, Mana, OldMana);
}
void UAFAttributeSet::OnRep_MaxMana(const FGameplayAttributeData& OldMaxMana)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, MaxMana, OldMaxMana);
}
void UAFAttributeSet::OnRep_Stamina(const FGameplayAttributeData& OldStamina)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, Stamina, OldStamina);
}
void UAFAttributeSet::OnRep_MaxStamina(const FGameplayAttributeData& OldMaxStamina)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, MaxStamina, OldMaxStamina);
}
void UAFAttributeSet::OnRep_Stagger(const FGameplayAttributeData& OldStagger)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, Stagger, OldStagger);
}
void UAFAttributeSet::OnRep_MaxStagger(const FGameplayAttributeData& OldMaxStagger)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, MaxStagger, OldMaxStagger);
}
void UAFAttributeSet::OnRep_Stun(const FGameplayAttributeData& OldStun)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, Stun, OldStun);
}
void UAFAttributeSet::OnRep_MaxStun(const FGameplayAttributeData& OldMaxStun)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, MaxStun, OldMaxStun);
}
void UAFAttributeSet::OnRep_Knockdown(const FGameplayAttributeData& OldKnockdown)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, Knockdown, OldKnockdown);
}
void UAFAttributeSet::OnRep_MaxKnockdown(const FGameplayAttributeData& OldMaxKnockdown)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, MaxKnockdown, OldMaxKnockdown);
}
void UAFAttributeSet::OnRep_ExperiencePoints(const FGameplayAttributeData& OldExperiencePoints)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, ExperiencePoints, OldExperiencePoints);
}
void UAFAttributeSet::OnRep_MaxExperiencePoints(const FGameplayAttributeData& OldMaxExperiencePoints)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, MaxExperiencePoints, OldMaxExperiencePoints);
}
void UAFAttributeSet::OnRep_FormPoint(const FGameplayAttributeData& OldFormPoint)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, FormPoint, OldFormPoint);
}
void UAFAttributeSet::OnRep_MaxFormPoint(const FGameplayAttributeData& OldMaxFormPoint)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, MaxFormPoint, OldMaxFormPoint);
}
void UAFAttributeSet::OnRep_StormMana(const FGameplayAttributeData& OldStormMana)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, StormMana, OldStormMana);
}
void UAFAttributeSet::OnRep_MaxStormMana(const FGameplayAttributeData& OldMaxStormMana)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, MaxStormMana, OldMaxStormMana);
}
void UAFAttributeSet::OnRep_BaseDamage(const FGameplayAttributeData& OldBaseDamage)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, BaseDamage, OldBaseDamage);
}
void UAFAttributeSet::OnRep_BaseResistance(const FGameplayAttributeData& OldBaseResistance)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, BaseResistance, OldBaseResistance);
}
void UAFAttributeSet::OnRep_EnergyDamage(const FGameplayAttributeData& OldEnergyDamage)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, EnergyDamage, OldEnergyDamage);
}
void UAFAttributeSet::OnRep_EnergyResistance(const FGameplayAttributeData& OldEnergyResistance)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, EnergyResistance, OldEnergyResistance);
}
void UAFAttributeSet::OnRep_Brave(const FGameplayAttributeData& OldBrave)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, Brave, OldBrave);
}
void UAFAttributeSet::OnRep_MaxBrave(const FGameplayAttributeData& OldMaxBrave)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAFAttributeSet, MaxBrave, OldMaxBrave);
}
@@ -0,0 +1,37 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "GAS/AfWeaponAttributeSet.h"
#include "Net/UnrealNetwork.h"
UAfWeaponAttributeSet::UAfWeaponAttributeSet()
{
}
void UAfWeaponAttributeSet::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
DOREPLIFETIME(UAfWeaponAttributeSet, BaseDamage);
DOREPLIFETIME(UAfWeaponAttributeSet, BaseResistance);
DOREPLIFETIME(UAfWeaponAttributeSet, EnergyDamage);
DOREPLIFETIME(UAfWeaponAttributeSet, EnergyResistance);
}
void UAfWeaponAttributeSet::OnRep_BaseDamage(const FGameplayAttributeData& OldBaseDamage)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAfWeaponAttributeSet, BaseDamage, OldBaseDamage);
}
void UAfWeaponAttributeSet::OnRep_BaseResistance(const FGameplayAttributeData& OldBaseResistance)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAfWeaponAttributeSet, BaseResistance, OldBaseResistance);
}
void UAfWeaponAttributeSet::OnRep_EnergyDamage(const FGameplayAttributeData& OldEnergyDamage)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAfWeaponAttributeSet, EnergyDamage, OldEnergyDamage);
}
void UAfWeaponAttributeSet::OnRep_EnergyResistance(const FGameplayAttributeData& OldEnergyResistance)
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAfWeaponAttributeSet, EnergyResistance, OldEnergyResistance);
}
@@ -0,0 +1,105 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "GAS/DamageExecutionCalculation.h"
#include "GAS/AFAttributeSet.h"
#include "AbilitySystemComponent.h"
struct BaseDamageStatics
{
DECLARE_ATTRIBUTE_CAPTUREDEF(BaseDamage);
DECLARE_ATTRIBUTE_CAPTUREDEF(BaseResistance);
DECLARE_ATTRIBUTE_CAPTUREDEF(Health);
BaseDamageStatics()
{
DEFINE_ATTRIBUTE_CAPTUREDEF(UAFAttributeSet, BaseDamage, Source, true);
DEFINE_ATTRIBUTE_CAPTUREDEF(UAFAttributeSet, BaseResistance, Target, true);
DEFINE_ATTRIBUTE_CAPTUREDEF(UAFAttributeSet, Health, Target, false);
}
};
static const BaseDamageStatics& GetBaseDamageStatics()
{
static BaseDamageStatics DmgStatics;
return DmgStatics;
}
UDamageExecutionCalculation::UDamageExecutionCalculation()
{
RelevantAttributesToCapture.Add(GetBaseDamageStatics().BaseDamageDef);
RelevantAttributesToCapture.Add(GetBaseDamageStatics().BaseResistanceDef);
}
void UDamageExecutionCalculation::Execute_Implementation(const FGameplayEffectCustomExecutionParameters& ExecutionParams, OUT FGameplayEffectCustomExecutionOutput& OutExecutionOutput) const
{
UAbilitySystemComponent* TargetAbilitySystemComponent = ExecutionParams.GetTargetAbilitySystemComponent();
UAbilitySystemComponent* SourceAbilitySystemComponent = ExecutionParams.GetSourceAbilitySystemComponent();
AActor* SourceActor = SourceAbilitySystemComponent ? SourceAbilitySystemComponent->GetAvatarActor_Direct() : nullptr;
AActor* TargetActor = TargetAbilitySystemComponent ? TargetAbilitySystemComponent->GetAvatarActor_Direct() : nullptr;
const FGameplayEffectSpec& Spec = ExecutionParams.GetOwningSpec();
const FGameplayTagContainer* SourceTags = Spec.CapturedSourceTags.GetAggregatedTags();
const FGameplayTagContainer* TargetTags = Spec.CapturedTargetTags.GetAggregatedTags();
FAggregatorEvaluateParameters EvaluationParameters;
EvaluationParameters.SourceTags = SourceTags;
EvaluationParameters.TargetTags = TargetTags;
float BaseDamage = 0.f;
ExecutionParams.AttemptCalculateCapturedAttributeMagnitude(GetBaseDamageStatics().BaseDamageDef, EvaluationParameters, BaseDamage);
float WeaponDamage = GetWeaponDamage(SourceActor);
float BaseResistance = 0.f;
ExecutionParams.AttemptCalculateCapturedAttributeMagnitude(GetBaseDamageStatics().BaseResistanceDef, EvaluationParameters, BaseResistance);
if (BaseResistance == 0.0f)
{
BaseResistance = 1.0f;
}
float BlockAbscorption = GetBlockAbscorption(TargetActor);
float DamageDone = GetDamageMagnitude(SourceActor) * (BaseDamage + WeaponDamage) * (1 - (BaseResistance / 100)) * (1 - (BlockAbscorption / 100));
if (DamageDone > 0)
{
OutExecutionOutput.AddOutputModifier(FGameplayModifierEvaluatedData(GetBaseDamageStatics().HealthProperty, EGameplayModOp::Additive, -DamageDone));
const_cast <UDamageExecutionCalculation*>(this)->OnDamageDone(SourceActor, TargetActor, DamageDone);
}
else
{
const_cast <UDamageExecutionCalculation*>(this)->OnFullDamageAbsorbed(SourceActor, TargetActor);
}
}
float UDamageExecutionCalculation::GetDamageMagnitude_Implementation(AActor* SourceActor) const
{
return 1.f;
}
float UDamageExecutionCalculation::GetWeaponDamage_Implementation(AActor* SourceActor) const
{
return 0.0f;
}
float UDamageExecutionCalculation::GetBlockAbscorption_Implementation(AActor* TargetActor) const
{
return 0.0f;
}
void UDamageExecutionCalculation::OnFullDamageAbsorbed_Implementation(AActor* SourceActor, AActor* TargetActor) const
{
UE_LOG(LogTemp, Log, TEXT("Full Base Damage from %s Absorbed: by %s"), *SourceActor->GetName(), *TargetActor->GetName());
}
void UDamageExecutionCalculation::OnDamageDone_Implementation(AActor* SourceActor, AActor* TargetActor, float Damage) const
{
UE_LOG(LogTemp, Log, TEXT("Damage Done:"), *SourceActor->GetName(), *TargetActor->GetName());
}
@@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "GAS/MyAbilitySystemComponent.h"
@@ -0,0 +1,37 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "HelperFunctions.h"
AActor* UHelperFunctions::GetNextTarget(const TArray<AActor*>& Targets, AActor* ReferenceActor, AActor* CurrentTarget, bool bClockwise)
{
if (Targets.Num() == 0 || !CurrentTarget)
{
return nullptr;
}
TArray<AActor*> SortedTargets = Targets;
FVector ReferenceLocation = ReferenceActor->GetActorLocation();
SortedTargets.Sort([&ReferenceLocation, bClockwise](const AActor& First, const AActor& Second)
{
FVector LocationFirst = First.GetActorLocation();
FVector LocationSecond = Second.GetActorLocation();
float AngleFirst = FMath::Atan2(LocationFirst.Y - ReferenceLocation.Y, LocationFirst.X - ReferenceLocation.X);
float AngleSecond = FMath::Atan2(LocationSecond.Y - ReferenceLocation.Y, LocationSecond.X - ReferenceLocation.X);
AngleFirst = FMath::Fmod(AngleFirst + 2 * PI, 2 * PI);
AngleSecond = FMath::Fmod(AngleSecond + 2 * PI, 2 * PI);
return bClockwise ? (AngleFirst < AngleSecond) : (AngleFirst > AngleSecond);
});
int32 CurrentTargetIndex = SortedTargets.IndexOfByKey(CurrentTarget);
if (CurrentTargetIndex == INDEX_NONE)
{
return nullptr;
}
int32 NextTargetIndex = (CurrentTargetIndex + 1) % SortedTargets.Num();
return SortedTargets[NextTargetIndex];
}
@@ -0,0 +1,51 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "NPCAIController.h"
#include "Perception/AIPerceptionSystem.h"
#include <AFCharacter.h>
void ANPCAIController::SetGenericTeamId(const FGenericTeamId& NewTeamID)
{
Super::SetGenericTeamId(NewTeamID);
UAIPerceptionSystem::GetCurrent(GetWorld())->UpdateListener(*GetAIPerceptionComponent());
}
ETeamAttitude::Type ANPCAIController::GetTeamAttitudeTowards(const AActor& Other) const
{
const APawn* OtherPawn = Cast<APawn>(&Other);
if (OtherPawn == nullptr)
{
return ETeamAttitude::Neutral;
}
auto CharacterTeamAgent = Cast<IGenericTeamAgentInterface>(&Other);
class IGenericTeamAgentInterface* ControllerTeamAgent = Cast<IGenericTeamAgentInterface>(OtherPawn->GetController());
if (CharacterTeamAgent == nullptr && ControllerTeamAgent == nullptr)
{
return ETeamAttitude::Neutral;
}
FGenericTeamId OtherTeamId = FGenericTeamId();
if (ControllerTeamAgent != nullptr)
{
OtherTeamId = ControllerTeamAgent->GetGenericTeamId();
}
else if (CharacterTeamAgent != nullptr)
{
OtherTeamId = CharacterTeamAgent->GetGenericTeamId();
}
FGenericTeamId MyTeamId = GetGenericTeamId();
if (OtherTeamId == EFraction::Civilians)
{
return ETeamAttitude::Neutral;
}
if (OtherTeamId == MyTeamId)
{
return ETeamAttitude::Friendly;
}
return ETeamAttitude::Hostile;
}
@@ -0,0 +1,51 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "NPCController.h"
#include "Perception/AIPerceptionSystem.h"
#include <AFCharacter.h>
void ANPCController::SetGenericTeamId(const FGenericTeamId& NewTeamID)
{
Super::SetGenericTeamId(NewTeamID);
UAIPerceptionSystem::GetCurrent(GetWorld())->UpdateListener(*GetAIPerceptionComponent());
}
ETeamAttitude::Type ANPCController::GetTeamAttitudeTowards(const AActor& Other) const
{
const APawn* OtherPawn = Cast<APawn>(&Other);
if (OtherPawn == nullptr)
{
return ETeamAttitude::Neutral;
}
auto CharacterTeamAgent = Cast<IGenericTeamAgentInterface>(&Other);
class IGenericTeamAgentInterface* ControllerTeamAgent = Cast<IGenericTeamAgentInterface>(OtherPawn->GetController());
if (CharacterTeamAgent == nullptr && ControllerTeamAgent == nullptr)
{
return ETeamAttitude::Neutral;
}
FGenericTeamId OtherTeamId = FGenericTeamId();
if (ControllerTeamAgent != nullptr)
{
OtherTeamId = ControllerTeamAgent->GetGenericTeamId();
}
else if (CharacterTeamAgent != nullptr)
{
OtherTeamId = CharacterTeamAgent->GetGenericTeamId();
}
FGenericTeamId MyTeamId = GetGenericTeamId();
if (OtherTeamId == EFraction::Civilians)
{
return ETeamAttitude::Neutral;
}
if (OtherTeamId == MyTeamId)
{
return ETeamAttitude::Friendly;
}
return ETeamAttitude::Hostile;
}
+292
View File
@@ -0,0 +1,292 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "AbilitySystemInterface.h"
#include "GenericTeamAgentInterface.h"
#include "GAS/AFAttributeSet.h"
#include "GameFramework/Character.h"
#include "AFWeapon.h"
#include "AFCharacter.generated.h"
UENUM(BlueprintType)
enum EFraction : int
{
Friends = 0,
Enemise = 1,
Civilians = 255
};
UENUM(BlueprintType)
enum EAbilitySlot : int
{
LightAttack,
HeavyAttack,
SpecialAttack,
SecondaryAbility,
DectosAbility,
SecondDectosAbility,
SpecAbility,
ManaAdd,
HeavyStaggerAttack,
LightStaggerAttack,
Combo1,
Combo2,
Combo3,
Gimmick1,
Gimmick2,
AirAttack,
Dodge,
Roll,
Block,
Parry
};
UENUM(BlueprintType)
enum EWeaponSlot : int
{
RightHand,
LeftHand
};
UCLASS()
class AFPROTOTYPE_API AAFCharacter :
public ACharacter,
public IAbilitySystemInterface,
public IGenericTeamAgentInterface,
public IGameplayTagAssetInterface
{
GENERATED_BODY()
public:
// Sets default values for this character's properties
AAFCharacter();
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual int32 GetCharacterLevel() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetHealth() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetMaxHealth() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetMana() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetMaxMana() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetStamina() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetMaxStamina() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetStagger() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetMaxStagger() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetStun() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetMaxStun() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetKnockdown() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetMaxKnockdown() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetExperiencePoints() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetMaxExperiencePoints() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetStormMana() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetMaxStormMana() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetFormPoint() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetMaxFormPoint() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetBrave() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
virtual float GetMaxBrave() const;
UFUNCTION(BlueprintCallable, Category = "AF Attribute")
bool ActivateAbilitiesWithTag(FGameplayTagContainer AbilityTags, bool AllowRemoteActivation = true);
UFUNCTION(BlueprintImplementableEvent)
void OnHealthChanged(float DeltaValue, AActor* Causer);
UFUNCTION(BlueprintImplementableEvent)
void OnDead();
UFUNCTION(BlueprintImplementableEvent)
void OnStaminaChanged(float DeltaValue, AActor* Causer);
UFUNCTION(BlueprintImplementableEvent)
void OnManaChanged(float DeltaValue, AActor* Causer);
UFUNCTION(BlueprintImplementableEvent)
void OnOverload();
UFUNCTION(BlueprintImplementableEvent)
void OnStaggerChanged(float DeltaValue, AActor* Causer);
UFUNCTION(BlueprintImplementableEvent)
void OnStaggered();
UFUNCTION(BlueprintImplementableEvent)
void OnStunChanged(float DeltaValue, AActor* Causer);
UFUNCTION(BlueprintImplementableEvent)
void OnStuned();
UFUNCTION(BlueprintImplementableEvent)
void OnKnockdownChanged(float DeltaValue, AActor* Causer);
UFUNCTION(BlueprintImplementableEvent)
void OnKnockdowned();
UFUNCTION(BlueprintImplementableEvent)
void OnXPChanged(float DeltaValue);
UFUNCTION(BlueprintImplementableEvent)
void OnCharacterLevelUp();
UFUNCTION(BlueprintImplementableEvent)
void OnStormManaChanged(float DeltaValue, AActor* Causer);
UFUNCTION(BlueprintImplementableEvent)
void OnStormOverload();
UFUNCTION(BlueprintImplementableEvent)
void OnFormPointChanged(float DeltaValue, AActor* Causer);
UFUNCTION(BlueprintImplementableEvent)
void OnBraveChanged(float DeltaValue, AActor* Causer);
UFUNCTION(BlueprintCallable, Category = "AF Abilites|Melee", meta = (DeprecatedFunction, DeprecatedMessage = "Use ActivateAbilityBySlot instead."))
bool ActivateMelleAbility(bool AllowRemoteActivation = true);
UFUNCTION(BlueprintCallable, Category = "AF Abilites")
virtual void GetActiveAbilitiesWithTag(FGameplayTagContainer AbilityTags, TArray<UGameplayAbility*>& ActiveAbilities, bool MatchExactTag);
UFUNCTION(BlueprintCallable, Category = "AF Abilites")
virtual void ApplyGameplayEffect(TSubclassOf<UGameplayEffect> GameplayEffect);
UFUNCTION(BlueprintCallable, Category = "AF Abilites")
virtual bool CanApplyGameplayEffect(TSubclassOf<UGameplayEffect> GameplayEffect);
UFUNCTION(BlueprintCallable, Category = "AF Abilites")
virtual bool EquipWeapon(AAFWeapon* Weapon, TEnumAsByte<EWeaponSlot> EquipSlot);
UFUNCTION(BlueprintCallable, Category = "AF Abilites")
virtual bool ActivateAbilityBySlot(TEnumAsByte<EAbilitySlot> AbilitySlot, bool AllowRemoteActivation = true);
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
UPROPERTY()
class UAbilitySystemComponent* AbilitySystemComponent;
UPROPERTY()
class UAFAttributeSet* AttributeSet;
UPROPERTY(EditAnywhere, Category = "AF Attribute")
int32 CharacterLevel;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Attribute")
TArray<TSubclassOf<class UGameplayEffect>> DefaultAttributeEffects;
UPROPERTY(EditAnywhere, Category = "AF Attribute|Debug")
bool EnableTestAbilities;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Attribute|Debug")
TArray<TSubclassOf<class UGameplayAbility>> TestAbilities;
virtual void SetTestAbilies();
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilites|Melee")
TSubclassOf<class UGameplayAbility> MeleeAbility;
UPROPERTY()
FGameplayAbilitySpecHandle MeleeAbilitySpecHandle;
virtual void SetMeleeAbility();
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Team)
TEnumAsByte<EFraction> Fraction = EFraction::Civilians;
FGenericTeamId TeamId;
TMap<TEnumAsByte<EAbilitySlot>, FGameplayAbilitySpecHandle> SlotAbilityHandles;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
virtual void PossessedBy(AController* NewController) override;
UAbilitySystemComponent* GetAbilitySystemComponent() const;
virtual void HandleHealthChange(float DeltaValue, AActor* Causer);
virtual void HandleStaminaChange(float DeltaValue, AActor* Causer);
virtual void HandleManaChange(float DeltaValue, AActor* Causer);
virtual void HandleStaggerChange(float DeltaValue, AActor* Causer);
virtual void HandleStunChange(float DeltaValue, AActor* Causer);
virtual void HandleKnockdownChange(float DeltaValue, AActor* Causer);
virtual void HandleExperiencePointsChange(float DeltaValue);
virtual void HandleCharacterLevelUp();
virtual void ApplyDefaultAttributesEffect();
virtual void RemoveDefaultAttributesEffect();
virtual void HandleStormManaChange(float DeltaValue, AActor* Causer);
virtual void HandleFormPointChange(float DeltaValue, AActor* Causer);
virtual void HandleBraveChange(float DeltaValue, AActor* Causer);
// Óíàñëåäîâàíî ÷åðåç IGameplayTagAssetInterface
void GetOwnedGameplayTags(FGameplayTagContainer& TagContainer) const override;
virtual FGenericTeamId GetGenericTeamId() const override;
protected:
virtual void ClearAbilitySlot(TEnumAsByte<EAbilitySlot> AbilitySlot);
virtual void AddAbilityToSlot(TSubclassOf<UGameplayAbility> NewAbility, TEnumAsByte<EAbilitySlot> AbilitySlot);
virtual void EquipRightHand(AAFWeapon* Weapon);
virtual void EquipLeftHand(AAFWeapon* Weapon);
};
+115
View File
@@ -0,0 +1,115 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include <Abilities/GameplayAbility.h>
#include "GAS/AfWeaponAttributeSet.h"
#include "AbilitySystemInterface.h"
#include "AFWeapon.generated.h"
UCLASS()
class AFPROTOTYPE_API AAFWeapon : public AActor, public IAbilitySystemInterface
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AAFWeapon();
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> LightAttackAbility;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> HeavyAttackAbility;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> SpecialAttackAbility;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> SecondaryAbility;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> DectosAbility;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> SecondDectosAbility;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> LightStaggerAttackAbility;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> HeavyStaggerAttackAbility;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> ManaAddAbility;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> DodgeAbility;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> RollAbility;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> BlockAbility;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> ParryAbility;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> Combo1Ability;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> Combo2Ability;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> Combo3Ability;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> AirAttackAbility;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> Gimmick1Ability;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TSubclassOf<UGameplayAbility> Gimmick2Ability;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Abilies")
TArray<TSubclassOf<class UGameplayAbility>> SpecAbilities;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "AF Weapon|Abilies")
TArray<TSubclassOf<UGameplayEffect>> WeaponEffects;
UFUNCTION(BlueprintCallable, Category = "AF Weapon|Abilies")
virtual void ApplyWeaponEffects();
UFUNCTION(BlueprintCallable, Category = "AF Weapon|Abilies")
float GetBaseDamage();
protected:
UPROPERTY()
class UAbilitySystemComponent* AbilitySystemComponent;
UPROPERTY()
class UAfWeaponAttributeSet* AttributeSet;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
UPROPERTY(EditAnywhere, Category = "AF Weapon|Attributes")
int32 WeaponLevel;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Óíàñëåäîâàíî ÷åðåç IAbilitySystemInterface
UAbilitySystemComponent* GetAbilitySystemComponent() const override;
};
@@ -0,0 +1,211 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "AttributeSet.h"
#include "AbilitySystemComponent.h"
#include "AFAttributeSet.generated.h"
#define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \
GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \
GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \
GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)
/**
*
*/
UCLASS()
class AFPROTOTYPE_API UAFAttributeSet : public UAttributeSet
{
GENERATED_BODY()
public:
UAFAttributeSet();
virtual void PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue) override;
virtual void PostGameplayEffectExecute(const FGameplayEffectModCallbackData& Data) override;
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_Health)
FGameplayAttributeData Health;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, Health);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_MaxHealth)
FGameplayAttributeData MaxHealth;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, MaxHealth);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_Mana)
FGameplayAttributeData Mana;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, Mana);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_MaxMana)
FGameplayAttributeData MaxMana;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, MaxMana);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_Stamina)
FGameplayAttributeData Stamina;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, Stamina);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_MaxStamina)
FGameplayAttributeData MaxStamina;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, MaxStamina);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_Stagger)
FGameplayAttributeData Stagger;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, Stagger);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_MaxStagger)
FGameplayAttributeData MaxStagger;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, MaxStagger);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_Stun)
FGameplayAttributeData Stun;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, Stun);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_MaxStun)
FGameplayAttributeData MaxStun;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, MaxStun);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_Knockdown)
FGameplayAttributeData Knockdown;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, Knockdown);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_MaxKnockdown)
FGameplayAttributeData MaxKnockdown;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, MaxKnockdown);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_ExperiencePoints)
FGameplayAttributeData ExperiencePoints;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, ExperiencePoints);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_MaxExperiencePoints)
FGameplayAttributeData MaxExperiencePoints;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, MaxExperiencePoints);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_StormMana)
FGameplayAttributeData StormMana;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, StormMana);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_MaxStormMana)
FGameplayAttributeData MaxStormMana;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, MaxStormMana);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_FormPoint)
FGameplayAttributeData FormPoint;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, FormPoint);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_MaxFormPoint)
FGameplayAttributeData MaxFormPoint;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, MaxFormPoint);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_BaseDamage)
FGameplayAttributeData BaseDamage;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, BaseDamage);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_BaseResistance)
FGameplayAttributeData BaseResistance;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, BaseResistance);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_EnergyDamage)
FGameplayAttributeData EnergyDamage;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, EnergyDamage);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_EnergyResistance)
FGameplayAttributeData EnergyResistance;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, EnergyResistance);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_Brave)
FGameplayAttributeData Brave;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, Brave);
UPROPERTY(BlueprintReadOnly, Category = "AF Attribute", ReplicatedUsing = OnRep_MaxBrave)
FGameplayAttributeData MaxBrave;
ATTRIBUTE_ACCESSORS(UAFAttributeSet, MaxBrave);
protected:
UFUNCTION()
void AdjustAttributeForMaxChange(
FGameplayAttributeData& AffectedAttribute,
const FGameplayAttributeData& MaxAttribute,
float NewMaxValue,
const FGameplayAttribute& AffectedAttributProperty);
UFUNCTION()
virtual void OnRep_Health(const FGameplayAttributeData& OldHealth);
UFUNCTION()
virtual void OnRep_MaxHealth(const FGameplayAttributeData& OldMaxHealth);
UFUNCTION()
virtual void OnRep_Mana(const FGameplayAttributeData& OldMana);
UFUNCTION()
virtual void OnRep_MaxMana(const FGameplayAttributeData& OldMaxMana);
UFUNCTION()
virtual void OnRep_Stamina(const FGameplayAttributeData& OldStamina);
UFUNCTION()
virtual void OnRep_MaxStamina(const FGameplayAttributeData& OldMaxStamina);
UFUNCTION()
virtual void OnRep_Stagger(const FGameplayAttributeData& OldStagger);
UFUNCTION()
virtual void OnRep_MaxStagger(const FGameplayAttributeData& OldMaxStagger);
UFUNCTION()
virtual void OnRep_Stun(const FGameplayAttributeData& OldStun);
UFUNCTION()
virtual void OnRep_MaxStun(const FGameplayAttributeData& OldMaxStun);
UFUNCTION()
virtual void OnRep_Knockdown(const FGameplayAttributeData& OldKnockdown);
UFUNCTION()
virtual void OnRep_MaxKnockdown(const FGameplayAttributeData& OldMaxKnockdown);
UFUNCTION()
virtual void OnRep_ExperiencePoints(const FGameplayAttributeData& OldExperiencePoints);
UFUNCTION()
virtual void OnRep_MaxExperiencePoints(const FGameplayAttributeData& OldMaxExperiencePoints);
UFUNCTION()
virtual void OnRep_StormMana(const FGameplayAttributeData& OldStormMana);
UFUNCTION()
virtual void OnRep_MaxStormMana(const FGameplayAttributeData& OldMaxStormMana);
UFUNCTION()
virtual void OnRep_FormPoint(const FGameplayAttributeData& OldFormPoint);
UFUNCTION()
virtual void OnRep_MaxFormPoint(const FGameplayAttributeData& OldMaxFormPoint);
UFUNCTION()
virtual void OnRep_BaseDamage(const FGameplayAttributeData& OldBaseDamage);
UFUNCTION()
virtual void OnRep_BaseResistance(const FGameplayAttributeData& OldBaseResistance);
UFUNCTION()
virtual void OnRep_EnergyDamage(const FGameplayAttributeData& OldEnergyDamage);
UFUNCTION()
virtual void OnRep_EnergyResistance(const FGameplayAttributeData& OldEnergyResistance);
UFUNCTION()
virtual void OnRep_Brave(const FGameplayAttributeData& OldBrave);
UFUNCTION()
virtual void OnRep_MaxBrave(const FGameplayAttributeData& OldMaxBrave);
};
@@ -0,0 +1,58 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "AttributeSet.h"
#include "AbilitySystemComponent.h"
#include "AfWeaponAttributeSet.generated.h"
#define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \
GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \
GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \
GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)
/**
*
*/
UCLASS()
class AFPROTOTYPE_API UAfWeaponAttributeSet : public UAttributeSet
{
GENERATED_BODY()
public:
UAfWeaponAttributeSet();
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
UPROPERTY(BlueprintReadOnly, Category = "AF Weapon|Attributes", ReplicatedUsing = OnRep_BaseDamage)
FGameplayAttributeData BaseDamage;
ATTRIBUTE_ACCESSORS(UAfWeaponAttributeSet, BaseDamage);
UPROPERTY(BlueprintReadOnly, Category = "AF Weapon|Attributes", ReplicatedUsing = OnRep_BaseResistance)
FGameplayAttributeData BaseResistance;
ATTRIBUTE_ACCESSORS(UAfWeaponAttributeSet, BaseResistance);
UPROPERTY(BlueprintReadOnly, Category = "AF Weapon|Attributes", ReplicatedUsing = OnRep_EnergyDamage)
FGameplayAttributeData EnergyDamage;
ATTRIBUTE_ACCESSORS(UAfWeaponAttributeSet, EnergyDamage);
UPROPERTY(BlueprintReadOnly, Category = "AF Weapon|Attributes", ReplicatedUsing = OnRep_EnergyResistance)
FGameplayAttributeData EnergyResistance;
ATTRIBUTE_ACCESSORS(UAfWeaponAttributeSet, EnergyResistance);
protected:
UFUNCTION()
virtual void OnRep_BaseDamage(const FGameplayAttributeData& OldBaseDamage);
UFUNCTION()
virtual void OnRep_BaseResistance(const FGameplayAttributeData& OldBaseResistance);
UFUNCTION()
virtual void OnRep_EnergyDamage(const FGameplayAttributeData& OldEnergyDamage);
UFUNCTION()
virtual void OnRep_EnergyResistance(const FGameplayAttributeData& OldEnergyResistance);
};
@@ -0,0 +1,43 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameplayEffectExecutionCalculation.h"
#include "DamageExecutionCalculation.generated.h"
/**
*
*/
UCLASS()
class AFPROTOTYPE_API UDamageExecutionCalculation : public UGameplayEffectExecutionCalculation
{
GENERATED_BODY()
public:
UDamageExecutionCalculation();
virtual void Execute_Implementation(
const FGameplayEffectCustomExecutionParameters& ExecutionParams,
OUT FGameplayEffectCustomExecutionOutput& OutExecutionOutput) const override;
protected:
UFUNCTION(BlueprintNativeEvent, Category = "AF Attribute|Calculations")
float GetDamageMagnitude(AActor* SourceActor) const;
UFUNCTION(BlueprintNativeEvent, Category = "AF Attribute|Calculations")
float GetWeaponDamage(AActor* SourceActor) const;
UFUNCTION(BlueprintNativeEvent, Category = "AF Attribute|Calculations")
float GetBlockAbscorption(AActor* TargetActor) const;
UFUNCTION(BlueprintNativeEvent, Category = "AF Attribute|Calculations")
void OnFullDamageAbsorbed(AActor* SourceActor, AActor* TargetActor);
virtual void OnFullDamageAbsorbed_Implementation(AActor* SourceActor, AActor* TargetActor) const;
UFUNCTION(BlueprintNativeEvent, Category = "AF Attribute|Calculations")
void OnDamageDone(AActor* SourceActor, AActor* TargetActor, float Damage);
virtual void OnDamageDone_Implementation(AActor* SourceActor, AActor* TargetActor, float Damage) const;
};
@@ -0,0 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "AbilitySystemComponent.h"
#include "MyAbilitySystemComponent.generated.h"
/**
*
*/
UCLASS()
class AFPROTOTYPE_API UMyAbilitySystemComponent : public UAbilitySystemComponent
{
GENERATED_BODY()
};
@@ -0,0 +1,4 @@
[ViewState]
Mode=
Vid=
FolderType=Documents
@@ -0,0 +1,20 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "HelperFunctions.generated.h"
/**
*
*/
UCLASS()
class AFPROTOTYPE_API UHelperFunctions : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "AF Framework|Helper")
static AActor* GetNextTarget(const TArray<AActor*>& Targets, AActor* ReferenceActor, AActor* CurrentTarget, bool bClockwise = true);
};
@@ -0,0 +1,24 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "DetourCrowdAIController.h"
#include "NPCAIController.generated.h"
/**
*
*/
UCLASS()
class AFPROTOTYPE_API ANPCAIController : public ADetourCrowdAIController
{
GENERATED_BODY()
public:
void SetGenericTeamId(const FGenericTeamId& NewTeamID) override;
protected:
virtual ETeamAttitude::Type GetTeamAttitudeTowards(const AActor& Other) const override;
};
+25
View File
@@ -0,0 +1,25 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "AIController.h"
#include "NPCController.generated.h"
/**
*
*/
UCLASS()
class AFPROTOTYPE_API ANPCController : public AAIController
{
GENERATED_BODY()
public:
void SetGenericTeamId(const FGenericTeamId& NewTeamID) override;
protected:
virtual ETeamAttitude::Type GetTeamAttitudeTowards(const AActor& Other) const override;
};