bool DoDrill(Player p, Vec3S32[] marks, object state, ExtBlock block) { ushort x = (ushort)marks[0].X, y = (ushort)marks[0].Y, z = (ushort)marks[0].Z; block = p.level.GetBlock(x, y, z); int dist = (ushort)state, numBlocks = (3 * 3) * dist; if (numBlocks > p.group.DrawLimit) { Player.Message(p, "You tried to drill " + numBlocks + " blocks."); Player.Message(p, "You cannot drill more than " + p.group.DrawLimit + "."); return(false); } int dx = 0, dz = 0; DirUtils.FourYaw(p.Rot.RotY, out dx, out dz); Level lvl = p.level; if (dx != 0) { for (int depth = 0; depth < dist; x += (ushort)dx, depth++) { if (x >= lvl.Width) { continue; } for (ushort yy = (ushort)(y - 1); yy <= (ushort)(y + 1); yy++) { for (ushort zz = (ushort)(z - 1); zz <= (ushort)(z + 1); zz++) { DoBlock(p, lvl, block, x, yy, zz); } } } } else { for (int depth = 0; depth < dist; z += (ushort)dz, depth++) { if (z >= lvl.Length) { break; } for (ushort yy = (ushort)(y - 1); yy <= (ushort)(y + 1); yy++) { for (ushort xx = (ushort)(x - 1); xx <= (ushort)(x + 1); xx++) { DoBlock(p, lvl, block, xx, yy, z); } } } } Player.Message(p, "Drilled " + numBlocks + " blocks."); return(true); }
bool DoDrill(Player p, Vec3S32[] marks, object state, byte type, byte extType) { ushort x = (ushort)marks[0].X, y = (ushort)marks[0].Y, z = (ushort)marks[0].Z; type = p.level.GetTile(x, y, z); extType = 0; if (type == Block.custom_block) { extType = p.level.GetExtTile(x, y, z); } int dist = (int)state, numBlocks = (3 * 3) * dist; if (numBlocks > p.group.maxBlocks) { Player.Message(p, "You tried to drill " + numBlocks + " blocks."); Player.Message(p, "You cannot drill more than " + p.group.maxBlocks + "."); return(false); } int dx = 0, dz = 0; DirUtils.FourYaw(p.rot[0], out dx, out dz); Level lvl = p.level; if (dx != 0) { for (int depth = 0; depth < dist; x += (ushort)dx, depth++) { if (x >= lvl.Width) { continue; } for (ushort yy = (ushort)(y - 1); yy <= (ushort)(y + 1); yy++) { for (ushort zz = (ushort)(z - 1); zz <= (ushort)(z + 1); zz++) { DoBlock(p, lvl, type, extType, x, yy, zz); } } } } else { for (int depth = 0; depth < dist; z += (ushort)dz, depth++) { if (z >= lvl.Length) { break; } for (ushort yy = (ushort)(y - 1); yy <= (ushort)(y + 1); yy++) { for (ushort xx = (ushort)(x - 1); xx <= (ushort)(x + 1); xx++) { DoBlock(p, lvl, type, extType, xx, yy, z); } } } } Player.Message(p, "Drilled " + numBlocks + " blocks."); return(true); }