Beispiel #1
0
        public void GameEnd(CTFTeam winTeam)
        {
            foreach (Player pl in mapOn.players)
            {
                if (pl.hidden && !pl.referee)
                {
                    Command.all.Find("hide").Use(pl, "s");
                }
                if (pl.invincible && !pl.referee)
                {
                    Command.all.Find("invincible").Use(pl, "");
                }
                if (pl.isFlying && !pl.referee)
                {
                    Command.all.Find("fly").Use(pl, "");
                }
                pl.userlinetype = "blockinfo";
            }
            mapOn.ChatLevel("The game has ended! " + winTeam.teamstring + " has won with " + winTeam.points + " point(s)!");
            foreach (CTFTeam team in teams)
            {
                ReturnFlag(null, team, false);
                foreach (Player p in team.players)
                {
                    p.hasflag      = null;
                    p.carryingFlag = false;
                }
                team.points = 0;
            }

            gameOn = false;
        }
Beispiel #2
0
        public void GrabFlag(Player p, CTFTeam team)
        {
            if (p.carryingFlag)
            {
                return;
            }
            ushort x = (ushort)(p.pos[0] / 32);
            ushort y = (ushort)((p.pos[1] / 32) + 3);
            ushort z = (ushort)(p.pos[2] / 32);

            team.tempFlagblock.x = x; team.tempFlagblock.y = y; team.tempFlagblock.z = z; team.tempFlagblock.type = mapOn.GetTile(x, y, z);

            mapOn.Blockchange(x, y, z, CTFTeam.GetColorBlock(team.color));

            mapOn.ChatLevel(p.color + p.prefix + p.name + "&g has stolen the " + team.teamstring + " flag!");
            p.hasflag        = team;
            p.carryingFlag   = true;
            team.holdingFlag = p;
            team.flagishome  = false;

            if (p.aiming)
            {
                p.ClearBlockchange();
                p.aiming = false;
            }
        }
Beispiel #3
0
        public void GameEnd(CTFTeam winTeam)
        {
            foreach (Player pl in mapOn.players)
            {
                if (pl.hidden && !pl.referee) { Command.all.Find("hide").Use(pl, "s"); }
                if (pl.invincible && !pl.referee) { Command.all.Find("invincible").Use(pl, ""); }
                if (pl.isFlying && !pl.referee) { Command.all.Find("fly").Use(pl, ""); }
                pl.userlinetype = "blockinfo";
            }
            mapOn.ChatLevel("The game has ended! " + winTeam.teamstring + " has won with " + winTeam.points + " point(s)!");
            foreach (CTFTeam team in teams)
            {
                ReturnFlag(null, team, false);
                foreach (Player p in team.players)
                {
                    p.hasflag = null;
                    p.carryingFlag = false;

                }
                team.points = 0;

            }

            gameOn = false;
        }
Beispiel #4
0
        public void AddFlag(Player p, string col, ushort x, ushort y, ushort z)
        {
            char    teamCol  = (char)col[1];
            CTFTeam workTeam = p.level.ctfgame.teams.Find(team => team.color == teamCol);

            workTeam.flagBase[0] = x;
            workTeam.flagBase[1] = y;
            workTeam.flagBase[2] = z;

            workTeam.flagLocation[0] = x;
            workTeam.flagLocation[1] = y;
            workTeam.flagLocation[2] = z;
            workTeam.Drawflag();
        }
Beispiel #5
0
        public void RemoveTeam(string color)
        {
            char teamCol = (char)color[1];

            CTFTeam       workteam = teams.Find(team => team.color == teamCol);
            List <Player> storedP  = new List <Player>();

            for (int i = 0; i < workteam.players.Count; i++)
            {
                storedP.Add(workteam.players[i]);
            }
            foreach (Player p in storedP)
            {
                workteam.RemoveMember(p);
            }
        }
Beispiel #6
0
        public void CaptureFlag(Player p, CTFTeam playerTeam, CTFTeam capturedTeam)
        {
            playerTeam.points++;
            mapOn.Blockchange(capturedTeam.tempFlagblock.x, capturedTeam.tempFlagblock.y, capturedTeam.tempFlagblock.z, capturedTeam.tempFlagblock.type);
            mapOn.ChatLevel(p.color + p.prefix + p.name + "&g has captured the " + capturedTeam.teamstring + " flag!");

            if (playerTeam.points >= maxPoints)
            {
                GameEnd(playerTeam);
                return;
            }

            mapOn.ChatLevel(playerTeam.teamstring + " now has " + playerTeam.points + " point(s).");
            p.hasflag      = null;
            p.carryingFlag = false;
            ReturnFlag(null, capturedTeam, false);
        }
Beispiel #7
0
        public void CaptureFlag(Player p, CTFTeam playerTeam, CTFTeam capturedTeam)
        {
            playerTeam.points++;
            mapOn.Blockchange(capturedTeam.tempFlagblock.x, capturedTeam.tempFlagblock.y, capturedTeam.tempFlagblock.z, capturedTeam.tempFlagblock.type);
            mapOn.ChatLevel(p.color + p.prefix + p.name + Server.DefaultColor + " has captured the " + capturedTeam.teamstring + " flag!");

            if (playerTeam.points >= maxPoints)
            {
                GameEnd(playerTeam);
                return;
            }

            mapOn.ChatLevel(playerTeam.teamstring + " now has " + playerTeam.points + " point(s).");
            p.hasflag = null;
            p.carryingFlag = false;
            ReturnFlag(null, capturedTeam, false);
        }
Beispiel #8
0
        public void Debug(Player p, string col)
        {
            if (col.ToLower() == "flags")
            {
                foreach (CTFTeam team in p.level.ctfgame.teams)
                {
                    Player.SendMessage(p, "Drawing flag for " + team.teamstring);
                    team.Drawflag();
                }
                return;
            }
            else if (col.ToLower() == "spawn")
            {
                foreach (CTFTeam team in p.level.ctfgame.teams)
                {
                    foreach (Player player in team.players)
                    {
                        team.SpawnPlayer(player);
                    }
                }
                return;
            }
            string  color      = c.Parse(col);
            char    teamCol    = (char)color[1];
            CTFTeam workTeam   = p.level.ctfgame.teams.Find(team => team.color == teamCol);
            string  debugteams = "";

            for (int i = 0; i < p.level.ctfgame.teams.Count; i++)
            {
                debugteams += p.level.ctfgame.teams[i].teamstring + ", ";
            }
            Player.SendMessage(p, "Player Debug: Team: " + p.team.teamstring /* + ", hasFlag: " + p.hasflag.teamstring + ", carryingFlag: " + p.carryingFlag*/);
            Player.SendMessage(p, "CTFGame teams: " + debugteams);
            string playerlist = "";

            foreach (Player player in workTeam.players)
            {
                playerlist += player.name + ", ";
            }
            Player.SendMessage(p, "Player list: " + playerlist);
            Player.SendMessage(p, "Points: " + workTeam.points + ", MapOn: " + workTeam.mapOn.name + ", flagishome: " + workTeam.flagishome + ", spawnset: " + workTeam.spawnset);
            Player.SendMessage(p, "FlagBase[0]: " + workTeam.flagBase[0] + ", [1]: " + workTeam.flagBase[1] + ", [2]: " + workTeam.flagBase[2]);
            Player.SendMessage(p, "FlagLocation[0]: " + workTeam.flagLocation[0] + ", [1]: " + workTeam.flagLocation[1] + ", [2]: " + workTeam.flagLocation[2]);
            //   Player.SendMessage(p, "Spawn[0]: " + workTeam.spawn[0] + ", [1]: " + workTeam.spawn[1] + ", [2]: " + workTeam.spawn[2] + ", [3]: " + workTeam.spawn[3] + ", [4]: " + workTeam.spawn[4]);
        }
Beispiel #9
0
        public void AddTeam(string color)
        {
            char teamCol = (char)color[1];

            CTFTeam workteam = new CTFTeam();

            workteam.color = teamCol;
            workteam.points = 0;
            workteam.mapOn = mapOn;
            char[] temp = c.Name("&" + teamCol).ToCharArray();
            temp[0] = char.ToUpper(temp[0]);
            string tempstring = new string(temp);
            workteam.teamstring = "&" + teamCol + tempstring + " team" + Server.DefaultColor;

            teams.Add(workteam);

            mapOn.ChatLevel(workteam.teamstring + " has been initialized!");
        }
Beispiel #10
0
        public void AddTeam(string color)
        {
            char teamCol = (char)color[1];

            CTFTeam workteam = new CTFTeam();

            workteam.color  = teamCol;
            workteam.points = 0;
            workteam.mapOn  = mapOn;
            char[] temp = c.Name("&" + teamCol).ToCharArray();
            temp[0] = char.ToUpper(temp[0]);
            string tempstring = new string(temp);

            workteam.teamstring = "&" + teamCol + tempstring + " team&g";

            teams.Add(workteam);

            mapOn.ChatLevel(workteam.teamstring + " has been initialized!");
        }
Beispiel #11
0
        public void DropFlag(Player p, CTFTeam team)
        {
            mapOn.ChatLevel(p.color + p.prefix + p.name + "&g has dropped the " + team.teamstring + " flag!");
            ushort x = (ushort)(p.pos[0] / 32);
            ushort y = (ushort)((p.pos[1] / 32) - 1);
            ushort z = (ushort)(p.pos[2] / 32);

            mapOn.Blockchange(team.tempFlagblock.x, team.tempFlagblock.y, team.tempFlagblock.z, team.tempFlagblock.type);

            team.flagLocation[0] = x;
            team.flagLocation[1] = y;
            team.flagLocation[2] = z;

            p.hasflag      = null;
            p.carryingFlag = false;

            team.holdingFlag = null;
            team.flagishome  = false;
        }
Beispiel #12
0
        public void DropFlag(Player p, CTFTeam team)
        {
            mapOn.ChatLevel(p.color + p.prefix + p.name + Server.DefaultColor + " has dropped the " + team.teamstring + " flag!");
            ushort x = (ushort)(p.pos[0] / 32);
            ushort y = (ushort)((p.pos[1] / 32) - 1);
            ushort z = (ushort)(p.pos[2] / 32);

            mapOn.Blockchange(team.tempFlagblock.x, team.tempFlagblock.y, team.tempFlagblock.z, team.tempFlagblock.type);

            team.flagLocation[0] = x;
            team.flagLocation[1] = y;
            team.flagLocation[2] = z;

            p.hasflag = null;
            p.carryingFlag = false;

            team.holdingFlag = null;
            team.flagishome = false;
        }
Beispiel #13
0
 public void ReturnFlag(Player p, CTFTeam team, bool verbose)
 {
     if (p != null && p.spawning)
     {
         return;
     }
     if (verbose)
     {
         if (p != null)
         {
             mapOn.ChatLevel(p.color + p.prefix + p.name + "&g has returned the " + team.teamstring + " flag!");
         }
         else
         {
             mapOn.ChatLevel("The " + team.teamstring + " flag has been returned.");
         }
     }
     team.holdingFlag     = null;
     team.flagLocation[0] = team.flagBase[0];
     team.flagLocation[1] = team.flagBase[1];
     team.flagLocation[2] = team.flagBase[2];
     team.flagishome      = true;
 }
Beispiel #14
0
 public override void Use(Player p, string message)
 {
     if (!p.level.ctfmode)
     {
         Player.SendMessage(p, "CTF has not been enabled for this map.");
         return;
     }
     if (message.Split(' ')[0].ToLower() == "set")
     {
         if (p.group.Permission >= LevelPermission.Operator)
         {
             string name = message.Split(' ')[1].ToLower();
             string team = message.Split(' ')[2].ToLower();
             if (team == "none")
             {
                 Player pl = Player.Find(name);
                 if (pl == null || pl.level != p.level)
                 {
                     Player.SendMessage(p, "That player does not exist or is not on your level.");
                 }
                 if (pl.team == null)
                 {
                     Player.SendMessage(p, "That player is not on a team.");
                 }
                 pl.team.RemoveMember(pl);
                 return;
             }
             string color = c.Parse(team);
             if (color == "")
             {
                 Player.SendMessage(p, "Invalid team color chosen."); return;
             }
             Player who = Player.Find(name);
             if (who == null || who.level != p.level)
             {
                 Player.SendMessage(p, "That player does not exist or is not on your level.");
             }
             char teamCol = (char)color[1];
             if (p.level.ctfgame.teams.Find(team1 => team1.color == teamCol) == null)
             {
                 Player.SendMessage(p, "Invalid team color chosen."); return;
             }
             CTFTeam workTeam = p.level.ctfgame.teams.Find(team1 => team1.color == teamCol);
             if (who.team != null)
             {
                 who.team.RemoveMember(who);
             }
             workTeam.AddMember(who);
         }
     }
     if (message.Split(' ')[0].ToLower() == "join")
     {
         string color = c.Parse(message.Split(' ')[1]);
         if (color == "")
         {
             Player.SendMessage(p, "Invalid team color chosen."); return;
         }
         char teamCol = (char)color[1];
         if (p.level.ctfgame.teams.Find(team => team.color == teamCol) == null)
         {
             Player.SendMessage(p, "Invalid team color chosen."); return;
         }
         CTFTeam workTeam = p.level.ctfgame.teams.Find(team => team.color == teamCol);
         if (p.team != null)
         {
             p.team.RemoveMember(p);
         }
         workTeam.AddMember(p);
     }
     else if (message.Split(' ')[0].ToLower() == "leave")
     {
         if (p.team != null)
         {
             p.team.RemoveMember(p);
         }
         else
         {
             Player.SendMessage(p, "You are not on a team.");
             return;
         }
     }
     else if (message.Split(' ')[0].ToLower() == "chat")
     {
         if (p.team == null)
         {
             Player.SendMessage(p, "You must be on a team before you can use team chat."); return;
         }
         p.teamchat = !p.teamchat;
         if (p.teamchat)
         {
             Player.SendMessage(p, "Team chat has been enabled.");
             return;
         }
         else
         {
             Player.SendMessage(p, "Team chat has been disabled.");
             return;
         }
     }
     else if (message.Split(' ')[0].ToLower() == "scores")
     {
         foreach (CTFTeam t in p.level.ctfgame.teams)
         {
             Player.SendMessage(p, t.teamstring + " has " + t.points + " point(s).");
         }
     }
 }
Beispiel #15
0
 public void ReturnFlag(Player p, CTFTeam team, bool verbose)
 {
     if (p != null && p.spawning) { return; }
     if (verbose)
     {
         if (p != null)
         {
             mapOn.ChatLevel(p.color + p.prefix + p.name + Server.DefaultColor + " has returned the " + team.teamstring + " flag!");
         }
         else
         {
             mapOn.ChatLevel("The " + team.teamstring + " flag has been returned.");
         }
     }
     team.holdingFlag = null;
     team.flagLocation[0] = team.flagBase[0];
     team.flagLocation[1] = team.flagBase[1];
     team.flagLocation[2] = team.flagBase[2];
     team.flagishome = true;
 }
Beispiel #16
0
        public void GrabFlag(Player p, CTFTeam team)
        {
            if (p.carryingFlag) { return; }
            ushort x = (ushort)(p.pos[0] / 32);
            ushort y = (ushort)((p.pos[1] / 32) + 3);
            ushort z = (ushort)(p.pos[2] / 32);

            team.tempFlagblock.x = x; team.tempFlagblock.y = y; team.tempFlagblock.z = z; team.tempFlagblock.type = mapOn.GetTile(x, y, z);

            mapOn.Blockchange(x, y, z, CTFTeam.GetColorBlock(team.color));

            mapOn.ChatLevel(p.color + p.prefix + p.name + Server.DefaultColor + " has stolen the " + team.teamstring + " flag!");
            p.hasflag = team;
            p.carryingFlag = true;
            team.holdingFlag = p;
            team.flagishome = false;

            if (p.aiming)
            {
                p.ClearBlockchange();
                p.aiming = false;
            }
        }