Files
UnrealEngineUWP/Engine/Source/Runtime/SkillSystem/Private/GameplayEffectExtension_ShieldTest.cpp
Billy Bramer b8d692da28 Merge CLs with refactor of GameplayTags to main. Largely WIP, more changes coming.
[AUTOMERGE]

- Step one of gameplay tag refactor: deletion of un-used and unfixed content

--------
Integrated using branch Ue4-To-UE4-Fortnite-Simple (reversed) of change#2067362 by Billy.Bramer on 2014/05/08 16:08:55.

[AUTOMERGE]

Gameplay Tag Refactor

Unshelved from AntonyC's pending changelist '2003772':

#TTP 322200 - Gameplay Tags: Refactor how tags are stored/queried

#proj Fortnite.Editor

#summary Refactored Tags from FName array to a FGamplayTag

#change removed all FName Tags and replaces with FGameplayTag
#added added tag verification so that new tags are not created at runtime
#added added new object version for data upgrade on all tagcontainers to be in new format and only store leaf most tags
#added requestgameplaytag function to FortGlobals, so that the tag manager can be started up before first use
#added New GraphPin for single tags
#change Added mode to SGamplayTagWidget to allow single select
#change PropertyArray fixed to now support empty arrays in the ImportText

---------------------

Additional Changes/Modifications
- Add new BlueprintGameplayTagLibrary to expose tag container functions to blueprints; Will add more in future post-refactor
- Fix bug with AddLeafTagToContainer incorrectly clearing the wrong container
- Remove default parameters for TagContainer.HasTag and fix call-sites to remain logically consistent with old behavior
- Make FName constructor for tag explicit
- Fix incorrect requirements check in combat effect
- Expose tag asset interface to blueprints
- Remove serialization fix-up from game data (manually fixed up)
- Remove version bump and serialization fix-up on tag container (will be re-done from main branch post merge)

--------
Integrated using branch Ue4-To-UE4-Fortnite-Simple (reversed) of change#2067378 by Billy.Bramer on 2014/05/08 16:15:42.

[AUTOMERGE]

#UE4 Fixed up GameplayTag usage in the SkillSystem module

--------
Integrated using branch Ue4-To-UE4-Fortnite-Simple (reversed) of change#2067576 by Bob.Tellez on 2014/05/08 18:38:58.

[AUTOMERGE]

- Linker build fix on gameplay tags

--------
Integrated using branch Ue4-To-UE4-Fortnite-Simple (reversed) of change#2067708 by Billy.Bramer on 2014/05/08 21:18:36.

[AUTOMERGE]

- Minor optimization in header

--------
Integrated using branch Ue4-To-UE4-Fortnite-Simple (reversed) of change#2067709 by Billy.Bramer on 2014/05/08 21:22:27.

[AUTOMERGE]

- Gameplay tag refactor, round 3
- Fortnite asset conversion/update

--------
Integrated using branch Ue4-To-UE4-Fortnite-Simple (reversed) of change#2068202 by Billy.Bramer on 2014/05/09 11:13:36.

[AUTOMERGE]

- Fix gameplay tag reimporting failing to reinitialize the tag table

--------
Integrated using branch Ue4-To-UE4-Fortnite-Simple (reversed) of change#2068787 by Billy.Bramer on 2014/05/09 18:11:23.

[AUTOMERGE]

#UE4 Fixed up GameplayTag usage in the SkillSystem module after merge from main

--------
Integrated using branch Ue4-To-UE4-Fortnite-Simple (reversed) of change#2070710 by Fred.Kimberley on 2014/05/12 15:57:13.

#codereview Fred.Kimberley, David.Ratti

[CL 2078452 by Billy Bramer in Main branch]
2014-05-19 23:21:13 -04:00

71 lines
3.6 KiB
C++

// Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.
#include "SkillSystemModulePrivatePCH.h"
#include "GameplayTagsModule.h"
UGameplayEffectExtension_ShieldTest::UGameplayEffectExtension_ShieldTest(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
}
void UGameplayEffectExtension_ShieldTest::PreGameplayEffectExecute(const FGameplayModifierEvaluatedData &SelfData, FGameplayEffectModCallbackData &Data) const
{
IGameplayTagsModule& GameplayTagsModule = IGameplayTagsModule::Get();
UAttributeComponent *Source = Data.EffectSpec.InstigatorStack.GetOriginInstigatorAttributeComponent();
// FIXME: some annoyances here: Damage about to be applied = Data.EvaluatedData.Magnitude = negative. Do some sign flipping here that would make more sense if we were dealing with
// 'damage' (positive) instead of 'health' (negative)
// How much damage we will absorb
float ShieldedDamage = FMath::Min(-Data.EvaluatedData.Magnitude, SelfData.Magnitude);
// Decrease the magnitude of damage done
Data.EvaluatedData.Magnitude += ShieldedDamage;
if (ShieldedDamage >= SelfData.Magnitude)
{
check(SelfData.Handle.IsValid());
// The shield is now depleted, so remove the gameplay effect altogether
bool RemovedSomething = Data.Target.RemoveActiveGameplayEffect(SelfData.Handle);
check(RemovedSomething);
// Note we could get in trouble with the above checks, depending on how the GameplayEffect that called us was setup.
// For example if we were applied to a periodic damage effect, and were copied as a snapshot, our shield could expire
// but our aggregator on the DOT gameplayeffect would still exist with a now invalid handle. This is ok, and possibly powerful
// but just means that the way an effect like this is written would have to take it into account. This one doesn't.
//
// It even opens up interesting possibilities. You could have a shield specifically designed for dots: something that would absorb
// the first X damage from each DOT applied to you. Practicaly? Maybe not, but demonstrates power of this setup.
}
else if (ShieldedDamage > 0.f)
{
// Apply a GameplayEffect to remove some of our shield
UGameplayEffect * LocalShieldRemoval = ShieldRemoveGameplayEffect;
if (!LocalShieldRemoval)
{
UProperty *HealthProperty = FindFieldChecked<UProperty>(USkillSystemTestAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED(USkillSystemTestAttributeSet, Health));
// Since this is a test class and we don't want to tie it any actual content assets, just construct a GameplayEffect here.
LocalShieldRemoval = Cast<UGameplayEffect>(StaticConstructObject(UGameplayEffect::StaticClass(), GetTransientPackage(), FName(TEXT("ShieldAbsorbRemoval"))));
LocalShieldRemoval->Modifiers.SetNum(1);
LocalShieldRemoval->Modifiers[0].Magnitude.SetValue(-ShieldedDamage);
LocalShieldRemoval->Modifiers[0].ModifierType = EGameplayMod::ActiveGE;
LocalShieldRemoval->Modifiers[0].ModifierOp = EGameplayModOp::Additive;
LocalShieldRemoval->Modifiers[0].Attribute.SetUProperty(HealthProperty);
LocalShieldRemoval->Modifiers[0].OwnedTags.AddTag(GameplayTagsModule.GetGameplayTagsManager().RequestGameplayTag(FName(TEXT("ShieldAbsorb"))));
LocalShieldRemoval->Duration.Value = UGameplayEffect::INSTANT_APPLICATION;
LocalShieldRemoval->Period.Value = UGameplayEffect::NO_PERIOD;
}
Data.Target.ApplyGameplayEffectToSelf(LocalShieldRemoval, ShieldedDamage, Source->GetOwner(), FModifierQualifier().ExclusiveTarget(SelfData.Handle));
}
}
void UGameplayEffectExtension_ShieldTest::PostGameplayEffectExecute(const FGameplayModifierEvaluatedData &SelfData, const FGameplayEffectModCallbackData &Data) const
{
}