protected virtual void FinishEffect(Point3D p, Map map, Mobile from) { from.RevealingAction(); int spawncount = GetSpawnCount(); int z = p.Z; //Ghost ship Z, should be 10 lower than the spawn Z int gsZ = z - 30; //Set to -30 so it spawns under the sea and then emerges up //Spawn Z, needs to be 10 higher than ghost ship Z so they get on top of the boat int spawnZ = z - 20; //Create the ghost ship here GhostShip gs = new GhostShip(); //Add treasure MetalChest tc = new MetalChest { ItemID = 0xE7C, LiftOverride = true }; TreasureMapChest.Fill(tc, 5); //Now declare an area the same size as the ship, to look for items that might block Point2D start = new Point2D(p.X - 10, p.Y - 7); //Starting location of the area Point2D end = new Point2D(p.X + 10, p.Y + 7); //Ending location of the area Rectangle2D rect = new Rectangle2D(start, end); //Declaring the entire area as a rectangle //Create a new list that will contain all items in the rectangle List <Item> list = new List <Item>(); IPooledEnumerable eable = map.GetItemsInBounds(rect); //Get all items in the rectangle foreach (Item item in eable) //Add all items in the rectangle to the list { list.Add(item); } eable.Free(); //While an item exists in the rectangle, move the spawnlocation of the boat/monsters while (list.Count > 0) { if (Utility.RandomDouble() < 0.5) { p.X += 1; } else { p.X -= 1; } if (Utility.RandomDouble() < 0.5) { p.Y += 1; } else { p.Y -= 1; } start = new Point2D(p.X - 10, p.Y - 7); end = new Point2D(p.X + 10, p.Y + 7); rect = new Rectangle2D(start, end); eable = map.GetItemsInBounds(rect); //Clear the list as we need to create a new one with the new location of the ship list.Clear(); foreach (Item item in eable) { list.Add(item); //Add the items (if any) in the new spawnlocation to the list } eable.Free(); } //No items blocking, move the ship to the world p.Z = gsZ; gs.MoveToWorld(p, map); //Move the treasure chest to the world p.Z = spawnZ + 2; p.X -= 9; tc.MoveToWorld(p, map); //Add the boat and all items inside the boat here gs.Itemlist.Add(gs); gs.Itemlist.Add(tc); //Add as many spawns as spawncount allows for (int i = 0; i < spawncount; ++i) { BaseCreature spawn; switch (Utility.Random(4)) { default: spawn = new LichLord(); break; case 1: spawn = new AncientLich(); break; case 2: spawn = new Lich(); break; case 3: spawn = new SkeletalCaptain(); break; } p.Z = spawnZ; Spawn(p, map, spawn); spawn.Combatant = from; //Add the spawn to the list "spawns", needed for the boat decay timer and emerge timer gs.Spawnlist.Add(spawn); } //Start the emerge timer, so the boat doesn't just appear instantly on top of the water new EmergeTimer(gs.Itemlist, gs.Spawnlist).Start(); Delete(); }
protected virtual void FinishEffect( Point3D p, Map map, Mobile from ) { from.RevealingAction(); int spawncount = GetSpawnCount(); int z = p.Z; //Ghost ship Z, should be 10 lower than the spawn Z int gsZ = z - 30; //Set to -30 so it spawns under the sea and then emerges up //Spawn Z, needs to be 10 higher than ghost ship Z so they get on top of the boat int spawnZ = z - 20; //Create the ghost ship here GhostShip gs = new GhostShip(); //Add treasure MetalChest tc = new MetalChest {ItemID = 0xE7C, LiftOverride = true}; TreasureMapChest.Fill(tc, 5); //Now declare an area the same size as the ship, to look for items that might block Point2D start = new Point2D( p.X - 10, p.Y - 7 ); //Starting location of the area Point2D end = new Point2D(p.X + 10, p.Y + 7); //Ending location of the area Rectangle2D rect = new Rectangle2D( start, end ); //Declaring the entire area as a rectangle //Create a new list that will contain all items in the rectangle List<Item> list = new List<Item>(); IPooledEnumerable eable = map.GetItemsInBounds(rect); //Get all items in the rectangle foreach (Item item in eable) //Add all items in the rectangle to the list list.Add(item); eable.Free(); //While an item exists in the rectangle, move the spawnlocation of the boat/monsters while (list.Count > 0 ) { if (Utility.RandomDouble() < 0.5 ) p.X += 1; else p.X -= 1; if (Utility.RandomDouble() < 0.5) p.Y += 1; else p.Y -= 1; start = new Point2D(p.X - 10, p.Y - 7); end = new Point2D(p.X + 10, p.Y + 7); rect = new Rectangle2D(start, end); eable = map.GetItemsInBounds(rect); //Clear the list as we need to create a new one with the new location of the ship list.Clear(); foreach (Item item in eable) list.Add(item); //Add the items (if any) in the new spawnlocation to the list eable.Free(); } //No items blocking, move the ship to the world p.Z = gsZ; gs.MoveToWorld(p, map); //Move the treasure chest to the world p.Z = spawnZ + 2; p.X -= 9; tc.MoveToWorld(p, map); //Add the boat and all items inside the boat here gs.Itemlist.Add(gs); gs.Itemlist.Add(tc); //Add as many spawns as spawncount allows for (int i = 0; i < spawncount; ++i) { BaseCreature spawn; switch (Utility.Random(4)) { default: spawn = new LichLord(); break; case 1: spawn = new AncientLich(); break; case 2: spawn = new Lich(); break; case 3: spawn = new SkeletalCaptain(); break; } p.Z = spawnZ; Spawn(p, map, spawn); spawn.Combatant = from; //Add the spawn to the list "spawns", needed for the boat decay timer and emerge timer gs.Spawnlist.Add(spawn); } //Start the emerge timer, so the boat doesn't just appear instantly on top of the water new EmergeTimer(gs.Itemlist, gs.Spawnlist).Start(); Delete(); }