How-To: Query Attitude & Gate Damage

Goal: decide friend/foe, block friendly fire, and filter ability targets by attitude.

Prerequisites
Actors with team agent components and tags (Quick Start / How-To: Make an Actor a Team Agent).

1. Attitude & damage

cpp
// Full attitude (Hostile / Friendly / Neutral):
const ETeamAttitude::Type Att = UCrimsonTeamStatics::GetTeamAttitudeBetween(Source, Target);
// Friendly fire gate (true for Hostile or Neutral; false for Friendly):
const bool bCanDamage = UCrimsonTeamStatics::ShouldCauseDamageToTarget(Source, Target);
// Subsystem variant with a self-damage flag:
UCrimsonTeamSubsystem* TS = GetWorld()->GetSubsystem<UCrimsonTeamSubsystem>();
const bool bCan = TS->CanCauseDamage(Instigator, Target, /*bAllowDamageToSelf*/ true);
Check at apply-time, not activation-time
Attitude is dynamic - a target can change teams mid-ability. Evaluate it when the hit actually lands, not when the ability starts, so a freshly-turned enemy (or ally) is judged correctly.

2. Filter ability targets by attitude

MakeFilteredTargetDataFromActors keeps only actors matching a filter and packages them as a FGameplayAbilityTargetDataHandle (self and nulls always excluded) - ideal for AoE.

ECrimsonTargetFilterKeeps
HostileAndNeutralDamage abilities (default)
HostileOnlyEnemy-only attacks
FriendlyAndNeutralSupport abilities
FriendlyOnlyHeals / buffs
AllIndiscriminate effects
cpp
FGameplayAbilityTargetDataHandle Data =
UCrimsonTeamStatics::MakeFilteredTargetDataFromActors(
AbilityOwner, OverlappingActors, ECrimsonTargetFilter::HostileAndNeutral);

See also

  • How-To: Debug at Runtime - the Attitude Matrix tab visualizes every pairing at once
  • API Reference - UCrimsonTeamStatics, UCrimsonTeamSubsystem