Exemplo n.º 1
0
        public static bool CheckSkill(Mobile from, Skill skill, object amObj, double chance)
        {
            if (from.Skills.Cap == 0)
            {
                return(false);
            }

            bool   success = (chance >= Utility.RandomDouble());
            double gc      = (double)(from.Skills.Cap - from.Skills.Total) / from.Skills.Cap;

            gc += (skill.Cap - skill.Base) / skill.Cap;
            gc /= 1.5;

            gc += (1.0 - chance) * (success ? 0.75 : 0.25);
            gc /= 2;

            gc *= skill.Info.GainFactor;

            if (gc < 0.02)
            {
                gc = 0.02;
            }

            if (from is BaseCreature && ((BaseCreature)from).Controlled)
            {
                if (((BaseCreature)from).ControlMaster is Player)
                {
                    Player      master = ((BaseCreature)from).ControlMaster as Player;
                    Beastmaster bmr    = Perk.GetByType <Beastmaster>(master);

                    if (bmr != null && bmr.GuidingHand())
                    {
                        gc *= 3;
                    }
                }
            }

            bool skillImproved = (from.Alive && ((gc >= Utility.RandomDouble() && AllowGain(from, skill, amObj)) ||
                                                 (skill.Base < 10.0 && Utility.RandomDouble() < 0.50)));

            if (!skillImproved)
            {
                skillImproved
                    = ((skill.Base < 33.3 && Utility.RandomDouble() <= 0.1665) ||
                       (skill.Base < 66.7 && Utility.RandomDouble() <= 0.08325) ||
                       (skill.Base <= 91.1 && Utility.RandomDouble() <= 0.041625) ||
                       (skill.Base <= 125.0 && Utility.RandomDouble() <= 0.01));
            }

            if (skillImproved)
            {
                Gain(from, skill);
            }

            return(success);
        }
Exemplo n.º 2
0
        public static bool CheckSkill(Mobile from, Skill skill, object amObj, double chance)
        {
            if (from.Skills.Cap == 0)
            {
                return(false);
            }

            bool   success = (chance >= Utility.RandomDouble());
            double gc      = (double)(from.Skills.Cap - from.Skills.Total) / from.Skills.Cap;

            gc += (skill.Cap - skill.Base) / skill.Cap;
            gc /= 5;

            gc += (1.0 - chance) * (success ? 0.5 : 0.2);
            gc /= 5;

            gc *= ((from.Hunger + from.Thirst) / 40);

            //gc *= skill.Info.GainFactor;

            if (gc < 0.01)
            {
                gc = 0.01;
            }

            if (from is BaseCreature && ((BaseCreature)from).Controlled)
            {
                if (((BaseCreature)from).ControlMaster is Player)
                {
                    Player      master = ((BaseCreature)from).ControlMaster as Player;
                    Beastmaster bmr    = Perk.GetByType <Beastmaster>(master);

                    if (bmr != null && bmr.GuidingHand())
                    {
                        gc *= 3;
                    }
                }
            }

            if (from.Alive && ((gc >= Utility.RandomDouble() && AllowGain(from, skill, amObj)) || skill.Base < 10.0))
            {
                Gain(from, skill);
            }

            return(success);
        }
Exemplo n.º 3
0
        public static bool CheckSkill(Mobile from, Skill skill, object amObj, double chance)
        {
            if (from.Skills.Cap == 0)
            {
                return(false);
            }

            bool   success = (chance >= Utility.RandomDouble());
            double gc      = (double)(from.Skills.Cap - from.Skills.Total) / from.Skills.Cap;

            gc += (skill.Cap - skill.Base) / skill.Cap;
            gc /= 2;

            gc += (1.0 - chance) * (success ? 0.5 : (Core.AOS ? 0.0 : 0.2));
            gc /= 2;

            gc *= skill.Info.GainFactor;

            if (gc < 0.01)
            {
                gc = 0.01;
            }

            if (from is BaseCreature && ((BaseCreature)from).Controlled)
            {
                if (((BaseCreature)from).ControlMaster is Player)
                {
                    Player      master = ((BaseCreature)from).ControlMaster as Player;
                    Beastmaster bmr    = Perk.GetByType <Beastmaster>(master);

                    if (bmr != null && bmr.GuidingHand())
                    {
                        gc *= 3;
                    }
                }
            }

            bool skillImproved = (from.Alive && ((gc >= Utility.RandomDouble() && AllowGain(from, skill, amObj)) ||
                                                 (skill.Base < 10.0 && Utility.RandomDouble() < 0.50)));

            //if (!skillImproved && Utility.RandomBool())
            //{
            //    skillImproved
            //        = ((skill.Base < 33.3 && Utility.RandomDouble()   <= 0.005)
            //        || (skill.Base < 66.7 && Utility.RandomDouble()   <= 0.004)
            //        || (skill.Base <= 91.1 && Utility.RandomDouble()  <= 0.003)
            //        || (skill.Base <= 100.0 && Utility.RandomDouble() <= 0.002)
            //        || (skill.Base <= 125.0 && Utility.RandomDouble() <= 0.001));
            //}

            if (skillImproved)
            {
                Gain(from, skill);
                if (from is Player)
                {
                    ((Player)from).EoC += (int)((skill.Base * 0.618) / Math.PI);

                    if (Utility.RandomDouble() == Utility.RandomDouble())
                    {
                        from.Hunger--;
                    }

                    if (Utility.RandomDouble() == Utility.RandomDouble())
                    {
                        from.Thirst--;
                    }
                }
            }

            if (success && from is Player)
            {
                ((Player)from).EoC++;
            }

            return(success);
        }