When I try to apply parry effect back to the attacker in an attribute set - I am technically mirroring the same melee effect class - I get a stack overflow at the line of ApplyEffectToTarget and then access violation error:
void Uattribute_set_combat::apply_parry_effect_back_to_source(
const FGameplayEffectModCallbackData & Data
) const
{
UAbilitySystemComponent * asc_ = GetOwningAbilitySystemComponent();
if ( !asc_ ) return;
FGameplayEffectContextHandle effect_context_handle_ = asc_->MakeEffectContext();
UAbilitySystemComponent * attacker_asc_ =
Data.EffectSpec.GetEffectContext().GetOriginalInstigatorAbilitySystemComponent();
if ( !attacker_asc_ )
{
GEngine->AddOnScreenDebugMessage(
-1,
5.f,
FColor::Red,
FString::Printf(
TEXT("Attacker ASC not found")
)
);
return;
}
FGameplayEffectSpecHandle effect_spec_handle_ = asc_->MakeOutgoingSpec(
Data.EffectSpec.Def->GetClass(),
1.f,
effect_context_handle_
);
FGameplayTag tag_parry_ = FGameplayTag::RequestGameplayTag("combat.action.parry");
effect_spec_handle_.Data->DynamicGrantedTags.AddTag(tag_parry_);
GEngine->AddOnScreenDebugMessage(
-1,
5.f,
FColor::Black,
FString::Printf(
TEXT("%s is PARRYING %s"),
*asc_->GetOwnerActor()->GetName(),
*attacker_asc_->GetOwnerActor()->GetName()
)
);
// ERROR: Backing attribute causing stack overflow?
// asc_->ApplyGameplayEffectSpecToTarget(
// *(effect_spec_handle_.Data),
// attacker_asc_,
// FPredictionKey()
// );
}
This is how I am detecting parry, in the same attribute set combat:
bool Uattribute_set_combat::PreGameplayEffectExecute(FGameplayEffectModCallbackData & Data){
// If not operated on parry, proceed with ABCDreturn !
operate_on_parry(Data);
}
bool Uattribute_set_combat::operate_on_parry(FGameplayEffectModCallbackData & Data) const{
if ( Data.EvaluatedData.Attribute != Getincoming_damageAttribute() )
return false;
if ( !validate_successfully_parried() )
return false;
// Mirror effect back to source
apply_parry_effect_back_to_source(Data);
return true;
}
const bool Uattribute_set_combat::validate_successfully_parried() const{
// combat_component->validate_is_facing_hit_result()
FGameplayTag tag_parry_ = FGameplayTag::RequestGameplayTag("combat.action.parry");
if ( UAbilitySystemComponent * asc_ = GetOwningAbilitySystemComponent() )
return ( asc_->HasMatchingGameplayTag(tag_parry_) );
return false;
}
To give more context:
I have 2 attributes in the same attribute-set combat:
- incoming_damage - outgoing_damage
The melee effect overrides target’s incoming damage with its own outgoing damage (say -50).
The incoming damage validates parry, block, and it’s own damage.
So I am able to damage my own health - factored by defense during block.
I do not seem to be able to mirror the same melee-effect class back to the attacker.
Why? How to resolve?
Thanks in advance.