Пример #1
0
        public void Spawn(PlunderZone zone, int amount)
        {
            Map map = Map.Trammel;

            if (zone == PlunderZone.Fel)
            {
                map = Map.Felucca;
            }
            else if (zone > PlunderZone.Fel)
            {
                map = Map.Tokuno;
            }

            for (int i = 0; i < amount; i++)
            {
                Rectangle2D rec = _Zones[(int)zone];
                Point3D     p;

                while (true)
                {
                    p = map.GetRandomSpawnPoint(rec); //new Point3D(rec.X + Utility.Random(rec.Width), rec.Y + Utility.RandomMinMax(rec.Start.X, rec.Height), -5);

                    if (p.Z != -5)
                    {
                        p.Z = -5;
                    }

                    Rectangle2D bounds = new Rectangle2D(p.X - 7, p.Y - 7, 15, 15);

                    bool badSpot = false;

                    for (int x = bounds.Start.X; x <= bounds.Start.X + bounds.Width; x++)
                    {
                        for (int y = bounds.Start.Y; y <= bounds.Start.Y + bounds.Height; y++)
                        {
                            if (BaseBoat.FindBoatAt(new Point3D(x, y, -5), map) != null || !SpecialFishingNet.ValidateDeepWater(map, x, y))
                            {
                                badSpot = true;
                                break;
                            }
                        }

                        if (badSpot)
                        {
                            break;
                        }
                    }

                    if (!badSpot)
                    {
                        IPooledEnumerable eable = map.GetMobilesInBounds(bounds);

                        foreach (Mobile m in eable)
                        {
                            if (m.AccessLevel == AccessLevel.Player)
                            {
                                badSpot = true;
                                break;
                            }
                        }

                        eable.Free();

                        if (!badSpot)
                        {
                            PlunderBeaconAddon beacon = new PlunderBeaconAddon();
                            beacon.MoveToWorld(p, map);

                            PlunderBeacons[zone].Add(beacon);
                            break;
                        }
                    }
                }
            }
        }
Пример #2
0
        public void FindCreature(Mobile from, int creatureLevel)
        {
            if (from == null)
            {
                return;
            }

            PlayerMobile player = from as PlayerMobile;

            if (player == null)
            {
                return;
            }

            int waterLocationChecks = 20;

            int minSpawnRadius = 3;
            int maxSpawnRadius = 6;

            bool foundWaterSpot   = false;
            bool spawnedCreatures = false;

            Point3D spawnLocation = Location;
            Point3D newLocation   = new Point3D();

            for (int a = 0; a < waterLocationChecks; a++)
            {
                int x = X;

                int xOffset = Utility.RandomMinMax(minSpawnRadius, maxSpawnRadius);
                if (Utility.RandomDouble() >= .5)
                {
                    xOffset *= -1;
                }

                x += xOffset;

                int y = Y;

                int yOffset = Utility.RandomMinMax(minSpawnRadius, maxSpawnRadius);
                if (Utility.RandomDouble() >= .5)
                {
                    yOffset *= -1;
                }

                y += yOffset;

                newLocation.X = x;
                newLocation.Y = y;
                newLocation.Z = -5;

                bool waterTile = BaseBoat.IsWaterTile(newLocation, Map);

                if (waterTile)
                {
                    if (BaseBoat.FindBoatAt(newLocation, Map) != null)
                    {
                        continue;
                    }

                    SpellHelper.AdjustField(ref spawnLocation, Map, 12, false);

                    foundWaterSpot = true;
                    break;
                }
            }

            if (!foundWaterSpot)
            {
                return;
            }

            int count = 0;

            switch (creatureLevel)
            {
            case 1:
                count = Utility.RandomMinMax(1, 2);

                for (int a = 0; a < count; a++)
                {
                    BaseCreature bc_Creature = new Puddle();

                    bc_Creature.m_WasFishedUp = true;
                    bc_Creature.MoveToWorld(spawnLocation, from.Map);
                    spawnedCreatures = true;
                }

                if (spawnedCreatures)
                {
                    from.PublicOverheadMessage(MessageType.Regular, 0, false, "*something rises from the water*");
                }
                break;

            case 2:
                count = Utility.RandomMinMax(1, 2);

                for (int a = 0; a < count; a++)
                {
                    BaseCreature bc_Creature = new WaterElemental();

                    bc_Creature.m_WasFishedUp = true;
                    bc_Creature.MoveToWorld(spawnLocation, from.Map);
                    spawnedCreatures = true;
                }

                if (spawnedCreatures)
                {
                    from.PublicOverheadMessage(MessageType.Regular, 0, false, "*something rises from the water*");
                }
                break;

            case 3:
                count = Utility.RandomMinMax(1, 2);

                for (int a = 0; a < count; a++)
                {
                    BaseCreature bc_Creature = new DeepSeaSerpent();

                    bc_Creature.m_WasFishedUp = true;
                    bc_Creature.MoveToWorld(spawnLocation, from.Map);
                    spawnedCreatures = true;
                }

                if (spawnedCreatures)
                {
                    from.PublicOverheadMessage(MessageType.Regular, 0, false, "*something rises from the water*");
                }
                break;

            case 4:
                count = Utility.RandomMinMax(1, 2);

                for (int a = 0; a < count; a++)
                {
                    BaseCreature bc_Creature = new Kraken();

                    bc_Creature.m_WasFishedUp = true;
                    bc_Creature.MoveToWorld(spawnLocation, from.Map);
                    spawnedCreatures = true;
                }

                if (spawnedCreatures)
                {
                    from.PublicOverheadMessage(MessageType.Regular, 0, false, "*something rises from the water*");
                }
                break;
            }
        }
Пример #3
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            BaseBoat  boat = BaseBoat.FindBoatAt(m_From, m_From.Map);
            Container pack = m_From.Backpack;

            if (boat == null)
            {
                return;
            }
            if (pack != null)               // && pack.ConsumeTotal( typeof( Gold ), 2 ) )
            {
                switch (info.ButtonID)
                {
                case 1:                 // Drop Anchor
                {
                    boat.LowerAnchor(true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 2:                 // Raise Anchor
                {
                    boat.RaiseAnchor(true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 3:                 // Forward
                {
                    boat.StartMove(Direction.North, true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 4:                 // Back
                {
                    boat.StartMove(Direction.South, true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 5:                 // Left
                {
                    boat.StartMove(Direction.West, true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 6:                 // Right
                {
                    boat.StartMove(Direction.East, true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 7:                 // Stop
                {
                    boat.StopMove(true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 8:                 // TurnLeft
                {
                    boat.StartTurn(-2, true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 9:                 // TurnRight
                {
                    boat.StartTurn(2, true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 10:                 // OneForward
                {
                    boat.OneMove(Direction.North);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 11:                 // OneBack
                {
                    boat.OneMove(Direction.South);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 12:                 // OneLeft
                {
                    boat.OneMove(Direction.West);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 13:                 // OneRight
                {
                    boat.OneMove(Direction.East);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 14:                 // LeftForward
                {
                    boat.StartMove(Direction.Up, true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 15:                 // RightForward
                {
                    boat.StartMove(Direction.Right, true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }
                }
            }
        }
Пример #4
0
        public void Mark(Mobile m)
        {
            RecallRuneEmpty();

            m_Marked = true;

            bool setDesc = false;

            m_Galleon = BaseBoat.FindBoatAt(m) as BaseGalleon;

            if (m_Galleon != null)
            {
                Type = RecallRuneType.Ship;
            }
            else
            {
                m_House = BaseHouse.FindHouseAt(m);

                if (m_House == null)
                {
                    Target      = m.Location;
                    m_TargetMap = m.Map;

                    Type = RecallRuneType.Normal;
                }
                else
                {
                    HouseSign sign = m_House.Sign;

                    if (sign != null)
                    {
                        m_Description = sign.Name;
                    }
                    else
                    {
                        m_Description = null;
                    }

                    if (m_Description == null || (m_Description = m_Description.Trim()).Length == 0)
                    {
                        m_Description = "an unnamed house";
                    }

                    setDesc = true;

                    int x = m_House.BanLocation.X;
                    int y = m_House.BanLocation.Y + 2;
                    int z = m_House.BanLocation.Z;

                    Map map = m_House.Map;

                    if (map != null && !map.CanFit(x, y, z, 16, false, false))
                    {
                        z = map.GetAverageZ(x, y);
                    }

                    Target      = new Point3D(x, y, z);
                    m_TargetMap = map;

                    Type = RecallRuneType.Shop;
                }
            }

            if (!setDesc)
            {
                m_Description = BaseRegion.GetRuneNameFor(Region.Find(Target, m_TargetMap));
            }

            CalculateHue();
            InvalidateProperties();
        }
Пример #5
0
        public void SpawnTentacle()
        {
            if (Combatant == null)
            {
                m_NextSpawn = DateTime.UtcNow + SpawnRate;
                return;
            }

            Map map = Map;

            List <Mobile> list = new List <Mobile>();

            IPooledEnumerable eable = GetMobilesInRange(15);

            foreach (Mobile m in eable)
            {
                if (m == this || !CanBeHarmful(m))
                {
                    continue;
                }

                if (m is BaseCreature && (((BaseCreature)m).Controlled || ((BaseCreature)m).Summoned || ((BaseCreature)m).Team != Team))
                {
                    list.Add(m);
                }
                else if (m.Player)
                {
                    list.Add(m);
                }
            }
            eable.Free();

            if (list.Count > 0)
            {
                Mobile   spawn = list[Utility.Random(list.Count)];
                BaseBoat boat  = BaseBoat.FindBoatAt(spawn, map);
                Point3D  loc   = spawn.Location;

                for (int i = 0; i < 25; i++)
                {
                    Point3D spawnLoc = Point3D.Zero;

                    if (boat != null)
                    {
                        spawnLoc = GetValidPoint(boat, map, 4);
                    }
                    else
                    {
                        int y = Utility.RandomMinMax(loc.X - 10, loc.Y + 10);
                        int x = Utility.RandomMinMax(loc.X - 10, loc.Y + 10);
                        int z = map.GetAverageZ(x, y);

                        spawnLoc = new Point3D(x, y, z);
                    }

                    if (Spells.SpellHelper.CheckMulti(spawnLoc, map))
                    {
                        continue;
                    }

                    LandTile t = map.Tiles.GetLandTile(spawnLoc.X, spawnLoc.Y);

                    if (IsSeaTile(t) && spawnLoc != Point3D.Zero)
                    {
                        GiantTentacle tent = new GiantTentacle(this);

                        tent.MoveToWorld(spawnLoc, map);
                        tent.Home      = tent.Location;
                        tent.RangeHome = 15;
                        tent.Team      = Team;
                        if (spawn != this)
                        {
                            tent.Combatant = spawn;
                        }
                        break;
                    }
                }
            }

            m_NextSpawn = DateTime.UtcNow + SpawnRate;
        }
Пример #6
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (!m_Town.IsFinance(m_From) || m_Town.Owner != m_Faction)
            {
                m_From.SendLocalizedMessage(1010339); // You no longer control this city
                return;
            }

            if (!FromButtonID(info.ButtonID, out int type, out int index))
            {
                return;
            }

            switch (type)
            {
            case 0: // general
            {
                switch (index)
                {
                case 0: // set price
                {
                    int[] switches = info.Switches;

                    if (switches.Length == 0)
                    {
                        break;
                    }

                    int opt    = switches[0];
                    int newTax = 0;

                    if (opt >= 1 && opt <= m_PriceOffsets.Length)
                    {
                        newTax = m_PriceOffsets[opt - 1];
                    }

                    if (m_Town.Tax == newTax)
                    {
                        break;
                    }

                    if (m_From.AccessLevel == AccessLevel.Player && !m_Town.TaxChangeReady)
                    {
                        TimeSpan remaining = DateTime.UtcNow - (m_Town.LastTaxChange + Town.TaxChangePeriod);

                        if (remaining.TotalMinutes < 4)
                        {
                            m_From.SendLocalizedMessage(
                                1042165); // You must wait a short while before changing prices again.
                        }
                        else if (remaining.TotalMinutes < 10)
                        {
                            m_From.SendLocalizedMessage(
                                1042166); // You must wait several minutes before changing prices again.
                        }
                        else if (remaining.TotalHours < 1)
                        {
                            m_From.SendLocalizedMessage(
                                1042167); // You must wait up to an hour before changing prices again.
                        }
                        else if (remaining.TotalHours < 4)
                        {
                            m_From.SendLocalizedMessage(
                                1042168); // You must wait a few hours before changing prices again.
                        }
                        else
                        {
                            m_From.SendLocalizedMessage(
                                1042169); // You must wait several hours before changing prices again.
                        }
                    }
                    else
                    {
                        m_Town.Tax = newTax;

                        if (m_From.AccessLevel == AccessLevel.Player)
                        {
                            m_Town.LastTaxChange = DateTime.UtcNow;
                        }
                    }

                    break;
                }
                }

                break;
            }

            case 1: // make vendor
            {
                List <VendorList> vendorLists = m_Town.VendorLists;

                if (index >= 0 && index < vendorLists.Count)
                {
                    VendorList vendorList = vendorLists[index];

                    if (Town.FromRegion(m_From.Region) != m_Town)
                    {
                        m_From.SendLocalizedMessage(1010305); // You must be in your controlled city to buy Items
                    }
                    else if (vendorList.Vendors.Count >= vendorList.Definition.Maximum)
                    {
                        m_From.SendLocalizedMessage(
                            1010306); // You currently have too many of this enhancement type to place another
                    }
                    else if (BaseBoat.FindBoatAt(m_From.Location, m_From.Map) != null)
                    {
                        m_From.SendMessage("You cannot place a vendor here");
                    }
                    else if (m_Town.Silver >= vendorList.Definition.Price)
                    {
                        BaseFactionVendor vendor = vendorList.Construct(m_Town, m_Faction);

                        if (vendor != null)
                        {
                            m_Town.Silver -= vendorList.Definition.Price;

                            vendor.MoveToWorld(m_From.Location, m_From.Map);
                            vendor.Home = vendor.Location;
                        }
                    }
                }

                break;
            }
            }
        }
Пример #7
0
        public void OnPlacement(Mobile from, Point3D p, int itemID, Direction d)
        {
            if (Deleted)
            {
                return;
            }

            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 && !IsRowBoatDeed))
            {
                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.MobilesOnBoard.Any()).OrderByDescending(y => y.Serial).FirstOrDefault();

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

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

                if (boat is BaseGalleon galleon)
                {
                    galleon.SecurityEntry = new SecurityEntry(galleon);
                    galleon.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);

                LighthouseAddon 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.
            }
        }
Пример #8
0
        public override void OnThink()
        {
            base.OnThink();

            if (m_NextSpawn < DateTime.UtcNow && m_Tentacles.Count < SpawnMax)
            {
                SpawnTentacle();
            }

            if (m_NextTeleport < DateTime.UtcNow && Combatant is Mobile m && !InRange(m, RangeFight) && BaseBoat.FindBoatAt(m, Map) != null)
            {
                DoTeleport(m.Location);
            }
        }
Пример #9
0
        public override void OnDoubleClick(Mobile from)
        {
            if (m_Boat == null || from == null)
            {
                return;
            }

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

            int  range   = boat != null && boat == this.Boat ? 3 : 8;
            bool canMove = false;

            if (m_Boat != null)
            {
                if (m_Boat.Owner == from && m_Boat.Status > 1043010)
                {
                    from.SendLocalizedMessage(1043294); // Your ship's age and contents have been refreshed.
                }

                m_Boat.Refresh();
            }

            if (boat != null && m_Boat != boat)
            {
                if (boat.Owner == from && boat.Status > 1043010)
                {
                    from.SendLocalizedMessage(1043294); // Your ship's age and contents have been refreshed.
                }

                boat.Refresh();
            }

            if (!from.InRange(this.Location, range))
            {
                from.SendLocalizedMessage(500295); //You are too far away to do that.
            }
            else if (!from.InLOS(this.Location))
            {
                from.SendLocalizedMessage(500950); //You cannot see that.
            }
            else if (m_Boat.IsMoving || m_Boat.IsTurning)
            {
                from.SendLocalizedMessage(1116611); //You can't use that while the ship is moving!
            }
            else if (BaseBoat.IsDriving(from))
            {
                from.SendLocalizedMessage(1116610); //You can't do that while piloting a ship!
            }
            else if (BaseHouse.FindHouseAt(from) != null)
            {
                from.SendLocalizedMessage(1149795); //You may not dock a ship while on another ship or inside a house.
            }
            else if (!m_Boat.IsClassicBoat)
            {
                if (boat == m_Boat && !MoveToNearestDockOrLand(from))
                {
                    from.SendLocalizedMessage(1149796); //You can not dock a ship this far out to sea. You must be near land or shallow water.
                }
                else if (boat == null)
                {
                    if (!from.Alive)
                    {
                        from.SendLocalizedMessage(1060190); //You cannot do that while dead!
                    }
                    else if ((m_Boat is BaseGalleon && ((BaseGalleon)m_Boat).HasAccess(from)) || (m_Boat is RowBoat && ((RowBoat)m_Boat).HasAccess(from)))
                    {
                        canMove = true;
                    }
                    else
                    {
                        from.SendLocalizedMessage(1116617); //You do not have permission to board this ship.
                    }
                }
                else if (boat != null && m_Boat != boat)
                {
                    if (!from.Alive)
                    {
                        from.SendLocalizedMessage(1060190); //You cannot do that while dead!
                    }
                    else if (m_Boat is RowBoat && ((RowBoat)m_Boat).HasAccess(from))
                    {
                        canMove = true;
                    }
                    else if (boat is RowBoat && m_Boat is BaseGalleon && ((BaseGalleon)m_Boat).HasAccess(from))
                    {
                        canMove = true;
                    }
                    else if (boat is BaseGalleon && m_Boat is BaseGalleon && ((BaseGalleon)m_Boat).HasAccess(from))
                    {
                        canMove = true;
                    }
                    else
                    {
                        from.SendLocalizedMessage(1149795); //You may not dock a ship while on another ship or inside a house.
                    }
                }
            }

            if (canMove)
            {
                BaseCreature.TeleportPets(from, this.Location, this.Map);
                from.MoveToWorld(this.Location, this.Map);

                m_Boat.SendContainerPacket();
            }
        }
Пример #10
0
            public override void OnResponse(NetState sender, RelayInfo info)
            {
                var boat = BaseBoat.FindBoatAt(m_From, m_From.Map);

                if (boat == null)
                {
                    m_From.SendMessage(33, "You need to be on a boat to use this command!");
                    return;
                }

                if (info.ButtonID >= 1 && info.ButtonID <= 15)
                {
                    m_From.SendGump(new BoatControlGump(m_From));
                }

                switch (info.ButtonID)
                {
                case 1:     // Drop Anchor
                    boat.LowerAnchor(true);
                    break;

                case 2:     // Raise Anchor
                    boat.RaiseAnchor(true);
                    break;

                case 3:     // Forward
                    boat.StartMove(Direction.North, true);
                    break;

                case 4:     // Back
                    boat.StartMove(Direction.South, true);
                    break;

                case 5:     // Left
                    boat.StartMove(Direction.West, true);
                    break;

                case 6:     // Right
                    boat.StartMove(Direction.East, true);
                    break;

                case 7:     // Stop
                    boat.StopMove(true);
                    break;

                case 8:     // TurnLeft
                    boat.StartTurn(-2, true);
                    break;

                case 9:     // TurnRight
                    boat.StartTurn(2, true);
                    break;

                case 10:     // OneForward
                    boat.OneMove(Direction.North);
                    break;

                case 11:     // OneBack
                    boat.OneMove(Direction.South);
                    break;

                case 12:     // OneLeft
                    boat.OneMove(Direction.West);
                    break;

                case 13:     // OneRight
                    boat.OneMove(Direction.East);
                    break;

                case 14:     // LeftForward
                    boat.StartMove(Direction.Up, true);
                    break;

                case 15:     // RightForward
                    boat.StartMove(Direction.Right, true);
                    break;
                }
            }
Пример #11
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.");
                }
            }
        }
Пример #12
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                from.RevealingAction();

                if (targeted is BaseCreature)
                {
                    BaseCreature bc_Target = targeted as BaseCreature;

                    if (!m_Instrument.IsChildOf(from.Backpack))
                    {
                        from.SendLocalizedMessage(1062488); // The instrument you are trying to play is no longer in your backpack!
                    }
                    else if (bc_Target.Unprovokable)
                    {
                        from.SendMessage("That creature is not provokable.");
                    }

                    else if (bc_FirstCreature.Map != bc_Target.Map || !bc_FirstCreature.InRange(bc_Target, BaseInstrument.GetBardRange(from, SkillName.Provocation)))
                    {
                        from.SendLocalizedMessage(1049450); // The creatures you are trying to provoke are too far away from each other for your music to have an effect.
                    }
                    else if (BaseBoat.FindBoatAt(bc_Target.Location, bc_Target.Map) != null)
                    {
                        from.SendMessage("You may not provoke creatures in sea vessels.");
                    }

                    else if (bc_FirstCreature != bc_Target)
                    {
                        if (from.CanBeHarmful(bc_FirstCreature, true) && from.CanBeHarmful(bc_Target, true))
                        {
                            if (bc_FirstCreature.NextBardingEffectAllowed > DateTime.UtcNow)
                            {
                                string timeRemaining = Utility.CreateTimeRemainingString(DateTime.UtcNow, bc_FirstCreature.NextBardingEffectAllowed, false, true, true, true, true);

                                from.SendMessage("Your original target is not vulnerable to barding attempts for another " + timeRemaining + ".");
                                return;
                            }

                            if (bc_Target.NextBardingEffectAllowed > DateTime.UtcNow)
                            {
                                string timeRemaining = Utility.CreateTimeRemainingString(DateTime.UtcNow, bc_Target.NextBardingEffectAllowed, false, true, true, true, true);

                                from.SendMessage("That target is not vulnerable to barding attempts for another " + timeRemaining + ".");
                                return;
                            }

                            if (!BaseInstrument.CheckMusicianship(from))
                            {
                                from.SendMessage("You struggle with basic musicianship and your song has no effect.");

                                m_Instrument.PlayInstrumentBadly(from);
                                m_Instrument.ConsumeUse(from);

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

                                return;
                            }
                        }

                        else
                        {
                            return;
                        }

                        double creatureDifficulty       = Math.Max(bc_FirstCreature.InitialDifficulty, bc_Target.InitialDifficulty);
                        double firstEffectiveBardSkill  = from.Skills[SkillName.Peacemaking].Value + BaseInstrument.GetBardBonusSkill(from, bc_FirstCreature, m_Instrument);
                        double secondEffectiveBardSkill = from.Skills[SkillName.Peacemaking].Value + BaseInstrument.GetBardBonusSkill(from, bc_Target, m_Instrument);
                        double effectiveBardSkill       = Math.Max(firstEffectiveBardSkill, secondEffectiveBardSkill);

                        double   successChance  = BaseInstrument.GetBardSuccessChance(effectiveBardSkill, creatureDifficulty);
                        TimeSpan effectDuration = BaseInstrument.GetBardDuration(bc_Target, creatureDifficulty);

                        if (BaseInstrument.CheckSkillGain(successChance))
                        {
                            from.CheckSkill(SkillName.Provocation, 0.0, 120.0, 1.0);
                        }

                        if (from.AccessLevel > AccessLevel.Player)
                        {
                            from.SendMessage("Chance of success was: " + Math.Round(successChance * 100, 3).ToString() + "%");
                        }

                        if (Utility.RandomDouble() <= successChance)
                        {
                            from.SendLocalizedMessage(501602); // Your music succeeds, as you start a fight.

                            m_Instrument.PlayInstrumentWell(from);
                            m_Instrument.ConsumeUse(from);
                            bc_FirstCreature.Provoke(from, bc_Target, true, effectDuration, false);

                            from.NextSkillTime = Core.TickCount + (int)(SkillCooldown.ProvocationSuccessCooldown * 1000);
                        }

                        else
                        {
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);

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

                            string failureMessage = BaseInstrument.GetFailureMessage(successChance, SkillName.Provocation);

                            from.SendMessage(failureMessage);
                        }
                    }

                    else
                    {
                        from.SendLocalizedMessage(501593); // You can't tell someone to attack themselves!
                    }
                }

                else if (targeted is PlayerMobile)
                {
                    PlayerMobile player = (PlayerMobile)targeted;

                    if (bc_FirstCreature.Map != player.Map || !bc_FirstCreature.InRange(player, BaseInstrument.GetBardRange(from, SkillName.Provocation)))
                    {
                        from.SendLocalizedMessage(1049450); // The creatures you are trying to provoke are too far away from each other for your music to have an effect.
                    }
                    else if (BaseBoat.FindBoatAt(player.Location, player.Map) != null)
                    {
                        from.SendMessage("You may not provoke creatures in sea vessels.");
                    }

                    else
                    {
                        if (from.CanBeHarmful(bc_FirstCreature, true) && from.CanBeHarmful(player, true))
                        {
                            if (bc_FirstCreature.NextBardingEffectAllowed > DateTime.UtcNow)
                            {
                                string timeRemaining = Utility.CreateTimeRemainingString(DateTime.UtcNow, bc_FirstCreature.NextBardingEffectAllowed, false, true, true, true, true);

                                from.SendMessage("That target is not vulnerable to barding attempts for another " + timeRemaining + ".");
                                return;
                            }

                            if (!BaseInstrument.CheckMusicianship(from))
                            {
                                from.SendLocalizedMessage(500612); // You play poorly, and there is no effect.

                                m_Instrument.PlayInstrumentBadly(from);
                                m_Instrument.ConsumeUse(from);

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

                                return;
                            }

                            double creatureDifficulty = bc_FirstCreature.InitialDifficulty;
                            double effectiveBardSkill = from.Skills[SkillName.Peacemaking].Value + BaseInstrument.GetBardBonusSkill(from, bc_FirstCreature, m_Instrument);

                            double   successChance  = BaseInstrument.GetBardSuccessChance(effectiveBardSkill, creatureDifficulty);
                            TimeSpan effectDuration = BaseInstrument.GetBardDuration(bc_FirstCreature, creatureDifficulty);

                            if (BaseInstrument.CheckSkillGain(successChance))
                            {
                                from.CheckSkill(SkillName.Provocation, 0.0, 120.0, 1.0);
                            }

                            if (from.AccessLevel > AccessLevel.Player)
                            {
                                from.SendMessage("Chance of success was: " + Math.Round(successChance * 100, 3).ToString() + "%");
                            }

                            if (Utility.RandomDouble() <= successChance)
                            {
                                from.SendLocalizedMessage(501602); // Your music succeeds, as you start a fight.

                                m_Instrument.PlayInstrumentWell(from);
                                m_Instrument.ConsumeUse(from);
                                bc_FirstCreature.Provoke(from, player, true, effectDuration, false);

                                from.NextSkillTime = Core.TickCount + (int)(SkillCooldown.ProvocationSuccessCooldown * 1000);
                            }

                            else
                            {
                                m_Instrument.PlayInstrumentBadly(from);
                                m_Instrument.ConsumeUse(from);

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

                                string failureMessage = BaseInstrument.GetFailureMessage(successChance, SkillName.Provocation);

                                from.SendMessage(failureMessage);
                            }
                        }

                        else
                        {
                            return;
                        }
                    }
                }

                else
                {
                    from.SendLocalizedMessage(501589); // You can't incite that!
                }
            }
Пример #13
0
            protected override void OnTarget(Mobile from, object target)
            {
                if (m_CampingFirepit.Deleted || m_CampingFirepit.RootParent != from)
                {
                    return;
                }

                PlayerMobile pm = from as PlayerMobile;

                if (pm == null)
                {
                    return;
                }

                IPoint3D location = target as IPoint3D;

                if (location == null)
                {
                    return;
                }

                Map map = from.Map;

                if (map == null)
                {
                    return;
                }

                SpellHelper.GetSurfaceTop(ref location);

                if (location is Mobile)
                {
                    targetLocation = (Mobile)location;
                }

                else
                {
                    targetLocation = new Entity(Serial.Zero, new Point3D(location), map);
                }

                if (!map.CanSpawnMobile(targetLocation.Location))
                {
                    from.SendLocalizedMessage(501942); // That location is blocked.
                    return;
                }

                if (BaseBoat.IsWaterTile(targetLocation.Location, map))
                {
                    BaseBoat boatAtLocation = BaseBoat.FindBoatAt(targetLocation.Location, map);

                    if (boatAtLocation == null)
                    {
                        from.SendMessage("You may only place those on dry land.");
                        return;
                    }
                }

                Point3D newLocation = targetLocation.Location;

                SpellHelper.AdjustField(ref newLocation, map, 12, false);

                CampingFirepitPlaced firepitPlaced = new CampingFirepitPlaced();

                firepitPlaced.MoveToWorld(newLocation, map);
                firepitPlaced.Light(from);

                m_CampingFirepit.m_Charges--;

                if (m_CampingFirepit.m_Charges <= 0)
                {
                    m_CampingFirepit.Delete();
                }
            }
Пример #14
0
        public override Item Construct(Type type, Mobile from, Item _i, HarvestDefinition _d, HarvestBank _b, HarvestResource _r)
        {
            if (type == typeof(TreasureMap))
            {
                int level = 1;

                return(new TreasureMap(level, Map.Felucca));
            }

            else if (type == typeof(MessageInABottle))
            {
                return(new MessageInABottle(Map.Felucca));
            }

            Container pack = from.Backpack;

            if (pack != null)
            {
                List <SOS> messages = pack.FindItemsByType <SOS>();

                for (int i = 0; i < messages.Count; ++i)
                {
                    SOS sos = messages[i];

                    if (from.Map == sos.TargetMap && from.InRange(sos.TargetLocation, 60) && !sos.Completed)
                    {
                        Item preLoot = null;

                        switch (Utility.Random(7))
                        {
                        case 0:     // Body parts
                        {
                            int[] list = new int[]
                            {
                                0x1CDD, 0x1CE5,                                        // arm
                                0x1CE0, 0x1CE8,                                        // torso
                                0x1CE1, 0x1CE9,                                        // head
                                0x1CE2, 0x1CEC                                         // leg
                            };

                            preLoot = new ShipwreckedItem(Utility.RandomList(list));
                            break;
                        }

                        case 1:     // Bone parts
                        {
                            int[] list = new int[]
                            {
                                0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4,                         // skulls
                                0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles
                                0x1B15, 0x1B16                                                  // pelvis bones
                            };

                            preLoot = new ShipwreckedItem(Utility.RandomList(list));
                            break;
                        }

                        case 2:     // Pillows
                        {
                            preLoot = new ShipwreckedItem(Utility.Random(0x13A4, 11));
                            break;
                        }

                        case 3:     // Shells
                        {
                            preLoot = new ShipwreckedItem(Utility.Random(0xFC4, 9));
                            break;
                        }

                        case 4:         //Hats
                        {
                            if (Utility.RandomBool())
                            {
                                preLoot = new SkullCap();
                            }
                            else
                            {
                                preLoot = new TricorneHat();
                            }

                            break;
                        }

                        case 5:     // Misc
                        {
                            int[] list = new int[]
                            {
                                0x1EB5,                                        // unfinished barrel
                                0xA2A,                                         // stool
                                0xC1F,                                         // broken clock
                                0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4                 // barrel staves
                            };

                            if (Utility.Random(list.Length + 1) == 0)
                            {
                                preLoot = new Candelabra();
                            }
                            else
                            {
                                preLoot = new ShipwreckedItem(Utility.RandomList(list));
                            }

                            break;
                        }
                        }

                        if (preLoot != null)
                        {
                            if (preLoot is IShipwreckedItem)
                            {
                                ((IShipwreckedItem)preLoot).IsShipwreckedItem = true;
                            }

                            return(preLoot);
                        }

                        LockableContainer chest;

                        if (Utility.RandomBool())
                        {
                            chest = new MetalGoldenChest();
                        }
                        else
                        {
                            chest = new WoodenChest();
                        }

                        if (sos.IsAncient)
                        {
                            chest.Hue = 0x481;
                        }

                        TreasureMapChest.Fill(chest, Math.Max(1, Math.Min(3, (sos.Level + 1))));

                        if (sos.IsAncient)
                        {
                            chest.DropItem(new FabledFishingNet());
                        }
                        else
                        {
                            chest.DropItem(new SpecialFishingNet());
                        }

                        if (Utility.Random(500) == 0)
                        {
                            Item mask = new HornedTribalMask();
                            mask.Hue  = 2715;
                            mask.Name = "Mask of Cthulu";

                            chest.DropItem(mask);
                        }

                        switch (Utility.Random(300))
                        {
                        case 0:
                        {
                            Item rustedchest = new PlateChest();
                            rustedchest.Hue  = 2718;
                            rustedchest.Name = "a rusted platemail chest recovered from a shipwreck";

                            chest.DropItem(rustedchest);
                            break;
                        }

                        case 1:
                        {
                            Item rustedarms = new PlateArms();
                            rustedarms.Hue  = 2718;
                            rustedarms.Name = "rusted platemail arms recovered from a shipwreck";

                            chest.DropItem(rustedarms);
                            break;
                        }

                        case 2:
                        {
                            Item rustedlegs = new PlateLegs();
                            rustedlegs.Hue  = 2718;
                            rustedlegs.Name = "rusted platemail legguards recovered from a shipwreck";

                            chest.DropItem(rustedlegs);
                            break;
                        }

                        case 3:
                        {
                            Item rustedgloves = new PlateGloves();
                            rustedgloves.Hue  = 2718;
                            rustedgloves.Name = "rusted platemail gloves recovered from a shipwreck";

                            chest.DropItem(rustedgloves);
                            break;
                        }

                        case 4:
                        {
                            Item rustedgorget = new PlateGorget();
                            rustedgorget.Hue  = 2718;
                            rustedgorget.Name = "rusted platemail gorget recovered from a shipwreck";

                            chest.DropItem(rustedgorget);
                            break;
                        }

                        case 5:
                        {
                            Item rustedhelm = new PlateHelm();
                            rustedhelm.Hue  = 2718;
                            rustedhelm.Name = "a rusted platemail helmet recovered from a shipwreck";

                            chest.DropItem(rustedhelm);
                            break;
                        }
                        }

                        switch (Utility.Random(400))
                        {
                        case 0:
                        {
                            Item lamp = new LampPost1();
                            lamp.Name = "Britannia Head Light";
                            lamp.Hue  = 2601;

                            chest.DropItem(lamp);
                            break;
                        }

                        case 1:
                        {
                            Item lantern = new HangingLantern();
                            lantern.Name    = "Fog Lamp";
                            lantern.Hue     = 2601;
                            lantern.Movable = true;

                            chest.DropItem(lantern);
                            break;
                        }
                        }

                        chest.Movable   = true;
                        chest.Locked    = false;
                        chest.TrapType  = TrapType.None;
                        chest.TrapPower = 0;
                        chest.TrapLevel = 0;

                        sos.Completed = true;

                        BaseBoat ownerBoat = BaseBoat.FindBoatAt(from.Location, from.Map);

                        PlayerMobile player = from as PlayerMobile;

                        if (ownerBoat != null && player != null)
                        {
                            if (ownerBoat.IsFriend(player) || ownerBoat.IsOwner(player) || ownerBoat.IsCoOwner(player))
                            {
                                double doubloonValue = Utility.RandomMinMax(25, 50);

                                int finalDoubloonAmount = (int)doubloonValue;

                                bool shipOwner          = ownerBoat.IsOwner(player);
                                bool bankDoubloonsValid = false;
                                bool holdPlacementValid = false;

                                //Deposit Half In Player's Bank
                                if (Banker.DepositUniqueCurrency(player, typeof(Doubloon), finalDoubloonAmount))
                                {
                                    Doubloon doubloonPile = new Doubloon(finalDoubloonAmount);
                                    player.SendSound(doubloonPile.GetDropSound());
                                    doubloonPile.Delete();

                                    bankDoubloonsValid = true;
                                }

                                //Deposit Other Half in Ship
                                if (ownerBoat.DepositDoubloons(finalDoubloonAmount))
                                {
                                    Doubloon doubloonPile = new Doubloon(finalDoubloonAmount);
                                    player.SendSound(doubloonPile.GetDropSound());
                                    doubloonPile.Delete();

                                    holdPlacementValid = true;
                                }

                                if (shipOwner)
                                {
                                    player.PirateScore += finalDoubloonAmount;
                                    //ownerBoat.doubloonsEarned += finalDoubloonAmount * 2;

                                    if (bankDoubloonsValid && holdPlacementValid)
                                    {
                                        player.SendMessage("You've received " + (finalDoubloonAmount * 2).ToString() + " doubloons for completing a message in a bottle! They have been evenly split between your bank box and your ship's hold.");
                                    }

                                    else if (bankDoubloonsValid && !holdPlacementValid)
                                    {
                                        player.SendMessage("You've earned " + (finalDoubloonAmount * 2).ToString() + " doubloons, however there was not enough room to place all of them in your ship's hold.");
                                    }

                                    else if (!bankDoubloonsValid && holdPlacementValid)
                                    {
                                        player.SendMessage("You've earned " + (finalDoubloonAmount * 2).ToString() + " doubloons, however there was not enough room to place all of them in your bank box.");
                                    }
                                }

                                else
                                {
                                    //ownerBoat.doubloonsEarned += finalDoubloonAmount;
                                    player.PirateScore += finalDoubloonAmount;

                                    if (bankDoubloonsValid)
                                    {
                                        player.SendMessage("You've earned " + finalDoubloonAmount.ToString() + " doubloons for completing a message in a bottle! They have been placed in your bank box.");
                                    }

                                    else
                                    {
                                        player.SendMessage("You've earned doubloons, but there was not enough room to place all of them in your bank box.");
                                    }
                                }
                            }
                        }

                        return(chest);
                    }
                }
            }

            return(base.Construct(type, from, _i, _d, _b, _r));
        }
Пример #15
0
        public void Target(IPoint3D p)
        {
            if (!Caster.CanSee(p))
            {
                Caster.SendLocalizedMessage(500237); // Target can not be seen.
            }
            else if (BaseBoat.FindBoatAt(p, Caster.Map) != null)
            {
                Caster.SendMessage("That location is blocked.");
            }

            else if (SpellHelper.CheckTown(p, Caster) && CheckSequence())
            {
                SpellHelper.Turn(Caster, p);

                SpellHelper.GetSurfaceTop(ref p);

                int dx = Caster.Location.X - p.X;
                int dy = Caster.Location.Y - p.Y;
                int rx = (dx - dy) * 44;
                int ry = (dx + dy) * 44;

                bool eastToWest;

                if (rx >= 0 && ry >= 0)
                {
                    eastToWest = false;
                }

                else if (rx >= 0)
                {
                    eastToWest = true;
                }

                else if (ry >= 0)
                {
                    eastToWest = true;
                }

                else
                {
                    eastToWest = false;
                }

                Effects.PlaySound(p, Caster.Map, 0x20B);

                int itemID = eastToWest ? 0x3967 : 0x3979;

                TimeSpan duration = TimeSpan.FromSeconds(3.0 + (Caster.Skills[SkillName.Magery].Value / 3.0));

                bool enhancedSpellcast = SpellHelper.IsEnhancedSpell(Caster, null, EnhancedSpellbookType.Warlock, false, true);

                for (int i = -2; i <= 2; ++i)
                {
                    Point3D loc    = new Point3D(eastToWest ? p.X + i : p.X, eastToWest ? p.Y : p.Y + i, p.Z);
                    bool    canFit = SpellHelper.AdjustField(ref loc, Caster.Map, 12, false);

                    if (!canFit)
                    {
                        continue;
                    }

                    InternalItem item = new InternalItem(Caster, itemID, loc, Caster.Map, duration);

                    if (enhancedSpellcast)
                    {
                        item.m_Enhanced = true;
                    }

                    item.ProcessDelta();

                    Effects.SendLocationParticles(EffectItem.Create(loc, Caster.Map, EffectItem.DefaultDuration), 0x376A, 9, 10, 5048);
                }
            }

            FinishSequence();
        }
Пример #16
0
        public virtual void OnChop(Mobile from)
        {
            BaseHouse house = BaseHouse.FindHouseAt(this);

            #region High Seas
            BaseBoat boat = BaseBoat.FindBoatAt(from, from.Map);
            if (boat != null && boat is BaseGalleon)
            {
                ((BaseGalleon)boat).OnChop(this, from);
                return;
            }
            #endregion

            if (house != null && (house.IsOwner(from) || (house.Addons.ContainsKey(this) && house.Addons[this] == from)))
            {
                Effects.PlaySound(GetWorldLocation(), Map, 0x3B3);
                from.SendLocalizedMessage(500461); // You destroy the item.

                int hue = 0;

                if (RetainDeedHue)
                {
                    for (int i = 0; hue == 0 && i < m_Components.Count; ++i)
                    {
                        AddonComponent c = m_Components[i];

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

                Delete();

                house.Addons.Remove(this);

                BaseAddonDeed deed = GetDeed();

                if (deed != null)
                {
                    if (!RetainComponentHue)
                    {
                        if (RetainDeedHue)
                        {
                            deed.Hue = hue;
                        }
                        else
                        {
                            deed.Hue = 0;
                        }
                    }

                    deed.IsReDeed = true;

                    from.AddToBackpack(deed);
                }
            }
            else
            {
                from.SendLocalizedMessage(1113134); // You can only redeed items in your own house!
            }
        }
Пример #17
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.Region.IsPartOf <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.
                }
            }
        }
Пример #18
0
        public void OnTarget(Mobile from, Point3D point, bool IsNPCShip, bool canHitCenter, bool canHitHold, bool canHitTillerman)
        {
            if (m_Boat == null)
            {
                return;
            }

            Map      map        = from.Map;
            BaseBoat targetBoat = BaseBoat.FindBoatAt(point, map);

            //For Player Ships
            if (m_Boat.MobileControlType == MobileControlType.Player)
            {
                if (!from.Player)
                {
                    return;
                }

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

                else if (!m_Boat.Contains(from))
                {
                    from.SendMessage("You are no longer on the boat.");
                    return;
                }

                else if (targetBoat == m_Boat)
                {
                    from.SendMessage("You may not fire onto your own ship!");
                    return;
                }

                else if (Ammunition == 0)
                {
                    from.SendMessage("At least one of your cannons must be loaded to fire a volley.");
                    return;
                }

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

            bool volleyValid = false;
            bool tooClose    = false;

            double cannonDelayTotal = 0;
            int    cannonsFiring    = 0;

            //Need At Least One Cannon With LOS to Target and In Range of Target For Volley To Be Valid
            foreach (ShipCannon shipCannon in m_Boat.m_Cannons)
            {
                //Cannon Has Ammunition and is on Correct Ship Side for Volley
                if (shipCannon.Ammunition > 0 && shipCannon.Facing == Facing)
                {
                    cannonDelayTotal += BaseBoat.CannonCooldownTime;
                    cannonsFiring++;

                    double modifiedRange = (double)BaseBoat.CannonMaxRange * m_Boat.CannonRangeScalar;

                    //Already Deterined to Be Valid Shot: NPC AI Ship
                    if (IsNPCShip)
                    {
                        volleyValid = true;
                        break;
                    }

                    //Cannon is in LOS and Within Range
                    if (shipCannon.InAngle(point) && Utility.GetDistanceToSqrt(shipCannon.Location, point) <= modifiedRange)
                    {
                        volleyValid = true;
                    }

                    //Cannon is too close
                    if (Utility.GetDistanceToSqrt(shipCannon.Location, point) < 2)
                    {
                        tooClose = true;
                    }
                }
            }

            //At Least One Cannon Was Too Close to Fire
            if (tooClose)
            {
                volleyValid = false;
            }

            //Can Fire Cannon Volley
            if (volleyValid)
            {
                if (m_Boat.TillerMan != null)
                {
                    m_Boat.TillerMan.Say("Firing cannons!");
                }

                m_Boat.LastCombatTime = DateTime.UtcNow;

                //Ship Cooldown Time (Average of Delay for Each Cannon Type that is Firing)
                double cooldown = cannonDelayTotal / cannonsFiring;

                m_Boat.CannonCooldown = DateTime.UtcNow + TimeSpan.FromSeconds(cooldown);
                m_Boat.StartCannonCooldown();

                List <ShipCannon> cannonsToFire = new List <ShipCannon>();

                foreach (ShipCannon shipCannon in m_Boat.m_Cannons)
                {
                    if (shipCannon.Ammunition > 0 && shipCannon.Facing == Facing)
                    {
                        cannonsToFire.Add(shipCannon);
                    }
                }

                int firingLoops = BaseBoat.CannonFiringLoops;

                int cannonCount = cannonsToFire.Count;

                for (int a = 0; a < firingLoops; a++)
                {
                    for (int b = 0; b < cannonCount; b++)
                    {
                        bool showSmoke  = false;
                        bool lastCannon = false;

                        int        cannonIndex = Utility.RandomMinMax(0, cannonsToFire.Count - 1);
                        ShipCannon shipCannon  = cannonsToFire[cannonIndex];

                        if (a == 0)
                        {
                            showSmoke = true;
                        }

                        if (a == (firingLoops - 1))
                        {
                            shipCannon.Ammunition--;
                            cannonsToFire.RemoveAt(cannonIndex);

                            if (b == cannonCount - 1)
                            {
                                lastCannon = true;
                            }
                        }

                        //Check Accuracy
                        double cannonAccuracy = BaseBoat.CannonAccuracy * m_Boat.CannonAccuracyModifer;

                        double opponentMovementPenalty = 0;
                        double movementAccuracyPenalty = 0;

                        //Own Ship Movement Penalty
                        TimeSpan timeStationary    = DateTime.UtcNow - m_Boat.TimeLastMoved;
                        double   secondsStationary = (double)timeStationary.TotalSeconds;

                        if (secondsStationary > BaseBoat.CannonMovementAccuracyCooldown)
                        {
                            secondsStationary = BaseBoat.CannonMovementAccuracyCooldown;
                        }

                        if (targetBoat != null)
                        {
                            TimeSpan timeTargetStationary      = DateTime.UtcNow - targetBoat.TimeLastMoved;
                            double   secondsOpponentStationary = (double)timeStationary.TotalSeconds;

                            if (secondsOpponentStationary > BaseBoat.CannonMovementAccuracyCooldown)
                            {
                                secondsOpponentStationary = BaseBoat.CannonMovementAccuracyCooldown;
                            }

                            opponentMovementPenalty = 1 - (BaseBoat.CannonTargetMovementMaxAccuracyPenalty * (1 - (secondsOpponentStationary / BaseBoat.CannonMovementAccuracyCooldown)));

                            //No Movement Penalty to Shoot a Ship That is in Reduced Speed Mode
                            if (targetBoat.ReducedSpeedMode)
                            {
                                opponentMovementPenalty = 1;
                            }
                        }

                        movementAccuracyPenalty = 1 - (BaseBoat.CannonMovementMaxAccuracyPenalty * (1 - (secondsStationary / BaseBoat.CannonMovementAccuracyCooldown)));

                        double finalAccuracy = cannonAccuracy * movementAccuracyPenalty * opponentMovementPenalty;

                        double chance = Utility.RandomDouble();

                        bool hit = false;

                        //Hit Target
                        if (chance <= finalAccuracy)
                        {
                            hit = true;
                        }

                        Point3D cannonEndLocation = point;

                        if (IsNPCShip && targetBoat != null)
                        {
                            if (canHitCenter)
                            {
                                cannonEndLocation = targetBoat.GetRandomEmbarkLocation(true);
                            }

                            else if (canHitHold && canHitTillerman)
                            {
                                if (Utility.RandomDouble() < .5)
                                {
                                    cannonEndLocation = targetBoat.Hold.Location;
                                }

                                else
                                {
                                    cannonEndLocation = targetBoat.TillerMan.Location;
                                }
                            }

                            else if (canHitHold && !canHitTillerman)
                            {
                                cannonEndLocation = targetBoat.Hold.Location;
                            }

                            else if (!canHitHold && canHitTillerman)
                            {
                                cannonEndLocation = targetBoat.TillerMan.Location;
                            }
                        }

                        double delay = (BaseBoat.CannonLoopDelay * (a + 1) / (double)firingLoops) * b;

                        Timer.DelayCall(TimeSpan.FromSeconds(delay), delegate
                        {
                            FireCannon(shipCannon, from, cannonEndLocation, map, hit, showSmoke);
                        });
                    }
                }
            }

            else
            {
                if (tooClose)
                {
                    from.SendMessage("Your target is too close to the ship to be fired upon.");
                }

                else
                {
                    from.SendMessage("At least one of your cannons must be within range of and in line of sight of your target in order to fire a cannon volley.");
                }
            }
        }
Пример #19
0
        public void TryDamageBoat()
        {
            Mobile focusMob = m_Fisher;

            if (focusMob == null || !focusMob.Alive)
            {
                focusMob = Combatant as Mobile;
            }

            if (focusMob == null || focusMob.AccessLevel > AccessLevel.Player || !InRange(focusMob.Location, DamageRange) || BaseBoat.FindBoatAt(focusMob, focusMob.Map) == null)
            {
                return;
            }

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

            if (boat != null)
            {
                int range = DamageRange;
                for (int x = X - range; x <= X + range; x++)
                {
                    for (int y = Y - range; y <= Y + range; y++)
                    {
                        if (BaseBoat.FindBoatAt(new Point2D(x, y), Map) == boat)
                        {
                            DoDamageBoat(boat);
                            m_NextBoatDamage = DateTime.UtcNow + BoatDamageCooldown;
                            m_InDamageMode   = false;
                            return;
                        }
                    }
                }
            }
        }
Пример #20
0
        public void ResolveCannonHit(Mobile from, Point3D targetLocation)
        {
            ArrayList validTargets = new ArrayList();

            Map map = Map;

            BaseBoat boatFrom   = BaseBoat.FindBoatAt(from.Location, map);
            BaseBoat targetBoat = BaseBoat.FindBoatAt(targetLocation, map);

            bool hitObject     = false;
            bool hitBoat       = false;
            bool showExplosion = true;

            IPooledEnumerable nearbyMobiles = map.GetMobilesInRange(targetLocation, BaseBoat.CannonExplosionRange);

            foreach (Mobile mobile in nearbyMobiles)
            {
                if (!validTargets.Contains(mobile))
                {
                    validTargets.Add(mobile);
                }
            }

            nearbyMobiles.Free();

            List <Mobile> m_MobilesOnSourceBoat = new List <Mobile>();
            List <Mobile> m_Targets             = new List <Mobile>();

            double baseCannonDamage = (double)(Utility.RandomMinMax(BaseBoat.CannonDamageMin, BaseBoat.CannonDamageMax));

            if (m_Boat == null)
            {
                m_MobilesOnSourceBoat.Add(from);
            }

            else
            {
                baseCannonDamage = m_Boat.CannonDamageScalar * baseCannonDamage;

                m_MobilesOnSourceBoat = m_Boat.GetMobilesOnBoat(false, false);
            }

            bool targetLocationIsBoat = false;

            if (targetBoat != null)
            {
                targetLocationIsBoat = true;
                m_Targets            = targetBoat.GetMobilesOnBoat(false, false);

                validTargets.Add(targetBoat);
            }

            else
            {
                m_Targets = new List <Mobile>();
            }

            double damageDealt;

            for (int a = 0; a < validTargets.Count; ++a)
            {
                damageDealt = baseCannonDamage;

                object target = validTargets[a];

                int d      = 0;
                int damage = 0;

                bool largeCreatureHit = false;

                PlayerMobile pm_Target;
                BaseCreature bc_Target;

                //Large Boss-Size Creature Hit: Don't Deal Damage to Boat Underneath it
                if (target is Mobile)
                {
                    bc_Target = target as BaseCreature;

                    if (bc_Target != null)
                    {
                        if (bc_Target.IsChamp() || bc_Target.IsBoss() || bc_Target.IsLoHBoss() || bc_Target.IsEventBoss())
                        {
                            largeCreatureHit = true;
                        }
                    }
                }

                if (target is Mobile)
                {
                    Mobile mobile = target as Mobile;

                    pm_Target = mobile as PlayerMobile;
                    bc_Target = mobile as BaseCreature;

                    if (!mobile.Alive)
                    {
                        continue;
                    }

                    //Mobile is somehow on boat that cannon is shooting from
                    BaseBoat mobileBoat = BaseBoat.FindBoatAt(mobile.Location, mobile.Map);

                    if (m_Boat != null && mobileBoat != null)
                    {
                        if (m_Boat == mobileBoat)
                        {
                            continue;
                        }
                    }

                    hitObject = true;

                    bool dealDamage = true;
                    bool directHit  = false;

                    if (mobile.InRange(targetLocation, 0))
                    {
                        directHit = true;
                    }

                    bool isOnWater = BaseBoat.IsWaterTile(mobile.Location, mobile.Map);

                    if (from != null || (SpellHelper.ValidIndirectTarget(from, mobile) && from.CanBeHarmful(mobile, false)))
                    {
                        //Player
                        if (pm_Target != null)
                        {
                            damageDealt *= BaseBoat.CannonPlayerDamageMultiplier;
                        }

                        //Creature
                        if (bc_Target != null)
                        {
                            if (bc_Target.IsOceanCreature)
                            {
                                damageDealt *= BaseBoat.CannonOceanCreatureDamageMultiplier;
                            }

                            else
                            {
                                damageDealt *= BaseBoat.CannonMobileDamageMultiplier;
                            }
                        }

                        if (!directHit)
                        {
                            damageDealt *= BaseBoat.CannonIndirectHitDamageMultiplier;
                        }

                        if (dealDamage)
                        {
                            from.DoHarmful(mobile);

                            int finalDamage = (int)Math.Round(damageDealt);

                            BaseCreature bc_Creature = mobile as BaseCreature;

                            if (bc_Creature != null)
                            {
                                bool willKill = false;

                                if (bc_Creature.Hits - finalDamage <= 0)
                                {
                                    willKill = true;
                                }

                                bc_Creature.OnGotCannonHit(finalDamage, from, willKill);
                            }

                            new Blood().MoveToWorld(mobile.Location, mobile.Map);
                            AOS.Damage(mobile, from, finalDamage, 100, 0, 0, 0, 0);
                        }
                    }
                }

                else if (target is DerelictCargo)
                {
                    DerelictCargo crate = target as DerelictCargo;
                    crate.TakeDamage(from, (int)damageDealt);
                }

                else if (target is BaseBoat && !largeCreatureHit)
                {
                    BaseBoat boatTarget = target as BaseBoat;

                    if (from != null && m_Boat != null && boatTarget != null)
                    {
                        //Somehow Hitting Own Boat
                        if (m_Boat == boatTarget)
                        {
                            continue;
                        }

                        CannonDoHarmful(from, m_MobilesOnSourceBoat, m_Targets);

                        hitObject = true;
                        hitBoat   = true;

                        bool dealDamage = true;

                        if (dealDamage)
                        {
                            DamageType damageType = boatTarget.GetDamageTypeByTargetingMode(m_Boat.TargetingMode);

                            int finalDamage = (int)(Math.Round(damageDealt));

                            boatTarget.ReceiveDamage(from, m_Boat, finalDamage, damageType);
                        }
                    }
                }
            }

            if (hitObject)
            {
                IEntity explosionLocationEntity = new Entity(Serial.Zero, new Point3D(targetLocation.X, targetLocation.Y, targetLocation.Z - 1), map);

                int explosionHue   = 0;
                int explosionSound = 0x307;

                if (m_Boat.MobileFactionType == MobileFactionType.Undead)
                {
                    explosionHue   = 2630;
                    explosionSound = 0x56E;
                }

                if (showExplosion)
                {
                    Effects.SendLocationParticles(explosionLocationEntity, Utility.RandomList(14013, 14015, 14027, 14012), 30, 7, explosionHue, 0, 5044, 0);
                    Effects.PlaySound(explosionLocationEntity.Location, map, explosionSound);
                }
            }

            else
            {
                Splash(targetLocation, map);
            }
        }
Пример #21
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);
                }
            }
        }
Пример #22
0
        public void Target(IPoint3D p)
        {
            Map map = Caster.Map;

            SpellHelper.GetSurfaceTop(ref p);

            if (map == null || !map.CanSpawnMobile(p.X, p.Y, p.Z) || BaseBoat.FindBoatAt(p, map) != null)
            {
                Caster.SendLocalizedMessage(501942); // That location is blocked.
            }

            else if (SpellHelper.CheckTown(p, Caster) && CheckSequence())
            {
                // Here's a little Napoleon Dynamite easter egg for IPY!
                if (Utility.RandomDouble() < 0.005)
                //if ( true )
                {
                    EnergyVortex tina = new EnergyVortex();
                    Slime        ham  = new Slime();

                    tina.Name   = "Tina";
                    tina.Body   = 0xDC;
                    tina.Hue    = 0;
                    tina.Frozen = true;

                    ham.Name   = "Ham";
                    ham.Hue    = 0x76;
                    ham.Frozen = true;

                    bool    validLocation = false;
                    Point3D tinaLocation  = new Point3D(p.X, p.Y, p.Z);
                    Point3D hamLocation   = new Point3D();

                    // Find a suitable location for Ham to spawn.
                    for (int j = 0; !validLocation && j < 10; ++j)
                    {
                        int x = tinaLocation.X + 1;
                        int y = tinaLocation.Y + 1;
                        int z = map.GetAverageZ(x, y);

                        if (validLocation = map.CanFit(x, y, tinaLocation.Z, 16, false, false))
                        {
                            hamLocation = new Point3D(x, y, tinaLocation.Z);
                        }
                        else if (validLocation = map.CanFit(x, y, z, 16, false, false))
                        {
                            hamLocation = new Point3D(x, y, z);
                        }
                    }

                    BaseCreature.Summon(tina, false, Caster, tinaLocation, 0x212, TimeSpan.FromSeconds(10.0));
                    BaseCreature.Summon(ham, false, Caster, hamLocation, 0, TimeSpan.FromSeconds(10.0));

                    List <Mobile> mobs = new List <Mobile>();
                    mobs.Add(tina);
                    mobs.Add(ham);

                    // Wait 5 seconds, then make Tina talk.
                    Timer.DelayCall(TimeSpan.FromSeconds(5.0), new TimerStateCallback(BeginAction), mobs);

                    // Wait 8 seconds, then make Tina and Ham recall.
                    Timer.DelayCall(TimeSpan.FromSeconds(8.0), new TimerStateCallback(EndAction), mobs);
                }

                else
                {
                    bool enhancedSpellcast = SpellHelper.IsEnhancedSpell(Caster, null, EnhancedSpellbookType.Summoner, false, true);

                    BaseCreature summon = new EnergyVortex();

                    summon.StoreBaseSummonValues();

                    double duration = 2.0 * Caster.Skills[SkillName.Magery].Value;

                    if (enhancedSpellcast)
                    {
                        duration *= SpellHelper.EnhancedSummonDurationMultiplier;

                        summon.DamageMin = (int)((double)summon.DamageMin * SpellHelper.EnhancedSummonDamageMultiplier);
                        summon.DamageMax = (int)((double)summon.DamageMax * SpellHelper.EnhancedSummonDamageMultiplier);

                        summon.SetHitsMax((int)((double)summon.HitsMax * SpellHelper.EnhancedSummonHitPointsMultiplier));
                        summon.Hits = summon.HitsMax;
                    }

                    summon.SetDispelResistance(Caster, enhancedSpellcast, 0);

                    int spellHue = PlayerEnhancementPersistance.GetSpellHueFor(Caster, HueableSpell.EnergyVortex);

                    summon.Hue = spellHue;

                    BaseCreature.Summon(summon, false, Caster, new Point3D(p), 0x212, TimeSpan.FromSeconds(duration));
                }
            }

            FinishSequence();
        }
Пример #23
0
        public void OnTick(Point3DList path, Direction dir, int i)
        {
            if (path.Count > i)
            {
                Point3D point = path[i];
                int     o     = i - 1;

                Server.Effects.PlaySound(point, Map, 278);
                Server.Effects.PlaySound(point, Map, 279);

                for (int rn = 0; rn < (o * 2) + 1; rn++)
                {
                    int  y = 0, x = 0, y2 = 0, x2 = 0;
                    bool diag = false;
                    switch ((int)dir)
                    {
                    case (int)Direction.Running:
                    case (int)Direction.North: { x = x - o + rn; break; }

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

                    case 130:
                    case (int)Direction.East: { y = y - o + rn; break; }

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

                    case 132:
                    case (int)Direction.South: { x = x + o - rn; break; }

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

                    case 134:
                    case (int)Direction.West: { y = y + o - rn; break; }

                    case (int)Direction.ValueMask:
                    case (int)Direction.Up: { y = y + o - rn; x = x - o + rn; break; }
                    }
                    switch ((int)dir)
                    {
                    case 129:
                    case (int)Direction.Right: { y2++; diag = true; break; }

                    case 131:
                    case (int)Direction.Down: { x2--; diag = true; break; }

                    case 133:
                    case (int)Direction.Left: { y2--; diag = true; break; }

                    case (int)Direction.ValueMask:
                    case (int)Direction.Up: { x2++; diag = true; break; }

                    default: { break; }
                    }

                    Point3D ep  = new Point3D(point.X + x, point.Y + y, point.Z);
                    Point3D ep2 = new Point3D(ep.X + x2, ep.Y + y2, ep.Z);

                    if (diag && i >= ((2 * path.Count) / 3))
                    {
                        return;
                    }

                    Point3D p;
                    if (diag && rn < (o * 2))
                    {
                        p = ep2;
                    }
                    else
                    {
                        p = ep;
                    }

                    if (Spells.SpellHelper.CheckMulti(p, Map))
                    {
                        BaseBoat boat = BaseBoat.FindBoatAt(p, Map);

                        if (boat != null && !m_HasPushed)
                        {
                            int damage = Utility.RandomMinMax(MinBoatDamage, MaxBoatDamage);
                            boat.OnTakenDamage(this, damage);

                            boat.StartMove(dir, 1, 0x2, boat.SlowDriftInterval, true, false);
                            m_HasPushed = true;
                        }
                        continue;
                    }

                    LandTile t = Map.Tiles.GetLandTile(x, y);

                    if (IsSeaTile(t))
                    {
                        Mobile spawn = new EffectSpawn();
                        spawn.MoveToWorld(p, Map);
                    }
                }
            }
        }
Пример #24
0
        public override void OnThink()
        {
            base.OnThink();

            if (DateTime.UtcNow > m_NextRepairCheck)
            {
                m_NextRepairCheck = DateTime.UtcNow + NextRepairCheckDelay;

                BaseBoat m_Boat = BaseBoat.FindBoatAt(this.Location, this.Map);

                if (DateTime.UtcNow > m_NextRepairAllowed && CheckIfBoatValid(m_Boat))
                {
                    if (m_Boat.HitPoints < m_Boat.MaxHitPoints || m_Boat.SailPoints < m_Boat.MaxSailPoints || m_Boat.GunPoints < m_Boat.MaxGunPoints)
                    {
                        Say("*begins repairing the ship*");

                        Effects.PlaySound(this.Location, this.Map, 0x23D);
                        Animate(12, 5, 1, true, false, 0);

                        double repairInterval = 3.5;

                        m_NextRepairAllowed = DateTime.UtcNow + NextRepairDelay;

                        AIObject.NextMove = DateTime.UtcNow + TimeSpan.FromSeconds(repairInterval);
                        LastSwingTime     = LastSwingTime + TimeSpan.FromSeconds(repairInterval);

                        NextSpellTime = NextSpellTime + TimeSpan.FromSeconds(repairInterval);
                        NextCombatHealActionAllowed    = NextCombatHealActionAllowed + TimeSpan.FromSeconds(repairInterval);
                        NextCombatSpecialActionAllowed = NextCombatSpecialActionAllowed + TimeSpan.FromSeconds(repairInterval);
                        NextCombatEpicActionAllowed    = NextCombatEpicActionAllowed + TimeSpan.FromSeconds(repairInterval);

                        for (int a = 0; a < 4; a++)
                        {
                            Timer.DelayCall(TimeSpan.FromSeconds((a + 1) * 3), delegate
                            {
                                if (this == null)
                                {
                                    return;
                                }
                                if (!this.Alive || this.Deleted)
                                {
                                    return;
                                }

                                if (CheckIfBoatValid(m_Boat))
                                {
                                    Effects.PlaySound(Location, Map, 0x23D);
                                    Animate(12, 5, 1, true, false, 0);

                                    AIObject.NextMove = DateTime.UtcNow + TimeSpan.FromSeconds(repairInterval);
                                    LastSwingTime     = DateTime.UtcNow + TimeSpan.FromSeconds(repairInterval);

                                    NextSpellTime = NextSpellTime + TimeSpan.FromSeconds(repairInterval);
                                    NextCombatHealActionAllowed    = NextCombatHealActionAllowed + TimeSpan.FromSeconds(repairInterval);
                                    NextCombatSpecialActionAllowed = NextCombatSpecialActionAllowed + TimeSpan.FromSeconds(repairInterval);
                                    NextCombatEpicActionAllowed    = NextCombatEpicActionAllowed + TimeSpan.FromSeconds(repairInterval);
                                }
                            });
                        }

                        Timer.DelayCall(TimeSpan.FromSeconds(15), delegate
                        {
                            if (this == null)
                            {
                                return;
                            }
                            if (!this.Alive || this.Deleted)
                            {
                                return;
                            }

                            if (CheckIfBoatValid(m_Boat))
                            {
                                Effects.PlaySound(Location, Map, 0x23D);
                                Animate(12, 5, 1, true, false, 0);

                                if (m_Boat.HitPoints < m_Boat.MaxHitPoints || m_Boat.SailPoints < m_Boat.MaxSailPoints || m_Boat.GunPoints < m_Boat.MaxGunPoints)
                                {
                                    int hitPointsRepairable  = (int)(.05 * (double)m_Boat.MaxHitPoints);
                                    int sailPointsRepairable = (int)(.10 * (double)m_Boat.MaxSailPoints);
                                    int gunPointsRepairable  = (int)(.10 * (double)m_Boat.MaxGunPoints);

                                    m_Boat.HitPoints  += hitPointsRepairable;
                                    m_Boat.SailPoints += sailPointsRepairable;
                                    m_Boat.GunPoints  += gunPointsRepairable;

                                    Say("Repairs completed!");
                                }
                            }
                        });
                    }
                }
            }
        }
Пример #25
0
        public static void StartTracking(Mobile from)
        {
            if (!ShipTrackingContext.CanAddContext(from))
            {
                return;
            }

            List <Item> targets = new List <Item>();
            Map         map     = from.Map;

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

            BaseBoat            fromBoat = BaseBoat.FindBoatAt(from, map);
            ShipTrackingContext context  = ShipTrackingContext.GetContext(from);

            if (fromBoat == null)
            {
                from.SendMessage("You must be on your boat to use this command.");
            }

            IPooledEnumerable eable = map.GetItemsInRange(from.Location, MaxRange);

            foreach (Item item in eable)
            {
                if (context != null && context.IsTrackingBoat(item))
                {
                    continue;
                }
                if (!targets.Contains(item) && (item is BaseBoat boat && boat != fromBoat || item is PlunderBeaconAddon))
                {
                    targets.Add(item);
                }
            }

            eable.Free();

            List <BoatTrackingArrow> arrows = new List <BoatTrackingArrow>();

            for (int i = 0; i < targets.Count; i++)
            {
                if (i >= MaxBoats)
                {
                    break;
                }

                BoatTrackingArrow arrow = new BoatTrackingArrow(from, targets[i], MaxRange);

                if (context == null)
                {
                    arrows.Add(arrow);
                }
                else
                {
                    context.AddArrow(arrow);
                }
            }

            if (from.QuestArrow == null && arrows.Count > 0)
            {
                from.QuestArrow = arrows[0];
            }

            if (context == null)
            {
                new ShipTrackingContext(from, arrows);
            }
        }
Пример #26
0
        public override void OnDoubleClick(Mobile from)
        {
            if (Boat == null || from == null)
            {
                return;
            }

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

            int  range   = boat != null && boat == Boat ? 3 : 8;
            bool canMove = false;

            if (!Boat.IsRowBoat)
            {
                Boat.Refresh(from);
            }

            if (!from.InRange(Location, range))
            {
                from.SendLocalizedMessage(500295); //You are too far away to do that.
            }
            else if (!from.InLOS(Location))
            {
                from.SendLocalizedMessage(500950); //You cannot see that.
            }
            else if (Boat.IsMoving || Boat.IsTurning)
            {
                from.SendLocalizedMessage(1116611); //You can't use that while the ship is moving!
            }
            else if (BaseBoat.IsDriving(from))
            {
                from.SendLocalizedMessage(1116610); //You can't do that while piloting a ship!
            }
            else if (BaseHouse.FindHouseAt(from) != null)
            {
                from.SendLocalizedMessage(1149795); //You may not dock a ship while on another ship or inside a house.
            }
            else if (Boat == boat && !MoveToNearestDockOrLand(from))
            {
                from.SendLocalizedMessage(1149796); //You can not dock a ship this far out to sea. You must be near land or shallow water.
            }
            else if (boat == null || boat != null && Boat != boat)
            {
                if (Boat.HasAccess(from))
                {
                    canMove = true;
                }
                else
                {
                    from.SendLocalizedMessage(1116617); //You do not have permission to board this ship.
                }
            }

            if (canMove)
            {
                BaseCreature.TeleportPets(from, Location, Map);
                from.MoveToWorld(Location, Map);

                Boat.SendContainerPacket();
            }
        }
Пример #27
0
        public static void SpawnCreatures(Mobile m, double difficulty)
        {
            BaseBoat boat = BaseBoat.FindBoatAt(m.Location, m.Map);

            Type[] types  = boat != null ? _SeaTypes : _LandTypes;
            int    amount = Utility.RandomMinMax(2, 4);

            for (int i = 0; i < amount; i++)
            {
                BaseCreature bc = Activator.CreateInstance(types[Utility.Random(types.Length)]) as BaseCreature;

                if (bc != null)
                {
                    Rectangle2D zone;

                    if (boat != null)
                    {
                        if (boat.Facing == Direction.North || boat.Facing == Direction.South)
                        {
                            if (Utility.RandomBool())
                            {
                                zone = new Rectangle2D(boat.X - 7, m.Y - 4, 3, 3);
                            }
                            else
                            {
                                zone = new Rectangle2D(boat.X + 4, m.Y - 4, 3, 3);
                            }
                        }
                        else
                        {
                            if (Utility.RandomBool())
                            {
                                zone = new Rectangle2D(m.X + 4, boat.Y - 7, 3, 3);
                            }
                            else
                            {
                                zone = new Rectangle2D(m.X + 4, boat.Y + 4, 3, 3);
                            }
                        }
                    }
                    else
                    {
                        zone = new Rectangle2D(m.X - 3, m.Y - 3, 6, 6);
                    }

                    Point3D p = m.Location;

                    if (m.Map != null)
                    {
                        for (int j = 0; j < 25; j++)
                        {
                            Point3D check = m.Map.GetRandomSpawnPoint(zone);

                            if (CanFit(check.X, check.Y, check.Z, m.Map, bc))
                            {
                                p = check;
                                break;
                            }
                        }
                    }

                    foreach (Skill sk in bc.Skills.Where(s => s.Base > 0))
                    {
                        sk.Base += sk.Base * (difficulty);
                    }

                    bc.RawStr += (int)(bc.RawStr * difficulty);
                    bc.RawInt += (int)(bc.RawInt * difficulty);
                    bc.RawDex += (int)(bc.RawDex * difficulty);

                    if (bc.HitsMaxSeed == -1)
                    {
                        bc.HitsMaxSeed = bc.RawStr;
                    }

                    if (bc.StamMaxSeed == -1)
                    {
                        bc.StamMaxSeed = bc.RawDex;
                    }

                    if (bc.ManaMaxSeed == -1)
                    {
                        bc.ManaMaxSeed = bc.RawInt;
                    }

                    bc.HitsMaxSeed += (int)(bc.HitsMaxSeed * difficulty);
                    bc.StamMaxSeed += (int)(bc.StamMaxSeed * difficulty);
                    bc.ManaMaxSeed += (int)(bc.ManaMaxSeed * difficulty);

                    bc.Hits = bc.HitsMaxSeed;
                    bc.Stam = bc.RawDex;
                    bc.Mana = bc.RawInt;

                    bc.PhysicalResistanceSeed += (int)(bc.PhysicalResistanceSeed * (difficulty / 3));
                    bc.FireResistSeed         += (int)(bc.FireResistSeed * (difficulty / 3));
                    bc.ColdResistSeed         += (int)(bc.ColdResistSeed * (difficulty / 3));
                    bc.PoisonResistSeed       += (int)(bc.PoisonResistSeed * (difficulty / 3));
                    bc.EnergyResistSeed       += (int)(bc.EnergyResistSeed * (difficulty / 3));

                    bc.IsAmbusher = true;

                    if (Ambushers == null)
                    {
                        Ambushers = new Dictionary <BaseCreature, DateTime>();
                    }

                    Ambushers.Add(bc, DateTime.UtcNow + TimeSpan.FromMinutes(AmbusherDelete));

                    bc.MoveToWorld(p, m.Map);
                    Timer.DelayCall(() => bc.Combatant = m);
                }
            }

            m.SendLocalizedMessage(1049330, "", 0x22); // You have been ambushed! Fight for your honor!!!
        }
Пример #28
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                BaseBoat bt  = null;
                Point3D  loc = new Point3D();

                //Check we have a hook
                if (m_Hook == null)
                {
                    return;
                }

                //first do all our validation *again* to thwart sneaky players!
                //Has to be in backpack and on a boat
                if (!m_Hook.IsChildOf(from.Backpack))
                {
                    from.SendMessage("That must be in your backpack to use it.");
                    return;
                }
                bt = BaseBoat.FindBoatAt(from);
                if (bt == null || !bt.IsOnDeck(from))
                {
                    from.SendMessage("You must be on a boat to use this.");
                    return;
                }
                bt = null;

                //Disallow the targetting of movable Items
                if (targeted is Item)
                {
                    Item i = (Item)targeted;
                    if (i.Movable == true)
                    {
                        from.SendMessage("You must grapple onto something more sturdy!");
                        return;
                    }
                    //this item is immovable, see if there's a boat at its location
                    bt  = BaseBoat.FindBoatAt(i);
                    loc = i.Location;
                } // A static target is a good candidate
                else if (targeted is StaticTarget)
                {
                    //see if there's a boat at its location
                    StaticTarget st = (StaticTarget)targeted;

                    // Boats seem to have both TileFlag.Surface and TileFlag.Impassable flags on different parts of the deck
                    if ((st.Flags & TileFlag.Wet) == 0)
                    {
                        bt  = BaseBoat.FindBoatAt(st.Location, from.Map, 16);
                        loc = st.Location;
                    }
                }

                //If bt is still null, something was targeted not on a ship.
                if (bt != null)
                {
                    //Prevent targeting their own boat
                    if (bt.IsOnDeck(from))
                    {
                        from.SendMessage("You can't grapple the boat you are on!");
                        return;
                    }

                    if (bt.IsMoving)
                    {
                        //Play a "rope being thrown"  type sound effect (bellows :P)
                        Effects.PlaySound(from.Location, from.Map, 0x2B2);
                        from.SendMessage("You fail to get a good hook into the boat.");
                        return;
                    }

                    //If there any players who are alive then the hook gets pusehd back in ye olde water..
                    foreach (Mobile m in bt.GetMobilesOnDeck())
                    {
                        if (m is PlayerMobile && m.Alive && m.AccessLevel <= AccessLevel.Player)
                        {
                            from.SendMessage("You grapple the boat, but the hook is tossed back into the water.");
                            //Play a random water splashy sound effect!
                            Effects.PlaySound(from.Location, from.Map, 36 + Utility.Random(3) + 1);
                            return;
                        }
                    }

                    //Success!
                    from.SendMessage("You grapple the boat!");
                    //This is the bellows and double arrow hit played together :D
                    Effects.PlaySound(from.Location, from.Map, 0x2B2);
                    Effects.PlaySound(from.Location, from.Map, 0x523);
                    //Consume the grappling hook
                    m_Hook.Consume();
                    //Start the timer (approx the same time as the sound effects finish)
                    InternalTimer t = new InternalTimer(from, bt);
                    t.Start();
                }
                else
                {
                    from.SendMessage("That's not a boat!");
                }
            }
Пример #29
0
        public void Effect(Point3D loc, Map map, bool checkMulti, bool isboatkey = false)
        {
            if (Factions.Sigil.ExistsOn(this.Caster))
            {
                this.Caster.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil.
            }
            else if (map == null || (!Core.AOS && this.Caster.Map != map))
            {
                this.Caster.SendLocalizedMessage(1005570); // You can not gate to another facet.
            }
            else if (!SpellHelper.CheckTravel(this.Caster, TravelCheckType.GateFrom))
            {
            }
            else if (!SpellHelper.CheckTravel(this.Caster, map, loc, TravelCheckType.GateTo))
            {
            }
            else if (map == Map.Felucca && this.Caster is PlayerMobile && ((PlayerMobile)this.Caster).Young)
            {
                this.Caster.SendLocalizedMessage(1049543); // You decide against traveling to Felucca while you are still young.
            }
            else if (this.Caster.Kills >= 5 && map != Map.Felucca)
            {
                this.Caster.SendLocalizedMessage(1019004); // You are not allowed to travel there.
            }
            else if (this.Caster.Criminal)
            {
                this.Caster.SendLocalizedMessage(1005561, "", 0x22); // Thou'rt a criminal and cannot escape so easily.
            }
            else if (SpellHelper.CheckCombat(this.Caster))
            {
                this.Caster.SendLocalizedMessage(1005564, "", 0x22); // Wouldst thou flee during the heat of battle??
            }
            else if (!map.CanSpawnMobile(loc.X, loc.Y, loc.Z) && !isboatkey)
            {
                this.Caster.SendLocalizedMessage(501942); // That location is blocked.
            }
            else if ((checkMulti && SpellHelper.CheckMulti(loc, map)) && !isboatkey)
            {
                this.Caster.SendLocalizedMessage(501942);                                                                  // That location is blocked.
            }
            else if (Core.SE && (this.GateExistsAt(map, loc) || this.GateExistsAt(this.Caster.Map, this.Caster.Location))) // SE restricted stacking gates
            {
                this.Caster.SendLocalizedMessage(1071242);                                                                 // There is already a gate there.
            }
            else if (Server.Engines.CityLoyalty.CityTradeSystem.HasTrade(Caster))
            {
                Caster.SendLocalizedMessage(1151733); // You cannot do that while carrying a Trade Order.
            }
            else if (this.CheckSequence())
            {
                this.Caster.SendLocalizedMessage(501024); // You open a magical gate to another location

                Effects.PlaySound(this.Caster.Location, this.Caster.Map, 0x20E);

                InternalItem firstGate = new InternalItem(loc, map);
                firstGate.MoveToWorld(this.Caster.Location, this.Caster.Map);

                Effects.PlaySound(loc, map, 0x20E);

                InternalItem secondGate = new InternalItem(this.Caster.Location, this.Caster.Map);
                secondGate.MoveToWorld(loc, map);

                firstGate.LinkedGate  = secondGate;
                secondGate.LinkedGate = firstGate;

                firstGate.BoatGate  = BaseBoat.FindBoatAt(firstGate, firstGate.Map) != null;
                secondGate.BoatGate = BaseBoat.FindBoatAt(secondGate, secondGate.Map) != null;
            }

            this.FinishSequence();
        }
Пример #30
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;
                }
            }