Files
UnrealEngineUWP/Engine/Source/Runtime/SkillSystem/Private/GameplayEffectStackingExtension_CappedNumberTest.cpp
Billy Bramer 8dd6c092d2 Second batch of merging of gameplay tag changes.
#codereview Fred.Kimberley

[AUTOMERGE]

fixed smasher picking first non tagged skill for wall attacks

#codereview Billy.Bramer

--------
Integrated using branch Ue4-To-UE4-Fortnite-Simple (reversed) of change#2070195 by Lukasz.Furman on 2014/05/12 06:41:54.

[AUTOMERGE]

- Back out changelist 2070195, which caused bugs in other areas (player skills not working correctly)
- Fix bug in MatchesAll in tag container (only care that filter results > 0)
- Allow MatchesAny/All in tag container to specify whether an empty container should count as a match or not

- Fortnite AI still afflicted with issues due to content problem with interface nodes. Email pending re: how to resolve

--------
Integrated using branch Ue4-To-UE4-Fortnite-Simple (reversed) of change#2071165 by Billy.Bramer on 2014/05/12 22:31:32.

[AUTOMERGE]

- Remove deprecated function usage from tag asset interface
- Remove deprecated function usage from Fortnite
#fortress

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

[AUTOMERGE]

- Minor commenting/clean-up on recent gameplay tag stuff

--------
Integrated using branch Ue4-To-UE4-Fortnite-Simple (reversed) of change#2072435 by Billy.Bramer on 2014/05/13 22:04:18.

[AUTOMERGE]

- Clean up on some tag refactor stuff; Give the tag module a static function for requesting tags

--------
Integrated using branch Ue4-To-UE4-Fortnite-Simple (reversed) of change#2072475 by Billy.Bramer on 2014/05/13 22:50:45.

[CL 2079409 by Billy Bramer in Main branch]
2014-05-20 16:40:26 -04:00

75 lines
2.9 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "SkillSystemModulePrivatePCH.h"
#include "GameplayTagsModule.h"
#include "Crc.h"
const int32 MaxNumInStack = 2;
UGameplayEffectStackingExtension_CappedNumberTest::UGameplayEffectStackingExtension_CappedNumberTest(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
Handle = FCrc::StrCrc32("UGameplayEffectStackingExtension_CappedNumberTest");
}
void UGameplayEffectStackingExtension_CappedNumberTest::CalculateStack(TArray<FActiveGameplayEffect*>& CustomGameplayEffects, FActiveGameplayEffectsContainer& Container, FActiveGameplayEffect& CurrentEffect)
{
// this effect shouldn't be in the array so be sure to count it as well
int32 EffectiveCount = FMath::Min(CustomGameplayEffects.Num() + 1, MaxNumInStack);
// find the most recent time one of these was applied
float StartTime = CurrentEffect.StartWorldTime;
for (FActiveGameplayEffect* Effect : CustomGameplayEffects)
{
StartTime = FMath::Max(StartTime, Effect->StartWorldTime);
}
{
// set the start time to be equal to the most recent start time so that the stacked effects stick around if a new effect has been added
CurrentEffect.StartWorldTime = StartTime;
int32 Idx = 0;
while (Idx < FMath::Min(MaxNumInStack - 1, CustomGameplayEffects.Num()))
{
CustomGameplayEffects[Idx]->StartWorldTime = StartTime;
++Idx;
}
// we don't need any effects beyond the cap
while (Idx < CustomGameplayEffects.Num())
{
Container.RemoveActiveGameplayEffect(CustomGameplayEffects[Idx]->Handle);
++Idx;
}
}
for (FModifierSpec Mod : CurrentEffect.Spec.Modifiers)
{
if (Mod.Info.OwnedTags.HasTag(IGameplayTagsModule::RequestGameplayTag("Stackable"), EGameplayTagMatchType::IncludeParentTags, EGameplayTagMatchType::Explicit))
{
// remove any stacking information that was already applied to the current modifier
for (int32 Idx = 0; Idx < Mod.Aggregator.Get()->Mods[EGameplayModOp::Multiplicitive].Num(); ++Idx)
{
FAggregatorRef& Agg = Mod.Aggregator.Get()->Mods[EGameplayModOp::Multiplicitive][Idx];
if (Agg.Get()->BaseData.Tags.HasTag(IGameplayTagsModule::RequestGameplayTag("Stack.CappedNumber"), EGameplayTagMatchType::IncludeParentTags, EGameplayTagMatchType::Explicit))
{
Mod.Aggregator.Get()->Mods[EGameplayModOp::Multiplicitive].RemoveAtSwap(Idx);
--Idx;
}
}
FGameplayModifierInfo ModInfo;
ModInfo.Magnitude.SetValue(EffectiveCount);
ModInfo.ModifierOp = EGameplayModOp::Multiplicitive;
ModInfo.OwnedTags.AddTag(IGameplayTagsModule::RequestGameplayTag("Stack.CappedNumber"));
ModInfo.Attribute = Mod.Info.Attribute;
TSharedPtr<FGameplayEffectLevelSpec> ModifierLevel(TSharedPtr< FGameplayEffectLevelSpec >(new FGameplayEffectLevelSpec()));
ModifierLevel->ApplyNewDef(ModInfo.LevelInfo, ModifierLevel);
FModifierSpec ModSpec(ModInfo, ModifierLevel, NULL);
ModSpec.ApplyModTo(Mod, true);
}
}
}