Esempio n. 1
0
        public static bool CheckThinkTrigger(BaseCreature bc)
        {
            var combatant = bc.Combatant;

            if (combatant is Mobile)
            {
                var profile = PetTrainingHelper.GetAbilityProfile(bc);

                if (profile != null)
                {
                    AreaEffect effect = null;

                    var effects = profile.GetAreaEffects().Where(a => !a.IsInCooldown(bc)).ToArray();

                    if (effects != null && effects.Length > 0)
                    {
                        effect = effects[Utility.Random(effects.Length)];
                    }

                    if (effect != null)
                    {
                        return(effect.Trigger(bc, (Mobile)combatant));
                    }
                }
            }
            return(false);
        }
Esempio n. 2
0
        public override double GetControlChance(Mobile m, bool useBaseSkill)
        {
            if (PetTrainingHelper.Enabled)
            {
                var profile = PetTrainingHelper.GetAbilityProfile(this);

                if (profile != null && profile.HasCustomized())
                {
                    return(base.GetControlChance(m, useBaseSkill));
                }
            }

            double tamingChance = base.GetControlChance(m, useBaseSkill);

            if (tamingChance >= 0.95)
            {
                return(tamingChance);
            }

            double skill = (useBaseSkill ? m.Skills.Bushido.Base : m.Skills.Bushido.Value);

            if (skill < 90.0)
            {
                return(tamingChance);
            }

            double bushidoChance = (skill - 30.0) / 100;

            if (m.Skills.Bushido.Base >= 120)
            {
                bushidoChance += 0.05;
            }

            return(bushidoChance > tamingChance ? bushidoChance : tamingChance);
        }
Esempio n. 3
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            if (version == 0)
            {
                Timer.DelayCall(TimeSpan.Zero, delegate { Hue = GetHue(); });
            }

            if (version <= 1)
            {
                Timer.DelayCall(TimeSpan.Zero, delegate
                {
                    if (InternalItem != null)
                    {
                        InternalItem.Hue = Hue;
                    }
                });
            }

            if (version < 2)
            {
                for (int i = 0; i < Skills.Length; ++i)
                {
                    Skills[i].Cap = Math.Max(100.0, Skills[i].Cap * 0.9);

                    if (Skills[i].Base > Skills[i].Cap)
                    {
                        Skills[i].Base = Skills[i].Cap;
                    }
                }
            }

            if (version < 3)
            {
                SetWeaponAbility(WeaponAbility.Dismount);
            }

            if (version < 3 && Controlled && RawStr >= 301 && ControlSlots == ControlSlotsMin)
            {
                Server.SkillHandlers.AnimalTaming.ScaleStats(this, 0.5);
            }

            if (version < 4 && PetTrainingHelper.Enabled && ControlSlots <= 3)
            {
                var profile = PetTrainingHelper.GetAbilityProfile(this);

                if (profile == null || !profile.HasCustomized())
                {
                    MinTameSkill    = 98.7;
                    ControlSlotsMin = 1;
                    ControlSlots    = 1;
                }
            }
        }
Esempio n. 4
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            if (version == 0)
            {
                PetTrainingHelper.GetAbilityProfile(this, true).TokunoTame = true;
            }
        }
Esempio n. 5
0
        public override double GetControlChance(Mobile m, bool useBaseSkill)
        {
            AbilityProfile profile = PetTrainingHelper.GetAbilityProfile(this);

            if (profile != null && profile.HasCustomized())
            {
                return(base.GetControlChance(m, useBaseSkill));
            }
            return(1.0);
        }
Esempio n. 6
0
        public override void OnAfterTame(Mobile tamer)
        {
            base.OnAfterTame(tamer);

            var profile = PetTrainingHelper.GetAbilityProfile(this);

            if (profile != null)
            {
                profile.RemoveAbility(AreaEffect.AuraDamage);
            }
        }
Esempio n. 7
0
        public override void OnAfterEffects(BaseCreature creature, Mobile defender)
        {
            if (creature.Controlled)
            {
                var profile = PetTrainingHelper.GetAbilityProfile(creature);

                if ((profile != null && profile.HasAbility(MagicalAbility.Poisoning)) || 0.2 > Utility.RandomDouble())
                {
                    creature.CheckSkill(SkillName.Poisoning, 0, creature.Skills[SkillName.Poisoning].Cap);
                }
            }
        }
Esempio n. 8
0
        public virtual bool Validate(BaseCreature attacker, Mobile defender)
        {
            if (RequiredSchool != MagicalAbility.None)
            {
                var profile = PetTrainingHelper.GetAbilityProfile(attacker);

                if (profile == null || !profile.HasAbility(RequiredSchool))
                {
                    return(false);
                }
            }

            return(defender != null && defender.Alive && !defender.Deleted && !defender.IsDeadBondedPet &&
                   attacker.Alive && !attacker.IsDeadBondedPet && defender.InRange(attacker.Location, MaxRange) &&
                   defender.Map == attacker.Map && attacker.InLOS(defender) && !attacker.BardPacified);
        }
Esempio n. 9
0
        public static bool CheckThinkTrigger(BaseCreature bc)
        {
            var combatant = bc.Combatant;
            var profile   = PetTrainingHelper.GetAbilityProfile(bc);

            if (combatant is Mobile)
            {
                if (profile != null)
                {
                    SpecialAbility ability = null;

                    var abilties = profile.EnumerateSpecialAbilities().Where(m => m.TriggerOnThink && !m.IsInCooldown(bc)).ToArray();

                    if (abilties != null && abilties.Length > 0)
                    {
                        ability = abilties[Utility.Random(abilties.Length)];
                    }

                    if (ability != null)
                    {
                        int d = 0;
                        ability.Trigger(bc, (Mobile)combatant, ref d);
                    }
                }
            }
            else
            {
                SpecialAbility ability = null;

                var abilties = profile.EnumerateSpecialAbilities().Where(m => m.TriggerOnThink && !m.IsInCooldown(bc) && !m.RequiresCombatant).ToArray();

                if (abilties != null && abilties.Length > 0)
                {
                    ability = abilties[Utility.Random(abilties.Length)];
                }

                if (ability != null)
                {
                    int d = 0;
                    return(ability.Trigger(bc, bc, ref d));
                }
            }

            return(false);
        }
Esempio n. 10
0
        public override void DoEffects(BaseCreature creature, Mobile defender, ref int damage)
        {
            IPooledEnumerable eable = creature.GetMobilesInRange(3);
            List <Mobile>     list  = new List <Mobile>();

            list.Add(defender);

            foreach (Mobile m in eable)
            {
                if (AreaEffect.ValidTarget(creature, m))
                {
                    list.Add(m);
                }
            }

            eable.Free();
            Poison p = creature.GetHitPoison();

            if (p == null)
            {
                return;
            }

            foreach (var m in list)
            {
                defender.PlaySound(0xDD);
                defender.FixedParticles(0x3728, 244, 25, 9941, 1266, 0, EffectLayer.Waist);

                m.SendLocalizedMessage(1008097, false, creature.Name); //  : poisoned you!

                m.ApplyPoison(creature, p);
            }

            if (creature.Controlled && list.Count > 0)
            {
                var profile = PetTrainingHelper.GetAbilityProfile(creature);

                if ((profile != null && profile.HasAbility(MagicalAbility.Poisoning)) || 0.2 > Utility.RandomDouble())
                {
                    creature.CheckSkill(SkillName.Poisoning, 0, creature.Skills[SkillName.Poisoning].Cap);
                }
            }

            ColUtility.Free(list);
        }
Esempio n. 11
0
        public IEnumerable <SpecialAbility> EnumerateSpecialAbilities()
        {
            if (SpecialAbilities == null)
            {
                yield break;
            }

            var profile = PetTrainingHelper.GetAbilityProfile(Creature);

            if (profile == null)
            {
                yield break;
            }

            foreach (var ability in SpecialAbilities)
            {
                yield return(ability);
            }
        }
Esempio n. 12
0
        public IEnumerable <AreaEffect> EnumerateAreaEffects()
        {
            if (AreaEffects == null)
            {
                yield break;
            }

            var profile = PetTrainingHelper.GetAbilityProfile(Creature);

            if (profile == null)
            {
                yield break;
            }

            foreach (var ability in AreaEffects)
            {
                yield return(ability);
            }
        }
Esempio n. 13
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            if (version < 1 && PetTrainingHelper.Enabled && ControlSlots <= 3)
            {
                var profile = PetTrainingHelper.GetAbilityProfile(this);

                if (profile == null || !profile.HasCustomized())
                {
                    MinTameSkill    = 98.7;
                    ControlSlotsMin = 1;
                    ControlSlots    = 1;
                }

                if ((ControlMaster != null || IsStabled) && Int < 500)
                {
                    SetInt(500);
                }
            }
        }
Esempio n. 14
0
        public override int LabelNumber => 1075084;  // This statuette will be destroyed when its trapped creature is summoned. The creature will be bonded to you but will disappear if released. <br><br>Do you wish to proceed?

        public override void Confirm(Mobile from)
        {
            if (m_Item == null || m_Item.Deleted)
            {
                return;
            }

            BaseCreature m = null;

            if (m_Item is ICreatureStatuette)
            {
                m = Activator.CreateInstance(((ICreatureStatuette)m_Item).CreatureType) as BaseCreature;
            }

            if (m != null)
            {
                if ((from.Followers + m.ControlSlots) > from.FollowersMax)
                {
                    m.Delete();
                    from.SendLocalizedMessage(1114321); // You have too many followers to control that pet.
                }
                else
                {
                    m.SetControlMaster(from);

                    m.IsBonded = true;
                    m.MoveToWorld(from.Location, from.Map);
                    m_Item.Delete();

                    PetTrainingHelper.GetAbilityProfile(m, true).OnTame();

                    Timer.DelayCall(TimeSpan.FromSeconds(1), () =>
                    {
                        m.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502799, from.NetState); // It seems to accept you as master.
                        from.SendLocalizedMessage(1049666);                                          // Your pet has bonded with you!
                    });
                }
            }
        }
Esempio n. 15
0
        public override int LabelNumber => 1075084;  // This statuette will be destroyed when its trapped creature is summoned. The creature will be bonded to you but will disappear if released. <br><br>Do you wish to proceed?

        public override void Confirm(Mobile from)
        {
            if (m_Item == null || m_Item.Deleted)
            {
                return;
            }

            BaseCreature summon = m_Item.Summon;

            if (summon != null)
            {
                if (!summon.SetControlMaster(from))
                {
                    summon.Delete();
                }
                else
                {
                    summon.MoveToWorld(from.Location, from.Map);
                    summon.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502799, from.NetState); // It seems to accept you as master.

                    summon.IsBonded = true;
                    from.SendLocalizedMessage(1049666); // Your pet has bonded with you!

                    summon.Skills.Wrestling.Base   = 100;
                    summon.Skills.Tactics.Base     = 100;
                    summon.Skills.MagicResist.Base = 100;
                    summon.Skills.Anatomy.Base     = 100;

                    PetTrainingHelper.GetAbilityProfile(summon, true).OnTame();

                    Effects.PlaySound(summon.Location, summon.Map, summon.BaseSoundID);
                    Effects.SendLocationParticles(EffectItem.Create(summon.Location, summon.Map, EffectItem.DefaultDuration), 0x3728, 1, 10, 0x26B6);

                    m_Item.Release(from, summon);
                    m_Item.Delete();
                }
            }
        }
Esempio n. 16
0
        public static bool CheckThinkTrigger(BaseCreature bc)
        {
            AbilityProfile profile = PetTrainingHelper.GetAbilityProfile(bc);

            if (profile != null)
            {
                AreaEffect effect = null;

                List <AreaEffect> list = new List <AreaEffect>();

                var af = profile.GetAreaEffects();

                for (var index = 0; index < af.Length; index++)
                {
                    var a = af[index];

                    if (!a.IsInCooldown(bc))
                    {
                        list.Add(a);
                    }
                }

                AreaEffect[] effects = list.ToArray();

                if (effects.Length > 0)
                {
                    effect = effects[Utility.Random(effects.Length)];
                }

                if (effect != null)
                {
                    return(effect.Trigger(bc, bc.Combatant as Mobile));
                }
            }

            return(false);
        }
Esempio n. 17
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            if (version < 2 && Controlled && RawStr >= 300 && ControlSlots == ControlSlotsMin)
            {
                Server.SkillHandlers.AnimalTaming.ScaleStats(this, 0.5);
            }

            if (PetTrainingHelper.Enabled && version == 2)
            {
                if (version < 1 && PetTrainingHelper.Enabled && ControlSlots <= 3)
                {
                    var profile = PetTrainingHelper.GetAbilityProfile(this);

                    if (profile == null || !profile.HasCustomized())
                    {
                        MinTameSkill    = 98.7;
                        ControlSlotsMin = 1;
                        ControlSlots    = 1;
                    }

                    if ((ControlMaster != null || IsStabled) && Int < 500)
                    {
                        SetInt(500);
                    }
                }
            }

            if (version == 0)
            {
                Hue = 0x489;
            }
        }
Esempio n. 18
0
                protected override void OnTick()
                {
                    m_Count++;

                    DamageEntry de           = m_Creature.FindMostRecentDamageEntry(false);
                    bool        alreadyOwned = m_Creature.Owners.Contains(m_Tamer);

                    if (!m_Tamer.InRange(m_Creature, Core.AOS ? 7 : 6))
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502795, m_Tamer.NetState);
                        // You are too far away to continue taming.
                        Stop();
                    }
                    else if (!m_Tamer.CheckAlive())
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502796, m_Tamer.NetState);
                        // You are dead, and cannot continue taming.
                        Stop();
                    }
                    else if (!m_Tamer.CanSee(m_Creature) || !m_Tamer.InLOS(m_Creature) || !CanPath())
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_Tamer.SendLocalizedMessage(1049654);
                        // You do not have a clear path to the animal you are taming, and must cease your attempt.
                        Stop();
                    }
                    else if (!m_Creature.Tamable)
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1049655, m_Tamer.NetState);
                        // That creature cannot be tamed.
                        Stop();
                    }
                    else if (m_Creature.Controlled)
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502804, m_Tamer.NetState);
                        // That animal looks tame already.
                        Stop();
                    }
                    else if (m_Creature.Owners.Count >= BaseCreature.MaxOwners && !m_Creature.Owners.Contains(m_Tamer))
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1005615, m_Tamer.NetState);
                        // This animal has had too many owners and is too upset for you to tame.
                        Stop();
                    }
                    else if (MustBeSubdued(m_Creature))
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1054025, m_Tamer.NetState);
                        // You must subdue this creature before you can tame it!
                        Stop();
                    }
                    else if (de != null && de.LastDamage > m_StartTime)
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502794, m_Tamer.NetState);
                        // The animal is too angry to continue taming.
                        Stop();
                    }
                    else if (m_Count < m_MaxCount)
                    {
                        m_Tamer.RevealingAction();

                        switch (Utility.Random(3))
                        {
                        case 0:
                            m_Tamer.PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(502790, 4));
                            break;

                        case 1:
                            m_Tamer.PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(1005608, 6));
                            break;

                        case 2:
                            m_Tamer.PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(1010593, 4));
                            break;
                        }

                        if (!alreadyOwned)                         // Passively check animal lore for gain
                        {
                            m_Tamer.CheckTargetSkill(SkillName.AnimalLore, m_Creature, 0.0, 120.0);
                        }

                        if (m_Creature.Paralyzed)
                        {
                            m_Paralyzed = true;
                        }
                    }
                    else
                    {
                        m_Tamer.RevealingAction();
                        m_Tamer.NextSkillTime = Core.TickCount;
                        m_BeingTamed.Remove(m_Creature);

                        if (m_Creature.Paralyzed)
                        {
                            m_Paralyzed = true;
                        }

                        if (!alreadyOwned)                         // Passively check animal lore for gain
                        {
                            m_Tamer.CheckTargetSkill(SkillName.AnimalLore, m_Creature, 0.0, 120.0);
                        }

                        double minSkill = m_Creature.CurrentTameSkill + (m_Creature.Owners.Count * 6.0);

                        if (minSkill > -24.9 && CheckMastery(m_Tamer, m_Creature))
                        {
                            minSkill = -24.9;                             // 50% at 0.0?
                        }

                        minSkill += 24.9;

                        if (CheckMastery(m_Tamer, m_Creature) || alreadyOwned ||
                            m_Tamer.CheckTargetSkill(SkillName.AnimalTaming, m_Creature, minSkill - 25.0, minSkill + 25.0))
                        {
                            if (m_Creature.Owners.Count == 0) // First tame
                            {
                                if (m_Creature is GreaterDragon)
                                {
                                    ScaleSkills(m_Creature, 0.72, 0.90); // 72% of original skills trainable to 90%
                                    m_Creature.Skills[SkillName.Magery].Base = m_Creature.Skills[SkillName.Magery].Cap;
                                    // Greater dragons have a 90% cap reduction and 90% skill reduction on magery
                                }
                                else if (m_Paralyzed)
                                {
                                    ScaleSkills(m_Creature, 0.86); // 86% of original skills if they were paralyzed during the taming
                                }
                                else
                                {
                                    ScaleSkills(m_Creature, 0.90); // 90% of original skills
                                }
                            }
                            else
                            {
                                ScaleSkills(m_Creature, 0.90); // 90% of original skills
                            }

                            if (alreadyOwned)
                            {
                                m_Tamer.SendLocalizedMessage(502797);                                 // That wasn't even challenging.
                            }
                            else
                            {
                                m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502799, m_Tamer.NetState);
                                // It seems to accept you as master.
                            }

                            m_Creature.SetControlMaster(m_Tamer);
                            m_Creature.IsBonded = false;

                            m_Creature.OnAfterTame(m_Tamer);

                            if (!m_Creature.Owners.Contains(m_Tamer))
                            {
                                m_Creature.Owners.Add(m_Tamer);
                            }

                            PetTrainingHelper.GetAbilityProfile(m_Creature, true).OnTame();
                        }
                        else
                        {
                            m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502798, m_Tamer.NetState);
                            // You fail to tame the creature.
                        }
                    }
                }
Esempio n. 19
0
        public static bool CheckCombatTrigger(Mobile attacker, Mobile defender, ref int damage, DamageType type)
        {
            if (defender == null)
            {
                return(false);
            }

            if (attacker is BaseCreature && !((BaseCreature)attacker).Summoned)
            {
                var bc      = attacker as BaseCreature;
                var profile = PetTrainingHelper.GetAbilityProfile(bc);

                if (profile != null)
                {
                    SpecialAbility ability = null;

                    var abilties = profile.EnumerateSpecialAbilities().Where(m =>
                                                                             (type == DamageType.Melee && m.TriggerOnDoMeleeDamage) || (type >= DamageType.Spell && m.TriggerOnDoSpellDamage) &&
                                                                             !m.IsInCooldown(attacker)).ToArray();

                    if (abilties != null && abilties.Length > 0)
                    {
                        ability = abilties[Utility.Random(abilties.Length)];
                    }

                    if (ability != null)
                    {
                        return(ability.Trigger(bc, defender, ref damage));
                    }
                }

                return(false);
            }

            if (defender is BaseCreature && !((BaseCreature)defender).Summoned)
            {
                var bc      = defender as BaseCreature;
                var profile = PetTrainingHelper.GetAbilityProfile(bc);

                if (profile != null)
                {
                    SpecialAbility ability = null;

                    var abilties = profile.EnumerateSpecialAbilities().Where(m =>
                                                                             (type == DamageType.Melee && m.TriggerOnGotMeleeDamage) || (type >= DamageType.Spell && m.TriggerOnGotSpellDamage) &&
                                                                             !m.IsInCooldown(attacker)).ToArray();

                    if (abilties != null && abilties.Length > 0)
                    {
                        ability = abilties[Utility.Random(abilties.Length)];
                    }

                    if (ability != null)
                    {
                        int d = 0;
                        return(ability.Trigger(bc, attacker, ref d));
                    }
                }
            }

            return(false);
        }