示例#1
0
        bool CheckTNTWarsChange(Player p, ushort x, ushort y, ushort z, ref byte block)
        {
            if (!(block == Block.TNT || block == Block.TNT_Big || block == Block.TNT_Nuke || block == Block.TNT_Small))
            {
                return(true);
            }

            TntWarsGame game = TntWarsGame.GameIn(p);

            if (game.InZone(x, y, z, true))
            {
                return(false);
            }

            if (p.CurrentAmountOfTnt == game.Config.MaxPlayerActiveTnt)
            {
                Player.Message(p, "TNT Wars: Maximum amount of TNT placed"); return(false);
            }
            if (p.CurrentAmountOfTnt > game.Config.MaxPlayerActiveTnt)
            {
                Player.Message(p, "TNT Wars: You have passed the maximum amount of TNT that can be placed!"); return(false);
            }
            p.TntAtATime();
            block = Block.TNT_Small;
            return(true);
        }
示例#2
0
        public override void Use(Player p, string message)
        {
            if (message.Length > 0)
            {
                Help(p); return;
            }
            bool     cpSpawn = p.useCheckpointSpawn;
            Position pos;

            pos.X = 16 + (cpSpawn ? p.checkpointX : p.level.spawnx) * 32;
            pos.Y = 32 + (cpSpawn ? p.checkpointY : p.level.spawny) * 32;
            pos.Z = 16 + (cpSpawn ? p.checkpointZ : p.level.spawnz) * 32;
            byte yaw   = cpSpawn ? p.checkpointRotX : p.level.rotx;
            byte pitch = cpSpawn ? p.checkpointRotY : p.level.roty;

            OnPlayerSpawningEvent.Call(p, ref pos, ref yaw, ref pitch, true);

            if (p.PlayingTntWars)
            {
                TntWarsGame game = TntWarsGame.GameIn(p);
                if (game.GameMode == TntWarsGame.TntWarsGameMode.TDM && game.GameStatus != TntWarsGame.TntWarsGameStatus.WaitingForPlayers &&
                    game.GameStatus != TntWarsGame.TntWarsGameStatus.Finished && game.RedSpawn != null && game.BlueSpawn != null)
                {
                    bool blue = game.FindPlayer(p).Blue;

                    pos.X = 16 + (blue ? game.BlueSpawn[0] : game.RedSpawn[0]) * 32;
                    pos.Y = 32 + (blue ? game.BlueSpawn[1] : game.RedSpawn[1]) * 32;
                    pos.Z = 16 + (blue ? game.BlueSpawn[2] : game.RedSpawn[2]) * 32;
                    yaw   = (byte)(blue ? game.BlueSpawn[3] : game.RedSpawn[3]);
                    pitch = (byte)(blue ? game.BlueSpawn[4] : game.RedSpawn[4]);
                }
            }

            p.SendPos(Entities.SelfID, pos, new Orientation(yaw, pitch));
        }
示例#3
0
        public void TntAtATime()
        {
            CurrentAmountOfTnt++;
            int delay = 0;

            switch (TntWarsGame.GameIn(this).Difficulty)
            {
            case TntWarsGame.TntWarsDifficulty.Easy:
                delay = 3250; break;

            case TntWarsGame.TntWarsDifficulty.Normal:
                delay = 2250; break;

            case TntWarsGame.TntWarsDifficulty.Hard:
            case TntWarsGame.TntWarsDifficulty.Extreme:
                delay = 1250; break;
            }
            Server.MainScheduler.QueueOnce(AllowMoreTntTask, null,
                                           TimeSpan.FromMilliseconds(delay));
        }
示例#4
0
        void HandleChat(byte[] buffer, int offset)
        {
            if (!loggedIn)
            {
                return;
            }
            byte   continued = buffer[offset + 1];
            string text      = NetUtils.ReadString(buffer, offset + 2);

            LastAction = DateTime.UtcNow;
            if (FilterChat(ref text, continued))
            {
                return;
            }

            if (text != "/afk" && IsAfk)
            {
                CmdAfk.ToggleAfk(this, "");
            }

            // Typing //Command appears in chat as /command
            // Suggested by McMrCat
            if (text.StartsWith("//"))
            {
                text = text.Remove(0, 1);
            }
            else if (DoCommand(text))
            {
                return;
            }

            // People who are muted can't speak or vote
            if (muted)
            {
                SendMessage("You are muted."); return;
            }                                                     //Muted: Only allow commands

            // Lava Survival map vote recorder
            if (Server.lava.HasPlayer(this) && Server.lava.HasVote(text.ToLower()))
            {
                if (Server.lava.AddVote(this, text.ToLower()))
                {
                    SendMessage("Your vote for &5" + text.ToLower().Capitalize() + " %Shas been placed. Thanks!");
                    Server.lava.map.ChatLevelOps(name + " voted for &5" + text.ToLower().Capitalize() + "%S.");
                    return;
                }
                else
                {
                    SendMessage("&cYou already voted!");
                    return;
                }
            }
            // Filter out bad words
            if (ServerConfig.ProfanityFiltering)
            {
                text = ProfanityFilter.Parse(text);
            }

            if (IsHandledMessage(text))
            {
                return;
            }

            // Put this after vote collection so that people can vote even when chat is moderated
            if (Server.chatmod && !voice)
            {
                SendMessage("Chat moderation is on, you cannot speak."); return;
            }

            if (ChatModes.Handle(this, text))
            {
                return;
            }

            if (text[0] == ':' && PlayingTntWars)
            {
                string      newtext = text.Remove(0, 1).Trim();
                TntWarsGame it      = TntWarsGame.GameIn(this);
                if (it.GameMode == TntWarsGame.TntWarsGameMode.TDM)
                {
                    TntWarsGame.player pl = it.FindPlayer(this);
                    foreach (TntWarsGame.player p in it.Players)
                    {
                        if (pl.Red && p.Red)
                        {
                            SendMessage(p.p, "To Team " + Colors.red + "-" + color + name + Colors.red + "- %S" + newtext);
                        }
                        if (pl.Blue && p.Blue)
                        {
                            SendMessage(p.p, "To Team " + Colors.blue + "-" + color + name + Colors.blue + "- %S" + newtext);
                        }
                    }

                    Logger.Log(LogType.GameActivity, "[TNT Wars] [TeamChat (" + (pl.Red ? "Red" : "Blue") + ") " + name + " " + newtext);
                    return;
                }
            }

            text = HandleJoker(text);
            if (Chatroom != null)
            {
                Chat.MessageChatRoom(this, text, true, Chatroom); return;
            }

            bool   levelOnly = !level.SeesServerWideChat;
            string format    = levelOnly ? "<{0}>[level] {1}" : "<{0}> {1}";

            Logger.Log(LogType.PlayerChat, format, name, text);

            OnPlayerChatEvent.Call(this, text);
            if (cancelchat)
            {
                cancelchat = false; return;
            }

            if (levelOnly)
            {
                Chat.MessageLevel(this, text, true, level);
            }
            else
            {
                SendChatFrom(this, text);
            }
            CheckForMessageSpam();
        }
示例#5
0
        void LeaveServer(string chatMsg, string discMsg, bool isKick, bool sync = false)
        {
            if (leftServer)
            {
                return;
            }
            leftServer = true;
            CriticalTasks.Clear();

            //Umm...fixed?
            if (name == null || name.Length == 0)
            {
                if (Socket != null)
                {
                    CloseSocket();
                }
                connections.Remove(this);
                disconnected = true;
                Logger.Log(LogType.UserActivity, "{0} disconnected.", ip);
                return;
            }

            Server.reviewlist.Remove(name);
            try {
                if (disconnected)
                {
                    CloseSocket();
                    connections.Remove(this);
                    PlayerInfo.Online.Remove(this);
                    return;
                }
                // FlyBuffer.Clear();
                LastAction = DateTime.UtcNow;
                IsAfk      = false;
                isFlying   = false;
                aiming     = false;

                if (chatMsg != null)
                {
                    chatMsg = Colors.Escape(chatMsg);
                }
                discMsg = Colors.Escape(discMsg);

                string kickPacketMsg = ChatTokens.Apply(discMsg, this);
                Send(Packet.Kick(kickPacketMsg, hasCP437), sync);
                disconnected = true;
                if (isKick)
                {
                    TimesBeenKicked++;
                }

                if (!loggedIn)
                {
                    connections.Remove(this);
                    RemoveFromPending();
                    PlayerInfo.Online.Remove(this);

                    string user = name + " (" + ip + ")";
                    Logger.Log(LogType.UserActivity, "{0} disconnected. ({1})", user, discMsg);
                    return;
                }

                if (Game.team != null)
                {
                    Game.team.RemoveMember(this);
                }
                TntWarsGame tntwarsgame = TntWarsGame.GameIn(this);
                if (tntwarsgame != null)
                {
                    tntwarsgame.Players.Remove(tntwarsgame.FindPlayer(this));
                    tntwarsgame.SendAllPlayersMessage("TNT Wars: " + ColoredName + " %Shas left TNT Wars!");
                }

                Entities.DespawnEntities(this, false);
                ShowDisconnectInChat(chatMsg, isKick);
                save();

                PlayerInfo.Online.Remove(this);
                Server.PlayerListUpdate();
                OnPlayerDisconnectEvent.Call(this, discMsg);

                if (ServerConfig.AutoLoadMaps && level.Config.AutoUnload && !level.IsMuseum && !level.HasPlayers())
                {
                    level.Unload(true);
                }
                Dispose();
            } catch (Exception e) {
                Logger.LogError(e);
            } finally {
                CloseSocket();
            }
        }
示例#6
0
        public static void DoSmallTnt(Level lvl, ref Check C)
        {
            ushort x, y, z;

            lvl.IntToPos(C.b, out x, out y, out z);
            Player p = GetPlayer(ref C.data);

            if (p != null && p.PlayingTntWars)
            {
                int         power = 2, threshold = 3;
                TntWarsGame game = TntWarsGame.GameIn(p);
                switch (game.Difficulty)
                {
                case TntWarsGame.TntWarsDifficulty.Easy:
                    threshold = 7; break;

                case TntWarsGame.TntWarsDifficulty.Normal:
                    threshold = 5; break;

                case TntWarsGame.TntWarsDifficulty.Extreme:
                    power = 3; break;
                }

                if ((C.data.Data >> 4) < threshold)
                {
                    C.data.Data += (1 << 4);
                    ToggleFuse(lvl, x, (ushort)(y + 1), z);
                    return;
                }
                if (p.TntWarsKillStreak >= game.Config.StreakTwoAmount && game.Config.Streaks)
                {
                    power++;
                }
                MakeExplosion(lvl, x, y, z, power - 2, true, game);

                List <Player> Killed  = new List <Player>();
                Player[]      players = PlayerInfo.Online.Items;
                foreach (Player p1 in players)
                {
                    if (p1.level == lvl && p1.PlayingTntWars && p1 != p &&
                        Math.Abs(p1.Pos.BlockX - x) + Math.Abs(p1.Pos.BlockY - y) + Math.Abs(p1.Pos.BlockZ - z) < ((power * 3) + 1))
                    {
                        Killed.Add(p1);
                    }
                }
                game.HandleKill(p, Killed);
            }
            else if (lvl.physics < 3)
            {
                lvl.Blockchange(x, y, z, ExtBlock.Air);
            }
            else
            {
                if (C.data.Data < 5 && lvl.physics == 3)
                {
                    C.data.Data++;
                    ToggleFuse(lvl, x, (ushort)(y + 1), z);
                    return;
                }
                MakeExplosion(lvl, x, y, z, 0);
            }
        }