Skip to content
Pablo Rodriguez

Team System

With AI characters now using projectiles alongside players, implementing a team system prevents friendly fire and ensures proper combat targeting.

Create enumeration for team identification:

  • Player: Player character team
  • Enemy: AI character team
  • Neutral: Non-combatant characters (NPCs, environmental)

This simple structure supports most combat scenarios while remaining extensible for future team types.

Modify projectile system to respect team allegiance:

  • Team Variable: Team enumeration type
  • Instance Editable: Allow runtime team assignment
  • Expose on Spawn: Set team when projectile spawns
// Projectile Team Checking
OnProjectileHit(OtherActor) {
if (OtherActor != Owner) {
other_actor_team = OtherActor.Interface_Get_Team();
if (other_actor_team != projectile_team) {
// Different teams - apply damage
ApplyDamage(OtherActor);
} else {
// Same team - projectile passes through
ContinueMovement();
}
}
}

Implement team identification for all characters:

  • Interface_Get_Team: Returns character’s team enumeration
  • Team Variable: Store team assignment in master character
  • Default Values: Set appropriate defaults for different character types
// Character Team Configuration
// Player Character Class Defaults:
Team = Player;
// AI Master Character Class Defaults:
Team = Enemy;
// NPC Character Class Defaults:
Team = Neutral;

Ensure projectiles inherit shooter’s team:

Modify F_Spawn_Projectile function to include team assignment:

// Team-Aware Projectile Spawning
F_Spawn_Projectile(Parameters...) {
shooter_team = GetTeam();
spawned_projectile = SpawnActor(ProjectileClass, Location, Rotation);
spawned_projectile.Team = shooter_team;
}
  • Owner Team: Projectiles automatically inherit owner’s team
  • Consistent Behavior: All projectile types respect team assignments
  • No Manual Assignment: Team assignment happens automatically during spawn

Team system prevents accidental damage between allies:

  • Team Matching: AI characters on same team ignore each other’s attacks
  • Projectile Passthrough: Friendly projectiles don’t trigger hit events
  • Melee Exclusion: Melee attacks exclude same-team targets
  • Allied NPCs: If NPCs set to player team, they won’t be damaged by player
  • Environmental Safety: Neutral team entities unaffected by combat

Test team system functionality:

  • Spawn multiple AI characters
  • Verify AI projectiles don’t damage each other
  • Confirm AI projectiles damage player character
  • Test player projectiles damage AI but not other players (in multiplayer scenarios)
  • Runtime Changes: Verify team changes work correctly
  • Projectile Updates: Existing projectiles maintain original team assignment
  • State Consistency: Team changes don’t break existing combat interactions

The team system provides essential combat organization while maintaining simple, extensible architecture for future gameplay modes requiring faction-based or team-based mechanics.