home *** CD-ROM | disk | FTP | other *** search
- /*
- TeamFortress 1.1 - 28/8/96
-
- Robin Walker, John Cook, Ian Caughley.
-
- Functions handling all the help displaying for TeamFortress.
- */
- // Prototypes
- // Team Functions
- void(float funcno) TeamFortress_Team;
- void(float tno) TeamFortress_TeamSet;
- float(float tno) TeamFortress_TeamGetColor;
- void(float tno) TeamFortress_TeamSetColor;
- void() TeamFortress_CheckTeamCheats;
-
- //=========================================================================
- // TEAM FUNCTIONS
- //=========================================================================
- //=========================================================================
- // Frontend to the different Team Functions
- void(float funcno) TeamFortress_Team =
- {
- // prevent team pre-impulse from triggering anything else
- self.impulse = 0;
- self.last_impulse = 0;
-
- // The range of impulses from 1-TM_MAX_NO is used to set
- // the player's teamno.
- if ((funcno >= 1) && (funcno <= TM_MAX_NO))
- TeamFortress_TeamSet(funcno);
-
- //if (helpindex == TF_TEAM_LIST) Not implemented yet. :)
- // TeamFortress_TeamList();
-
- };
-
- //=========================================================================
- // Return the color for the team corresponding to the no passed in
- float(float tno) TeamFortress_TeamGetColor =
- {
- if (tno == 1)
- return team1col;
- if (tno == 2)
- return team2col;
- if (tno == 3)
- return team3col;
- if (tno == 4)
- return team4col;
-
- return 0;
- };
-
- //=========================================================================
- // Set the color for the team corresponding to the no passed in, to self.team
- void(float tno) TeamFortress_TeamSetColor =
- {
- if (tno == 1)
- {
- // Check to make sure no other team has this color
- if ((self.team != team2col) && (self.team != team3col) && (self.team != team4col))
- team1col = self.team;
- return;
- }
- if (tno == 2)
- {
- // Check to make sure no other team has this color
- if ((self.team != team1col) && (self.team != team3col) && (self.team != team4col))
- team2col = self.team;
- return;
- }
- if (tno == 3)
- {
- // Check to make sure no other team has this color
- if ((self.team != team1col) && (self.team != team2col) && (self.team != team4col))
- team3col = self.team;
- return;
- }
- if (tno == 4)
- {
- // Check to make sure no other team has this color
- if ((self.team != team1col) && (self.team != team2col) && (self.team != team3col))
- team4col = self.team;
- return;
- }
- };
-
- //=========================================================================
- // Set the current player's teamno to self.impulse.
- void(float tno) TeamFortress_TeamSet =
- {
- local string st;
- local float tc;
-
- if (teamplay < 1)
- {
- sprint(self, "Teamplay is not On, so FortressTeams are inactive.\n");
- return;
- }
-
- if (self.teamno > 0)
- {
- sprint(self, "You're already in Team No ");
- st = ftos(tno);
- sprint(self, st);
- sprint(self, ".\n");
- return;
- }
-
- // If the color for the team this player is changing to is 0,
- // then this is the first player in this team, and we set the
- // teamcolor to this player's pants color.
- // If not, we change this player's color to this team.
- if (TeamFortress_TeamGetColor(tno) == 0)
- {
- TeamFortress_TeamSetColor(tno);
- // If the color wasn't set
- if (TeamFortress_TeamGetColor(tno) == 0)
- {
- sprint(self, "You can't start a new team with your color, since another ");
- sprint(self, "already using that color. Change your pants color, then try again.\n");
- return;
- }
-
- // Announce the new team
- bprint(self.netname);
- bprint(" has started Team No ");
- st = ftos(tno);
- bprint(st);
- bprint(".\n");
- self.teamno = tno;
- return;
- }
-
- // Announce the new teammember
- bprint(self.netname);
- bprint(" has joined Team No ");
- st = ftos(tno);
- bprint(st);
- bprint(".\n");
-
- // Set the player's color
- stuffcmd(self, "color ");
- tc = TeamFortress_TeamGetColor(tno) - 1;
- st = ftos(tc);
- stuffcmd(self, st);
- stuffcmd(self, "\n");
- self.teamno = tno;
- };
-
- void() TeamFortress_CheckTeamCheats =
- {
- local string st;
- local float tc;
-
- if (self.teamno > 0 && teamplay > 0)
- {
- // Have they changed color?
- if (TeamFortress_TeamGetColor(self.teamno) != self.team)
- {
- // Tell everyone
- bprint("Naughty ");
- bprint(self.netname);
- bprint("! Don't change your colors in Teamplay!\n");
-
- // Set their color back :)
- stuffcmd(self, "color ");
- tc = TeamFortress_TeamGetColor(self.teamno) - 1;
- st = ftos(tc);
- stuffcmd(self, st);
- stuffcmd(self, "\n");
-
- // Lose 1 frag
- self.frags = self.frags - 1;
- }
- }
- };
-