74. Modifier Magnitude Calculations
This commit is contained in:
parent
7e27f708cf
commit
001a542521
35
Project/Source/Gasa/AbilitySystem/MMC/MMC_MaxHealth.cpp
Normal file
35
Project/Source/Gasa/AbilitySystem/MMC/MMC_MaxHealth.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#include "MMC_MaxHealth.h"
|
||||||
|
|
||||||
|
#include "AbilitySystem/GasaAttributeSet.h"
|
||||||
|
#include "Interfaces/CombatInterface.h"
|
||||||
|
|
||||||
|
UMMC_MaxHealth::UMMC_MaxHealth()
|
||||||
|
{
|
||||||
|
VigorDef.AttributeToCapture = UGasaAttributeSet::GetVigorAttribute();
|
||||||
|
VigorDef.AttributeSource = EGameplayEffectAttributeCaptureSource::Target;
|
||||||
|
VigorDef.bSnapshot = false;
|
||||||
|
|
||||||
|
RelevantAttributesToCapture.Add( VigorDef);
|
||||||
|
}
|
||||||
|
|
||||||
|
float UMMC_MaxHealth::CalculateBaseMagnitude_Implementation( FGameplayEffectSpec const& Spec ) const
|
||||||
|
{
|
||||||
|
// Gather tags from source and target
|
||||||
|
FGameplayTagContainer const* SourceTags = Spec.CapturedSourceTags.GetAggregatedTags();
|
||||||
|
FGameplayTagContainer const* TargetTags = Spec.CapturedTargetTags.GetAggregatedTags();
|
||||||
|
|
||||||
|
FAggregatorEvaluateParameters EvaluationParamters;
|
||||||
|
EvaluationParamters.SourceTags = SourceTags;
|
||||||
|
EvaluationParamters.TargetTags = TargetTags;
|
||||||
|
|
||||||
|
float Vigor = 0.f;
|
||||||
|
GetCapturedAttributeMagnitude(VigorDef, Spec, EvaluationParamters, Vigor);
|
||||||
|
Vigor = FMath::Max(Vigor, 0.f);
|
||||||
|
|
||||||
|
ICombat* Combat = Cast<ICombat>(Spec.GetContext().GetSourceObject());
|
||||||
|
int32 PlayerLevel = Combat->GetPlayerLevel();
|
||||||
|
|
||||||
|
float Calculation = 80.f + 2.5 * Vigor + 10.f * PlayerLevel;
|
||||||
|
return Calculation;
|
||||||
|
}
|
||||||
|
|
19
Project/Source/Gasa/AbilitySystem/MMC/MMC_MaxHealth.h
Normal file
19
Project/Source/Gasa/AbilitySystem/MMC/MMC_MaxHealth.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GameplayModMagnitudeCalculation.h"
|
||||||
|
|
||||||
|
#include "MMC_MaxHealth.generated.h"
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class GASA_API UMMC_MaxHealth : public UGameplayModMagnitudeCalculation
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UMMC_MaxHealth();
|
||||||
|
|
||||||
|
FGameplayEffectAttributeCaptureDefinition VigorDef;
|
||||||
|
|
||||||
|
float CalculateBaseMagnitude_Implementation( FGameplayEffectSpec const& Spec ) const override;
|
||||||
|
};
|
34
Project/Source/Gasa/AbilitySystem/MMC/MMC_MaxMana.cpp
Normal file
34
Project/Source/Gasa/AbilitySystem/MMC/MMC_MaxMana.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include "MMC_MaxMana.h"
|
||||||
|
|
||||||
|
#include "AbilitySystem/GasaAttributeSet.h"
|
||||||
|
#include "Interfaces/CombatInterface.h"
|
||||||
|
|
||||||
|
UMMC_MaxMana::UMMC_MaxMana()
|
||||||
|
{
|
||||||
|
IntelligenceDef.AttributeToCapture = UGasaAttributeSet::GetVigorAttribute();
|
||||||
|
IntelligenceDef.AttributeSource = EGameplayEffectAttributeCaptureSource::Target;
|
||||||
|
IntelligenceDef.bSnapshot = false;
|
||||||
|
|
||||||
|
RelevantAttributesToCapture.Add( IntelligenceDef);
|
||||||
|
}
|
||||||
|
|
||||||
|
float UMMC_MaxMana::CalculateBaseMagnitude_Implementation( FGameplayEffectSpec const& Spec ) const
|
||||||
|
{
|
||||||
|
// Gather tags from source and target
|
||||||
|
FGameplayTagContainer const* SourceTags = Spec.CapturedSourceTags.GetAggregatedTags();
|
||||||
|
FGameplayTagContainer const* TargetTags = Spec.CapturedTargetTags.GetAggregatedTags();
|
||||||
|
|
||||||
|
FAggregatorEvaluateParameters EvaluationParamters;
|
||||||
|
EvaluationParamters.SourceTags = SourceTags;
|
||||||
|
EvaluationParamters.TargetTags = TargetTags;
|
||||||
|
|
||||||
|
float Intelligence = 0.f;
|
||||||
|
GetCapturedAttributeMagnitude(IntelligenceDef, Spec, EvaluationParamters, Intelligence);
|
||||||
|
Intelligence = FMath::Max(Intelligence, 0.f);
|
||||||
|
|
||||||
|
ICombat* Combat = Cast<ICombat>(Spec.GetContext().GetSourceObject()); check(Combat);
|
||||||
|
int32 PlayerLevel = Combat->GetPlayerLevel();
|
||||||
|
|
||||||
|
float Calculation = 50.f + 2.5 * Intelligence + 15.f * PlayerLevel;
|
||||||
|
return Calculation;
|
||||||
|
}
|
19
Project/Source/Gasa/AbilitySystem/MMC/MMC_MaxMana.h
Normal file
19
Project/Source/Gasa/AbilitySystem/MMC/MMC_MaxMana.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GameplayModMagnitudeCalculation.h"
|
||||||
|
|
||||||
|
#include "MMC_MaxMana.generated.h"
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class GASA_API UMMC_MaxMana : public UGameplayModMagnitudeCalculation
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UMMC_MaxMana();
|
||||||
|
|
||||||
|
FGameplayEffectAttributeCaptureDefinition IntelligenceDef;
|
||||||
|
|
||||||
|
float CalculateBaseMagnitude_Implementation( FGameplayEffectSpec const& Spec ) const override;
|
||||||
|
};
|
@ -79,13 +79,17 @@ void AGasaCharacter::InitDefaultAttributes()
|
|||||||
{
|
{
|
||||||
UAbilitySystemComponent* ASC = GetAbilitySystemComponent();
|
UAbilitySystemComponent* ASC = GetAbilitySystemComponent();
|
||||||
ensure(ASC);
|
ensure(ASC);
|
||||||
|
|
||||||
ensure(DefaultVitalAttributes);
|
ensure(DefaultVitalAttributes);
|
||||||
ensure(DefaultPrimaryAttributes);
|
ensure(DefaultPrimaryAttributes);
|
||||||
ensure(DefaultSecondaryAttributes);
|
ensure(DefaultSecondaryAttributes);
|
||||||
FGameplayEffectContextHandle Context = ASC->MakeEffectContext();
|
|
||||||
FGameplayEffectSpecHandle SpecPrimary = ASC->MakeOutgoingSpec(DefaultPrimaryAttributes, 1.0f, Context );
|
FGameplayEffectContextHandle Context = ASC->MakeEffectContext();
|
||||||
FGameplayEffectSpecHandle SpecSecondary = ASC->MakeOutgoingSpec(DefaultSecondaryAttributes, 1.0f, Context );
|
Context.AddSourceObject(this);
|
||||||
FGameplayEffectSpecHandle SpecVital = ASC->MakeOutgoingSpec(DefaultVitalAttributes, 1.0f, Context );
|
|
||||||
|
FGameplayEffectSpecHandle SpecPrimary = ASC->MakeOutgoingSpec(DefaultPrimaryAttributes, 1.0f, Context );
|
||||||
|
FGameplayEffectSpecHandle SpecSecondary = ASC->MakeOutgoingSpec(DefaultSecondaryAttributes, 1.0f, Context );
|
||||||
|
FGameplayEffectSpecHandle SpecVital = ASC->MakeOutgoingSpec(DefaultVitalAttributes, 1.0f, Context );
|
||||||
ASC->ApplyGameplayEffectSpecToTarget( * SpecPrimary.Data, ASC );
|
ASC->ApplyGameplayEffectSpecToTarget( * SpecPrimary.Data, ASC );
|
||||||
ASC->ApplyGameplayEffectSpecToTarget( * SpecSecondary.Data, ASC );
|
ASC->ApplyGameplayEffectSpecToTarget( * SpecSecondary.Data, ASC );
|
||||||
ASC->ApplyGameplayEffectSpecToTarget( * SpecVital.Data, ASC );
|
ASC->ApplyGameplayEffectSpecToTarget( * SpecVital.Data, ASC );
|
||||||
|
@ -14,9 +14,9 @@ APlayerCharacter::APlayerCharacter()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#pragma region ICombat
|
#pragma region ICombat
|
||||||
int32 APlayerCharacter::GetLevel()
|
int32 APlayerCharacter::GetPlayerLevel()
|
||||||
{
|
{
|
||||||
return GetPlayerState<AGasaPlayerState>()->Level;
|
return GetPlayerState<AGasaPlayerState>()->PlayerLevel;
|
||||||
}
|
}
|
||||||
#pragma endregion ICombat
|
#pragma endregion ICombat
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "GasaCharacter.h"
|
#include "GasaCharacter.h"
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ public:
|
|||||||
APlayerCharacter();
|
APlayerCharacter();
|
||||||
|
|
||||||
#pragma region ICombat
|
#pragma region ICombat
|
||||||
int32 GetLevel() override;
|
int32 GetPlayerLevel() override;
|
||||||
#pragma endregion ICombat
|
#pragma endregion ICombat
|
||||||
|
|
||||||
#pragma region Pawn
|
#pragma region Pawn
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "GasaPlayerState.h"
|
#include "GasaPlayerState.h"
|
||||||
|
|
||||||
#include "Net/UnrealNetwork.h"
|
#include "Net/UnrealNetwork.h"
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ AGasaPlayerState::AGasaPlayerState()
|
|||||||
{
|
{
|
||||||
bAutoAbilitySystem = true;
|
bAutoAbilitySystem = true;
|
||||||
|
|
||||||
Level = 1;
|
PlayerLevel = 1;
|
||||||
|
|
||||||
AbilitySystem = CreateDefaultSubobject<UGasaAbilitySystemComp>("Ability System");
|
AbilitySystem = CreateDefaultSubobject<UGasaAbilitySystemComp>("Ability System");
|
||||||
AbilitySystem->SetIsReplicated(true);
|
AbilitySystem->SetIsReplicated(true);
|
||||||
@ -96,6 +96,6 @@ void AGasaPlayerState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& Out
|
|||||||
{
|
{
|
||||||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||||
|
|
||||||
DOREPLIFETIME(AGasaPlayerState, Level);
|
DOREPLIFETIME(AGasaPlayerState, PlayerLevel);
|
||||||
}
|
}
|
||||||
#pragma endregion UObject
|
#pragma endregion UObject
|
||||||
|
Loading…
Reference in New Issue
Block a user