public static void Gain(Mobile from, Skill skill) { if (from.Region.IsPartOf <Jail>()) { return; } if (from is BaseCreature && ((BaseCreature)from).IsDeadPet) { return; } if (skill.SkillName == SkillName.Focus && from is BaseCreature && (!PetTrainingHelper.Enabled || !((BaseCreature)from).Controlled)) { return; } if (skill.Base < skill.Cap && skill.Lock == SkillLock.Up) { var toGain = 1; var skills = from.Skills; if (from is PlayerMobile && Siege.SiegeShard) { var minsPerGain = Siege.MinutesPerGain(from, skill); if (minsPerGain > 0) { if (Siege.CheckSkillGain((PlayerMobile)from, minsPerGain, skill)) { CheckReduceSkill(skills, toGain, skill); if (skills.Total + toGain <= skills.Cap) { skill.BaseFixedPoint += toGain; } } return; } } if (skill.Base <= 10.0) { toGain = Utility.Random(4) + 1; } #region Mondain's Legacy if (from is PlayerMobile && QuestHelper.EnhancedSkill((PlayerMobile)from, skill)) { toGain *= Utility.RandomMinMax(2, 4); } #endregion #region Scroll of Alacrity if (from is PlayerMobile && skill.SkillName == ((PlayerMobile)from).AcceleratedSkill && ((PlayerMobile)from).AcceleratedStart > DateTime.UtcNow) { // You are infused with intense energy. You are under the effects of an accelerated skillgain scroll. ((PlayerMobile)from).SendLocalizedMessage(1077956); toGain = Utility.RandomMinMax(2, 5); } #endregion #region Skill Masteries else if (from is BaseCreature && !(from is Server.Engines.Despise.DespiseCreature) && (((BaseCreature)from).Controlled || ((BaseCreature)from).Summoned)) { var master = ((BaseCreature)from).GetMaster(); if (master != null) { var spell = SkillMasterySpell.GetSpell(master, typeof(WhisperingSpell)) as WhisperingSpell; if (spell != null && master.InRange(from.Location, spell.PartyRange) && master.Map == from.Map && spell.EnhancedGainChance >= Utility.Random(100)) { toGain = Utility.RandomMinMax(2, 5); } } } #endregion if (from is PlayerMobile) { CheckReduceSkill(skills, toGain, skill); } if (!from.Player || (skills.Total + toGain <= skills.Cap)) { skill.BaseFixedPoint = Math.Min(skill.CapFixedPoint, skill.BaseFixedPoint + toGain); EventSink.InvokeSkillGain(new SkillGainEventArgs(from, skill, toGain)); if (from is PlayerMobile) { UpdateGGS(from, skill); } } } #region Mondain's Legacy if (from is PlayerMobile) { QuestHelper.CheckSkill((PlayerMobile)from, skill); } #endregion if (skill.Lock == SkillLock.Up && (!Siege.SiegeShard || !(from is PlayerMobile) || Siege.CanGainStat((PlayerMobile)from))) { var info = skill.Info; // Old gain mechanic if (!Core.ML) { var scalar = 1.0; if (from.StrLock == StatLockType.Up && (info.StrGain / 33.3) * scalar > Utility.RandomDouble()) { GainStat(from, Stat.Str); } else if (from.DexLock == StatLockType.Up && (info.DexGain / 33.3) * scalar > Utility.RandomDouble()) { GainStat(from, Stat.Dex); } else if (from.IntLock == StatLockType.Up && (info.IntGain / 33.3) * scalar > Utility.RandomDouble()) { GainStat(from, Stat.Int); } } else { TryStatGain(info, from); } } }
public static void Gain(Mobile from, Skill skill) { if (from.Region.IsPartOf(typeof(Regions.Jail))) { return; } if (from is BaseCreature && ((BaseCreature)from).IsDeadPet) { return; } if (skill.SkillName == SkillName.Focus && from is BaseCreature) { return; } if (skill.Base < skill.Cap && skill.Lock == SkillLock.Up) { int toGain = 1; if (skill.Base <= 10.0) { toGain = Utility.Random(4) + 1; } Skills skills = from.Skills; #region Mondain's Legacy if (from is PlayerMobile) { if (Server.Engines.Quests.QuestHelper.EnhancedSkill((PlayerMobile)from, skill)) { toGain *= Utility.RandomMinMax(2, 4); } } #endregion #region Scroll of Alacrity if (from is PlayerMobile) { PlayerMobile pm = from as PlayerMobile; if (pm != null && skill.SkillName == pm.AcceleratedSkill && pm.AcceleratedStart > DateTime.UtcNow) { pm.SendLocalizedMessage(1077956); // You are infused with intense energy. You are under the effects of an accelerated skillgain scroll. toGain = Utility.RandomMinMax(2, 5); } } #endregion if (from.Player && (skills.Total / skills.Cap) >= Utility.RandomDouble())//( skills.Total >= skills.Cap ) { for (int i = 0; i < skills.Length; ++i) { Skill toLower = skills[i]; if (toLower != skill && toLower.Lock == SkillLock.Down && toLower.BaseFixedPoint >= toGain) { toLower.BaseFixedPoint -= toGain; break; } } } #region Skill Masteries else if (from is BaseCreature && (((BaseCreature)from).Controlled || ((BaseCreature)from).Summoned)) { Mobile master = ((BaseCreature)from).GetMaster(); if (master != null) { WhisperingSpell spell = SkillMasterySpell.GetSpell(master, typeof(WhisperingSpell)) as WhisperingSpell; if (spell != null && master.InRange(from.Location, spell.PartyRange) && master.Map == from.Map && spell.EnhancedGainChance >= Utility.Random(100)) { toGain = Utility.RandomMinMax(2, 5); } } } #endregion if (!from.Player || (skills.Total + toGain) <= skills.Cap) { skill.BaseFixedPoint += toGain; } } #region Mondain's Legacy if (from is PlayerMobile) { Server.Engines.Quests.QuestHelper.CheckSkill((PlayerMobile)from, skill); } #endregion if (skill.Lock == SkillLock.Up) { SkillInfo info = skill.Info; // Old gain mechanic if (!Core.ML) { if (from.StrLock == StatLockType.Up && (info.StrGain / 33.3) > Utility.RandomDouble()) { GainStat(from, Stat.Str); } else if (from.DexLock == StatLockType.Up && (info.DexGain / 33.3) > Utility.RandomDouble()) { GainStat(from, Stat.Dex); } else if (from.IntLock == StatLockType.Up && (info.IntGain / 33.3) > Utility.RandomDouble()) { GainStat(from, Stat.Int); } } else { TryStatGain(info, from); } } }
public static void Gain(Mobile from, Skill skill, int toGain) { if (from.Region.IsPartOf <Jail>()) { return; } if (from is BaseCreature creature && creature.IsDeadPet) { return; } if (skill.SkillName == SkillName.Focus && from is BaseCreature baseCreature && !baseCreature.Controlled) { return; } if (skill.Base < skill.Cap && skill.Lock == SkillLock.Up) { Skills skills = from.Skills; if (from is PlayerMobile mobile && Siege.SiegeShard) { int minsPerGain = Siege.MinutesPerGain(mobile, skill); if (minsPerGain > 0) { if (Siege.CheckSkillGain(mobile, minsPerGain, skill)) { CheckReduceSkill(skills, toGain, skill); if (skills.Total + toGain <= skills.Cap) { skill.BaseFixedPoint += toGain; } } return; } } if (toGain == 1 && skill.Base <= 10.0) { toGain = Utility.Random(4) + 1; } if (from is PlayerMobile playerMobile && QuestHelper.EnhancedSkill(playerMobile, skill)) { toGain *= Utility.RandomMinMax(2, 4); } #region Scroll of Alacrity if (from is PlayerMobile pm && skill.SkillName == pm.AcceleratedSkill && pm.AcceleratedStart > DateTime.UtcNow) { pm.SendLocalizedMessage(1077956); // You are infused with intense energy. You are under the effects of an accelerated skill gain scroll. toGain = Utility.RandomMinMax(2, 5); } #endregion #region Skill Masteries else if (from is BaseCreature bc && !(bc is Engines.Despise.DespiseCreature) && (bc.Controlled || bc.Summoned)) { Mobile master = bc.GetMaster(); if (master != null) { WhisperingSpell spell = SkillMasterySpell.GetSpell(master, typeof(WhisperingSpell)) as WhisperingSpell; if (spell != null && master.InRange(bc.Location, spell.PartyRange) && master.Map == bc.Map && spell.EnhancedGainChance >= Utility.Random(100)) { toGain = Utility.RandomMinMax(2, 5); } } } #endregion if (from is PlayerMobile) { CheckReduceSkill(skills, toGain, skill); } if (!from.Player || (skills.Total + toGain <= skills.Cap)) { skill.BaseFixedPoint = Math.Min(skill.CapFixedPoint, skill.BaseFixedPoint + toGain); EventSink.InvokeSkillGain(new SkillGainEventArgs(from, skill, toGain)); if (from is PlayerMobile) { UpdateGGS(from, skill); } } }