home *** CD-ROM | disk | FTP | other *** search
/ Quake 'em / QUAKEEM.BIN / quake / programs / tf1_1src / tforttm.qc < prev    next >
Encoding:
Text File  |  1996-08-30  |  4.4 KB  |  177 lines

  1. /* 
  2.     TeamFortress 1.1    -    28/8/96
  3.  
  4.     Robin Walker, John Cook, Ian Caughley.
  5.  
  6.     Functions handling all the help displaying for TeamFortress. 
  7. */
  8. // Prototypes
  9. // Team Functions
  10. void(float funcno) TeamFortress_Team;
  11. void(float tno) TeamFortress_TeamSet;
  12. float(float tno) TeamFortress_TeamGetColor;
  13. void(float tno) TeamFortress_TeamSetColor;
  14. void() TeamFortress_CheckTeamCheats;
  15.  
  16. //=========================================================================
  17. // TEAM FUNCTIONS
  18. //=========================================================================
  19. //=========================================================================
  20. // Frontend to the different Team Functions
  21. void(float funcno) TeamFortress_Team =
  22. {
  23.     // prevent team pre-impulse from triggering anything else
  24.     self.impulse = 0;
  25.     self.last_impulse = 0;
  26.  
  27.     // The range of impulses from 1-TM_MAX_NO is used to set 
  28.     // the player's teamno.
  29.     if ((funcno >= 1) && (funcno <= TM_MAX_NO))
  30.         TeamFortress_TeamSet(funcno);
  31.  
  32.     //if (helpindex == TF_TEAM_LIST)        Not implemented yet. :)
  33.     //    TeamFortress_TeamList();
  34.  
  35. };
  36.  
  37. //=========================================================================
  38. // Return the color for the team corresponding to the no passed in
  39. float(float tno) TeamFortress_TeamGetColor =
  40. {
  41.     if (tno == 1)
  42.         return team1col;
  43.     if (tno == 2)
  44.         return team2col;
  45.     if (tno == 3)
  46.         return team3col;
  47.     if (tno == 4)
  48.         return team4col;
  49.  
  50.     return 0;
  51. };
  52.  
  53. //=========================================================================
  54. // Set the color for the team corresponding to the no passed in, to self.team
  55. void(float tno) TeamFortress_TeamSetColor =
  56. {
  57.     if (tno == 1)
  58.     {
  59.         // Check to make sure no other team has this color
  60.         if ((self.team != team2col) && (self.team != team3col) && (self.team != team4col))
  61.             team1col = self.team;
  62.         return;
  63.     }
  64.     if (tno == 2)
  65.     {
  66.         // Check to make sure no other team has this color
  67.         if ((self.team != team1col) && (self.team != team3col) && (self.team != team4col))
  68.             team2col = self.team;
  69.         return;
  70.     }
  71.     if (tno == 3)
  72.     {
  73.         // Check to make sure no other team has this color
  74.         if ((self.team != team1col) && (self.team != team2col) && (self.team != team4col))
  75.             team3col = self.team;
  76.         return;
  77.     }
  78.     if (tno == 4)
  79.     {
  80.         // Check to make sure no other team has this color
  81.         if ((self.team != team1col) && (self.team != team2col) && (self.team != team3col))
  82.             team4col = self.team;
  83.         return;
  84.     }
  85. };
  86.  
  87. //=========================================================================
  88. // Set the current player's teamno to self.impulse.
  89. void(float tno) TeamFortress_TeamSet =
  90. {
  91.     local string st;
  92.     local float tc;
  93.  
  94.     if (teamplay < 1)
  95.     {
  96.         sprint(self, "Teamplay is not On, so FortressTeams are inactive.\n");
  97.         return;
  98.     }
  99.  
  100.     if (self.teamno > 0)
  101.     {
  102.         sprint(self, "You're already in Team No ");
  103.         st = ftos(tno);
  104.         sprint(self, st);
  105.         sprint(self, ".\n");
  106.         return;
  107.     }
  108.  
  109.     // If the color for the team this player is changing to is 0,
  110.     // then this is the first player in this team, and we set the
  111.     // teamcolor to this player's pants color.
  112.     // If not, we change this player's color to this team.
  113.     if (TeamFortress_TeamGetColor(tno) == 0)
  114.     {
  115.         TeamFortress_TeamSetColor(tno);
  116.         // If the color wasn't set
  117.         if (TeamFortress_TeamGetColor(tno) == 0)
  118.         {
  119.             sprint(self, "You can't start a new team with your color, since another ");
  120.             sprint(self, "already using that color. Change your pants color, then try again.\n");
  121.             return;
  122.         }
  123.  
  124.         // Announce the new team
  125.         bprint(self.netname);
  126.         bprint(" has started Team No ");
  127.         st = ftos(tno);
  128.         bprint(st);
  129.         bprint(".\n");
  130.         self.teamno = tno;
  131.         return;
  132.     }
  133.  
  134.     // Announce the new teammember
  135.     bprint(self.netname);
  136.     bprint(" has joined Team No ");
  137.     st = ftos(tno);
  138.     bprint(st);
  139.     bprint(".\n");
  140.  
  141.     // Set the player's color
  142.     stuffcmd(self, "color ");
  143.     tc = TeamFortress_TeamGetColor(tno) - 1;
  144.     st = ftos(tc);
  145.     stuffcmd(self, st);
  146.     stuffcmd(self, "\n");
  147.     self.teamno = tno;
  148. };
  149.  
  150. void() TeamFortress_CheckTeamCheats =
  151. {
  152.     local string st;
  153.     local float tc;
  154.  
  155.     if (self.teamno > 0 && teamplay > 0)
  156.     {
  157.         // Have they changed color?
  158.         if (TeamFortress_TeamGetColor(self.teamno) != self.team)
  159.         {
  160.             // Tell everyone
  161.             bprint("Naughty ");
  162.             bprint(self.netname);
  163.             bprint("! Don't change your colors in Teamplay!\n");
  164.  
  165.             // Set their color back :)
  166.             stuffcmd(self, "color ");
  167.             tc = TeamFortress_TeamGetColor(self.teamno) - 1;
  168.             st = ftos(tc);
  169.             stuffcmd(self, st);
  170.             stuffcmd(self, "\n");
  171.  
  172.             // Lose 1 frag
  173.             self.frags = self.frags - 1;
  174.         }
  175.     }
  176. };
  177.