Esempio n. 1
0
        private static void OnLoad()
        {
            if (!File.Exists(Path.Combine(SavePath, SaveFile)))
            {
                return;
            }

            using (FileStream bin = new FileStream(Path.Combine(SavePath, SaveFile), FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                GenericReader reader = new BinaryFileReader(new BinaryReader(bin));

                m_LastResetTime = reader.ReadDateTime();

                int count = reader.ReadInt();

                for (int i = 0; i < count; ++i)
                {
                    Mobile mobile = reader.ReadMobile();

                    MobileRateInfo info = new MobileRateInfo();

                    info.Deserialize(reader);

                    if (mobile != null)
                    {
                        MobileRateInfo.Entries.Add(mobile, info);
                    }
                }
            }
        }
Esempio n. 2
0
        public static bool ForceSkillGain(Mobile from, Skill skill)
        {
            if (from.Player)
            {
                MobileRateInfo mobileInfo = MobileRateInfo.GetMobileInfo(from);
                SkillRateInfo  skillInfo  = mobileInfo.GetSkillInfo(skill);

                int[] table = null;

                if (from.Skills.Total <= 350)
                {
                    table = m_Terms350;
                }
                else if (from.Skills.Total <= 500)
                {
                    table = m_Terms500;
                }
                else
                {
                    table = m_Terms700;
                }

                int index = skill.BaseFixedPoint / 50;

                if (DateTime.Now - skillInfo.LastGainTime < TimeSpan.FromMinutes(table[index > 23 ? 23 : index]))
                {
                    return(false);
                }

                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        public static void RegisterStatGain(Mobile from)
        {
            if (from.Player)
            {
                MobileRateInfo mobileInfo = MobileRateInfo.GetMobileInfo(from);

                mobileInfo.LastStatGainTime = DateTime.Now;
                mobileInfo.StatGainsCount++;
            }
        }
Esempio n. 4
0
        public static void RegisterSkillGain(Mobile from, Skill skill)
        {
            if (from.Player)
            {
                MobileRateInfo mobileInfo = MobileRateInfo.GetMobileInfo(from);
                SkillRateInfo  skillInfo  = mobileInfo.GetSkillInfo(skill);

                skillInfo.LastGainTime = DateTime.Now;
            }
        }
Esempio n. 5
0
            public static MobileRateInfo GetMobileInfo(Mobile from)
            {
                MobileRateInfo info = null;

                if (!Entries.TryGetValue(from, out info))
                {
                    info = new MobileRateInfo();

                    Entries.Add(from, info);
                }

                return(info);
            }
Esempio n. 6
0
        public static bool ForceStatGain(Mobile from)
        {
            if (from.Player)
            {
                MobileRateInfo mobileInfo = MobileRateInfo.GetMobileInfo(from);

                if (mobileInfo.StatGainsCount < 10 && DateTime.Now - mobileInfo.LastStatGainTime > TimeSpan.FromMinutes(15))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 7
0
        public static bool StatGainAllowed(Mobile from)
        {
            if (from.Player)
            {
                MobileRateInfo info = MobileRateInfo.GetMobileInfo(from);

                // STAT GAIN RESTRICTIONS
                // Here you can edit restrictions suitable for your needs
                if (info.StatGainsCount < 8)
                // END!
                {
                    info.StatGainsCount++;
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 8
0
        public static bool SkillGainAllowed(Mobile from, Skill skill)
        {
            if (from.Player)
            {
                MobileRateInfo mobileInfo = MobileRateInfo.GetMobileInfo(from);
                SkillRateInfo  skillInfo  = mobileInfo.GetSkillInfo(skill);

                // SKILL GAIN RESTRICTIONS
                // Here you can edit restrictions suitable for your needs
                if (skill.Base >= 100.0 && (mobileInfo.SkillGainsCount >= 72 || DateTime.Now - skillInfo.LastGainTime < TimeSpan.FromMinutes(5.0)))
                {
                    return(false);
                }
                if (skill.Base >= 90.0 && (mobileInfo.SkillGainsCount >= 30 || DateTime.Now - skillInfo.LastGainTime < TimeSpan.FromMinutes(10.0)))
                {
                    return(false);
                }
                else if (skill.Base >= 80.0 && (mobileInfo.SkillGainsCount >= 60 || DateTime.Now - skillInfo.LastGainTime < TimeSpan.FromMinutes(5.0)))
                {
                    return(false);
                }
                else if (skill.Base >= 70.0 && (mobileInfo.SkillGainsCount >= 100 || DateTime.Now - skillInfo.LastGainTime < TimeSpan.FromMinutes(3.0)))
                {
                    return(false);
                }
                else if (skill.Base < 70.0)
                {
                    return(true);
                }
                // End!

                mobileInfo.SkillGainsCount++;

                skillInfo.LastGainTime = DateTime.Now;
                skillInfo.GainsCount++;
            }

            return(true);
        }
Esempio n. 9
0
        private static void OnSave(WorldSaveEventArgs args)
        {
            if (!Directory.Exists(SavePath))
            {
                Directory.CreateDirectory(SavePath);
            }

            GenericWriter writer = new BinaryFileWriter(Path.Combine(SavePath, SaveFile), true);

            writer.Write(m_LastResetTime);

            writer.Write(MobileRateInfo.Entries.Count);

            foreach (KeyValuePair <Mobile, MobileRateInfo> kvp in MobileRateInfo.Entries)
            {
                writer.Write((Mobile)kvp.Key);

                MobileRateInfo info = (MobileRateInfo)kvp.Value;

                info.Serialize(writer);
            }

            writer.Close();
        }
			public static MobileRateInfo GetMobileInfo( Mobile from )
			{
				MobileRateInfo info = null;

				if ( !Entries.TryGetValue( from, out info ) )
				{
					info = new MobileRateInfo();

					Entries.Add( from, info );
				}

				return info;
			}
		private static void OnLoad()
		{
			if ( !File.Exists( Path.Combine( SavePath, SaveFile ) ) )
			{
				return;
			}

			using ( FileStream bin = new FileStream( Path.Combine( SavePath, SaveFile ), FileMode.Open, FileAccess.Read, FileShare.Read ) )
			{
				GenericReader reader = new BinaryFileReader( new BinaryReader( bin ) );

				m_LastResetTime = reader.ReadDateTime();

				int count = reader.ReadInt();

				for ( int i = 0; i < count; ++i )
				{
					Mobile mobile = reader.ReadMobile();

					MobileRateInfo info = new MobileRateInfo();

					info.Deserialize( reader );

					if ( mobile != null )
					{
						MobileRateInfo.Entries.Add( mobile, info );
					}
				}
			}
		}