Пример #1
0
        public override void OnBeforeSpawn(Point3D location, Map m)
        {
            base.OnBeforeSpawn(location, m);

            if (!BaseBoat.IsWaterTile(location, m))
            {
                Delete();
            }
        }
Пример #2
0
        public static void Splash(Point3D point, Map map)
        {
            BaseBoat boatCheck = BaseBoat.FindBoatAt(point, map);

            bool foundAnyItem = false;

            IPooledEnumerable itemsInRange = map.GetItemsInRange(point, 1);

            foreach (Item item in itemsInRange)
            {
                if (item != null)
                {
                    foundAnyItem = true;
                    break;
                }
            }

            itemsInRange.Free();

            //Boat in Location
            if (boatCheck != null)
            {
                Effects.PlaySound(point, map, 0x148);
            }

            //Water
            else if (BaseBoat.IsWaterTile(point, map))
            {
                if (!foundAnyItem)
                {
                    Effects.SendLocationEffect(point, map, 0x352D, 7);
                }

                Effects.PlaySound(point, map, 0x027);
            }

            //Anything Else
            else
            {
                Effects.PlaySound(point, map, 0x148);
            }
        }
Пример #3
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;
            }
        }
Пример #4
0
            protected override void OnTick()
            {
                if (!m_FishingSpotSpawner.Activated)
                {
                    return;
                }

                DateTime nextSpawnTime = m_FishingSpotSpawner.m_LastActivity + m_FishingSpotSpawner.m_NextActivity;

                if (nextSpawnTime < DateTime.UtcNow)
                {
                    if (m_FishingSpotSpawner.m_FishingSpots.Count < m_FishingSpotSpawner.InstanceCount)
                    {
                        int spotsNeeded  = m_FishingSpotSpawner.InstanceCount - m_FishingSpotSpawner.m_FishingSpots.Count;
                        int spotsSpawned = 0;

                        if (!m_FishingSpotSpawner.SpawnAllAvailable)
                        {
                            spotsNeeded = 1;
                        }

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

                        //Ships Needed
                        for (int a = 0; a < spotsNeeded; a++)
                        {
                            bool spotSpawned = false;

                            for (int b = 0; b < 25; b++)
                            {
                                if (spotSpawned)
                                {
                                    break;
                                }

                                Point3D newLocation = new Point3D();

                                int x = m_FishingSpotSpawner.X;

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

                                x += xOffset;

                                int y = m_FishingSpotSpawner.Y;

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

                                y += yOffset;

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

                                bool validWaterSpot = true;

                                for (int c = -2; c < 3; c++)
                                {
                                    if (!validWaterSpot)
                                    {
                                        break;
                                    }

                                    for (int d = -2; d < 3; d++)
                                    {
                                        Point3D componentPoint = new Point3D(newLocation.X - c, newLocation.Y - d, newLocation.Z);

                                        if (!BaseBoat.IsWaterTile(componentPoint, m_FishingSpotSpawner.Map))
                                        {
                                            validWaterSpot = false;
                                            break;
                                        }
                                    }
                                }

                                if (validWaterSpot)
                                {
                                    FishingSpot spot = null;

                                    switch (Utility.RandomMinMax(1, 2))
                                    {
                                    case 1: spot = new SchoolOfFish(); break;

                                    case 2: spot = new Shipwreck(); break;
                                    }

                                    if (spot != null)
                                    {
                                        spot.MoveToWorld(newLocation, m_FishingSpotSpawner.Map);
                                        spot.FishingSpotSpawner = m_FishingSpotSpawner;

                                        m_FishingSpotSpawner.m_LastActivity = DateTime.UtcNow;
                                        m_FishingSpotSpawner.m_FishingSpots.Add(spot);

                                        spotSpawned = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
Пример #5
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);
            }
        }
Пример #6
0
            protected override void OnTarget(Mobile from, object target)
            {
                if (from == null || m_SpidersilkNet == null)
                {
                    return;
                }
                if (from.Deleted || !from.Alive || m_SpidersilkNet.Deleted || m_SpidersilkNet.RootParent != from)
                {
                    return;
                }

                PlayerMobile player = from as PlayerMobile;

                if (player == null)
                {
                    return;
                }

                if (player.BoatOccupied == null)
                {
                    from.SendMessage("You must stay onboard your boat to continue your fishing action.");
                    return;
                }

                else if (player.BoatOccupied.Deleted)
                {
                    from.SendMessage("The boat you were fishing from no longer exists.");
                    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);
                }

                bool isWaterTile = BaseBoat.IsWaterTile(targetLocation.Location, map);

                if (!isWaterTile)
                {
                    from.SendMessage("That is not a valid location for that.");
                    return;
                }

                else
                {
                    FishingSpot fishingSpot = null;

                    IPooledEnumerable itemsNearTarget = map.GetItemsInRange(targetLocation.Location, 6);

                    foreach (Item item in itemsNearTarget)
                    {
                        if (item is FishingSpot)
                        {
                            fishingSpot = item as FishingSpot;
                            break;
                        }
                    }

                    itemsNearTarget.Free();

                    if (fishingSpot != null)
                    {
                        if (!fishingSpot.Deleted)
                        {
                            m_SpidersilkNet.ThrowNet(from, targetLocation.Location, fishingSpot);

                            return;
                        }
                    }

                    from.SendMessage("That is not a valid location for that.");
                    return;
                }
            }
Пример #7
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();
                }
            }