示例#1
0
 public override void OnDoubleClick(Mobile from)
 {
     if (m_Boat != null)
     {
         if (m_Boat.Owner == from || from.AccessLevel >= AccessLevel.Administrator)
         {
             if (m_Boat.Contains(from))
             {
                 from.SendGump(new TillerManGump(from, m_Boat, false));                             //m_Boat.BeginRename( from );
             }
             else if (DockSearch.NearDock(from) == false)
             {
                 from.SendMessage("You must be near a dock to dry dock your ship!");
             }
             else
             {
                 m_Boat.BeginDryDock(from, m_Boat.Hue);
             }
         }
         else
         {
             from.SendLocalizedMessage(501023);                    // You must be the owner to use this item
         }
     }
 }
示例#2
0
 public override void GetContextMenuEntries(Mobile from, List <ContextMenuEntry> list)
 {
     base.GetContextMenuEntries(from, list);
     if (!from.Alive && m_Boat.Contains(from))
     {
         list.Add(new RemoveContext(from, this));
     }
 }
示例#3
0
        public override bool OnDragDrop(Mobile from, Item item)
        {
            if (m_Boat == null || !m_Boat.Contains(from) || m_Boat.IsMoving)
            {
                return(false);
            }

            return(base.OnDragDrop(from, item));
        }
示例#4
0
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            if (dropped is MapItem && m_Boat != null && m_Boat.CanCommand(from) && m_Boat.Contains(from))
            {
                m_Boat.AssociateMap((MapItem)dropped);
            }

            return(false);
        }
示例#5
0
文件: Hold.cs 项目: Pumpk1ns/outlands
        public override bool OnDragDropInto(Mobile from, Item item, Point3D p)
        {
            if (m_Boat == null || !m_Boat.Contains(from))
            {
                return(false);
            }

            return(base.OnDragDropInto(from, item, p));
        }
示例#6
0
 public override void OnDoubleClick(Mobile from)
 {
     if (m_Boat != null && m_Boat.Contains(from))
     {
         m_Boat.BeginRename(from);
     }
     else if (m_Boat != null)
     {
         m_Boat.BeginDryDock(from);
     }
 }
示例#7
0
 public override void OnClick()
 {
     if (m_Boat != null && !m_Boat.Contains(m_From))
     {
         m_Boat.BeginDryDock(m_From);
     }
 }
        public static List <Mobile> GetMobilesOn(BaseBoat boat)
        {
            List <Mobile> mobiles = new List <Mobile>();

            MultiComponentList mcl = boat.Components;

            Map map = boat.Map;

            if (map == null || map == Map.Internal)
            {
                return(mobiles);
            }

            IPooledEnumerable eable = map.GetObjectsInBounds(new Rectangle2D(boat.X + mcl.Min.X, boat.Y + mcl.Min.Y, mcl.Width, mcl.Height));

            foreach (object o in eable)
            {
                if (o == boat || o == boat.Hold || o == boat.SPlank || o == boat.PPlank || o == boat.TillerMan)
                {
                    continue;
                }

                else if (o is Mobile && boat.Contains((Mobile)o))
                {
                    mobiles.Add(o as Mobile);
                }
            }

            eable.Free();
            return(mobiles);
        }
示例#9
0
        public override bool OnDragDrop(Mobile from, Item item)
        {
            if (m_Boat == null || !m_Boat.Contains(from))
            {
                return(false);
            }

            if (m_Boat.IsMoving)
            {
                if (m_Boat.TillerMan != null)
                {
                    m_Boat.TillerMan.Say(502491);                       // I can not open the hold while the ship is moving.
                }
                return(false);
            }

            return(base.OnDragDrop(from, item));
        }
示例#10
0
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            if (dropped is MapItem item && m_Boat?.CanCommand(from) == true && m_Boat.Contains(from))
            {
                m_Boat.AssociateMap(item);
            }

            return(false);
        }
示例#11
0
        public override void OnDoubleClick(Mobile from)
        {
            if (m_Boat == null)
            {
                return;
            }

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

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

            else if (!m_Boat.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_Boat.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();
            }
        }
示例#12
0
 public override void OnDoubleClick(Mobile from)
 {
     if (m_Boat?.Contains(from) == true)
     {
         m_Boat.BeginRename(from);
     }
     else
     {
         m_Boat?.BeginDryDock(from);
     }
 }
示例#13
0
        public void OnTarget(Mobile from, Point3D point)
        {
            BaseBoat boat = BaseBoat.FindBoatAt(point, this.Map);

            if (boat != null)
            {
                if (boat.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;
                }

                //Last Repair Action Was Made During Combat, But Ship is Now Out of Combat (Reduce Repair Timer)
                if (boat.LastCombatTime + boat.TimeNeededToBeOutOfCombat <= DateTime.UtcNow && boat.NextTimeRepairable > DateTime.UtcNow + RepairDuration)
                {
                    boat.NextTimeRepairable = DateTime.UtcNow;
                }

                if (boat.NextTimeRepairable > DateTime.UtcNow)
                {
                    string repairString = Utility.CreateTimeRemainingString(DateTime.UtcNow, boat.NextTimeRepairable, false, false, false, true, true);

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

                    return;
                }

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

                    return;
                }

                if (boat.IsOwner(from) || boat.IsCoOwner(from))
                {
                    from.CloseGump(typeof(ShipRepairGump));
                    from.SendGump(new ShipRepairGump(boat, 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.");
                }
            }
        }
示例#14
0
        public override void DoDamageBoat(BaseBoat boat)
        {
            if (boat == null)
            {
                return;
            }

            m_HasPushed = false;
            IPoint2D pnt = boat;

            if (Combatant != null && boat.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(X + x, Y + y, Z);
            }

            new EffectsTimer(this, path, dir, DamageRange);
        }
示例#15
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is IPoint3D)
                {
                    IPoint3D pnt  = (IPoint3D)targeted;
                    BaseBoat boat = BaseBoat.FindBoatAt(pnt, from.Map);

                    if (boat is BaseGalleon && boat.Contains(from))
                    {
                        if (((BaseGalleon)boat).RemovePaint())
                        {
                            m_PaintRemover.Delete();
                        }
                    }

                    else
                    {
                        from.SendLocalizedMessage(1116612); //You must target the main mast of the ship you wish to dye.
                    }
                }
            }
示例#16
0
        public override bool OnDecay(Item item)
        {
            if (BaseBoat.FindBoatAt(item.Location, item.Map) != null)
            {
                BaseBoat           boat = BaseBoat.FindBoatAt(item.Location, item.Map);
                MultiComponentList mcl  = boat.Components;
                Map map = boat.Map;

                IPooledEnumerable eable = map.GetObjectsInBounds(new Rectangle2D(boat.X + mcl.Min.X, boat.Y + mcl.Min.Y, mcl.Width, mcl.Height));
                foreach (object o in eable)
                {
                    if (o is Item && boat.Contains((Item)o))
                    {
                        if ((Item)o == item)
                        {
                            eable.Free();
                            return(false);
                        }
                    }
                }
                eable.Free();
            }
            return(base.OnDecay(item));
        }
示例#17
0
            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_Boat.Contains(m_From) || m_Boat.GetBoatToLocationDistance(m_Boat, 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 + m_ShipRepairTools.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_Boat, m_From, m_DamageType, true);
                }

                //Henchman Repair Assistance
                List <Mobile> m_MobilesOnBoat = m_Boat.GetMobilesOnBoat(false, false);

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

                    if (mobile is HenchmanPirateCarpenter)
                    {
                        HenchmanPirateCarpenter pirateCarpenter = mobile as HenchmanPirateCarpenter;
                        pirateCarpenter.AssistRepair();
                    }
                }
            }
示例#18
0
        public override void OnSpeech(SpeechEventArgs e)
        {
            Mobile from = e.Mobile;

            if (!e.Handled && from.InRange(this, 10) && e.Speech.ToLower() == this.Word)
            {
                BaseBoat boat = BaseBoat.FindBoatAt(from, from.Map);

                if (boat == null)
                {
                    return;
                }

                if (!this.Active)
                {
                    if (boat.TillerMan != null)
                    {
                        boat.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 (boat.Map != null && boat.Map != Map.Internal)
                    {
                        MultiComponentList mcl = boat.Components;

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

                        foreach (NetState ns in eable)
                        {
                            if (ns != null && ns.Mobile != null && boat.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 (boat.CanFit(dest, map, boat.ItemID))
                    {
                        int xOffset = x - boat.X;
                        int yOffset = y - boat.Y;
                        int zOffset = z - boat.Z;

                        boat.Teleport(xOffset, yOffset, zOffset);

                        return;
                    }
                }

                if (boat.TillerMan != null)
                {
                    boat.TillerMan.Say(502508);                       // Ar, I refuse to take that matey through here!
                }
            }
        }
示例#19
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);
                    }
                }
            }
        }
示例#20
0
        public void DockBoat(BaseBoat boat, BaseHouse house)
        {
            List <ISpawnable> list = boat.GetMovingEntities();

            foreach (ISpawnable o in list)
            {
                if (!(o is Item) || o == this || boat.IsComponentItem(o) || o is EffectItem || o == boat.TillerMan)
                {
                    continue;
                }

                Item item = o as Item;

                if (!item.Deleted && boat.Contains(item))
                {
                    if (item is AddonComponent || item is BaseAddon)
                    {
                        BaseAddon addon = item is AddonComponent ? ((AddonComponent)item).Addon : (BaseAddon)item;
                        Item      deed  = addon.Deed;

                        bool retainDeedHue = false;
                        int  hue           = 0;

                        if (addon != null && addon.RetainDeedHue)
                        {
                            retainDeedHue = true;

                            for (int j = 0; hue == 0 && j < addon.Components.Count; ++j)
                            {
                                AddonComponent c = addon.Components[j];

                                if (c.Hue != 0)
                                {
                                    hue = c.Hue;
                                }
                            }
                        }

                        if (deed != null)
                        {
                            if (retainDeedHue)
                            {
                                deed.Hue = hue;
                            }

                            house.DropToMovingCrate(deed);
                        }
                    }
                    else
                    {
                        item.Delete();
                    }
                }

                Container cont;

                if (boat is BaseGalleon)
                {
                    cont = ((BaseGalleon)boat).GalleonHold;
                }
                else
                {
                    cont = boat.Hold;
                }

                if (cont != null)
                {
                    cont.Items.ForEach(i =>
                    {
                        if (i is BaseWeapon)
                        {
                            house.DropToMovingCrate(i);
                        }
                        else
                        {
                            i.Delete();
                        }
                    });
                }
            }

            BaseDockedBoat model = boat.BoatItem;

            if (model == null || model.Deleted)
            {
                model = boat.DockedBoat;
            }

            if (model == null)
            {
                return;
            }

            model.BoatItem = boat;

            if (boat.IsClassicBoat && boat.Owner != null)
            {
                boat.RemoveKeys(boat.Owner);
            }

            house.DropToMovingCrate(model);

            boat.OnDryDock();

            boat.Refresh();
            boat.Internalize();

            list.Clear();
            list.TrimExcess();
        }
示例#21
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Boat == null || m_From == null)
            {
                return;
            }

            if (!m_Boat.Contains(m_From))
            {
                if (BaseBoat.isCarpet(m_Boat))
                {
                    m_From.SendMessage("You have to be on your carpet to do that!");
                }
                else
                {
                    m_From.SendMessage("You have to be on the boat to do that!");
                }
                m_From.CloseGump(typeof(TillerManGump));
                return;
            }

            switch (info.ButtonID)
            {
            case 100: m_Boat.StopMove(true); break;

            case 99: m_Boat.BeginRename(m_From); break;

            case 1:                     // N
            {
                if (m_Boat.Facing == Direction.North)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.North, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.North);
                    }
                }
                else if (m_Boat.Facing == Direction.South)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.South, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.South);
                    }
                }
                else if (m_Boat.Facing == Direction.East)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.West, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.West);
                    }
                }
                else if (m_Boat.Facing == Direction.West)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.East, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.East);
                    }
                }
                break;
            }

            case 2:                     // NE
            {
                if (m_Boat.Facing == Direction.North)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Right, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Right);
                    }
                }
                else if (m_Boat.Facing == Direction.South)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Left, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Left);
                    }
                }
                else if (m_Boat.Facing == Direction.East)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Up, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Up);
                    }
                }
                else if (m_Boat.Facing == Direction.West)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Down, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Down);
                    }
                }
                break;
            }

            case 3:                     // E
            {
                if (m_Boat.Facing == Direction.North)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.East, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.East);
                    }
                }
                else if (m_Boat.Facing == Direction.South)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.West, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.West);
                    }
                }
                else if (m_Boat.Facing == Direction.East)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.North, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.North);
                    }
                }
                else if (m_Boat.Facing == Direction.West)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.South, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.South);
                    }
                }
                break;
            }

            case 4:                     // SE
            {
                if (m_Boat.Facing == Direction.North)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Down, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Down);
                    }
                }
                else if (m_Boat.Facing == Direction.South)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Up, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Up);
                    }
                }
                else if (m_Boat.Facing == Direction.East)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Right, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Right);
                    }
                }
                else if (m_Boat.Facing == Direction.West)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Left, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Left);
                    }
                }
                break;
            }

            case 5:                     // S
            {
                if (m_Boat.Facing == Direction.North)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.South, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.South);
                    }
                }
                else if (m_Boat.Facing == Direction.South)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.North, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.North);
                    }
                }
                else if (m_Boat.Facing == Direction.East)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.East, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.East);
                    }
                }
                else if (m_Boat.Facing == Direction.West)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.West, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.West);
                    }
                }
                break;
            }

            case 6:                     // SW
            {
                if (m_Boat.Facing == Direction.North)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Left, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Left);
                    }
                }
                else if (m_Boat.Facing == Direction.South)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Right, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Right);
                    }
                }
                else if (m_Boat.Facing == Direction.East)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Down, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Down);
                    }
                }
                else if (m_Boat.Facing == Direction.West)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Up, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Up);
                    }
                }
                break;
            }

            case 7:                     // W
            {
                if (m_Boat.Facing == Direction.North)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.West, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.West);
                    }
                }
                else if (m_Boat.Facing == Direction.South)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.East, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.East);
                    }
                }
                else if (m_Boat.Facing == Direction.East)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.South, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.South);
                    }
                }
                else if (m_Boat.Facing == Direction.West)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.North, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.North);
                    }
                }
                break;
            }

            case 8:                     // NW
            {
                if (m_Boat.Facing == Direction.North)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Up, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Up);
                    }
                }
                else if (m_Boat.Facing == Direction.South)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Down, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Down);
                    }
                }
                else if (m_Boat.Facing == Direction.East)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Left, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Left);
                    }
                }
                else if (m_Boat.Facing == Direction.West)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Right, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Right);
                    }
                }
                break;
            }

            case 9:                     // TOGGLE ONE STEP
            {
                if (!ToggleOneStep)
                {
                    ToggleOneStep = true;
                }
                else
                {
                    ToggleOneStep = false;
                }
                break;
            }

            case 10:                            // RAISE / DROP ANCHOR
            {
                if (m_Boat.Anchored)
                {
                    m_Boat.RaiseAnchor(true);
                }
                else
                {
                    m_Boat.LowerAnchor(true);
                }
                break;
            }

            case 11:                            // TURN LEFT/RIGHT/AROUND
            {
                m_Boat.StartTurn(-2, true);     // LEFT
                break;
            }

            case 12:
            {
                m_Boat.StartTurn(2, true);                              // RIGHT
                break;
            }

            case 13:
            {
                m_Boat.StartTurn(-4, true);                             // AROUND
                break;
            }
            }

            m_From.CloseGump(typeof(TillerManGump));
            m_From.SendGump(new TillerManGump(m_From, m_Boat, ToggleOneStep));
        }
示例#22
0
        public override void OnDoubleClick(Mobile from)
        {
            from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1008155);               // You peer into the heavens, seeking the moons...

            from.Send(new MessageLocalizedAffix(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 1008146 + (int)Clock.GetMoonPhase(Map.Trammel, from.X, from.Y), "", AffixType.Prepend, "Trammel : ", ""));

            // Scriptiz : on ne joue pas sur felucca
            //from.Send( new MessageLocalizedAffix( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 1008146 + (int)Clock.GetMoonPhase( Map.Felucca, from.X, from.Y ), "", AffixType.Prepend, "Felucca : ", "" ) );

            PlayerMobile player = from as PlayerMobile;

            /* Scriptiz : Code pour repérer les autres bateaux (source : Alambik) */
            // Get the maximum range the player can see
            // A cartograph master with a tracking master experience lead to see to 125 tiles: A true captain!
            int MinimumRange      = 25; //Regular 800x600 screen + "normal" extra
            int MaximumExtraRange = 100;
            int ExtraRange        = MaximumExtraRange *
                                    ((int)(from.Skills[SkillName.Cartography].Value) +
                                     (int)(from.Skills[SkillName.Tracking].Value)) / 200;
            int range = MinimumRange + ExtraRange;

            foreach (Item item in from.GetItemsInRange(range))
            {
                if (item is BaseBoat)
                {
                    // Player can see the boat
                    BaseBoat baseboat = (BaseBoat)item;
                    if (!(baseboat.Contains(from))) // On va éviter de répeter qu'on voit son propre bateau
                    {
                        /* Scriptiz : implémentation du tracking */
                        // If the player is good at tracking, let him track a mobile on the boat
                        if (from.Skills[SkillName.Tracking].Value * 2 >= from.GetDistanceToSqrt(baseboat.Location))
                        {
                            foreach (Mobile m in baseboat.GetMobilesInRange(15))
                            {
                                if (m == null)
                                {
                                    continue;
                                }
                                if (baseboat.Contains(m))
                                {
                                    from.QuestArrow = new TrackArrow(from, m, range);
                                    break;
                                }
                            }
                        }

                        // Get the name if not too far
                        string name = "un navire";
                        if (from.InRange(item.Location, MinimumRange + MaximumExtraRange / 5))
                        {
                            if (baseboat.ShipName != null)
                            {
                                name = "le" + baseboat.ShipName;
                            }
                        }

                        // Is it far?
                        string distance = "à l'horizon";
                        if (from.InRange(item.Location, MinimumRange + MaximumExtraRange * 1 / 5))
                        {
                            distance = "à côté";
                        }
                        else if (from.InRange(item.Location, MinimumRange + MaximumExtraRange * 2 / 5))
                        {
                            distance = "proche";
                        }
                        else if (from.InRange(item.Location, MinimumRange + MaximumExtraRange * 3 / 5))
                        {
                            distance = "loin";
                        }
                        else if (from.InRange(item.Location, MinimumRange + MaximumExtraRange * 4 / 5))
                        {
                            distance = "très loin";
                        }

                        // Get the relative direction of the seen boat
                        string direction;
                        // north/south
                        if (from.Y < baseboat.Y)
                        {
                            direction = "Sud";
                        }
                        else
                        {
                            direction = "Nord";
                        }
                        // east/west (Scriptiz : correction est <> ouest)
                        if (from.X < baseboat.X)
                        {
                            direction = direction + " Est";
                        }
                        else
                        {
                            direction = direction + " Ouest";
                        }

                        //Does the boat is moving?
                        string mobility = "est immobile";
                        if (baseboat.IsMoving)
                        {
                            mobility = "bouge vers ";
                            switch (baseboat.Moving)
                            {
                            case Direction.North: mobility += "le nord"; break;

                            case Direction.South: mobility += "le sud"; break;

                            case Direction.East: mobility += "l'est"; break;

                            case Direction.West: mobility += "l'ouest"; break;

                            case Direction.Up: mobility += "le nord-ouest"; break;

                            case Direction.Down: mobility += "le sud-est"; break;

                            case Direction.Left: mobility += "le sud-ouest"; break;

                            case Direction.Right: mobility += "le nord-est"; break;

                            default: break;
                            }
                        }
                        from.SendMessage("Vous voyez {0} au {1}. Il est {2} et {3}.", name, direction, distance, mobility);
                    }
                }
            }
            /* Scriptiz : fin du code de Alambik */

            if (player != null)
            {
                QuestSystem qs = player.Quest;

                if (qs is WitchApprenticeQuest)
                {
                    FindIngredientObjective obj = qs.FindObjective(typeof(FindIngredientObjective)) as FindIngredientObjective;

                    if (obj != null && !obj.Completed && obj.Ingredient == Ingredient.StarChart)
                    {
                        int hours, minutes;
                        Clock.GetTime(from.Map, from.X, from.Y, out hours, out minutes);

                        if (hours < 5 || hours > 17)
                        {
                            player.SendLocalizedMessage(1055040);                               // You gaze up into the glittering night sky.  With great care, you compose a chart of the most prominent star patterns.

                            obj.Complete();
                        }
                        else
                        {
                            player.SendLocalizedMessage(1055039);                               // You gaze up into the sky, but it is not dark enough to see any stars.
                        }
                    }
                }
            }
        }
示例#23
0
            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;
                }

                //Boat Searching: Automatic Success for Owner, Co-Owner, Owner
                BaseBoat boat = BaseBoat.FindBoatAt(p, from.Map);

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

                    if (boat.IsFriend(from) || boat.IsCoOwner(from) || boat.IsOwner(from))
                    {
                        List <Mobile> m_MobilesOnBoard = boat.GetMobilesOnBoat(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;
                }
            }
示例#24
0
        public void DockBoat(BaseBoat boat, BaseHouse house)
        {
            foreach (IEntity entity in boat.GetEntitiesOnBoard())
            {
                if (!(entity is Item) || entity == this || boat.IsComponentItem(entity) || entity is EffectItem || entity == boat.TillerMan)
                {
                    continue;
                }

                Item item = entity as Item;

                if (!item.Deleted && boat.Contains(item))
                {
                    if (item is AddonComponent || item is BaseAddon)
                    {
                        BaseAddon addon = item is AddonComponent component ? component.Addon : (BaseAddon)item;
                        Item      deed  = addon.Deed;

                        bool retainDeedHue = false;
                        int  hue           = 0;

                        if (addon.RetainDeedHue)
                        {
                            retainDeedHue = true;

                            for (int j = 0; hue == 0 && j < addon.Components.Count; ++j)
                            {
                                AddonComponent c = addon.Components[j];

                                if (c.Hue != 0)
                                {
                                    hue = c.Hue;
                                }
                            }
                        }

                        if (deed != null)
                        {
                            if (retainDeedHue)
                            {
                                deed.Hue = hue;
                            }

                            house.DropToMovingCrate(deed);
                        }
                    }
                    else
                    {
                        item.Delete();
                    }
                }

                Container cont;

                if (boat is BaseGalleon galleon)
                {
                    cont = galleon.GalleonHold;
                }
                else
                {
                    cont = boat.Hold;
                }

                if (cont != null)
                {
                    for (var index = 0; index < cont.Items.Count; index++)
                    {
                        var i = cont.Items[index];

                        if (i is BaseWeapon)
                        {
                            house.DropToMovingCrate(i);
                        }
                        else
                        {
                            i.Delete();
                        }
                    }
                }
            }

            BaseDockedBoat model = boat.BoatItem;

            if (model == null || model.Deleted)
            {
                model = boat.DockedBoat;
            }

            if (model == null)
            {
                return;
            }

            model.BoatItem = boat;

            if (boat.IsClassicBoat && boat.Owner != null)
            {
                boat.RemoveKeys(boat.Owner);
            }

            house.DropToMovingCrate(model);

            boat.OnDryDock(null);

            boat.Refresh();
            boat.Internalize();
        }