06_TeamsFriendlyFire — Teams • Friendly Fire¶
Goal¶
Teach how team identity affects damage through TeamRule, including blocked friendly fire, scaled friendly fire, and scaled enemy damage.
What This Scene Demonstrates¶
Attacker team → victim team → TeamRule scale/block decision → PreviewDamage → ApplyDamage.
This scene compares one attacker hitting an ally victim and an enemy victim. TeamRule reads team information from the damage context and the victim, then decides whether damage should be blocked or scaled.
PreviewDamage is the authoritative preview. ApplyDamage is the authoritative runtime result. TeamRule is only one rule in the pipeline, so other victim rules can still affect the final value.
What To Look For¶
- Setup: The panel binds an attacker, ally victim, and enemy victim.
- Team IDs: The panel shows attacker, ally, and enemy team IDs when
ITeamProvideris present. - Rule: Friendly-fire permission, friendly-fire scale, and enemy scale are mirrored onto both victims.
- Preview / Apply: Ally and enemy previews are shown side by side before either target is mutated.
- Mini-bars: Ally/enemy preview values are shown as a fraction of the raw input amount.
- Apply result: Attack buttons call
HealthSystem.ApplyDamageand report the real result or rejection reason.
Mental model: attacker team + victim team → TeamRule branch → preview result → apply result.
Sample Scope¶
This scene covers:
- Attacker, ally victim, and enemy victim bindings
ITeamProviderteam identity checks- Demo fallback when attacker has no
ITeamProvider - Same-team vs other-team comparison
- Friendly fire disabled
- Friendly fire enabled
- Friendly-fire scaling
- Enemy damage scaling
- Side-by-side ally/enemy preview
- Real
ApplyDamagecalls against ally and enemy victims - Detection of other damage rules that may affect final results
This scene does NOT cover:
- Full faction systems
- Relationship matrices
- Networked team authority
- Production team assignment UI
- All possible damage-rule ordering cases
- Isolated TeamRule-only maths when other victim rules are present
In Play Mode, this panel may add missing TeamRule components so the demo remains runnable. That is demo convenience, not a production integration pattern.
Authority Note¶
This scene may include a permissive sample authority setup where mutations are allowed locally for demonstration purposes.
Networking Reminder¶
No networking is included; integration is the developer’s responsibility.
How To Use¶
- Enter Play Mode.
- Open the Setup tab.
-
Confirm the panel has:
-
Attacker binding
- Ally Victim binding
- Enemy Victim binding
HealthSystemon both victimsTeamRuleon both victimsITeamProvideron victims for clear team comparison-
Check the displayed team IDs:
-
Attacker Team
- Ally Team
- Enemy Team
- Open the Rule tab.
- Toggle Allow Friendly Fire.
- Adjust Friendly Scale.
- Adjust Enemy Scale.
-
Confirm the displayed rule settings:
-
Allow Friendly Fire
- Friendly Fire Scale
- Enemy Scale
- Open the Preview / Apply tab.
- Set Amount to the raw incoming damage amount.
-
Compare:
-
Preview Ally (same-team)
-
Preview Enemy (other-team)
-
Use the mini-bars to compare ally/enemy preview output visually.
- Click Attack Ally (same team) to apply damage to the ally victim.
- Click Attack Enemy (other team) to apply damage to the enemy victim.
- Read the result message to confirm whether the hit was applied, blocked, absorbed, or reduced.
Failure Behaviour¶
-
Missing Victim Binding
-
Meaning: Ally and/or enemy victim is not assigned.
-
Fix: Assign same-team and other-team targets.
-
Missing HealthSystem
-
Meaning: One or both victims cannot preview or apply damage.
-
Fix: Add
HealthSystemto the missing victim(s). -
Missing Team Provider
-
Meaning: Team comparison may be unclear because team IDs cannot be resolved.
-
Fix: Add
ITeamProvidercomponents to victims. -
Zero TeamId Detected
-
Meaning: One or more victims resolve
TeamId = 0. -
Fix: Assign non-zero team IDs for a clearer ally/enemy demo.
-
Attacker TeamId = 0
-
Meaning: The attacker has
ITeamProvider, but its team ID is zero. -
Fix: Assign a meaningful attacker team or rely on the demo fallback.
-
Victims Share TeamId
-
Meaning: Ally and enemy currently resolve to the same team.
-
Fix: Give the enemy a different
TeamIdfor an other-team comparison. -
Demo Fallback Active
-
Meaning: Attacker has no
ITeamProvider, so the panel uses Ally TeamId as the attacker TeamId. -
Fix: Add
ITeamProviderto the attacker for production-style wiring. -
Other Damage Rules Detected
-
Meaning: Preview/Apply may include more than TeamRule.
-
Fix: Temporarily remove or disable other rules if you want isolated TeamRule behaviour.
-
Rule Blocked
-
Meaning: Both victims need
HealthSystembefore TeamRule testing can run. -
Fix: Return to Setup and fix missing HealthSystem bindings.
-
TeamRule Not Fully Ready
-
Meaning: A TeamRule is missing.
-
Fix: Enter Play Mode to let the demo add it, or add
TeamRulemanually. -
Preview / Apply Blocked
-
Meaning: Both victims need
HealthSystembefore preview/apply can run. -
Fix: Return to Setup and fix missing victim bindings.
-
Apply Requires Play Mode
-
Meaning: Attack buttons mutate health and are disabled outside Play Mode.
-
Fix: Enter Play Mode.
-
Zero Damage
-
Meaning: Amount is zero, so hits may be rejected or reduced to nothing.
-
Fix: Set Amount above 0.
-
No ally/enemy victim
-
Meaning: The selected attack target is missing.
-
Fix: Assign the missing victim in Setup.
-
AuthorityBlocked
-
Meaning: Damage was blocked by authority policy.
-
Fix: Check health authority settings or run from an allowed authority path.
-
Invincible
-
Meaning: Damage was blocked by invincibility.
-
Fix: Wait for i-frames to expire or disable the invincibility source.
-
DamageLocked
-
Meaning: Damage is currently locked.
-
Fix: Unlock damage or inspect the component/rule that enabled the lock.
-
TargetIsDead
-
Meaning: The selected victim is dead.
-
Fix: Revive or reset the victim before attacking again.
-
AbsorbedByShield
-
Meaning: Damage was fully absorbed by a shield.
-
Fix: Deplete/bypass shield or increase Amount if you want HP damage.
-
ZeroOrNegativeAmount
-
Meaning: Damage was reduced to zero by TeamRule, another rule, or damage math.
- Fix: Enable friendly fire, raise scale, increase Amount, or inspect other rules.
Behind The Scenes¶
HealthSystem— previews and applies damage for each victimDamageContext— carries attacker, victim, amount, tags, and attacker team IDDamageTag— passed into the damage contextITeamProvider— supplies team identity for attacker and victimsTeamRule— compares attacker team and victim team, then blocks or scales damageTeamRule.SetAllowFriendlyFire(...)— updates friendly-fire permissionTeamRule.SetFriendlyFireScale(...)— updates same-team damage scaleTeamRule.SetEnemyScale(...)— updates other-team damage scaleIDamageRule— used to detect other victim rules that may affect resultsHealthSystem.PreviewDamage(in ctx, includeShields:true)— authoritative previewHealthSystem.ApplyDamage(in ctx)— authoritative runtime mutation resultDamageResult— reports applied state, final amount, shield bypass state, and rejection reason
The panel uses public HealthSystem, TeamRule, damage-rule, and team-provider seams only. It does not access internals, use reflection, or fake damage results.
Key Takeaway¶
TeamRule uses team IDs to decide whether a hit is same-team or other-team damage.
It can block friendly fire, scale friendly fire, or scale enemy damage, while HealthSystem remains the source of truth for preview and apply results.
That keeps team logic out of weapons and callers, and lets the damage pipeline handle it consistently.