Пример #1
0
 public override void Use(Player p, string message)
 {
     if (p != null)
     {
         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;
         p.isFlying = false;
         try
         {
             p.level.blockqueue.RemoveAll((BlockQueue.block b) => { if (b.p == p) return true; return false; });
         }
         finally { BlockQueue.resume(); }
         Player.SendMessage(p, "Every toggle or action was aborted.");
         return;
     }
     Player.SendMessage(p, "This command can only be used in-game!");
 }
Пример #2
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);
        }
Пример #3
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"); }
        }
Пример #4
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");
            }
        }
Пример #5
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.level.Blockchange(p, x, y, z, Block.c4det);
     Player.SendMessage(p, "Placed detenator block!");
 }
Пример #6
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;

            //<writes in text file the x coords>
            using (StreamWriter writer = new StreamWriter("pyramid/" + p.name + "x1.txt", true))
            {
                writer.WriteLine(bp.x);
            }
            //</writes in text file the x coords>

            //<writes in text file the y coords>
            using (StreamWriter writer = new StreamWriter("pyramid/" + p.name + "z1.txt", true))
            {
                writer.WriteLine(bp.y);
            }
            //</writes in text file the y coords>

            //<writes in text file the z coords>
            using (StreamWriter writer = new StreamWriter("pyramid/" + p.name + "y1.txt", true))
            {
                writer.WriteLine(bp.z);
            }
            //</writes in text file the z coords>

            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
        }
Пример #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;

            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);
        }
Пример #8
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>();

            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) != cpos.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);
        }
Пример #9
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.");
        }
Пример #10
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);
        }
Пример #11
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);
     p.blockchangeObject = new CatchPos(x, y, z);
     p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
 }
 public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
 {
     p.ClearBlockchange();
     p.SendBlockchange(x, y, z, p.level.GetTile(x, y, z));
     CatchPos bp = (CatchPos)p.blockchangeObject;
     bp.x = x; bp.y = y; bp.z = z; p.blockchangeObject = bp;
     p.Blockchange += Blockchange2;
 }
Пример #13
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 = Server.useMySQL ? MySQL.fillData("SELECT * FROM `Block" + p.level.name + "` WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z) : SQLite.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");
                //Server.s.Log(Blocks.Rows[i]["Type"].ToString());
                BlockUsed = Block.Name(Convert.ToByte(Blocks.Rows[i]["Type"])).ToString();
                Deleted = Convert.ToBoolean(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();
        }
Пример #14
0
 public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
 {
     p.ClearBlockchange();
     byte block = p.level.GetTile(x, y, z);
     p.SendBlockchange(x, y, z, block);
     Position bp;
     bp.x = x; bp.y = y; bp.z = z; bp.type = type; p.blockchangeObject = bp;
     p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
 }
Пример #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;

            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);
        }
Пример #16
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);
 }
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            p.SendBlockchange(x, y, z, p.level.GetTile(x, y, z));
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            FileStream fs = File.OpenRead(@Server.backupLocation + "/" + p.level.name + "/" + cpos.backup + "/" + p.level.name + ".lvl");
            GZipStream gs = new GZipStream(fs, CompressionMode.Decompress);
            byte[] ver = new byte[2];
            gs.Read(ver, 0, ver.Length);
            ushort version = BitConverter.ToUInt16(ver, 0);
            ushort[] vars = new ushort[6];
            try
            {
                if (version == 1874)
                {
                    byte[] header = new byte[16]; gs.Read(header, 0, header.Length);

                    vars[0] = BitConverter.ToUInt16(header, 0);
                    vars[1] = BitConverter.ToUInt16(header, 2);
                    vars[2] = BitConverter.ToUInt16(header, 4);
                }
                else
                {
                    byte[] header = new byte[12]; gs.Read(header, 0, header.Length);

                    vars[0] = version;
                    vars[1] = BitConverter.ToUInt16(header, 0);
                    vars[2] = BitConverter.ToUInt16(header, 2);
                }
                byte[] blocks = new byte[vars[0] * vars[2] * vars[1]];
                gs.Read(blocks, 0, blocks.Length);
                gs.Dispose();
                fs.Dispose();

                if (blocks.Length != p.level.blocks.Length) { p.SendMessage("Cant restore selection of different size maps."); blocks = null; return; }

                if (p.level.bufferblocks && !p.level.Instant)
                {
                    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)
                                BlockQueue.Addblock(p, xx, yy, zz, blocks[xx + (zz * vars[0]) + (yy * vars[0] * vars[1])]);
                }
                else
                {
                    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)
                                p.level.Blockchange(p, xx, yy, zz, blocks[xx + (zz * vars[0]) + (yy * vars[0] * vars[1])]);
                }

                blocks = null;
                if (p.staticCommands) p.Blockchange += Blockchange1;
            }
            catch { Server.s.Log("Restore selection failed"); }
        }
Пример #18
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);
     bp = (CatchPos)p.blockchangeObject;
     thex = x; they = y + 2; thez = z; p.blockchangeObject = bp;
     Thread t = new Thread(ZombieMob);
     t.Start(p);
 }
Пример #19
0
        public void BlockchangeHCone(Player p, ushort x, ushort y, ushort z, byte type)
        {
            int height = p.BcVar[0];
            int radius = p.BcVar[1];

            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            p.ClearBlockchange();
            Util.SCOGenerator.HCone(p, x, y, z, height, radius, type);
        }
Пример #20
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();

            if (type == Block.red) { Blockchange2(p, x, y, z, type); return; }
            if (type != Block.air)
            {
                p.level.Blockchange(p, x, y, z, Block.c4);
            }
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Пример #21
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);
        }
Пример #22
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;
 }
Пример #23
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            p.SendBlockchange(x, y, z, p.level.GetTile(x, y, z));
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            LavaSurvival.MapSettings settings = Server.lava.LoadMapSettings(p.level.name);
            if (cpos.mode == 0) settings.blockFlood = new LavaSurvival.Pos(x, y, z);
            if (cpos.mode == 1) settings.blockLayer = new LavaSurvival.Pos(x, y, z);
            Server.lava.SaveMapSettings(settings);

            Player.SendMessage(p, "Position set! &b(" + x + ", " + y + ", " + z + ")");
        }
Пример #24
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);
        }
Пример #25
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);
        }
Пример #26
0
 public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
 {
     p.ClearBlockchange();
     //com(p, "get the type of the changed block");
     byte b = p.level.GetTile(x, y, z);
     //com(p, "undo the change2");
     p.SendBlockchange(x, y, z, b);
     //com(p, "blockundone making Catchpos bp");
     CatchPos bp = (CatchPos)p.blockchangeObject;
     //com(p, "copy the coordinates");
     p.copystart[0] = x;
     p.copystart[1] = y;
     p.copystart[2] = z;
     //com(p, "saving the coordinates");
     com(p, x + "," + y + "," + z);
     bp.x = x; bp.y = y; bp.z = z; p.blockchangeObject = bp;
     //com(p, "wait for next blockchange");
     p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
 }
Пример #27
0
 public override void Use(Player p, string message)
 {
     if ((p.group.CanExecute(Command.all.Find("cuboid"))) && (p.group.CanExecute(Command.all.Find("static"))))
     {
         if ((!p.staticCommands == true) && (!p.megaBoid == true))
         {
             Command.all.Find("static").Use(p, message);
             Command.all.Find("cuboid").Use(p, message);
             Player.SendMessage(p, p.color + p.name + Server.DefaultColor + " to stop this, use /zz again");
         }
         else
         {
             p.ClearBlockchange();
             p.staticCommands = false;
             Player.SendMessage(p, "/zz has ended.");
         }
     }
     else { Player.SendMessage(p, "Sorry, your rank cannot use one of the commands this uses!"); }
 }
Пример #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;

            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);
        }
Пример #29
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;
         case "3":
         case "notch": p.Blockchange += new Player.BlockchangeEventHandler(AddNotchTree); break;
         case "4":
         case "swamp": p.Blockchange += new Player.BlockchangeEventHandler(AddNotchSwampTree); break;
         /*case "5":
         case "big": p.Blockchange += new Player.BlockchangeEventHandler(AddNotchBigTree); break;
         case "6":
         case "pine": p.Blockchange += new Player.BlockchangeEventHandler(AddNotchPineTree); break;*/
         default: p.Blockchange += new Player.BlockchangeEventHandler(AddTree); break;
     }
     Player.SendMessage(p, "Select where you wish your tree to grow");
     p.painting = false;
 }
Пример #30
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            p.SendBlockchange(x, y, z, p.level.GetTile(x, y, z));
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            if (cpos.mode == 2)
            {
                cpos.x = x; cpos.y = y; cpos.z = z;
                p.blockchangeObject = cpos;
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
                return;
            }

            LavaSurvival.MapSettings settings = Server.lava.LoadMapSettings(p.level.name);
            if (cpos.mode == 0) settings.blockFlood = new LavaSurvival.Pos(x, y, z);
            if (cpos.mode == 1) settings.blockLayer = new LavaSurvival.Pos(x, y, z);
            Server.lava.SaveMapSettings(settings);

            Player.SendMessage(p, String.Format("Position set! &b({0}, {1}, {2})", x, y, z));
        }
Пример #31
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
                {
                    using (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");
                    }
                    Player.SendMessage(p, "Download complete.");
                    bitmaplocation = "tempImage_" + p.name;
                    message        = bitmaplocation;
                }
                catch { }
            }
            else if (message.IndexOf('.') != -1)
            {
                try
                {
                    using (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");
                    }
                    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);
        }
Пример #32
0
        public override void Use(Player p, string message)
        {
            if (p.megaBoid == true)
            {
                Player.SendMessage(p, "You may only have on Megaboid going at once. Use /abort to cancel it."); return;
            }

            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
                {
                    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
                {
                    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);
        }
Пример #33
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 = FillType.Up;
                }
                else if (s == "down")
                {
                    cpos.fillType = FillType.Down;
                }
                else if (s == "layer")
                {
                    cpos.fillType = FillType.Layer;
                }
                else if (s == "vertical_x")
                {
                    cpos.fillType = FillType.VerticalX;
                }
                else if (s == "vertical_z")
                {
                    cpos.fillType = FillType.VerticalZ;
                }
                else
                {
                    Player.SendMessage(p, "Invalid fill type"); return;
                }
            }
            else if (message != "")
            {
                message = message.ToLower();
                if (message == "up")
                {
                    cpos.fillType = FillType.Up; cpos.type = Block.Zero;
                }
                else if (message == "down")
                {
                    cpos.fillType = FillType.Down; cpos.type = Block.Zero;
                }
                else if (message == "layer")
                {
                    cpos.fillType = FillType.Layer; cpos.type = Block.Zero;
                }
                else if (message == "vertical_x")
                {
                    cpos.fillType = FillType.VerticalX; cpos.type = Block.Zero;
                }
                else if (message == "vertical_z")
                {
                    cpos.fillType = FillType.VerticalZ; 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 = FillType.Default;
                }
            }
            else
            {
                cpos.type = Block.Zero; cpos.fillType = FillType.Default;
            }

            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);
        }
Пример #34
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 = buffer.GZip();
                    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;
            }
        }
Пример #35
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);
        }
Пример #36
0
        public override void Use(Player p, string message)
        {
            int height;
            int radius;

            if (p != null)
            {
                if (p.level.permissionbuild > p.group.Permission)
                {
                    p.SendMessage("You can not edit this map.");
                    return;
                }
                string[] message2 = message.Split(' ');

                #region cones
                if (message2[0].ToLower() == "cone")
                {
                    if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1))
                    {
                        Player.SendMessage(p, "That commands addition is for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 1)).name + "+"); return;
                    }
                    if (message2.Length != 3)
                    {
                        goto Help;
                    }

                    try
                    {
                        height  = Convert.ToUInt16(message2[1].Trim());
                        radius  = Convert.ToUInt16(message2[2].Trim());
                        p.BcVar = new int[2] {
                            height, radius
                        };
                    }
                    catch
                    {
                        goto Help;
                    }

                    p.SendMessage("Place a block");
                    p.ClearBlockchange();
                    p.Blockchange += new Player.BlockchangeEventHandler(BlockchangeCone);

                    return;
                }
                if (message2[0].ToLower() == "hcone")
                {
                    if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1))
                    {
                        Player.SendMessage(p, "That commands addition is for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 1)).name + "+"); return;
                    }
                    if (message2.Length != 3)
                    {
                        goto Help;
                    }

                    try
                    {
                        height  = Convert.ToUInt16(message2[1].Trim());
                        radius  = Convert.ToUInt16(message2[2].Trim());
                        p.BcVar = new int[2] {
                            height, radius
                        };
                    }
                    catch
                    {
                        goto Help;
                    }

                    p.SendMessage("Place a block");
                    p.ClearBlockchange();
                    p.Blockchange += new Player.BlockchangeEventHandler(BlockchangeHCone);

                    return;
                }

                if (message2[0].ToLower() == "icone")
                {
                    if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1))
                    {
                        Player.SendMessage(p, "That commands addition is for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 1)).name + "+"); return;
                    }
                    if (message2.Length != 3)
                    {
                        goto Help;
                    }

                    try
                    {
                        height  = Convert.ToUInt16(message2[1].Trim());
                        radius  = Convert.ToUInt16(message2[2].Trim());
                        p.BcVar = new int[2] {
                            height, radius
                        };
                    }
                    catch
                    {
                        goto Help;
                    }

                    p.SendMessage("Place a block");
                    p.ClearBlockchange();
                    p.Blockchange += new Player.BlockchangeEventHandler(BlockchangeICone);

                    return;
                }
                if (message2[0].ToLower() == "hicone")
                {
                    if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 1))
                    {
                        Player.SendMessage(p, "That commands addition is for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 1)).name + "+"); return;
                    }
                    if (message2.Length != 3)
                    {
                        goto Help;
                    }

                    try
                    {
                        height  = Convert.ToUInt16(message2[1].Trim());
                        radius  = Convert.ToUInt16(message2[2].Trim());
                        p.BcVar = new int[2] {
                            height, radius
                        };
                    }
                    catch
                    {
                        goto Help;
                    }

                    p.SendMessage("Place a block");
                    p.ClearBlockchange();
                    p.Blockchange += new Player.BlockchangeEventHandler(BlockchangeHICone);

                    return;
                }
                #endregion
                #region pyramids
                if (message2[0].ToLower() == "pyramid")
                {
                    if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 2))
                    {
                        Player.SendMessage(p, "That commands addition is for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 2)).name + "+"); return;
                    }
                    if (message2.Length != 3)
                    {
                        goto Help;
                    }

                    try
                    {
                        height  = Convert.ToUInt16(message2[1].Trim());
                        radius  = Convert.ToUInt16(message2[2].Trim());
                        p.BcVar = new int[2] {
                            height, radius
                        };
                    }
                    catch
                    {
                        goto Help;
                    }

                    p.SendMessage("Place a block");
                    p.ClearBlockchange();
                    p.Blockchange += new Player.BlockchangeEventHandler(BlockchangePyramid);

                    return;
                }
                if (message2[0].ToLower() == "hpyramid")
                {
                    if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 2))
                    {
                        Player.SendMessage(p, "That commands addition is for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 2)).name + "+"); return;
                    }
                    if (message2.Length != 3)
                    {
                        goto Help;
                    }

                    try
                    {
                        height  = Convert.ToUInt16(message2[1].Trim());
                        radius  = Convert.ToUInt16(message2[2].Trim());
                        p.BcVar = new int[2] {
                            height, radius
                        };
                    }
                    catch
                    {
                        goto Help;
                    }

                    p.SendMessage("Place a block");
                    p.ClearBlockchange();
                    p.Blockchange += new Player.BlockchangeEventHandler(BlockchangeHPyramid);

                    return;
                }
                if (message2[0].ToLower() == "ipyramid")
                {
                    if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 2))
                    {
                        Player.SendMessage(p, "That commands addition is for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 2)).name + "+"); return;
                    }
                    if (message2.Length != 3)
                    {
                        goto Help;
                    }

                    try
                    {
                        height  = Convert.ToUInt16(message2[1].Trim());
                        radius  = Convert.ToUInt16(message2[2].Trim());
                        p.BcVar = new int[2] {
                            height, radius
                        };
                    }
                    catch
                    {
                        goto Help;
                    }

                    p.SendMessage("Place a block");
                    p.ClearBlockchange();
                    p.Blockchange += new Player.BlockchangeEventHandler(BlockchangeIPyramid);

                    return;
                }
                if (message2[0].ToLower() == "hipyramid")
                {
                    if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 2))
                    {
                        Player.SendMessage(p, "That commands addition is for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 2)).name + "+"); return;
                    }
                    if (message2.Length != 3)
                    {
                        goto Help;
                    }

                    try
                    {
                        height  = Convert.ToUInt16(message2[1].Trim());
                        radius  = Convert.ToUInt16(message2[2].Trim());
                        p.BcVar = new int[2] {
                            height, radius
                        };
                    }
                    catch
                    {
                        goto Help;
                    }

                    p.SendMessage("Place a block");
                    p.ClearBlockchange();
                    p.Blockchange += new Player.BlockchangeEventHandler(BlockchangeHIPyramid);

                    return;
                }
                #endregion
                #region spheres
                if (message2[0].ToLower() == "sphere")
                {
                    if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 3))
                    {
                        Player.SendMessage(p, "That commands addition is for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 3)).name + "+"); return;
                    }
                    if (message2.Length != 2)
                    {
                        goto Help;
                    }

                    try
                    {
                        radius  = Convert.ToUInt16(message2[1].Trim());
                        p.BcVar = new int[2] {
                            0, radius
                        };
                    }
                    catch
                    {
                        goto Help;
                    }

                    p.SendMessage("Place a block");
                    p.ClearBlockchange();
                    p.Blockchange += new Player.BlockchangeEventHandler(BlockchangeSphere);

                    return;
                }
                if (message2[0].ToLower() == "hsphere")
                {
                    if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 3))
                    {
                        Player.SendMessage(p, "That commands addition is for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 3)).name + "+"); return;
                    }
                    if (message2.Length != 2)
                    {
                        goto Help;
                    }

                    try
                    {
                        radius  = Convert.ToUInt16(message2[1].Trim());
                        p.BcVar = new int[2] {
                            0, radius
                        };
                    }
                    catch
                    {
                        goto Help;
                    }

                    p.SendMessage("Place a block");
                    p.ClearBlockchange();
                    p.Blockchange += new Player.BlockchangeEventHandler(BlockchangeHSphere);

                    return;
                }
                #endregion
                #region other
                if (message2[0].ToLower() == "volcano")
                {
                    if ((int)p.group.Permission < CommandOtherPerms.GetPerm(this, 4))
                    {
                        Player.SendMessage(p, "That commands addition is for " + Group.findPermInt(CommandOtherPerms.GetPerm(this, 4)).name + "+"); return;
                    }
                    if (message2.Length != 3)
                    {
                        goto Help;
                    }

                    try
                    {
                        height  = Convert.ToUInt16(message2[1].Trim());
                        radius  = Convert.ToUInt16(message2[2].Trim());
                        p.BcVar = new int[2] {
                            height, radius
                        };
                    }
                    catch
                    {
                        goto Help;
                    }

                    p.SendMessage("Place a block");
                    p.ClearBlockchange();
                    p.Blockchange += new Player.BlockchangeEventHandler(BlockchangeValcano);

                    return;
                }
                #endregion

Help:
                Help(p);
                return;
            }
            Player.SendMessage(p, "This command can only be used in-game!");
        }
Пример #37
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);
            }
        }
Пример #38
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte block = p.level.GetTile(x, y, z);

            p.SendBlockchange(x, y, z, block);
            Position cpos = (Position)p.blockchangeObject;

            unchecked { if (cpos.type != (byte)-1)
                        {
                            type = cpos.type;
                        }
            }



            double x1     = cpos.x;
            double y1     = cpos.z;
            double x2     = x;
            double y2     = z;
            int    height = Math.Abs(cpos.y - y) + 1;

            double xstart = Math.Min(x1, x2);
            double ystart = Math.Min(y1, y2);


            double a = ((Math.Abs(x1 - x2) + 1) / 2);
            double b = ((Math.Abs(y1 - y2) + 1) / 2);



            int  dimensionx = (int)(Math.Abs(x1 - x2) + 1);
            bool OVX;
            bool OVY;
            int  dimensiony = (int)(Math.Abs(y1 - y2) + 1);

            double[] yc     = new double[dimensionx / 2 + 1];
            double[] length = new double[dimensionx / 2 + 1];

            if (dimensionx % 2 == 0)  // x is even
            {
                OVX = false;
            }
            else
            {
                // It's odd

                OVX = true;
            }

            if (dimensiony % 2 == 0)
            {
                OVY = false;
            }
            else
            {
                OVY = true;
            }

            int limit = 0;

            for (int i = 0; i < ((int)a); i++)
            {
                if (i == 0)
                {
                    yc[i]     = Math.Ceiling(Math.Abs(Math.Sqrt((Math.Pow(a, 2) - Math.Pow(i + 0.5, 2))) * Math.Abs(b / a)));
                    length[i] = 0;
                    limit++;
                }
                else
                {
                    if (i == (int)a - 1)
                    {
                        yc[i] = 1;
                        if (yc[i - 1] - yc[i] > 1)
                        {
                            length[i] = Math.Round(yc[i - 1]) - Math.Round(yc[i]) - 1;
                            limit++;
                        }
                        else
                        {
                            length[i] = 0; limit++;
                        }
                    }
                    else
                    {
                        yc[i] = Math.Abs(Math.Sqrt((Math.Pow(a, 2) - Math.Pow(i + 0.5, 2))) * Math.Abs(b / a));
                        if (yc[i - 1] - yc[i] > 1)
                        {
                            length[i] = Math.Round(yc[i - 1]) - Math.Round(yc[i]) - 1; limit++;
                        }
                        else
                        {
                            length[i] = 0; limit++;
                        }
                    }
                }
            }


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



            //firststart
            int startx = (int)xstart + (int)a;
            int starty = (int)ystart + (int)b;

            ushort starth = Math.Min(cpos.y, y);

            //int endh = Math.Max(cpos.y,y);

            for (int h = 0; h < height; h++)
            {
                for (int i = 0; i < ((int)a); i++)
                {
                    if (length[i] == 0)
                    {
                        p.level.Blockchange(p, (ushort)(startx + i), starth, (ushort)(starty + ((int)Math.Round(yc[i]) - 1)), type);
                    }
                    if (length[i] != 0)
                    {
                        for (int ii = 0; ii <= length[i]; ii++)
                        {
                            p.level.Blockchange(p, (ushort)(startx + i), starth, (ushort)(starty + ((int)Math.Round(yc[i]) - 1 + ii)), type);
                        }
                    }
                }
                if (OVX)
                {
                    for (int i = 0; i < ((int)a); i++)
                    {
                        if (length[i] == 0)
                        {
                            p.level.Blockchange(p, (ushort)(startx - i), starth, (ushort)(starty + ((int)Math.Round(yc[i]) - 1)), type);
                        }
                        if (length[i] != 0)
                        {
                            for (int ii = 0; ii <= length[i]; ii++)
                            {
                                p.level.Blockchange(p, (ushort)(startx - i), starth, (ushort)(starty + ((int)Math.Round(yc[i]) - 1 + ii)), type);
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < ((int)a); i++)
                    {
                        if (length[i] == 0)
                        {
                            p.level.Blockchange(p, (ushort)(startx - 1 - i), starth, (ushort)(starty + ((int)Math.Round(yc[i]) - 1)), type);
                        }
                        if (length[i] != 0)
                        {
                            for (int ii = 0; ii <= length[i]; ii++)
                            {
                                p.level.Blockchange(p, (ushort)(startx - 1 - i), starth, (ushort)(starty + ((int)Math.Round(yc[i]) - 1 + ii)), type);
                            }
                        }
                    }
                }
                // OVY STARTS HERE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                if (OVY)
                {
                    for (int i = 0; i < ((int)a); i++)
                    {
                        if (length[i] == 0)
                        {
                            p.level.Blockchange(p, (ushort)(startx + i), starth, (ushort)(starty - ((int)Math.Round(yc[i]) - 1)), type);
                        }
                        if (length[i] != 0)
                        {
                            for (int ii = 0; ii <= length[i]; ii++)
                            {
                                p.level.Blockchange(p, (ushort)(startx + i), starth, (ushort)(starty - ((int)Math.Round(yc[i]) - 1 + ii)), type);
                            }
                        }
                    }
                    if (OVX)
                    {
                        for (int i = 0; i < ((int)a); i++)
                        {
                            if (length[i] == 0)
                            {
                                p.level.Blockchange(p, (ushort)(startx - i), starth, (ushort)(starty - ((int)Math.Round(yc[i]) - 1)), type);
                            }
                            if (length[i] != 0)
                            {
                                for (int ii = 0; ii <= length[i]; ii++)
                                {
                                    p.level.Blockchange(p, (ushort)(startx - i), starth, (ushort)(starty - ((int)Math.Round(yc[i]) - 1 + ii)), type);
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < ((int)a); i++)
                        {
                            if (length[i] == 0)
                            {
                                p.level.Blockchange(p, (ushort)(startx - 1 - i), starth, (ushort)(starty - ((int)Math.Round(yc[i]) - 1)), type);
                            }
                            if (length[i] != 0)
                            {
                                for (int ii = 0; ii <= length[i]; ii++)
                                {
                                    p.level.Blockchange(p, (ushort)(startx - 1 - i), starth, (ushort)(starty - ((int)Math.Round(yc[i]) - 1 + ii)), type);
                                }
                            }
                        }
                    }
                }
                // NO OVY !!!!!!!!!!!!!!!!!!!!!!!!
                else
                {
                    for (int i = 0; i < ((int)a); i++)
                    {
                        if (length[i] == 0)
                        {
                            p.level.Blockchange(p, (ushort)(startx + i), starth, (ushort)(starty - ((int)Math.Round(yc[i]))), type);
                        }
                        if (length[i] != 0)
                        {
                            for (int ii = 0; ii <= length[i]; ii++)
                            {
                                p.level.Blockchange(p, (ushort)(startx + i), starth, (ushort)(starty - ((int)Math.Round(yc[i]) + ii)), type);
                            }
                        }
                    }
                    if (OVX)
                    {
                        for (int i = 0; i < ((int)a); i++)
                        {
                            if (length[i] == 0)
                            {
                                p.level.Blockchange(p, (ushort)(startx - i), starth, (ushort)(starty - ((int)Math.Round(yc[i]))), type);
                            }
                            if (length[i] != 0)
                            {
                                for (int ii = 0; ii <= length[i]; ii++)
                                {
                                    p.level.Blockchange(p, (ushort)(startx - i), starth, (ushort)(starty - ((int)Math.Round(yc[i]) + ii)), type);
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < ((int)a); i++)
                        {
                            if (length[i] == 0)
                            {
                                p.level.Blockchange(p, (ushort)(startx - 1 - i), starth, (ushort)(starty - ((int)Math.Round(yc[i]))), type);
                            }
                            if (length[i] != 0)
                            {
                                for (int ii = 0; ii <= length[i]; ii++)
                                {
                                    p.level.Blockchange(p, (ushort)(startx - 1 - i), starth, (ushort)(starty - ((int)Math.Round(yc[i]) + ii)), type);
                                }
                            }
                        }
                    }
                }
                starth++;
            }
            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Пример #39
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);
            }
        }
Пример #40
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);
        }
Пример #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;
            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);
            }
        }
Пример #42
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);
            }
        }
Пример #43
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.");
        }
 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);
 }
Пример #45
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            //com(p, "get the type of the changed block");
            byte b = p.level.GetTile(x, y, z);

            //com(p, "undo the change");
            p.SendBlockchange(x, y, z, b);
            //getting the startpos of copy stored in blockchangeobject
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            List <Player.CopyPos> CBuffer = new List <Player.CopyPos>();

            CBuffer.Clear();
            //com(p, "copy stuff");
            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);
                        BufferAdd(p, (ushort)(xx - cpos.x), (ushort)(yy - cpos.y), (ushort)(zz - cpos.z), b, CBuffer);
                    }
                }
            }
            //com(p, "stuff is copied. now append to file");
            //com(p, "get the number of next frame");
            int FrameNumber = 0;

            using (FileStream ReadStream = File.OpenRead(Filepath))
            {
                String temp = "";
                for (int j = 0; j < 5; j++)
                {
                    temp += (Char)ReadStream.ReadByte();
                }
                FrameNumber = int.Parse(temp);
                //framecount aquired(hopefully)
                //now we have to add 1 to that and write it back in the file
                FrameNumber++;
                Byte[] ba   = new Byte[5];
                int    Fnum = FrameNumber;
                for (int i = 4; i >= 0; i--)
                {
                    ba[i]  = Byte.Parse((Fnum % 10).ToString());
                    ba[i] += 48;
                    //ba[i] = (Byte)49;
                    Fnum /= 10;
                }

                using (FileStream WriteStream = File.OpenWrite(Filepath))
                {
                    WriteStream.Write(ba, 0, 5);
                    //written new number in file
                }
            }
            cin = File.AppendText(Filepath);
            cin.Write("[Frame" + String.Format("{0:00000}", FrameNumber) + "]{");
            //written frameheader
            foreach (Player.CopyPos CP in CBuffer)
            {
                String tBlock = "";
                tBlock += CP.x + ";";
                tBlock += CP.y + ";";
                tBlock += CP.z + ";";
                //written coordinates in string
                tBlock += CP.type + "|";
                cin.Write(tBlock);
            }
            cin.Write("}" + Environment.NewLine);
            //work done. saved frame in file
            cin.Flush();
            cin.Close();
            cin.Dispose();
            com(p, "Saved Blocks to File");
        }
Пример #46
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 center points
                double cx = (ex + sx) / 2 + (((ex + sx) % 2 == 1) ? 0.5 : 0);
                double cy = (ey + sy) / 2 + (((ey + sy) % 2 == 1) ? 0.5 : 0);
                double cz = (ez + sz) / 2 + (((ez + sz) % 2 == 1) ? 0.5 : 0);

                // find axis lengths
                double rx = Convert.ToDouble(ex) - cx + 0.25;
                double ry = Convert.ToDouble(ey) - cy + 0.25;
                double rz = Convert.ToDouble(ez) - cz + 0.25;

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

                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 + ".");
                    wait = 1;
                    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
            {
                // 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 center points
                double cx = (ex + sx) / 2 + (((ex + sx) % 2 == 1) ? 0.5 : 0);
                double cz = (ez + sz) / 2 + (((ez + sz) % 2 == 1) ? 0.5 : 0);

                // find axis lengths
                double rx = Convert.ToDouble(ex) - cx + 0.25;
                double rz = Convert.ToDouble(ez) - cz + 0.25;

                double rx2      = 1 / (rx * rx);
                double rz2      = 1 / (rz * rz);
                double smallrx2 = 1 / ((rx - 1) * (rx - 1));
                double smallrz2 = 1 / ((rz - 1) * (rz - 1));

                Pos pos = new Pos();

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

                                // test if it's inside ellipse
                                if ((dx * dx) * rx2 + (dz * dz) * rz2 <= 1 && (dx * dx) * smallrx2 + (dz * dz) * smallrz2 > 1)
                                {
                                    pos.x = (ushort)(x3 + xx);
                                    pos.y = (ushort)(sy);
                                    pos.z = (ushort)(zz + z3);
                                    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 + ".");
                    wait = 1;
                    return;
                }
                Player.SendMessage(p, buffer.Count * ydiff + " blocks.");


                foreach (Pos Pos in buffer)
                {
                    for (ushort yy = (ushort)sy; yy <= (ushort)ey; yy++)
                    {
                        p.level.Blockchange(p, Pos.x, yy, Pos.z, type);
                    }
                }
            }
            wait = 2;
            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Пример #47
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.");
                    }
                }
            }
        }
        public override void Use(Player p, string message)
        {
            if (String.IsNullOrEmpty(message))
            {
                Help(p); return;
            }
            string[] s = message.ToLower().Split(' ');
            if (p == null && (s[0] == "go" || s[0] == "setup"))
            {
                Player.SendMessage(p, "The \"" + s[0] + "\" command can only be used in-game!"); return;
            }

            if (s[0] == "go")
            {
                if (!Server.lava.active)
                {
                    Player.SendMessage(p, "There is no Lava Survival game right now."); return;
                }
                Command.all.Find("goto").Use(p, Server.lava.map.name);
                return;
            }
            if (s[0] == "info")
            {
                if (!Server.lava.active)
                {
                    Player.SendMessage(p, "There is no Lava Survival game right now."); return;
                }
                if (!Server.lava.roundActive)
                {
                    Player.SendMessage(p, "The round of Lava Survival hasn't started yet."); return;
                }
                Server.lava.AnnounceRoundInfo(p, p == null);
                Server.lava.AnnounceTimeLeft(!Server.lava.flooded, true, p, p == null);
                return;
            }
            if (p == null || p.group.Permission >= Server.lava.controlRank)
            {
                if (s[0] == "start")
                {
                    switch (Server.lava.Start(s.Length > 1 ? s[1] : ""))
                    {
                    case 0:
                        Player.GlobalMessage("Lava Survival has started! Join the fun with /ls go");
                        return;

                    case 1:
                        Player.SendMessage(p, "There is already an active Lava Survival game.");
                        return;

                    case 2:
                        Player.SendMessage(p, "You must have at least 3 configured maps to play Lava Survival.");
                        return;

                    case 3:
                        Player.SendMessage(p, "The specified map doesn't exist.");
                        return;

                    default:
                        Player.SendMessage(p, "An unknown error occurred.");
                        return;
                    }
                }
                if (s[0] == "stop")
                {
                    switch (Server.lava.Stop())
                    {
                    case 0:
                        Player.GlobalMessage("Lava Survival has ended! We hope you had fun!");
                        return;

                    case 1:
                        Player.SendMessage(p, "There isn't an active Lava Survival game.");
                        return;

                    default:
                        Player.SendMessage(p, "An unknown error occurred.");
                        return;
                    }
                }
                if (s[0] == "end")
                {
                    if (!Server.lava.active)
                    {
                        Player.SendMessage(p, "There isn't an active Lava Survival game."); return;
                    }
                    if (Server.lava.roundActive)
                    {
                        Server.lava.EndRound();
                    }
                    else if (Server.lava.voteActive)
                    {
                        Server.lava.EndVote();
                    }
                    else
                    {
                        Player.SendMessage(p, "There isn't an active round or vote to end.");
                    }
                    return;
                }
            }
            if (p == null || p.group.Permission >= Server.lava.setupRank)
            {
                if (s[0] == "setup")
                {
                    if (s.Length < 2)
                    {
                        SetupHelp(p); return;
                    }
                    if (Server.lava.active)
                    {
                        Player.SendMessage(p, "You cannot configure Lava Survival while a game is active."); return;
                    }
                    if (s[1] == "map")
                    {
                        if (s.Length < 3)
                        {
                            SetupHelp(p, "map"); return;
                        }
                        Level foundLevel = Level.Find(s[2]);
                        if (foundLevel == null)
                        {
                            Player.SendMessage(p, "The level must be loaded to add/remove it.");
                            return;
                        }
                        else
                        {
                            if (foundLevel == Server.mainLevel)
                            {
                                Player.SendMessage(p, "You cannot use the main map for Lava Survival."); return;
                            }
                            if (Server.lava.HasMap(foundLevel.name))
                            {
                                Server.lava.RemoveMap(foundLevel.name);
                                foundLevel.motd       = "ignore";
                                foundLevel.overload   = 1500;
                                foundLevel.unload     = true;
                                foundLevel.loadOnGoto = true;
                                Level.SaveSettings(foundLevel);
                                Player.SendMessage(p, "Map \"" + foundLevel.name + "\" has been removed.");
                                return;
                            }
                            else
                            {
                                Server.lava.AddMap(foundLevel.name);

                                LavaSurvival.MapSettings settings = Server.lava.LoadMapSettings(foundLevel.name);
                                settings.blockFlood = new LavaSurvival.Pos((ushort)(foundLevel.width / 2), (ushort)(foundLevel.depth - 1), (ushort)(foundLevel.height / 2));
                                settings.blockLayer = new LavaSurvival.Pos(0, (ushort)(foundLevel.depth / 2), 0);
                                ushort x = (ushort)(foundLevel.width / 2), y = (ushort)(foundLevel.depth / 2), z = (ushort)(foundLevel.height / 2);
                                settings.safeZone = new LavaSurvival.Pos[] { new LavaSurvival.Pos((ushort)(x - 3), y, (ushort)(z - 3)), new LavaSurvival.Pos((ushort)(x + 3), (ushort)(y + 4), (ushort)(z + 3)) };
                                Server.lava.SaveMapSettings(settings);

                                foundLevel.motd       = "Lava Survival: " + foundLevel.name.Capitalize();
                                foundLevel.overload   = 1000000;
                                foundLevel.unload     = false;
                                foundLevel.loadOnGoto = false;
                                Level.SaveSettings(foundLevel);
                                Player.SendMessage(p, "Map \"" + foundLevel.name + "\" has been added.");
                                return;
                            }
                        }
                    }
                    if (s[1] == "block")
                    {
                        if (!Server.lava.HasMap(p.level.name))
                        {
                            Player.SendMessage(p, "Add the map before configuring it."); return;
                        }
                        if (s.Length < 3)
                        {
                            SetupHelp(p, "block"); return;
                        }

                        if (s[2] == "flood")
                        {
                            Player.SendMessage(p, "Place or destroy the block you want to be the total flood block spawn point.");
                            CatchPos cpos; cpos.mode = 0;
                            cpos.x = 0; cpos.y = 0; cpos.z = 0;
                            p.blockchangeObject = cpos;
                            p.ClearBlockchange();
                            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                            return;
                        }
                        if (s[2] == "layer")
                        {
                            Player.SendMessage(p, "Place or destroy the block you want to be the layer flood base spawn point.");
                            CatchPos cpos; cpos.mode = 1;
                            cpos.x = 0; cpos.y = 0; cpos.z = 0;
                            p.blockchangeObject = cpos;
                            p.ClearBlockchange();
                            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                            return;
                        }

                        SetupHelp(p, "block");
                        return;
                    }
                    if (s[1] == "safezone" || s[1] == "safe")
                    {
                        Player.SendMessage(p, "Place two blocks to determine the edges.");
                        CatchPos cpos; cpos.mode = 2;
                        cpos.x = 0; cpos.y = 0; cpos.z = 0;
                        p.blockchangeObject = cpos;
                        p.ClearBlockchange();
                        p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                        return;
                    }
                    if (s[1] == "settings")
                    {
                        if (s.Length < 3)
                        {
                            Player.SendMessage(p, "Maps: &b" + Server.lava.Maps.Concatenate(", "));
                            Player.SendMessage(p, "Setup rank: " + Group.findPerm(Server.lava.setupRank).color + Group.findPerm(Server.lava.setupRank).trueName);
                            Player.SendMessage(p, "Control rank: " + Group.findPerm(Server.lava.controlRank).color + Group.findPerm(Server.lava.controlRank).trueName);
                            Player.SendMessage(p, "Start on server startup: " + (Server.lava.startOnStartup ? "&aON" : "&cOFF"));
                            Player.SendMessage(p, "Send AFK to main: " + (Server.lava.sendAfkMain ? "&aON" : "&cOFF"));
                            Player.SendMessage(p, "Vote count: &b" + Server.lava.voteCount);
                            Player.SendMessage(p, "Vote time: &b" + Server.lava.voteTime + " minute" + (Server.lava.voteTime == 1 ? "" : "s"));
                            return;
                        }

                        try
                        {
                            switch (s[2])
                            {
                            case "sendafkmain":
                                Server.lava.sendAfkMain = !Server.lava.sendAfkMain;
                                Player.SendMessage(p, "Send AFK to main: " + (Server.lava.sendAfkMain ? "&aON" : "&cOFF"));
                                break;

                            case "votecount":
                                Server.lava.voteCount = (byte)MathHelper.Clamp(decimal.Parse(s[3]), 2, 10);
                                Player.SendMessage(p, "Vote count: &b" + Server.lava.voteCount);
                                break;

                            case "votetime":
                                Server.lava.voteTime = double.Parse(s[3]);
                                Player.SendMessage(p, "Vote time: &b" + Server.lava.voteTime + "minute" + (Server.lava.voteTime == 1 ? "" : "s"));
                                break;

                            default:
                                SetupHelp(p, "settings");
                                return;
                            }
                            Server.lava.SaveSettings();
                            return;
                        }
                        catch { Player.SendMessage(p, "INVALID INPUT"); return; }
                    }
                    if (s[1] == "mapsettings")
                    {
                        if (!Server.lava.HasMap(p.level.name))
                        {
                            Player.SendMessage(p, "Add the map before configuring it."); return;
                        }
                        LavaSurvival.MapSettings settings = Server.lava.LoadMapSettings(p.level.name);
                        if (s.Length < 4)
                        {
                            Player.SendMessage(p, "Fast lava chance: &b" + settings.fast + "%");
                            Player.SendMessage(p, "Killer lava/water chance: &b" + settings.killer + "%");
                            Player.SendMessage(p, "Destroy blocks chance: &b" + settings.destroy + "%");
                            Player.SendMessage(p, "Water flood chance: &b" + settings.water + "%");
                            Player.SendMessage(p, "Layer flood chance: &b" + settings.layer + "%");
                            Player.SendMessage(p, "Layer height: &b" + settings.layerHeight + " block" + (settings.layerHeight == 1 ? "" : "s"));
                            Player.SendMessage(p, "Layer count: &b" + settings.layerCount);
                            Player.SendMessage(p, "Layer time: &b" + settings.layerInterval + " minute" + (settings.layerInterval == 1 ? "" : "s"));
                            Player.SendMessage(p, "Round time: &b" + settings.roundTime + " minute" + (settings.roundTime == 1 ? "" : "s"));
                            Player.SendMessage(p, "Flood time: &b" + settings.floodTime + " minute" + (settings.floodTime == 1 ? "" : "s"));
                            Player.SendMessage(p, "Flood position: &b" + settings.blockFlood.ToString(", "));
                            Player.SendMessage(p, "Layer position: &b" + settings.blockLayer.ToString(", "));
                            Player.SendMessage(p, String.Format("Safe zone: &b({0}) ({1})", settings.safeZone[0].ToString(", "), settings.safeZone[1].ToString(", ")));
                            return;
                        }

                        try
                        {
                            switch (s[2])
                            {
                            case "fast":
                                settings.fast = (byte)MathHelper.Clamp(decimal.Parse(s[3]), 0, 100);
                                Player.SendMessage(p, "Fast lava chance: &b" + settings.fast + "%");
                                break;

                            case "killer":
                                settings.killer = (byte)MathHelper.Clamp(decimal.Parse(s[3]), 0, 100);
                                Player.SendMessage(p, "Killer lava/water chance: &b" + settings.killer + "%");
                                break;

                            case "destroy":
                                settings.destroy = (byte)MathHelper.Clamp(decimal.Parse(s[3]), 0, 100);
                                Player.SendMessage(p, "Destroy blocks chance: &b" + settings.destroy + "%");
                                break;

                            case "water":
                                settings.water = (byte)MathHelper.Clamp(decimal.Parse(s[3]), 0, 100);
                                Player.SendMessage(p, "Water flood chance: &b" + settings.water + "%");
                                break;

                            case "layer":
                                settings.layer = (byte)MathHelper.Clamp(decimal.Parse(s[3]), 0, 100);
                                Player.SendMessage(p, "Layer flood chance: &b" + settings.layer + "%");
                                break;

                            case "layerheight":
                                settings.layerHeight = int.Parse(s[3]);
                                Player.SendMessage(p, "Layer height: &b" + settings.layerHeight + " block" + (settings.layerHeight == 1 ? "" : "s"));
                                break;

                            case "layercount":
                                settings.layerCount = int.Parse(s[3]);
                                Player.SendMessage(p, "Layer count: &b" + settings.layerCount);
                                break;

                            case "layertime":
                                settings.layerInterval = double.Parse(s[3]);
                                Player.SendMessage(p, "Layer time: &b" + settings.layerInterval + " minute" + (settings.layerInterval == 1 ? "" : "s"));
                                break;

                            case "roundtime":
                                settings.roundTime = double.Parse(s[3]);
                                Player.SendMessage(p, "Round time: &b" + settings.roundTime + " minute" + (settings.roundTime == 1 ? "" : "s"));
                                break;

                            case "floodtime":
                                settings.floodTime = double.Parse(s[3]);
                                Player.SendMessage(p, "Flood time: &b" + settings.floodTime + " minute" + (settings.floodTime == 1 ? "" : "s"));
                                break;

                            default:
                                SetupHelp(p, "mapsettings");
                                return;
                            }
                        }
                        catch { Player.SendMessage(p, "INVALID INPUT"); return; }
                        Server.lava.SaveMapSettings(settings);
                        return;
                    }
                }
            }

            Help(p);
        }
Пример #49
0
        public override void Use(Player p, string message)
        {
            if (message.Split(' ')[0].ToLower() == "save")
            {
                if (message.Split(' ').Length != 2 || String.IsNullOrEmpty(message.Split(' ')[1]))
                {
                    Help(p); return;
                }
                Savecopy(p, message.Split(' ')[1]); return;
            }
            if (message.Split(' ')[0].ToLower() == "load")
            {
                if (message.Split(' ').Length != 2 || String.IsNullOrEmpty(message.Split(' ')[1]))
                {
                    Help(p); return;
                }
                Loadcopy(p, message.Split(' ')[1]); return;
            }
            if (message.Split(' ')[0].ToLower() == "delete")
            {
                if (message.Split(' ').Length != 2 || String.IsNullOrEmpty(message.Split(' ')[1]))
                {
                    Help(p); return;
                }
                message = message.Split(' ')[1];
                if (!File.Exists("extra/savecopy/" + p.name + "/" + message + ".cpy"))
                {
                    Player.SendMessage(p, "No such copy exists"); return;
                }
                File.Delete("extra/savecopy/" + p.name + "/" + message + ".cpy");
                Player.SendMessage(p, "Deleted copy " + message); return;
            }
            if (message.ToLower() == "list")
            {
                if (!Directory.Exists("extra/savecopy/" + p.name))
                {
                    Player.SendMessage(p, "No such directory exists"); return;
                }
                FileInfo[] fin = new DirectoryInfo("extra/savecopy/" + p.name).GetFiles();
                for (int i = 0; i < fin.Length; i++)
                {
                    Player.SendMessage(p, fin[i].Name.Replace(".cpy", ""));
                }
                return;
            }
            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);
        }
Пример #50
0
        public override void Use(Player p, string message)
        {
            int    number = 0;
            string msg    = String.Empty;

            try
            {
                number = message.Split(' ').Length;
            }
            catch { }
            wait = 0;
            if (number > 2)
            {
                Help(p); wait = 1;  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 + "\"."); wait = 1; return;
                }

                if (!Block.canPlace(p, type))
                {
                    Player.SendMessage(p, "Cannot place that."); wait = 1; 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;
                try
                {
                    msg = message.ToLower();
                }
                catch { }
                byte type; unchecked { type = (byte)-1; }
                if (msg == "solid")
                {
                    solid = SolidType.solid;
                }
                else if (msg == "hollow")
                {
                    solid = SolidType.hollow;
                }
                else if (msg == "walls")
                {
                    solid = SolidType.walls;
                }
                else if (msg == "holes")
                {
                    solid = SolidType.holes;
                }
                else if (msg == "wire")
                {
                    solid = SolidType.wire;
                }
                else if (msg == "random")
                {
                    solid = SolidType.random;
                }
                else
                {
                    byte t = Block.Byte(msg);
                    if (t == 255)
                    {
                        Player.SendMessage(p, "There is no block \"" + msg + "\"."); wait = 1; return;
                    }

                    if (!Block.canPlace(p, t))
                    {
                        Player.SendMessage(p, "Cannot place that."); wait = 1; 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;
            }
            if (p.pyramidsilent == false)
            {
                Player.SendMessage(p, "Place two blocks to determine the edges.");
            }
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Пример #51
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)
            {
            }
            else if (message.IndexOf('.') != -1)
            {
            }
            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);
        }
Пример #52
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;
            }

            // Check to see if user is subject to anti-tunneling
            if (Server.antiTunnel && p.group.Permission == LevelPermission.Guest && !p.ignoreGrief)
            {
                int CheckForBlocksBelowY = p.level.depth / 2 - Server.maxDepth;
                if (buffer.Any(pos => pos.y < CheckForBlocksBelowY))
                {
                    p.SendMessage("You're not allowed to build this far down!");
                    return;
                }
            }

            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.");

                    wait = 2;
                }
                else
                {
                    Player.SendMessage(p, buffer.Count.ToString() + " blocks.");
                }
                wait = 2;
                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 + ".");
                wait = 1;
                return;
            }

            if (p.pyramidsilent == false)
            {
                Player.SendMessage(p, buffer.Count.ToString() + " blocks.");
            }

            if (p.level.bufferblocks && !p.level.Instant)
            {
                buffer.ForEach(delegate(Pos pos)
                {
                    BlockQueue.Addblock(p, pos.x, pos.y, pos.z, type);
                });
            }
            else
            {
                buffer.ForEach(delegate(Pos pos)
                {
                    p.level.Blockchange(p, pos.x, pos.y, pos.z, type);
                });
            }

            wait = 2;
            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Пример #53
0
        public override void Use(Player p, string message)
        {
            Level foundLevel;

            foundLevel = p.level;
            if (foundLevel.guns == false)
            {
                Player.SendMessage(p, "Guns and missiles cannot be used on this map!");
                return;
            }
            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 (p.allowTnt == false)
            {
                if (message.ToLower() == "explode")
                {
                    Player.SendMessage(p, Server.DefaultColor + "Since tnt usage is disallowed at the moment, switching to normal gun!"); cpos.ending = 1;
                }
                else if (message.ToLower() == "laser")
                {
                    Player.SendMessage(p, Server.DefaultColor + "Since tnt usage is disallowed at the moment, switching to normal gun!"); cpos.ending = 1;
                }
                else if (message.ToLower() == "teleport" || message.ToLower() == "tp")
                {
                    cpos.ending = -1;
                }
                else if (message != "")
                {
                    Help(p); return;
                }
            }


            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();
        }
Пример #54
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)
            {
                if (p.canBuild == true)        //Checks if player can build there
                {
                    switch (message.ToLower()) //If true - they can delete the zone
                    {
                    case "del":
                        p.zoneDel = true;
                        Player.SendMessage(p, "Place a block where you would like to delete a zone.");
                        return;

                    default:
                        Help(p);
                        return;
                    }
                }
                else //if they cant, it warns them, the ops and logs it on the server!
                {
                    Player.SendMessage(p, "You can't delete a zone which is above your rank!");
                    Player.GlobalMessageOps(p.name + " tried to delete a zone that is above their rank!");
                    Server.s.Log(p.name + " tried to delete a zone that is above their rank!");
                    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);
        }
Пример #55
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);
            }
        }
Пример #56
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);
            }
        }
Пример #57
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            System.Timers.Timer megaTimer = new System.Timers.Timer(1);

            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;
            }

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

            Player.SendMessage(p, buffer.Count.ToString() + " blocks.");
            Player.SendMessage(p, "Use /abort to cancel the megaboid at any time.");
            p.megaBoid = true;
            Pos   pos; int CurrentLoop = 0;
            Level currentLevel = p.level;

            megaTimer.Start();
            megaTimer.Elapsed += delegate
            {
                if (p.megaBoid == true)
                {
                    pos = buffer[CurrentLoop];
                    try { currentLevel.Blockchange(pos.x, pos.y, pos.z, type); }
                    catch { }
                    CurrentLoop++;
                    if (CurrentLoop % 1000 == 0)
                    {
                        Player.SendMessage(p, CurrentLoop + " blocks down, " + (buffer.Count - CurrentLoop) + " to go.");
                    }
                    if (CurrentLoop >= buffer.Count)
                    {
                        Player.SendMessage(p, "Completed megaboid"); buffer.Clear(); p.megaBoid = false; megaTimer.Stop();
                    }
                }
                else
                {
                    megaTimer.Stop();
                }
            };

            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Пример #58
0
        public override void Use(Player theP, string message)
        {
            int number = message.Split(' ').Length;

            String[] param = message.Split(' ');

            if (number == 1)
            {
                if (String.Compare(param[0], "x", true) == 0)
                {
                    Command.all.Find("replaceall").Use(theP, "zombie air");
                    Player.SendMessage(theP, "&aAll zombies have been destroyed.");
                    return;
                }
            }

            if (number != 4)
            {
                Help(theP); return;
            }

            try
            {
                if (String.Compare(param[0], "r", true) == 0)
                {
                    isRandom = true;
                }
                else if (String.Compare(param[0], "d", true) == 0)
                {
                    isRandom = false;
                }
                else
                {
                    Player.SendMessage(theP, "Flag set must be 'r' or 'd'.");
                    return;
                }

                wavesNum    = Int32.Parse(param[1]);
                wavesLength = Int32.Parse(param[2]);
                zombiesNum  = Int32.Parse(param[3]);

                if (isRandom == false)
                {
                    CatchPos cpos;
                    cpos.x = 0;
                    cpos.y = 0;
                    cpos.z = 0;
                    theP.blockchangeObject = cpos;

                    Player.SendMessage(theP, "Place a block for center of zombie spawn.");
                    theP.ClearBlockchange();
                    theP.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                }
                else
                {
                    Thread t = new Thread(ZombieMob);
                    t.Start(theP);
                }
            }
            catch (FormatException)
            {
                Player.SendMessage(theP, "&4All parameters must be numbers!");
            }
        }
Пример #59
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();
        }
        public void AboutBlockchange(Player p, ushort x, ushort y, ushort z, ushort type)
        {
            if (!p.staticCommands)
            {
                p.ClearBlockchange();
            }
            ushort 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);
            }

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

            foreach (Blockchange bc in BlocksDB.blockchanges)
            {
                if (bc.level == p.level.name && bc.x == x && bc.y == y && bc.z == z)
                {
                    foundOne      = true;
                    Username      = bc.username;
                    TimePerformed = bc.timePerformed.ToString("HH:mm:ss (dd/MM/yy)");
                    BlockUsed     = Block.Name(bc.type);
                    Deleted       = bc.deleted;
                }
            }

            if (foundOne)
            {
                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);
            }
            else
            {
                List <Blockchange> 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].username;
                    TimePerformed = inCache[i].timePerformed.ToString("HH:mm:ss (dd/MM/yy)");
                    BlockUsed     = Block.Name(inCache[i].type);
                }

                if (foundOne)
                {
                    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.");
            }

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }