예제 #1
0
 public override void OnAfterDelete()
 {
     if (m_Boat != null)
     {
         m_Boat.Delete();
     }
 }
예제 #2
0
        public override void OnAfterDelete()
        {
            base.OnAfterDelete();

            if (BoatItem != null && !BoatItem.Deleted)
            {
                BoatItem.Delete();
            }
        }
예제 #3
0
        public void OnPlacement(Mobile from, Point3D p)
        {
            if (Deleted)
            {
                return;
            }
            else if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }
            else
            {
                Map map = from.Map;

                if (map == null)
                {
                    return;
                }

                BaseBoat boat = Boat;

                if (boat == null)
                {
                    return;
                }

                p = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);

                if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, boat.ItemID) && map != Map.Ilshenar && map != Map.Malas)
                {
                    Delete();

                    boat.Owner    = from;
                    boat.Anchored = true;
                    boat.ShipName = m_ShipName;

                    uint keyValue = boat.CreateKeys(from);

                    if (boat.PPlank != null)
                    {
                        boat.PPlank.KeyValue = keyValue;
                    }

                    if (boat.SPlank != null)
                    {
                        boat.SPlank.KeyValue = keyValue;
                    }

                    boat.MoveToWorld(p, map);
                }
                else
                {
                    boat.Delete();
                    from.SendLocalizedMessage(1043284);                       // A ship can not be created here.
                }
            }
        }
예제 #4
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            if (m_Selection == null)
            {
                int v = info.ButtonID - 1;

                if (v >= 0 && v < m_List.Count)
                {
                    m_From.SendGump(new ViewBoatsGump(m_From, m_List, (BaseBoat)m_List[v]));
                }
            }
            else if (!m_Selection.Deleted)
            {
                switch (info.ButtonID)
                {
                case 0:
                {
                    m_From.SendGump(new ViewBoatsGump(m_From, m_List, null));
                    break;
                }

                case 1:
                {
                    Map map = m_Selection.Map;

                    if (map != null && map != Map.Internal)
                    {
                        m_From.MoveToWorld(m_Selection.GetMarkedLocation(), map);
                    }

                    m_From.SendGump(new ViewBoatsGump(m_From, m_List, m_Selection));

                    break;
                }

                case 3:
                {
                    m_From.SendGump(new ViewBoatsGump(m_From, m_List, null));
                    m_Selection.Delete();
                    break;
                }

                case 4:
                {
                    m_Selection.TimeOfDecay = DateTime.UtcNow + BaseBoat.BoatDecayDelay;
                    m_From.SendGump(new ViewBoatsGump(m_From, m_List, m_Selection));

                    break;
                }
                }
            }
        }
예제 #5
0
        public void OnSummonBoat(Mobile from, Point3D p)
        {
            Map map = from.Map;

            if (map == null)
            {
                return;
            }

            BaseBoat boat = SummonedBoat;

            if (boat == null)
            {
                return;
            }

            p = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);

            if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, boat.ItemID))
            {
                Delete();

                boat.Owner    = from;
                boat.Anchored = true;

                uint keyValue = boat.CreateKeys(from);

                if (boat.PPlank != null)
                {
                    boat.PPlank.KeyValue = keyValue;
                }

                if (boat.SPlank != null)
                {
                    boat.SPlank.KeyValue = keyValue;
                }

                boat.MoveToWorld(p, map);
            }
            else
            {
                boat.Delete();

                from.SendMessage("A ship cannot be summoned here.");
            }

            from.Frozen = false;
        }
예제 #6
0
            protected override void OnTick()
            {
                if (m_Count == 4)
                {
                    List <Mobile>     targets = new List <Mobile>();
                    IPooledEnumerable eable   = m_Boat.GetMobilesInRange(16);

                    foreach (Mobile m in eable)
                    {
                        if (m is PirateCrew2)
                        {
                            targets.Add(m);
                        }
                    }
                    eable.Free();
                    if (targets.Count > 0)
                    {
                        for (int i = 0; i < targets.Count; ++i)
                        {
                            Mobile m = targets[i];
                            m.Kill();
                        }
                    }
                }
                if (m_Count >= 15)
                {
                    m_Boat.Delete();
                    Stop();
                }
                else
                {
                    if (m_Count < 5)
                    {
                        m_Boat.Location = new Point3D(m_Boat.X, m_Boat.Y, m_Boat.Z - 1);

                        if (m_Boat.TillerMan != null && m_Count < 5)
                        {
                            m_Boat.TillerMan.Say(1007168 + m_Count);
                        }
                    }
                    else
                    {
                        m_Boat.Location = new Point3D(m_Boat.X, m_Boat.Y, m_Boat.Z - 3);
                    }
                    ++m_Count;
                }
            }
예제 #7
0
            protected override void OnTick()
            {
                if (m_Boat == null || m_Mobile == null || m_Boat.Map == Map.Internal)
                {
                    if (m_Mobile != null && _Table.ContainsKey(m_Mobile))
                    {
                        _Table.Remove(m_Mobile);
                    }

                    Stop();
                }
                else if (DateTime.UtcNow > m_End)
                {
                    if (m_Mobile != null && _Table.ContainsKey(m_Mobile))
                    {
                        _Table.Remove(m_Mobile);
                    }

                    m_Boat.Delete();
                    Stop();
                }
            }
예제 #8
0
        public void OnPlacement(Mobile from, Point3D p, int hue)
        {
            if (Deleted)
            {
                return;
            }
            else if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }
            else
            {
                Map    map = from.Map;
                Region reg = Region.Find(from.Location, from.Map);

                if (map == null)
                {
                    return;
                }

                BaseBoat boat = Boat;
                boat.Hue = hue;

                if (boat == null)
                {
                    return;
                }

                p = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);

                bool CanBuild = false;

                if (reg.IsPartOf(typeof(OutDoorBadRegion)) ||
                    reg.IsPartOf(typeof(VillageRegion)) ||
                    reg.IsPartOf(typeof(BargeDeadRegion)) ||
                    reg.IsPartOf(typeof(DeadRegion)) ||
                    reg.IsPartOf(typeof(PirateRegion)) ||
                    reg.IsPartOf(typeof(OutDoorRegion)) ||
                    reg.IsPartOf(typeof(PublicRegion)) ||
                    Server.Misc.Worlds.IsMainRegion(Server.Misc.Worlds.GetRegionName(from.Map, from.Location)))
                {
                    CanBuild = true;
                }

                if (DockSearch.NearDock(from) == false)
                {
                    from.SendMessage("You must be near a dock to launch your ship!");
                }
                else if (BaseBoat.IsValidLocation(p, map) && CanBuild == true && boat.CanFit(p, map, boat.ItemID))
                {
                    Delete();

                    boat.Owner    = from;
                    boat.Anchored = true;
                    boat.ShipName = m_ShipName;

                    if (from.Skills[SkillName.Fishing].Base >= 90)
                    {
                        boat.m_BoatDoor.Visible = true;
                    }

                    uint keyValue = boat.CreateKeys(from);

                    if (boat.PPlank != null)
                    {
                        boat.PPlank.KeyValue = keyValue;
                    }

                    if (boat.SPlank != null)
                    {
                        boat.SPlank.KeyValue = keyValue;
                    }

                    boat.TillerMan.Hue = hue;
                    boat.Hold.Hue      = hue;
                    boat.BoatDoor.Hue  = hue;
                    boat.PPlank.Hue    = hue;
                    boat.SPlank.Hue    = hue;

                    boat.MoveToWorld(p, map);
                    from.PlaySound(0x026);
                }
                else
                {
                    boat.Delete();
                    from.SendLocalizedMessage(1043284);                       // A ship can not be created here.
                }
            }
        }
예제 #9
0
        public void OnPlacement(Mobile from, Point3D p, int hue)
        {
            if (Deleted)
            {
                return;
            }
            else if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }
            else
            {
                string phrase_a = "You must be near a dock to launch your ship!";
                string phrase_b = "A ship can not be launched here.";
                if (BaseBoat.isCarpet(Boat))
                {
                    phrase_b = "The magic of the carpet cannot be used here.";
                }

                Map    map = from.Map;
                Region reg = Region.Find(from.Location, from.Map);

                if (map == null)
                {
                    return;
                }

                if (from.Region.IsPartOf(typeof(HouseRegion)) || BaseBoat.FindBoatAt(from, from.Map) != null)
                {
                    from.SendMessage(phrase_a);
                    return;
                }

                BaseBoat boat = Boat;
                boat.Hue = hue;

                if (boat == null)
                {
                    return;
                }

                p = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);

                bool CanBuild = false;

                if (reg.IsPartOf(typeof(OutDoorBadRegion)) ||
                    reg.IsPartOf(typeof(VillageRegion)) ||
                    reg.IsPartOf(typeof(BargeDeadRegion)) ||
                    reg.IsPartOf(typeof(NecromancerRegion)) ||
                    reg.IsPartOf(typeof(DeadRegion)) ||
                    reg.IsPartOf("the Forgotten Lighthouse") ||
                    reg.IsPartOf("Anchor Rock Docks") ||
                    reg.IsPartOf("Kraken Reef Docks") ||
                    reg.IsPartOf("Savage Sea Docks") ||
                    reg.IsPartOf("Serpent Sail Docks") ||
                    reg.IsPartOf(typeof(PirateRegion)) ||
                    reg.IsPartOf(typeof(OutDoorRegion)) ||
                    reg.IsPartOf(typeof(PublicRegion)) ||
                    Server.Misc.Worlds.IsMainRegion(Server.Misc.Worlds.GetRegionName(from.Map, from.Location)))
                {
                    CanBuild = true;
                }

                if (!DockSearch.NearDock(from) && !BaseBoat.isCarpet(boat))
                {
                    from.SendMessage(phrase_a);
                }
                else if (BaseBoat.IsValidLocation(p, map) && CanBuild == true && boat.CanFit(p, map, boat.ItemID))
                {
                    Delete();

                    boat.Owner    = from;
                    boat.Anchored = true;
                    boat.ShipName = m_ShipName;

                    if (from.Skills[SkillName.Fishing].Base >= 90 && boat.m_BoatDoor != null)
                    {
                        boat.m_BoatDoor.Visible = true; boat.BoatDoor.Hue = hue;
                    }

                    uint keyValue = boat.CreateKeys(from);

                    if (boat.PPlank != null)
                    {
                        boat.PPlank.KeyValue = keyValue;
                    }

                    if (boat.SPlank != null)
                    {
                        boat.SPlank.KeyValue = keyValue;
                    }

                    boat.TillerMan.Hue = hue;
                    boat.Hold.Hue      = hue;
                    boat.PPlank.Hue    = hue;
                    boat.SPlank.Hue    = hue;

                    boat.MoveToWorld(p, map);
                    if (BaseBoat.isCarpet(boat))
                    {
                        from.PlaySound(0x1FD);
                    }
                    else
                    {
                        from.PlaySound(0x026);
                    }
                }
                else
                {
                    boat.Delete();
                    from.SendMessage(phrase_b);
                }
            }
        }
예제 #10
0
        public void OnPlacement(Mobile from, Point3D p)
        {
            if (Deleted)
            {
                return;
            }
            else if (!IsChildOf(from.Backpack))
            {
                from.SendAsciiMessage("That must be in your pack for you to use it.");                   // That must be in your pack for you to use it.
            }
            else
            {
                Map map = from.Map;

                if (map == null)
                {
                    return;
                }

                BaseBoat boat = Boat;

                if (boat == null)
                {
                    return;
                }

                if (from.InRange(this.DockLocation, 20))
                {
                }
                else
                {
                    from.SendAsciiMessage("You are too far away from the location at which the ship was docked.");
                    return;
                }

                p = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);

                if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, boat.ItemID) && map != Map.Ilshenar && map != Map.Malas)
                {
                    Delete();

                    boat.Owner    = from;
                    boat.Anchored = true;
                    boat.ShipName = m_ShipName;

                    uint keyValue = boat.CreateKeys(from);

                    if (boat.PPlank != null)
                    {
                        boat.PPlank.KeyValue = keyValue;
                    }

                    if (boat.SPlank != null)
                    {
                        boat.SPlank.KeyValue = keyValue;
                    }

                    boat.MoveToWorld(p, map);
                }
                else
                {
                    boat.Delete();
                    from.SendAsciiMessage("A ship can not be created here.");                       // A ship can not be created here.
                }
            }
        }
예제 #11
0
        public void OnPlacement(Mobile from, Point3D p, int itemID, Direction d)
        {
            if (Deleted)
            {
                return;
            }
            else if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }
            else
            {
                Map map = from.Map;

                if (map == null)
                {
                    return;
                }

                if (from.AccessLevel < AccessLevel.GameMaster && (map == Map.Ilshenar || map == Map.Malas))
                {
                    from.SendLocalizedMessage(1043284);                       // A ship can not be created here.
                    return;
                }

                if (from.Region.IsPartOf(typeof(HouseRegion)) || (Server.Multis.BaseBoat.FindBoatAt(from, from.Map) != null && !(this is RowBoatDeed)))
                {
                    from.SendLocalizedMessage(1010568, null, 0x25);                       // You may not place a ship while on another ship or inside a house.
                    return;
                }

                m_Direction = d;
                BaseBoat boat = Boat;

                if (boat == null)
                {
                    return;
                }

                p = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);

                if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, itemID))
                {
                    Delete();

                    boat.Owner  = from;
                    boat.ItemID = itemID;

                    if (boat is BaseGalleon)
                    {
                        ((BaseGalleon)boat).SecurityEntry = new SecurityEntry((BaseGalleon)boat);
                        ((BaseGalleon)boat).BaseBoatHue   = RandomBasePaintHue();
                    }

                    if (boat.IsClassicBoat)
                    {
                        uint keyValue = boat.CreateKeys(from);

                        if (boat.PPlank != null)
                        {
                            boat.PPlank.KeyValue = keyValue;
                        }

                        if (boat.SPlank != null)
                        {
                            boat.SPlank.KeyValue = keyValue;
                        }
                    }

                    boat.MoveToWorld(p, map);
                    boat.OnAfterPlacement(true);

                    var addon = LighthouseAddon.GetLighthouse(from);

                    if (addon != null)
                    {
                        if (boat.CanLinkToLighthouse)
                        {
                            from.SendLocalizedMessage(1154592); // You have linked your boat lighthouse.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1154597); // Failed to link to lighthouse.
                        }
                    }
                }
                else
                {
                    boat.Delete();
                    from.SendLocalizedMessage(1043284);                       // A ship can not be created here.
                }
            }
        }
예제 #12
0
            protected override void OnTick()
            {
                if (!m_ShipSpawner.Activated)
                {
                    return;
                }

                DateTime nextSpawnTime = m_ShipSpawner.m_LastActivity + m_ShipSpawner.m_NextActivity;

                if (nextSpawnTime < DateTime.UtcNow)
                {
                    if (m_ShipSpawner.m_Boats.Count < m_ShipSpawner.ShipCount)
                    {
                        int shipsNeeded  = m_ShipSpawner.ShipCount - m_ShipSpawner.m_Boats.Count;
                        int shipsSpawned = 0;

                        if (!m_ShipSpawner.SpawnAllAvailable)
                        {
                            shipsNeeded = 1;
                        }

                        m_ShipSpawner.m_LastActivity = DateTime.UtcNow;
                        m_ShipSpawner.m_NextActivity = TimeSpan.FromMinutes(Utility.RandomMinMax(m_ShipSpawner.m_MinSpawnTime, m_ShipSpawner.m_MaxSpawnTime));

                        //Ships Needed
                        for (int a = 0; a < shipsNeeded; a++)
                        {
                            BaseBoat boat = GetRandomBoatType(m_ShipSpawner.m_ShipTypes);

                            if (boat == null)
                            {
                                continue;
                            }

                            bool shipSpawned = false;

                            //Make 50 Attempts to Find Randomized Location for Boat Spawn Point Before Aborting
                            for (int b = 0; b < 50; b++)
                            {
                                if (shipSpawned)
                                {
                                    break;
                                }

                                Point3D newLocation = new Point3D();

                                int x = m_ShipSpawner.X;

                                int xOffset = Utility.RandomMinMax(0, m_ShipSpawner.SpawnRange);
                                if (Utility.RandomDouble() >= .5)
                                {
                                    xOffset *= -1;
                                }

                                x += xOffset;

                                int y = m_ShipSpawner.Y;

                                int yOffset = Utility.RandomMinMax(0, m_ShipSpawner.SpawnRange);
                                if (Utility.RandomDouble() >= .5)
                                {
                                    yOffset *= -1;
                                }

                                y += yOffset;

                                newLocation.X = x;
                                newLocation.Y = y;
                                newLocation.Z = m_ShipSpawner.Z;

                                Direction newDirection     = Direction.North;
                                int       shipFacingItemID = -1;

                                //Try Preferred Direction first
                                switch (m_ShipSpawner.PreferredDirection)
                                {
                                case Direction.North:
                                    newDirection     = Direction.North;
                                    shipFacingItemID = boat.NorthID;
                                    break;

                                case Direction.Up:
                                    newDirection     = Direction.North;
                                    shipFacingItemID = boat.NorthID;
                                    break;

                                case Direction.East:
                                    newDirection     = Direction.East;
                                    shipFacingItemID = boat.EastID;
                                    break;

                                case Direction.Right:
                                    newDirection     = Direction.East;
                                    shipFacingItemID = boat.EastID;
                                    break;

                                case Direction.South:
                                    newDirection     = Direction.South;
                                    shipFacingItemID = boat.SouthID;
                                    break;

                                case Direction.Down:
                                    newDirection     = Direction.South;
                                    shipFacingItemID = boat.SouthID;
                                    break;

                                case Direction.West:
                                    newDirection     = Direction.West;
                                    shipFacingItemID = boat.WestID;
                                    break;

                                case Direction.Left:
                                    newDirection     = Direction.West;
                                    shipFacingItemID = boat.WestID;
                                    break;

                                default:
                                    newDirection     = Direction.North;
                                    shipFacingItemID = boat.NorthID;
                                    break;
                                }

                                if (boat.CanFit(newLocation, m_ShipSpawner.Map, shipFacingItemID))
                                {
                                    m_ShipSpawner.m_LastActivity = DateTime.UtcNow;

                                    boat.MoveToWorld(newLocation, m_ShipSpawner.Map);
                                    m_ShipSpawner.m_Boats.Add(boat);
                                    boat.m_ShipSpawner = m_ShipSpawner;

                                    Timer.DelayCall(TimeSpan.FromSeconds(.200), delegate
                                    {
                                        if (boat != null)
                                        {
                                            if (!boat.Deleted && boat.CanFit(newLocation, m_ShipSpawner.Map, shipFacingItemID))
                                            {
                                                boat.SetFacing(newDirection);
                                            }
                                        }
                                    });

                                    shipSpawned = true;
                                }

                                //Try Random Direction
                                else
                                {
                                    int randomDirection = Utility.RandomList(1, 2, 3, 4);

                                    switch (randomDirection)
                                    {
                                    case 1:
                                        newDirection     = Direction.North;
                                        shipFacingItemID = boat.NorthID;
                                        break;

                                    case 2:
                                        newDirection     = Direction.East;
                                        shipFacingItemID = boat.EastID;
                                        break;

                                    case 3:
                                        newDirection     = Direction.South;
                                        shipFacingItemID = boat.SouthID;
                                        break;

                                    case 4:
                                        newDirection     = Direction.West;
                                        shipFacingItemID = boat.WestID;
                                        break;
                                    }

                                    if (boat.CanFit(newLocation, m_ShipSpawner.Map, shipFacingItemID))
                                    {
                                        m_ShipSpawner.m_LastActivity = DateTime.UtcNow;

                                        boat.MoveToWorld(newLocation, m_ShipSpawner.Map);
                                        m_ShipSpawner.m_Boats.Add(boat);
                                        boat.m_ShipSpawner = m_ShipSpawner;

                                        Timer.DelayCall(TimeSpan.FromSeconds(.200), delegate
                                        {
                                            boat.SetFacing(newDirection);
                                        });

                                        shipSpawned = true;
                                    }
                                }
                            }

                            if (!shipSpawned)
                            {
                                boat.Delete();
                            }
                        }
                    }
                }
            }
예제 #13
0
        public static void SailBoat(Mobile from, BaseBoat boat)
        {
            bool newsail = true;

            if (m_SailTime.ContainsKey(from))
            {
                if (m_SailTime[from] >= DateTime.Now)
                {
                    newsail = false;
                }
                else
                {
                    m_SailTime.Remove(from);
                }
            }

            if (newsail)
            {
                int MinLevel = 10;
                int MaxLevel = 100;
                //if (Core.Debug) from.SendMessage("TEST: SAILING IN A BOAT");

                Mobile sailor = from;

                LokaiSkills skils = LokaiSkillUtilities.XMLGetSkills(sailor);

                List <Mobile> crew = GetMobilesOn(boat);

                SuccessRating rating = SuccessRating.LokaiSkillNotEnabled;

                foreach (Mobile seaman in crew)
                {
                    skils = LokaiSkillUtilities.XMLGetSkills(sailor);

                    LokaiSkills seamanAbs = LokaiSkillUtilities.XMLGetSkills(seaman);
                    if (seamanAbs.Sailing.Value > skils.Sailing.Value)
                    {
                        sailor = seaman;
                    }
                    MinLevel--;
                    MaxLevel--;
                    if ((MinLevel == 5 && (boat is SmallBoat || boat is SmallDragonBoat)) ||
                        (MinLevel == 0 && (boat is MediumBoat || boat is MediumDragonBoat)) ||
                        (MinLevel == -5 && (boat is LargeBoat || boat is LargeDragonBoat)))
                    {
                        break;
                    }
                }

                int count = 0;
                foreach (Mobile seaman in crew)
                {
                    if ((count == 5 && (boat is SmallBoat || boat is SmallDragonBoat)) ||
                        (count == 10 && (boat is MediumBoat || boat is MediumDragonBoat)) ||
                        (count == 15 && (boat is LargeBoat || boat is LargeDragonBoat)))
                    {
                        break;
                    }
                    else
                    {
                        count++;
                        skils = LokaiSkillUtilities.XMLGetSkills(seaman);
                        if (seaman != sailor)
                        {
                            rating = LokaiSkillUtilities.CheckLokaiSkill(seaman, skils.Sailing, MinLevel, MaxLevel);
                            if (rating >= SuccessRating.PartialSuccess)
                            {
                                seaman.SendMessage("You did your part.");
                            }
                            else
                            {
                                seaman.SendMessage("You could have been more helpful.");
                            }
                        }
                    }
                }

                skils = LokaiSkillUtilities.XMLGetSkills(sailor);

                rating = LokaiSkillUtilities.CheckLokaiSkill(sailor, skils.Sailing, MinLevel, MaxLevel);
                if (rating <= SuccessRating.Failure)
                {
                    int severity = 25;
                    if (rating == SuccessRating.HazzardousFailure)
                    {
                        severity += 4;
                    }
                    else if (rating == SuccessRating.CriticalFailure)
                    {
                        severity += 8;
                    }

                    bool crash = false;

                    foreach (Mobile seaman in crew)
                    {
                        if (!m_SailTime.ContainsKey(seaman))
                        {
                            m_SailTime.Add(seaman, DateTime.Now.AddSeconds(FAILSECONDS));
                        }
                    }

                    switch (Utility.Random(severity))
                    {
                    case 0:
                    case 1:
                    case 2: boat.StartMove(Direction.Down, true); goto case 24;

                    case 3:
                    case 4:
                    case 5: boat.StartMove(Direction.East, true); goto case 24;

                    case 6:
                    case 7:
                    case 8: boat.StartMove(Direction.Left, true); goto case 24;

                    case 9:
                    case 10:
                    case 11: boat.StartMove(Direction.North, true); goto case 24;

                    case 12:
                    case 13:
                    case 14: boat.StartMove(Direction.Right, true); goto case 24;

                    case 15:
                    case 16:
                    case 17: boat.StartMove(Direction.South, true); goto case 24;

                    case 18:
                    case 19:
                    case 20: boat.StartMove(Direction.Up, true); goto case 24;

                    case 21:
                    case 22:
                    case 23: boat.StartMove(Direction.West, true); goto case 24;

                    case 24: boat.StartTurn(Utility.RandomList(2, -2, -4), false); goto case 99;

                    case 99:
                    {
                        foreach (Mobile mobile in crew)
                        {
                            MightGetSick(mobile);
                        }
                        break;
                    }

                    default: crash = true; break;
                    }

                    if (crash)
                    {
                        boat.LowerAnchor(false);
                        List <Item> items = CheckForItems(boat);

                        BaseDockedBoat dboat = boat.DockedBoat;

                        foreach (Mobile seaman in crew)
                        {
                            seaman.SendMessage("The boat runs aground at some nearby land.");
                            boat.RemoveKeys(seaman);
                            if (seaman == boat.Owner)
                            {
                                if (dboat != null)
                                {
                                    seaman.AddToBackpack(dboat);
                                }
                            }
                        }

                        boat.Delete();

                        foreach (Mobile seaman in crew)
                        {
                            Strand(seaman);
                        }
                        if (items.Count > 0)
                        {
                            for (int v = 0; v < items.Count; v++)
                            {
                                int x = from.X + Utility.Random(7) - 3;
                                int y = from.Y + Utility.Random(7) - 3;
                                items[v].MoveToWorld(new Point3D(x, y, from.Z));
                            }
                        }
                    }
                    else
                    {
                        foreach (Mobile seaman in crew)
                        {
                            seaman.SendMessage("You go off course slightly.");
                        }
                    }
                }
                else
                {
                    //if (Core.Debug) from.SendMessage("TEST: SAILING SUCCESSFUL.");

                    foreach (Mobile seaman in crew)
                    {
                        seaman.SendMessage("You feel the gentle breeze of the open sea.");
                        if (!m_SailTime.ContainsKey(seaman))
                        {
                            m_SailTime.Add(seaman, DateTime.Now.AddSeconds(SAILSECONDS));
                        }
                    }
                }
            }
        }
예제 #14
0
        public void OnPlacement(Mobile from, Point3D p)
        {
            PlayerMobile player = from as PlayerMobile;

            if (Deleted)
            {
                return;
            }

            else if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
            }
            else
            {
                Map map = from.Map;

                if (map == null)
                {
                    return;
                }

                if (from.AccessLevel < AccessLevel.GameMaster && map != Map.Felucca)
                {
                    from.SendLocalizedMessage(1043284); // A ship can not be created here.
                    return;
                }

                if (from.Region.IsPartOf(typeof(HouseRegion)) || BaseBoat.FindBoatAt(from, from.Map) != null)
                {
                    from.SendLocalizedMessage(1010568, null, 0x25); // You may not place a ship while on another ship or inside a house.
                    return;
                }

                if (from.GetDistanceToSqrt(p) > 10)
                {
                    from.SendMessage("You cannot place a ship that far away from land.");
                    return;
                }

                foreach (BaseBoat boatInstance in BaseBoat.m_Instances)
                {
                    if (boatInstance.Owner == from)
                    {
                        from.SendMessage("You already have a boat at sea.");
                        return;
                    }
                }

                BaseBoat boat = Boat;

                if (boat == null)
                {
                    return;
                }

                p = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);

                Direction newDirection     = Direction.North;
                int       shipFacingItemID = -1;

                switch (from.Direction)
                {
                case Direction.North:
                    newDirection     = Direction.North;
                    shipFacingItemID = boat.NorthID;
                    break;

                case Direction.Up:
                    newDirection     = Direction.North;
                    shipFacingItemID = boat.NorthID;
                    break;

                case Direction.East:
                    newDirection     = Direction.East;
                    shipFacingItemID = boat.EastID;
                    break;

                case Direction.Right:
                    newDirection     = Direction.East;
                    shipFacingItemID = boat.EastID;
                    break;

                case Direction.South:
                    newDirection     = Direction.South;
                    shipFacingItemID = boat.SouthID;
                    break;

                case Direction.Down:
                    newDirection     = Direction.South;
                    shipFacingItemID = boat.SouthID;
                    break;

                case Direction.West:
                    newDirection     = Direction.West;
                    shipFacingItemID = boat.WestID;
                    break;

                case Direction.Left:
                    newDirection     = Direction.West;
                    shipFacingItemID = boat.WestID;
                    break;

                default:
                    newDirection     = Direction.North;
                    shipFacingItemID = boat.NorthID;
                    break;
                }

                if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, shipFacingItemID))
                {
                    //Set Boat Properties Stored in Deed
                    boat.CoOwners       = m_CoOwners;
                    boat.Friends        = m_Friends;
                    boat.GuildAsFriends = GuildAsFriends;

                    boat.Owner    = from;
                    boat.ShipName = m_ShipName;

                    boat.TargetingMode      = m_TargetingMode;
                    boat.TimeLastRepaired   = m_TimeLastRepaired;
                    boat.NextTimeRepairable = m_NextTimeRepairable;

                    boat.DecayTime = DateTime.UtcNow + boat.BoatDecayDelay;

                    boat.Anchored = true;

                    ShipUniqueness.GenerateShipUniqueness(boat);

                    boat.HitPoints  = HitPoints;
                    boat.SailPoints = SailPoints;
                    boat.GunPoints  = GunPoints;

                    bool fullSailPoints = (boat.SailPoints == boat.BaseMaxSailPoints);
                    bool fullGunPoints  = (boat.GunPoints == boat.BaseMaxGunPoints);
                    bool fullHitPoints  = (boat.HitPoints == boat.BaseMaxHitPoints);

                    boat.SetFacing(newDirection);

                    boat.MoveToWorld(p, map);

                    Delete();

                    BoatRune boatRune = new BoatRune(boat, from);
                    boat.BoatRune = boatRune;

                    BoatRune boatBankRune = new BoatRune(boat, from);
                    boat.BoatBankRune = boatBankRune;

                    bool addedToPack = false;
                    bool addedToBank = false;

                    if (from.AddToBackpack(boatRune))
                    {
                        addedToPack = true;
                    }

                    BankBox bankBox = from.FindBankNoCreate();

                    if (bankBox != null)
                    {
                        if (bankBox.Items.Count < bankBox.MaxItems)
                        {
                            bankBox.AddItem(boatBankRune);
                            addedToBank = true;
                        }
                    }

                    string message = "You place the ship at sea. A boat rune has been placed both in your bankbox and your backpack.";

                    if (!addedToPack && !addedToBank)
                    {
                        message = "You place the ship at sea. However, there was no room in neither your bankbox nor your backpack to place boat runes.";
                    }

                    else if (!addedToPack)
                    {
                        message = "You place the ship at sea. A boat rune was placed in your bankbox, however, there was no room in your backpack to place a boat rune.";
                    }

                    else if (!addedToBank)
                    {
                        message = "You place the ship at sea. A boat rune was placed in your backpack, however, there was no room in your bankbox to place a boat rune.";
                    }

                    from.SendMessage(message);
                }

                else
                {
                    boat.Delete();
                    from.SendMessage("A boat cannot be placed there. You may change your facing to change the direction of the boat placement.");
                }
            }
        }
예제 #15
0
        public void OnPlacement(Mobile from, Point3D p, int hue)
        {
            if (Deleted)
            {
                return;
            }
            else if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }
            else
            {
                Map map = from.Map;

                if (map == null)
                {
                    return;
                }

                if (from.Region.IsPartOf(typeof(HouseRegion)) || BaseBoat.FindBoatAt(from, from.Map) != null)
                {
                    from.SendLocalizedMessage(1010568, null, 0x25);                       // You may not place a ship while on another ship or inside a house.
                    return;
                }

                BaseBoat boat = Boat;
                boat.Hue = hue;

                if (boat == null)
                {
                    return;
                }

                p = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);

                if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, boat.ItemID))
                {
                    Delete();

                    boat.Owner    = from;
                    boat.Anchored = true;

                    if (from.Skills[SkillName.Fishing].Base >= 90)
                    {
                        boat.m_BoatDoor.Visible = true;
                    }

                    uint keyValue = boat.CreateKeys(from);

                    if (boat.PPlank != null)
                    {
                        boat.PPlank.KeyValue = keyValue;
                    }

                    if (boat.SPlank != null)
                    {
                        boat.SPlank.KeyValue = keyValue;
                    }

                    boat.TillerMan.Hue = hue;
                    boat.Hold.Hue      = hue;
                    boat.BoatDoor.Hue  = hue;
                    boat.PPlank.Hue    = hue;
                    boat.SPlank.Hue    = hue;

                    boat.MoveToWorld(p, map);
                    from.PlaySound(0x026);
                }
                else
                {
                    boat.Delete();
                    from.SendLocalizedMessage(1043284);                       // A ship can not be created here.
                }
            }
        }
예제 #16
0
        public void OnPlacement(Mobile from, Point3D p, int itemID, Direction d)
        {
            if (Deleted)
            {
                return;
            }
            else
            {
                Map map = from.Map;

                if (map == null)
                {
                    return;
                }

                if (from.AccessLevel < AccessLevel.GameMaster && (map == Map.Ilshenar || map == Map.Malas))
                {
                    from.SendLocalizedMessage(1043284); // A ship can not be created here.
                    return;
                }

                BaseBoat b = BaseBoat.FindBoatAt(from, from.Map);

                if (from.Region.IsPartOf(typeof(HouseRegion)) || b != null && (b.GetType() == Boat.GetType() || !b.IsRowBoat && !(this is RowBoatDeed)))
                {
                    from.SendLocalizedMessage(1010568, null, 0x25); // You may not place a ship while on another ship or inside a house.
                    return;
                }

                BoatDirection = d;
                BaseBoat boat = Boat;

                if (boat == null)
                {
                    return;
                }

                p = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z);

                if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, itemID))
                {
                    if (boat.IsRowBoat)
                    {
                        BaseBoat lastrowboat = World.Items.Values.OfType <BaseBoat>().Where(x => x.Owner == from && x.IsRowBoat && x.Map != Map.Internal && !x.GetMobilesOnBoard().Any()).OrderByDescending(y => y.Serial).FirstOrDefault();

                        if (lastrowboat != null)
                        {
                            lastrowboat.Delete();
                        }
                    }
                    else
                    {
                        Delete();
                    }

                    boat.Owner  = from;
                    boat.ItemID = itemID;

                    if (boat is BaseGalleon)
                    {
                        ((BaseGalleon)boat).SecurityEntry = new SecurityEntry((BaseGalleon)boat);
                        ((BaseGalleon)boat).BaseBoatHue   = RandomBasePaintHue();
                    }

                    if (boat.IsClassicBoat)
                    {
                        uint keyValue = boat.CreateKeys(from);

                        if (boat.PPlank != null)
                        {
                            boat.PPlank.KeyValue = keyValue;
                        }

                        if (boat.SPlank != null)
                        {
                            boat.SPlank.KeyValue = keyValue;
                        }
                    }

                    boat.MoveToWorld(p, map);
                    boat.OnAfterPlacement(true);

                    var addon = LighthouseAddon.GetLighthouse(from);

                    if (addon != null)
                    {
                        if (boat.CanLinkToLighthouse)
                        {
                            from.SendLocalizedMessage(1154592); // You have linked your boat lighthouse.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1154597); // Failed to link to lighthouse.
                        }
                    }
                }
                else
                {
                    boat.Delete();
                    from.SendLocalizedMessage(1043284); // A ship can not be created here.
                }
            }
        }
예제 #17
0
        private void OnTarget(Mobile from, object targeted)
        {
            BaseBoat ship = null;

            if (targeted is BaseBoat)
            {
                ship = (BaseBoat)targeted;
            }
            else if (targeted is TillerMan)
            {
                ship = ((TillerMan)targeted).Boat;
            }
            else if (targeted is Plank)
            {
                ship = ((Plank)targeted).Boat;
            }
            else if (targeted is Hold)
            {
                ship = ((Hold)targeted).Boat;
            }

            if (ship == null)
            {
                SayTo(from, true, "That is not a ship!");
                return;
            }
            else if (!InRange(ship.Location, 50))
            {
                SayTo(from, true, "That is too far away!");
                return;
            }

            BaseBoat.DryDockResult res = ship.CheckDryDock(from);
            switch (res)
            {
            case BaseBoat.DryDockResult.Dead:
                SayTo(from, true, "Thou art dead and cannot do that.");
                break;

            case BaseBoat.DryDockResult.Decaying:
                SayTo(from, true, "I will not dock a boat that is sinking!");
                break;

            case BaseBoat.DryDockResult.Hold:
                SayTo(from, true, "You must clear the ship's hold before you can dock it.");
                break;

            case BaseBoat.DryDockResult.Items:
                SayTo(from, true, "You must clear the ship's deck of items before docking it.");
                break;

            case BaseBoat.DryDockResult.Mobiles:
                SayTo(from, true, "You cannot dock a ship with beings on board!");
                break;

            case BaseBoat.DryDockResult.NoKey:
                SayTo(from, true, "That ship does not belong to you.");
                break;

            case BaseBoat.DryDockResult.NotAnchored:
                SayTo(from, true, "The ship is not anchored.");
                break;

            case BaseBoat.DryDockResult.Valid:
            {
                if (!from.BankBox.ConsumeTotal(typeof(Gold), 25))
                {
                    SayTo(from, true, "You do not have 25 gold in your bank account to pay for the docking of this ship.");
                    break;
                }

                BaseDockedBoat claim = ship.DockedBoat;
                if (claim == null)
                {
                    break;
                }

                StringBuilder sb = new StringBuilder("a ship claim ticket");
                if (this.Region.Name != "")
                {
                    sb.AppendFormat(" from {0}", this.Region.Name);
                }
                if (claim.ShipName != null && claim.ShipName != "")
                {
                    sb.AppendFormat(" for the {0}", claim.ShipName);
                }
                claim.Name         = sb.ToString();
                claim.DockLocation = this.Home != Point3D.Zero ? this.Home : ship.Location;

                ship.RemoveKeys(from);
                ship.Delete();

                from.AddToBackpack(claim);

                SayTo(from, true, "Here is your claim ticket.  I suggest you store it in a safe place.");
                break;
            }
            }
        }
예제 #18
0
파일: TillerMan.cs 프로젝트: silky/ModernUO
 public override void OnAfterDelete()
 {
     m_Boat?.Delete();
 }
예제 #19
0
        public void OnPlacement(Mobile from, Point3D p)
        {
            if (Deleted)
            {
                return;
            }
            else if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
            }
            else
            {
                Map map = from.Map;

                if (map == null)
                {
                    return;
                }

                if (from.AccessLevel < AccessLevel.GameMaster && (map == Map.Ilshenar || map == Map.Malas))
                {
                    from.SendLocalizedMessage(1043284); // A ship can not be created here.
                    return;
                }

                if (from.Region.IsPartOf(typeof(HouseRegion)) || BaseBoat.FindBoatAt(from, from.Map) != null)
                {
                    from.SendLocalizedMessage(1010568, null, 0x25); // You may not place a ship while on another ship or inside a house.
                    return;
                }

                BaseBoat boat = Boat;

                if (boat == null)
                {
                    return;
                }

                p = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);

                if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, boat.ItemID))
                {
                    Delete();

                    boat.Owner    = from;
                    boat.Anchored = true;

                    uint keyValue = boat.CreateKeys(from);

                    if (boat.PPlank != null)
                    {
                        boat.PPlank.KeyValue = keyValue;
                    }

                    if (boat.SPlank != null)
                    {
                        boat.SPlank.KeyValue = keyValue;
                    }

                    boat.MoveToWorld(p, map);
                }
                else
                {
                    boat.Delete();
                    from.SendLocalizedMessage(1043284); // A ship can not be created here.
                }
            }
        }
예제 #20
0
        public void OnPlacement(Mobile from, Point3D p)
        {
            if (Deleted)
            {
                return;
            }

            if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                 // That must be in your pack for you to use it.
            }
            else
            {
                Map map = from.Map;

                if (map == null)
                {
                    return;
                }

                if (from.AccessLevel < AccessLevel.GameMaster && (map == Map.Ilshenar || map == Map.Malas))
                {
                    from.SendLocalizedMessage(1043284);                     // A ship can not be created here.
                    return;
                }

                if (from.Region.IsPartOf(typeof(HouseRegion)) || BaseBoat.FindBoatAt(from, from.Map) != null)
                {
                    // You may not place a ship while on another ship or inside a house.
                    from.SendLocalizedMessage(1010568, null, 0x25);
                    return;
                }

                BaseBoat boat = Boat;

                if (boat == null)
                {
                    return;
                }

                p = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z);

                if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, boat.ItemID))
                {
                    Delete();

                    boat.Owner    = from;
                    boat.Anchored = true;

                    uint keyValue = boat.CreateKeys(from);

                    if (boat.PPlank != null)
                    {
                        boat.PPlank.KeyValue = keyValue;
                    }

                    if (boat.SPlank != null)
                    {
                        boat.SPlank.KeyValue = keyValue;
                    }

                    foreach (BoatComponent component in boat.BoatComponents)
                    {
                        if (component is BoatRope)
                        {
                            ((BoatRope)component).KeyValue = keyValue;
                        }
                    }

                    boat.MoveToWorld(p, map);
                    from.SendGump(
                        new WarningGump(
                            1060637,
                            30720,
                            "!!! WARNING WARNING WARNING WARNING !!!\nBoats are SINKABLE by using cannons. When a boat has sustained significant damage, it will also be BOARDABLE (the planks or ropes will open to anybody). This means anything that you have on the boat is at risk! The owner of a sunken boat can (through a deed that appears in their bank) either pay a ransom to those who destroyed the boat OR risk venturing out to repair the boat themselves, in which case they have a certain time window to do so or else it can be repaired and captured by anybody else (and therefore LOST TO THEM). Boat deeds and dry-docked boats ARE blessed.",
                            0xFFC000,
                            320,
                            240,
                            null,
                            null));
                }
                else
                {
                    boat.Delete();
                    from.SendLocalizedMessage(1043284);                     // A ship can not be created here.
                }
            }
        }