public void DoAreaLightningAttack(Mobile focus)
        {
            if (focus == null)
            {
                return;
            }

            BaseBoat boat = BaseBoat.FindBoatAt(focus, focus.Map);

            if (boat != null)
            {
                List <Mobile> mobs = boat.GetMobilesOnBoard();

                foreach (Mobile mob in mobs)
                {
                    if (CanBeHarmful(mob, false) && mob.Alive)
                    {
                        double damage = Math.Max(40, Utility.RandomMinMax(50, 100) * ((double)Hits / (double)HitsMax));

                        mob.BoltEffect(0);
                        AOS.Damage((Mobile)mob, this, (int)damage, false, 0, 0, 0, 0, 0, 0, 100, false, false, false);
                        mob.FixedParticles(0x36BD, 20, 10, 5044, EffectLayer.Head);
                    }
                }
            }
        }
Beispiel #2
0
        public virtual void OnShipHit(object obj)
        {
            object[] list   = (object[])obj;
            BaseBoat target = list[0] as BaseBoat;
            Point3D  pnt    = (Point3D)list[1];

            var ammoInfo = AmmoInfo.GetAmmoInfo((AmmunitionType)list[2]);

            if (ammoInfo != null && target != null)
            {
                int damage = (Utility.RandomMinMax(ammoInfo.MinDamage, ammoInfo.MaxDamage));
                damage /= 7;
                target.OnTakenDamage(Operator, 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);

                if (Operator != null && (!Operator.Deleted || CanFireUnmanned))
                {
                    Mobile victim = target.Owner;

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

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

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

                        ColUtility.Free(candidates);
                    }
                }
            }
        }