コード例 #1
0
        void HandlePlayerCommand(Player p, string cmd, string args)
        {
            if (!Game.started || p.level != Game.Map || cmd != "teamchat")
            {
                return;
            }
            CtfData data = Game.Get(p);

            if (data == null)
            {
                return;
            }

            if (data.TeamChatting)
            {
                Player.Message(data.p, "You are no longer chatting with your team!");
            }
            else
            {
                Player.Message(data.p, "You are now chatting with your team!");
            }

            data.TeamChatting = !data.TeamChatting;
            p.cancelcommand   = true;
        }
コード例 #2
0
        /// <summary> Called when the given player, while holding opposing team's flag, clicks on their own flag. </summary>
        void ReturnFlag(Player p, CtfTeam team)
        {
            Vec3U16 flagPos = team.FlagPos;

            p.RevertBlock(flagPos.X, flagPos.Y, flagPos.Z);

            CtfData data = Get(p);

            if (data.HasFlag)
            {
                Map.Message(team.Color + p.DisplayName + " RETURNED THE FLAG!");
                data.HasFlag = false;
                ResetPlayerFlag(p, data);

                data.Points += cfg.Capture_PointsGained;
                data.Captures++;
                team.Captures++;

                CtfTeam opposing = Opposing(team);
                opposing.RespawnFlag(Map);
            }
            else
            {
                p.Message("You cannot take your own flag!");
            }
        }
コード例 #3
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!");
            }
        }
コード例 #4
0
        void ResetPlayerFlag(Player p, CtfData data)
        {
            Vec3S32 last = data.LastHeadPos;
            ushort  x = (ushort)last.X, y = (ushort)last.Y, z = (ushort)last.Z;

            data.LastHeadPos = default(Vec3S32);
            Map.BroadcastRevert(x, y, z);
        }
コード例 #5
0
        void Tick()
        {
            int dist = (int)(Config.TagDistance * 32);

            Player[] online = PlayerInfo.Online.Items;

            foreach (Player p in online)
            {
                if (p.level != Map)
                {
                    continue;
                }
                CtfTeam team = TeamOf(p);
                CtfData data = Get(p);

                // Draw flag above player head
                if (data.HasFlag)
                {
                    DrawPlayerFlag(p, data);
                }

                if (team == null || data.TagCooldown)
                {
                    continue;
                }
                if (!OnOwnTeamSide(p.Pos.BlockZ, team))
                {
                    continue;
                }
                CtfTeam opposing = Opposing(team);

                Player[] opponents = opposing.Members.Items;
                foreach (Player other in opponents)
                {
                    if (!InRange(p, other, dist))
                    {
                        continue;
                    }
                    CtfData otherData = Get(other);

                    otherData.TagCooldown = true;
                    other.Message(p.ColoredName + " &Stagged you!");
                    PlayerActions.Respawn(other);
                    Thread.Sleep(300); // TODO: get rid of this

                    if (otherData.HasFlag)
                    {
                        DropFlag(p, opposing);
                    }
                    data.Points      += cfg.Tag_PointsGained;
                    otherData.Points -= cfg.Tag_PointsLost;
                    data.Tags++;
                    otherData.TagCooldown = false;
                }
            }
        }
コード例 #6
0
        /// <summary> Called when the given player takes the opposing team's flag. </summary>
        void TakeFlag(Player p, CtfTeam team)
        {
            CtfTeam opposing = Opposing(team);

            Map.Message(team.Color + p.DisplayName + " took the " + opposing.ColoredName + " &Steam's FLAG");

            CtfData data = Get(p);

            data.HasFlag = true;
            DrawPlayerFlag(p, data);
        }
コード例 #7
0
ファイル: CtfGame.Round.cs プロジェクト: TheDireMaster/McDire
        void ResetPlayerFlag(Player p, CtfData data)
        {
            Vec3S32 last = data.LastHeadPos;
            ushort  x = (ushort)last.X, y = (ushort)last.Y, z = (ushort)last.Z;

            data.LastHeadPos = default(Vec3S32);

            BlockID origBlock = Map.GetBlock(x, y, z);

            if (origBlock != Block.Invalid)
            {
                Player.GlobalBlockchange(Map, x, y, z, origBlock);
            }
        }
コード例 #8
0
        void DrawPlayerFlag(Player p, CtfData data)
        {
            Vec3S32 coords = p.Pos.BlockCoords; coords.Y += 3;

            if (coords == data.LastHeadPos)
            {
                return;
            }
            ResetPlayerFlag(p, data);

            data.LastHeadPos = coords;
            ushort  x = (ushort)coords.X, y = (ushort)coords.Y, z = (ushort)coords.Z;
            CtfTeam opposing = Opposing(TeamOf(p));

            Map.BroadcastChange(x, y, z, opposing.FlagBlock);
        }
コード例 #9
0
        static CtfData Get(Player p)
        {
            CtfData data = TryGet(p);

            if (data != null)
            {
                return(data);
            }
            data = new CtfData();

            // TODO: Is this even thread-safe
            CtfStats s = LoadStats(p.name);

            data.Captures = s.Captures; data.Points = s.Points; data.Tags = s.Tags;

            p.Extras[ctfExtrasKey] = data;
            return(data);
        }
コード例 #10
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);
        }
コード例 #11
0
        /// <summary> Called when the given player drops the opposing team's flag. </summary>
        void DropFlag(Player p, CtfTeam team)
        {
            CtfData data = Get(p);

            if (!data.HasFlag)
            {
                return;
            }

            data.HasFlag = false;
            ResetPlayerFlag(p, data);

            Map.Message(team.Color + p.DisplayName + " DROPPED THE FLAG!");
            data.Points -= cfg.Capture_PointsLost;

            CtfTeam opposing = Opposing(team);

            opposing.RespawnFlag(Map);
        }
コード例 #12
0
        void HandlePlayerCommand(Player p, string cmd, string args, CommandData data)
        {
            if (p.level != Map || cmd != "teamchat")
            {
                return;
            }
            CtfData data_ = Get(p);

            if (data_.TeamChatting)
            {
                p.Message("You are no longer chatting with your team!");
            }
            else
            {
                p.Message("You are now chatting with your team!");
            }

            data_.TeamChatting = !data_.TeamChatting;
            p.cancelcommand    = true;
        }
コード例 #13
0
        protected override void SaveStats(Player p)
        {
            CtfData data = TryGet(p);

            if (data == null || data.Points == 0 && data.Captures == 0 && data.Tags == 0)
            {
                return;
            }

            int count = Database.CountRows("CTF", "WHERE Name=@0", p.name);

            if (count == 0)
            {
                Database.AddRow("CTF", "Points, Captures, tags, Name",
                                data.Points, data.Captures, data.Tags, p.name);
            }
            else
            {
                Database.UpdateRows("CTF", "Points=@0, Captures=@1, tags=@2", "WHERE Name=@3",
                                    data.Points, data.Captures, data.Tags, p.name);
            }
        }
コード例 #14
0
        void ResetFlagsState()
        {
            Blue.RespawnFlag(Map);
            Red.RespawnFlag(Map);
            Player[] players = PlayerInfo.Online.Items;

            foreach (Player p in players)
            {
                if (p.level != Map)
                {
                    continue;
                }
                CtfData data = Get(p);

                if (!data.HasFlag)
                {
                    continue;
                }
                data.HasFlag = false;
                ResetPlayerFlag(p, data);
            }
        }