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); }
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"); } }
public void ExitChange(Player p, ushort x, ushort y, ushort z, byte type) { p.ClearBlockchange(); byte b = p.level.GetTile(x, y, z); p.SendBlockchange(x, y, z, b); portalPos bp = (portalPos)p.blockchangeObject; foreach (portPos pos in bp.port) { DataTable Portals = MySQL.fillData("SELECT * FROM `Portals" + pos.portMapName + "` WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z); Portals.Dispose(); if (Portals.Rows.Count == 0) { MySQL.executeQuery("INSERT INTO `Portals" + pos.portMapName + "` (EntryX, EntryY, EntryZ, ExitMap, ExitX, ExitY, ExitZ) VALUES (" + (int)pos.x + ", " + (int)pos.y + ", " + (int)pos.z + ", '" + p.level.name + "', " + (int)x + ", " + (int)y + ", " + (int)z + ")"); } else { MySQL.executeQuery("UPDATE `Portals" + pos.portMapName + "` SET ExitMap='" + p.level.name + "', ExitX=" + (int)x + ", ExitY=" + (int)y + ", ExitZ=" + (int)z + " WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z); } //DB if (pos.portMapName == p.level.name) p.SendBlockchange(pos.x, pos.y, pos.z, bp.type); } Player.SendMessage(p, "&3Exit" + Server.DefaultColor + " block placed"); if (p.staticCommands) { bp.port.Clear(); p.blockchangeObject = bp; p.Blockchange += new Player.BlockchangeEventHandler(EntryChange); } }
public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type) { p.ClearBlockchange(); byte b = p.level.GetTile(x, y, z); p.SendBlockchange(x, y, z, b); CatchPos cpos = (CatchPos)p.blockchangeObject; unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } } List<Pos> buffer = new List<Pos>(); for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx) { for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy) { for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz) { if (p.level.GetTile(xx, yy, zz) == type) { BufferAdd(buffer, xx, yy, zz); } } } } if (buffer.Count > p.group.maxBlocks) { Player.SendMessage(p, "You tried to replace " + buffer.Count + " blocks."); Player.SendMessage(p, "You cannot replace more than " + p.group.maxBlocks + "."); return; } Player.SendMessage(p, buffer.Count.ToString() + " blocks."); buffer.ForEach(delegate(Pos pos) { p.level.Blockchange(p, pos.x, pos.y, pos.z, cpos.type2); //update block for everyone }); if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); }
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); }
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"); } }
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 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); }
public void AboutBlockchange(Player p, ushort x, ushort y, ushort z, byte type) { if (!p.staticCommands) p.ClearBlockchange(); byte b = p.level.GetTile(x, y, z); if (b == Block.Zero) { Player.SendMessage(p, "Invalid Block(" + x + "," + y + "," + z + ")!"); return; } p.SendBlockchange(x, y, z, b); string message = "Block (" + x + "," + y + "," + z + "): "; message += "&f" + b + " = " + Block.Name(b); Player.SendMessage(p, message + Server.DefaultColor + "."); message = p.level.foundInfo(x, y, z); if (message != "") Player.SendMessage(p, "Physics information: &a" + message); DataTable Blocks = MySQL.fillData("SELECT * FROM `Block" + p.level.name + "` WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z); string Username, TimePerformed, BlockUsed; bool Deleted, foundOne = false; for (int i = 0; i < Blocks.Rows.Count; i++) { foundOne = true; Username = Blocks.Rows[i]["Username"].ToString(); TimePerformed = DateTime.Parse(Blocks.Rows[i]["TimePerformed"].ToString()).ToString("yyyy-MM-dd HH:mm:ss"); BlockUsed = Block.Name((byte)Blocks.Rows[i]["Type"]).ToString(); Deleted = (bool)Blocks.Rows[i]["Deleted"]; if (!Deleted) Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed); else Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed); Player.SendMessage(p, "Date and time modified: &2" + TimePerformed); } List<Level.BlockPos> inCache = p.level.blockCache.FindAll(bP => bP.x == x && bP.y == y && bP.z == z); for (int i = 0; i < inCache.Count; i++) { foundOne = true; Deleted = inCache[i].deleted; Username = inCache[i].name; TimePerformed = inCache[i].TimePerformed.ToString("yyyy-MM-dd HH:mm:ss"); BlockUsed = Block.Name(inCache[i].type); if (!Deleted) Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed); else Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + Server.DefaultColor + ", using &3" + BlockUsed); Player.SendMessage(p, "Date and time modified: &2" + TimePerformed); } if (!foundOne) Player.SendMessage(p, "This block has not been modified since the map was cleared."); Blocks.Dispose(); GC.Collect(); GC.WaitForPendingFinalizers(); }
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); }
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 Blockchange1(Player p, ushort x, ushort y, ushort z, byte type) { try { p.ClearBlockchange(); CatchPos cpos = (CatchPos)p.blockchangeObject; if (cpos.type == Block.Zero) cpos.type = p.bindings[type]; byte oldType = p.level.GetTile(x, y, z); p.SendBlockchange(x, y, z, oldType); if (cpos.type == oldType) { Player.SendMessage(p, "Cannot fill the same time"); return; } if (!Block.canPlace(p, oldType) && !Block.BuildIn(oldType)) { Player.SendMessage(p, "Cannot fill that."); return; } byte[] mapBlocks = new byte[p.level.blocks.Length]; List<Pos> buffer = new List<Pos>(); p.level.blocks.CopyTo(mapBlocks, 0); fromWhere.Clear(); deep = 0; FloodFill(p, x, y, z, cpos.type, oldType, cpos.FillType, ref mapBlocks, ref buffer); int totalFill = fromWhere.Count; for (int i = 0; i < totalFill; i++) { totalFill = fromWhere.Count; Pos pos = fromWhere[i]; deep = 0; FloodFill(p, pos.x, pos.y, pos.z, cpos.type, oldType, cpos.FillType, ref mapBlocks, ref buffer); totalFill = fromWhere.Count; } fromWhere.Clear(); if (buffer.Count > p.group.maxBlocks) { Player.SendMessage(p, "You tried to fill " + buffer.Count + " blocks."); Player.SendMessage(p, "You cannot fill more than " + p.group.maxBlocks + "."); return; } foreach (Pos pos in buffer) { p.level.Blockchange(p, pos.x, pos.y, pos.z, cpos.type); } Player.SendMessage(p, "Filled " + buffer.Count + " blocks."); buffer.Clear(); if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); } catch (Exception e) { Server.ErrorLog(e); } }
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); }
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; }
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); } }
public override void Use(Player p, string message) { p.ClearBlockchange(); p.painting = false; p.BlockAction = 0; p.megaBoid = false; p.cmdTimer = false; p.staticCommands = false; p.deleteMode = false; p.ZoneCheck = false; p.modeType = 0; p.aiming = false; p.onTrain = false; Player.SendMessage(p, "Every toggle or action was aborted."); }
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); }
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); }
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); }
public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type) { p.ClearBlockchange(); byte b = p.level.GetTile(x, y, z); p.SendBlockchange(x, y, z, b); Player.UndoPos Pos1; //p.UndoBuffer.Clear(); p.CopyBuffer.ForEach(delegate(Player.CopyPos pos) { Pos1.x = (ushort)(Math.Abs(pos.x) + x); Pos1.y = (ushort)(Math.Abs(pos.y) + y); Pos1.z = (ushort)(Math.Abs(pos.z) + z); if (pos.type != Block.air || p.copyAir) unchecked { if (p.level.GetTile(Pos1.x, Pos1.y, Pos1.z) != Block.Zero) p.level.Blockchange(p, (ushort)(Pos1.x + p.copyoffset[0]), (ushort)(Pos1.y + p.copyoffset[1]), (ushort)(Pos1.z + p.copyoffset[2]), pos.type); } }); Player.SendMessage(p, "Pasted " + p.CopyBuffer.Count + " blocks."); if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); }
public override void Use(Player p, string message) { CatchPos cpos; if (message != "") if (Block.Byte(message.ToLower()) == Block.Zero) { Player.SendMessage(p, "Cannot find block entered."); return; } if (message != "") { cpos.countOther = Block.Byte(message.ToLower()); } else { cpos.countOther = Block.Zero; } cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos; Player.SendMessage(p, "Place two blocks to determine the edges."); p.ClearBlockchange(); p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); }
public override void Use(Player p, string message) { int number = message.Split(' ').Length; if (number != 2) { Help(p); return; } int pos = message.IndexOf(' '); string t = message.Substring(0, pos).ToLower(); string t2 = message.Substring(pos + 1).ToLower(); byte type = Block.Byte(t); if (type == 255) { Player.SendMessage(p, "There is no block \"" + t + "\"."); return; } byte type2 = Block.Byte(t2); if (type2 == 255) { Player.SendMessage(p, "There is no block \"" + t2 + "\"."); return; } if (!Block.canPlace(p, type) && !Block.BuildIn(type)) { Player.SendMessage(p, "Cannot replace that."); return; } if (!Block.canPlace(p, type2)) { Player.SendMessage(p, "Cannot place that."); return; } CatchPos cpos; cpos.type2 = type2; cpos.type = type; cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos; Player.SendMessage(p, "Place two blocks to determine the edges."); p.ClearBlockchange(); p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); }
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); }
public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type) { if (!p.staticCommands) { p.ClearBlockchange(); p.aiming = false; } byte by = p.level.GetTile(x, y, z); p.SendBlockchange(x, y, z, by); Pos bp = (Pos)p.blockchangeObject; List<CatchPos> previous = new List<CatchPos>(); List<CatchPos> allBlocks = new List<CatchPos>(); CatchPos pos; if (p.modeType != Block.air) type = p.modeType; Thread gunThread = new Thread(new ThreadStart(delegate { ushort startX = (ushort)(p.pos[0] / 32); ushort startY = (ushort)(p.pos[1] / 32); ushort startZ = (ushort)(p.pos[2] / 32); pos.x = startX; pos.y = startY; pos.z = startZ; int total = 0; while (true) { startX = (ushort)(p.pos[0] / 32); startY = (ushort)(p.pos[1] / 32); startZ = (ushort)(p.pos[2] / 32); total++; 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); CatchPos lookedAt; int i; for (i = 1; true; i++) { lookedAt.x = (ushort)Math.Round(startX + (double)(a * i)); lookedAt.y = (ushort)Math.Round(startY + (double)(c * i)); lookedAt.z = (ushort)Math.Round(startZ + (double)(b * i)); by = p.level.GetTile(lookedAt.x, lookedAt.y, lookedAt.z); if (by == Block.Zero) break; if (by != Block.air && !allBlocks.Contains(lookedAt)) { if (p.level.physics < 2 || bp.ending <= 0) { break; } else { if (bp.ending == 1) { if ((!Block.LavaKill(by) && !Block.NeedRestart(by)) && by != Block.glass) { break; } } else if (p.level.physics >= 3) { if (by != Block.glass) { break; } } else { break; } } } bool comeInner = false; foreach (Player pl in Player.players) { if (pl.level == p.level && pl != p) { if ((ushort)(pl.pos[0] / 32) == lookedAt.x || (ushort)(pl.pos[0] / 32 + 1) == lookedAt.x || (ushort)(pl.pos[0] / 32 - 1) == lookedAt.x) { if ((ushort)(pl.pos[1] / 32) == lookedAt.y || (ushort)(pl.pos[1] / 32 + 1) == lookedAt.y || (ushort)(pl.pos[1] / 32 - 1) == lookedAt.y) { if ((ushort)(pl.pos[2] / 32) == lookedAt.z || (ushort)(pl.pos[2] / 32 + 1) == lookedAt.z || (ushort)(pl.pos[2] / 32 - 1) == lookedAt.z) { lookedAt.x = (ushort)(pl.pos[0] / 32); lookedAt.y = (ushort)(pl.pos[1] / 32); lookedAt.z = (ushort)(pl.pos[2] / 32); comeInner = true; break; } } } } } if (comeInner) break; } lookedAt.x = (ushort)Math.Round(startX + (double)(a * (i - 1))); lookedAt.y = (ushort)Math.Round(startY + (double)(c * (i - 1))); lookedAt.z = (ushort)Math.Round(startZ + (double)(b * (i - 1))); findNext(lookedAt, ref pos); by = p.level.GetTile(pos.x, pos.y, pos.z); if (total > 3) { if (by != Block.air && !allBlocks.Contains(pos)) { if (p.level.physics < 2 || bp.ending <= 0) { break; } else { if (bp.ending == 1) { if ((!Block.LavaKill(by) && !Block.NeedRestart(by)) && by != Block.glass) { break; } } else if (p.level.physics >= 3) { if (by != Block.glass) { p.level.MakeExplosion(pos.x, pos.y, pos.z, 1); break; } } else { break; } } } p.level.Blockchange(pos.x, pos.y, pos.z, type); previous.Add(pos); allBlocks.Add(pos); bool comeOut = false; foreach (Player pl in Player.players) { if (pl.level == p.level && pl != p) { if ((ushort)(pl.pos[0] / 32) == pos.x || (ushort)(pl.pos[0] / 32 + 1) == pos.x || (ushort)(pl.pos[0] / 32 - 1) == pos.x) { if ((ushort)(pl.pos[1] / 32) == pos.y || (ushort)(pl.pos[1] / 32 + 1) == pos.y || (ushort)(pl.pos[1] / 32 - 1) == pos.y) { if ((ushort)(pl.pos[2] / 32) == pos.z || (ushort)(pl.pos[2] / 32 + 1) == pos.z || (ushort)(pl.pos[2] / 32 - 1) == pos.z) { if (p.level.physics >= 3 && bp.ending >= 2) pl.HandleDeath(Block.stone, " was blown up by " + p.color + p.name, true); else pl.HandleDeath(Block.stone, " was hit a missile from " + p.color + p.name); comeOut = true; } } } } } if (comeOut) break; if (pos.x == lookedAt.x && pos.y == lookedAt.y && pos.z == lookedAt.z) { if (p.level.physics >= 3 && bp.ending >= 2) p.level.MakeExplosion(lookedAt.x, lookedAt.y, lookedAt.z, 2); break; } if (previous.Count > 12) { p.level.Blockchange(previous[0].x, previous[0].y, previous[0].z, Block.air); previous.Remove(previous[0]); } Thread.Sleep(100); } } foreach (CatchPos pos1 in previous) { p.level.Blockchange(pos1.x, pos1.y, pos1.z, Block.air); Thread.Sleep(100); } })); gunThread.Start(); }
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); }
public override void Use(Player p, string message) { Pos cpos; if (p.aiming) { if (message == "") { p.aiming = false; Player.SendMessage(p, "Disabled missiles"); return; } } cpos.ending = 0; if (message.ToLower() == "destroy") cpos.ending = 1; else if (message.ToLower() == "explode") cpos.ending = 2; else if (message.ToLower() == "teleport") 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("Missile mode engaged, fire and guide!"); 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(); }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } CatchPos cpos; cpos.message = ""; try { switch (message.Split(' ')[0]) { case "air": cpos.type = Block.MsgAir; break; case "water": cpos.type = Block.MsgWater; break; case "lava": cpos.type = Block.MsgLava; break; case "black": cpos.type = Block.MsgBlack; break; case "white": cpos.type = Block.MsgWhite; break; case "show": showMBs(p); return; default: cpos.type = Block.MsgWhite; cpos.message = message; break; } } catch { cpos.type = Block.MsgWhite; cpos.message = message; } if (cpos.message == "") cpos.message = message.Substring(message.IndexOf(' ') + 1); p.blockchangeObject = cpos; Player.SendMessage(p, "Place where you wish the message block to go."); p.ClearBlockchange(); p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); }
public override void Use(Player p, string message) { CatchPos cpos; int number = message.Split(' ').Length; if (number > 2) { Help(p); return; } if (number == 2) { int pos = message.IndexOf(' '); string t = message.Substring(0, pos).ToLower(); string s = message.Substring(pos + 1).ToLower(); cpos.type = Block.Byte(t); if (cpos.type == 255) { Player.SendMessage(p, "There is no block \"" + t + "\"."); return; } if (!Block.canPlace(p, cpos.type)) { Player.SendMessage(p, "Cannot place that."); return; } if (s == "up") cpos.FillType = 1; else if (s == "down") cpos.FillType = 2; else if (s == "layer") cpos.FillType = 3; else if (s == "vertical_x") cpos.FillType = 4; else if (s == "vertical_z") cpos.FillType = 5; else { Player.SendMessage(p, "Invalid fill type"); return; } } else if (message != "") { message = message.ToLower(); if (message == "up") { cpos.FillType = 1; cpos.type = Block.Zero; } else if (message == "down") { cpos.FillType = 2; cpos.type = Block.Zero; } else if (message == "layer") { cpos.FillType = 3; cpos.type = Block.Zero; } else if (message == "vertical_x") { cpos.FillType = 4; cpos.type = Block.Zero; } else if (message == "vertical_z") { cpos.FillType = 5; cpos.type = Block.Zero; } else { cpos.type = Block.Byte(message); if (cpos.type == (byte)255) { Player.SendMessage(p, "Invalid block or fill type"); return; } if (!Block.canPlace(p, cpos.type)) { Player.SendMessage(p, "Cannot place that."); return; } cpos.FillType = 0; } } else { cpos.type = Block.Zero; cpos.FillType = 0; } cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos; Player.SendMessage(p, "Destroy the block you wish to fill."); p.ClearBlockchange(); p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); }
public override void Use(Player p, string message) { CatchPos cpos; cpos.distance = 20; if (message != "") try { cpos.distance = int.Parse(message); } catch { Help(p); return; } cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos; Player.SendMessage(p, "Destroy the block you wish to drill."); p.ClearBlockchange(); p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); }
public override void Use(Player p, string message) { CatchPos cpos; cpos.x = 0; cpos.y = 0; cpos.z = 0; message = message.ToLower(); cpos.extraInfo = ""; if (message != "") { int currentLoop = 0; string[] storedArray; bool skip = false; retry: foreach (string s in message.Split(' ')) { if (currentLoop % 2 == 0) { switch (s) { case "drop": case "explode": case "dissipate": case "finite": case "wait": case "rainbow": break; case "revert": if (skip) break; storedArray = message.Split(' '); try { storedArray[currentLoop + 1] = Block.Byte(message.Split(' ')[currentLoop + 1].ToString().ToLower()).ToString(); if (storedArray[currentLoop + 1].ToString() == "255") throw new OverflowException(); } catch { Player.SendMessage(p, "Invalid block type."); return; } message = string.Join(" ", storedArray); skip = true; currentLoop = 0; goto retry; default: Player.SendMessage(p, s + " is not supported."); return; } } else { try { if (int.Parse(s) < 1) { Player.SendMessage(p, "Values must be above 0"); return; } } catch { Player.SendMessage(p, "/rp [text] [num] [text] [num]"); return; } } currentLoop++; } if (currentLoop % 2 != 1) cpos.extraInfo = message; else { Player.SendMessage(p, "Number of parameters must be even"); Help(p); return; } } p.blockchangeObject = cpos; Player.SendMessage(p, "Place two blocks to determine the edges."); p.ClearBlockchange(); p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); }