Example #1
0
        public void Target(Mobile m)
        {
            if (!Caster.CanSee(m))
            {
                Caster.SendLocalizedMessage(500237);                   // Target can not be seen.
            }
            else if (CheckHSequence(m))
            {
                Mobile attacker = Caster, source = Caster;

                SpellHelper.Turn(Caster, m);

                attacker.AggressiveAction(m, attacker.IsHarmfulCriminal(m));

                SpellHelper.CheckReflect((int)this.Circle, ref source, ref m);

                InternalTimer t = new InternalTimer(this, attacker, source, m);
                t.Start();
            }

            FinishSequence();
        }
Example #2
0
        public virtual void OnShipHit(object obj)
        {
            object[]    list     = (object[])obj;
            BaseGalleon target   = list[0] as BaseGalleon;
            Point3D     pnt      = (Point3D)list[1];
            AmmoInfo    ammoInfo = list[2] as AmmoInfo;
            Mobile      shooter  = list[3] as Mobile;

            if (target != null && Galleon != null)
            {
                int damage = (int)(ammoInfo.GetDamage(this) * Galleon.CannonDamageMod);
                target.OnTakenDamage(shooter, damage);

                int z = target.ZSurface;

                if (target.TillerMan != null && target.TillerMan is IEntity)
                {
                    z = ((IEntity)target.TillerMan).Z;
                }

                Direction d       = Utility.GetDirection(this, pnt);
                int       xOffset = 0;
                int       yOffset = 0;
                Point3D   hit     = pnt;

                if (!ammoInfo.RequiresSurface)
                {
                    switch (d)
                    {
                    default:
                    case Direction.North:
                        xOffset = Utility.RandomMinMax(-1, 1);
                        yOffset = Utility.RandomMinMax(-2, 0);
                        hit     = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z);
                        break;

                    case Direction.South:
                        xOffset = Utility.RandomMinMax(-1, 1);
                        yOffset = Utility.RandomMinMax(0, 2);
                        hit     = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z);
                        break;

                    case Direction.East:
                        xOffset = Utility.RandomMinMax(0, 2);
                        yOffset = Utility.RandomMinMax(-1, 1);
                        hit     = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z);
                        break;

                    case Direction.West:
                        xOffset = Utility.RandomMinMax(-2, 0);
                        yOffset = Utility.RandomMinMax(-1, 1);
                        hit     = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z);
                        break;
                    }
                }

                Effects.SendLocationEffect(hit, target.Map, Utility.RandomBool() ? 14000 : 14013, 15, 10);
                Effects.PlaySound(hit, target.Map, 0x207);

                Mobile victim = target.Owner;

                if (victim != null && target.Contains(victim) && shooter.CanBeHarmful(victim, false))
                {
                    shooter.DoHarmful(victim);
                }
                else
                {
                    List <Mobile> candidates = new List <Mobile>();
                    SecurityLevel highest    = SecurityLevel.Passenger;

                    foreach (var mob in target.GetMobilesOnBoard().OfType <PlayerMobile>().Where(pm => shooter.CanBeHarmful(pm, false)))
                    {
                        if (Galleon.GetSecurityLevel(mob) > highest)
                        {
                            candidates.Insert(0, mob);
                        }
                        else
                        {
                            candidates.Add(mob);
                        }
                    }

                    if (candidates.Count > 0)
                    {
                        shooter.DoHarmful(candidates[0]);
                    }
                    else if (victim != null && shooter.IsHarmfulCriminal(victim))
                    {
                        shooter.CriminalAction(false);
                    }

                    ColUtility.Free(candidates);
                }

                if (Galleon.Map != null)
                {
                    IPooledEnumerable eable = Galleon.Map.GetItemsInRange(hit, 1);

                    foreach (Item item in eable)
                    {
                        if (item is IShipCannon && !Galleon.Contains(item))
                        {
                            ((IShipCannon)item).OnDamage(damage, shooter);
                        }
                    }

                    eable.Free();
                }
            }
        }
			public static bool ISHARMFULCRIMINAL(TriggerObject trigObject, Mobile from, Mobile to)
			{
				return from != null && to != null && from.IsHarmfulCriminal(to);
			}
			public static void AGGRESSIVEACTION(TriggerObject trigObject, Mobile from, Mobile to)
			{
				if (from != null && to != null)
				{
					AGGRESSIVEACTION(trigObject, from, to, from.IsHarmfulCriminal(to));
				}
			}
Example #5
0
        public void DoFireEffect(IPoint3D target, Mobile from)
        {
            Map map = Map;

            if (target == null || map == null)
            {
                return;
            }

            var      startloc = new Point3D(Location);
            IPoint3D point    = target;

            switch (Facing)
            {
            case 3:
            {
                Effects.SendLocationEffect(new Point3D(X, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                break;
            }

            case 1:
            {
                Effects.SendLocationEffect(new Point3D(X, Y - 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                break;
            }

            case 2:
            {
                Effects.SendLocationEffect(new Point3D(X + 1, Y, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                break;
            }

            case 0:
            {
                Effects.SendLocationEffect(new Point3D(X - 1, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                break;
            }
            }
            Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D));

            var queue = new EffectQueue();

            queue.Deferred = false;

            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    m_Projectile.AnimationID,
                    m_Projectile.AnimationHue > 0 ? m_Projectile.AnimationHue - 1 : 0,
                    10,
                    EffectRender.Normal,
                    TimeSpan.FromSeconds(0.1),
                    () =>
            {
                if (Projectile.ShipDamage > 0)
                {
                    for (int count = 8; count > 0; count--)
                    {
                        IPoint3D location = new Point3D(target.X + Utility.RandomMinMax(-1, 1),
                                                        target.Y + Utility.RandomMinMax(-1, 1), target.Z);
                        int effect = Utility.RandomList(0x36B0);
                        Effects.SendLocationEffect(location, map, effect, 25, 1);
                        Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D));
                    }
                }
                foreach (Mobile mob in AcquireAllTargets(new Point3D(point), Projectile.DamageRange))
                {
                    if (from.CanBeHarmful(mob))
                    {
                        mob.Damage(Projectile.PlayerDamage, from);
                        if (from.IsHarmfulCriminal(mob) && !from.Criminal)
                        {
                            from.CriminalAction(true);
                        }
                        else if (from.IsHarmfulCriminal(mob))
                        {
                            from.CriminalAction(false);
                        }
                    }
                }

                foreach (Item item in from.Map.GetItemsInRange(new Point3D(point), Projectile.DamageRange))
                {
                    if (item is MainMast)
                    {
                        var mast = item as MainMast;
                        if (mast.HullDurability < Projectile.ShipDamage)
                        {
                            mast.HullDurability = 0;
                        }
                        else
                        {
                            mast.HullDurability -= (ushort)Projectile.ShipDamage;
                        }
                        mast.PublicOverheadMessage(MessageType.Label, 61, true, mast.HullDurability + "/" + mast.MaxHullDurability);
                    }

                    if (item is BaseShipWeapon)
                    {
                        var cannon = item as BaseShipWeapon;
                        if (cannon.Durability < Projectile.ShipDamage)
                        {
                            cannon.Durability = 0;
                        }
                        else
                        {
                            cannon.Durability -= Projectile.ShipDamage;
                        }
                    }

                    if (item is NewBaseBoat)
                    {
                        var boat = item as NewBaseBoat;
                        if (boat.HullDurability < Projectile.ShipDamage)
                        {
                            boat.HullDurability = 0;
                        }
                        else
                        {
                            boat.HullDurability -= (ushort)Projectile.ShipDamage;
                        }
                        boat.PublicOverheadMessage(MessageType.Label, 61, true, boat.HullDurability + "/" + boat.MaxHullDurability);
                    }
                }
            }));
            queue.Process();
            Projectile.Delete();
            Projectile            = null;
            this.m_NextFiringTime = DateTime.UtcNow + TimeSpan.FromSeconds(15);
        }
        public void DoFireEffect(IPoint3D target, Mobile from)
        {
            Map map = Map;

            if (target == null || map == null)
            {
                return;
            }

            var startloc = new Point3D(Location);
            IPoint3D point = target;

            switch (Facing)
            {
                case 3:
                    {
                        Effects.SendLocationEffect(new Point3D(X, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                        break;
                    }
                case 1:
                    {
                        Effects.SendLocationEffect(new Point3D(X, Y - 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                        break;
                    }
                case 2:
                    {
                        Effects.SendLocationEffect(new Point3D(X + 1, Y, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                        break;
                    }
                case 0:
                    {
                        Effects.SendLocationEffect(new Point3D(X - 1, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                        break;
                    }
            }
            Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D));

            var queue = new EffectQueue();
            queue.Deferred = false;

            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    m_Projectile.AnimationID,
                    m_Projectile.AnimationHue > 0 ? m_Projectile.AnimationHue-1 : 0,
                    10,
                    EffectRender.Normal,
                    TimeSpan.FromSeconds(0.1),
                    () =>
                    {
                        if (Projectile.ShipDamage > 0)
                        {
                            for (int count = 8; count > 0; count--)
                            {
                                IPoint3D location = new Point3D(target.X + Utility.RandomMinMax(-1, 1),
                                    target.Y + Utility.RandomMinMax(-1, 1), target.Z);
                                int effect = Utility.RandomList(0x36B0);
                                Effects.SendLocationEffect(location, map, effect, 25, 1);
                                Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D));
                            }
                        }
                        foreach (Mobile mob in AcquireAllTargets(new Point3D(point), Projectile.DamageRange))
                        {
                            if (from.CanBeHarmful(mob))
                            {
                                mob.Damage(Projectile.PlayerDamage, from);
                                if (from.IsHarmfulCriminal(mob) && !from.Criminal)
                                    from.CriminalAction(true);
                                else if (from.IsHarmfulCriminal(mob))
                                    from.CriminalAction(false);
                            }
                        }

                        foreach (Item item in from.Map.GetItemsInRange(new Point3D(point), Projectile.DamageRange))
                        {
                            if (item is MainMast)
                            {
                                var mast = item as MainMast;
                                if (mast.HullDurability < Projectile.ShipDamage)
                                    mast.HullDurability = 0;
                                else
                                {
                                    mast.HullDurability -= (ushort)Projectile.ShipDamage;
                                }
                                mast.PublicOverheadMessage(MessageType.Label, 61, true, mast.HullDurability + "/" + mast.MaxHullDurability);
                            }

                            if (item is BaseShipWeapon)
                            {
                                var cannon = item as BaseShipWeapon;
                                if (cannon.Durability < Projectile.ShipDamage)
                                    cannon.Durability = 0;
                                else
                                {
                                    cannon.Durability -= Projectile.ShipDamage;
                                }
                            }

                            if (item is NewBaseBoat)
                            {
                                var boat = item as NewBaseBoat;
                                if (boat.HullDurability < Projectile.ShipDamage)
                                    boat.HullDurability = 0;
                                else
                                {
                                    boat.HullDurability -= (ushort)Projectile.ShipDamage;
                                }
                                boat.PublicOverheadMessage(MessageType.Label, 61, true, boat.HullDurability + "/" + boat.MaxHullDurability);
                            }
                        }
                    }));
            queue.Process();
            Projectile.Delete();
            Projectile = null;
            this.m_NextFiringTime = DateTime.UtcNow + TimeSpan.FromSeconds(15);
        }