Example #1
0
        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();
                }
            }
        }
Example #2
0
        public LokaiSkills(Mobile owner)
        {
            m_Owner = owner;
            m_Cap   = LOKAISKILLSCAP;

            LokaiSkillInfo[] info = LokaiSkillInfo.Table;

            m_LokaiSkills = new LokaiSkill[info.Length];

            for (int i = 0; i < info.Length; ++i)
            {
                m_LokaiSkills[i] = new LokaiSkill(this, info[i], STARTVALUE, LOKAISKILLCAP, LokaiSkillLock.Up);
            }

            m_LastCheck = new SuccessRating[LokaiSkillInfo.Table.Length];
        }
Example #3
0
        public LokaiSkill this[int LokaiSkillID]
        {
            get
            {
                if (LokaiSkillID < 0 || LokaiSkillID >= m_LokaiSkills.Length)
                {
                    return(null);
                }

                LokaiSkill skil = m_LokaiSkills[LokaiSkillID];

                if (skil == null)
                {
                    m_LokaiSkills[LokaiSkillID] = skil = new LokaiSkill(this, LokaiSkillInfo.Table[LokaiSkillID], 0, 1000, LokaiSkillLock.Up);
                }

                return(skil);
            }
        }
Example #4
0
        public void OnLokaiSkillChange(LokaiSkill lokaiSkill, double oldValue)
        {
            if (lokaiSkill == m_Highest)
            {
                m_Highest = null;
            }
            else if (m_Highest != null && lokaiSkill.BaseFixedPoint > m_Highest.BaseFixedPoint)
            {
                m_Highest = lokaiSkill;
            }

            double change = lokaiSkill.Value - oldValue;

            if (change != 0.0)
            {
                m_Owner.SendMessage(string.Format("Your {0} skill has changed by {1}. It is now {2}.",
                                                  lokaiSkill.Name, change.ToString("F1"), lokaiSkill.Base.ToString("F1")));
            }
            m_Owner.InvalidateProperties();
        }
Example #5
0
        public LokaiSkills(Mobile owner, GenericReader reader)
        {
            m_Owner = owner;

            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
            {
                m_Cap = reader.ReadInt();

                LokaiSkillInfo[] info = LokaiSkillInfo.Table;

                m_LokaiSkills = new LokaiSkill[info.Length];

                int count = reader.ReadInt();

                for (int i = 0; i < count; ++i)
                {
                    if (i < info.Length)
                    {
                        LokaiSkill skil = new LokaiSkill(this, info[i], reader);

                        if (skil.BaseFixedPoint != 0 || skil.CapFixedPoint != LOKAISKILLCAP || skil.Lock != LokaiSkillLock.Up)
                        {
                            m_LokaiSkills[i] = skil;
                            m_Total         += skil.BaseFixedPoint;
                        }
                    }
                    else
                    {
                        new LokaiSkill(this, null, reader);
                    }
                }

                break;
            }
            }
            m_LastCheck = new SuccessRating[LokaiSkillInfo.Table.Length];
        }
Example #6
0
        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();
                }
            }
        }
Example #7
0
        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();
                    }
                }
            }
        }
Example #8
0
        public void Serialize(GenericWriter writer)
        {
            m_Total = 0;

            writer.Write((int)0); // version

            writer.Write((int)m_Cap);
            writer.Write((int)m_LokaiSkills.Length);

            for (int i = 0; i < m_LokaiSkills.Length; ++i)
            {
                LokaiSkill skil = m_LokaiSkills[i];

                if (skil == null)
                {
                    writer.Write((byte)0xFF);
                }
                else
                {
                    skil.Serialize(writer);
                    m_Total += skil.BaseFixedPoint;
                }
            }
        }
Example #9
0
 public void OnLokaiSkillChange(LokaiSkill lokaiSkill)
 {
     OnLokaiSkillChange(lokaiSkill, lokaiSkill.Value);
 }
        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);
        }