74. Modifier Magnitude Calculations

This commit is contained in:
2024-10-22 18:12:31 -04:00
parent 7e27f708cf
commit 001a542521
8 changed files with 122 additions and 11 deletions

View 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;
}

View 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;
};

View 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;
}

View 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;
};