Exemplo n.º 1
0
        public override bool OnDragDrop(Mobile from, Item item)
        {
            if (m_Galleon == null || !m_Galleon.Contains(from) || m_Galleon.IsMoving)
            {
                return(false);
            }

            return(base.OnDragDrop(from, item));
        }
Exemplo n.º 2
0
 public override void OnDoubleClick(Mobile from)
 {
     if (m_Galleon == null || !m_Galleon.IsOwner(from))
     {
         base.OnDoubleClick(from);
     }
     else if (m_Galleon != null && m_Galleon.Contains(from))
     {
         m_Galleon.BeginRename(from);
     }
     else if (m_Galleon != null)
     {
         m_Galleon.BeginDryDock(from);
     }
 }
Exemplo n.º 3
0
 public override void OnClick()
 {
     if (m_Galleon != null && !m_Galleon.Contains(m_From) && m_Galleon.IsOwner(m_From))
     {
         m_Galleon.BeginDryDock(m_From);
     }
 }
Exemplo n.º 4
0
        public virtual void OnChop(Mobile from)
        {
            BaseGalleon galleon = null;

            if (this.LinkedSingleCannonPlace != null)
            {
                galleon = this.LinkedSingleCannonPlace.Galleon;
            }

            if (this.LinkedMultiCannonPlace != null)
            {
                galleon = this.LinkedMultiCannonPlace.Galleon;
            }

            if (galleon != null && (galleon.Owner == from) && galleon.Contains(this))
            {
                Effects.PlaySound(this.GetWorldLocation(), this.Map, 0x3B3);
                from.SendLocalizedMessage(500461); // You destroy the item.

                this.Delete();

                LightCannonDeed deed = new LightCannonDeed();

                from.AddToBackpack(deed);
            }
        }
Exemplo n.º 5
0
        public override void DoDamageBoat(BaseGalleon galleon)
        {
            if (galleon == null)
            {
                return;
            }

            m_HasPushed = false;
            IPoint2D pnt = galleon;

            if (Combatant != null && galleon.Contains(Combatant))
            {
                pnt = Combatant;
            }

            Direction   dir  = Utility.GetDirection(this, pnt);
            Point3DList path = new Point3DList();

            for (int i = 0; i < DamageRange; i++)
            {
                int x = 0, y = 0;
                switch ((int)dir)
                {
                case (int)Direction.Running:
                case (int)Direction.North: { y -= i; break; }

                case 129:
                case (int)Direction.Right: { y -= i; x += i; break; }

                case 130:
                case (int)Direction.East: { x += i; break; }

                case 131:
                case (int)Direction.Down: { x += i; y += i; break; }

                case 132:
                case (int)Direction.South: { y += i; break; }

                case 133:
                case (int)Direction.Left: { y += i; x -= i; break; }

                case 134:
                case (int)Direction.West: { x -= i; break; }

                case (int)Direction.ValueMask:
                case (int)Direction.Up: { x -= i; y -= i; break; }
                }

                path.Add(this.X + x, this.Y + y, this.Z);
            }

            new EffectsTimer(this, path, dir, DamageRange);
        }
Exemplo n.º 6
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is IPoint3D)
                {
                    IPoint3D    pnt     = (IPoint3D)targeted;
                    BaseGalleon galleon = BaseGalleon.FindGalleonAt(pnt, from.Map);

                    if (galleon == null || !galleon.Contains(from))
                    {
                        return;
                    }

                    if (galleon.GetSecurityLevel(from) < SecurityLevel.Captain)
                    {
                        from.SendMessage("You must be the captain to paint this ship!");
                    }

                    else if (galleon.Contains(pnt) /*&& boat.X == pnt.X && boat.Y == pnt.Y*/)
                    {
                        if (m_Paint.Permanent)
                        {
                            if (galleon.TryPermanentPaintBoat(from, m_Paint.Hue))
                            {
                                m_Paint.Delete();
                            }
                        }
                        else
                        {
                            if (galleon.TryPaintBoat(from, m_Paint.Hue))
                            {
                                m_Paint.Delete();
                            }
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(1116612); //You must target the main mast of the ship you wish to dye.
                    }
                }
            }
Exemplo n.º 7
0
 public override void OnDoubleClick(Mobile from)
 {
     if (m_Galleon == null || from.AccessLevel > AccessLevel.Player)
     {
         base.OnDoubleClick(from);
     }
     else if (!m_Galleon.Contains(from))
     {
         if (m_Galleon.TillerMan != null)
         {
             m_Galleon.TillerManSay("You must be on the ship to open the container.");
         }
     }
     else if (m_Galleon.Owner is PlayerMobile && !m_Galleon.Scuttled && m_Galleon.GetSecurityLevel(from) < SecurityLevel.Crewman)
     {
         from.SendMessage("You must be at least a crewman to access the ship container.");
     }
     else
     {
         base.OnDoubleClick(from);
     }
 }
Exemplo n.º 8
0
 public override void OnDoubleClick(Mobile from)
 {
     if (m_Galleon == null || from.AccessLevel > AccessLevel.Player)
     {
         base.OnDoubleClick(from);
     }
     else if (!m_Galleon.Contains(from))
     {
         if (m_Galleon.TillerMan != null)
         {
             m_Galleon.TillerManSay(502490); // You must be on the ship to open the hold.
         }
     }
     else if (m_Galleon.Owner is PlayerMobile && !m_Galleon.Scuttled && m_Galleon.GetSecurityLevel(from) < SecurityLevel.Officer)
     {
         from.SendMessage("You must be at least an officer to access the cargo hold.");
     }
     else
     {
         base.OnDoubleClick(from);
     }
 }
Exemplo n.º 9
0
        public override void OnThink()
        {
            base.OnThink();

            if (m_Galleon == null)
            {
                return;
            }

            if (m_Galleon.Deleted)
            {
                OnShipDelete();
            }

            // Ship is f****d without his captain!!!
            if (!m_Galleon.Contains(this))
            {
                return;
            }

            if (!IsInBattle())
            {
                if (!m_OnCourse)
                {
                    ResumeCourse();
                }
                else if (m_OnCourse && !m_Galleon.IsMoving && m_ActionTime < DateTime.UtcNow)
                {
                    ResumeCourseTimed(ResumeTime, true);
                    m_ActionTime = DateTime.UtcNow + ResumeTime;
                }
                return;
            }

            m_OnCourse = false;

            Mobile focusMob = GetFocusMob();

            if (m_TargetBoat == null || !InRange(m_TargetBoat.Location, 25))
            {
                m_TargetBoat = GetFocusBoat(focusMob);
            }

            if (focusMob == null && m_TargetBoat == null)
            {
                return;
            }

            if (m_NextMoveCheck < DateTime.UtcNow && !m_Galleon.Scuttled && !m_Blockade)
            {
                Point3D pnt = m_TargetBoat != null ? m_TargetBoat.Location : focusMob.Location;

                int dist = (int)GetDistanceToSqrt(pnt);

                if (!Aggressive && dist < 25)
                {
                    MoveBoat(pnt);
                }
                else if (Aggressive && dist >= 10 && dist <= 35)
                {
                    MoveBoat(pnt);
                }
                else
                {
                    m_Galleon.StopMove(false);
                    ResumeCourseTimed(TimeSpan.FromMinutes(2), false); //Loiter
                }
            }

            if (m_TargetBoat != null && !m_TargetBoat.Scuttled)
            {
                ShootCannons(focusMob, true);
            }
            else
            {
                ShootCannons(focusMob, false);
            }
        }
Exemplo n.º 10
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();
                }
            }
        }
Exemplo n.º 11
0
        public virtual void OnShipHit(object obj)
        {
            object[]    list   = (object[])obj;
            BaseGalleon target = list[0] as BaseGalleon;
            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.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);
                    }
                }
            }
        }
Exemplo n.º 12
0
        public override void OnDoubleClick(Mobile from)
        {
            if (m_Boat != null && !m_Boat.Contains(from))
            {
                if (m_Boat.Status == ShipStatus.Low)
                {
                    from.MoveToWorld(this.Location, this.Map);
                    from.SendMessage(61, "You have boarded the ship.");
                    return;
                }

                if (from == m_Boat.Owner)
                {
                    from.SendMessage("Welcome aboard, Owner !");
                    base.OnDoubleClick(from);
                    from.MoveToWorld(this.Location, this.Map);
                }
                else if (m_Boat.PlayerAccess != null)
                {
                    if (m_Boat.PlayerAccess.ContainsKey((PlayerMobile)from))
                    {
                        if (m_Boat.PlayerAccess[(PlayerMobile)from] == 1)
                        {
                            from.SendMessage("Welcome aboard, you are now a passenger !");
                            base.OnDoubleClick(from);
                            from.MoveToWorld(this.Location, this.Map);
                        }
                        else if (m_Boat.PlayerAccess[(PlayerMobile)from] == 2)
                        {
                            from.SendMessage("Welcome aboard, you are now a crew !");
                            base.OnDoubleClick(from);
                            from.MoveToWorld(this.Location, this.Map);
                        }
                        else if (m_Boat.PlayerAccess[(PlayerMobile)from] == 3)
                        {
                            from.SendMessage("Welcome aboard, you are now an officer !");
                            base.OnDoubleClick(from);
                            from.MoveToWorld(this.Location, this.Map);
                        }
                        else if (m_Boat.PlayerAccess[(PlayerMobile)from] == 4)
                        {
                            from.SendMessage("Welcome aboard, you are now a captain !");
                            base.OnDoubleClick(from);
                            from.MoveToWorld(this.Location, this.Map);
                        }
                        else if ((from.Guild == m_Boat.Owner.Guild) && (from.Guild != null))
                        {
                            if (m_Boat.Guild == 1)
                            {
                                from.SendMessage("Welcome aboard, you are now a passenger !");
                                base.OnDoubleClick(from);
                                from.MoveToWorld(this.Location, this.Map);
                            }
                            else if (m_Boat.Guild == 2)
                            {
                                from.SendMessage("Welcome aboard, you are now a crew !");
                                base.OnDoubleClick(from);
                                from.MoveToWorld(this.Location, this.Map);
                            }
                            else if (m_Boat.Guild == 3)
                            {
                                from.SendMessage("Welcome aboard, you are now an officer !");
                                base.OnDoubleClick(from);
                                from.MoveToWorld(this.Location, this.Map);
                            }
                            else if (m_Boat.Guild == 4)
                            {
                                from.SendMessage("Welcome aboard, you are now a captain !");
                                base.OnDoubleClick(from);
                                from.MoveToWorld(this.Location, this.Map);
                            }
                        }
                        else if ((from.Party == m_Boat.Owner.Party) && (from.Party != null))
                        {
                            if (m_Boat.Party == 1)
                            {
                                from.SendMessage("Welcome aboard, you are now a passenger !");
                                base.OnDoubleClick(from);
                                from.MoveToWorld(this.Location, this.Map);
                            }
                            else if (m_Boat.Party == 2)
                            {
                                from.SendMessage("Welcome aboard, you are now a crew !");
                                base.OnDoubleClick(from);
                                from.MoveToWorld(this.Location, this.Map);
                            }
                            else if (m_Boat.Party == 3)
                            {
                                from.SendMessage("Welcome aboard, you are now an officer !");
                                base.OnDoubleClick(from);
                                from.MoveToWorld(this.Location, this.Map);
                            }
                            else if (m_Boat.Party == 4)
                            {
                                from.SendMessage("Welcome aboard, you are now a captain !");
                                base.OnDoubleClick(from);
                                from.MoveToWorld(this.Location, this.Map);
                            }
                        }
                        else
                        {
                            if (m_Boat.Public == 1)
                            {
                                from.SendMessage("Welcome aboard, you are now a passenger !");
                                base.OnDoubleClick(from);
                                from.MoveToWorld(this.Location, this.Map);
                            }
                            else if (m_Boat.Public == 2)
                            {
                                from.SendMessage("Welcome aboard, you are now a crew !");
                                base.OnDoubleClick(from);
                                from.MoveToWorld(this.Location, this.Map);
                            }
                            else if (m_Boat.Public == 3)
                            {
                                from.SendMessage("Welcome aboard, you are now an officer !");
                                base.OnDoubleClick(from);
                                from.MoveToWorld(this.Location, this.Map);
                            }
                            else if (m_Boat.Public == 4)
                            {
                                from.SendMessage("Welcome aboard, you are now a captain !");
                                base.OnDoubleClick(from);
                                from.MoveToWorld(this.Location, this.Map);
                            }
                        }
                    }
                }
            }
            else if (m_Boat != null && m_Boat.Contains(from))
            {
                Map map = Map;

                if (map == null)
                {
                    return;
                }

                int rx = 0, ry = 0;

                if (m_Side == BoatRopeSide.Port)
                {
                    if (m_Boat.Facing == Direction.North)
                    {
                        rx = 1;
                    }
                    else if (m_Boat.Facing == Direction.South)
                    {
                        rx = -1;
                    }
                    else if (m_Boat.Facing == Direction.East)
                    {
                        ry = 1;
                    }
                    else if (m_Boat.Facing == Direction.West)
                    {
                        ry = -1;
                    }
                }
                else if (m_Side == BoatRopeSide.Starboard)
                {
                    if (m_Boat.Facing == Direction.North)
                    {
                        rx = -1;
                    }
                    else if (m_Boat.Facing == Direction.South)
                    {
                        rx = 1;
                    }
                    else if (m_Boat.Facing == Direction.East)
                    {
                        ry = -1;
                    }
                    else if (m_Boat.Facing == Direction.West)
                    {
                        ry = 1;
                    }
                }

                for (int i = 1; i <= 6; ++i)
                {
                    int x = X + (i * rx);
                    int y = Y + (i * ry);
                    int z;

                    for (int j = -16; j <= 16; ++j)
                    {
                        z = from.Z + j;

                        if (map.CanFit(x, y, z, 16, false, false) && !Server.Spells.SpellHelper.CheckMulti(new Point3D(x, y, z), map) && !Region.Find(new Point3D(x, y, z), map).IsPartOf(typeof(Factions.StrongholdRegion)))
                        {
                            if (i == 1 && j >= -2 && j <= 2)
                            {
                                return;
                            }

                            from.Location = new Point3D(x, y, z);
                            return;
                        }
                    }

                    z = map.GetAverageZ(x, y);

                    if (map.CanFit(x, y, z, 16, false, false) && !Server.Spells.SpellHelper.CheckMulti(new Point3D(x, y, z), map) && !Region.Find(new Point3D(x, y, z), map).IsPartOf(typeof(Factions.StrongholdRegion)))
                    {
                        if (i == 1)
                        {
                            return;
                        }

                        from.Location = new Point3D(x, y, z);
                        return;
                    }
                }
            }
        }