public override void OnEquip(Mobile from) { try { LokaiSkillMod lsm = new LokaiSkillMod(Skill, Relative, ObeyCap, Value, from); lsm.Name = string.Format("{0}{1}{2}", Skill.ToString(), from.Name, Serial.Value); XmlAttach.AttachTo(from, lsm); LokaiSkills skills = LokaiSkillUtilities.XMLGetSkills(from); skills.OnLokaiSkillChange(skills[Skill]); } catch { base.OnEquip(from); } }
private void InternalRemoveSkillMod(Mobile from, LokaiSkillMod mod) { if (XmlAttach.FindAttachment(from, typeof(LokaiSkillMod)) == mod) { mod.Delete(); LokaiSkill sk = LokaiSkillUtilities.XMLGetSkills(from)[mod.Skill]; if (sk != null) { sk.Update(); } } }
public override void OnRemoved(object parent) { try { if (parent is Mobile) { Mobile from = parent as Mobile; XmlAttach.FindAttachmentOnMobile(from, typeof(LokaiSkillMod), string.Format("{0}{1}{2}", Skill.ToString(), from.Name, Serial.Value)).Delete(); LokaiSkills skills = LokaiSkillUtilities.XMLGetSkills(from); skills.OnLokaiSkillChange(skills[Skill]); } } catch { base.OnRemoved(parent); } }
public virtual void AddSkillMod(Mobile from) { if (from == null) { return; } ValidateSkillMods(from); if (XmlAttach.FindAttachment(from, typeof(LokaiSkillMod)) != this /*m_SkillMods.Contains(mod)*/) { XmlAttach.AttachTo(from, this); LokaiSkill sk = LokaiSkillUtilities.XMLGetSkills(from)[this.Skill]; if (sk != null) { sk.Update(); } } }
public virtual void UpdateSkillMods(Mobile from) { ValidateSkillMods(from); ArrayList a = XmlAttach.FindAttachments(from); foreach (XmlAttachment x in a) { if (x is LokaiSkillMod) { LokaiSkillMod mod = x as LokaiSkillMod; LokaiSkill sk = LokaiSkillUtilities.XMLGetSkills(from)[this.Skill]; if (sk != null) { sk.Update(); } } } }
public static void Gain(Mobile from, LokaiSkill lokaiSkill) { if (from.Region.IsPartOf(typeof(Regions.Jail))) { return; } if (lokaiSkill.Base < lokaiSkill.Cap && lokaiSkill.Lock == LokaiSkillLock.Up) { int oldLokaiSkill = lokaiSkill.BaseFixedPoint; int toGain = 1; if (lokaiSkill.Base <= 30.0) { toGain = Utility.Random(3) + 1; } LokaiSkills lokaiSkills = LokaiSkillUtilities.XMLGetSkills(from); if (lokaiSkills.Total >= lokaiSkills.Cap) { for (int i = 0; i < lokaiSkills.Length; ++i) { LokaiSkill toLower = lokaiSkills[i]; if (toLower != lokaiSkill && toLower.Lock == LokaiSkillLock.Down && toLower.BaseFixedPoint >= toGain) { toLower.BaseFixedPoint -= toGain; break; } } } if ((lokaiSkills.Total + toGain) <= lokaiSkills.Cap) { lokaiSkill.BaseFixedPoint += toGain; } if ((oldLokaiSkill <= 199 && lokaiSkill.BaseFixedPoint >= 200) || (oldLokaiSkill <= 299 && lokaiSkill.BaseFixedPoint >= 300) || (oldLokaiSkill <= 399 && lokaiSkill.BaseFixedPoint >= 400) || (oldLokaiSkill <= 499 && lokaiSkill.BaseFixedPoint >= 500) || (oldLokaiSkill <= 599 && lokaiSkill.BaseFixedPoint >= 600) || (oldLokaiSkill <= 699 && lokaiSkill.BaseFixedPoint >= 700) || (oldLokaiSkill <= 799 && lokaiSkill.BaseFixedPoint >= 800) || (oldLokaiSkill <= 899 && lokaiSkill.BaseFixedPoint >= 900)) { lokaiSkills.Teaching.BaseFixedPoint += (7 - toGain); } } if (lokaiSkill.Lock == LokaiSkillLock.Up) { LokaiSkillInfo info = lokaiSkill.Info; if (from.StrLock == StatLockType.Up && (info.StrScale / 33.3) > Utility.RandomDouble()) { SkillCheck.GainStat(from, SkillCheck.Stat.Str); } else if (from.DexLock == StatLockType.Up && (info.IntScale / 33.3) > Utility.RandomDouble()) { SkillCheck.GainStat(from, SkillCheck.Stat.Dex); } else if (from.IntLock == StatLockType.Up && (info.DexScale / 33.3) > Utility.RandomDouble()) { SkillCheck.GainStat(from, SkillCheck.Stat.Int); } } }
public static SuccessRating CheckLokaiSkill(Mobile from, LokaiSkill lokaiSkill, double minLokaiSkill, double maxLokaiSkill) { double value = lokaiSkill.Value; if (value < minLokaiSkill) { return(SuccessRating.TooDifficult); // Too difficult } else if (value >= maxLokaiSkill) { return(SuccessRating.TooEasy); // No challenge } double chance = (value - minLokaiSkill) / (maxLokaiSkill - minLokaiSkill); if (LokaiSkillUtilities.XMLGetSkills(from).Cap == 0) { return(SuccessRating.LokaiSkillNotEnabled); } SuccessRating rating = SuccessRating.PartialSuccess; double random = Utility.RandomDouble(); bool success = (chance >= random); double gc = (double)(LokaiSkillUtilities.XMLGetSkills(from).Cap - LokaiSkillUtilities.XMLGetSkills(from).Total) / LokaiSkillUtilities.XMLGetSkills(from).Cap; gc += (lokaiSkill.Cap - lokaiSkill.Base) / lokaiSkill.Cap; gc /= 2; gc += (1.0 - chance) * (success ? 0.5 : (Core.AOS ? 0.0 : 0.2)); gc /= 2; if (gc < 0.01) { gc = 0.01; } if (from is BaseCreature && ((BaseCreature)from).Controlled) { gc *= 2; } if (from.Alive && (gc >= Utility.RandomDouble() || lokaiSkill.Base < 10.0)) { Gain(from, lokaiSkill); } if (chance - random <= -0.9) { rating = SuccessRating.CriticalFailure; } else if (chance - random <= -0.6) { rating = SuccessRating.HazzardousFailure; } else if (chance - random <= 0.0) { rating = SuccessRating.Failure; } else if (chance - random <= 0.15) { rating = SuccessRating.PartialSuccess; } else if (chance - random <= 0.45) { rating = SuccessRating.Success; } else if (chance - random <= 0.75) { rating = SuccessRating.CompleteSuccess; } else if (chance - random <= 0.9) { rating = SuccessRating.ExceptionalSuccess; } return(rating); }