Beispiel #1
0
 public LokaiSkill(LokaiSkills owner, LokaiSkillInfo info, int baseValue, int cap, LokaiSkillLock LokaiSkillLock)
 {
     m_Owner = owner;
     m_Info  = info;
     m_Base  = (ushort)baseValue;
     m_Cap   = (ushort)cap;
     m_Lock  = LokaiSkillLock;
 }
Beispiel #2
0
 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); }
 }
Beispiel #3
0
 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); }
 }
Beispiel #4
0
        public LokaiSkill(LokaiSkills owner, LokaiSkillInfo info, GenericReader reader)
        {
            m_Owner = owner;
            m_Info  = info;

            int version = reader.ReadByte();

            switch (version)
            {
            case 0:
            {
                m_Base = reader.ReadUShort();
                m_Cap  = reader.ReadUShort();
                m_Lock = (LokaiSkillLock)reader.ReadByte();

                break;
            }

            case 0xFF:
            {
                m_Base = 0;
                m_Cap  = 1000;
                m_Lock = LokaiSkillLock.Up;

                break;
            }

            default:
            {
                if ((version & 0xC0) == 0x00)
                {
                    if ((version & 0x1) != 0)
                    {
                        m_Base = reader.ReadUShort();
                    }

                    if ((version & 0x2) != 0)
                    {
                        m_Cap = reader.ReadUShort();
                    }
                    else
                    {
                        m_Cap = 1000;
                    }

                    if ((version & 0x4) != 0)
                    {
                        m_Lock = (LokaiSkillLock)reader.ReadByte();
                    }
                }

                break;
            }
            }

            if (m_Lock < LokaiSkillLock.Up || m_Lock > LokaiSkillLock.Locked)
            {
                Console.WriteLine("Bad Lokai Skill lock -> {0}.{1}", owner.Owner, m_Lock);
                m_Lock = LokaiSkillLock.Up;
            }
        }
        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);
                }
            }
        }