Exemplo n.º 1
0
            private bool CheckRepairDifficulty(Mobile mob, SkillName skill, int curHits, int maxHits)
            {
                double difficulty = GetRepairDifficulty(curHits, maxHits) * 0.1;

                if (m_Deed != null)
                {
                    double value    = m_Deed.SkillLevel;
                    double minSkill = difficulty - 25.0;
                    double maxSkill = difficulty + 25;

                    if (value < minSkill)
                    {
                        return(false); // Too difficult
                    }
                    else if (value >= maxSkill)
                    {
                        return(true); // No challenge
                    }
                    double chance = (value - minSkill) / (maxSkill - minSkill);

                    return(chance >= Utility.RandomDouble());
                }
                else
                {
                    SkillLock sl = mob.Skills[SkillName.Tinkering].Lock;
                    mob.Skills[SkillName.Tinkering].SetLockNoRelay(SkillLock.Locked);

                    bool check = mob.CheckSkill(skill, difficulty - 25.0, difficulty + 25.0);

                    mob.Skills[SkillName.Tinkering].SetLockNoRelay(sl);

                    return(check);
                }
            }
Exemplo n.º 2
0
 public SkillEntry(SkillName name, int value, int baseValue, SkillLock lockType, int cap)
 {
     m_Name      = name;
     m_Value     = value;
     m_BaseValue = baseValue;
     m_Lock      = lockType;
     m_Cap       = cap;
 }
Exemplo n.º 3
0
 internal void UpdateSkillLock(int id, SkillLock skillLock)
 {
     if (id < skills.Length)
     {
         skills[id].Lock = skillLock;
         delta          |= Delta.Skills;
     }
 }
Exemplo n.º 4
0
 public Skill(Skills owner, SkillInfo info, int baseValue, int cap, SkillLock skillLock)
 {
     this.m_Owner = owner;
     this.m_Info  = info;
     this.m_Base  = ((ushort)baseValue);
     this.m_Cap   = ((ushort)cap);
     this.m_Lock  = skillLock;
 }
Exemplo n.º 5
0
 public Skill(Skills owner, SkillInfo info, int baseValue, int cap, SkillLock skillLock)
 {
     Owner  = owner;
     Info   = info;
     m_Base = (ushort)baseValue;
     m_Cap  = (ushort)cap;
     Lock   = skillLock;
 }
Exemplo n.º 6
0
 public void OnSkillChange(double newValue, SkillLock newLock)
 {
     this.m_Value.Text = newValue.ToString("F1");
     this.m_Value.X    = (this.m_Width - 0x18) - this.m_Value.Image.xMax;
     this.m_Value.Y    = -this.m_Value.Image.yMin;
     this.m_Lock.State = (int)newLock;
     this.UpdateLock();
 }
Exemplo n.º 7
0
 public SkillValue(ushort id, ushort value, ushort realValue, SkillLock lockStatus, ushort maxValue)
 {
     ID        = id;
     Value     = value;
     RealValue = realValue;
     Lock      = lockStatus;
     MaxValue  = maxValue;
 }
Exemplo n.º 8
0
 public SkillEntry(PacketReader reader)
 {
     m_Name      = (SkillName)reader.ReadUInt16();
     m_Value     = reader.ReadUInt16();
     m_BaseValue = reader.ReadUInt16();
     m_Lock      = (SkillLock)reader.ReadByte();
     m_Cap       = reader.ReadUInt16();
 }
Exemplo n.º 9
0
 public Skill(Skills owner, SkillInfo info, int baseValue, int cap, SkillLock skillLock)
 {
     m_Owner    = owner;
     m_Info     = info;
     m_Base     = (ushort)baseValue;
     m_Cap      = (ushort)cap;
     m_Lock     = skillLock;
     m_LastUsed = DateTime.Now;
 }
Exemplo n.º 10
0
        public void SetLockNoRelay(SkillLock skillLock)
        {
            if (skillLock < SkillLock.Up || skillLock > SkillLock.Locked)
            {
                return;
            }

            m_Lock = skillLock;
        }
Exemplo n.º 11
0
 public Skill(int id, bool action, string name)
 {
     this.ID     = id;
     this.Action = action;
     this.Name   = name;
     this.Value  = 0f;
     this.Real   = 0f;
     this.Group  = null;
     this.Lock   = SkillLock.Up;
 }
Exemplo n.º 12
0
 public Skill(int id, bool action, string name)
 {
     this.ID = id;
     this.Action = action;
     this.Name = name;
     this.Value = 0f;
     this.Real = 0f;
     this.Group = null;
     this.Lock = SkillLock.Up;
 }
Exemplo n.º 13
0
        private void Lock_OnStateChange(int state, Gump g)
        {
            SkillLock @lock = (SkillLock)state;

            if (this.m_Skill.Lock != @lock)
            {
                this.m_Skill.Lock = @lock;
                Network.Send(new PUpdateSkillLock(this.m_Skill));
            }
        }
Exemplo n.º 14
0
        public Skill(Skills owner, SkillInfo 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 = (SkillLock)reader.ReadByte();

                break;
            }

            case 0xFF:
            {
                m_Base = 0;
                m_Cap  = 1000;
                m_Lock = SkillLock.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 = (SkillLock)reader.ReadByte();
                    }
                }

                break;
            }
            }
        }
Exemplo n.º 15
0
 internal void UpdateSkill(int id, ushort realValue, ushort baseValue, SkillLock skillLock, ushort cap)
 {
     if (id < skills.Length)
     {
         skills[id].ValueFixed = realValue;
         skills[id].BaseFixed  = baseValue;
         skills[id].Lock       = skillLock;
         skills[id].CapFixed   = cap;
         delta |= Delta.Skills;
     }
 }
Exemplo n.º 16
0
        private void Lock_OnStateChange(int state, Gump g)
        {
            SkillLock skillLock = (SkillLock)state;

            if (this.m_Skill.Lock == skillLock)
            {
                return;
            }
            this.m_Skill.Lock = skillLock;
            Network.Send((Packet) new PUpdateSkillLock(this.m_Skill));
        }
Exemplo n.º 17
0
        public static Skill Deserialize(Skills owner, SkillInfo info, GenericReader reader)
        {
            int version = reader.ReadByte();

            ushort    m_Base = 0;
            ushort    m_Cap  = 0;
            SkillLock m_Lock = SkillLock.Up;

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

                break;
            }

            case 0xFF:
                return(null);

            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 = (SkillLock)reader.ReadByte();
                    }
                }

                break;
            }
            }

            return(new Skill(owner, info, m_Base, m_Cap, m_Lock));
        }
Exemplo n.º 18
0
        public Skill(Skills owner, SkillInfo info, Database.Skill v)
        {
            m_Owner = owner;
            m_Info  = info;

            m_Base = (ushort)v.Base;
            m_Cap  = (ushort)v.Cap;
            m_Lock = (SkillLock)(byte)v.Lock;



            if (m_Lock < SkillLock.Up || m_Lock > SkillLock.Locked)
            {
                Console.WriteLine("Bad skill lock -> {0}.{1}", owner.Owner, m_Lock);
                m_Lock = SkillLock.Up;
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// Function allows to change the lockstate of any stat such as STR,DEX,INT.
 /// </summary>
 /// <param name="stat"></param>
 /// <param name="statState"></param>
 public virtual void ChangeStatLockState(Stats stat, SkillLock statState)
 {
     ChangeStatLockState((byte)stat, (byte)statState);
 }
Exemplo n.º 20
0
        public void SetLockNoRelay( SkillLock skillLock )
        {
            if ( skillLock < SkillLock.Up || skillLock > SkillLock.Locked )
                return;

            m_Lock = skillLock;
        }
Exemplo n.º 21
0
 public Skill( Skills owner, SkillInfo info, int baseValue, int cap, SkillLock skillLock )
 {
     m_Owner = owner;
     m_Info = info;
     m_Base = (ushort)baseValue;
     m_Cap = (ushort)cap;
     m_Lock = skillLock;
 }
Exemplo n.º 22
0
        public Skill( Skills owner, SkillInfo 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 = (SkillLock)reader.ReadByte();

                    break;
                }
                case 0xFF:
                {
                    m_Base = 0;
                    m_Cap = 1000;
                    m_Lock = SkillLock.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 = (SkillLock)reader.ReadByte();
                    }

                    break;
                }
            }

            if ( m_Lock < SkillLock.Up || m_Lock > SkillLock.Locked )
            {
                Console.WriteLine( "Bad skill lock -> {0}.{1}", owner.Owner, m_Lock );
                m_Lock = SkillLock.Up;
            }
        }
Exemplo n.º 23
0
        public Skill( Skills owner, SkillInfo 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 = (SkillLock)reader.ReadByte();

                    break;
                }
                case 0xFF:
                {
                    m_Base = 0;
                    m_Cap = 1000;
                    m_Lock = SkillLock.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 = (SkillLock)reader.ReadByte();
                    }

                    break;
                }
            }
        }
Exemplo n.º 24
0
 public void SetLockNoRelay( SkillLock skillLock )
 {
     m_Lock = skillLock;
 }
Exemplo n.º 25
0
            public bool TryRepairMobile(Mobile from, IRepairableMobile m, bool usingDeed, out bool toDelete)
            {
                int          damage = m.HitsMax - m.Hits;
                BaseCreature bc     = m as BaseCreature;

                toDelete = false;

                string name = bc != null ? bc.Name : "the creature";

                if (!from.InRange(m.Location, 2))
                {
                    from.SendLocalizedMessage(1113612, name); // You must move closer to attempt to repair ~1_CREATURE~.
                }
                else if (bc != null && bc.IsDeadBondedPet)
                {
                    from.SendLocalizedMessage(500426); // You can't repair that.
                }
                else if (damage <= 0)
                {
                    from.SendLocalizedMessage(1113613, name); // ~1_CREATURE~ doesn't appear to be damaged.
                }
                else
                {
                    double value = 0;

                    if (m_Deed != null)
                    {
                        value = m_Deed.SkillLevel;
                    }
                    else if (m_Addon != null)
                    {
                        value = m_Addon.Tools.Find(x => x.System == m_CraftSystem).SkillValue;
                    }
                    else
                    {
                        value = from.Skills[SkillName.Tinkering].Value;
                    }

                    double skillValue = value;
                    double required   = m is KotlAutomaton ? 80.0 : 0.1;

                    if (skillValue < required)
                    {
                        if (required == 80.0)
                        {
                            from.SendLocalizedMessage(1157049, name); // You must have at least 80 tinkering skill to attempt to repair ~1_CREATURE~.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1113614, name); // You must have some tinkering skills to attempt to repair a ~1_CREATURE~.
                        }
                    }
                    else if (!from.CanBeginAction(typeof(IRepairableMobile)))
                    {
                        from.SendLocalizedMessage(1113611, name); // You must wait a moment before attempting to repair ~1_CREATURE~ again.
                    }
                    else if (bc != null && bc.GetMaster() != null && bc.GetMaster() != from && !bc.GetMaster().InRange(from.Location, 10))
                    {
                        from.SendLocalizedMessage(1157045); // The pet's owner must be nearby to attempt repair.
                    }
                    else if (!from.CanBeBeneficial(bc, false, false))
                    {
                        from.SendLocalizedMessage(1001017); // You cannot perform beneficial acts on your target.
                    }
                    else
                    {
                        if (damage > (int)(skillValue * 0.6))
                        {
                            damage = (int)(skillValue * 0.6);
                        }

                        SkillLock sl = from.Skills[SkillName.Tinkering].Lock;
                        from.Skills[SkillName.Tinkering].SetLockNoRelay(SkillLock.Locked);

                        if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0))
                        {
                            damage /= 6;
                        }

                        from.Skills[SkillName.Tinkering].SetLockNoRelay(sl);

                        Container pack = from.Backpack;

                        if (pack != null)
                        {
                            int v = pack.ConsumeUpTo(m.RepairResource, (damage + 4) / 5);

                            if (v <= 0 && m is Golem)
                            {
                                v = pack.ConsumeUpTo(typeof(BronzeIngot), (damage + 4) / 5);
                            }

                            if (v > 0)
                            {
                                m.Hits += damage;

                                if (damage > 1)
                                {
                                    from.SendLocalizedMessage(1113616, name); // You repair ~1_CREATURE~.
                                }
                                else
                                {
                                    from.SendLocalizedMessage(1157030, name); // You repair ~1_CREATURE~, but it barely helps.
                                }

                                toDelete = true;
                                double delay = 10 - (skillValue / 16.65);

                                from.BeginAction(typeof(IRepairableMobile));
                                Timer.DelayCall(TimeSpan.FromSeconds(delay), new TimerStateCallback(EndMobileRepair), from);

                                return(true);
                            }
                            else if (m is Golem)
                            {
                                from.SendLocalizedMessage(1113615, name); // You need some iron or bronze ingots to repair the ~1_CREATURE~.
                            }
                            else
                            {
                                from.SendLocalizedMessage(1044037); // You do not have sufficient metal to make that.
                            }
                        }
                        else
                        {
                            from.SendLocalizedMessage(1044037); // You do not have sufficient metal to make that.
                        }
                    }
                }

                return(false);
            }
Exemplo n.º 26
0
        public static Skill Deserialize( Skills owner, SkillInfo info, GenericReader reader )
        {
            int version = reader.ReadByte();

            ushort m_Base = 0;
            ushort m_Cap = 0;
            SkillLock m_Lock = SkillLock.Up;

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

                    break;
                }
                case 0xFF:
                    return null;

                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 = (SkillLock)reader.ReadByte();
                    }

                    break;
                }
            }

            return new Skill(owner, info, m_Base, m_Cap, m_Lock);
        }
Exemplo n.º 27
0
 internal void UpdateSkill(int id, ushort realValue, ushort baseValue, SkillLock skillLock, ushort cap)
 {
     if (id < skills.Length)
     {
         skills[id].ValueFixed = realValue;
         skills[id].BaseFixed = baseValue;
         skills[id].Lock = skillLock;
         skills[id].CapFixed = cap;
         delta |= Delta.Skills;
     }
 }
Exemplo n.º 28
0
 public static bool IsLocked(this Skill skill, SkillLock locked)
 {
     return(skill.Lock == locked);
 }
Exemplo n.º 29
0
 internal void UpdateSkillLock(int id, SkillLock skillLock)
 {
     if (id < skills.Length)
     {
         skills[id].Lock = skillLock;
         delta |= Delta.Skills;
     }
 }
Exemplo n.º 30
0
		public static bool IsLocked(this Skill skill, SkillLock locked)
		{
			return skill.Lock == locked;
		}
Exemplo n.º 31
0
 public void SetLockNoRelay(SkillLock skillLock)
 {
     m_Lock = skillLock;
 }
Exemplo n.º 32
0
 /// <summary>
 /// Function allows to change the lockstate of any stat such as STR,DEX,INT.
 /// </summary>
 /// <param name="statNum"></param>
 /// <param name="statState"></param>
 public virtual void ChangeStatLockState(byte statNum, SkillLock statState)
 {
     ChangeStatLockState(statNum, (byte)statState);
 }
Exemplo n.º 33
0
        public Skill(Skills owner, SkillInfo 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 = (SkillLock)reader.ReadByte();

                break;
            }

            case 0xFF:
            {
                m_Base = 0;
                m_Cap  = 1000;
                m_Lock = SkillLock.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 = (SkillLock)reader.ReadByte();
                    }
                }

                break;
            }
            }

            if (m_Lock < SkillLock.Up || m_Lock > SkillLock.Locked)
            {
                Console.WriteLine("Bad skill lock -> {0}.{1}", owner.Owner, m_Lock);
                m_Lock = SkillLock.Up;
            }
        }
Exemplo n.º 34
0
 public void OnSkillChange(double newValue, SkillLock newLock)
 {
     this.m_Value.Text = newValue.ToString("F1");
     this.m_Value.X = (this.m_Width - 0x18) - this.m_Value.Image.xMax;
     this.m_Value.Y = -this.m_Value.Image.yMin;
     this.m_Lock.State = (int) newLock;
     this.UpdateLock();
 }
Exemplo n.º 35
0
 public PChangeStatLockStateRequest(byte stat, SkillLock state) : base(0xBF)
 {
     WriteUShort(0x1A);
     WriteByte(stat);
     WriteByte((byte)state);
 }