public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); if (Instances == null) { Instances = new List <BedrollSpawner>(); } Instances.Add(this); DateTime next = reader.ReadDateTime(); if (next < DateTime.UtcNow) { next = DateTime.UtcNow; } m_Timer = Timer.DelayCall(next - DateTime.UtcNow, RestartDelay, CheckRespawn); m_Timer.Start(); Bedrolls = new List <WrongBedrollBase>(); MysteriousTunnels = new List <MysteriousTunnel>(); int bedrollcount = reader.ReadInt(); for (int x = 0; x < bedrollcount; x++) { WrongBedrollBase wb = reader.ReadItem() as WrongBedrollBase; if (wb != null) { Bedrolls.Add(wb); } } int mysteriouscount = reader.ReadInt(); for (int y = 0; y < mysteriouscount; y++) { MysteriousTunnel mt = reader.ReadItem() as MysteriousTunnel; if (mt != null) { MysteriousTunnels.Add(mt); } } if (version == 0) { Timer.DelayCall(TimeSpan.FromSeconds(5), map => { EnchantedHotItem.SpawnChests(map); Console.WriteLine("Hot Item chests spawned for {0}.", Map); }, Map); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); if (Instances == null) { Instances = new List <BedrollSpawner>(); } Instances.Add(this); DateTime next = reader.ReadDateTime(); if (next < DateTime.UtcNow) { next = DateTime.UtcNow; } this.m_Timer = Timer.DelayCall(next - DateTime.UtcNow, RestartDelay, new TimerCallback(CheckRespawn)); this.m_Timer.Start(); Bedrolls = new List <WrongBedrollBase>(); MysteriousTunnels = new List <MysteriousTunnel>(); int bedrollcount = reader.ReadInt(); for (int x = 0; x < bedrollcount; x++) { WrongBedrollBase wb = reader.ReadItem() as WrongBedrollBase; if (wb != null) { Bedrolls.Add(wb); } } int mysteriouscount = reader.ReadInt(); for (int y = 0; y < mysteriouscount; y++) { MysteriousTunnel mt = reader.ReadItem() as MysteriousTunnel; if (mt != null) { MysteriousTunnels.Add(mt); } } }
private void CheckRespawn() { Cleanup(); // Bedrolls Spawn foreach (BedrollEntry entry in m_Entries) { WrongBedrollBase item = (WrongBedrollBase)Activator.CreateInstance(entry.Type); item.Movable = false; item.MoveToWorld(entry.Location, Map); Bedrolls.Add(item); } // Mysterious Tunnels Spawn MysteriousTunnel mt; WrongBedrollBase bedroll; int mtrandom; for (int i = 0; i < m_OutsideTunnels.Length; i++) { mt = new MysteriousTunnel(); if (i < 3) { mtrandom = Utility.Random(m_Entries.Length); mt.PointDest = Bedrolls[mtrandom].Location; Bedrolls[mtrandom].PointDest = m_OutsideTunnels[i]; Bedrolls[mtrandom].BedrollSpawner = this; } else { mt.PointDest = m_RoomDestinations[Utility.Random(m_RoomDestinations.Length)]; bedroll = Bedrolls.Where(x => x.InRange(mt.PointDest, 4) && x.PointDest == Point3D.Zero).FirstOrDefault(); if (bedroll != null) { bedroll.PointDest = m_OutsideTunnels[i]; bedroll.BedrollSpawner = this; } } mt.MoveToWorld(m_OutsideTunnels[i], Map); MysteriousTunnels.Add(mt); } }
public override void OnDoubleClick(Mobile from) { if (!from.InRange(GetWorldLocation(), 2)) { from.SendLocalizedMessage(500446); // That is too far away. return; } from.RevealingAction(); if (PointDest != Point3D.Zero) { MysteriousTunnel mt = new MysteriousTunnel(); Effects.PlaySound(from.Location, from.Map, 0x3BD); mt.PointDest = PointDest; mt.MoveToWorld(Location, Map); m_Spawner.MysteriousTunnels.Add(mt); } else { if (Utility.RandomDouble() < 0.5) { Point3D loc = GetWorldLocation(); Map facet = Map; SendMessageTo(from, 502999, 0x3B2); // You set off a trap! AOS.Damage(from, 40, 0, 100, 0, 0, 0); switch (Utility.Random(3)) { case 0: { Effects.SendLocationEffect(loc, facet, 0x36BD, 15, 10); Effects.PlaySound(loc, facet, 0x307); break; } case 1: { Effects.PlaySound(loc, Map, 0x307); Effects.SendLocationEffect(new Point3D(loc.X - 1, loc.Y, loc.Z), Map, 0x36BD, 15); Effects.SendLocationEffect(new Point3D(loc.X + 1, loc.Y, loc.Z), Map, 0x36BD, 15); Effects.SendLocationEffect(new Point3D(loc.X, loc.Y - 1, loc.Z), Map, 0x36BD, 15); Effects.SendLocationEffect(new Point3D(loc.X, loc.Y + 1, loc.Z), Map, 0x36BD, 15); Effects.SendLocationEffect(new Point3D(loc.X + 1, loc.Y + 1, loc.Z + 11), Map, 0x36BD, 15); break; } case 2: { Effects.SendLocationEffect(loc, facet, 0x113A, 10, 20); Effects.PlaySound(loc, facet, 0x231); break; } } } else { if (Utility.RandomDouble() < 0.01) { Item soap = new Soap(); Effects.PlaySound(from.Location, from.Map, 0x247); //powder if (Utility.RandomBool()) { from.AddToBackpack(soap); from.SendLocalizedMessage(1152268, string.Format("soap")); } else { soap.MoveToWorld(Location, Map); } } else { Effects.PlaySound(from.Location, from.Map, 0x3E3); //leather from.SendLocalizedMessage(1152212); //You tear the bedroll to pieces but find nothing. } } } Delete(); }