CanBeHarmful() public method

public CanBeHarmful ( Server.Mobile target, bool message, bool ignoreOurBlessedness ) : bool
target Server.Mobile
message bool
ignoreOurBlessedness bool
return bool
示例#1
0
        public void Provoke(Mobile target)
        {
            if (target == null || Deleted || !Alive || m_NextProvoke > DateTime.UtcNow || 0.05 < Utility.RandomDouble())
            {
                return;
            }

            foreach (Mobile m in GetMobilesInRange(RangePerception))
            {
                if (m is BaseCreature)
                {
                    BaseCreature c = (BaseCreature)m;

                    if (c == this || c == target || c.Unprovokable || c.IsParagon || c.BardProvoked ||
                        c.AccessLevel != AccessLevel.Player || !c.CanBeHarmful(target))
                    {
                        continue;
                    }

                    c.Provoke(this, target, true);

                    if (target.Player)
                    {
                        target.SendLocalizedMessage(1072062); // You hear angry music, and start to fight.
                    }
                    PlaySound(0x58A);
                    break;
                }
            }

            m_NextProvoke = DateTime.UtcNow + TimeSpan.FromSeconds(10);
        }
示例#2
0
        public void PerformAttack(Mobile attacker)
        {
            if (0.50 >= Utility.RandomDouble() && attacker is BaseCreature)
            {
                BaseCreature c = (BaseCreature)attacker;

                if (c.Controlled && (c.ControlMaster != null || c.SummonMaster != null))
                {
                    ArrayList list = new ArrayList();

                    foreach (Mobile m in this.GetMobilesInRange(10))
                    {
                        if (m != this && m.Player && m.Alive && c.CanBeHarmful(m))
                        {
                            list.Add(m);
                        }
                    }

                    if (list.Count > 0)
                    {
                        Mobile target = (Mobile)list[Utility.Random(list.Count)];

                        c.ControlTarget = target;                         //Fix an exploit where players use multiclients to help pets while the owners are not present.  Bypasses this ability completely.
                        c.ControlOrder  = OrderType.Attack;
                        c.Combatant     = target;
                        c.Controlled    = false;
                        //BaseCreature.CannotControl.Add( c );

                        Timer.DelayCall(TimeSpan.FromSeconds(7.5 + (Utility.RandomDouble() * 2.5)), new TimerStateCallback(StopCounterAttack), c);
                    }
                }
            }
        }
示例#3
0
        public void Provoke(Mobile target)
        {
            foreach (Mobile m in GetMobilesInRange(PerceptionRange))
            {
                if (m is BaseCreature)
                {
                    BaseCreature c = (BaseCreature)m;

                    if (!c.CanBeHarmful(target, false) || target == c || c.BardTarget == target)
                    {
                        continue;
                    }

                    if (Utility.RandomDouble() < 0.9)
                    {
                        c.BardMaster  = this;
                        c.BardTarget  = target;
                        c.Combatant   = target;
                        c.BardEndTime = DateTime.Now + TimeSpan.FromSeconds(30.0);

                        target.SendLocalizedMessage(1072062);                           // You hear angry music, and start to fight.
                        PlaySound(0x58A);
                    }
                    else
                    {
                        target.SendLocalizedMessage(1072063);                           // You hear angry music that fails to incite you to fight.
                        PlaySound(0x58C);
                    }

                    break;
                }
            }

            m_NextProvokeTime = DateTime.Now + TimeSpan.FromSeconds(ProvokeMinDelay + Utility.RandomDouble() * ProvokeMaxDelay);
        }
示例#4
0
        public static void IceNova_Callback(object state)
        {
            object[] states = ((object[])state);
            Aghor    ag     = states[0] as Aghor;
            Point3D  loc    = ((Point3D)states[1]);

            if (ag == null || !ag.Alive || ag.Map == Map.Internal)
            {
                return;
            }

            Effects.PlaySound(ag.Location, ag.Map, 534);

            IPooledEnumerable eable = ag.Map.GetMobilesInRange(loc, 12);

            if (eable == null)
            {
                return;
            }

            foreach (Mobile m in eable)
            {
                if (m is BaseCreature)
                {
                    BaseCreature b = m as BaseCreature;

                    if (b == null)
                    {
                        return;
                    }

                    if (b.Alive && !b.Blessed && !b.IsDeadBondedPet && b.CanBeHarmful(ag) && ((BaseCreature)ag).IsEnemy(b) && b.Map != null && b.Map != Map.Internal && b != null)
                    {
                        AOS.Damage(b, ag, Utility.RandomMinMax(100, 150), 0, 0, 100, 0, 0);
                        ag.DoFreeze(b, 20);
                    }
                }
                else if (m is PlayerMobile)
                {
                    PlayerMobile p = m as PlayerMobile;

                    if (p == null)
                    {
                        return;
                    }

                    if (p.Alive && !p.Blessed && p.AccessLevel == AccessLevel.Player && p.Map != null && p.Map != Map.Internal && p != null)
                    {
                        AOS.Damage(p, ag, Utility.RandomMinMax(50, 100), 0, 0, 100, 0, 0);
                        ag.DoFreeze(p, 3);
                    }
                }
            }
            eable.Free();
        }
示例#5
0
        public static void DetonateShipBomb(BaseCreature creature, BaseShip targetShip, Point3D location)
        {
            IEntity explosionLocation = new Entity(Serial.Zero, new Point3D(location.X, location.Y, location.Z - 1), targetShip.Map);

            Effects.SendLocationParticles(explosionLocation, Utility.RandomList(0x36BD, 0x36BF, 0x36CB, 0x36BC), 30, 7, 5044);
            Effects.PlaySound(explosionLocation, targetShip.Map, 0x11D);

            BaseShip shipAtLocation = BaseShip.FindShipAt(location, targetShip.Map);

            if (shipAtLocation != null)
            {
                int shipDamage = Utility.RandomMinMax(10, 20);

                shipAtLocation.ReceiveDamage(null, null, shipDamage, DamageType.Hull);

                int mobileDamage = Utility.RandomMinMax(10, 20);

                IPooledEnumerable eable = targetShip.Map.GetObjectsInRange(location, 1);

                foreach (object obj in eable)
                {
                    if (obj is Mobile)
                    {
                        Mobile mobile = obj as Mobile;

                        if (creature.CanBeHarmful(mobile))
                        {
                            int finalDamage = mobileDamage;

                            PlayerMobile pm_Target = mobile as PlayerMobile;

                            creature.DoHarmful(mobile);
                            AOS.Damage(mobile, creature, finalDamage, 100, 0, 0, 0, 0);
                            new Blood().MoveToWorld(mobile.Location, mobile.Map);
                        }
                    }
                }

                eable.Free();
            }
        }
示例#6
0
        public static void RoarAttack(BaseCreature from, Mobile target)
        {
            if (from.RoarAttack < 10 || from == null || target == null)
                return;

            int power = from.RoarAttack / 10;
            int mindam = from.RoarAttack / 3;
            int maxdam = from.RoarAttack / 2;
            from.Say("*Roars*");

            ArrayList targets = new ArrayList();

            foreach (Mobile m in from.GetMobilesInRange(power))
            {
                if (m != from && from.CanBeHarmful(m))
                    targets.Add(m);
            }

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

                if (m is BaseCreature)
                {
                    BaseCreature bc = (BaseCreature)m;

                   // if (bc.Controlled == true && bc.ControlMaster != null)
                       // return;//////////////////////////////////////////////////////////////////////////////
                    
                  //  else
                    
                    bc.BeginFlee(TimeSpan.FromSeconds(10.0));
                    AOS.Damage(target, from, Utility.RandomMinMax(mindam, maxdam), 100, 0, 0, 0, 0);
                }
            }
        }
        public bool UseProvocation()
        {
            if (!this.m_Mobile.UseSkill(SkillName.Provocation))
            {
                return(false);
            }
            else if (this.m_Mobile.Target != null)
            {
                this.m_Mobile.Target.Cancel(this.m_Mobile, TargetCancelType.Canceled);
            }

            Mobile target = this.m_Mobile.Combatant as Mobile;

            if (this.m_Mobile.Combatant is BaseCreature)
            {
                BaseCreature bc = this.m_Mobile.Combatant as BaseCreature;
                target = bc.GetMaster();

                if (target != null && bc.CanBeHarmful(target))
                {
                    if (this.m_Mobile.Debug)
                    {
                        this.m_Mobile.Say(1162, "Provocation: Pet to Master");
                    }

                    bc.Provoke(this.m_Mobile, target, true);
                    return(true);
                }
            }

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

            foreach (Mobile m in this.m_Mobile.GetMobilesInRange(5))
            {
                if (m != null && m is BaseCreature && m != this.m_Mobile)
                {
                    BaseCreature bc = m as BaseCreature;

                    if (this.m_Mobile.Controlled != bc.Controlled)
                    {
                        continue;
                    }

                    if (this.m_Mobile.Summoned != bc.Summoned)
                    {
                        continue;
                    }

                    list.Add(bc);
                }
            }

            if (list.Count == 0)
            {
                return(false);
            }

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].CanBeHarmful(target))
                {
                    if (this.m_Mobile.Debug)
                    {
                        this.m_Mobile.Say(1162, "Provocation: " + list[i].Name + " to " + target.Name);
                    }

                    list[i].Provoke(this.m_Mobile, target, true);
                    return(true);
                }
            }

            return(false);
        }
示例#8
0
        public void ShootWebs(BaseCreature creature)
        {
            if (creature == null)
            {
                return;
            }
            if (!creature.Alive || creature.Deleted)
            {
                return;
            }

            double minWebs = 25;
            double maxWebs = 50;

            int minRadius = 1;
            int maxRadius = 20;

            double spawnPercent = (double)intervalCount / (double)totalIntervals;
            int    websToAdd    = (int)(minWebs + ((maxWebs - minWebs) * spawnPercent));

            for (int a = 0; a < websToAdd; a++)
            {
                List <Point3D> m_ValidLocations = SpecialAbilities.GetSpawnableTiles(Location, false, true, creature.Location, creature.Map, 1, 15, minRadius, maxRadius, true);

                if (m_ValidLocations.Count > 0)
                {
                    Point3D newLocation = m_ValidLocations[Utility.RandomMinMax(0, m_ValidLocations.Count - 1)];

                    int webId = Utility.RandomList(3811, 3812, 3813, 3814, 4306, 4307, 4308, 4308);

                    IEntity startLocation = new Entity(Serial.Zero, new Point3D(creature.Location.X, creature.Location.Y, creature.Location.Z), creature.Map);
                    IEntity endLocation   = new Entity(Serial.Zero, new Point3D(newLocation.X, newLocation.Y, newLocation.Z), creature.Map);

                    Effects.PlaySound(newLocation, creature.Map, 0x4F1);
                    Effects.SendMovingEffect(startLocation, endLocation, webId, 5, 0, false, false, 0, 0);

                    double distance         = creature.GetDistanceToSqrt(newLocation);
                    double destinationDelay = (double)distance * .08;

                    Timer.DelayCall(TimeSpan.FromSeconds(destinationDelay), delegate
                    {
                        if (creature == null)
                        {
                            return;
                        }
                        if (!creature.Alive || creature.Deleted)
                        {
                            return;
                        }

                        Effects.SendLocationParticles(EffectItem.Create(newLocation, creature.Map, TimeSpan.FromSeconds(15)), webId, 5, 4000, 0, 0, 5029, 0);
                    });
                }
            }

            IPooledEnumerable eable = creature.Map.GetObjectsInRange(creature.Location, 20);

            foreach (object obj in eable)
            {
                if (obj is PlayerMobile)
                {
                    Mobile       mobile      = obj as Mobile;
                    PlayerMobile player      = obj as PlayerMobile;
                    BaseCreature bc_Creature = obj as BaseCreature;

                    if (mobile == null)
                    {
                        continue;
                    }
                    if (!mobile.Alive)
                    {
                        continue;
                    }

                    bool validTarget = false;

                    if (player != null)
                    {
                        if (player.AccessLevel == AccessLevel.Player)
                        {
                            validTarget = true;
                        }
                    }

                    if (bc_Creature != null)
                    {
                        if (bc_Creature.Controlled && bc_Creature.ControlMaster is PlayerMobile)
                        {
                            validTarget = true;
                        }
                    }

                    double mobileWebChanceMin = .4;
                    double mobileWebChanceMax = .8;

                    double chance = mobileWebChanceMin + ((mobileWebChanceMax - mobileWebChanceMin) * spawnPercent);

                    if (creature.CanBeHarmful(mobile) && validTarget && !mobile.Hidden && Utility.RandomDouble() <= chance)
                    {
                        Effects.PlaySound(mobile.Location, player.Map, 0x580);
                        SpecialAbilities.HinderSpecialAbility(1.0, creature, mobile, 1.0, Utility.RandomMinMax(4, 8), false, -1, false, "", "You have been wrapped in a web!", "-1");

                        int webId = Utility.RandomList(3811, 3812, 3813, 3814, 4306, 4307, 4308, 4308);

                        IEntity startLocation = new Entity(Serial.Zero, new Point3D(creature.Location.X, creature.Location.Y, creature.Location.Z), creature.Map);
                        IEntity endLocation   = new Entity(Serial.Zero, new Point3D(mobile.X, mobile.Y, mobile.Z), creature.Map);

                        Effects.SendMovingEffect(startLocation, endLocation, webId, 5, 0, false, false, 0, 0);

                        double distance         = creature.GetDistanceToSqrt(mobile.Location);
                        double destinationDelay = (double)distance * .08;

                        Timer.DelayCall(TimeSpan.FromSeconds(destinationDelay), delegate
                        {
                            if (mobile == null || creature == null)
                            {
                                return;
                            }
                            if (!mobile.Alive || mobile.Deleted || !creature.Alive || creature.Deleted)
                            {
                                return;
                            }

                            Effects.SendLocationParticles(EffectItem.Create(mobile.Location, creature.Map, TimeSpan.FromSeconds(10)), webId, 0, 125, 0, 0, 5029, 0);
                        });
                    }
                }
            }

            eable.Free();
        }
示例#9
0
 private static void AttemptFireBreath(BaseCreature creature, Mobile target)
 {
     if (!creature.InLOS(target))
     {
         creature.SendMessage("Target cannot be seen.");
         return;
     }
     if (!target.InRange(creature, creature.BreathRange))
     {
         creature.SendMessage("That is too far away.");
         return;
     }
     if (target != null && target.Alive && !target.IsDeadBondedPet && creature.CanBeHarmful(target) &&
         target.Map == creature.Map && !creature.IsDeadBondedPet &&
         !creature.BardPacified)
     {
         creature.BreathStart(target);
         creature.SetNextBreathTime();
     }
     else
     {
         creature.SendMessage("You can't breathe fire on that!");
     }
 }
示例#10
0
        /// <summary>
        /// Used for second Provocation target.
        /// </summary>
        /// <param name="first"></param>
        /// <returns></returns>
        public virtual Mobile GetSecondTarget(BaseCreature first)
        {
            if (first == null)
                return null;

            int range = BaseInstrument.GetBardRange(this, SkillName.Provocation);

            IPooledEnumerable eable = this.Map.GetMobilesInRange(Location, range);
            List<Mobile> possibles = new List<Mobile>();

            foreach (Mobile m in eable)
            {
                if (m != first && m != this && first.InRange(m.Location, range))
                {
                    if (this.CanBeHarmful(m, false) && first.CanBeHarmful(m, false))
                        possibles.Add(m);
                }
            }
            eable.Free();

            Mobile t = null;

            if (possibles.Count > 0)
                t = possibles[Utility.Random(possibles.Count)];

            possibles.Clear();
            possibles.TrimExcess();

            return t;
        }
示例#11
0
        public static void DoBreathAttack(BreathAttackType breathType, BaseCreature creature, Mobile target)
        {
            if (!SpecialAbilities.Exists(creature))
            {
                return;
            }
            if (!SpecialAbilities.Exists(target))
            {
                return;
            }
            if (!creature.CanBeHarmful(target))
            {
                return;
            }

            creature.DoHarmful(target);
            creature.Direction = creature.GetDirectionTo(target);

            if (creature.IsHighSeasBodyType)
            {
                creature.Animate(Utility.RandomList(27), 5, 1, true, false, 0);
            }
            else
            {
                creature.Animate(12, 5, 1, true, false, 0);
            }

            SpecialAbilities.HinderSpecialAbility(1.0, null, creature, 1.0, 1.5, true, 0, false, "", "", "-1");

            Timer.DelayCall(TimeSpan.FromSeconds(1.3), delegate
            {
                if (!SpecialAbilities.Exists(creature))
                {
                    return;
                }

                switch (breathType)
                {
                case BreathAttackType.Fire:
                    Effects.PlaySound(creature.Location, creature.Map, 0x227);
                    Effects.SendMovingEffect(creature, target, 0x36D4, 5, 0, false, false, 0, 0);
                    break;

                case BreathAttackType.Ice:
                    Effects.PlaySound(creature.Location, creature.Map, 0x64F);
                    Effects.SendMovingEffect(creature, target, 0x36D4, 5, 0, false, false, 1153, 0);
                    break;

                case BreathAttackType.Poison:
                    Effects.PlaySound(creature.Location, creature.Map, 0x22F);
                    Effects.SendMovingEffect(creature, target, 0x372A, 10, 0, false, false, 2208, 0);
                    break;
                }

                Timer.DelayCall(TimeSpan.FromSeconds(1.0), delegate
                {
                    if (creature == null)
                    {
                        return;
                    }

                    if (creature.CanBeHarmful(target))
                    {
                        double baseDamage = (double)creature.DamageMax;

                        if (creature.Controlled && creature.ControlMaster is PlayerMobile)
                        {
                            if (target is PlayerMobile)
                            {
                                baseDamage *= BaseCreature.BreathDamageToPlayerScalar * creature.PvPAbilityDamageScalar;
                            }

                            if (target is BaseCreature)
                            {
                                baseDamage *= BaseCreature.BreathDamageToCreatureScalar;
                            }
                        }

                        switch (breathType)
                        {
                        case BreathAttackType.Fire:
                            Effects.PlaySound(target.Location, target.Map, 0x208);
                            Effects.SendLocationParticles(EffectItem.Create(target.Location, target.Map, TimeSpan.FromSeconds(0.5)), 0x3996, 10, 20, 5029);
                            break;

                        case BreathAttackType.Ice:
                            baseDamage = (double)creature.DamageMax * .75;

                            if (target is PlayerMobile)
                            {
                                SpecialAbilities.CrippleSpecialAbility(1.0, creature, target, .05, 10, -1, true, "", "The blast of ice has slowed your actions!", "-1");
                            }
                            else
                            {
                                SpecialAbilities.CrippleSpecialAbility(1.0, creature, target, .10, 10, -1, true, "", "The blast of ice has slowed your actions!", "-1");
                            }

                            Effects.PlaySound(target.Location, target.Map, 0x208);
                            Effects.SendLocationParticles(EffectItem.Create(target.Location, target.Map, TimeSpan.FromSeconds(0.25)), 0x3779, 10, 20, 1153, 0, 5029, 0);
                            break;

                        case BreathAttackType.Poison:
                            baseDamage = (double)creature.DamageMax * .5;

                            int poisonLevel = 0;

                            if (creature.HitPoison != null)
                            {
                                poisonLevel = creature.HitPoison.Level;
                            }

                            double poisonChance = 1.0;

                            if (creature.IsControlledCreature())
                            {
                                if (target is PlayerMobile)
                                {
                                    poisonChance = .5;
                                    poisonLevel--;
                                }

                                if (target is BaseCreature)
                                {
                                    BaseCreature bc_Target = target as BaseCreature;

                                    if (bc_Target.IsControlledCreature())
                                    {
                                        poisonChance = .5;
                                        poisonLevel--;
                                    }
                                }
                            }

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

                            int poisonHue = 2208;

                            poisonHue += poisonLevel;

                            if (Utility.RandomDouble() <= poisonChance)
                            {
                                Poison poison = Poison.GetPoison(poisonLevel);
                                target.ApplyPoison(target, poison);
                            }

                            Effects.PlaySound(target.Location, target.Map, 0x22F);
                            Effects.SendLocationParticles(EffectItem.Create(target.Location, target.Map, TimeSpan.FromSeconds(0.25)), 0x372A, 10, 20, poisonHue, 0, 5029, 0);
                            break;
                        }

                        int finalDamage = (int)baseDamage;

                        if (target != null)
                        {
                            AOS.Damage(target, creature, finalDamage, 100, 0, 0, 0, 0);
                        }
                    }
                });
            });
        }
示例#12
0
        public static bool ValidTarget(BaseCreature caster, Mobile m)
        {
            bool validTarget = false;

            if (m.AccessLevel > AccessLevel.Player) // can not hurt staff
                validTarget = false;
            else if (caster == null) // nobody cast the AOE, it hurts everybody
                validTarget = true;
            // player can not use this AOE
            /*
        else if (m_Caster.Player && m_Caster == m) // player can use AOE to hurt themselves under any condition
            validTarget = true;
             */
            else if (Core.AOS && caster == m) // NPC never hurt themselves with AOE in AOS context
                validTarget = false;
            else if (!caster.Controlled && !caster.Summoned)
            {   // potion thrown by a wild creature (the most typical case for now)
                if (m is BaseCreature)
                {
                    BaseCreature target = (BaseCreature)m;
                    if (target.Blessed)
                        validTarget = false; // obvious
                    else if (!target.Controlled && !target.Summoned)
                    {   // wild NPC can not hurt another wild NPC of same alliance (good can not hurt good, bad can not hurt bad, but can hurt across)
                        if (target.InitialInnocent == caster.InitialInnocent)
                            validTarget = false;
                        else
                            validTarget = true;
                    }
                    else if (!caster.InitialInnocent && ((target.Controlled && target.ControlMaster != null && target.ControlMaster.Player && !target.IsDeadPet) || (target.Summoned && target.SummonMaster != null && target.SummonMaster.Player)))
                        validTarget = true; // wild non-good NPC can always hurt player controlled/summoned NPC
                }
                else if (m.Player && !caster.InitialInnocent && !(m.AccessLevel > AccessLevel.Player && m.Hidden))
                    validTarget = true; // wild NPC of non-good alliance can always hurt a player, given it is not a hidden GM
            }
            else
                validTarget = (SpellHelper.ValidIndirectTarget(caster, m) && caster.CanBeHarmful(m, false));

            return validTarget;

        }
		public static void DoBomber(BaseCreature mobile, Mobile player)
		{
			Mobile combatant = player;

			if ( combatant == null || combatant.Deleted || combatant.Map != mobile.Map || !mobile.InRange( combatant, 12 ) || !mobile.CanBeHarmful( combatant ) || !mobile.InLOS( combatant ) )
				return;

			if ( DateTime.Now >= m_NextBomb )
			{
				ThrowBomb( combatant, player );

				m_Thrown++;

				if ( 0.75 >= Utility.RandomDouble() && (m_Thrown % 2) == 1 )
					m_NextBomb = DateTime.Now + TimeSpan.FromSeconds( 3.0 );
				else
					m_NextBomb = DateTime.Now + TimeSpan.FromSeconds( 5.0 + (10.0 * Utility.RandomDouble()) );
			}
		}
示例#14
0
        public static bool DoMeleeBleedAoE(BaseCreature creature)
        {
            if (creature == null)
            {
                return(false);
            }

            double swingCount    = 12;
            double swingInterval = .3;
            double preSwingDelay = .1;

            double hitChance = .25;

            double actionsCooldown = (swingCount * swingInterval) + (swingCount * preSwingDelay) + 1;

            if (creature.AIObject != null)
            {
                creature.AIObject.NextMove              = DateTime.UtcNow + TimeSpan.FromSeconds(actionsCooldown);
                creature.LastSwingTime                  = creature.LastSwingTime + TimeSpan.FromSeconds(actionsCooldown);
                creature.NextSpellTime                  = creature.NextSpellTime + TimeSpan.FromSeconds(actionsCooldown);
                creature.NextCombatHealActionAllowed    = creature.NextCombatHealActionAllowed + TimeSpan.FromSeconds(actionsCooldown);
                creature.NextCombatSpecialActionAllowed = creature.NextCombatSpecialActionAllowed + TimeSpan.FromSeconds(actionsCooldown);
                creature.NextCombatEpicActionAllowed    = creature.NextCombatEpicActionAllowed + TimeSpan.FromSeconds(actionsCooldown);
            }

            for (int a = 0; a < swingCount; a++)
            {
                double delay = (a * swingInterval) + (a * preSwingDelay);

                Timer.DelayCall(TimeSpan.FromSeconds(delay), delegate
                {
                    if (creature == null)
                    {
                        return;
                    }

                    if (!creature.Alive || creature.Paralyzed || creature.Frozen)
                    {
                        return;
                    }

                    Effects.PlaySound(creature.Location, creature.Map, 0x51F);

                    int newDirectionValue = (int)creature.Direction;
                    newDirectionValue    += Utility.RandomList(-3, -4, -5, 3, 4, 5);

                    if (newDirectionValue > 7)
                    {
                        newDirectionValue = 0 + (newDirectionValue - 8);
                    }
                    else if (newDirectionValue < 0)
                    {
                        newDirectionValue = 8 + newDirectionValue;
                    }

                    creature.Direction = (Direction)(newDirectionValue);

                    Timer.DelayCall(TimeSpan.FromSeconds(preSwingDelay), delegate
                    {
                        if (creature == null)
                        {
                            return;
                        }

                        if (!creature.Alive || creature.Paralyzed || creature.Frozen)
                        {
                            return;
                        }

                        BaseWeapon weapon = creature.Weapon as BaseWeapon;

                        if (weapon != null)
                        {
                            weapon.PlaySwingAnimation(creature);

                            IPooledEnumerable eable = creature.Map.GetObjectsInRange(creature.Location, 1);

                            foreach (object obj in eable)
                            {
                                if (obj is Mobile)
                                {
                                    Mobile mobile = obj as Mobile;

                                    if (creature == null || mobile == null)
                                    {
                                        continue;
                                    }

                                    if (!creature.Alive || !mobile.Alive)
                                    {
                                        continue;
                                    }

                                    if (creature == mobile)
                                    {
                                        continue;
                                    }

                                    if (creature.CanBeHarmful(mobile))
                                    {
                                        BaseCreature bc_CreatureTarget = mobile as BaseCreature;

                                        bool validCreatureTarget = false;

                                        if (bc_CreatureTarget != null)
                                        {
                                            if (bc_CreatureTarget.Controlled && bc_CreatureTarget.ControlMaster is PlayerMobile)
                                            {
                                                validCreatureTarget = true;
                                            }
                                        }

                                        //Valid Targets
                                        if (mobile == creature.Combatant || mobile is PlayerMobile || validCreatureTarget)
                                        {
                                            if (a == 0 || Utility.RandomDouble() < hitChance)
                                            {
                                                int damage = Utility.RandomMinMax(creature.DamageMin, creature.DamageMax);

                                                if (damage < 1)
                                                {
                                                    damage = 1;
                                                }

                                                creature.DoHarmful(mobile);

                                                BaseCreature bc_Mobile = mobile as BaseCreature;
                                                PlayerMobile pm_Mobile = mobile as PlayerMobile;

                                                double bleedValue = bc_Mobile.GetSpecialAbilityEntryValue(SpecialAbilityEffect.Bleed);

                                                if (bleedValue == 0)
                                                {
                                                    SpecialAbilities.BleedSpecialAbility(1.0, creature, mobile, creature.DamageMax, 8.0, -1, true, "", "Their attack causes you to bleed!", "-1");
                                                }

                                                AOS.Damage(mobile, creature, damage, 100, 0, 0, 0, 0);
                                                new Blood().MoveToWorld(mobile.Location, mobile.Map);
                                            }
                                        }
                                    }
                                }
                            }

                            eable.Free();
                        }
                    });
                });
            }

            return(true);
        }
        public static void DoBomber(BaseCreature mobile, Mobile player)
        {
            Mobile combatant = player;

            if (combatant == null || combatant.Deleted || combatant.Map != mobile.Map || !mobile.InRange(combatant, 12) || !mobile.CanBeHarmful(combatant) || !mobile.InLOS(combatant))
            {
                return;
            }

            if (DateTime.Now >= m_NextBomb)
            {
                ThrowBomb(combatant, player);

                m_Thrown++;

                if (0.75 >= Utility.RandomDouble() && (m_Thrown % 2) == 1)
                {
                    m_NextBomb = DateTime.Now + TimeSpan.FromSeconds(3.0);
                }
                else
                {
                    m_NextBomb = DateTime.Now + TimeSpan.FromSeconds(5.0 + (10.0 * Utility.RandomDouble()));
                }
            }
        }
示例#16
0
        public static void IcyWindAttack(BaseCreature from, Mobile target)
        {
            if (from.IcyWindAttack < 10 || from == null || target == null)
                return;

            Effects.SendLocationParticles(EffectItem.Create(target.Location, target.Map, EffectItem.DefaultDuration), 0x37CC, 1, 40, 97, 3, 9917, 0);
            int mindam = from.IcyWindAttack / 3;
            int maxdam = from.IcyWindAttack / 2;

            ArrayList targets = new ArrayList();

            foreach (Mobile m in from.GetMobilesInRange(from.IcyWindAttack / 10))
            {
                if (m != from && from.CanBeHarmful(m))
                    targets.Add(m);
            }

            for (int i = 0; i < targets.Count; ++i)
            {
                Mobile m = (Mobile)targets[i];
                from.Say("Icy Wind Attack");
                AOS.Damage(target, from, Utility.RandomMinMax(mindam, maxdam), 0, 0, 100, 0, 0);
                Slow.SlowWalk(m, 10);
            }
        }