Пример #1
0
        void HandleBlockChange(Player p, ushort x, ushort y, ushort z, ExtBlock block, bool placing)
        {
            if (!Game.started || p.level != Game.Map)
            {
                return;
            }
            CtfTeam2 team = Game.TeamOf(p);

            if (team == null)
            {
                p.RevertBlock(x, y, z);
                Player.Message(p, "You are not on a team!");
                p.cancelBlock = true;
                return;
            }

            Vec3U16 pos = new Vec3U16(x, y, z);

            if (pos == Game.Opposing(team).FlagPos&& !Game.Map.IsAirAt(x, y, z))
            {
                Game.TakeFlag(p, team);
            }
            if (pos == team.FlagPos && !Game.Map.IsAirAt(x, y, z))
            {
                Game.ReturnFlag(p, team);
            }
        }
Пример #2
0
        /// <summary> Called when the given player, while holding opposing team's flag, clicks on their own flag. </summary>
        public void ReturnFlag(Player p, CtfTeam2 team)
        {
            Vec3U16 flagPos = team.FlagPos;

            p.RevertBlock(flagPos.X, flagPos.Y, flagPos.Z);
            p.cancelBlock = true;

            CtfData data = Get(p);

            if (data.hasflag)
            {
                Chat.MessageLevel(Map, team.Color + p.DisplayName + " RETURNED THE FLAG!");
                data.hasflag = false;
                data.Points += Config.Capture_PointsGained;
                data.Captures++;

                CtfTeam2 opposing = Opposing(team);
                team.Points++;
                flagPos = opposing.FlagPos;
                Map.Blockchange(flagPos.X, flagPos.Y, flagPos.Z, opposing.FlagBlock);

                if (team.Points >= Config.RoundPoints)
                {
                    EndRound();
                }
            }
            else
            {
                Player.Message(p, "You cannot take your own flag!");
            }
        }
Пример #3
0
        /// <summary> Called when the given player takes the opposing team's flag. </summary>
        public void TakeFlag(Player p, CtfTeam2 team)
        {
            CtfTeam2 opposing = Opposing(team);

            Chat.MessageLevel(Map, team.Color + p.DisplayName + " took the " + opposing.ColoredName + " %Steam's FLAG");
            Get(p).hasflag = true;
        }
Пример #4
0
        /// <summary> Create a new CTF object </summary>
        public CTFGame()
        {
            Red  = new CtfTeam2("Red", Colors.red);
            Blue = new CtfTeam2("Blue", Colors.blue);

            tagging.Elapsed += CheckTagging;
            tagging.Start();
            plugin.Game = this;
            plugin.Load(false);
        }
Пример #5
0
        void HandlePlayerChat(Player p, string message)
        {
            if (Game.voting)
            {
                if (message == "1" || message.CaselessEq(Game.map1))
                {
                    Player.Message(p, "Thanks for voting :D");
                    Game.vote1++;
                    p.cancelchat = true;
                }
                else if (message == "2" || message.CaselessEq(Game.map2))
                {
                    Player.Message(p, "Thanks for voting :D");
                    Game.vote2++;
                    p.cancelchat = true;
                }
                else if (message == "3" || message.CaselessEq(Game.map3))
                {
                    Player.Message(p, "Thanks for voting :D");
                    Game.vote3++;
                    p.cancelchat = true;
                }
                else
                {
                    Player.Message(p, "%2VOTE:");
                    Player.Message(p, "1. " + Game.map1 + " 2. " + Game.map2 + " 3. " + Game.map3);
                    p.cancelchat = true;
                }
            }

            if (!Game.started || p.level != Game.Map)
            {
                return;
            }
            if (!Game.Get(p).TeamChatting)
            {
                return;
            }

            CtfTeam2 team = Game.TeamOf(p);

            if (team == null)
            {
                return;
            }
            Player[] members = team.Members.Items;

            foreach (Player pl in members)
            {
                Player.Message(pl, "({0}) {1}: &f{2}", team.Name, p.ColoredName, message);
            }
            p.cancelchat = true;
        }
Пример #6
0
        bool OnOwnTeamSide(int z, CtfTeam2 team)
        {
            int baseZ = team.FlagPos.Z, zline = Config.ZDivider;

            if (baseZ < zline && z < zline)
            {
                return(true);
            }
            if (baseZ > zline && z > zline)
            {
                return(true);
            }
            return(false);
        }
Пример #7
0
        public void JoinTeam(Player p, CtfTeam2 team)
        {
            if (Get(p) == null)
            {
                cache.Add(new CtfData(p));
            }
            else
            {
                Get(p).hasflag = false;
            }

            team.Members.Add(p);
            Chat.MessageLevel(Map, p.ColoredName + " %Sjoined the " + team.ColoredName + " %Steam");
            Player.Message(p, "You are now on the " + team.ColoredName + " team!");
        }
Пример #8
0
        void HandleDisconnect(Player p, string reason)
        {
            if (p.level != Game.Map)
            {
                return;
            }
            CtfTeam2 team = Game.TeamOf(p);

            if (team == null)
            {
                return;
            }

            Game.DropFlag(p, team);
            team.Remove(p);
            Chat.MessageLevel(Game.Map, team.Color + p.DisplayName + " %Sleft the ctf game");
        }
Пример #9
0
        void CheckTagging(object sender, System.Timers.ElapsedEventArgs e)
        {
            Player[] online = PlayerInfo.Online.Items;
            foreach (Player p in online)
            {
                if (p.level != Map)
                {
                    continue;
                }

                CtfTeam2 team = TeamOf(p);
                if (team == null || Get(p).tagging)
                {
                    continue;
                }
                if (!OnOwnTeamSide(p.Pos.BlockZ, team))
                {
                    continue;
                }
                CtfTeam2 opposing = Opposing(team);

                Player[] opponents = opposing.Members.Items;
                foreach (Player other in opponents)
                {
                    if (!MovementCheck.InRange(p, other, 2 * 32))
                    {
                        continue;
                    }

                    Get(other).tagging = true;
                    Player.Message(other, p.ColoredName + " %Stagged you!");
                    Command.all.FindByName("Spawn").Use(other, "");
                    Thread.Sleep(300);

                    if (Get(other).hasflag)
                    {
                        DropFlag(p, opposing);
                    }
                    Get(p).Points     += Config.Tag_PointsGained;
                    Get(other).Points -= Config.Tag_PointsLost;
                    Get(p).Tags++;
                    Get(other).tagging = false;
                }
            }
        }
Пример #10
0
        void HandlePlayerDeath(Player p, ExtBlock deathblock)
        {
            if (!Game.started || p.level != Game.Map)
            {
                return;
            }
            if (!Game.Get(p).hasflag)
            {
                return;
            }

            CtfTeam2 team = Game.TeamOf(p);

            if (team != null)
            {
                Game.DropFlag(p, team);
            }
        }
Пример #11
0
        void HandlePlayerSpawning(Player p, ref Position pos, ref byte yaw, ref byte pitch, bool respawning)
        {
            if (!Game.started || p.level != Game.Map)
            {
                return;
            }

            CtfTeam2 team = Game.TeamOf(p);

            if (team != null)
            {
                pos = team.SpawnPos;
            }
            if (team != null && respawning)
            {
                Game.DropFlag(p, team);
            }
        }
Пример #12
0
        /// <summary> Called when the given player drops the opposing team's flag. </summary>
        public void DropFlag(Player p, CtfTeam2 team)
        {
            CtfData data = Get(p);

            if (!data.hasflag)
            {
                return;
            }

            data.hasflag = false;
            Chat.MessageLevel(Map, team.Color + p.DisplayName + " DROPPED THE FLAG!");
            data.Points -= Config.Capture_PointsLost;

            CtfTeam2 opposing = Opposing(team);
            Vec3U16  pos      = opposing.FlagPos;

            Map.Blockchange(pos.X, pos.Y, pos.Z, opposing.FlagBlock);
        }
Пример #13
0
        void HandleOnJoinedLevel(Player p, Level prevLevel, Level level)
        {
            if (p == null || !Game.started)
            {
                return;
            }

            if (prevLevel == Game.Map)
            {
                CtfTeam2 team = Game.TeamOf(p);
                if (team == null)
                {
                    return;
                }

                Game.DropFlag(p, team);
                team.Remove(p);
                Chat.MessageLevel(Game.Map, team.Color + p.DisplayName + " %Sleft the ctf game");
            }
            else if (level == Game.Map)
            {
                if (Game.Blue.Members.Count > Game.Red.Members.Count)
                {
                    Game.JoinTeam(p, Game.Red);
                }
                else if (Game.Red.Members.Count > Game.Blue.Members.Count)
                {
                    Game.JoinTeam(p, Game.Blue);
                }
                else if (new Random().Next(2) == 0)
                {
                    Game.JoinTeam(p, Game.Red);
                }
                else
                {
                    Game.JoinTeam(p, Game.Blue);
                }
            }
        }
Пример #14
0
        void HandleTabListEntryAdded(Entity entity, ref string tabName, ref string tabGroup, Player dst)
        {
            Player p = entity as Player;

            if (p == null || !Game.started || p.level != Game.Map)
            {
                return;
            }
            CtfTeam2 team = Game.TeamOf(p);

            if (p.Game.Referee)
            {
                tabGroup = "&2Referees";
            }
            else if (team != null)
            {
                tabGroup = team.ColoredName + " team";
            }
            else
            {
                tabGroup = "&7Spectators";
            }
        }
Пример #15
0
        /// <summary> Start the CTF game </summary>
        public bool Start(Player p)
        {
            if (started)
            {
                Player.Message(p, "CTF game already running."); return(false);
            }

            List <string> maps = GetCtfMaps();

            if (maps.Count == 0)
            {
                Player.Message(p, "No CTF maps were found."); return(false);
            }

            Blue = new CtfTeam2("Blue", Colors.blue);
            Red  = new CtfTeam2("Red", Colors.red);
            SetMap(maps[new Random().Next(maps.Count)]);

            Logger.Log(LogType.GameActivity, "[CTF] Running...");
            started = true;
            Database.Backend.CreateTable("CTF", createSyntax);
            return(true);
        }
Пример #16
0
 public CtfTeam2 Opposing(CtfTeam2 team)
 {
     return(team == Red ? Blue : Red);
 }