home *** CD-ROM | disk | FTP | other *** search
/ Game Level Design / GLDesign.bin / Software / UnrealEngine2Runtime / UE2Runtime-22262001_Demo.exe / Engine / Classes / TeamInfo.uc < prev    next >
Text File  |  2003-06-23  |  2KB  |  101 lines

  1. //=============================================================================
  2. // TeamInfo.
  3. //=============================================================================
  4. class TeamInfo extends ReplicationInfo
  5.     native
  6.     nativereplication;
  7.  
  8. var localized string TeamName;
  9. var int Size; //number of players on this team in the level
  10. var float Score;
  11. var int TeamIndex;
  12. var color TeamColor, AltTeamColor;
  13. var Actor HomeBase;            // key objective associated with this team
  14. var() class<Pawn> DefaultPlayerClass;
  15. var localized string ColorNames[4];
  16. var Material TeamIcon;
  17.  
  18. replication
  19. {
  20.     // Variables the server should send to the client.
  21.     reliable if( bNetDirty && (Role==ROLE_Authority) )
  22.         Score, HomeBase;
  23.     reliable if ( bNetInitial && (Role==ROLE_Authority) )
  24.         TeamName, TeamColor, AltTeamColor, TeamIndex, TeamIcon;
  25. }
  26.  
  27. function bool BelongsOnTeam(class<Pawn> PawnClass)
  28. {
  29.     return true;
  30. }
  31.  
  32. simulated function UpdatePrecacheMaterials()
  33. {
  34.     Level.AddPrecacheMaterial(TeamIcon);
  35. }
  36.  
  37. simulated function string GetHumanReadableName()
  38. {
  39.     if ( TeamName == Default.TeamName )
  40.     {
  41.         if ( TeamIndex < 4 )
  42.             return ColorNames[TeamIndex];
  43.         return TeamName@TeamIndex;
  44.     }
  45.     return TeamName;
  46. }
  47.  
  48. function bool AddToTeam( Controller Other )
  49. {
  50.     local Controller P;
  51.     local bool bSuccess;
  52.  
  53.     // make sure loadout works for this team
  54.     if ( Other == None )
  55.     {
  56.         log("Added none to team!!!");
  57.         return false;
  58.     }
  59.  
  60.     if (MessagingSpectator(Other) != None)
  61.         return false;
  62.  
  63.     Size++;
  64.     Other.PlayerReplicationInfo.Team = self;
  65.  
  66.     bSuccess = false;
  67.     if ( Other.IsA('PlayerController') )
  68.         Other.PlayerReplicationInfo.TeamID = 0;
  69.     else
  70.         Other.PlayerReplicationInfo.TeamID = 1;
  71.  
  72.     while ( !bSuccess )
  73.     {
  74.         bSuccess = true;
  75.         for ( P=Level.ControllerList; P!=None; P=P.nextController )
  76.             if ( P.bIsPlayer && (P != Other) 
  77.                 && (P.PlayerReplicationInfo.Team == Other.PlayerReplicationInfo.Team) 
  78.                 && (P.PlayerReplicationInfo.TeamId == Other.PlayerReplicationInfo.TeamId) )
  79.                 bSuccess = false;
  80.         if ( !bSuccess )
  81.             Other.PlayerReplicationInfo.TeamID = Other.PlayerReplicationInfo.TeamID + 1;
  82.     }
  83.     return true;
  84. }
  85.  
  86. function RemoveFromTeam(Controller Other)
  87. {
  88.     Size--;
  89. }
  90.  
  91. defaultproperties
  92. {
  93.     TeamName="Team"
  94.     TeamColor=(R=255,G=0,B=0,A=255)
  95.     AltTeamColor=(R=200,G=0,B=0,A=255)
  96.     ColorNames(0)="Red"
  97.     ColorNames(1)="Blue"
  98.     ColorNames(2)="Green"
  99.     ColorNames(3)="Gold"
  100. }
  101.