public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); m_Addictions = new List<AddictionTimer>(); int count = reader.ReadInt(); for (int i = 0; i < count; i++) { PlayerMobile addict = (PlayerMobile)reader.ReadMobile(); string addictionType = reader.ReadString(); AddictionTimer newTimer = new AddictionTimer(addict, addictionType); newTimer.Hunger = reader.ReadInt(); newTimer.HungerMax = reader.ReadInt(); newTimer.RecoveryCount = reader.ReadInt(); Addictions.Add(newTimer); newTimer.Start(); } if (m_Addictions.Count <= 0) Delete(); }
public static void AcquireAddiction(Mobile from, string type) { if (from == null || from.Deleted) return; if (type == null) return; if (!(from is PlayerMobile)) return; if (Utility.RandomMinMax(1, 100) > Utility.RandomMinMax(from.StamMax, from.StamMax * 2)) { XmlAddiction addAtt = XmlAttach.FindAttachment(from, typeof(XmlAddiction)) as XmlAddiction; if (addAtt == null) { addAtt = new XmlAddiction(); XmlAttach.AttachTo(from, addAtt); } AddictionTimer addTimer = new AddictionTimer(from as PlayerMobile, type); addAtt.Addictions.Add(addTimer); addTimer.Start(); } }