public bool SpawnPortal() { bool success = false; bool CanFit = false; Map map = Map.Felucca; int count = 0; if (PortalItem != null) { return(true); } while (!CanFit) { int x = Utility.Random(0, 5072); int y = Utility.Random(0, 4072); int z = map.GetAverageZ(x, y); CanFit = map.CanSpawnMobile(new Point3D(x, y, z)); Region region = Region.Find(new Point3D(x, y, z), map); if (CanFit && !(region is HouseRegion || region is GuardedRegion)) { PortalEntrance = new Point3D(x, y, z); PortalItem = new PortalItem(DungeonEntrance, DungeonMap) { _PortalSerial = UID }; PortalItem.MoveToWorld(PortalEntrance, map); PortalItem2 = new PortalItem(PortalEntrance, map); PortalItem2.MoveToWorld(DungeonEntrance, DungeonMap); Anim1 = new FireElemental { CantWalk = true, Blessed = true, Direction = Direction.Mask, IgnoreMobiles = true, Name = "" }; Anim2 = new FireElemental { CantWalk = true, Blessed = true, Direction = Direction.Mask, IgnoreMobiles = true, Name = "a mysterious gate" }; Anim1.MoveToWorld(PortalEntrance, map); Anim2.MoveToWorld(PortalEntrance, map); success = true; } else { CanFit = false; } count++; if (count >= 10000) { break; } } return(success); }