CrimsonTeams · Lesson 3 of 6
Gate Damage & Filter Targets
Before you start
- Completed: Agents & Attitude
Chapters
Gate friendly fire
ShouldCauseDamageToTarget is the quick bool — true for Hostile or Neutral, false for Friendly. The subsystem variant adds a self-damage flag.
// 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.
Filter ability targets by attitude
MakeFilteredTargetDataFromActors keeps only the actors matching a filter and packages them as a FGameplayAbilityTargetDataHandle (self and nulls always excluded) — ideal for AoE.
| ECrimsonTargetFilter | Keeps |
| HostileAndNeutral | Damage abilities (default) |
| HostileOnly | Enemy-only attacks |
| FriendlyAndNeutral | Support abilities |
| FriendlyOnly | Heals / buffs |
| All | Indiscriminate effects |
FGameplayAbilityTargetDataHandle Data =UCrimsonTeamStatics::MakeFilteredTargetDataFromActors(AbilityOwner, OverlappingActors, ECrimsonTargetFilter::HostileAndNeutral);