Ejemplo n.º 1
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
            List<Pos> buffer = new List<Pos>();

            for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
            {
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                {
                    for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        if (p.level.GetTile(xx, yy, zz) == type) { BufferAdd(buffer, xx, yy, zz); }
                    }
                }
            }

            if (buffer.Count > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to replace " + buffer.Count + " blocks.");
                Player.SendMessage(p, "You cannot replace more than " + p.group.maxBlocks + ".");
                return;
            }

            Player.SendMessage(p, buffer.Count.ToString() + " blocks.");
            buffer.ForEach(delegate(Pos pos)
            {
                p.level.Blockchange(p, pos.x, pos.y, pos.z, cpos.type2);                  //update block for everyone
            });

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 2
0
        public void EntryChange(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            portalPos bp = (portalPos)p.blockchangeObject;

            if (bp.Multi && type == Block.red && bp.port.Count > 0) { ExitChange(p, x, y, z, type); return; }

            byte b = p.level.GetTile(x, y, z);
            p.level.Blockchange(p, x, y, z, bp.type);
            p.SendBlockchange(x, y, z, Block.green);
            portPos Port;

            Port.portMapName = p.level.name;
            Port.x = x; Port.y = y; Port.z = z;

            bp.port.Add(Port);

            p.blockchangeObject = bp;

            if (!bp.Multi)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(ExitChange);
                Player.SendMessage(p, "&aEntry block placed");
            }
            else
            {
                p.Blockchange += new Player.BlockchangeEventHandler(EntryChange);
                Player.SendMessage(p, "&aEntry block placed. &cRed block for exit");
            }
        }
Ejemplo n.º 3
0
        public void ExitChange(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            portalPos bp = (portalPos)p.blockchangeObject;

            foreach (portPos pos in bp.port)
            {
                DataTable Portals = MySQL.fillData("SELECT * FROM `Portals" + pos.portMapName + "` WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z);
                Portals.Dispose();

                if (Portals.Rows.Count == 0)
                {
                    MySQL.executeQuery("INSERT INTO `Portals" + pos.portMapName + "` (EntryX, EntryY, EntryZ, ExitMap, ExitX, ExitY, ExitZ) VALUES (" + (int)pos.x + ", " + (int)pos.y + ", " + (int)pos.z + ", '" + p.level.name + "', " + (int)x + ", " + (int)y + ", " + (int)z + ")");
                }
                else
                {
                    MySQL.executeQuery("UPDATE `Portals" + pos.portMapName + "` SET ExitMap='" + p.level.name + "', ExitX=" + (int)x + ", ExitY=" + (int)y + ", ExitZ=" + (int)z + " WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z);
                }
                //DB

                if (pos.portMapName == p.level.name) p.SendBlockchange(pos.x, pos.y, pos.z, bp.type);
            }

            Player.SendMessage(p, "&3Exit" + Server.DefaultColor + " block placed");

            if (p.staticCommands) { bp.port.Clear(); p.blockchangeObject = bp; p.Blockchange += new Player.BlockchangeEventHandler(EntryChange); }
        }
Ejemplo n.º 4
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            cpos.message = cpos.message.Replace("'", "\\'");

            DataTable Messages = MySQL.fillData("SELECT * FROM `Messages" + p.level.name + "` WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);
            Messages.Dispose();

            if (Messages.Rows.Count == 0)
            {
                MySQL.executeQuery("INSERT INTO `Messages" + p.level.name + "` (X, Y, Z, Message) VALUES (" + (int)x + ", " + (int)y + ", " + (int)z + ", '" + cpos.message + "')");
            }
            else
            {
                MySQL.executeQuery("UPDATE `Messages" + p.level.name + "` SET Message='" + cpos.message + "' WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);
            }

            Player.SendMessage(p, "Message block placed.");
            p.level.Blockchange(p, x, y, z, cpos.type);
            p.SendBlockchange(x, y, z, cpos.type);

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 5
0
        public override void Use(Player p, string message)
        {
            p.staticCommands = !p.staticCommands;
            p.ClearBlockchange();
            p.BlockAction = 0;

            Player.SendMessage(p, "Static mode: &a" + p.staticCommands.ToString());

            try
            {
                if (message != "")
                {
                    if (message.IndexOf(' ') == -1)
                    {
                        if (p.group.CanExecute(Command.all.Find(message)))
                            Command.all.Find(message).Use(p, "");
                        else
                            Player.SendMessage(p, "Cannot use that command.");
                    }
                    else
                    {
                        if (p.group.CanExecute(Command.all.Find(message.Split(' ')[0])))
                            Command.all.Find(message.Split(' ')[0]).Use(p, message.Substring(message.IndexOf(' ') + 1));
                        else
                            Player.SendMessage(p, "Cannot use that command.");
                    }
                }
            }
            catch { Player.SendMessage(p, "Could not find specified command"); }
        }
Ejemplo n.º 6
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            Level.Zone Zn;

            Zn.smallX = Math.Min(cpos.x, x);
            Zn.smallY = Math.Min(cpos.y, y);
            Zn.smallZ = Math.Min(cpos.z, z);
            Zn.bigX = Math.Max(cpos.x, x);
            Zn.bigY = Math.Max(cpos.y, y);
            Zn.bigZ = Math.Max(cpos.z, z);
            Zn.Owner = cpos.Owner;

            p.level.ZoneList.Add(Zn);

            //DB
            MySQL.executeQuery("INSERT INTO `Zone" + p.level.name + "` (SmallX, SmallY, SmallZ, BigX, BigY, BigZ, Owner) VALUES (" + Zn.smallX + ", " + Zn.smallY + ", " + Zn.smallZ + ", " + Zn.bigX + ", " + Zn.bigY + ", " + Zn.bigZ + ", '" + Zn.Owner + "')");
            //DB

            Player.SendMessage(p, "Added zone for &b" + cpos.Owner);
        }
Ejemplo n.º 7
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            List<CatchPos> buffer = new List<CatchPos>();
            CatchPos pos = new CatchPos();
            //int totalChecks = 0;

            //if (Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z) > 8000) { Player.SendMessage(p, "Tried to restart too many blocks. You may only restart 8000"); return; }

            for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
            {
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                {
                    for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        if (p.level.GetTile(xx, yy, zz) != Block.air)
                        {
                            pos.x = xx; pos.y = yy; pos.z = zz;
                            pos.extraInfo = cpos.extraInfo;
                            buffer.Add(pos);
                        }
                    }
                }
            }

            try
            {
                if (cpos.extraInfo == "")
                {
                    if (buffer.Count > Server.rpNormLimit)
                    {
                        Player.SendMessage(p, "Cannot restart more than " + Server.rpNormLimit + " blocks.");
                        Player.SendMessage(p, "Tried to restart " + buffer.Count + " blocks.");
                        return;
                    }
                }
                else
                {
                    if (buffer.Count > Server.rpLimit)
                    {
                        Player.SendMessage(p, "Tried to add physics to " + buffer.Count + " blocks.");
                        Player.SendMessage(p, "Cannot add physics to more than " + Server.rpLimit + " blocks.");
                        return;
                    }
                }
            }
            catch { return; }

            foreach (CatchPos pos1 in buffer)
            {
                p.level.AddCheck(p.level.PosToInt(pos1.x, pos1.y, pos1.z), pos1.extraInfo, true);
            }

            Player.SendMessage(p, "Activated " + buffer.Count + " blocks.");
            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 8
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            if (!p.staticCommands) p.ClearBlockchange();
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            byte oldType = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, oldType);

            int diffX = 0, diffZ = 0;

            if (p.rot[0] <= 32 || p.rot[0] >= 224) { diffZ = -1; }
            else if (p.rot[0] <= 96) { diffX = 1; }
            else if (p.rot[0] <= 160) { diffZ = 1; }
            else diffX = -1;

            List<Pos> buffer = new List<Pos>();
            Pos pos;
            int total = 0;

            if (diffX != 0)
            {
                for (ushort xx = x; total < cpos.distance; xx += (ushort)diffX)
                {
                    for (ushort yy = (ushort)(y - 1); yy <= (ushort)(y + 1); yy++)
                        for (ushort zz = (ushort)(z - 1); zz <= (ushort)(z + 1); zz++)
                        {
                            pos.x = xx; pos.y = yy; pos.z = zz;
                            buffer.Add(pos);
                        }
                    total++;
                }
            }
            else
            {
                for (ushort zz = z; total < cpos.distance; zz += (ushort)diffZ)
                {
                    for (ushort yy = (ushort)(y - 1); yy <= (ushort)(y + 1); yy++)
                        for (ushort xx = (ushort)(x - 1); xx <= (ushort)(x + 1); xx++)
                        {
                            pos.x = xx; pos.y = yy; pos.z = zz;
                            buffer.Add(pos);
                        }
                    total++;
                }
            }

            if (buffer.Count > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to drill " + buffer.Count + " blocks.");
                Player.SendMessage(p, "You cannot drill more than " + p.group.maxBlocks + ".");
                return;
            }

            foreach (Pos pos1 in buffer)
            {
                if (p.level.GetTile(pos1.x, pos1.y, pos1.z) == oldType)
                    p.level.Blockchange(p, pos1.x, pos1.y, pos1.z, Block.air);
            }
            Player.SendMessage(p, buffer.Count + " blocks.");
        }
Ejemplo n.º 9
0
        public void AboutBlockchange(Player p, ushort x, ushort y, ushort z, byte type)
        {
            if (!p.staticCommands) p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            if (b == Block.Zero) { Player.SendMessage(p, "Invalid Block(" + x + "," + y + "," + z + ")!"); return; }
            p.SendBlockchange(x, y, z, b);

            string message = "Block (" + x + "," + y + "," + z + "): ";
            message += "&f" + b + " = " + Block.Name(b);
            Player.SendMessage(p, message + Server.DefaultColor + ".");
            message = p.level.foundInfo(x, y, z);
            if (message != "") Player.SendMessage(p, "Physics information: &a" + message);

            DataTable Blocks = MySQL.fillData("SELECT * FROM `Block" + p.level.name + "` WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);

            string Username, TimePerformed, BlockUsed;
            bool Deleted, foundOne = false;

            for (int i = 0; i < Blocks.Rows.Count; i++)
            {
                foundOne = true;
                Username = Blocks.Rows[i]["Username"].ToString();
                TimePerformed = DateTime.Parse(Blocks.Rows[i]["TimePerformed"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                BlockUsed = Block.Name((byte)Blocks.Rows[i]["Type"]).ToString();
                Deleted = (bool)Blocks.Rows[i]["Deleted"];

                if (!Deleted)
                    Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
                else
                    Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
                Player.SendMessage(p, "Date and time modified: &2" + TimePerformed);
            }

            List<Level.BlockPos> inCache = p.level.blockCache.FindAll(bP => bP.x == x && bP.y == y && bP.z == z);

            for (int i = 0; i < inCache.Count; i++)
            {
                foundOne = true;
                Deleted = inCache[i].deleted;
                Username = inCache[i].name;
                TimePerformed = inCache[i].TimePerformed.ToString("yyyy-MM-dd HH:mm:ss");
                BlockUsed = Block.Name(inCache[i].type);

                if (!Deleted)
                    Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
                else
                    Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
                Player.SendMessage(p, "Date and time modified: &2" + TimePerformed);
            }

            if (!foundOne)
                Player.SendMessage(p, "This block has not been modified since the map was cleared.");

            Blocks.Dispose();

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Ejemplo n.º 10
0
 public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
 {
     p.ClearBlockchange();
     byte b = p.level.GetTile(x, y, z);
     p.SendBlockchange(x, y, z, b);
     CatchPos bp = (CatchPos)p.blockchangeObject;
     bp.x = x; bp.y = y; bp.z = z; p.blockchangeObject = bp;
     p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
 }
Ejemplo n.º 11
0
        public override void Use(Player p, string message)
        {
            if (message != "") { Help(p); return; }

            CatchPos cpos;
            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;

            Player.SendMessage(p, "Place a block in the corner of where you want to paste."); p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 12
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            try
            {
                p.ClearBlockchange();
                CatchPos cpos = (CatchPos)p.blockchangeObject;
                if (cpos.type == Block.Zero) cpos.type = p.bindings[type];

                byte oldType = p.level.GetTile(x, y, z);
                p.SendBlockchange(x, y, z, oldType);

                if (cpos.type == oldType) { Player.SendMessage(p, "Cannot fill the same time"); return; }
                if (!Block.canPlace(p, oldType) && !Block.BuildIn(oldType)) { Player.SendMessage(p, "Cannot fill that."); return; }

                byte[] mapBlocks = new byte[p.level.blocks.Length];
                List<Pos> buffer = new List<Pos>();
                p.level.blocks.CopyTo(mapBlocks, 0);

                fromWhere.Clear();
                deep = 0;
                FloodFill(p, x, y, z, cpos.type, oldType, cpos.FillType, ref mapBlocks, ref buffer);

                int totalFill = fromWhere.Count;
                for (int i = 0; i < totalFill; i++)
                {
                    totalFill = fromWhere.Count;
                    Pos pos = fromWhere[i];
                    deep = 0;
                    FloodFill(p, pos.x, pos.y, pos.z, cpos.type, oldType, cpos.FillType, ref mapBlocks, ref buffer);
                    totalFill = fromWhere.Count;
                }
                fromWhere.Clear();

                if (buffer.Count > p.group.maxBlocks)
                {
                    Player.SendMessage(p, "You tried to fill " + buffer.Count + " blocks.");
                    Player.SendMessage(p, "You cannot fill more than " + p.group.maxBlocks + ".");
                    return;
                }

                foreach (Pos pos in buffer)
                {
                    p.level.Blockchange(p, pos.x, pos.y, pos.z, cpos.type);
                }

                Player.SendMessage(p, "Filled " + buffer.Count + " blocks.");
                buffer.Clear();

                if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
            catch (Exception e)
            {
                Server.ErrorLog(e);
            }
        }
Ejemplo n.º 13
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            type = p.bindings[type];

            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);

            CatchPos cpos = (CatchPos)p.blockchangeObject;

            ushort cur;

            if (x == cpos.x && z == cpos.z) { Player.SendMessage(p, "No direction was selected"); return; }

            if (Math.Abs(cpos.x - x) > Math.Abs(cpos.z - z))
            {
                cur = cpos.x;
                if (x > cpos.x)
                {
                    foreach (char c in cpos.givenMessage)
                    {
                        cur = FindReference.writeLetter(p, c, cur, cpos.y, cpos.z, type, 0);
                    }
                }
                else
                {
                    foreach (char c in cpos.givenMessage)
                    {
                        cur = FindReference.writeLetter(p, c, cur, cpos.y, cpos.z, type, 1);
                    }
                }
            }
            else
            {
                cur = cpos.z;
                if (z > cpos.z)
                {
                    foreach (char c in cpos.givenMessage)
                    {
                        cur = FindReference.writeLetter(p, c, cpos.x, cpos.y, cur, type, 2);
                    }
                }
                else
                {
                    foreach (char c in cpos.givenMessage)
                    {
                        cur = FindReference.writeLetter(p, c, cpos.x, cpos.y, cur, type, 3);
                    }
                }
            }

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 14
0
 public override void Use(Player p, string message)
 {
     p.ClearBlockchange();
     switch (message.ToLower())
     {
         case "2":
         case "cactus": p.Blockchange += new Player.BlockchangeEventHandler(AddCactus); break;
         default: p.Blockchange += new Player.BlockchangeEventHandler(AddTree); break;
     }
     Player.SendMessage(p, "Select where you wish your tree to grow");
     p.painting = false;
 }
Ejemplo n.º 15
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            p.CopyBuffer.Clear();
            int TotalAir = 0;
            if (cpos.type == 2) p.copyAir = true; else p.copyAir = false;

            for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        b = p.level.GetTile(xx, yy, zz);
                        if (Block.canPlace(p, b))
                        {
                            if (b == Block.air && cpos.type != 2 || cpos.ignoreTypes.Contains(b)) TotalAir++;

                            if (cpos.ignoreTypes.Contains(b)) BufferAdd(p, (ushort)(xx - cpos.x), (ushort)(yy - cpos.y), (ushort)(zz - cpos.z), Block.air);
                            else BufferAdd(p, (ushort)(xx - cpos.x), (ushort)(yy - cpos.y), (ushort)(zz - cpos.z), b);
                        }
                        else BufferAdd(p, (ushort)(xx - cpos.x), (ushort)(yy - cpos.y), (ushort)(zz - cpos.z), Block.air);
                    }

            if ((p.CopyBuffer.Count - TotalAir) > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to copy " + p.CopyBuffer.Count + " blocks.");
                Player.SendMessage(p, "You cannot copy more than " + p.group.maxBlocks + ".");
                p.CopyBuffer.Clear();
                return;
            }

            if (cpos.type == 1)
                for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                    for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                        for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                        {
                            b = p.level.GetTile(xx, yy, zz);
                            if (b != Block.air && Block.canPlace(p, b))
                                p.level.Blockchange(p, xx, yy, zz, Block.air);
                        }

            Player.SendMessage(p, (p.CopyBuffer.Count - TotalAir) + " blocks copied.");
            if (allowoffset != -1)
            {
                Player.SendMessage(p, "Place a block to determine where to paste from");
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange3);
            }
        }
Ejemplo n.º 16
0
 public override void Use(Player p, string message)
 {
     p.ClearBlockchange();
     p.painting = false;
     p.BlockAction = 0;
     p.megaBoid = false;
     p.cmdTimer = false;
     p.staticCommands = false;
     p.deleteMode = false;
     p.ZoneCheck = false;
     p.modeType = 0;
     p.aiming = false;
     p.onTrain = false;
     Player.SendMessage(p, "Every toggle or action was aborted.");
 }
Ejemplo n.º 17
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            List<Pos> buffer = new List<Pos>();
            Pos pos;

            bool AddMe = false;

            for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        AddMe = true;

                        if (!Block.RightClick(Block.Convert(p.level.GetTile(xx, yy, zz)), true) && p.level.GetTile(xx, yy, zz) != cpos.countOther)
                        {
                            if (Block.RightClick(Block.Convert(p.level.GetTile((ushort)(xx - 1), yy, zz))) || p.level.GetTile((ushort)(xx - 1), yy, zz) == cpos.countOther) AddMe = false;
                            else if (Block.RightClick(Block.Convert(p.level.GetTile((ushort)(xx + 1), yy, zz))) || p.level.GetTile((ushort)(xx + 1), yy, zz) == cpos.countOther) AddMe = false;
                            else if (Block.RightClick(Block.Convert(p.level.GetTile(xx, (ushort)(yy - 1), zz))) || p.level.GetTile(xx, (ushort)(yy - 1), zz) == cpos.countOther) AddMe = false;
                            else if (Block.RightClick(Block.Convert(p.level.GetTile(xx, (ushort)(yy + 1), zz))) || p.level.GetTile(xx, (ushort)(yy + 1), zz) == cpos.countOther) AddMe = false;
                            else if (Block.RightClick(Block.Convert(p.level.GetTile(xx, yy, (ushort)(zz - 1)))) || p.level.GetTile(xx, yy, (ushort)(zz - 1)) == cpos.countOther) AddMe = false;
                            else if (Block.RightClick(Block.Convert(p.level.GetTile(xx, yy, (ushort)(zz + 1)))) || p.level.GetTile(xx, yy, (ushort)(zz + 1)) == cpos.countOther) AddMe = false;
                        }
                        else AddMe = false;

                        if (AddMe) { pos.x = xx; pos.y = yy; pos.z = zz; buffer.Add(pos); }
                    }

            if (buffer.Count > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to hollow more than " + buffer.Count + " blocks.");
                Player.SendMessage(p, "You cannot hollow more than " + p.group.maxBlocks + ".");
                return;
            }

            buffer.ForEach(delegate(Pos pos1)
            {
                p.level.Blockchange(p, pos1.x, pos1.y, pos1.z, Block.air);
            });

            Player.SendMessage(p, "You hollowed " + buffer.Count + " blocks.");

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 18
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
            List<Pos> buffer = new List<Pos>();
            Pos pos;

            bool AddMe = false;

            for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        AddMe = false;

                        if (p.level.GetTile((ushort)(xx - 1), yy, zz) == cpos.type) AddMe = true;
                        else if (p.level.GetTile((ushort)(xx + 1), yy, zz) == cpos.type) AddMe = true;
                        else if (p.level.GetTile(xx, (ushort)(yy - 1), zz) == cpos.type) AddMe = true;
                        else if (p.level.GetTile(xx, (ushort)(yy + 1), zz) == cpos.type) AddMe = true;
                        else if (p.level.GetTile(xx, yy, (ushort)(zz - 1)) == cpos.type) AddMe = true;
                        else if (p.level.GetTile(xx, yy, (ushort)(zz + 1)) == cpos.type) AddMe = true;

                        if (AddMe && p.level.GetTile(xx, yy, zz) != cpos.type) { pos.x = xx; pos.y = yy; pos.z = zz; buffer.Add(pos); }
                    }

            if (buffer.Count > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to outline more than " + buffer.Count + " blocks.");
                Player.SendMessage(p, "You cannot outline more than " + p.group.maxBlocks + ".");
                return;
            }

            buffer.ForEach(delegate(Pos pos1)
            {
                p.level.Blockchange(p, pos1.x, pos1.y, pos1.z, cpos.type2);
            });

            Player.SendMessage(p, "You outlined " + buffer.Count + " blocks.");

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 19
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            ushort xx, yy, zz; int foundBlocks = 0;

            for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        if (p.level.GetTile(xx, yy, zz) != cpos.toIgnore) foundBlocks++;
                    }

            Player.SendMessage(p, foundBlocks + " blocks are between (" + cpos.x + ", " + cpos.y + ", " + cpos.z + ") and (" + x + ", " + y + ", " + z + ")");
            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 20
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);

            Player.UndoPos Pos1;
            //p.UndoBuffer.Clear();
            p.CopyBuffer.ForEach(delegate(Player.CopyPos pos)
            {
                Pos1.x = (ushort)(Math.Abs(pos.x) + x);
                Pos1.y = (ushort)(Math.Abs(pos.y) + y);
                Pos1.z = (ushort)(Math.Abs(pos.z) + z);

                if (pos.type != Block.air || p.copyAir)
                    unchecked { if (p.level.GetTile(Pos1.x, Pos1.y, Pos1.z) != Block.Zero) p.level.Blockchange(p, (ushort)(Pos1.x + p.copyoffset[0]), (ushort)(Pos1.y + p.copyoffset[1]), (ushort)(Pos1.z + p.copyoffset[2]), pos.type); }
            });

            Player.SendMessage(p, "Pasted " + p.CopyBuffer.Count + " blocks.");

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 21
0
        void AddCactus(Player p, ushort x, ushort y, ushort z, byte type)
        {
            Random Rand = new Random();

            byte height = (byte)Rand.Next(3, 6);
            ushort yy;

            for (yy = 0; yy <= height; yy++) p.level.Blockchange(p, x, (ushort)(y + yy), z, Block.green);

            int inX = 0, inZ = 0;

            switch (Rand.Next(1, 3))
            {
                case 1: inX = -1; break;
                case 2:
                default: inZ = -1; break;
            }

            for (yy = height; yy <= Rand.Next(height + 2, height + 5); yy++) p.level.Blockchange(p, (ushort)(x + inX), (ushort)(y + yy), (ushort)(z + inZ), Block.green);
            for (yy = height; yy <= Rand.Next(height + 2, height + 5); yy++) p.level.Blockchange(p, (ushort)(x - inX), (ushort)(y + yy), (ushort)(z - inZ), Block.green);

            if (!p.staticCommands) p.ClearBlockchange();
        }
Ejemplo n.º 22
0
        public override void Use(Player p, string message)
        {
            CatchPos cpos;

            message = message.ToLower();

            if (message == "")
            {
                cpos.maxNum    = 0;
                cpos.extraType = 0;
                cpos.type      = Block.Zero;
            }
            else if (message.IndexOf(' ') == -1)
            {
                try
                {
                    cpos.maxNum    = int.Parse(message);
                    cpos.extraType = 0;
                    cpos.type      = Block.Zero;
                }
                catch
                {
                    cpos.maxNum = 0;
                    if (message == "wall")
                    {
                        cpos.extraType = 1;
                        cpos.type      = Block.Zero;
                    }
                    else if (message == "straight")
                    {
                        cpos.extraType = 2;
                        cpos.type      = Block.Zero;
                    }
                    else
                    {
                        cpos.extraType = 0;
                        cpos.type      = Block.Byte(message);
                        if (cpos.type == Block.Zero)
                        {
                            Help(p); return;
                        }
                    }
                }
            }
            else
            {
                if (message.Split(' ').Length == 2)
                {
                    try
                    {
                        cpos.maxNum = int.Parse(message.Split(' ')[0]);
                        cpos.type   = Block.Byte(message.Split(' ')[1]);
                        if (cpos.type == Block.Zero)
                        {
                            if (message.Split(' ')[1] == "wall")
                            {
                                cpos.extraType = 1;
                            }
                            else if (message.Split(' ')[1] == "straight")
                            {
                                cpos.extraType = 2;
                            }
                            else
                            {
                                cpos.extraType = 0;
                            }
                        }
                        else
                        {
                            cpos.extraType = 0;
                        }
                    }
                    catch
                    {
                        cpos.maxNum = 0;
                        cpos.type   = Block.Byte(message.Split(' ')[0]); if (cpos.type == Block.Zero)
                        {
                            Help(p); return;
                        }
                        if (message.Split(' ')[1] == "wall")
                        {
                            cpos.extraType = 1;
                        }
                        else if (message.Split(' ')[1] == "straight")
                        {
                            cpos.extraType = 2;
                        }
                        else
                        {
                            cpos.extraType = 0;
                        }
                    }
                }
                else
                {
                    try { cpos.maxNum = int.Parse(message.Split(' ')[0]); }
                    catch { Help(p); return; }
                    cpos.type = Block.Byte(message.Split(' ')[1]); if (cpos.type == Block.Zero)
                    {
                        Help(p); return;
                    }
                    if (message.Split(' ')[2] == "wall")
                    {
                        cpos.extraType = 1;
                    }
                    else if (message.Split(' ')[2] == "straight")
                    {
                        cpos.extraType = 2;
                    }
                    else
                    {
                        cpos.extraType = 0;
                    }
                }
            }

            if (!Block.canPlace(p, cpos.type) && cpos.type != Block.Zero)
            {
                Player.SendMessage(p, "Cannot place this block type!"); return;
            }

            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
            Player.SendMessage(p, "Place two blocks to determine the edges.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 23
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);

            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            if (cpos.type != Block.Zero)
            {
                type = cpos.type;
            }
            List <Pos> buffer = new List <Pos>();

            if (!cpos.vertical)
            {
                /* Courtesy of fCraft's awesome Open-Source'ness :D */

                // find start/end coordinates
                int sx = Math.Min(cpos.x, x);
                int ex = Math.Max(cpos.x, x);
                int sy = Math.Min(cpos.y, y);
                int ey = Math.Max(cpos.y, y);
                int sz = Math.Min(cpos.z, z);
                int ez = Math.Max(cpos.z, z);

                // find axis lengths
                double rx = (ex - sx + 1) / 2 + .25;
                double ry = (ey - sy + 1) / 2 + .25;
                double rz = (ez - sz + 1) / 2 + .25;

                double rx2 = 1 / (rx * rx);
                double ry2 = 1 / (ry * ry);
                double rz2 = 1 / (rz * rz);

                // find center points
                double cx          = (ex + sx) / 2;
                double cy          = (ey + sy) / 2;
                double cz          = (ez + sz) / 2;
                int    totalBlocks = (int)(Math.PI * 0.75 * rx * ry * rz);

                if (totalBlocks > p.group.maxBlocks)
                {
                    Player.SendMessage(p, "You tried to spheroid " + totalBlocks + " blocks.");
                    Player.SendMessage(p, "You cannot spheroid more than " + p.group.maxBlocks + ".");
                    return;
                }

                Player.SendMessage(p, totalBlocks + " blocks.");

                for (int xx = sx; xx <= ex; xx += 8)
                {
                    for (int yy = sy; yy <= ey; yy += 8)
                    {
                        for (int zz = sz; zz <= ez; zz += 8)
                        {
                            for (int z3 = 0; z3 < 8 && zz + z3 <= ez; z3++)
                            {
                                for (int y3 = 0; y3 < 8 && yy + y3 <= ey; y3++)
                                {
                                    for (int x3 = 0; x3 < 8 && xx + x3 <= ex; x3++)
                                    {
                                        // get relative coordinates
                                        double dx = (xx + x3 - cx);
                                        double dy = (yy + y3 - cy);
                                        double dz = (zz + z3 - cz);

                                        // test if it's inside ellipse
                                        if ((dx * dx) * rx2 + (dy * dy) * ry2 + (dz * dz) * rz2 <= 1)
                                        {
                                            p.level.Blockchange(p, (ushort)(x3 + xx), (ushort)(yy + y3), (ushort)(zz + z3), type);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                int radius = Math.Abs(cpos.x - x) / 2;
                int f      = 1 - radius;
                int ddF_x  = 1;
                int ddF_y  = -2 * radius;
                int xx     = 0;
                int zz     = radius;

                int x0 = Math.Min(cpos.x, x) + radius;
                int z0 = Math.Min(cpos.z, z) + radius;

                Pos pos = new Pos();
                pos.x = (ushort)x0; pos.z = (ushort)(z0 + radius); buffer.Add(pos);
                pos.z = (ushort)(z0 - radius); buffer.Add(pos);
                pos.x = (ushort)(x0 + radius); pos.z = (ushort)z0; buffer.Add(pos);
                pos.x = (ushort)(x0 - radius); buffer.Add(pos);

                while (xx < zz)
                {
                    if (f >= 0)
                    {
                        zz--;
                        ddF_y += 2;
                        f     += ddF_y;
                    }
                    xx++;
                    ddF_x += 2;
                    f     += ddF_x;

                    pos.z = (ushort)(z0 + zz);
                    pos.x = (ushort)(x0 + xx); buffer.Add(pos);
                    pos.x = (ushort)(x0 - xx); buffer.Add(pos);
                    pos.z = (ushort)(z0 - zz);
                    pos.x = (ushort)(x0 + xx); buffer.Add(pos);
                    pos.x = (ushort)(x0 - xx); buffer.Add(pos);
                    pos.z = (ushort)(z0 + xx);
                    pos.x = (ushort)(x0 + zz); buffer.Add(pos);
                    pos.x = (ushort)(x0 - zz); buffer.Add(pos);
                    pos.z = (ushort)(z0 - xx);
                    pos.x = (ushort)(x0 + zz); buffer.Add(pos);
                    pos.x = (ushort)(x0 - zz); buffer.Add(pos);
                }

                int ydiff = Math.Abs(y - cpos.y) + 1;

                if (buffer.Count * ydiff > p.group.maxBlocks)
                {
                    Player.SendMessage(p, "You tried to spheroid " + buffer.Count * ydiff + " blocks.");
                    Player.SendMessage(p, "You cannot spheroid more than " + p.group.maxBlocks + ".");
                    return;
                }
                Player.SendMessage(p, buffer.Count * ydiff + " blocks.");

                foreach (Pos Pos in buffer)
                {
                    for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); yy++)
                    {
                        p.level.Blockchange(p, Pos.x, yy, Pos.z, type);
                    }
                }
            }

            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Ejemplo n.º 24
0
        public override void Use(Player p, string message)
        {
            if (!Server.useMySQL) { p.SendMessage("MySQL has not been configured! Please configure MySQL to use Message Blocks!"); return; }
            if (message == "") { Help(p); return; }

            CatchPos cpos;
            cpos.message = "";

            try
            {
                switch (message.Split(' ')[0])
                {
                    case "air": cpos.type = Block.MsgAir; break;
                    case "water": cpos.type = Block.MsgWater; break;
                    case "lava": cpos.type = Block.MsgLava; break;
                    case "black": cpos.type = Block.MsgBlack; break;
                    case "white": cpos.type = Block.MsgWhite; break;
                    case "show": showMBs(p); return;
                    default: cpos.type = Block.MsgWhite; cpos.message = message; break;
                }
            }
            catch { cpos.type = Block.MsgWhite; cpos.message = message; }

            if (cpos.message == "") cpos.message = message.Substring(message.IndexOf(' ') + 1);
            p.blockchangeObject = cpos;

            Player.SendMessage(p, "Place where you wish the message block to go."); p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 25
0
        public void AboutBlockchange(Player p, ushort x, ushort y, ushort z, byte type)
        {
            if (!p.staticCommands)
            {
                p.ClearBlockchange();
            }
            byte b = p.level.GetTile(x, y, z);

            if (b == Block.Zero)
            {
                Player.SendMessage(p, "Invalid Block(" + x + "," + y + "," + z + ")!"); return;
            }
            p.SendBlockchange(x, y, z, b);

            string message = "Block (" + x + "," + y + "," + z + "): ";

            message += "&f" + b + " = " + Block.Name(b);
            Player.SendMessage(p, message + Server.DefaultColor + ".");
            message = p.level.foundInfo(x, y, z);
            if (message != "")
            {
                Player.SendMessage(p, "Physics information: &a" + message);
            }

            Table blocks = Server.s.database.GetTable("Blocks" + p.level.name);
            List <List <string> > foundRows = blocks.GetRows(new string[] { "X", "Y", "Z" }, new string[] { x.ToString(), y.ToString(), z.ToString() });

            string Username, TimePerformed, BlockUsed;
            bool   Deleted, foundOne = false;

            foreach (List <string> row in foundRows)
            {
                int i = foundRows.IndexOf(row);
                foundOne      = true;
                Username      = blocks.GetValue(i, "Username");
                TimePerformed = blocks.GetValue(i, "TimePerformed");
                BlockUsed     = Block.Name(byte.Parse(blocks.GetValue(i, "Type")));
                Deleted       = bool.Parse(blocks.GetValue(i, "Deleted"));

                Player.SendMessage(p, ((Deleted) ? "&4Destroyed by " : "&3Created by ") + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
                Player.SendMessage(p, "Date and time modified: &2" + TimePerformed);
            }
            //DataTable Blocks = MySQL.fillData("SELECT * FROM `Block" + p.level.name + "` WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);

            /*
             * for (int i = 0; i < Blocks.Rows.Count; i++)
             * {
             *  foundOne = true;
             *  Username = Blocks.Rows[i]["Username"].ToString();
             *  TimePerformed = DateTime.Parse(Blocks.Rows[i]["TimePerformed"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
             *  BlockUsed = Block.Name((byte)Blocks.Rows[i]["Type"]).ToString();
             *  Deleted = (bool)Blocks.Rows[i]["Deleted"];
             *
             *  if (!Deleted)
             *      Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
             *  else
             *      Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
             *  Player.SendMessage(p, "Date and time modified: &2" + TimePerformed);
             * }*/

            List <Level.BlockPos> inCache = p.level.blockCache.FindAll(bP => bP.x == x && bP.y == y && bP.z == z);

            for (int i = 0; i < inCache.Count; i++)
            {
                foundOne      = true;
                Deleted       = inCache[i].deleted;
                Username      = inCache[i].name;
                TimePerformed = inCache[i].TimePerformed.ToString("yyyy-MM-dd HH:mm:ss");
                BlockUsed     = Block.Name(inCache[i].type);

                if (!Deleted)
                {
                    Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
                }
                else
                {
                    Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed);
                }
                Player.SendMessage(p, "Date and time modified: &2" + TimePerformed);
            }

            if (!foundOne)
            {
                Player.SendMessage(p, "This block has not been modified since the map was cleared.");
            }

            //Blocks.Dispose();

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Ejemplo n.º 26
0
 public override void Use(Player p, string message)
 {
     Player.SendMessage(p, "Break/build a block to display information.");
     p.ClearBlockchange();
     p.Blockchange += new Player.BlockchangeEventHandler(AboutBlockchange);
 }
Ejemplo n.º 27
0
        public override void Use(Player p, string message)
        {
            CatchPos cpos;
            cpos.ignoreTypes = new List<byte>();
            cpos.type = 0;
            p.copyoffset[0] = 0; p.copyoffset[1] = 0; p.copyoffset[2] = 0;
            allowoffset = (message.IndexOf('@'));
            if (allowoffset != -1) { message = message.Replace("@ ", ""); }
            if (message.ToLower() == "cut") { cpos.type = 1; message = ""; }
            else if (message.ToLower() == "air") { cpos.type = 2; message = ""; }
            else if (message == "@") { message = ""; }
            else if (message.IndexOf(' ') != -1)
            {
                if (message.Split(' ')[0] == "ignore")
                {
                    foreach (string s in message.Substring(message.IndexOf(' ') + 1).Split(' '))
                    {
                        if (Block.Byte(s) != Block.Zero)
                        {
                            cpos.ignoreTypes.Add(Block.Byte(s));
                            Player.SendMessage(p, "Ignoring &b" + s);
                        }
                    }
                }
                else
                {
                    Help(p); return;
                }
                message = "";
            }

            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;

            if (message != "") { Help(p); return; }

            Player.SendMessage(p, "Place two blocks to determine the edges.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 28
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);

            p.SendBlockchange(x, y, z, b);
            CatchPos   cpos   = (CatchPos)p.blockchangeObject;
            List <Pos> buffer = new List <Pos>();

            byte newType = Block.darkpink;

            int xdif = Math.Abs(cpos.x - x);
            int ydif = Math.Abs(cpos.y - y);
            int zdif = Math.Abs(cpos.z - z);

            if (xdif >= ydif && xdif >= zdif)
            {
                for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); xx++)
                {
                    newType += 1;
                    if (newType > Block.darkpink)
                    {
                        newType = Block.red;
                    }
                    for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); yy++)
                    {
                        for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); zz++)
                        {
                            if (p.level.GetTile(xx, yy, zz) != Block.air)
                            {
                                BufferAdd(buffer, xx, yy, zz, newType);
                            }
                        }
                    }
                }
            }
            else if (ydif > xdif && ydif > zdif)
            {
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); yy++)
                {
                    newType += 1;
                    if (newType > Block.darkpink)
                    {
                        newType = Block.red;
                    }
                    for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); xx++)
                    {
                        for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); zz++)
                        {
                            if (p.level.GetTile(xx, yy, zz) != Block.air)
                            {
                                BufferAdd(buffer, xx, yy, zz, newType);
                            }
                        }
                    }
                }
            }
            else if (zdif > ydif && zdif > xdif)
            {
                for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); zz++)
                {
                    newType += 1;
                    if (newType > Block.darkpink)
                    {
                        newType = Block.red;
                    }
                    for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); yy++)
                    {
                        for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); xx++)
                        {
                            if (p.level.GetTile(xx, yy, zz) != Block.air)
                            {
                                BufferAdd(buffer, xx, yy, zz, newType);
                            }
                        }
                    }
                }
            }

            if (buffer.Count > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to replace " + buffer.Count + " blocks.");
                Player.SendMessage(p, "You cannot replace more than " + p.group.maxBlocks + ".");
                return;
            }

            Player.SendMessage(p, buffer.Count.ToString() + " blocks.");
            buffer.ForEach(delegate(Pos pos)
            {
                p.level.Blockchange(p, pos.x, pos.y, pos.z, pos.newType);                  //update block for everyone
            });

            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Ejemplo n.º 29
0
        public override void Use(Player p, string message)
        {
            if (p.hasflag != null)
            {
                Player.SendMessage(p, "You can't use a gun while you have the flag!"); return;
            }
            Pos cpos;

            if (p.aiming)
            {
                if (message == "")
                {
                    p.aiming = false;
                    p.ClearBlockchange();
                    Player.SendMessage(p, "Disabled gun");
                    return;
                }
            }

            cpos.ending = 0;
            if (message.ToLower() == "destroy")
            {
                cpos.ending = 1;
            }
            else if (message.ToLower() == "explode")
            {
                cpos.ending = 2;
            }
            else if (message.ToLower() == "laser")
            {
                cpos.ending = 3;
            }
            else if (message.ToLower() == "teleport" || message.ToLower() == "tp")
            {
                cpos.ending = -1;
            }
            else if (message != "")
            {
                Help(p); return;
            }

            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);

            p.SendMessage("Gun mode engaged, fire at will");

            if (p.aiming)
            {
                return;
            }

            p.aiming = true;
            Thread aimThread = new Thread(new ThreadStart(delegate
            {
                CatchPos pos;
                List <CatchPos> buffer = new List <CatchPos>();
                while (p.aiming)
                {
                    List <CatchPos> tempBuffer = new List <CatchPos>();

                    double a = Math.Sin(((double)(128 - p.rot[0]) / 256) * 2 * Math.PI);
                    double b = Math.Cos(((double)(128 - p.rot[0]) / 256) * 2 * Math.PI);
                    double c = Math.Cos(((double)(p.rot[1] + 64) / 256) * 2 * Math.PI);

                    try
                    {
                        ushort x = (ushort)(p.pos[0] / 32);
                        x        = (ushort)Math.Round(x + (double)(a * 3));

                        ushort y = (ushort)(p.pos[1] / 32 + 1);
                        y        = (ushort)Math.Round(y + (double)(c * 3));

                        ushort z = (ushort)(p.pos[2] / 32);
                        z        = (ushort)Math.Round(z + (double)(b * 3));

                        if (x > p.level.width || y > p.level.depth || z > p.level.height)
                        {
                            throw new Exception();
                        }
                        if (x < 0 || y < 0 || z < 0)
                        {
                            throw new Exception();
                        }

                        for (ushort xx = x; xx <= x + 1; xx++)
                        {
                            for (ushort yy = (ushort)(y - 1); yy <= y; yy++)
                            {
                                for (ushort zz = z; zz <= z + 1; zz++)
                                {
                                    if (p.level.GetTile(xx, yy, zz) == Block.air)
                                    {
                                        pos.x = xx; pos.y = yy; pos.z = zz;
                                        tempBuffer.Add(pos);
                                    }
                                }
                            }
                        }

                        List <CatchPos> toRemove = new List <CatchPos>();
                        foreach (CatchPos cP in buffer)
                        {
                            if (!tempBuffer.Contains(cP))
                            {
                                p.SendBlockchange(cP.x, cP.y, cP.z, Block.air);
                                toRemove.Add(cP);
                            }
                        }

                        foreach (CatchPos cP in toRemove)
                        {
                            buffer.Remove(cP);
                        }

                        foreach (CatchPos cP in tempBuffer)
                        {
                            if (!buffer.Contains(cP))
                            {
                                buffer.Add(cP);
                                p.SendBlockchange(cP.x, cP.y, cP.z, Block.glass);
                            }
                        }

                        tempBuffer.Clear();
                        toRemove.Clear();
                    }
                    catch { }
                    Thread.Sleep(20);
                }

                foreach (CatchPos cP in buffer)
                {
                    p.SendBlockchange(cP.x, cP.y, cP.z, Block.air);
                }
            }));

            aimThread.Start();
        }
Ejemplo n.º 30
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            if (!p.staticCommands)
            {
                p.ClearBlockchange();
            }
            CatchPos cpos    = (CatchPos)p.blockchangeObject;
            byte     oldType = p.level.GetTile(x, y, z);

            p.SendBlockchange(x, y, z, oldType);

            int diffX = 0, diffZ = 0;

            if (p.rot[0] <= 32 || p.rot[0] >= 224)
            {
                diffZ = -1;
            }
            else if (p.rot[0] <= 96)
            {
                diffX = 1;
            }
            else if (p.rot[0] <= 160)
            {
                diffZ = 1;
            }
            else
            {
                diffX = -1;
            }

            List <Pos> buffer = new List <Pos>();
            Pos        pos;
            int        total = 0;

            if (diffX != 0)
            {
                for (ushort xx = x; total < cpos.distance; xx += (ushort)diffX)
                {
                    for (ushort yy = (ushort)(y - 1); yy <= (ushort)(y + 1); yy++)
                    {
                        for (ushort zz = (ushort)(z - 1); zz <= (ushort)(z + 1); zz++)
                        {
                            pos.x = xx; pos.y = yy; pos.z = zz;
                            buffer.Add(pos);
                        }
                    }
                    total++;
                }
            }
            else
            {
                for (ushort zz = z; total < cpos.distance; zz += (ushort)diffZ)
                {
                    for (ushort yy = (ushort)(y - 1); yy <= (ushort)(y + 1); yy++)
                    {
                        for (ushort xx = (ushort)(x - 1); xx <= (ushort)(x + 1); xx++)
                        {
                            pos.x = xx; pos.y = yy; pos.z = zz;
                            buffer.Add(pos);
                        }
                    }
                    total++;
                }
            }

            if (buffer.Count > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to drill " + buffer.Count + " blocks.");
                Player.SendMessage(p, "You cannot drill more than " + p.group.maxBlocks + ".");
                return;
            }

            foreach (Pos pos1 in buffer)
            {
                if (p.level.GetTile(pos1.x, pos1.y, pos1.z) == oldType)
                {
                    p.level.Blockchange(p, pos1.x, pos1.y, pos1.z, Block.air);
                }
            }
            Player.SendMessage(p, buffer.Count + " blocks.");
        }
Ejemplo n.º 31
0
        public override void Use(Player p, string message)
        {
            CatchPos cpos;

            if (message == "")
            {
                p.ZoneCheck = true;
                Player.SendMessage(p, "Place a block where you would like to check for zones.");
                return;
            }
            else if (p.group.Permission < LevelPermission.Operator)
            {
                Player.SendMessage(p, "Reserved for OP+");
                return;
            }

            if (message.IndexOf(' ') == -1)
            {
                switch (message.ToLower())
                {
                case "del":
                    p.zoneDel = true;
                    Player.SendMessage(p, "Place a block where you would like to delete a zone.");
                    return;

                default:
                    Help(p);
                    return;
                }
            }


            if (message.ToLower() == "del all")
            {
                if (p.group.Permission < LevelPermission.Admin)
                {
                    Player.SendMessage(p, "Only a SuperOP may delete all zones at once");
                    return;
                }
                else
                {/*
                  * for (int i = 0; i < p.level.ZoneList.Count; i++)
                  * {
                  *     Level.Zone Zn = p.level.ZoneList[i];
                  *     MySQL.executeQuery("DELETE FROM `Zone" + p.level.name + "` WHERE Owner='" + Zn.Owner + "' AND SmallX='" + Zn.smallX + "' AND SMALLY='" + Zn.smallY + "' AND SMALLZ='" + Zn.smallZ + "' AND BIGX='" + Zn.bigX + "' AND BIGY='" + Zn.bigY + "' AND BIGZ='" + Zn.bigZ + "'");
                  *
                  *     Player.SendMessage(p, "Zone deleted for &b" + Zn.Owner);
                  *     p.level.ZoneList.Remove(p.level.ZoneList[i]);
                  *     if (i == p.level.ZoneList.Count) { Player.SendMessage(p, "Finished removing all zones"); return; }
                  *     i--;
                  * }*/
                    Server.s.database.GetTable("Zones" + p.level.name).Truncate();
                    Player.SendMessage(p, "Deleted all zones.");
                    return;
                }
            }


            if (p.group.Permission < LevelPermission.Operator)
            {
                Player.SendMessage(p, "Setting zones is reserved for OP+"); return;
            }

            if (Group.Find(message.Split(' ')[1]) != null)
            {
                message = message.Split(' ')[0] + " grp" + Group.Find(message.Split(' ')[1]).name;
            }

            if (message.Split(' ')[0].ToLower() == "add")
            {
                Player foundPlayer = Player.Find(message.Split(' ')[1]);
                if (foundPlayer == null)
                {
                    cpos.Owner = message.Split(' ')[1].ToString();
                }
                else
                {
                    cpos.Owner = foundPlayer.name;
                }
            }
            else
            {
                Help(p); return;
            }

            if (!Player.ValidName(cpos.Owner))
            {
                Player.SendMessage(p, "INVALID NAME."); return;
            }

            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;

            Player.SendMessage(p, "Place two blocks to determine the edges.");
            Player.SendMessage(p, "Zone for: &b" + cpos.Owner + ".");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 32
0
        public override void Use(Player p, string message)
        {
            if (!Directory.Exists("extra/images/"))
            {
                Directory.CreateDirectory("extra/images/");
            }
            layer   = false;
            popType = 1;
            if (message == "")
            {
                Help(p); return;
            }
            if (message.IndexOf(' ') != -1)     //Yay parameters
            {
                string[] parameters = message.Split(' ');

                for (int i = 0; i < parameters.Length; i++)
                {
                    if (parameters[i] == "layer" || parameters[i] == "l")
                    {
                        layer = true;
                    }
                    else if (parameters[i] == "1" || parameters[i] == "2color")
                    {
                        popType = 1;
                    }
                    else if (parameters[i] == "2" || parameters[i] == "1color")
                    {
                        popType = 2;
                    }
                    else if (parameters[i] == "3" || parameters[i] == "2gray")
                    {
                        popType = 3;
                    }
                    else if (parameters[i] == "4" || parameters[i] == "1gray")
                    {
                        popType = 4;
                    }
                    else if (parameters[i] == "5" || parameters[i] == "bw")
                    {
                        popType = 5;
                    }
                    else if (parameters[i] == "6" || parameters[i] == "gray")
                    {
                        popType = 6;
                    }
                }

                message = parameters[parameters.Length - 1];
            }
            if (message.IndexOf('/') == -1 && message.IndexOf('.') != -1)
            {
                try
                {
                    WebClient web = new WebClient();
                    Player.SendMessage(p, "Downloading IMGUR file from: &fhttp://www.imgur.com/" + message);
                    web.DownloadFile("http://www.imgur.com/" + message, "extra/images/tempImage_" + p.name + ".bmp");
                    web.Dispose();
                    Player.SendMessage(p, "Download complete.");
                    bitmaplocation = "tempImage_" + p.name;
                    message        = bitmaplocation;
                }
                catch { }
            }
            else if (message.IndexOf('.') != -1)
            {
                try
                {
                    WebClient web = new WebClient();
                    if (message.Substring(0, 4) != "http")
                    {
                        message = "http://" + message;
                    }
                    Player.SendMessage(p, "Downloading file from: &f" + message + Server.DefaultColor + ", please wait.");
                    web.DownloadFile(message, "extra/images/tempImage_" + p.name + ".bmp");
                    web.Dispose();
                    Player.SendMessage(p, "Download complete.");
                    bitmaplocation = "tempImage_" + p.name;
                }
                catch { }
            }
            else
            {
                bitmaplocation = message;
            }

            if (!File.Exists("extra/images/" + bitmaplocation + ".bmp"))
            {
                Player.SendMessage(p, "The URL entered was invalid!"); return;
            }

            CatchPos cpos;

            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
            Player.SendMessage(p, "Place two blocks to determine direction.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 33
0
        public override void Use(Player p, string message)
        {
            CatchPos cpos;
            cpos.distance = 20;

            if (message != "")
                try
                {
                    cpos.distance = int.Parse(message);
                }
                catch { Help(p); return; }

            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;

            Player.SendMessage(p, "Destroy the block you wish to drill."); p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 34
0
        public override void Use(Player p, string message)
        {
            CatchPos cpos;

            cpos.x = 0; cpos.y = 0; cpos.z = 0;

            message        = message.ToLower();
            cpos.extraInfo = "";

            if (message != "")
            {
                int currentLoop = 0; string[] storedArray; bool skip = false;

                retry : foreach (string s in message.Split(' '))
                {
                    if (currentLoop % 2 == 0)
                    {
                        switch (s)
                        {
                        case "drop"      :
                        case "explode"   :
                        case "dissipate" :
                        case "finite"    :
                        case "wait"      :
                        case "rainbow"   :
                            break;

                        case "revert":
                            if (skip)
                            {
                                break;
                            }
                            storedArray = message.Split(' ');
                            try
                            {
                                storedArray[currentLoop + 1] = Block.Byte(message.Split(' ')[currentLoop + 1].ToString().ToLower()).ToString();
                                if (storedArray[currentLoop + 1].ToString() == "255")
                                {
                                    throw new OverflowException();
                                }
                            }
                            catch { Player.SendMessage(p, "Invalid block type."); return; }

                            message = string.Join(" ", storedArray);
                            skip    = true; currentLoop = 0;

                            goto retry;

                        default:
                            Player.SendMessage(p, s + " is not supported."); return;
                        }
                    }
                    else
                    {
                        try
                        {
                            if (int.Parse(s) < 1)
                            {
                                Player.SendMessage(p, "Values must be above 0"); return;
                            }
                        }
                        catch { Player.SendMessage(p, "/rp [text] [num] [text] [num]"); return; }
                    }

                    currentLoop++;
                }

                if (currentLoop % 2 != 1)
                {
                    cpos.extraInfo = message;
                }
                else
                {
                    Player.SendMessage(p, "Number of parameters must be even"); Help(p); return;
                }
            }

            p.blockchangeObject = cpos;
            Player.SendMessage(p, "Place two blocks to determine the edges.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 35
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);

            p.SendBlockchange(x, y, z, b);
            CatchPos        cpos   = (CatchPos)p.blockchangeObject;
            List <CatchPos> buffer = new List <CatchPos>();
            CatchPos        pos    = new CatchPos();

            //int totalChecks = 0;

            //if (Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z) > 8000) { Player.SendMessage(p, "Tried to restart too many blocks. You may only restart 8000"); return; }

            for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
            {
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                {
                    for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        if (p.level.GetTile(xx, yy, zz) != Block.air)
                        {
                            pos.x         = xx; pos.y = yy; pos.z = zz;
                            pos.extraInfo = cpos.extraInfo;
                            buffer.Add(pos);
                        }
                    }
                }
            }

            try
            {
                if (cpos.extraInfo == "")
                {
                    if (buffer.Count > Server.rpNormLimit)
                    {
                        Player.SendMessage(p, "Cannot restart more than " + Server.rpNormLimit + " blocks.");
                        Player.SendMessage(p, "Tried to restart " + buffer.Count + " blocks.");
                        return;
                    }
                }
                else
                {
                    if (buffer.Count > Server.rpLimit)
                    {
                        Player.SendMessage(p, "Tried to add physics to " + buffer.Count + " blocks.");
                        Player.SendMessage(p, "Cannot add physics to more than " + Server.rpLimit + " blocks.");
                        return;
                    }
                }
            }
            catch { return; }

            foreach (CatchPos pos1 in buffer)
            {
                p.level.AddCheck(p.level.PosToInt(pos1.x, pos1.y, pos1.z), pos1.extraInfo, true);
            }

            Player.SendMessage(p, "Activated " + buffer.Count + " blocks.");
            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Ejemplo n.º 36
0
        public override void Use(Player p, string message)
        {
            if (!Server.useMySQL) { Player.SendMessage(p, "MySQL has not been configured! Please configure MySQL to use Zones!"); return; }
            CatchPos cpos;

            if (message == "")
            {
                p.ZoneCheck = true;
                Player.SendMessage(p, "Place a block where you would like to check for zones.");
                return;
            }
            else if (p.group.Permission < LevelPermission.Operator)
            {
                Player.SendMessage(p, "Reserved for OP+");
                return;
            }

            if (message.IndexOf(' ') == -1)
            {
                switch (message.ToLower())
                {
                    case "del":
                        p.zoneDel = true;
                        Player.SendMessage(p, "Place a block where you would like to delete a zone.");
                        return;
                    default:
                        Help(p);
                        return;
                }
            }

            if (message.ToLower() == "del all")
            {
                if (p.group.Permission < LevelPermission.Admin)
                {
                    Player.SendMessage(p, "Only a SuperOP may delete all zones at once");
                    return;
                }
                else
                {
                    for (int i = 0; i < p.level.ZoneList.Count; i++)
                    {
                        Level.Zone Zn = p.level.ZoneList[i];
                        MySQL.executeQuery("DELETE FROM `Zone" + p.level.name + "` WHERE Owner='" + Zn.Owner + "' AND SmallX='" + Zn.smallX + "' AND SMALLY='" + Zn.smallY + "' AND SMALLZ='" + Zn.smallZ + "' AND BIGX='" + Zn.bigX + "' AND BIGY='" + Zn.bigY + "' AND BIGZ='" + Zn.bigZ + "'");

                        Player.SendMessage(p, "Zone deleted for &b" + Zn.Owner);
                        p.level.ZoneList.Remove(p.level.ZoneList[i]);
                        if (i == p.level.ZoneList.Count) { Player.SendMessage(p, "Finished removing all zones"); return; }
                        i--;
                    }
                }
            }

            if (p.group.Permission < LevelPermission.Operator)
            {
                Player.SendMessage(p, "Setting zones is reserved for OP+"); return;
            }

            if (Group.Find(message.Split(' ')[1]) != null)
            {
                message = message.Split(' ')[0] + " grp" + Group.Find(message.Split(' ')[1]).name;
            }

            if (message.Split(' ')[0].ToLower() == "add")
            {
                Player foundPlayer = Player.Find(message.Split(' ')[1]);
                if (foundPlayer == null)
                    cpos.Owner = message.Split(' ')[1].ToString();
                else
                    cpos.Owner = foundPlayer.name;
            }
            else { Help(p); return; }

            if (!Player.ValidName(cpos.Owner)) { Player.SendMessage(p, "INVALID NAME."); return; }

            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;

            Player.SendMessage(p, "Place two blocks to determine the edges.");
            Player.SendMessage(p, "Zone for: &b" + cpos.Owner + ".");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 37
0
        public void GrabFlag(Player p, Team 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, Team.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;
            }
        }
Ejemplo n.º 38
0
        public override void Use(Player p, string message)
        {
            int num = message.Split(' ').Length;

            if (num == 3)
            {
                string[] strings = message.Split(' ');

                for (int i = 0; i < num; i++)
                {
                    strings[i] = strings[i].ToLower();
                }

                if (strings[0] == "team")
                {
                    if (strings[1] == "add")
                    {
                        string color = c.Parse(strings[2]);
                        if (color == "")
                        {
                            Player.SendMessage(p, "Invalid team color chosen."); return;
                        }
                        char teamCol = (char)color[1];
                        switch (teamCol)
                        {
                        case '2':
                        case '5':
                        case '8':
                        case '9':
                        case 'c':
                        case 'e':
                        case 'f':
                            AddTeam(p, color);
                            break;

                        default:
                            Player.SendMessage(p, "Invalid team color chosen.");
                            return;
                        }
                    }
                    else if (strings[1] == "remove")
                    {
                        string color = c.Parse(strings[2]);
                        if (color == "")
                        {
                            Player.SendMessage(p, "Invalid team color chosen."); return;
                        }
                        char teamCol = (char)color[1];
                        switch (teamCol)
                        {
                        case '2':
                        case '5':
                        case '8':
                        case '9':
                        case 'c':
                        case 'e':
                        case 'f':
                            RemoveTeam(p, color);
                            break;

                        default:
                            Player.SendMessage(p, "Invalid team color chosen.");
                            return;
                        }
                    }
                }
            }
            else if (num == 2)
            {
                string[] strings = message.Split(' ');

                for (int i = 0; i < num; i++)
                {
                    strings[i] = strings[i].ToLower();
                }

                if (strings[0] == "debug")
                {
                    Debug(p, strings[1]);
                }
                else if (strings[0] == "flag")
                {
                    string color = c.Parse(strings[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;
                    }
                    CatchPos cpos;
                    cpos.x = 0; cpos.y = 0; cpos.z = 0; cpos.color = color; p.blockchangeObject = cpos;
                    Player.SendMessage(p, "Place a block to determine where to place the flag.");
                    p.ClearBlockchange();
                    p.Blockchange += new Player.BlockchangeEventHandler(FlagBlockChange);
                }
                else if (strings[0] == "spawn")
                {
                    string color = c.Parse(strings[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;
                    }
                    AddSpawn(p, color);
                }
                else if (strings[0] == "points")
                {
                    int i = 0;
                    Int32.TryParse(strings[1], out i);
                    if (i == 0)
                    {
                        Player.SendMessage(p, "You must choose a points value greater than 0!"); return;
                    }
                    p.level.ctfgame.maxPoints = i;
                    Player.SendMessage(p, "Max round points has been set to " + i);
                }
            }
            else if (num == 1)
            {
                if (message.ToLower() == "start")
                {
                    if (!p.level.ctfmode)
                    {
                        p.level.ctfmode = true;
                    }
                    p.level.ctfgame.gameOn = true;
                    p.level.ctfgame.GameStart();
                }
                else if (message.ToLower() == "stop")
                {
                    if (p.level.ctfmode)
                    {
                        p.level.ctfmode = false;
                    }
                    p.level.ctfmode        = false;
                    p.level.ctfgame.gameOn = false;
                    p.level.ChatLevel(p.color + p.name + Server.DefaultColor + " has ended the game");
                }
                else if (message.ToLower() == "ff")
                {
                    if (p.level.ctfgame.friendlyfire)
                    {
                        p.level.ChatLevel("Friendly fire has been disabled.");
                        p.level.ctfgame.friendlyfire = false;
                    }
                    else
                    {
                        p.level.ChatLevel("Friendly fire has been enabled.");
                        p.level.ctfgame.friendlyfire = true;
                    }
                }
                else if (message.ToLower() == "clear")
                {
                    List <Team> storedT = new List <Team>();
                    for (int i = 0; i < p.level.ctfgame.teams.Count; i++)
                    {
                        storedT.Add(p.level.ctfgame.teams[i]);
                    }
                    foreach (Team t in storedT)
                    {
                        p.level.ctfgame.RemoveTeam("&" + t.color);
                    }
                    p.level.ctfgame.onTeamCheck.Stop();
                    p.level.ctfgame.onTeamCheck.Dispose();
                    p.level.ctfgame.gameOn = false;
                    p.level.ctfmode        = false;
                    p.level.ctfgame        = new CTFGame();
                    p.level.ctfgame.mapOn  = p.level;
                    Player.SendMessage(p, "CTF data has been cleared.");
                }

                else if (message.ToLower() == "")
                {
                    if (p.level.ctfmode)
                    {
                        p.level.ctfmode = false;
                        p.level.ChatLevel("CTF Mode has been disabled.");
                    }
                    else if (!p.level.ctfmode)
                    {
                        p.level.ctfmode = true;
                        p.level.ChatLevel("CTF Mode has been enabled.");
                    }
                }
            }
        }
Ejemplo n.º 39
0
        public void Blockchange3(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            p.copyoffset[0] = (p.copystart[0] - x);
            p.copyoffset[1] = (p.copystart[1] - y);
            p.copyoffset[2] = (p.copystart[2] - z);
        }
Ejemplo n.º 40
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);

            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            List <Pos> buffer = new List <Pos>();
            Pos        pos;

            bool AddMe = false;

            for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
            {
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                {
                    for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        AddMe = true;

                        if (!Block.RightClick(Block.Convert(p.level.GetTile(xx, yy, zz)), true) && p.level.GetTile(xx, yy, zz) != cpos.countOther)
                        {
                            if (Block.RightClick(Block.Convert(p.level.GetTile((ushort)(xx - 1), yy, zz))) || p.level.GetTile((ushort)(xx - 1), yy, zz) == cpos.countOther)
                            {
                                AddMe = false;
                            }
                            else if (Block.RightClick(Block.Convert(p.level.GetTile((ushort)(xx + 1), yy, zz))) || p.level.GetTile((ushort)(xx + 1), yy, zz) == cpos.countOther)
                            {
                                AddMe = false;
                            }
                            else if (Block.RightClick(Block.Convert(p.level.GetTile(xx, (ushort)(yy - 1), zz))) || p.level.GetTile(xx, (ushort)(yy - 1), zz) == cpos.countOther)
                            {
                                AddMe = false;
                            }
                            else if (Block.RightClick(Block.Convert(p.level.GetTile(xx, (ushort)(yy + 1), zz))) || p.level.GetTile(xx, (ushort)(yy + 1), zz) == cpos.countOther)
                            {
                                AddMe = false;
                            }
                            else if (Block.RightClick(Block.Convert(p.level.GetTile(xx, yy, (ushort)(zz - 1)))) || p.level.GetTile(xx, yy, (ushort)(zz - 1)) == cpos.countOther)
                            {
                                AddMe = false;
                            }
                            else if (Block.RightClick(Block.Convert(p.level.GetTile(xx, yy, (ushort)(zz + 1)))) || p.level.GetTile(xx, yy, (ushort)(zz + 1)) == cpos.countOther)
                            {
                                AddMe = false;
                            }
                        }
                        else
                        {
                            AddMe = false;
                        }

                        if (AddMe)
                        {
                            pos.x = xx; pos.y = yy; pos.z = zz; buffer.Add(pos);
                        }
                    }
                }
            }

            if (buffer.Count > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to hollow more than " + buffer.Count + " blocks.");
                Player.SendMessage(p, "You cannot hollow more than " + p.group.maxBlocks + ".");
                return;
            }

            buffer.ForEach(delegate(Pos pos1)
            {
                p.level.Blockchange(p, pos1.x, pos1.y, pos1.z, Block.air);
            });

            Player.SendMessage(p, "You hollowed " + buffer.Count + " blocks.");

            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Ejemplo n.º 41
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);

            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            if (cpos.type == Block.Zero)
            {
                type = p.bindings[type];
            }
            else
            {
                type = cpos.type;
            }
            List <CatchPos> buffer = new List <CatchPos>();
            CatchPos        pos    = new CatchPos();

            if (cpos.extraType == 2)
            {  //Fun part of making a straight line
                int xdif = Math.Abs(cpos.x - x);
                int ydif = Math.Abs(cpos.y - y);
                int zdif = Math.Abs(cpos.z - z);

                if (xdif > ydif && xdif > zdif)
                {
                    y = cpos.y; z = cpos.z;
                }
                else if (ydif > xdif && ydif > zdif)
                {
                    x = cpos.x; z = cpos.z;
                }
                else if (zdif > ydif && zdif > xdif)
                {
                    y = cpos.y; x = cpos.x;
                }
            }

            if (cpos.maxNum == 0)
            {
                cpos.maxNum = 100000;
            }

            int i, dx, dy, dz, l, m, n, x_inc, y_inc, z_inc, err_1, err_2, dx2, dy2, dz2;

            int[] pixel = new int[3];

            pixel[0] = cpos.x; pixel[1] = cpos.y; pixel[2] = cpos.z;
            dx       = x - cpos.x; dy = y - cpos.y; dz = z - cpos.z;

            x_inc = (dx < 0) ? -1 : 1; l = Math.Abs(dx);
            y_inc = (dy < 0) ? -1 : 1; m = Math.Abs(dy);
            z_inc = (dz < 0) ? -1 : 1; n = Math.Abs(dz);

            dx2 = l << 1; dy2 = m << 1; dz2 = n << 1;

            if ((l >= m) && (l >= n))
            {
                err_1 = dy2 - l;
                err_2 = dz2 - l;
                for (i = 0; i < l; i++)
                {
                    pos.x = (ushort)pixel[0];
                    pos.y = (ushort)pixel[1];
                    pos.z = (ushort)pixel[2];
                    buffer.Add(pos);

                    if (err_1 > 0)
                    {
                        pixel[1] += y_inc;
                        err_1    -= dx2;
                    }
                    if (err_2 > 0)
                    {
                        pixel[2] += z_inc;
                        err_2    -= dx2;
                    }
                    err_1    += dy2;
                    err_2    += dz2;
                    pixel[0] += x_inc;
                }
            }
            else if ((m >= l) && (m >= n))
            {
                err_1 = dx2 - m;
                err_2 = dz2 - m;
                for (i = 0; i < m; i++)
                {
                    pos.x = (ushort)pixel[0];
                    pos.y = (ushort)pixel[1];
                    pos.z = (ushort)pixel[2];
                    buffer.Add(pos);

                    if (err_1 > 0)
                    {
                        pixel[0] += x_inc;
                        err_1    -= dy2;
                    }
                    if (err_2 > 0)
                    {
                        pixel[2] += z_inc;
                        err_2    -= dy2;
                    }
                    err_1    += dx2;
                    err_2    += dz2;
                    pixel[1] += y_inc;
                }
            }
            else
            {
                err_1 = dy2 - n;
                err_2 = dx2 - n;
                for (i = 0; i < n; i++)
                {
                    pos.x = (ushort)pixel[0];
                    pos.y = (ushort)pixel[1];
                    pos.z = (ushort)pixel[2];
                    buffer.Add(pos);

                    if (err_1 > 0)
                    {
                        pixel[1] += y_inc;
                        err_1    -= dz2;
                    }
                    if (err_2 > 0)
                    {
                        pixel[0] += x_inc;
                        err_2    -= dz2;
                    }
                    err_1    += dy2;
                    err_2    += dx2;
                    pixel[2] += z_inc;
                }
            }

            pos.x = (ushort)pixel[0];
            pos.y = (ushort)pixel[1];
            pos.z = (ushort)pixel[2];
            buffer.Add(pos);

            int count;

            count = Math.Min(buffer.Count, cpos.maxNum);
            if (cpos.extraType == 1)
            {
                count = count * Math.Abs(cpos.y - y);
            }

            if (count > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to fill " + count + " blocks at once.");
                Player.SendMessage(p, "You are limited to " + p.group.maxBlocks);
                return;
            }

            for (count = 0; count < cpos.maxNum && count < buffer.Count; count++)
            {
                if (cpos.extraType != 1)
                {
                    p.level.Blockchange(p, buffer[count].x, buffer[count].y, buffer[count].z, type);
                }
                else
                {
                    for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); yy++)
                    {
                        p.level.Blockchange(p, buffer[count].x, yy, buffer[count].z, type);
                    }
                }
            }

            Player.SendMessage(p, "Line was " + count.ToString() + " blocks long.");

            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Ejemplo n.º 42
0
        public override void Use(Player p, string message)
        {
            string path;

            if (message.Split(' ').Length == 1)
            {
                path = "levels/" + message + ".lvl";
            }
            else if (message.Split(' ').Length == 2)
            {
                try { path = @Server.backupLocation + "/" + message.Split(' ')[0] + "/" + int.Parse(message.Split(' ')[1]) + "/" + message.Split(' ')[0] + ".lvl"; }
                catch { Help(p); return; }
            }
            else
            {
                Help(p); return;
            }

            if (File.Exists(path))
            {
                FileStream fs = File.OpenRead(path);
                try
                {
                    GZipStream gs  = new GZipStream(fs, CompressionMode.Decompress);
                    byte[]     ver = new byte[2];
                    gs.Read(ver, 0, ver.Length);
                    ushort version = BitConverter.ToUInt16(ver, 0);
                    Level  level;
                    if (version == 1874)
                    {
                        byte[] header = new byte[16]; gs.Read(header, 0, header.Length);
                        ushort width  = BitConverter.ToUInt16(header, 0);
                        ushort height = BitConverter.ToUInt16(header, 2);
                        ushort depth  = BitConverter.ToUInt16(header, 4);
                        level        = new Level(name, width, depth, height, "empty");
                        level.spawnx = BitConverter.ToUInt16(header, 6);
                        level.spawnz = BitConverter.ToUInt16(header, 8);
                        level.spawny = BitConverter.ToUInt16(header, 10);
                        level.rotx   = header[12]; level.roty = header[13];
                    }
                    else
                    {
                        byte[] header = new byte[12]; gs.Read(header, 0, header.Length);
                        ushort width  = version;
                        ushort height = BitConverter.ToUInt16(header, 0);
                        ushort depth  = BitConverter.ToUInt16(header, 2);
                        level        = new Level(name, width, depth, height, "grass");
                        level.spawnx = BitConverter.ToUInt16(header, 4);
                        level.spawnz = BitConverter.ToUInt16(header, 6);
                        level.spawny = BitConverter.ToUInt16(header, 8);
                        level.rotx   = header[10]; level.roty = header[11];
                    }

                    level.setPhysics(0);

                    byte[] blocks = new byte[level.width * level.height * level.depth];
                    gs.Read(blocks, 0, blocks.Length);
                    level.blocks = blocks;
                    gs.Close();

                    level.backedup        = true;
                    level.permissionbuild = LevelPermission.Admin;

                    level.jailx    = (ushort)(level.spawnx * 32); level.jaily = (ushort)(level.spawny * 32); level.jailz = (ushort)(level.spawnz * 32);
                    level.jailrotx = level.rotx; level.jailroty = level.roty;

                    p.Loading = true;
                    foreach (Player pl in Player.players)
                    {
                        if (p.level == pl.level && p != pl)
                        {
                            p.SendDie(pl.id);
                        }
                    }
                    foreach (PlayerBot b in PlayerBot.playerbots)
                    {
                        if (p.level == b.level)
                        {
                            p.SendDie(b.id);
                        }
                    }

                    Player.GlobalDie(p, true);

                    p.level = level;
                    p.SendMotd();

                    p.SendRaw(2);
                    byte[] buffer = new byte[level.blocks.Length + 4];
                    BitConverter.GetBytes(IPAddress.HostToNetworkOrder(level.blocks.Length)).CopyTo(buffer, 0);
                    //ushort xx; ushort yy; ushort zz;

                    for (int i = 0; i < level.blocks.Length; ++i)
                    {
                        buffer[4 + i] = Block.Convert(level.blocks[i]);
                    }

                    buffer = Player.GZip(buffer);
                    int number = (int)Math.Ceiling(((double)buffer.Length) / 1024);
                    for (int i = 1; buffer.Length > 0; ++i)
                    {
                        short  length = (short)Math.Min(buffer.Length, 1024);
                        byte[] send   = new byte[1027];
                        Player.HTNO(length).CopyTo(send, 0);
                        Buffer.BlockCopy(buffer, 0, send, 2, length);
                        byte[] tempbuffer = new byte[buffer.Length - length];
                        Buffer.BlockCopy(buffer, length, tempbuffer, 0, buffer.Length - length);
                        buffer     = tempbuffer;
                        send[1026] = (byte)(i * 100 / number);
                        p.SendRaw(3, send);
                        Thread.Sleep(10);
                    }
                    buffer = new byte[6];
                    Player.HTNO((short)level.width).CopyTo(buffer, 0);
                    Player.HTNO((short)level.depth).CopyTo(buffer, 2);
                    Player.HTNO((short)level.height).CopyTo(buffer, 4);
                    p.SendRaw(4, buffer);

                    ushort x = (ushort)((0.5 + level.spawnx) * 32);
                    ushort y = (ushort)((1 + level.spawny) * 32);
                    ushort z = (ushort)((0.5 + level.spawnz) * 32);

                    p.aiming = false;
                    Player.GlobalSpawn(p, x, y, z, level.rotx, level.roty, true);
                    p.ClearBlockchange();
                    p.Loading = false;

                    if (message.IndexOf(' ') == -1)
                    {
                        level.name = "&cMuseum " + Server.DefaultColor + "(" + message.Split(' ')[0] + ")";
                    }
                    else
                    {
                        level.name = "&cMuseum " + Server.DefaultColor + "(" + message.Split(' ')[0] + " " + message.Split(' ')[1] + ")";
                    }

                    if (!p.hidden)
                    {
                        Player.GlobalChat(null, p.color + p.prefix + p.name + Server.DefaultColor + " went to the " + level.name, false);
                    }

                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                catch (Exception ex) { Player.SendMessage(p, "Error loading level."); Server.ErrorLog(ex); return; }
                finally { fs.Close(); }
            }
            else
            {
                Player.SendMessage(p, "Level or backup could not be found."); return;
            }
        }
Ejemplo n.º 43
0
        public override void Use(Player p, string message)
        {
            int number = message.Split(' ').Length;
            if (number != 2) { Help(p); return; }

            int pos = message.IndexOf(' ');
            string t = message.Substring(0, pos).ToLower();
            string t2 = message.Substring(pos + 1).ToLower();
            byte type = Block.Byte(t);
            if (type == 255) { Player.SendMessage(p, "There is no block \"" + t + "\"."); return; }
            byte type2 = Block.Byte(t2);
            if (type2 == 255) { Player.SendMessage(p, "There is no block \"" + t2 + "\"."); return; }
            if (!Block.canPlace(p, type2)) { Player.SendMessage(p, "Cannot place that block type."); return; }

            CatchPos cpos; cpos.type2 = type2; cpos.type = type;

            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
            Player.SendMessage(p, "Place two blocks to determine the edges.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 44
0
        public override void Use(Player p, string message)
        {
            CatchPos cpos;

            int number = message.Split(' ').Length;
            if (number > 2) { Help(p); return; }
            if (number == 2)
            {
                int pos = message.IndexOf(' ');
                string t = message.Substring(0, pos).ToLower();
                string s = message.Substring(pos + 1).ToLower();
                cpos.type = Block.Byte(t);
                if (cpos.type == 255) { Player.SendMessage(p, "There is no block \"" + t + "\"."); return; }

                if (!Block.canPlace(p, cpos.type)) { Player.SendMessage(p, "Cannot place that."); return; }

                if (s == "up") cpos.FillType = 1;
                else if (s == "down") cpos.FillType = 2;
                else if (s == "layer") cpos.FillType = 3;
                else if (s == "vertical_x") cpos.FillType = 4;
                else if (s == "vertical_z") cpos.FillType = 5;
                else { Player.SendMessage(p, "Invalid fill type"); return; }
            }
            else if (message != "")
            {
                message = message.ToLower();
                if (message == "up") { cpos.FillType = 1; cpos.type = Block.Zero; }
                else if (message == "down") { cpos.FillType = 2; cpos.type = Block.Zero; }
                else if (message == "layer") { cpos.FillType = 3; cpos.type = Block.Zero; }
                else if (message == "vertical_x") { cpos.FillType = 4; cpos.type = Block.Zero; }
                else if (message == "vertical_z") { cpos.FillType = 5; cpos.type = Block.Zero; }
                else
                {
                    cpos.type = Block.Byte(message);
                    if (cpos.type == (byte)255) { Player.SendMessage(p, "Invalid block or fill type"); return; }
                    if (!Block.canPlace(p, cpos.type)) { Player.SendMessage(p, "Cannot place that."); return; }

                    cpos.FillType = 0;
                }
            }
            else
            {
                cpos.type = Block.Zero; cpos.FillType = 0;
            }

            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;

            Player.SendMessage(p, "Destroy the block you wish to fill."); p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 45
0
        public override void Use(Player p, string message)
        {
            CatchPos cpos;
            if (message != "")
                if (Block.Byte(message.ToLower()) == Block.Zero) { Player.SendMessage(p, "Cannot find block entered."); return; }

            if (message != "")
            {
                cpos.countOther = Block.Byte(message.ToLower());
            }
            else
            {
                cpos.countOther = Block.Zero;
            }

            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
            Player.SendMessage(p, "Place two blocks to determine the edges.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 46
0
        public override void Use(Player p, string message)
        {
            int number = message.Split(' ').Length;

            if (number > 2)
            {
                Help(p); return;
            }
            if (number == 2)
            {
                int    pos  = message.IndexOf(' ');
                string t    = message.Substring(0, pos).ToLower();
                string s    = message.Substring(pos + 1).ToLower();
                byte   type = Block.Byte(t);
                if (type == 255)
                {
                    Player.SendMessage(p, "There is no block \"" + t + "\"."); return;
                }

                if (!Block.canPlace(p, type))
                {
                    Player.SendMessage(p, "Cannot place that."); return;
                }

                SolidType solid;
                if (s == "solid")
                {
                    solid = SolidType.solid;
                }
                else if (s == "hollow")
                {
                    solid = SolidType.hollow;
                }
                else if (s == "walls")
                {
                    solid = SolidType.walls;
                }
                else if (s == "holes")
                {
                    solid = SolidType.holes;
                }
                else if (s == "wire")
                {
                    solid = SolidType.wire;
                }
                else if (s == "random")
                {
                    solid = SolidType.random;
                }
                else
                {
                    Help(p); return;
                }
                CatchPos cpos; cpos.solid = solid; cpos.type = type;
                cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
            }
            else if (message != "")
            {
                SolidType solid = SolidType.solid;
                message = message.ToLower();
                byte type; unchecked { type = (byte)-1; }
                if (message == "solid")
                {
                    solid = SolidType.solid;
                }
                else if (message == "hollow")
                {
                    solid = SolidType.hollow;
                }
                else if (message == "walls")
                {
                    solid = SolidType.walls;
                }
                else if (message == "holes")
                {
                    solid = SolidType.holes;
                }
                else if (message == "wire")
                {
                    solid = SolidType.wire;
                }
                else if (message == "random")
                {
                    solid = SolidType.random;
                }
                else
                {
                    byte t = Block.Byte(message);
                    if (t == 255)
                    {
                        Player.SendMessage(p, "There is no block \"" + message + "\"."); return;
                    }

                    if (!Block.canPlace(p, t))
                    {
                        Player.SendMessage(p, "Cannot place that."); return;
                    }

                    type = t;
                } CatchPos cpos; cpos.solid = solid; cpos.type = type;
                cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
            }
            else
            {
                CatchPos cpos; cpos.solid = SolidType.solid; unchecked { cpos.type = (byte)-1; }
                cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
            }
            Player.SendMessage(p, "Place two blocks to determine the edges.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 47
0
        public override void Use(Player p, string message)
        {
            if (message != "")
            {
                Help(p); return;
            }

            CatchPos cpos;

            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;

            Player.SendMessage(p, "Place a block in the corner of where you want to paste."); p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Ejemplo n.º 48
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);

            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            unchecked { if (cpos.type != (byte)-1)
                        {
                            type = cpos.type;
                        }
                        else
                        {
                            type = p.bindings[type];
                        } }
            List <Pos> buffer = new List <Pos>();

            ushort xx; ushort yy; ushort zz;

            switch (cpos.solid)
            {
            case SolidType.solid:
                buffer.Capacity = Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z);
                for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                {
                    for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    {
                        for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                        {
                            if (p.level.GetTile(xx, yy, zz) != type)
                            {
                                BufferAdd(buffer, xx, yy, zz);
                            }
                        }
                    }
                }
                break;

            case SolidType.hollow:
                //todo work out if theres 800 blocks used before making the buffer
                for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                {
                    for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        if (p.level.GetTile(cpos.x, yy, zz) != type)
                        {
                            BufferAdd(buffer, cpos.x, yy, zz);
                        }
                        if (cpos.x != x)
                        {
                            if (p.level.GetTile(x, yy, zz) != type)
                            {
                                BufferAdd(buffer, x, yy, zz);
                            }
                        }
                    }
                }
                if (Math.Abs(cpos.x - x) >= 2)
                {
                    for (xx = (ushort)(Math.Min(cpos.x, x) + 1); xx <= Math.Max(cpos.x, x) - 1; ++xx)
                    {
                        for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                        {
                            if (p.level.GetTile(xx, cpos.y, zz) != type)
                            {
                                BufferAdd(buffer, xx, cpos.y, zz);
                            }
                            if (cpos.y != y)
                            {
                                if (p.level.GetTile(xx, y, zz) != type)
                                {
                                    BufferAdd(buffer, xx, y, zz);
                                }
                            }
                        }
                    }
                    if (Math.Abs(cpos.y - y) >= 2)
                    {
                        for (xx = (ushort)(Math.Min(cpos.x, x) + 1); xx <= Math.Max(cpos.x, x) - 1; ++xx)
                        {
                            for (yy = (ushort)(Math.Min(cpos.y, y) + 1); yy <= Math.Max(cpos.y, y) - 1; ++yy)
                            {
                                if (p.level.GetTile(xx, yy, cpos.z) != type)
                                {
                                    BufferAdd(buffer, xx, yy, cpos.z);
                                }
                                if (cpos.z != z)
                                {
                                    if (p.level.GetTile(xx, yy, z) != type)
                                    {
                                        BufferAdd(buffer, xx, yy, z);
                                    }
                                }
                            }
                        }
                    }
                }
                break;

            case SolidType.walls:
                for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                {
                    for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        if (p.level.GetTile(cpos.x, yy, zz) != type)
                        {
                            BufferAdd(buffer, cpos.x, yy, zz);
                        }
                        if (cpos.x != x)
                        {
                            if (p.level.GetTile(x, yy, zz) != type)
                            {
                                BufferAdd(buffer, x, yy, zz);
                            }
                        }
                    }
                }
                if (Math.Abs(cpos.x - x) >= 2)
                {
                    if (Math.Abs(cpos.z - z) >= 2)
                    {
                        for (xx = (ushort)(Math.Min(cpos.x, x) + 1); xx <= Math.Max(cpos.x, x) - 1; ++xx)
                        {
                            for (yy = (ushort)(Math.Min(cpos.y, y)); yy <= Math.Max(cpos.y, y); ++yy)
                            {
                                if (p.level.GetTile(xx, yy, cpos.z) != type)
                                {
                                    BufferAdd(buffer, xx, yy, cpos.z);
                                }
                                if (cpos.z != z)
                                {
                                    if (p.level.GetTile(xx, yy, z) != type)
                                    {
                                        BufferAdd(buffer, xx, yy, z);
                                    }
                                }
                            }
                        }
                    }
                }
                break;

            case SolidType.holes:
                bool Checked = true, startZ, startY;

                for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                {
                    startY = Checked;
                    for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    {
                        startZ = Checked;
                        for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                        {
                            Checked = !Checked;
                            if (Checked && p.level.GetTile(xx, yy, zz) != type)
                            {
                                BufferAdd(buffer, xx, yy, zz);
                            }
                        }
                        Checked = !startZ;
                    }
                    Checked = !startY;
                }
                break;

            case SolidType.wire:
                for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                {
                    BufferAdd(buffer, xx, y, z);
                    BufferAdd(buffer, xx, y, cpos.z);
                    BufferAdd(buffer, xx, cpos.y, z);
                    BufferAdd(buffer, xx, cpos.y, cpos.z);
                }
                for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                {
                    BufferAdd(buffer, x, yy, z);
                    BufferAdd(buffer, x, yy, cpos.z);
                    BufferAdd(buffer, cpos.x, yy, z);
                    BufferAdd(buffer, cpos.x, yy, cpos.z);
                }
                for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                {
                    BufferAdd(buffer, x, y, zz);
                    BufferAdd(buffer, x, cpos.y, zz);
                    BufferAdd(buffer, cpos.x, y, zz);
                    BufferAdd(buffer, cpos.x, cpos.y, zz);
                }
                break;

            case SolidType.random:
                Random rand = new Random();
                for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                {
                    for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    {
                        for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                        {
                            if (rand.Next(1, 11) <= 5 && p.level.GetTile(xx, yy, zz) != type)
                            {
                                BufferAdd(buffer, xx, yy, zz);
                            }
                        }
                    }
                }
                break;
            }

            if (Server.forceCuboid)
            {
                int counter = 1;
                buffer.ForEach(delegate(Pos pos)
                {
                    if (counter <= p.group.maxBlocks)
                    {
                        counter++;
                        p.level.Blockchange(p, pos.x, pos.y, pos.z, type);
                    }
                });
                if (counter >= p.group.maxBlocks)
                {
                    Player.SendMessage(p, "Tried to cuboid " + buffer.Count + " blocks, but your limit is " + p.group.maxBlocks + ".");
                    Player.SendMessage(p, "Executed cuboid up to limit.");
                }
                else
                {
                    Player.SendMessage(p, buffer.Count.ToString() + " blocks.");
                }
                if (p.staticCommands)
                {
                    p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                }
                return;
            }

            if (buffer.Count > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to cuboid " + buffer.Count + " blocks.");
                Player.SendMessage(p, "You cannot cuboid more than " + p.group.maxBlocks + ".");
                return;
            }

            Player.SendMessage(p, buffer.Count.ToString() + " blocks.");

            buffer.ForEach(delegate(Pos pos)
            {
                p.level.Blockchange(p, pos.x, pos.y, pos.z, type);
            });

            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Ejemplo n.º 49
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);

            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            if (cpos.y == y)
            {
                Player.SendMessage(p, "Cannot create a stairway 0 blocks high.");
                return;
            }

            ushort xx, zz; int currentState = 0;

            xx = cpos.x; zz = cpos.z;

            if (cpos.x > x && cpos.z > z)
            {
                currentState = 0;
            }
            else if (cpos.x > x && cpos.z < z)
            {
                currentState = 1;
            }
            else if (cpos.x < x && cpos.z > z)
            {
                currentState = 2;
            }
            else
            {
                currentState = 3;
            }

            for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
            {
                if (currentState == 0)
                {
                    xx++; p.level.Blockchange(p, xx, yy, zz, Block.staircasestep);
                    xx++; p.level.Blockchange(p, xx, yy, zz, Block.staircasefull);
                    currentState = 1;
                }
                else if (currentState == 1)
                {
                    zz++; p.level.Blockchange(p, xx, yy, zz, Block.staircasestep);
                    zz++; p.level.Blockchange(p, xx, yy, zz, Block.staircasefull);
                    currentState = 2;
                }
                else if (currentState == 2)
                {
                    xx--; p.level.Blockchange(p, xx, yy, zz, Block.staircasestep);
                    xx--; p.level.Blockchange(p, xx, yy, zz, Block.staircasefull);
                    currentState = 3;
                }
                else
                {
                    zz--; p.level.Blockchange(p, xx, yy, zz, Block.staircasestep);
                    zz--; p.level.Blockchange(p, xx, yy, zz, Block.staircasefull);
                    currentState = 0;
                }

                /*
                 * if (cpos.x == xx && cpos.z == zz || cpos.x == xx + 1 && cpos.z == zz) xx++;
                 * else if (cpos.x == xx + 2 && cpos.z == zz || cpos.x == xx + 2 && cpos.z == zz + 1) zz++;
                 * else if (cpos.x == xx + 2 && cpos.z == zz + 2 || cpos.x == xx + 1 && cpos.z == zz + 2) xx--;
                 * else zz--;
                 */
            }

            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Ejemplo n.º 50
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);

            p.SendBlockchange(x, y, z, b);

            Bitmap myBitmap = new Bitmap("extra/images/" + bitmaplocation + ".bmp");

            myBitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);

            CatchPos cpos = (CatchPos)p.blockchangeObject;

            if (x == cpos.x && z == cpos.z)
            {
                Player.SendMessage(p, "No direction was selected"); return;
            }

            int direction;

            if (Math.Abs(cpos.x - x) > Math.Abs(cpos.z - z))
            {
                direction = 0;
                if (x <= cpos.x)
                {
                    direction = 1;
                }
            }
            else
            {
                direction = 2;
                if (z <= cpos.z)
                {
                    direction = 3;
                }
            }
            if (layer)
            {
                if (popType == 1)
                {
                    popType = 2;
                }
                if (popType == 3)
                {
                    popType = 4;
                }
            }
            List <FindReference.ColorBlock> refCol = FindReference.popRefCol(popType);

            FindReference.ColorBlock colblock;
            p.SendMessage("" + direction);
            Thread printThread = new Thread(new ThreadStart(delegate
            {
                double[] distance = new double[refCol.Count]; // Array of distances between color pulled from image to the referance colors.

                int position;                                 // This is the block selector for when we find which distance is the shortest.

                for (int k = 0; k < myBitmap.Width; k++)
                {
                    for (int i = 0; i < myBitmap.Height; i++)
                    {
                        if (layer)
                        {
                            colblock.y = cpos.y;
                            if (direction <= 1)
                            {
                                if (direction == 0)
                                {
                                    colblock.x = (ushort)(cpos.x + k); colblock.z = (ushort)(cpos.z - i);
                                }
                                else
                                {
                                    colblock.x = (ushort)(cpos.x - k); colblock.z = (ushort)(cpos.z + i);
                                }
                                //colblock.z = (ushort)(cpos.z - i);
                            }
                            else
                            {
                                if (direction == 2)
                                {
                                    colblock.z = (ushort)(cpos.z + k); colblock.x = (ushort)(cpos.x + i);
                                }
                                else
                                {
                                    colblock.z = (ushort)(cpos.z - k); colblock.x = (ushort)(cpos.x - i);
                                }
                                //colblock.x = (ushort)(cpos.x - i);
                            }
                        }
                        else
                        {
                            colblock.y = (ushort)(cpos.y + i);
                            if (direction <= 1)
                            {
                                if (direction == 0)
                                {
                                    colblock.x = (ushort)(cpos.x + k);
                                }
                                else
                                {
                                    colblock.x = (ushort)(cpos.x - k);
                                }
                                colblock.z = cpos.z;
                            }
                            else
                            {
                                if (direction == 2)
                                {
                                    colblock.z = (ushort)(cpos.z + k);
                                }
                                else
                                {
                                    colblock.z = (ushort)(cpos.z - k);
                                }
                                colblock.x = cpos.x;
                            }
                        }


                        colblock.r = myBitmap.GetPixel(k, i).R;
                        colblock.g = myBitmap.GetPixel(k, i).G;
                        colblock.b = myBitmap.GetPixel(k, i).B;
                        colblock.a = myBitmap.GetPixel(k, i).A;

                        if (popType == 6)
                        {
                            if ((colblock.r + colblock.g + colblock.b) / 3 < (256 / 4))
                            {
                                colblock.type = Block.obsidian;
                            }
                            else if (((colblock.r + colblock.g + colblock.b) / 3) >= (256 / 4) && ((colblock.r + colblock.g + colblock.b) / 3) < (256 / 4) * 2)
                            {
                                colblock.type = Block.darkgrey;
                            }
                            else if (((colblock.r + colblock.g + colblock.b) / 3) >= (256 / 4) * 2 && ((colblock.r + colblock.g + colblock.b) / 3) < (256 / 4) * 3)
                            {
                                colblock.type = Block.lightgrey;
                            }
                            else
                            {
                                colblock.type = Block.white;
                            }
                        }
                        else
                        {
                            for (int j = 0; j < distance.Length; j++) // Calculate distances between the colors in the image and the set referance colors, and store them.
                            {
                                distance[j] = Math.Sqrt(Math.Pow((colblock.r - refCol[j].r), 2) + Math.Pow((colblock.b - refCol[j].b), 2) + Math.Pow((colblock.g - refCol[j].g), 2));
                            }

                            position       = 0;
                            double minimum = distance[0];
                            for (int h = 1; h < distance.Length; h++) // Find the smallest distance in the array of distances.
                            {
                                if (distance[h] < minimum)
                                {
                                    minimum  = distance[h];
                                    position = h;
                                }
                            }


                            colblock.type = refCol[position].type; // Set the block we found closest to the image to the block we are placing.

                            if (popType == 1)
                            {
                                if (position <= 20)
                                {
                                    if (direction == 0)
                                    {
                                        colblock.z = (ushort)(colblock.z + 1);
                                    }
                                    else if (direction == 2)
                                    {
                                        colblock.x = (ushort)(colblock.x - 1);
                                    }
                                    else if (direction == 1)
                                    {
                                        colblock.z = (ushort)(colblock.z - 1);
                                    }
                                    else if (direction == 3)
                                    {
                                        colblock.x = (ushort)(colblock.x + 1);
                                    }
                                }
                            }
                            else if (popType == 3)
                            {
                                if (position <= 3)
                                {
                                    if (direction == 0)
                                    {
                                        colblock.z = (ushort)(colblock.z + 1);
                                    }
                                    else if (direction == 2)
                                    {
                                        colblock.x = (ushort)(colblock.x - 1);
                                    }
                                    else if (direction == 1)
                                    {
                                        colblock.z = (ushort)(colblock.z - 1);
                                    }
                                    else if (direction == 3)
                                    {
                                        colblock.x = (ushort)(colblock.x + 1);
                                    }
                                }
                            }
                        }

                        //ALPHA HANDLING (REAL HARD STUFF, YO)
                        if (colblock.a < 20)
                        {
                            colblock.type = Block.air;
                        }

                        FindReference.placeBlock(p.level, p, colblock.x, colblock.y, colblock.z, colblock.type);
                    }
                }
                if (bitmaplocation == "tempImage_" + p.name)
                {
                    File.Delete("extra/images/tempImage_" + p.name + ".bmp");
                }

                string printType;
                switch (popType)
                {
                case 1: printType = "2-layer color"; break;

                case 2: printType = "1-layer color"; break;

                case 3: printType = "2-layer grayscale"; break;

                case 4: printType = "1-layer grayscale"; break;

                case 5: printType = "Black and White"; break;

                case 6: printType = "Mathematical grayscale"; break;

                default: printType = "Something unknown"; break;
                }

                Player.SendMessage(p, "Finished printing image using " + printType);
            })); printThread.Start();
        }