Example #1
0
        public override void OnRemoved(IEntity parent)
        {
            base.OnRemoved(parent);

            if (parent is Mobile m)
            {
                AnimalForm.RemoveContext(m, true);
            }
        }
Example #2
0
        public override void OnRemoved(object parent)
        {
            base.OnRemoved(parent);

            if (parent is Mobile)
            {
                Mobile m = (Mobile)parent;

                AnimalForm.RemoveContext(m, true);
            }
        }
Example #3
0
        public override void OnDelete()
        {
            base.OnDelete();

            if (Parent is Mobile)
            {
                Mobile m = (Mobile)Parent;

                AnimalForm.RemoveContext(m, true);
            }
        }
Example #4
0
        public static readonly TimeSpan BlockMountDuration = TimeSpan.FromSeconds(10.0);           // TODO: Taken from bola script, needs to be verified

        public override void OnHit(Mobile attacker, Mobile defender, int damage)
        {
            if (!defender.Mounted && !AnimalForm.UnderTransformation(defender) && !defender.Flying)
            {
                attacker.SendLocalizedMessage(1060848);                   // This attack only works on mounted or flying targets
                ClearCurrentAbility(attacker);
                return;
            }

            if (!Validate(attacker) || !CheckMana(attacker, true))
            {
                return;
            }

            ClearCurrentAbility(attacker);

            IMount mount = defender.Mount;

            if (!attacker.Mounted)
            {
                defender.FixedParticles(0x376A, 9, 32, 0x13AF, 0, 0, EffectLayer.RightFoot);

                if (mount != null)
                {
                    mount.Rider = null;
                }
                else if (defender.Flying)
                {
                    defender.Flying = false;
                }
                else
                {
                    AnimalForm.RemoveContext(defender, true);
                }

                if (mount is Mobile)
                {
                    Mobile m = (Mobile)mount;

                    AOS.Damage(m, attacker, (int)(0.4 * m.Hits), 100, 0, 0, 0, 0);
                }
            }
            else
            {
                int amount = 10 + (int)(10.0 * (attacker.Skills[SkillName.Bushido].Value - 50.0) / 70.0 + 5);

                AOS.Damage(defender, attacker, amount, 100, 0, 0, 0, 0);

                ParalyzingBlow pb = new ParalyzingBlow();
                pb.IsBladeweaveAttack = true;
                pb.OnHit(attacker, defender, damage);
            }
        }
Example #5
0
        public void CheckCancelMorph(Mobile m)
        {
            if (m == null)
            {
                return;
            }

            double minSkill, maxSkill;

            AnimalFormContext acontext = AnimalForm.GetContext(m);
            TransformContext  context  = TransformationSpellHelper.GetContext(m);

            if (context != null)
            {
                Spell spell = context.Spell as Spell;
                spell.GetCastSkills(out minSkill, out maxSkill);
                if (m.Skills[spell.CastSkill].Value < minSkill)
                {
                    TransformationSpellHelper.RemoveContext(m, context, true);
                }
            }
            if (acontext != null)
            {
                int i;
                for (i = 0; i < AnimalForm.Entries.Length; ++i)
                {
                    if (AnimalForm.Entries[i].Type == acontext.Type)
                    {
                        break;
                    }
                }
                if (m.Skills[SkillName.Ninjitsu].Value < AnimalForm.Entries[i].ReqSkill)
                {
                    AnimalForm.RemoveContext(m, true);
                }
            }
            if (!m.CanBeginAction(typeof(PolymorphSpell)) && m.Skills[SkillName.Magery].Value < 66.1)
            {
                m.BodyMod = 0;
                m.HueMod  = -1;
                m.NameMod = null;
                m.EndAction(typeof(PolymorphSpell));
                BaseArmor.ValidateMobile(m);
                BaseClothing.ValidateMobile(m);
            }
            if (!m.CanBeginAction(typeof(IncognitoSpell)) && m.Skills[SkillName.Magery].Value < 38.1)
            {
                if (m is PlayerMobile)
                {
                    ((PlayerMobile)m).SetHairMods(-1, -1);
                }
                m.BodyMod = 0;
                m.HueMod  = -1;
                m.NameMod = null;
                m.EndAction(typeof(IncognitoSpell));
                BaseArmor.ValidateMobile(m);
                BaseClothing.ValidateMobile(m);
                BuffInfo.RemoveBuff(m, BuffIcon.Incognito);
            }
            return;
        }
Example #6
0
        public override void OnCast()
        {
            if (!Caster.CanBeginAction(typeof(PolymorphSpell)))
            {
                Caster.SendLocalizedMessage(1061628); // You can't do that while polymorphed.
            }
            else if (TransformationSpellHelper.UnderTransformation(Caster))
            {
                Caster.SendLocalizedMessage(1063219); // You cannot mimic an animal while in that form.
            }
            else if (!Caster.CanBeginAction(typeof(IncognitoSpell)) || (Caster.IsBodyMod && AnimalForm.GetContext(Caster) == null))
            {
                DoFizzle();
            }
            else if (CheckSequence())
            {
                AnimalFormContext context = AnimalForm.GetContext(Caster);
                int mana = ScaleMana(RequiredMana);

                Ninjitsu.AnimalForm.AddLastAnimalForm(Caster, 16);

                if (mana > Caster.Mana)
                {
                    Caster.SendLocalizedMessage(1060174, mana.ToString()); // You must have at least ~1_MANA_REQUIREMENT~ Mana to use this ability.
                }
                else if (context != null)
                {
                    AnimalForm.RemoveContext(Caster, context, true);
                    Caster.Mana -= mana;

                    BuffInfo.RemoveBuff(Caster, BuffIcon.WhiteTigerForm);
                    return;
                }
                else
                {
                    double ninjitsu = Caster.Skills.Ninjitsu.Value;

                    if (ninjitsu < RequiredSkill + 37.5)
                    {
                        double chance = (ninjitsu - RequiredSkill) / 37.5;

                        if (chance < Utility.RandomDouble())
                        {
                            DoFizzle();
                            return;
                        }
                    }
                }

                Caster.FixedParticles(0x3728, 10, 13, 2023, EffectLayer.Waist);
                Caster.Mana -= mana;

                Caster.CheckSkill(SkillName.Ninjitsu, 0.0, 90.0);

                BaseMount.BaseDismount(Caster);

                int bodyMod = Caster.Female ? 1255 : 1254;
                int hueMod  = 2500;

                Caster.BodyMod = bodyMod;
                Caster.HueMod  = hueMod;

                Caster.SendSpeedControl(SpeedControlType.MountSpeed);

                Timer timer = new AnimalFormTimer(Caster, bodyMod, hueMod);
                timer.Start();

                int skills = (int)((Caster.Skills[CastSkill].Value + Caster.Skills[DamageSkill].Value + (GetMasteryLevel() * 40)) / 3);

                AnimalForm.AddContext(Caster, new AnimalFormContext(timer, null, true, typeof(WildWhiteTiger), null));
                Caster.CheckStatTimers();

                int bleedMod = (int)(((Caster.Skills[SkillName.Ninjitsu].Value + Caster.Skills[SkillName.Stealth].Value + (GetMasteryLevel() * 40)) / 3) / 10);
                BuffInfo.AddBuff(Caster, new BuffInfo(BuffIcon.WhiteTigerForm, 1155911, 1156060, string.Format("{0}\t{1}\t{2}\t{3}", "20", "5", "", bleedMod.ToString())));
                // +~1_ARG~ Defense Chance Increase.<br>+~2_ARG~ Max Defense Chance Increase Cap.<br> Chance to evade attacks.<br>Applies bleed to victim with a max damage of ~4_ARG~.

                Caster.Delta(MobileDelta.WeaponDamage);
            }

            FinishSequence();
        }
Example #7
0
        private static void FinishThrow(object state)
        {
            object[] states = (object[])state;

            Mobile from = (Mobile)states[0];
            Mobile to   = (Mobile)states[1];
            Item   bola = (Item)states[2];

            if (!from.Alive)
            {
                return;
            }
            if (!bola.IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1040019);                   // The bola must be in your pack to use it.
            }
            else if (!from.InRange(to, 15) || !from.InLOS(to) || !from.CanSee(to))
            {
                from.SendLocalizedMessage(1042060);                   // You cannot see that target!
            }
            else if (!to.Mounted && !to.Flying && !AnimalForm.UnderTransformation(to))
            {
                from.SendLocalizedMessage(1049628);                   // You have no reason to throw a bola at that.
            }
            else
            {
                bola.Consume();

                from.Direction = from.GetDirectionTo(to);
                from.Animate(11, 5, 1, true, false, 0);
                from.MovingEffect(to, 0x26AC, 10, 0, false, false);

                new Bola().MoveToWorld(to.Location, to.Map);

                to.Damage(1, from);

                if (to is Neira || to is ChaosDragoon || to is ChaosDragoonElite)
                {
                    from.SendLocalizedMessage(1042047);                       // You fail to knock the rider from its mount.
                }
                else
                {
                    if (from.Flying)
                    {
                        to.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1113590, from.Name);                           // You have been grounded by ~1_NAME~!
                    }
                    else
                    {
                        to.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1049623, from.Name);                           // You have been knocked off of your mount by ~1_NAME~!
                    }
                    BaseMount.Dismount(to);

                    if (AnimalForm.UnderTransformation(to))
                    {
                        AnimalForm.RemoveContext(to, true);
                    }

                    to.Flying = false;

                    BaseMount.SetMountPrevention(to, BlockMountType.Dazed, TimeSpan.FromSeconds(10.0));
                }
            }
        }
Example #8
0
        public static void Dismount(Mobile dismounter, Mobile dismounted, BlockMountType blockmounttype, TimeSpan delay, bool message)
        {
            if (Core.ML && AnimalForm.UnderTransformation(dismounted))
            {
                AnimalForm.RemoveContext(dismounted, true);
                if (dismounted.Player)
                {
                    dismounted.SendLocalizedMessage(1114066, dismounter.Name); // ~1_NAME~ knocked you out of animal form!
                }
            }
            else
            {
                if (!dismounted.Mounted)
                {
                    return;
                }

                if (dismounted is Neira || dismounted is ChaosDragoon || dismounted is ChaosDragoonElite)
                {
                    if (dismounter.Player)
                    {
                        dismounter.SendLocalizedMessage(1042047); // You fail to knock the rider from its mount.
                    }
                    return;
                }

                IMount mount = dismounted.Mount;

                if (mount != null)
                {
                    if (dismounter is PlayerMobile)
                    {
                        dismounter.SendLocalizedMessage(1060082); // The force of your attack has dislodged them from their mount!
                        ((PlayerMobile)dismounter).SetMountBlock(BlockMountType.DismountRecovery, TimeSpan.FromSeconds(Core.TOL && dismounter.Weapon is BaseRanged ? 8 : 10), false);
                    }

                    mount.Rider = null;

                    new BaseMount.DespawnTimer(mount, TimeSpan.FromMinutes(1.0)).Start();
                    if (mount is Mobile newMob)
                    {
                        // if (dismounter.Aggressor) newMob.Aggressed = dismounter;
                        newMob?.Attack(dismounter);
                    }

                    if (message)
                    {
                        if (dismounted.Flying)
                        {
                            if (dismounted.Player)
                            {
                                dismounted.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1113590, dismounter.Name); // You have been grounded by ~1_NAME~!
                            }
                            if (!BaseMount.OnFlightPath(dismounted))
                            {
                                dismounted.Flying = false;
                                dismounted.Freeze(TimeSpan.FromSeconds(1));
                                dismounted.Animate(AnimationType.Land, 0);
                                BuffInfo.RemoveBuff(dismounted, BuffIcon.Fly);
                            }
                        }
                        else
                        {
                            // defender.SendLocalizedMessage(1060083); // You fall off of your mount and take damage!
                            if (dismounted.Player)
                            {
                                dismounted.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1049623, dismounter.Name); // You have been knocked off of your mount by ~1_NAME~!
                            }
                        }
                    }

                    if (Core.ML)
                    {
                        if (dismounter is BaseCreature)
                        {
                            BaseCreature bc = dismounter as BaseCreature;

                            if (bc.ControlMaster is PlayerMobile)
                            {
                                PlayerMobile pm = bc.ControlMaster as PlayerMobile;
                                pm.SetMountBlock(BlockMountType.DismountRecovery, TimeSpan.FromSeconds(10.0), false);
                            }
                        }
                    }

                    if (delay != TimeSpan.MinValue)
                    {
                        BaseMount.SetMountPrevention(dismounted, mount, blockmounttype, delay);
                    }
                }
            }
        }
Example #9
0
        public override void OnHit(Mobile attacker, Mobile defender, int damage)
        {
            if (!Validate(attacker) || !CheckMana(attacker, true))
            {
                return;
            }

            ClearCurrentAbility(attacker);

            if (AnimalForm.UnderTransformation(attacker))
            {
                attacker.SendLocalizedMessage(1063024);                   // You cannot perform this special move right now.
                return;
            }

            if (!attacker.Flying && (defender.Mounted || defender.Flying || AnimalForm.UnderTransformation(defender)))
            {
                attacker.SendLocalizedMessage(1060082);                   // The force of your attack has dislodged them from their mount!
                defender.SendLocalizedMessage(1060083);                   // You fall off of your mount and take damage!

                defender.PlaySound(0x140);
                defender.FixedParticles(0x3728, 10, 15, 9955, EffectLayer.Waist);

                IMount mount = defender.Mount;

                if (mount != null)
                {
                    mount.Rider = null;
                }
                else if (defender.Flying)
                {
                    defender.Flying = false;
                }
                else
                {
                    AnimalForm.RemoveContext(defender, true);
                }

                BaseMount.SetMountPrevention(defender, BlockMountType.Dazed, DefenderRemountDelay);
                BaseMount.SetMountPrevention(attacker, BlockMountType.DismountRecovery, AttackerRemountDelay);

                AOS.Damage(defender, attacker, Utility.RandomMinMax(15, 25), 100, 0, 0, 0, 0);
            }
            else
            {
                if (!Items.ParalyzingBlow.IsInmune(defender))
                {
                    attacker.SendLocalizedMessage(1060163);                       // You deliver a paralyzing blow!
                    defender.SendLocalizedMessage(1072221);                       // You have been hit by a paralyzing blow!

                    defender.Freeze(TimeSpan.FromSeconds(2.0));

                    Items.ParalyzingBlow.BeginInmunity(defender);
                }
                else
                {
                    attacker.SendLocalizedMessage(1070804);                       // Your target resists paralysis.
                    defender.SendLocalizedMessage(1070813);                       // You resist paralysis.
                }

                defender.FixedEffect(0x376A, 9, 32);
                defender.PlaySound(0x204);
            }
        }
Example #10
0
        public static void NegateEffects(Mobile target, bool curses, bool buffs, bool damage, bool morph)
        {
            if (target == null)
            {
                return;
            }

            if (damage)
            {
                if (target.Poisoned)
                {
                    var p = target.Poison;

                    target.Poison = null;

                    target.OnCured(target, p);
                }

                target.Frozen    = false;
                target.Paralyzed = false;

                target.SetPropertyValue("Asleep", false);

                BuffInfo.RemoveBuff(target, BuffIcon.Paralyze);
                BuffInfo.RemoveBuff(target, BuffIcon.Sleep);
            }

            if (buffs)
            {
                ReactiveArmorSpell.EndArmor(target);
                MagicReflectSpell.EndReflect(target);
            }

            if (curses)
            {
                #region Pain Spike
                IDictionary table;

                if (typeof(PainSpikeSpell).GetFieldValue("m_Table", out table) && table.Contains(target))
                {
                    var t = table[target] as Timer;

                    if (t != null)
                    {
                        t.Stop();
                    }

                    table.Remove(target);

                    BuffInfo.RemoveBuff(target, BuffIcon.PainSpike);
                }
                #endregion

                CurseSpell.RemoveEffect(target);
                EvilOmenSpell.TryEndEffect(target);
                StrangleSpell.RemoveCurse(target);
                CorpseSkinSpell.RemoveCurse(target);
                BloodOathSpell.RemoveCurse(target);
                MindRotSpell.ClearMindRotScalar(target);
            }

            if (damage)
            {
                MortalStrike.EndWound(target);
                BleedAttack.EndBleed(target, target.Alive);
                MeerMage.StopEffect(target, target.Alive);
            }

            if (morph)
            {
                AnimalForm.RemoveContext(target, true);

                PolymorphSpell.StopTimer(target);
                IncognitoSpell.StopTimer(target);

                target.Send(SpeedControl.Disable);

                target.EndAction(typeof(PolymorphSpell));
                target.EndAction(typeof(IncognitoSpell));

                BuffInfo.RemoveBuff(target, BuffIcon.AnimalForm);
                BuffInfo.RemoveBuff(target, BuffIcon.Polymorph);
                BuffInfo.RemoveBuff(target, BuffIcon.Incognito);
            }

            if (buffs)
            {
                RemoveStatBonus(target, StatType.All);
            }

            if (curses)
            {
                RemoveStatCurse(target, StatType.All);
            }
        }
Example #11
0
        public override void OnHit(Mobile attacker, Mobile defender, int damage)
        {
            if (attacker is LesserHiryu && 0.2 < Utility.RandomDouble())
            {
                return;
            }

            if (!Validate(attacker))
            {
                return;
            }

            if (attacker.Mounted && !(defender.Weapon is Lance))                 // TODO: Should there be a message here?
            {
                return;
            }

            ClearCurrentAbility(attacker);

            if (defender is Neira || defender is ChaosDragoonElite)
            {
                attacker.SendLocalizedMessage(1042047);                   // You fail to knock the rider from its mount.
                return;
            }

            if (AnimalForm.UnderTransformation(attacker))
            {
                attacker.SendLocalizedMessage(1070902);                   // You can't use this while in an animal form!
                return;
            }

            IMount mount = defender.Mount;

            if (mount == null && !AnimalForm.UnderTransformation(defender) && !defender.Flying)
            {
                attacker.SendLocalizedMessage(1060848);                   // This attack only works on mounted or flying targets
                return;
            }

            if (!CheckMana(attacker, true))
            {
                return;
            }

            attacker.SendLocalizedMessage(1060082);               // The force of your attack has dislodged them from their mount!

            if (attacker.Mounted)
            {
                defender.SendLocalizedMessage(1062315);                   // You fall off your mount!
            }
            else
            {
                defender.SendLocalizedMessage(1060083);                   // You fall off of your mount and take damage!
            }
            defender.PlaySound(0x140);
            defender.FixedParticles(0x3728, 10, 15, 9955, EffectLayer.Waist);

            if (mount != null)
            {
                mount.Rider = null;
            }
            else if (defender.Flying)
            {
                defender.Flying = false;
            }
            else
            {
                AnimalForm.RemoveContext(defender, true);
            }

            BaseMount.SetMountPrevention(defender, BlockMountType.Dazed, DefenderRemountDelay);
            BaseMount.SetMountPrevention(attacker, BlockMountType.DismountRecovery, AttackerRemountDelay);

            if (!attacker.Mounted)
            {
                AOS.Damage(defender, attacker, Utility.RandomMinMax(15, 25), 100, 0, 0, 0, 0);
            }
        }
Example #12
0
        public void Target(IPoint3D p)
        {
            if (!Caster.CanSee(p))
            {
                Caster.SendLocalizedMessage(500237);                   // Target can not be seen.
            }
            else if (CheckSequence())
            {
                SpellHelper.Turn(Caster, p);

                SpellHelper.GetSurfaceTop(ref p);

                List <Mobile> targets = new List <Mobile>();

                Map map = Caster.Map;

                if (map != null)
                {
                    IPooledEnumerable eable = map.GetMobilesInRange(new Point3D(p), 8);

                    foreach (Mobile m in eable)
                    {
                        if ((m is BaseCreature) && (m as BaseCreature).IsDispellable && Caster.CanBeHarmful(m, false) ||
                            TransformationSpellHelper.UnderTransformation(m) || !m.CanBeginAction(typeof(PolymorphSpell)) ||
                            AnimalForm.UnderTransformation(Caster) || (TransformationSpellHelper.GetContext(m) != null))
                        {
                            targets.Add(m);
                        }
                    }

                    eable.Free();
                }

                for (int i = 0; i < targets.Count; ++i)
                {
                    Mobile m = targets[i];

                    BaseCreature bc = m as BaseCreature;
                    if (TransformationSpellHelper.UnderTransformation(m))
                    {
                        double dispelChance = Math.Pow((((Caster.Hunger + Caster.Thirst) / 2 + Caster.Skills.Magery.Value) /
                                                        ((m.Hunger - m.Thirst) / 2 + m.Skills.Necromancy.Value + m.Skills.MagicResist.Value + 1)), 4) / 2;
                        if (dispelChance < 0)
                        {
                            dispelChance = 0.01;
                        }
                        if (dispelChance > 1)
                        {
                            dispelChance = 1;
                        }
                        if (dispelChance > Utility.RandomDouble())
                        {
                            Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, 5042);
                            Effects.PlaySound(m, m.Map, 0x201);
                            Caster.DoHarmful(m);
                            TransformationSpellHelper.RemoveContext(m, true);
                        }
                        else
                        {
                            m.FixedEffect(0x3779, 10, 20);
                            Caster.SendLocalizedMessage(1010084); // The creature resisted the attempt to dispel it!
                            Caster.DoHarmful(m);
                        }
                    }
                    else if (!m.CanBeginAction(typeof(PolymorphSpell)))
                    {
                        double dispelChance = Math.Pow((((Caster.Hunger + Caster.Thirst) / 2 + Caster.Skills.Magery.Value) /
                                                        ((m.Hunger - m.Thirst) / 2 + m.Skills.Magery.Value + m.Skills.MagicResist.Value + 1)), 4) / 2;
                        if (dispelChance < 0)
                        {
                            dispelChance = 0.01;
                        }
                        if (dispelChance > 1)
                        {
                            dispelChance = 1;
                        }
                        if (dispelChance > Utility.RandomDouble())
                        {
                            Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, 5042);
                            Effects.PlaySound(m, m.Map, 0x201);
                            PolymorphSpell.EndPolymorph(m);
                            //TransformationSpellHelper.RemoveContext(m, true);
                            Caster.DoHarmful(m);
                        }
                        else
                        {
                            Caster.DoHarmful(m);
                            m.FixedEffect(0x3779, 10, 20);
                            Caster.SendLocalizedMessage(1010084); // The creature resisted the attempt to dispel it!
                        }
                    }
                    else if (AnimalForm.UnderTransformation(Caster))
                    {
                        double dispelChance = Math.Pow((((Caster.Hunger + Caster.Thirst) / 2 + Caster.Skills.Magery.Value) /
                                                        ((m.Hunger - m.Thirst) / 2 + m.Skills.Ninjitsu.Value + m.Skills.MagicResist.Value + 1)), 4) / 2;
                        if (dispelChance < 0)
                        {
                            dispelChance = 0.01;
                        }
                        if (dispelChance > 1)
                        {
                            dispelChance = 1;
                        }
                        if (dispelChance > Utility.RandomDouble())
                        {
                            Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, 5042);
                            Effects.PlaySound(m, m.Map, 0x201);
                            AnimalForm.RemoveContext(m, true);
                            Caster.DoHarmful(m);
                        }
                        else
                        {
                            Caster.DoHarmful(m);
                            m.FixedEffect(0x3779, 10, 20);
                            Caster.SendLocalizedMessage(1010084); // The creature resisted the attempt to dispel it!
                        }
                    }
                    else if (TransformationSpellHelper.GetContext(m) != null)
                    {
                        double dispelChance = Math.Pow((((Caster.Hunger + Caster.Thirst) / 2 + Caster.Skills.Magery.Value) /
                                                        ((m.Hunger - m.Thirst) / 2 + m.Skills.Spellweaving.Value + m.Skills.MagicResist.Value + 1)), 4) / 2;
                        if (dispelChance < 0)
                        {
                            dispelChance = 0.01;
                        }
                        if (dispelChance > 1)
                        {
                            dispelChance = 1;
                        }
                        if (dispelChance > Utility.RandomDouble())
                        {
                            Caster.DoHarmful(m);
                            Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, 5042);
                            Effects.PlaySound(m, m.Map, 0x201);
                            TransformationSpellHelper.RemoveContext(m, true);
                        }
                        else
                        {
                            Caster.DoHarmful(m);
                            m.FixedEffect(0x3779, 10, 20);
                            Caster.SendLocalizedMessage(1010084); // The creature resisted the attempt to dispel it!
                        }
                    }
                    else
                    {
                        if (bc == null)
                        {
                            continue;
                        }

                        double dispelChance = (50.0 + ((100 * (Caster.Skills.Magery.Value - bc.DispelDifficulty)) / (bc.DispelFocus * 2))) / 100;

                        if (dispelChance > Utility.RandomDouble())
                        {
                            Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, 5042);
                            Effects.PlaySound(m, m.Map, 0x201);

                            m.Delete();
                        }
                        else
                        {
                            Caster.DoHarmful(m);

                            m.FixedEffect(0x3779, 10, 20);
                        }
                    }
                }
            }

            FinishSequence();
        }
Example #13
0
            protected override void OnTarget(Mobile from, object o)
            {
                if (o is Mobile)
                {
                    Mobile       m  = (Mobile)o;
                    BaseCreature bc = m as BaseCreature;

                    if (!from.CanSee(m))
                    {
                        from.SendLocalizedMessage(500237);                           // Target can not be seen.
                    }
                    else if (TransformationSpellHelper.UnderTransformation(m))
                    {
                        double dispelChance = Math.Pow((((from.Hunger + from.Thirst) / 2 + from.Skills.Magery.Value) /
                                                        ((m.Hunger - m.Thirst) / 2 + m.Skills.Necromancy.Value + m.Skills.MagicResist.Value + 1)), 4) / 2;
                        if (dispelChance < 0)
                        {
                            dispelChance = 0.01;
                        }
                        if (dispelChance > 1)
                        {
                            dispelChance = 1;
                        }
                        if (dispelChance > Utility.RandomDouble())
                        {
                            Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, 5042);
                            Effects.PlaySound(m, m.Map, 0x201);
                            from.DoHarmful(m);
                            TransformationSpellHelper.RemoveContext(m, true);
                        }
                        else
                        {
                            m.FixedEffect(0x3779, 10, 20);
                            from.SendLocalizedMessage(1010084); // The creature resisted the attempt to dispel it!
                            from.DoHarmful(m);
                        }
                    }
                    else if (!m.CanBeginAction(typeof(PolymorphSpell)))
                    {
                        double dispelChance = Math.Pow((((from.Hunger + from.Thirst) / 2 + from.Skills.Magery.Value) /
                                                        ((m.Hunger - m.Thirst) / 2 + m.Skills.Magery.Value + m.Skills.MagicResist.Value + 1)), 4) / 2;
                        if (dispelChance < 0)
                        {
                            dispelChance = 0.01;
                        }
                        if (dispelChance > 1)
                        {
                            dispelChance = 1;
                        }
                        if (dispelChance > Utility.RandomDouble())
                        {
                            Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, 5042);
                            Effects.PlaySound(m, m.Map, 0x201);
                            //TransformationSpellHelper.RemoveContext(m, true);
                            PolymorphSpell.EndPolymorph(m);
                            from.DoHarmful(m);
                        }
                        else
                        {
                            m.FixedEffect(0x3779, 10, 20);
                            from.SendLocalizedMessage(1010084); // The creature resisted the attempt to dispel it!
                        }
                    }
                    else if (AnimalForm.UnderTransformation(m))
                    {
                        double dispelChance = Math.Pow((((from.Hunger + from.Thirst) / 2 + from.Skills.Magery.Value) /
                                                        ((m.Hunger - m.Thirst) / 2 + m.Skills.Ninjitsu.Value + m.Skills.MagicResist.Value + 1)), 4) / 2;
                        if (dispelChance < 0)
                        {
                            dispelChance = 0.01;
                        }
                        if (dispelChance > 1)
                        {
                            dispelChance = 1;
                        }
                        if (dispelChance > Utility.RandomDouble())
                        {
                            Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, 5042);
                            Effects.PlaySound(m, m.Map, 0x201);
                            AnimalForm.RemoveContext(m, true);
                            from.DoHarmful(m);
                        }
                        else
                        {
                            from.DoHarmful(m);
                            m.FixedEffect(0x3779, 10, 20);
                            from.SendLocalizedMessage(1010084); // The creature resisted the attempt to dispel it!
                        }
                    }
                    else if (TransformationSpellHelper.GetContext(m) != null)
                    {
                        double dispelChance = Math.Pow((((from.Hunger + from.Thirst) / 2 + from.Skills.Magery.Value) /
                                                        ((m.Hunger - m.Thirst) / 2 + m.Skills.Spellweaving.Value + m.Skills.MagicResist.Value + 1)), 4) / 2;
                        if (dispelChance < 0)
                        {
                            dispelChance = 0.01;
                        }
                        if (dispelChance > 1)
                        {
                            dispelChance = 1;
                        }
                        if (dispelChance > Utility.RandomDouble())
                        {
                            from.DoHarmful(m);
                            Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, 5042);
                            Effects.PlaySound(m, m.Map, 0x201);
                            TransformationSpellHelper.RemoveContext(m, true);
                        }
                        else
                        {
                            from.DoHarmful(m);
                            m.FixedEffect(0x3779, 10, 20);
                            from.SendLocalizedMessage(1010084); // The creature resisted the attempt to dispel it!
                        }
                    }
                    else if (bc == null || !bc.IsDispellable)
                    {
                        from.SendLocalizedMessage(1005049);                           // That cannot be dispelled.
                    }
                    else if (m_Owner.CheckHSequence(m))
                    {
                        SpellHelper.Turn(from, m);

                        double dispelChance = (50.0 + ((100 * (from.Skills.Magery.Value - bc.DispelDifficulty)) / (bc.DispelFocus * 2))) / 100;

                        if (dispelChance > Utility.RandomDouble())
                        {
                            Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, 5042);
                            Effects.PlaySound(m, m.Map, 0x201);

                            m.Delete();
                        }
                        else
                        {
                            m.FixedEffect(0x3779, 10, 20);
                            from.SendLocalizedMessage(1010084);                               // The creature resisted the attempt to dispel it!
                        }
                    }
                }
            }