public override bool OnDragDropInto(Mobile from, Item item, Point3D p)
        {
            if (m_Ship == null || !m_Ship.Contains(from))
            {
                return(false);
            }

            return(base.OnDragDropInto(from, item, p));
        }
Exemple #2
0
        public override void OnDoubleClick(Mobile from)
        {
            if (m_Ship == null)
            {
                return;
            }

            if (!from.Alive)
            {
                from.SendMessage("You must be alive to use this.");
                return;
            }

            else if (!(m_Ship.IsOwner(from) || m_Ship.IsCoOwner(from)))
            {
                from.SendMessage("You do not have permission to use this.");
                return;
            }

            else if (!m_Ship.Contains(from))
            {
                from.SendMessage("You cannot reach that.");
                return;
            }

            else if (Ammunition == 0)
            {
                from.SendMessage("Those cannons are out of ammunition.");
                return;
            }

            else if (DateTime.UtcNow < m_Ship.CannonCooldown)
            {
                from.SendMessage("You must wait before firing another cannon volley.");
                return;
            }

            else
            {
                from.SendMessage("Where would you like to fire the cannon volley?");
                from.Target = new CannonTarget(this);
                from.RevealingAction();
            }
        }
        public void OnTarget(Mobile from, Point3D point)
        {
            BaseShip ship = BaseShip.FindShipAt(point, this.Map);

            if (ship != null)
            {
                if (ship.m_ScuttleInProgress)
                {
                    from.SendMessage("You cannot repair a ship that is being scuttled.");
                    return;
                }

                if (!from.CanBeginAction(typeof(ShipRepairTool)))
                {
                    from.SendMessage("You must wait a few moments before attempting to use that again.");
                    return;
                }

                TimeSpan repairCooldownRequired = TimeSpan.FromSeconds(ship.m_ShipStatsProfile.RepairCooldownDuration);

                if (ship.LastCombatTime + ship.TimeNeededToBeOutOfCombat <= DateTime.UtcNow)
                {
                    repairCooldownRequired = BaseShip.RepairDuration;
                }

                if (ship.m_TimeLastRepaired + repairCooldownRequired > DateTime.UtcNow)
                {
                    string repairString = Utility.CreateTimeRemainingString(DateTime.UtcNow, ship.m_TimeLastRepaired + repairCooldownRequired, false, false, false, true, true);

                    from.SendMessage("This ship cannot be repaired for another " + repairString + ".");
                    return;
                }

                if (!(ship.Contains(from) || ship.GetShipToLocationDistance(ship, from.Location) <= 6))
                {
                    from.SendMessage("You are too far away from that ship to repair it.");

                    return;
                }

                if (ship.IsOwner(from) || ship.IsCoOwner(from))
                {
                    from.CloseGump(typeof(ShipRepairGump));
                    from.SendGump(new ShipRepairGump(ship, from, this));
                    from.SendMessage("What do you wish to repair on the ship?");
                }

                else
                {
                    from.SendMessage("You must be the owner or co-owner of the ship in order to repair it.");
                }
            }
        }
		public override void OnSpeech( SpeechEventArgs e )
		{
			Mobile from = e.Mobile;

			if ( !e.Handled && from.InRange( this, 10 ) && e.Speech.ToLower() == this.Word )
			{
				BaseShip ship = BaseShip.FindShipAt( from, from.Map );
                
				if ( ship == null )
					return;

				if ( !this.Active )
				{
					if ( ship.TillerMan != null )
						ship.TillerMan.Say( 502507 ); // Ar, Legend has it that these pillars are inactive! No man knows how it might be undone!

					return;
				}

                
                if (T2AAccess.IsT2A(m_Destination.Start, from.Map))
                {
                    if (ship.Map != null && ship.Map != Map.Internal)
                    {
                        MultiComponentList mcl = ship.Components;

                        IPooledEnumerable eable = ship.Map.GetClientsInBounds(new Rectangle2D(ship.X + mcl.Min.X, ship.Y + mcl.Min.Y, mcl.Width, mcl.Height));

                        foreach (NetState ns in eable)
                            if (ns != null && ns.Mobile != null && ship.Contains((Mobile)ns.Mobile) && !T2AAccess.HasAccess(ns.Mobile))
                            {
                                eable.Free();
                                from.SendMessage("One or more players on board does not have access to T2A at this time.");
                                return;
                            }

                        eable.Free();
                    }


                }

				Map map = from.Map;

				for ( int i = 0; i < 5; i++ ) // Try 5 times
				{
					int x = Utility.Random( Destination.X, Destination.Width );
					int y = Utility.Random( Destination.Y, Destination.Height );
					int z = map.GetAverageZ( x, y );

					Point3D dest = new Point3D( x, y, z );

					if ( ship.CanFit( dest, map, ship.ItemID ) )
					{
						int xOffset = x - ship.X;
						int yOffset = y - ship.Y;
						int zOffset = z - ship.Z;

						ship.Teleport( xOffset, yOffset, zOffset );

						return;
					}
				}

				if ( ship.TillerMan != null )
					ship.TillerMan.Say( 502508 ); // Ar, I refuse to take that matey through here!
			}
		}
            protected override void OnTick()
            {
                //No Longer Alive
                if (!m_From.Alive)
                {
                    this.Stop();

                    return;
                }

                //No Longer On Ship or Close Enough to the Ship to Repair
                if (!(m_Ship.Contains(m_From) || m_Ship.GetShipToLocationDistance(m_Ship, m_From.Location) <= 6))
                {
                    m_From.SendMessage("You are not close enough to the ship to finish your repairs.");

                    this.Stop();
                    return;
                }

                m_From.RevealingAction();

                //Repair Time Remains
                if ((m_Start + BaseShip.RepairDuration) > DateTime.UtcNow)
                {
                    Effects.PlaySound(m_From.Location, m_From.Map, 0x23D);

                    if (!m_From.Mounted)
                    {
                        m_From.Animate(11, 5, 1, true, false, 0);
                    }
                }

                //Repairs Complete
                else
                {
                    Effects.PlaySound(m_From.Location, m_From.Map, 0x23D);

                    if (!m_From.Mounted)
                    {
                        m_From.Animate(11, 5, 1, true, false, 0);
                    }

                    Stop();

                    m_ShipRepairTools.FinishRepairs(m_Ship, m_From, m_DamageType, true);
                }

                //Henchman Repair Assistance
                List <Mobile> m_MobilesOnShip = m_Ship.GetMobilesOnShip(false, false);

                foreach (Mobile mobile in m_MobilesOnShip)
                {
                    if (mobile is HenchmanNavyCarpenter)
                    {
                        HenchmanNavyCarpenter navyCarpenter = mobile as HenchmanNavyCarpenter;
                        navyCarpenter.AssistRepair();
                    }

                    if (mobile is HenchmanPirateCarpenter)
                    {
                        HenchmanPirateCarpenter pirateCarpenter = mobile as HenchmanPirateCarpenter;
                        pirateCarpenter.AssistRepair();
                    }
                }
            }
            protected override void OnTarget(Mobile from, object target)
            {
                bool foundAnyone = false;

                from.RevealingAction();
                from.NextSkillTime = Core.TickCount + (int)(SkillCooldown.DetectHiddenCooldown * 1000);

                Point3D p;

                if (target is Mobile)
                {
                    p = ((Mobile)target).Location;
                }

                else if (target is Item)
                {
                    p = ((Item)target).Location;
                }

                else if (target is IPoint3D)
                {
                    p = new Point3D((IPoint3D)target);
                }

                else
                {
                    p = from.Location;
                }

                //Ship Searching: Automatic Success for Owner, Co-Owner, Owner
                BaseShip ship = BaseShip.FindShipAt(p, from.Map);

                if (ship != null)
                {
                    if (!ship.Contains(from))
                    {
                        from.SendMessage("You must be onboard this ship in order to search it.");
                        return;
                    }

                    if (ship.IsFriend(from) || ship.IsCoOwner(from) || ship.IsOwner(from))
                    {
                        List <Mobile> m_MobilesOnBoard = ship.GetMobilesOnShip(false, true);

                        foreach (Mobile mobile in m_MobilesOnBoard)
                        {
                            if (mobile == from)
                            {
                                continue;
                            }

                            if (mobile.Hidden && !mobile.RevealImmune && from.AccessLevel >= mobile.AccessLevel)
                            {
                                mobile.RevealingAction();
                                mobile.SendLocalizedMessage(500814); // You have been revealed!

                                foundAnyone = true;
                            }
                        }

                        if (foundAnyone)
                        {
                            from.SendMessage("You reveal what was hidden.");
                        }

                        else
                        {
                            from.SendMessage("You search the decks and find no one hiding onboard.");
                        }
                    }

                    return;
                }

                //House Searching: Automatic Success for Owner, Co-Owner, Owner
                BaseHouse house = BaseHouse.FindHouseAt(p, from.Map, 16);

                if (house != null)
                {
                    if (!house.Contains(from.Location))
                    {
                        from.SendMessage("You must be inside this house in order to search it.");
                        return;
                    }

                    if (house.IsFriend(from) || house.IsCoOwner(from) || house.IsOwner(from))
                    {
                        IPooledEnumerable nearbyMobiles = from.Map.GetMobilesInRange(p, HouseSearchRange);

                        foreach (Mobile mobile in nearbyMobiles)
                        {
                            if (mobile == from)
                            {
                                continue;
                            }

                            BaseHouse mobileHouse = BaseHouse.FindHouseAt(p, from.Map, 16);

                            if (mobile == null || mobileHouse != house)
                            {
                                continue;
                            }

                            if (mobile.Hidden && !mobile.RevealImmune && from.AccessLevel >= mobile.AccessLevel)
                            {
                                mobile.RevealingAction();
                                mobile.SendLocalizedMessage(500814); // You have been revealed!

                                foundAnyone = true;
                            }
                        }

                        nearbyMobiles.Free();

                        if (foundAnyone)
                        {
                            from.SendMessage("You reveal what was hidden.");
                        }

                        else
                        {
                            from.SendMessage("You search the home and find no one hiding within.");
                        }
                    }

                    return;
                }

                from.CheckSkill(SkillName.DetectHidden, 0.0, 100.0, 1.0);

                double successChance = (from.Skills[SkillName.DetectHidden].Value / 100);

                int searchRadius = (int)(Math.Floor(from.Skills[SkillName.DetectHidden].Value / 100) * MaxSearchRadius);

                if (Utility.RandomDouble() <= successChance)
                {
                    IPooledEnumerable nearbyMobiles = from.Map.GetMobilesInRange(p, searchRadius);

                    foreach (Mobile mobile in nearbyMobiles)
                    {
                        if (mobile == from)
                        {
                            continue;
                        }

                        if (mobile.Hidden && !mobile.RevealImmune && from.AccessLevel >= mobile.AccessLevel)
                        {
                            mobile.RevealingAction();
                            mobile.SendLocalizedMessage(500814); // You have been revealed!

                            foundAnyone = true;
                        }
                    }

                    nearbyMobiles.Free();

                    if (foundAnyone)
                    {
                        from.SendMessage("You reveal what was hidden.");
                    }

                    else
                    {
                        from.SendMessage("You search the area but find nothing hidden.");
                    }
                }

                else
                {
                    from.SendMessage("You are not certain what lies hidden nearby.");
                    return;
                }
            }