Beispiel #1
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!");
            }
        }
Beispiel #2
0
        void HandleBlockChange(Player p, ushort x, ushort y, ushort z, BlockID block, bool placing)
        {
            if (p.level != Map)
            {
                return;
            }
            CtfTeam team = TeamOf(p);

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

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

            if (pos == Opposing(team).FlagPos&& !Map.IsAirAt(x, y, z))
            {
                TakeFlag(p, team);
            }
            if (pos == team.FlagPos && !Map.IsAirAt(x, y, z))
            {
                ReturnFlag(p, team);
            }
        }
Beispiel #3
0
 void JoinTeam(Player p, CtfTeam team)
 {
     Get(p).HasFlag = false;
     team.Members.Add(p);
     Map.Message(p.ColoredName + " &Sjoined the " + team.ColoredName + " &Steam");
     p.Message("You are now on the " + team.ColoredName + " team!");
     TabList.Update(p, true);
 }
Beispiel #4
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;
                }
            }
        }
Beispiel #5
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);
        }
Beispiel #6
0
        public override void PlayerLeftGame(Player p)
        {
            CtfTeam team = TeamOf(p);

            if (team == null)
            {
                return;
            }
            team.Members.Remove(p);

            DropFlag(p, team);
        }
Beispiel #7
0
        void HandlePlayerDeath(Player p, BlockID deathblock)
        {
            if (p.level != Map || !Get(p).HasFlag)
            {
                return;
            }
            CtfTeam team = TeamOf(p);

            if (team != null)
            {
                DropFlag(p, team);
            }
        }
Beispiel #8
0
        bool OnOwnTeamSide(int z, CtfTeam team)
        {
            int baseZ = team.FlagPos.Z, zline = cfg.ZDivider;

            if (baseZ < zline && z < zline)
            {
                return(true);
            }
            if (baseZ > zline && z > zline)
            {
                return(true);
            }
            return(false);
        }
Beispiel #9
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);
        }
Beispiel #10
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);
        }
Beispiel #11
0
        void HandlePlayerChat(Player p, string message)
        {
            if (p.level != Map || !Get(p).TeamChatting)
            {
                return;
            }

            CtfTeam team = TeamOf(p);

            if (team == null)
            {
                return;
            }

            string prefix = team.Color + " - to " + team.Name;

            Chat.MessageChat(ChatScope.Level, p, prefix + " - λNICK: &f" + message,
                             Map, (pl, arg) => pl.Game.Referee || TeamOf(pl) == team);
            p.cancelchat = true;
        }
Beispiel #12
0
        void HandlePlayerSpawning(Player p, ref Position pos, ref byte yaw, ref byte pitch, bool respawning)
        {
            if (p.level != Map)
            {
                return;
            }
            CtfTeam team = TeamOf(p);

            if (team == null)
            {
                return;
            }
            if (respawning)
            {
                DropFlag(p, team);
            }

            Vec3U16 coords = team.SpawnPos;

            pos = Position.FromFeetBlockCoords(coords.X, coords.Y, coords.Z);
        }
Beispiel #13
0
        void HandleTabListEntryAdded(Entity entity, ref string tabName, ref string tabGroup, Player dst)
        {
            Player p = entity as Player;

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

            if (p.Game.Referee)
            {
                tabGroup = "&2Referees";
            }
            else if (team != null)
            {
                tabGroup = team.ColoredName + " team";
            }
            else
            {
                tabGroup = "&7Spectators";
            }
        }
Beispiel #14
0
 CtfTeam Opposing(CtfTeam team)
 {
     return(team == Red ? Blue : Red);
 }