Example #1
0
        static bool CopyBlocks(Player p, Level other, ushort x, ushort y, ushort z, CatchPos cpos) {
            byte[] blocks = other.blocks;
            if (blocks.Length != p.level.blocks.Length) { 
                p.SendMessage("Cant restore selection of different size maps.");
                return false;
            }
            int width = other.Width, height = other.Length;

            if (p.level.bufferblocks && !p.level.Instant) {
                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)
                        for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                {
                    BlockQueue.Addblock(p, xx, yy, zz, blocks[xx + (zz * width) + (yy * width * height)]);
                }
            } else {
                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)
                        
                        for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                {
                    p.level.Blockchange(p, xx, yy, zz, blocks[xx + (zz * width) + (yy * width * height)]);
                }
            }
            return true;
        }
        public void Use(Player p, string[] args) {
            CatchPos cpos = new CatchPos();
            if (args.Length != 0) {
                cpos.ignore = new List<byte>();
                for (int i = 0; i < args.Length; i++) {
                    try {
                        cpos.ignore.Add(Block.NameToBlock(args[i]));
                    }
                    catch {
                        p.SendMessage("Could not find the block '" + args[i] + "'");
                        return;
                    }
                }
                string s = "";
                for (int i = 0; i < cpos.ignore.Count; i++) {
                    s += ((Block)cpos.ignore[i]).Name;
                    if (i == cpos.ignore.Count - 2) s += " and ";
                    else if (i != cpos.ignore.Count - 1) s += ", ";
                }
                p.SendMessage("Ignoring " + s + ".");
            }
            //else
            //cpos.ignore.Add(Block.NameToByte("unknown")); //So it doesn't ignore air.
            p.SendMessage("Place two blocks to determine the edges.");
            //p.CatchNextBlockchange(new Player.BlockChangeDelegate(CatchBlock), (object)cpos);
            p.SetDatapass("CmdMeasure_cpos", cpos);
            p.OnPlayerBlockChange.Normal += new BlockChangeEvent.EventHandler(CatchBlock);

        }
        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);
        }
Example #4
0
 public void Use(Player p, string[] args) {
     if (args.Length == 0) { p.SendMessage("Please specify a message to write!"); Help(p); return; }
     CatchPos cpos = new CatchPos();
     cpos.message = string.Join(" ", args);
     p.SetDatapass(Name, cpos);
     p.SendMessage("Place two blocks to determine the direction!");
     p.OnPlayerBlockChange.Normal += BlockChange1;
 }
Example #5
0
 public void CatchBlock(Player p, BlockChangeEventArgs args)
 {
     CatchPos cpos = new CatchPos();
     cpos.pos = new Vector3S(args.X, args.Z, args.Y);
     cpos.block = args.Holding;
     args.Cancel();
     p.OnPlayerBlockChange.Normal -= new Event<Player, BlockChangeEventArgs>.EventHandler(CatchBlock);
     p.SetDatapass(this.Name, cpos);
     p.OnPlayerBlockChange.Normal += new BlockChangeEvent.EventHandler(CatchBlock2);
 }
Example #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);
     bp = (CatchPos)p.blockchangeObject;
     thex = x; they = y + 2; thez = z; p.blockchangeObject = bp;
     Thread t = new Thread(ZombieMob);
     t.Start(p);
 }
        public void CatchBlock2(Player p, BlockChangeEventArgs args)
        {
            p.OnPlayerBlockChange.Normal -= new Event <Player, BlockChangeEventArgs> .EventHandler(CatchBlock2);

            CatchPos cpos = (CatchPos)p.GetDatapass(this.Name);

            cpos.secondPos = new Vector3S(args.X, args.Z, args.Y);
            cpos.block     = args.Holding;
            args.Cancel();
            Cuboid(cpos, p);
        }
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, ushort type)
        {
            p.ClearBlockchange();
            ushort 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 (cpos.oldType.Contains(p.level.GetTile(xx, yy, zz)))
                        {
                            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 + ".");
                wait = 1;
                return;
            }

            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, cpos.newType);                  //update block for everyone
                });
            }
            else
            {
                buffer.ForEach(delegate(Pos pos)
                {
                    p.level.Blockchange(p, pos.x, pos.y, pos.z, cpos.newType);                  //update block for everyone
                });
            }

            wait = 2;
            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Example #9
0
        public override void Use(Player p, string message)
        {
            CatchPos cpos = default(CatchPos);

            cpos.message        = message.ToLower();
            p.blockchangeObject = cpos;

            Player.SendMessage(p, "Place two blocks to determine the edges.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
        public void CatchBlock1(Player p, BlockChangeEventArgs args)
        {
            CatchPos cpos = (CatchPos)p.GetDatapass(this.Name);

            cpos.pos = new Vector3S(args.X, args.Z, args.Y);
            args.Cancel();
            p.OnPlayerBlockChange.Normal -= new Event <Player, BlockChangeEventArgs> .EventHandler(CatchBlock1);

            p.SetDatapass(this.Name, cpos);
            p.OnPlayerBlockChange.Normal += new BlockChangeEvent.EventHandler(CatchBlock2);
        }
Example #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);
            CatchPos bp = (CatchPos)p.blockchangeObject;

            bp.x           = x; bp.y = y; bp.z = z; p.blockchangeObject = bp;
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
        }
Example #12
0
 protected override void OnUse(Player p, string msg, string[] parts, ref CatchPos cpos) {
     if (parts.Length == 2 || parts.Length == 3) {
         string arg = parts[parts.Length - 1];
         ushort len;
         if (!ushort.TryParse(arg, out len)) {
             if (arg == "walls" || arg == "straight" || arg == "normal") return;                
             Player.SendMessage(p, msg + " is not valid length, assuming maximum length allowed.");
         } else {
             cpos.data = len;
         }
     } 
 }
Example #13
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);
        }
        //public void CatchBlock(Player p, ushort x, ushort z, ushort y, byte NewType, bool placed, object DataPass)
        public void CatchBlock(Player sender, BlockChangeEventArgs args)
        {
            args.Cancel();
            args.Unregister();
            sender.SendBlockChange(args.X, args.Z, args.Y, sender.Level.GetBlock(args.X, args.Z, args.Y));
            CatchPos cpos = (CatchPos)sender.GetDatapass("CmdMeasure_cpos");

            cpos.FirstBlock = new Vector3S(args.X, args.Z, args.Y);
            sender.SetDatapass("CmdMeasure_cpos", cpos);
            sender.OnPlayerBlockChange.Normal += new BlockChangeEvent.EventHandler(CatchBlock2);
            //p.CatchNextBlockchange(new Player.BlockChangeDelegate(CatchBlock2), (object)cpos);
        }
Example #15
0
        void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type, byte extType)
        {
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            RevertAndClearState(p, x, y, z);
            int       offX = p.copyoffset[0] + x, offY = p.copyoffset[1] + y, offZ = p.copyoffset[2] + z;
            CopyState state = p.CopyBuffer;

            if (state.X != state.OriginX)
            {
                offX -= (state.Width - 1);
            }
            if (state.Y != state.OriginY)
            {
                offY -= (state.Height - 1);
            }
            if (state.Z != state.OriginZ)
            {
                offZ -= (state.Length - 1);
            }

            DrawOp op;

            if (cpos.message == "")
            {
                op = new SimplePasteDrawOp();
                ((SimplePasteDrawOp)op).CopyState = p.CopyBuffer;
            }
            else
            {
                op = new PasteDrawOp();
                ((PasteDrawOp)op).CopyState = p.CopyBuffer;
                string[] args = cpos.message.Split(' ');
                if (args[0].CaselessEq("not"))
                {
                    ((PasteDrawOp)op).Exclude = ReplaceBrush.GetBlocks(p, 1, args.Length, args);
                }
                else
                {
                    ((PasteDrawOp)op).Include = ReplaceBrush.GetBlocks(p, 0, args.Length, args);
                }
            }

            if (!DrawOp.DoDrawOp(op, null, p, (ushort)offX, (ushort)offY, (ushort)offZ, 0, 0, 0))
            {
                return;
            }
            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Example #16
0
        protected override void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType)
        {
            RevertAndClearState(p, x, y, z);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            GetRealBlock(type, extType, p, ref cpos);
            DrawOp op = null;
            Func <BrushArgs, Brush> constructor = null;

            switch (cpos.mode)
            {
            case DrawMode.solid:
                op          = new CuboidDrawOp();
                constructor = SolidBrush.Process; break;

            case DrawMode.normal:
                op = new CuboidDrawOp(); break;

            case DrawMode.hollow:
                op = new CuboidHollowsDrawOp(); break;

            case DrawMode.walls:
                op = new CuboidWallsDrawOp(); break;

            case DrawMode.holes:
                op          = new CuboidDrawOp();
                constructor = CheckeredBrush.Process; break;

            case DrawMode.wire:
                op = new CuboidWireframeDrawOp(); break;

            case DrawMode.random:
                op          = new CuboidDrawOp();
                constructor = RandomBrush.Process; break;
            }

            int   brushOffset = cpos.mode == DrawMode.normal ? 0 : 1;
            Brush brush       = GetBrush(p, cpos, brushOffset, constructor);

            if (brush == null)
            {
                return;
            }
            if (!DrawOp.DoDrawOp(op, brush, p, cpos.x, cpos.y, cpos.z, x, y, z))
            {
                return;
            }
            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Example #17
0
        void BlockChange2(Player sender, BlockChangeEventArgs args)
        {
            //string direction = null;
            sender.OnPlayerBlockChange.Normal -= BlockChange2;
            CatchPos cpos = (CatchPos)sender.GetDatapass(this.Name);

            foreach (Vector3S v in BlockString(cpos.message, cpos.pos, new Vector3S(args.X, args.Z, args.Y), sender.Level.Size))
            {
                sender.Level.BlockChange(v, args.Holding, sender);
            }
            args.Cancel();
            return;
        }
Example #18
0
        void BlockChange2(Player sender, BlockChangeEventArgs args)
        {
            //string direction = null;
            sender.OnPlayerBlockChange.Normal -= BlockChange2;
            CatchPos cpos = (CatchPos)sender.GetDatapass(this.Name);

            foreach (Vector3S v in BlockString(cpos.message, cpos.pos, new Vector3S(args.X, args.Z, args.Y), sender.Level.CWMap.Size))
            {
                BlockQueue.Addblock(sender, (ushort)v.x, (ushort)v.y, (ushort)v.z, args.Holding);
            }
            args.Cancel();
            return;
        }
Example #19
0
        public void Blockchange3(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);

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


            p.copyoffset[0] = (p.copystart[0] - x);
            p.copyoffset[1] = (p.copystart[1] - y);
            p.copyoffset[2] = (p.copystart[2] - z);
        }
Example #20
0
        public void Use(Player p, string[] args)
        {
            if (args.Length == 0)
            {
                p.SendMessage("Please specify a message to write!"); Help(p); return;
            }
            CatchPos cpos = new CatchPos();

            cpos.message = string.Join(" ", args);
            p.SetDatapass(Name, cpos);
            p.SendMessage("Place two blocks to determine the direction!");
            p.OnPlayerBlockChange.Normal += BlockChange1;
        }
Example #21
0
 public override void Use(Player p, string message) {
     CatchPos cpos = default(CatchPos);
     if (p == null) { MessageInGameOnly(p); return; }
     if (message == "") { Player.SendMessage(p, "You need to provide a player name."); return; }
     
     string[] parts = message.Split(' ');
     cpos.message = parts[0];
     cpos.seconds = CmdUndo.GetSeconds(p, null, parts.Length > 1 ? parts[1] : "30");
     
     Player.SendMessage(p, "Place two blocks to determine the edges.");           
     p.ClearBlockchange();
     p.blockchangeObject = cpos;
     p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
 }
Example #22
0
        public override void Use(Player p, string message)
        {
            CatchPos cpos = default(CatchPos);

            if (message.Length > 0 && !int.TryParse(message, out cpos.randomizer))
            {
                Help(p); return;
            }

            Player.SendMessage(p, "Place two blocks to determine the edges.");
            p.ClearBlockchange();
            p.blockchangeObject = cpos;
            p.Blockchange      += new Player.BlockchangeEventHandler(Blockchange1);
        }
Example #23
0
        protected override void OnUse(Player p, string msg, string[] parts, ref CatchPos cpos)
        {
            if (parts.Length < 2 || cpos.mode == DrawMode.normal)
            {
                return;
            }
            string arg = parts[parts.Length - 1];
            ushort len;

            if (ushort.TryParse(arg, out len))
            {
                cpos.data = len;
            }
        }
Example #24
0
        protected override void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType)
        {
            RevertAndClearState(p, x, y, z);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            GetRealBlock(type, extType, p, ref cpos);

            if (cpos.mode == DrawMode.straight)
            {
                int dx = Math.Abs(cpos.x - x), dy = Math.Abs(cpos.y - y), dz = Math.Abs(cpos.z - z);

                if (dx > dy && dx > dz)
                {
                    y = cpos.y; z = cpos.z;
                }
                else if (dy > dx && dy > dz)
                {
                    x = cpos.x; z = cpos.z;
                }
                else if (dz > dy && dz > dx)
                {
                    y = cpos.y; x = cpos.x;
                }
            }

            LineDrawOp drawOp = new LineDrawOp();

            drawOp.WallsMode = cpos.mode == DrawMode.walls;
            int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1;

            if (cpos.data != null)
            {
                drawOp.MaxLength = (ushort)cpos.data; brushOffset++;
            }
            Brush brush = GetBrush(p, cpos, brushOffset);

            if (brush == null)
            {
                return;
            }

            if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z))
            {
                return;
            }
            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Example #25
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("'", "\\'");

            if (!Regex.IsMatch(cpos.message.ToLower(), @"^[a-z0-9]*?$"))
            {
                Player.SendMessage(p, "That is not allowed");
                return;
            }

            DataTable Messages = Server.useMySQL ? MySQL.fillData("SELECT * FROM `Messages" + p.level.name + "` WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z) : SQLite.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)
            {
                if (Server.useMySQL)
                {
                    MySQL.executeQuery("INSERT INTO `Messages" + p.level.name + "` (X, Y, Z, Message) VALUES (" + (int)x + ", " + (int)y + ", " + (int)z + ", '" + cpos.message + "')");
                }
                else
                {
                    SQLite.executeQuery("INSERT INTO `Messages" + p.level.name + "` (X, Y, Z, Message) VALUES (" + (int)x + ", " + (int)y + ", " + (int)z + ", '" + cpos.message + "')");
                }
            }
            else
            {
                if (Server.useMySQL)
                {
                    MySQL.executeQuery("UPDATE `Messages" + p.level.name + "` SET Message='" + cpos.message + "' WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);
                }
                else
                {
                    SQLite.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);
            }
        }
Example #26
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);

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

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

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

            if (buffer.Count > p.maxblocsbuild())
            {
                Player.SendMessage(p, "Vous essayez de remplacer " + buffer.Count + " blocs.");
                Player.SendMessage(p, "Vous ne pouvez pas remplacer plus de " + p.maxblocsbuild() + "blocs.");
                return;
            }

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

            buffer.Clear();

            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Example #27
0
        public override void Use(Player p, string message)
        {
            if (p.CopyBuffer == null)
            {
                Player.SendMessage(p, "You haven't copied anything yet"); return;
            }

            CatchPos cpos = default(CatchPos);

            cpos.message        = message;
            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);
        }
Example #28
0
        public override void Use(Player p, string message)
        {
            CatchPos cpos = default(CatchPos);

            message = message.ToLower();
            if (message != "" && !ParseArgs(p, message, ref cpos))
            {
                return;
            }

            p.blockchangeObject = cpos;
            Player.SendMessage(p, "Place two blocks to determine the edges.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Example #29
0
        public void Use(Player p, string[] args)
        {
            main = new CatchPos();
            main.block = 255;
            main.cuboidType = SolidType.solid;
            switch (args.Length)
            {
                case -1:
                    p.SendMessage("Invalid block or type!");
                    return;
                case 0: // No arguments
                    break;
                case 1: // Block or Type ONLY
                    if (ValidSolidType(args[0]) || ValidBlockName(args[0]))
                        break;
                    goto case -1;
                case 2: // Block AND Type
                    if (ValidSolidType(args[0]) || ValidSolidType(args[1]))
                        if (ValidBlockName(args[0]) || ValidBlockName(args[1]))
                            break;
                    goto case -1;
                case 6: // Coordinates ONLY
                    main.block = 1;
                    ParseCoordinates(p, args);
                    return;
                case 7: //Coordinates with Block OR Type
                    if (ValidSolidType(args[6]) || ValidBlockName(args[6]))
                        ParseCoordinates(p, args);
                    else
                        goto case -1;
                    return;
                case 8: //Coordinates with Block AND Type
                    if (ValidSolidType(args[6]) || ValidSolidType(args[7]))
                        if (ValidBlockName(args[6]) || ValidBlockName(args[7]))
                        {
                            ParseCoordinates(p, args);
                            return;
                        }
                    goto case -1;
                default:
                    p.SendMessage("Invalid number of arguments!");
                    Help(p);
                    return;
            }

            p.SendMessage("Place two blocks to determine the corners.");
            p.OnPlayerBlockChange.Normal += new Event<Player, BlockChangeEventArgs>.EventHandler(CatchBlock1);
        }
Example #30
0
        public void Use(Player p, string[] args)
        {
            if (args.Length != 2)
            {
                p.SendMessage("Invalid number of arguments!");
                Help(p);
                return;
            }

            CatchPos cpos = new CatchPos();
            List<string> oldType;

            if (args[0].Contains(","))
                oldType = new List<string>(args[0].Split(','));
            else
                oldType = new List<string>() { args[0] };
            
            oldType = oldType.Distinct().ToList(); // Remove duplicates

            List<string> invalid = new List<string>(); //Check for invalid blocks
            foreach (string name in oldType)
                if (!Block.ValidBlockName(name))
                    invalid.Add(name);
            if (!Block.ValidBlockName(args[1]))
                invalid.Add(args[1]);
            if (invalid.Count > 0)
            {
                p.SendMessage(String.Format("Invalid block{0}: {1}", invalid.Count == 1 ? "" : "s", String.Join(", ", invalid)));
                return;
            }

            if (oldType.Contains(args[1]))
                oldType.Remove(args[1]);
            if (oldType.Count < 1)
            {
                p.SendMessage("Replacing a block with the same one would be pointless!");
                return;
            }

            cpos.oldType = new List<byte>();
            foreach (string name in oldType)
                cpos.oldType.Add(Block.NameToBlock(name));
            cpos.newType = Block.NameToBlock(args[1]);

            p.SendMessage("Place two blocks to determine the edges.");
            p.SetDatapass(this.Name, cpos);
            p.OnPlayerBlockChange.Normal += new Event<Player, BlockChangeEventArgs>.EventHandler(CatchBlock1);
        }
Example #31
0
        protected void ParseCoordinates(Player p, string[] coordinates)
        {
            CatchPos cpos = new CatchPos();

            try
            {
                cpos.pos       = new Vector3S(ushort.Parse(coordinates[0]), ushort.Parse(coordinates[1]), ushort.Parse(coordinates[2]));
                cpos.secondPos = new Vector3S(ushort.Parse(coordinates[3]), ushort.Parse(coordinates[4]), ushort.Parse(coordinates[5]));
            }
            catch
            {
                p.SendMessage("Invalid coordinates!");
                return;
            }
            Cuboid(cpos, p);
        }
Example #32
0
 void UndoOnlinePlayer(Player p, Player who, CatchPos cpos, ushort x, ushort y, ushort z) {
     if (p != who && who.group.Permission >= p.group.Permission) {
         MessageTooHighRank(p, "undo", false); return;
     }
     
     UndoOnlineDrawOp op = new UndoOnlineDrawOp();
     op.Start = DateTime.UtcNow.AddTicks(-cpos.seconds * TimeSpan.TicksPerSecond);
     op.who = who;
     DrawOp.DoDrawOp(op, null, p, cpos.x, cpos.y, cpos.z, x, y, z);
     
     Level saveLevel = op.saveLevel;
     Player.SendChatFrom(who, who.color + who.DisplayName + 
                         "%S's actions for the past &b" + cpos.seconds + " seconds were undone.", false);
     Server.s.Log(who.name + "'s actions for the past " + cpos.seconds + " seconds were undone.");
     if (saveLevel != null) saveLevel.Save(true);
 }
Example #33
0
        public override void Use(Player p, string message)
        {
            CatchPos cpos = default(CatchPos);

            cpos.dist = 20;

            if (message != "" && !int.TryParse(message, out cpos.dist))
            {
                Help(p); return;
            }

            p.blockchangeObject = cpos;
            Player.SendMessage(p, "Destroy the block you wish to drill.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Example #34
0
        void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType)
        {
            RevertAndClearState(p, x, y, z);
            CatchPos   cpos   = (CatchPos)p.blockchangeObject;
            List <int> buffer = new List <int>();

            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)
                {
                    for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                    {
                        int index = p.level.PosToInt(xx, yy, zz);
                        if (index >= 0 && p.level.blocks[index] != Block.air)
                        {
                            buffer.Add(index);
                        }
                    }
                }
            }

            if (cpos.extraInfo.Raw == 0)
            {
                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;
            }

            foreach (int index in buffer)
            {
                p.level.AddCheck(index, true, cpos.extraInfo);
            }
            Player.SendMessage(p, "Activated " + buffer.Count + " blocks.");
            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Example #35
0
        void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType)
        {
            RevertAndClearState(p, x, y, z);
            CatchPos   cpos   = (CatchPos)p.blockchangeObject;
            MazeDrawOp drawOp = new MazeDrawOp();

            drawOp.randomizer = cpos.randomizer;

            if (!DrawOp.DoDrawOp(drawOp, null, p, cpos.x, cpos.y, cpos.z, x, y, z))
            {
                return;
            }
            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Example #36
0
        void PlacedMark2(Player p, ushort x, ushort y, ushort z, byte type, byte extType)
        {
            RevertAndClearState(p, x, y, z);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            if (cpos.mode == 2)
            {
                ushort sx = Math.Min(cpos.x, x), ex = Math.Max(cpos.x, x);
                ushort sy = Math.Min(cpos.y, y), ey = Math.Max(cpos.y, y);
                ushort sz = Math.Min(cpos.z, z), ez = Math.Max(cpos.z, z);

                LavaSurvival.MapSettings settings = Server.lava.LoadMapSettings(p.level.name);
                settings.safeZone = new Vec3U16[] { new Vec3U16(sx, sy, sz), new Vec3U16(ex, ey, ez) };
                Server.lava.SaveMapSettings(settings);

                Player.Message(p, "Safe zone set! &b({0}, {1}, {2}) ({3}, {4}, {5})", sx, sy, sz, ex, ey, ez);
            }
        }
Example #37
0
        bool HandlesPlayers(Player p, CatchPos bp, Vec3U16 pos)
        {
            Player pl = GetPlayer(p, pos, true);

            if (pl == null)
            {
                return(false);
            }

            if (p.level.physics >= 3 && bp.ending >= EndType.Explode)
            {
                pl.HandleDeath(Block.stone, " was blown up by " + p.ColoredName, true);
            }
            else
            {
                pl.HandleDeath(Block.stone, " was shot by " + p.ColoredName);
            }
            return(true);
        }
Example #38
0
        protected override void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType)
        {
            RevertAndClearState(p, x, y, z);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            GetRealBlock(type, extType, p, ref cpos);
            DrawOp drawOp      = null;
            int    brushOffset = cpos.mode == DrawMode.normal ? 0 : 1;
            Brush  brush       = GetBrush(p, cpos, brushOffset);

            if (brush == null)
            {
                return;
            }

            if (y != cpos.y)
            {
                Player.SendMessage(p, "The two edges of the pyramid must be on the same level");
                return;
            }

            switch (cpos.mode)
            {
            case DrawMode.solid:
            case DrawMode.normal:
                drawOp = new PyramidSolidDrawOp(); break;

            case DrawMode.hollow:
                drawOp = new PyramidHollowDrawOp(); break;

            case DrawMode.reverse:
                drawOp = new PyramidReverseDrawOp(); break;
            }

            if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z))
            {
                return;
            }
            if (p.staticCommands)
            {
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
            }
        }
Example #39
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("'", "\\'");

            if (!Regex.IsMatch(cpos.message.ToLower(), @".*%([0-9]|[a-f]|[k-r])%([0-9]|[a-f]|[k-r])%([0-9]|[a-f]|[k-r])"))
            {
                if (Regex.IsMatch(cpos.message.ToLower(), @".*%([0-9]|[a-f]|[k-r])(.+?).*"))
                {
                    Regex           rg = new Regex(@"%([0-9]|[a-f]|[k-r])(.+?)");
                    MatchCollection mc = rg.Matches(cpos.message.ToLower());
                    if (mc.Count > 0)
                    {
                        Match           ma = mc[0];
                        GroupCollection gc = ma.Groups;
                        cpos.message.Replace("%" + gc[1].ToString().Substring(1), "&" + gc[1].ToString().Substring(1));
                    }
                }
            }
            //safe against SQL injections because no user input is given here
            DataTable Messages = Database.fillData("SELECT * FROM `Messages" + p.level.name + "` WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);

            Database.AddParams("@Message", cpos.message);
            if (Messages.Rows.Count == 0)
            {
                Database.executeQuery("INSERT INTO `Messages" + p.level.name + "` (X, Y, Z, Message) VALUES (" + (int)x + ", " + (int)y + ", " + (int)z + ", @Message)");
            }
            else
            {
                Database.executeQuery("UPDATE `Messages" + p.level.name + "` SET Message=@Message WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);
            }
            Messages.Dispose();
            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);
            }
        }
Example #40
0
 public void Use(Player p, string[] args)
 {
     //To-do
     //Broken types: Walls,
     //Hollows seems to make an error on GetBlock because of negative pos value >_>
     //Need testing for: Wire
     CatchPos cpos = new CatchPos();
     cpos.block = 255;
     ushort unused; //For the TryParse
     switch (args.Length) {
         case 0:
             Default(cpos);
             break;
         case 1: //Block or type only
             if (ValidSolidType(args[0]) || Block.ValidBlockName(args[0])) {
                 cpos = Parser(p, true, false, args, cpos);
                 break;
             }
             else {
                 p.SendMessage("Invalid block or type!");
                 return;
             }
         case 2: //Block and type
             if (ValidSolidType(args[0 | 1]) || Block.ValidBlockName(args[0 | 1])) {
                 cpos = Parser(p, false, false, args, cpos);
                 break;
             }
             else {
                 p.SendMessage("Invalid block or type!");
                 return;
             }
         case 6: //Coordinates
             Default(cpos);
             cpos.block = 1; //Silliness
             cpos = CoordinatesParse(p, args, cpos);
             p.SendMessage("Coordinates");
             Cuboid(cpos, cpos.block, p, (ushort)cpos.secondPos.x, (ushort)cpos.secondPos.y, (ushort)cpos.secondPos.z);
             return;
         case 7: //Coordinates and block or type
             if (ValidSolidType(args[7]) || Block.ValidBlockName(args[7])) {
                 cpos = Parser(p, true, true, args, cpos);
                 Cuboid(cpos, cpos.block, p, (ushort)cpos.secondPos.x, (ushort)cpos.secondPos.y, (ushort)cpos.secondPos.z);
                 return;
             }
             else {
                 p.SendMessage("Invalid block or type!");
                 return;
             }
         case 8: //Coordinates block and type
             if (ValidSolidType(args[7 | 8]) || Block.ValidBlockName(args[7 | 8])) {
                 CoordinatesParse(p, args, cpos);
                 cpos = Parser(p, false, true, args, cpos);
                 Cuboid(cpos, cpos.block, p, (ushort)cpos.secondPos.x, (ushort)cpos.secondPos.y, (ushort)cpos.secondPos.z);
                 return;
             }
             else {
                 p.SendMessage("Invalid block or type!");
                 return;
             }
         default:
             if (ushort.TryParse(args[0 | 1 | 2 | 3 | 4 | 5], out unused)) {
                 p.SendMessage("You need 6 coordinates for cuboid to work like that!");
                 return;
             }
             else
                 p.SendMessage("Invalid arguments!");
             Help(p);
             return;
     }
     p.SendMessage("Place two blocks to determine the corners.");
     p.OnPlayerBlockChange.Normal += new Event<Player, BlockChangeEventArgs>.EventHandler(CatchBlock);
 }
 public void findNext(CatchPos lookedAt, ref CatchPos pos)
Example #42
0
 private static int calculatehollow(Player p, CatchPos cpos)
 {
     int total = 0;
     int minx = Math.Min(cpos.x, p.pyramidx1);
     int maxx = Math.Max(cpos.x, p.pyramidx1) - 2;
     int minz = Math.Min(cpos.z, p.pyramidy1);
     int maxz = Math.Max(cpos.z, p.pyramidy1) - 2;
     for (int xx = minx; xx <= maxx; ++xx)
         for (int zz = minz; zz <= maxz; ++zz)
         {
             total += 1;
         }
     int finaltotal = 0;
     int totald2 = (int)Math.Sqrt(total);
     int xxx = 0;
     int zzz = 0;
     for (int i = 0; i < totald2 / 2; i++)
     {
         for (int xx = minx; xx <= maxx; ++xx)
             xxx += 1;
         for (int zz = minz; zz <= maxz; ++zz)
             zzz += 1;
         finaltotal += xxx * zzz;
         xxx = 0;
         zzz = 0;
         maxx -= 2;
         maxz -= 2;
     }
     finaltotal -= total;
     return finaltotal;
 }
Example #43
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);
        }
        public void Use(Player p, string[] args)
        {
            if (args.Length != 2)
            {
                p.SendMessage("Invalid number of arguments!");
                Help(p);
                return;
            }

            CatchPos cpos = new CatchPos();
            List<string> ignore;

            if (args[0].Contains(","))
                ignore = new List<string>(args[0].Split(','));
            else
                ignore = new List<string>() { args[0] };

            ignore = ignore.Distinct().ToList(); // Remove duplicates

            List<string> invalid = new List<string>(); //Check for invalid blocks
            foreach (string name in ignore)
                if (!Block.ValidBlockName(name))
                    invalid.Add(name);
            if (!Block.ValidBlockName(args[1]))
                invalid.Add(args[1]);
            if (invalid.Count > 0)
            {
                p.SendMessage(String.Format("Invalid block{0}: {1}", invalid.Count == 1 ? "" : "s", String.Join(", ", invalid)));
                return;
            }

            if (ignore.Contains(args[1]))
                ignore.Remove(args[1]);
            if (ignore.Count < 1)
                p.SendMessage("Next time, just use cuboid if you're not going to ignore anything!");

            cpos.ignore = new List<byte>();
            foreach (string name in ignore)
                cpos.ignore.Add(Block.NameToBlock(name));
            cpos.newType = Block.NameToBlock(args[1]);

            p.SendMessage("Place two blocks to determine the edges.");
            p.SetDatapass(this.Name, cpos);
            p.OnPlayerBlockChange.Normal += new Event<Player, BlockChangeEventArgs>.EventHandler(CatchBlock1);
        }
Example #45
0
        private void Cuboid(CatchPos cpos, byte NewType, Player p, ushort x, ushort y, ushort z)
        {
            List<Pos> buffer = new List<Pos>();
            ushort xx, zz, yy;
            if (cpos.block != 255) {
                NewType = cpos.block;
            }
            switch (cpos.cuboidType) {
                case SolidType.solid:
                    buffer.Capacity = Math.Max(Math.Abs(cpos.pos.x - x), 1) * Math.Max(Math.Abs(cpos.pos.z - z), 1) * Math.Max(Math.Abs(cpos.pos.y - y), 1);
                    for (xx = Math.Min((ushort)(cpos.pos.x), x); xx <= Math.Max((ushort)(cpos.pos.x), x); ++xx) {
                        for (zz = Math.Min((ushort)(cpos.pos.z), z); zz <= Math.Max((ushort)(cpos.pos.z), z); ++zz) {
                            for (yy = Math.Min((ushort)(cpos.pos.y), y); yy <= Math.Max((ushort)(cpos.pos.y), y); ++yy) {
                                Vector3S loop = new Vector3S(xx, zz, yy);
                                if (p.Level.GetBlock(loop) != NewType) {
                                    BufferAdd(buffer, xx, zz, yy);
                                }
                            }
                        }
                    }
                    break;
                case SolidType.hollow:
                    for (zz = Math.Min((ushort)cpos.pos.z, z); zz <= Math.Max(cpos.pos.z, y); ++zz)
                        for (yy = Math.Min((ushort)cpos.pos.z, z); yy <= Math.Max(cpos.pos.z, z); ++yy) {
                            if (p.Level.GetBlock(cpos.pos.x, yy, zz) != NewType) {
                                BufferAdd(buffer, (ushort)cpos.pos.x, yy, zz);
                            }
                            if (cpos.pos.x != x) {
                                if (p.Level.GetBlock(x, yy, zz) != NewType) {
                                    BufferAdd(buffer, x, yy, zz);
                                }
                            }
                        }
                    if (Math.Abs(cpos.pos.x - x) >= 2) {
                        for (xx = (ushort)(Math.Min(cpos.pos.x, x) + 1); xx <= Math.Max(cpos.pos.x, x) - 1; ++xx)
                            for (yy = Math.Min((ushort)cpos.pos.y, y); yy <= Math.Max((ushort)cpos.pos.y, y); ++yy) {
                                if (p.Level.GetBlock(xx, cpos.pos.z, yy) != NewType) {
                                    BufferAdd(buffer, xx, (ushort)cpos.pos.z, yy);
                                }
                                if (cpos.pos.z != z) {
                                    if (p.Level.GetBlock(xx, z, yy) != NewType) {
                                        BufferAdd(buffer, xx, z, yy);
                                    }
                                }
                            }
                        if (Math.Abs(cpos.pos.z - z) >= 2) {
                            for (xx = (ushort)(Math.Min(cpos.pos.x, x) + 1); xx <= Math.Max(cpos.pos.x, x) - 1; ++xx)
                                for (zz = (ushort)(Math.Min(cpos.pos.z, y) + 1); zz <= Math.Max(cpos.pos.z, y) - 1; ++zz) {
                                    if (p.Level.GetBlock(xx, zz, cpos.pos.y) != NewType) {
                                        BufferAdd(buffer, xx, zz, (ushort)cpos.pos.y);
                                    }
                                    if (cpos.pos.y != y) {
                                        if (p.Level.GetBlock(xx, zz, y) != NewType) {
                                            BufferAdd(buffer, xx, zz, y);
                                        }
                                    }
                                }
                        }
                    }
                    break;
                case SolidType.walls:
                    for (zz = Math.Min((ushort)cpos.pos.z, z); zz <= Math.Max(cpos.pos.z, z); ++zz)
                        for (yy = Math.Min((ushort)cpos.pos.y, y); yy <= Math.Max(cpos.pos.y, y); ++yy) {
                            if (p.Level.GetBlock(cpos.pos.x, zz, yy) != NewType) {
                                BufferAdd(buffer, (ushort)cpos.pos.x, zz, yy);
                            }
                            if (cpos.pos.x != x) {
                                if (p.Level.GetBlock(x, zz, yy) != NewType) {
                                    BufferAdd(buffer, x, zz, yy);
                                }
                            }
                        }
                    if (Math.Abs(cpos.pos.x - x) >= 2) {
                        if (Math.Abs(cpos.pos.y - y) >= 2) {
                            for (xx = (ushort)(Math.Min(cpos.pos.x, x) + 1); xx <= Math.Max(cpos.pos.x, x) - 1; ++xx)
                                for (zz = (ushort)(Math.Min(cpos.pos.z, z)); zz <= Math.Max(cpos.pos.z, z); ++zz) {
                                    if (p.Level.GetBlock(xx, zz, (ushort)cpos.pos.y) != NewType) {
                                        BufferAdd(buffer, xx, zz, (ushort)cpos.pos.y);
                                    }
                                    if (cpos.pos.y != y) {
                                        if (p.Level.GetBlock(xx, zz, y) != NewType) {
                                            BufferAdd(buffer, xx, zz, y);
                                        }
                                    }
                                }
                        }
                    }
                    break;
                case SolidType.holes:
                    bool Checked = true, startZ, startY;

                    for (xx = Math.Min((ushort)cpos.pos.x, x); xx <= Math.Max((ushort)cpos.pos.x, x); ++xx) {
                        startZ = Checked;
                        for (zz = Math.Min((ushort)cpos.pos.z, z); zz <= Math.Max((ushort)cpos.pos.z, z); ++zz) {
                            startY = Checked;
                            for (yy = Math.Min((ushort)cpos.pos.y, y); yy <= Math.Max((ushort)cpos.pos.y, y); ++yy) {
                                Checked = !Checked;
                                if (Checked && p.Level.GetBlock(xx, zz, yy) != NewType) {
                                    BufferAdd(buffer, xx, zz, yy);
                                }
                            } Checked = !startY;
                        } Checked = !startZ;
                    }
                    break;
                case SolidType.wire:
                    for (xx = Math.Min((ushort)cpos.pos.x, x); xx <= Math.Max(cpos.pos.x, x); ++xx) {
                        BufferAdd(buffer, xx, z, y);
                        BufferAdd(buffer, xx, (ushort)cpos.pos.z, y);
                        BufferAdd(buffer, xx, y, (ushort)cpos.pos.z);
                        BufferAdd(buffer, xx, (ushort)cpos.pos.z, (ushort)cpos.pos.y);
                    }
                    for (zz = Math.Min((ushort)cpos.pos.z, z); zz <= Math.Max(cpos.pos.z, z); ++zz) {
                        BufferAdd(buffer, x, zz, z);
                        BufferAdd(buffer, x, zz, (ushort)cpos.pos.y);
                        BufferAdd(buffer, (ushort)cpos.pos.x, zz, y);
                        BufferAdd(buffer, (ushort)cpos.pos.x, zz, (ushort)cpos.pos.y);
                    }
                    for (yy = Math.Min((ushort)cpos.pos.y, y); yy <= Math.Max(cpos.pos.y, y); ++yy) {
                        BufferAdd(buffer, x, y, zz);
                        BufferAdd(buffer, x, (ushort)cpos.pos.z, yy);
                        BufferAdd(buffer, (ushort)cpos.pos.x, z, yy);
                        BufferAdd(buffer, (ushort)cpos.pos.x, (ushort)cpos.pos.z, yy);
                    }
                    break;
                case SolidType.random:
                    Random rand = new Random();
                    for (xx = Math.Min((ushort)cpos.pos.x, x); xx <= Math.Max(cpos.pos.x, x); ++xx)
                        for (zz = Math.Min((ushort)cpos.pos.z, z); zz <= Math.Max(cpos.pos.z, z); ++zz)
                            for (yy = Math.Min((ushort)cpos.pos.y, y); yy <= Math.Max(cpos.pos.y, y); ++yy) {
                                if (rand.Next(1, 11) <= 5 && p.Level.GetBlock(xx, zz, yy) != NewType) {
                                    BufferAdd(buffer, xx, zz, yy);
                                }
                            }
                    break;
            }
            //Anti-tunneling permissions

            //Server force cuboid

            //Group Max Blocks permissions here
            //if(buffer.Count > p.group.maxBlocks)
            //{
            //p.SendMessage("You tried to cuboid + " buffer.Count + "blocks.");
            //p.SendMessage("You cannot cuboid more than " + p.group.maxBlocks + ".");
            //}

            //Silent pyramids == false

            //Level bufferblocks and level not instant

            //Level Blockqueue
            p.SendMessage(buffer.Count.ToString() + " blocks.");
            buffer.ForEach(delegate(Pos pos) {
                p.Level.BlockChange((ushort)(pos.pos.x), (ushort)(pos.pos.z), (ushort)(pos.pos.y), NewType);
            });
        }
Example #46
0
        public void Use(Player p, string[] args)
        {
            byte type = 0;
            byte type2 = 0;
            if (args.Length != 2) {
                p.SendMessage("Invalid arguments!");
                Help(p);
                return;
            }
            if (!Block.ValidBlockName(args[0 | 1])) {
                p.SendMessage("Could not find block specified");
            }

            //Block permissions here.
            CatchPos cpos = new CatchPos();
            cpos.type = type;
            cpos.type2 = type2;

            p.SendMessage("Place two blocks to determine the edges.");
            p.OnPlayerBlockChange.Normal += new BlockChangeEvent.EventHandler(CatchBlock);
            p.SetDatapass("CmdReplaceNot_cpos", cpos);
            //p.CatchNextBlockchange(new Player.BlockChangeDelegate(CatchBlock), (object)cpos);
        }
Example #47
0
 protected void ParseCoordinates(Player p, string[] coordinates)
 {
     CatchPos cpos = new CatchPos();
     try
     {
         cpos.pos = new Vector3S(ushort.Parse(coordinates[0]), ushort.Parse(coordinates[1]), ushort.Parse(coordinates[2]));
         cpos.secondPos = new Vector3S(ushort.Parse(coordinates[3]), ushort.Parse(coordinates[4]), ushort.Parse(coordinates[5]));
     }
     catch
     {
         p.SendMessage("Invalid coordinates!");
         return;
     }
     Cuboid(cpos, p);
 }
Example #48
0
 void FirstChange(Player p, BlockChangeEventArgs args)
 {
     CatchPos cpos = new CatchPos();
     cpos.pos = new Vector3(args.X, args.Z, args.Y);
     cpos.block = args.Holding;
     //args.Cancel();
     p.OnPlayerBlockChange.Normal -= FirstChange;
     p.setDatapass(this.Name, cpos);
 }
Example #49
0
        public void Use(Player p, string[] args)
        {
            byte type = 0;
            byte type2 = 0;
            if (args.Length != 2)
            {
                p.SendMessage("Invalid arguments!");
                Help(p);
                return;
            }
            try
            {
                type = Blocks.NameToByte(args[0]);
                type2 = Blocks.NameToByte(args[1]);
            }
            catch
            {
                p.SendMessage("Could not find block specified");
                return;
            }

            //Block permissions here.
            CatchPos cpos = new CatchPos();
            cpos.type = type;
            cpos.type2 = type2;

            p.SendMessage("Place two blocks to determine the edges.");
            p.CatchNextBlockchange(new Player.BlockChangeDelegate(CatchBlock), (object)cpos);
        }
Example #50
0
        public override void Use(Player p, string message)
        {
            int number = message.Split(' ').Length;
            CatchPos cpos = new CatchPos(); byte btype;
            if (number < 2) { Help(p); return; }

            btype = Block.Byte(message.Split(' ')[0]);
            if (btype == 255) { Player.SendMessage(p, message.Split(' ')[0] + " does not exist, please spell it correctly."); return; }

            cpos.type = btype;

            if (Block.Byte(message.Split(' ')[1]) == 255) { Player.SendMessage(p, message.Split(' ')[1] + " does not exist, please spell it correctly."); return; }

            cpos.type2 = Block.Byte(message.Split(' ')[1]);
            if (!Block.canPlace(p, cpos.type2)) { 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);
        }
Example #51
0
		public static void Volcano(Player p, ushort x, ushort y, ushort z, int height, int radius) {
			List<CatchPos> buffer = new List<CatchPos>();
			CatchPos temp = new CatchPos();
			for (short yy = 0; yy <= height; yy++)
				for (short zz = (short)-radius; zz <= radius; zz++)
					for (short xx = (short)-radius; xx <= radius; xx++)
			{
				int cx = (x + xx), cy = (y + yy), cz = (z + zz);
				int curHeight = height - yy;
				if (curHeight == 0)
					continue;
				double curRadius = radius * ((double)curHeight / (double)height);
				int dist = xx * xx + zz * zz;
				if (dist > curRadius * curRadius)
					continue;
				
				byte ctile = p.level.GetTile((ushort)cx, (ushort)cy, (ushort)cz);
				if (ctile == 0) {
					temp.x = (ushort)cx; temp.y = (ushort)cy; temp.z = (ushort)cz;
					bool layer = dist >= (curRadius - 1) * (curRadius - 1);
					temp.type = layer ? Block.grass : Block.lavastill;
					buffer.Add(temp);
				}
			}
			if (buffer.Count > p.group.maxBlocks) { Player.SendMessage(p, "You tried Valcanoing " + buffer.Count + " blocks, your limit is " + p.group.maxBlocks); buffer = null; return; }
			buffer.ForEach(delegate(CatchPos pos) { p.level.Blockchange(p, pos.x, pos.y, pos.z, pos.type); });
			buffer = null;
		}
Example #52
0
 public void Use(Player p, string[] args)
 {
     CatchPos cpos = new CatchPos();
     if (args.Length == 1)
     {
         try
         {
             cpos.ignore = Blocks.NameToByte(args[0]);
         }
         catch
         {
             p.SendMessage("Could not find block specified");
             return;
         }
         p.SendMessage("Ignoring " + args[0]);
     }
     else
         cpos.ignore = (byte)(Blocks.Types.zero); //So it doesn't ignore air.
     p.SendMessage("Place two blocks to determine the edges.");
     p.CatchNextBlockchange(new Player.BlockChangeDelegate(CatchBlock), (object)cpos);
 }
Example #53
0
        public override void Use(Player p, string message)
        {
            wait = 0;
            string[] args = message.Split(' ');
            if (args.Length != 2) { p.SendMessage("Invalid number of arguments!"); Help(p); wait = 1; return; }

            CatchPos cpos = new CatchPos();
            List<string> ignore;

            if (args[0].Contains(","))
                ignore = new List<string>(args[0].Split(','));
            else
                ignore = new List<string>() { args[0] };

            ignore = ignore.Distinct().ToList(); // Remove duplicates

            List<string> invalid = new List<string>(); //Check for invalid blocks
            foreach (string name in ignore)
                if (Block.Byte(name) == 255)
                    invalid.Add(name);
            if (Block.Byte(args[1]) == 255)
                invalid.Add(args[1]);
            if (invalid.Count > 0)
            {
                p.SendMessage(String.Format("Invalid block{0}: {1}", invalid.Count == 1 ? "" : "s", String.Join(", ", invalid.ToArray())));
                return;
            }

            if (ignore.Contains(args[1]))
                ignore.Remove(args[1]);
            if (ignore.Count == 0)
                p.SendMessage("Next time just use cuboid if you're not going to ignore anything!");

            if (Block.Byte(message.Split(' ')[1]) == 255) { p.SendMessage(message.Split(' ')[1] + " does not exist, please spell it correctly."); wait = 1; return; }

            cpos.ignore = new List<byte>();
            foreach (string name in ignore)
                cpos.ignore.Add(Block.Byte(name));
            cpos.newType = Block.Byte(args[1]);

            if (!Block.canPlace(p, cpos.newType)) { p.SendMessage("Cannot place this block type!"); wait = 1; return; }

            p.blockchangeObject = cpos;
            Player.SendMessage(p, "Place two blocks to determine the edges.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Example #54
0
 protected CatchPos CoordinatesParse(Player p, string[] coordinates, CatchPos cpos)
 {
     short unused;
     if (!short.TryParse(coordinates[0 | 1 | 2 | 3 | 4 | 5], out unused)) {
         p.SendMessage("Invalid coordinates!");
     }
     else {
         cpos.pos.x = short.Parse(coordinates[0]);
         cpos.pos.z = short.Parse(coordinates[1]);
         cpos.pos.y = short.Parse(coordinates[2]);
         cpos.secondPos.x = short.Parse(coordinates[3]);
         cpos.secondPos.z = short.Parse(coordinates[4]);
         cpos.secondPos.y = short.Parse(coordinates[5]);
     }
     return cpos;
 }
Example #55
0
        public void findNext(CatchPos lookedAt, ref CatchPos pos)
        {
            int 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] = pos.x; pixel[1] = pos.y; pixel[2] = pos.z;
            dx = lookedAt.x - pos.x; dy = lookedAt.y - pos.y; dz = lookedAt.z - pos.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;

                pixel[0] += x_inc;
                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;

                pos.x = (ushort)pixel[0];
                pos.y = (ushort)pixel[1];
                pos.z = (ushort)pixel[2];
            }
            else if ((m >= l) && (m >= n))
            {
                err_1 = dx2 - m;
                err_2 = dz2 - m;

                pixel[1] += y_inc;
                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;

                pos.x = (ushort)pixel[0];
                pos.y = (ushort)pixel[1];
                pos.z = (ushort)pixel[2];
            }
            else
            {
                err_1 = dy2 - n;
                err_2 = dx2 - n;

                pixel[2] += z_inc;
                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;

                pos.x = (ushort)pixel[0];
                pos.y = (ushort)pixel[1];
                pos.z = (ushort)pixel[2];
            }
        }
Example #56
0
        private void Replace(CatchPos cpos, Player p)
        {
            List<Pos> buffer = new List<Pos>();
            ushort x, z, y;
            ushort xmin = Math.Min((ushort)cpos.pos.x, (ushort)cpos.pos2.x),
                xmax = Math.Max((ushort)cpos.pos.x, (ushort)cpos.pos2.x),
                zmin = Math.Min((ushort)cpos.pos.z, (ushort)cpos.pos2.z),
                zmax = Math.Max((ushort)cpos.pos.z, (ushort)cpos.pos2.z),
                ymin = Math.Min((ushort)cpos.pos.y, (ushort)cpos.pos2.y),
                ymax = Math.Max((ushort)cpos.pos.y, (ushort)cpos.pos2.y);

            for (x = xmin; x <= xmax; ++x)
                for (z = zmin; z <= zmax; ++z)
                    for (y = ymin; y <= ymax; ++y)
                        if (cpos.oldType.Contains(p.Level.GetBlock(x, z, y)))
                            BufferAdd(buffer, new Vector3S(x, z, y));

            p.SendMessage(buffer.Count.ToString() + " blocks.");
            buffer.ForEach(delegate(Pos pos)
            {
                BlockQueue.Addblock(p, (ushort)pos.pos.x, (ushort)pos.pos.y, (ushort)pos.pos.z, cpos.newType);
            });
        }
Example #57
0
        private void Cuboid(CatchPos cpos, Player p)
        {
            List<Pos> buffer = new List<Pos>();
            ushort x, z, y;
            ushort xmin = Math.Min((ushort)cpos.pos.x, (ushort)cpos.secondPos.x),
                xmax = Math.Max((ushort)cpos.pos.x, (ushort)cpos.secondPos.x),
                zmin = Math.Min((ushort)cpos.pos.z, (ushort)cpos.secondPos.z),
                zmax = Math.Max((ushort)cpos.pos.z, (ushort)cpos.secondPos.z),
                ymin = Math.Min((ushort)cpos.pos.y, (ushort)cpos.secondPos.y),
                ymax = Math.Max((ushort)cpos.pos.y, (ushort)cpos.secondPos.y);
            if (main.block != 255)
                cpos.block = main.block;
            switch (main.cuboidType)
            {
                case SolidType.solid:
                    for (x = xmin; x <= xmax; ++x)
                        for (z = zmin; z <= zmax; ++z)
                            for (y = ymin; y <= ymax; ++y)
                                if (p.Level.GetBlock(x, z, y) != cpos.block)
                                    BufferAdd(buffer, x, z, y);
                    break;
                case SolidType.hollow:
                    for (x = xmin; x <= xmax; ++x)
                        for (z = zmin; z <= zmax; ++z)
                            for (y = ymin; y <= ymax; ++y)
                                if (x == xmin || x == xmax || z == zmin || z == zmax || y == ymin || y == ymax)
                                    if (p.Level.GetBlock(x, z, y) != cpos.block)
                                        BufferAdd(buffer, x, z, y);
                    break;
                case SolidType.walls:
                    for (x = xmin; x <= xmax; ++x)
                        for (z = zmin; z <= zmax; ++z)
                            for (y = ymin; y <= ymax; ++y)
                                if (x == xmin || x == xmax || z == zmin || z == zmax)
                                    if (p.Level.GetBlock(x, z, y) != cpos.block)
                                        BufferAdd(buffer, x, z, y);
                    break;
                case SolidType.holes:
                    for (x = xmin; x <= xmax; ++x)
                        for (z = zmin; z <= zmax; ++z)
                            for (y = ymin; y <= ymax; ++y)
                                if ((x - xmin + z - zmin + y - ymin) % 2 == 0)
                                    if (p.Level.GetBlock(x, z, y) != cpos.block)
                                        BufferAdd(buffer, x, z, y);
                    break;
                case SolidType.wire:
                    for (x = xmin; x <= xmax; ++x)
                    {
                        BufferAdd(buffer, x, zmin, ymin);
                        BufferAdd(buffer, x, zmin, ymax);
                        BufferAdd(buffer, x, zmax, ymin);
                        BufferAdd(buffer, x, zmax, ymax);
                    }
                    for (z = zmin; z <= zmax; ++z)
                    {
                        BufferAdd(buffer, xmin, z, ymin);
                        BufferAdd(buffer, xmin, z, ymax);
                        BufferAdd(buffer, xmax, z, ymin);
                        BufferAdd(buffer, xmax, z, ymax);
                    }
                    for (y = ymin; y <= ymax; ++y)
                    {
                        BufferAdd(buffer, xmin, zmin, y);
                        BufferAdd(buffer, xmin, zmax, y);
                        BufferAdd(buffer, xmax, zmin, y);
                        BufferAdd(buffer, xmax, zmax, y);
                    }
                    break;
                case SolidType.random:
                    Random rand = new Random();
                    for (x = xmin; x <= xmax; ++x)
                        for (z = zmin; z <= zmax; ++z)
                            for (y = ymin; y <= ymax; ++y)
                                if (rand.Next(1, 11) <= 5 && p.Level.GetBlock(x, z, y) != cpos.block)
                                    BufferAdd(buffer, x, z, y);
                    break;
            }
            //Anti-tunneling permissions

            //Server force cuboid

            //Group Max Blocks permissions here
            //if(buffer.Count > p.group.maxBlocks)
            //{
            //p.SendMessage("You tried to cuboid + " buffer.Count + "blocks.");
            //p.SendMessage("You cannot cuboid more than " + p.group.maxBlocks + ".");
            //}

            //Silent pyramids == false

            //Level bufferblocks and level not instant

            //Level Blockqueue
            p.SendMessage(buffer.Count.ToString() + " blocks.");
            buffer.ForEach(delegate(Pos pos)
            {
                p.Level.BlockChange((ushort)(pos.pos.x), (ushort)(pos.pos.z), (ushort)(pos.pos.y), cpos.block, p);
            });
        }
Example #58
0
 protected CatchPos Parser(Player p, bool one, bool coordinates, string[] args, CatchPos cpos)
 {
     ushort unused;
     if (one && !coordinates) {
         cpos.block = (Block.ValidBlockName(args[0]) ? Block.NameToBlock(args[0]) : (byte)255);
         cpos.cuboidType = (ValidSolidType(args[0]) ? StringToSolidType(args[0]) : SolidType.solid);
     }
     else if (coordinates && !one) {
         cpos = CoordinatesParse(p, args, cpos);
         cpos.block = (Block.ValidBlockName(args[6]) ? Block.NameToBlock(args[6]) : (Block.ValidBlockName(args[7]) ? Block.NameToBlock(args[7]) : (byte)255));
         cpos.cuboidType = (ValidSolidType(args[6]) ? StringToSolidType(args[6]) : ValidSolidType(args[7]) ? StringToSolidType(args[7]) : SolidType.solid);
     }
     else if (one && coordinates) {
         cpos = CoordinatesParse(p, args, cpos);
         cpos.block = (Block.ValidBlockName(args[7]) ? Block.NameToBlock(args[7]) : (byte)255);
         cpos.cuboidType = (ValidSolidType(args[7]) ? StringToSolidType(args[7]) : SolidType.solid);
     }
     else if (!coordinates && !one) {
         cpos.block = (Block.ValidBlockName(args[0]) ? Block.NameToBlock(args[0]) : (Block.ValidBlockName(args[1]) ? Block.NameToBlock(args[1]) : (byte)255));
         cpos.cuboidType = (ValidSolidType(args[0]) ? StringToSolidType(args[0]) : ValidSolidType(args[1]) ? StringToSolidType(args[1]) : SolidType.solid);
     }
     else if (!coordinates && (ushort.TryParse(args[0 | 1 | 2 | 3 | 4 | 5], out unused))) {
         p.SendMessage("You need 6 coordinates for cuboid to work like that!");
     }
     p.SendMessage("[Debug] Cpos.Block " + ((Block)cpos.block).Name + " Cpos.cuboidType " + cpos.cuboidType.ToString());
     return cpos;
 }
Example #59
0
 protected CatchPos Default(CatchPos cpos)
 {
     cpos.block = 255;
     cpos.cuboidType = SolidType.solid;
     return cpos;
 }
        public override void Use(Player p, string message)
        {
            wait = 0;
            string[] args = message.Split(' ');
            if (args.Length != 2)
            {
                p.SendMessage("Invail number of arguments!");
                wait = 1;
                Help(p);
                return;
            }

            CatchPos cpos = new CatchPos();
            List<string> oldType;

            oldType = new List<string>(args[0].Split(','));

            oldType = oldType.Distinct().ToList(); // Remove duplicates

            List<string> invalid = new List<string>(); //Check for invalid blocks
            foreach (string name in oldType)
                if (Block.Ushort(name) == Block.maxblocks)
                    invalid.Add(name);
            if (Block.Ushort(args[1]) == Block.maxblocks)
                invalid.Add(args[1]);
            if (invalid.Count > 0)
            {
                p.SendMessage(String.Format("Invalid block{0}: {1}", invalid.Count == 1 ? "" : "s", String.Join(", ", invalid.ToArray())));
                wait = 1;
                return;
            }

            if (oldType.Contains(args[1]))
                oldType.Remove(args[1]);
            if (oldType.Count < 1)
            {
                p.SendMessage("Replacing a block with the same one would be pointless!");
                return;
            }

            cpos.oldType = new List<ushort>();
            foreach (string name in oldType)
                cpos.oldType.Add(Block.Ushort(name));
            cpos.newType = Block.Ushort(args[1]);

            foreach (byte type in cpos.oldType)
                if (!Block.canPlace(p, type) && !Block.BuildIn(type)) { p.SendMessage("Cannot replace that."); wait = 1; return; }
            if (!Block.canPlace(p, cpos.newType)) { p.SendMessage("Cannot place that."); wait = 1; return; }

            p.blockchangeObject = cpos;
            Player.SendMessage(p, "Place two blocks to determine the edges.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }