Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #4
0
        private static TimeSpan Mobile_HitsRegenRate(Mobile from)
        {
            int points = AosAttributes.GetValue(from, AosAttribute.RegenHits);

            if (from is BaseCreature)
            {
                if (from is BaseCreature && !((BaseCreature)from).IsAnimatedDead)
                {
                    points += 4;
                }

                BaseCreature bc = from as BaseCreature;

                if (bc.ControlMaster != null && bc.ControlMaster is Player)
                {
                    Player      master = bc.ControlMaster as Player;
                    Beastmaster bmr    = Perk.GetByType <Beastmaster>((Player)master);

                    if (bmr != null)
                    {
                        points += bmr.PackRegenBonus();
                    }
                }
            }

            if (from is PlayerMobile)
            {
                if (Utility.RandomBool() == Utility.RandomBool())
                {
                    ((Player)from).EoC++;
                }

                if (CheckTransform(from, typeof(HorrificBeastSpell)))
                {
                    points += 20;
                }

                if (CheckAnimal(from, typeof(Dog)) || CheckAnimal(from, typeof(Cat)))
                {
                    points += from.Skills[SkillName.Ninjitsu].Fixed / 30;
                }

                if (((Player)from).Race == Race.HalfDaemon && ((Player)from).AbilityActive == true)
                {
                    points += 16;
                }

                if (from.Hunger != 0 && from.Thirst != 0)
                {
                    int hungerRegen = (int)((from.Hunger + from.Thirst) * 0.1618);

                    if (hungerRegen != 0)
                    {
                        points += hungerRegen;
                    }
                }

                Beastmaster bmr = Perk.GetByType <Beastmaster>((Player)from);

                if (bmr != null)
                {
                    points += bmr.BMasterRegenBonus();
                }

                Monk mk = Perk.GetByType <Monk>((Player)from);

                if (mk != null)
                {
                    points += mk.MeditationMastery();
                }
            }

            if (!(from is Player))
            {
                points += (int)(from.Str * 0.03);
            }

            if (points < 0)
            {
                points = 0;
            }

            return(TimeSpan.FromSeconds(1.0 / (0.1 * (1 + points))));
        }
Пример #5
0
        private static TimeSpan Mobile_ManaRegenRate(Mobile from)
        {
            if (from.Skills == null)
            {
                return(Mobile.DefaultManaRate);
            }

            if (!from.Meditating)
            {
                CheckBonusSkill(from, from.Mana, from.ManaMax, SkillName.Meditation);
            }

            double rate;
            double armorPenalty = GetArmorOffset(from);

            if (Core.AOS)
            {
                double medPoints = from.Int + (from.Skills[SkillName.Meditation].Value * 3);

                if (from is Player)
                {
                    if (((Player)from).Race == Race.Marid && ((Player)from).AbilityActive == true)
                    {
                        medPoints += 24;
                    }

                    //Arcanite arc = Perk.GetByType<Arcanite>((Player)from);
                    //if (arc != null)
                    //{
                    //    medPoints += arc.RegenBonus();
                    //}

                    Beastmaster bmr = Perk.GetByType <Beastmaster>((Player)from);

                    if (bmr != null)
                    {
                        medPoints += bmr.BMasterRegenBonus();
                    }
                }

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

                        if (bmr != null)
                        {
                            medPoints += bmr.PackRegenBonus();
                        }
                    }
                }

                medPoints += (int)((from.Hunger + from.Thirst) * 0.06 - 1);
                medPoints *= (from.Skills[SkillName.Meditation].Value < 100.0) ? 0.025 : 0.0275;

                CheckBonusSkill(from, from.Mana, from.ManaMax, SkillName.Focus);

                double focusPoints = (from.Skills[SkillName.Focus].Value * 0.04);

                if (armorPenalty > 0)
                {
                    medPoints = 0; // In AOS, wearing any meditation-blocking armor completely removes meditation bonus
                }
                double totalPoints = focusPoints + medPoints + (from.Meditating ? (medPoints > 13.0 ? 13.0 : medPoints) : 0.0);

                int cappedPoints = AosAttributes.GetValue(from, AosAttribute.RegenMana);

                if (CheckTransform(from, typeof(VampiricEmbraceSpell)))
                {
                    cappedPoints += 3;
                }
                else if (CheckTransform(from, typeof(LichFormSpell)))
                {
                    cappedPoints += 13;
                }

                if (Core.ML && from is PlayerMobile)
                {
                    cappedPoints = Math.Min(cappedPoints, 18);
                }


                totalPoints += cappedPoints;

                if (totalPoints < -1)
                {
                    totalPoints = -1;
                }

                rate = 1.0 / (0.1 * (2 + totalPoints));
            }

            else
            {
                double medPoints = (from.Int + from.Skills[SkillName.Meditation].Value) * 0.5;

                if (medPoints <= 0)
                {
                    rate = 7.0;
                }
                else if (medPoints <= 100)
                {
                    rate = 7.0 - (239 * medPoints / 2400) + (19 * medPoints * medPoints / 48000);
                }
                else if (medPoints < 120)
                {
                    rate = 1.0;
                }
                else
                {
                    rate = 0.75;
                }

                rate += armorPenalty;

                if (from.Meditating)
                {
                    rate *= 0.5;
                }

                if (rate < 0.5)
                {
                    rate = 0.5;
                }
                else if (rate > 7.0)
                {
                    rate = 7.0;
                }
            }

            return(TimeSpan.FromSeconds(rate));
        }
Пример #6
0
        private static TimeSpan Mobile_StamRegenRate(Mobile from)
        {
            if (from.Skills == null)
            {
                return(Mobile.DefaultStamRate);
            }

            CheckBonusSkill(from, from.Stam, from.StamMax, SkillName.Focus);

            int points = (int)(from.Skills[SkillName.Focus].Value * 0.08);

            int cappedPoints = AosAttributes.GetValue(from, AosAttribute.RegenStam);

            if (CheckTransform(from, typeof(VampiricEmbraceSpell)))
            {
                cappedPoints += 15;
            }

            if (CheckAnimal(from, typeof(Kirin)))
            {
                cappedPoints += 20;
            }

            points += cappedPoints;

            if (from.Player)
            {
                Beastmaster bmr = Perk.GetByType <Beastmaster>((Player)from);

                if (bmr != null)
                {
                    points += bmr.BMasterRegenBonus();
                }

                Acrobat acr = Perk.GetByType <Acrobat>((Player)from);

                if (acr != null)
                {
                    points += acr.GetStamRegenBonus();
                }

                Adventurer adv = Perk.GetByType <Adventurer>((Player)from);

                if (adv != null)
                {
                    points += adv.GetStamRegenBonus();
                }

                Scout sct = Perk.GetByType <Scout>((Player)from);

                if (sct != null)
                {
                    points += sct.StamRegenBonus();
                }

                Dragoon drg = Perk.GetByType <Dragoon>((Player)from);

                if (drg != null)
                {
                    points += drg.Symbiosis();
                }

                Monk mk = Perk.GetByType <Monk>((Player)from);

                if (mk != null)
                {
                    points += mk.MeditationMastery();
                }

                int hungerRegen = (int)((from.Hunger + from.Thirst) * 0.10);

                if (hungerRegen != 0)
                {
                    points += hungerRegen;
                }

                if (from.Stam < 10)
                {
                    points += 16;
                }

                if (from.Stam < from.StamMax * 0.125)
                {
                    points += 8;
                }
            }

            if (!(from is Player))
            {
                points += (int)(from.Dex * 0.04);
            }

            if (from is BaseCreature)
            {
                BaseCreature bc = from as BaseCreature;

                if (bc.ControlMaster != null && bc.ControlMaster is Player)
                {
                    Player      master = bc.ControlMaster as Player;
                    Beastmaster bmr    = Perk.GetByType <Beastmaster>((Player)master);

                    if (bmr != null)
                    {
                        points += bmr.PackRegenBonus();
                    }
                }
            }

            if (from is BaseMount)
            {
                BaseMount mount = from as BaseMount;
                if (mount.Rider != null && mount.Rider is Player)
                {
                    Player  rider = mount.Rider as Player;
                    Dragoon drg   = Perk.GetByType <Dragoon>((Player)rider);

                    if (drg != null)
                    {
                        points += drg.Symbiosis();
                    }
                }
            }

            if (points < -1)
            {
                points = -1;
            }

            if (((from.Direction & Direction.Running) != 0) &&
                from.Mounted == false)
            {
                points = (int)(points / 1.618);
            }

            return(TimeSpan.FromSeconds(1.0 / (0.1 * (2 + points))));
        }
Пример #7
0
        private static TimeSpan Mobile_HitsRegenRate(Mobile from)
        {
            int points = AosAttributes.GetValue(from, AosAttribute.RegenHits);

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

                    if (bmr != null)
                    {
                        points += bmr.PackRegenBonus();
                    }
                }
            }

            if (from is Player)
            {
                if (((Player)from).Race == Race.HalfDaemon && ((Player)from).AbilityActive == true)
                {
                    points += 16;
                }

                if (from.Hunger != 0 && from.Thirst != 0)
                {
                    int hungerRegen = (int)((from.Hunger + from.Thirst) * 0.085);

                    if (hungerRegen != 0)
                    {
                        points += hungerRegen;
                    }
                }

                Beastmaster bmr = Perk.GetByType <Beastmaster>((Player)from);

                if (bmr != null)
                {
                    points += bmr.MasterRegenBonus();
                }

                Monk mk = Perk.GetByType <Monk>((Player)from);

                if (mk != null)
                {
                    points += mk.MeditationMastery();
                }
            }

            if (!(from is Player))
            {
                points += (int)(from.Str * 0.04);
            }

            if (points < 0)
            {
                points = 0;
            }

            return(TimeSpan.FromSeconds(1.0 / (0.1 * (1 + points))));
        }
Пример #8
0
        private static TimeSpan Mobile_StamRegenRate(Mobile from)
        {
            if (from.Skills == null)
            {
                return(Mobile.DefaultStamRate);
            }

            CheckBonusSkill(from, from.Stam, from.StamMax, SkillName.Focus);

            int points = (int)(from.Skills[SkillName.Focus].Value * 0.08);

            int cappedPoints = AosAttributes.GetValue(from, AosAttribute.RegenStam);

            points += cappedPoints;

            if (from.Player)
            {
                bool running = ((Player)from).isRunning && from.Mounted == false;

                if (((Player)from).lastMove < DateTime.Now - TimeSpan.FromSeconds(0.2))
                {
                    running = false;
                }

                if (running)
                {
                    points -= 32;
                }

                Beastmaster bmr = Perk.GetByType <Beastmaster>((Player)from);

                if (bmr != null)
                {
                    points += bmr.MasterRegenBonus();
                }

                Acrobat acr = Perk.GetByType <Acrobat>((Player)from);

                if (acr != null)
                {
                    points += acr.GetStamRegenBonus();
                }

                Adventurer adv = Perk.GetByType <Adventurer>((Player)from);

                if (adv != null)
                {
                    points += adv.GetStamRegenBonus();
                }

                Scout sct = Perk.GetByType <Scout>((Player)from);

                if (sct != null)
                {
                    points += sct.StamRegenBonus();
                }

                Dragoon drg = Perk.GetByType <Dragoon>((Player)from);

                if (drg != null)
                {
                    points += drg.Symbiosis();
                }

                Monk mk = Perk.GetByType <Monk>((Player)from);

                if (mk != null)
                {
                    points += mk.MeditationMastery();
                }

                int hungerRegen = (int)((from.Hunger + from.Thirst) * 0.10);

                if (hungerRegen != 0)
                {
                    points += hungerRegen;
                }

                if (from.Hits != 0 && from.HitsMax != 0)
                {
                    double hitsratio = (int)((from.HitsMax / from.Hits) / 4);
                    if (hitsratio != 0)
                    {
                        points = (int)(points * hitsratio);
                    }
                }
            }

            if (!(from is Player))
            {
                points += (int)(from.Dex * 0.04);
            }

            if (from is BaseCreature)
            {
                BaseCreature bc = from as BaseCreature;

                if (bc.ControlMaster != null && bc.ControlMaster is Player)
                {
                    Player      master = bc.ControlMaster as Player;
                    Beastmaster bmr    = Perk.GetByType <Beastmaster>((Player)master);

                    if (bmr != null)
                    {
                        points += bmr.PackRegenBonus();
                    }
                }
            }

            if (from is BaseMount)
            {
                BaseMount mount = from as BaseMount;
                if (mount.Rider != null && mount.Rider is Player)
                {
                    Player  rider = mount.Rider as Player;
                    Dragoon drg   = Perk.GetByType <Dragoon>((Player)rider);

                    if (drg != null)
                    {
                        points += drg.Symbiosis();
                    }
                }
            }

            if (points < -1)
            {
                points = -1;
            }

            return(TimeSpan.FromSeconds(1.0 / (0.1 * (2 + points))));
        }
Пример #9
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                from.RevealingAction();

                if (targeted is Mobile)
                {
                    if (targeted is BaseCreature)
                    {
                        BaseCreature creature = (BaseCreature)targeted;

                        if (!creature.Tamable)
                        {
                            creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1049655, from.NetState); // That creature cannot be tamed.
                        }
                        else if (creature.Controlled)
                        {
                            creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502804, from.NetState); // That animal looks tame already.
                        }
                        else if (from.Female && !creature.AllowFemaleTamer)
                        {
                            creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1049653, from.NetState); // That creature can only be tamed by males.
                        }
                        else if (!from.Female && !creature.AllowMaleTamer)
                        {
                            creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1049652, from.NetState); // That creature can only be tamed by females.
                        }
                        else if (from.Followers + creature.ControlSlots > from.FollowersMax)
                        {
                            from.SendLocalizedMessage(1049611); // You have too many followers to tame that creature.
                        }
                        else if (creature.Owners.Count >= BaseCreature.MaxOwners && !creature.Owners.Contains(from))
                        {
                            creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1005615, from.NetState); // This animal has had too many owners and is too upset for you to tame.
                        }
                        else if (MustBeSubdued(creature))
                        {
                            creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1054025, from.NetState); // You must subdue this creature before you can tame it!
                        }
                        else if (CheckMastery(from, creature) || from.Skills[SkillName.AnimalTaming].Value >= creature.MinTameSkill)
                        {
                            Beastmaster bmr = Perk.GetByType <Beastmaster>((Player)from);

                            if (m_BeingTamed.Contains(targeted))
                            {
                                creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502802, from.NetState); // Someone else is already taming this.
                            }

                            else if (creature.CanAngerOnTame && 0.95 >= Utility.RandomDouble() && bmr != null)
                            {
                                creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502805, from.NetState); // You seem to anger the beast!
                                creature.PlaySound(creature.GetAngerSound());
                                creature.Direction = creature.GetDirectionTo(from);

                                if (creature.BardPacified && Utility.RandomDouble() > .24)
                                {
                                    Timer.DelayCall(TimeSpan.FromSeconds(2.0), new TimerStateCallback(ResetPacify), creature);
                                }
                                else
                                {
                                    creature.BardEndTime = DateTime.Now;
                                }

                                creature.BardPacified = false;

                                if (creature.AIObject != null)
                                {
                                    creature.AIObject.DoMove(creature.Direction);
                                }

                                if (from is PlayerMobile && !(((PlayerMobile)from).HonorActive))
                                {
                                    creature.Combatant = from;
                                }
                            }
                            else
                            {
                                m_BeingTamed[targeted] = from;

                                from.LocalOverheadMessage(MessageType.Emote, 0x59, 1010597);    // You start to tame the creature.
                                from.NonlocalOverheadMessage(MessageType.Emote, 0x59, 1010598); // *begins taming a creature.*

                                new InternalTimer(from, creature, Utility.Random(3, 2)).Start();

                                m_SetSkillTime = false;
                            }
                        }
                        else
                        {
                            creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502806, from.NetState); // You have no chance of taming this creature.
                        }
                    }
                    else
                    {
                        ((Mobile)targeted).PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502469, from.NetState); // That being cannot be tamed.
                    }
                }
                else
                {
                    from.SendLocalizedMessage(502801); // You can't tame that!
                }

                EventSink.InvokeSkillUsed(new SkillUsedEventArgs(from, from.Skills[SkillName.AnimalTaming]));
            }