コード例 #1
0
        public static bool CanFit(int x, int y, int z, Map map, Mobile mob, int height = 16, bool checkMobiles = true, bool requireSurface = true)
        {
            if (map == null || map == Map.Internal)
            {
                return(false);
            }

            if (x < 0 || y < 0 || x >= map.Width || y >= map.Height)
            {
                return(false);
            }

            bool hasSurface = false;
            bool canswim    = mob.CanSwim;
            bool cantwalk   = mob.CantWalk;

            LandTile lt = map.Tiles.GetLandTile(x, y);
            int      lowZ = 0, avgZ = 0, topZ = 0;

            bool surface, impassable;

            map.GetAverageZ(x, y, ref lowZ, ref avgZ, ref topZ);
            TileFlag landFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags;

            impassable = (landFlags & TileFlag.Impassable) != 0;

            bool wet = (landFlags & TileFlag.Wet) != 0;

            if (cantwalk && !wet)
            {
                impassable = true;
            }

            if (canswim && wet)
            {
                impassable = false;
            }

            if (impassable && avgZ > z && (z + height) > lowZ)
            {
                return(false);
            }
            else if (!impassable && z == avgZ && !lt.Ignored)
            {
                hasSurface = true;
            }

            StaticTile[] staticTiles = map.Tiles.GetStaticTiles(x, y, true);

            for (int i = 0; i < staticTiles.Length; ++i)
            {
                ItemData id = TileData.ItemTable[staticTiles[i].ID & TileData.MaxItemValue];
                surface    = id.Surface;
                impassable = id.Impassable;

                wet = (id.Flags & TileFlag.Wet) != 0;

                if (cantwalk && !wet)
                {
                    impassable = true;
                }
                if (canswim && wet)
                {
                    surface    = true;
                    impassable = false;
                }

                if ((surface || impassable) && (staticTiles[i].Z + id.CalcHeight) > z && (z + height) > staticTiles[i].Z)
                {
                    return(false);
                }
                else if (surface && !impassable && z == (staticTiles[i].Z + id.CalcHeight))
                {
                    hasSurface = true;
                }
            }

            IPooledEnumerable eable = map.GetItemsInRange(new Point3D(x, y, z), 0);

            foreach (Item item in eable)
            {
                if (item.ItemID < 0x4000)
                {
                    ItemData id = item.ItemData;
                    surface    = id.Surface;
                    impassable = id.Impassable;

                    wet = (id.Flags & TileFlag.Wet) != 0;
                    if (cantwalk && !wet)
                    {
                        impassable = true;
                    }
                    if (canswim && wet)
                    {
                        surface    = true;
                        impassable = false;
                    }

                    if ((surface || impassable) && (item.Z + id.CalcHeight) > z && (z + height) > item.Z)
                    {
                        eable.Free();
                        return(false);
                    }
                    else if (surface && !impassable && !item.Movable && z == (item.Z + id.CalcHeight))
                    {
                        hasSurface = true;
                    }
                }
            }

            eable.Free();

            if (checkMobiles)
            {
                eable = map.GetMobilesInRange(new Point3D(x, y, z), 0);

                foreach (Mobile m in eable)
                {
                    if (m.AccessLevel == AccessLevel.Player || !m.Hidden)
                    {
                        if ((m.Z + 16) > z && (z + height) > m.Z)
                        {
                            eable.Free();
                            return(false);
                        }
                    }
                }

                eable.Free();
            }

            return(!requireSurface || hasSurface);
        }
コード例 #2
0
        public void WingBuffet()
        {
            if (!SpecialAbilities.Exists(this))
            {
                return;
            }

            int    wingFlaps    = 3;
            double flapDuration = 0.5;

            double minRange = 10;
            double maxRange = 30;

            int range = (int)(minRange + ((maxRange - minRange) * m_SpawnPercent));

            double totalDelay = 3;

            Combatant = null;

            SpecialAbilities.HinderSpecialAbility(1.0, null, this, 1.0, totalDelay, true, 0, false, "", "", "-1");

            m_AbilityInProgress  = true;
            m_NextAbilityAllowed = DateTime.UtcNow + GetNextAbilityDelay();

            m_HealthIntervalAbilityInProgress = true;

            Timer.DelayCall(TimeSpan.FromSeconds(totalDelay), delegate
            {
                if (!SpecialAbilities.Exists(this))
                {
                    return;
                }

                m_AbilityInProgress  = false;
                m_NextAbilityAllowed = DateTime.UtcNow + GetNextAbilityDelay();

                m_HealthIntervalAbilityInProgress = false;
            });

            PublicOverheadMessage(MessageType.Regular, 0, false, "*furiously beats wings*");

            for (int a = 0; a < wingFlaps; a++)
            {
                Timer.DelayCall(TimeSpan.FromSeconds(a * flapDuration), delegate
                {
                    if (!SpecialAbilities.Exists(this))
                    {
                        return;
                    }

                    Effects.PlaySound(Location, Map, GetAngerSound());

                    Animate(19, 10, 2, true, false, 0);
                });
            }

            Timer.DelayCall(TimeSpan.FromSeconds((double)wingFlaps * flapDuration), delegate
            {
                if (!SpecialAbilities.Exists(this))
                {
                    return;
                }

                Point3D location = Location;
                Map map          = Map;

                Queue m_Queue = new Queue();

                IPooledEnumerable nearbyMobiles = map.GetMobilesInRange(location, range);

                foreach (Mobile mobile in nearbyMobiles)
                {
                    if (mobile == this)
                    {
                        continue;
                    }
                    if (!SpecialAbilities.MonsterCanDamage(this, mobile))
                    {
                        continue;
                    }

                    m_Queue.Enqueue(mobile);
                }

                nearbyMobiles.Free();

                while (m_Queue.Count > 0)
                {
                    Mobile mobile = (Mobile)m_Queue.Dequeue();

                    int distance = range - Utility.GetDistance(location, mobile.Location);

                    if (distance < 1)
                    {
                        distance = 1;
                    }

                    double damage = (double)(Utility.RandomMinMax(DamageMin, DamageMax)) * 2;

                    SpecialAbilities.KnockbackSpecialAbility(1.0, location, this, mobile, damage, distance, -1, "", "The beast buffets you with its wings!");
                }
            });
        }
コード例 #3
0
            protected override void OnTarget(Mobile from, object target)
            {
                if (m_ParagonDevolveWand.Deleted || m_ParagonDevolveWand.RootParent != from)
                {
                    return;
                }

                PlayerMobile player = from as PlayerMobile;

                if (player == null)
                {
                    return;
                }

                BaseCreature bc_Target = target as BaseCreature;

                if (bc_Target == null)
                {
                    from.SendMessage("That is not a valid creature.");
                    return;
                }

                if (!bc_Target.IsParagon)
                {
                    from.SendMessage("That creature is not a paragon.");
                    return;
                }

                if (bc_Target.Controlled)
                {
                    from.SendMessage("That creature is currently controlled.");
                    return;
                }

                if (player.AccessLevel == AccessLevel.Player)
                {
                    if (!bc_Target.Map.InLOS(from.Location, bc_Target.Location))
                    {
                        from.SendMessage("You must have a valid line-of-sight to the creature you wish to target.");
                        return;
                    }

                    if (bc_Target.Combatant != null)
                    {
                        from.SendMessage("You may not target creatures currently engaged in combat.");
                        return;
                    }

                    if (bc_Target.Hits < bc_Target.HitsMax)
                    {
                        from.SendMessage("You may not target creatures that are currently injured.");
                        return;
                    }

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

                        from.SendMessage("That has spawned too recently to be devolved. You must wait another " + timeRemaining + ".");
                        return;
                    }

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

                        from.SendMessage("That has been in combat too recently. You must wait another " + timeRemaining + ".");
                        return;
                    }

                    if (!from.CanBeginAction(typeof(ParagonDevolveWand)))
                    {
                        from.SendMessage("You may only use a single paragon devolve wand per hour.");
                        return;
                    }
                }

                bool targetValid = true;

                IPooledEnumerable mobilesNearby = bc_Target.Map.GetMobilesInRange(bc_Target.Location, 12);

                if (player.AccessLevel == AccessLevel.Player)
                {
                    foreach (Mobile mobile in mobilesNearby)
                    {
                        if (mobile.Combatant == bc_Target)
                        {
                            targetValid = false;
                            from.SendMessage("That creature is currently being engaged in combat by someone.");

                            break;
                        }

                        BaseCreature nearbyCreature = mobile as BaseCreature;
                        PlayerMobile nearbyPlayer   = mobile as PlayerMobile;

                        if (mobile != from)
                        {
                            if (nearbyCreature != null)
                            {
                                if (nearbyCreature.Controlled && nearbyCreature.ControlMaster is PlayerMobile && nearbyCreature.ControlMaster != from)
                                {
                                    targetValid = false;
                                    from.SendMessage("That target is too near another player's follower.");
                                    break;
                                }
                            }

                            if (nearbyPlayer != null)
                            {
                                targetValid = false;
                                from.SendMessage("That target is too near another player.");
                                break;
                            }
                        }
                    }
                }

                mobilesNearby.Free();

                if (targetValid)
                {
                    bc_Target.FixedParticles(0x374A, 10, 30, 5054, EffectLayer.Head);
                    bc_Target.PlaySound(0x1F9);

                    bc_Target.IsParagon        = false;
                    bc_Target.ConvertedParagon = true;

                    from.SendMessage("You devolve the creature and remove its paragon status.");

                    m_ParagonDevolveWand.m_Charges--;

                    if (from.AccessLevel == AccessLevel.Player)
                    {
                        from.BeginAction(typeof(ParagonDevolveWand));

                        Timer.DelayCall(ParagonDevolveWand.UsageCooldown, delegate
                        {
                            if (from != null)
                            {
                                from.EndAction(typeof(ParagonDevolveWand));
                            }
                        });
                    }

                    if (m_ParagonDevolveWand.m_Charges == 0)
                    {
                        from.SendMessage("You use the last charge on the wand.");
                        m_ParagonDevolveWand.Delete();
                    }
                }
            }
コード例 #4
0
ファイル: ArchProtection.cs プロジェクト: alucardxlx/Casiopia
        public void Target(IPoint3D p)
        {
            if (!Caster.CanSee(p))
            {
                Caster.SendLocalizedMessage(500237);                   // Target can not be seen.
            }
            else if (CheckSequence())
            {
                SpellHelper.Turn(Caster, p);

                SpellHelper.GetSurfaceTop(ref p);

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

                Map map = Caster.Map;

                if (map != null)
                {
                    IPooledEnumerable eable = map.GetMobilesInRange(new Point3D(p), Core.AOS ? 2 : 3);

                    foreach (Mobile m in eable)
                    {
                        if (Caster.CanBeBeneficial(m, false))
                        {
                            targets.Add(m);
                        }
                    }

                    eable.Free();
                }

                if (Core.AOS)
                {
                    Party party = Party.Get(Caster);

                    for (int i = 0; i < targets.Count; ++i)
                    {
                        Mobile m = targets[i];

                        if (m == Caster || (party != null && party.Contains(m)))
                        {
                            Caster.DoBeneficial(m);
                            Spells.Second.ProtectionSpell.Toggle(Caster, m);
                        }
                    }
                }
                else
                {
                    Effects.PlaySound(p, Caster.Map, 0x299);

                    int val = (int)(Caster.Skills[SkillName.Magery].Value / 10.0 + 1);

                    if (targets.Count > 0)
                    {
                        for (int i = 0; i < targets.Count; ++i)
                        {
                            Mobile m = targets[i];

                            if (m.BeginAction(typeof(ArchProtectionSpell)))
                            {
                                Caster.DoBeneficial(m);
                                m.VirtualArmorMod += val;
                                new InternalTimer(m, Caster, val).Start();

                                m.FixedParticles(0x375A, 9, 20, 5027, EffectLayer.Waist);
                                m.PlaySound(0x1F7);
                            }
                        }
                    }
                }
            }

            FinishSequence();
        }
コード例 #5
0
        public void FireBarrage()
        {
            if (!SpecialAbilities.Exists(this))
            {
                return;
            }

            IPooledEnumerable nearbyMobiles = Map.GetMobilesInRange(Location, FireBarrageRange);

            int mobileCount = 0;

            foreach (Mobile mobile in nearbyMobiles)
            {
                if (mobile == this)
                {
                    continue;
                }
                if (!SpecialAbilities.MonsterCanDamage(this, mobile))
                {
                    continue;
                }
                if (!Map.InLOS(Location, mobile.Location))
                {
                    continue;
                }
                if (mobile.Hidden)
                {
                    continue;
                }

                mobileCount++;
            }

            nearbyMobiles.Free();
            nearbyMobiles = Map.GetMobilesInRange(Location, FireBarrageRange);

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

            foreach (Mobile mobile in nearbyMobiles)
            {
                if (mobile == this)
                {
                    continue;
                }
                if (!SpecialAbilities.MonsterCanDamage(this, mobile))
                {
                    continue;
                }
                if (!Map.InLOS(Location, mobile.Location))
                {
                    continue;
                }
                if (mobile.Hidden)
                {
                    continue;
                }
                if (Combatant != null)
                {
                    if (mobileCount > 1 && mobile == Combatant)
                    {
                        continue;
                    }
                }

                m_NearbyMobiles.Add(mobile);
            }

            nearbyMobiles.Free();

            if (m_NearbyMobiles.Count == 0)
            {
                return;
            }

            Mobile mobileTarget = m_NearbyMobiles[Utility.RandomMinMax(0, m_NearbyMobiles.Count - 1)];

            int maxExtraFireballs = 10;
            int fireballs         = 10 + (int)Math.Ceiling(((double)maxExtraFireballs * m_SpawnPercent));

            double directionDelay = .25;
            double initialDelay   = 1;
            double fireballDelay  = .1;
            double totalDelay     = 1 + directionDelay + initialDelay + ((double)fireballs * fireballDelay);

            SpecialAbilities.HinderSpecialAbility(1.0, null, this, 1.0, totalDelay, true, 0, false, "", "", "-1");

            m_AbilityInProgress  = true;
            m_NextAbilityAllowed = DateTime.UtcNow + GetNextAbilityDelay();

            m_NextFireBarrageAllowed = DateTime.UtcNow + NextFireBarrageDelay;

            Timer.DelayCall(TimeSpan.FromSeconds(totalDelay), delegate
            {
                if (!SpecialAbilities.Exists(this))
                {
                    return;
                }

                m_AbilityInProgress  = false;
                m_NextAbilityAllowed = DateTime.UtcNow + GetNextAbilityDelay();

                m_NextFireBarrageAllowed = DateTime.UtcNow + NextFireBarrageDelay;
            });

            PublicOverheadMessage(MessageType.Regular, 0, false, "*takes deep breath*");

            Point3D location = Location;
            Map     map      = Map;

            Point3D targetLocation = mobileTarget.Location;
            Map     targetMap      = mobileTarget.Map;

            Direction = Utility.GetDirection(Location, targetLocation);

            Timer.DelayCall(TimeSpan.FromSeconds(directionDelay), delegate
            {
                if (!SpecialAbilities.Exists(this))
                {
                    return;
                }

                Animate(5, 15, 1, true, false, 0);
                PlaySound(GetAngerSound());

                Timer.DelayCall(TimeSpan.FromSeconds(initialDelay), delegate
                {
                    if (!SpecialAbilities.Exists(this))
                    {
                        return;
                    }

                    for (int a = 0; a < fireballs; a++)
                    {
                        Timer.DelayCall(TimeSpan.FromSeconds(a * fireballDelay), delegate
                        {
                            if (!SpecialAbilities.Exists(this))
                            {
                                return;
                            }
                            if (m_HealthIntervalAbilityInProgress)
                            {
                                return;
                            }

                            bool mobileTargetValid = true;

                            if (mobileTarget == null)
                            {
                                mobileTargetValid = false;
                            }

                            else if (mobileTarget.Deleted || !mobileTarget.Alive)
                            {
                                mobileTargetValid = false;
                            }

                            else
                            {
                                if (mobileTarget.Hidden || Utility.GetDistance(Location, mobileTarget.Location) >= FireBarrageRange)
                                {
                                    mobileTargetValid = false;
                                }
                            }

                            if (mobileTargetValid)
                            {
                                targetLocation = mobileTarget.Location;
                                targetMap      = mobileTarget.Map;
                            }

                            int effectSound = 0x357;
                            int itemID      = 0x36D4;
                            int itemHue     = 0;

                            int impactSound = 0x226;
                            int impactHue   = 0;

                            int xOffset = 0;
                            int yOffset = 0;

                            int distance = Utility.GetDistance(Location, targetLocation);

                            if (distance > 1)
                            {
                                if (Utility.RandomDouble() <= .5)
                                {
                                    xOffset = Utility.RandomList(-1, 1);
                                }

                                if (Utility.RandomDouble() <= .5)
                                {
                                    yOffset = Utility.RandomList(-1, 1);
                                }
                            }

                            IEntity startLocation = new Entity(Serial.Zero, new Point3D(location.X, location.Y, location.Z + 10), map);

                            Point3D adjustedLocation = new Point3D(targetLocation.X + xOffset, targetLocation.Y + yOffset, targetLocation.Z);
                            SpellHelper.AdjustField(ref adjustedLocation, targetMap, 12, false);

                            IEntity endLocation = new Entity(Serial.Zero, new Point3D(adjustedLocation.X, adjustedLocation.Y, adjustedLocation.Z + 10), targetMap);

                            Effects.PlaySound(location, map, effectSound);
                            Effects.SendMovingEffect(startLocation, endLocation, itemID, 8, 0, false, false, itemHue, 0);

                            double targetDistance   = Utility.GetDistanceToSqrt(location, adjustedLocation);
                            double destinationDelay = (double)targetDistance * .06;

                            Direction newDirection = Utility.GetDirection(location, adjustedLocation);

                            if (Direction != newDirection)
                            {
                                Direction = newDirection;
                            }

                            Timer.DelayCall(TimeSpan.FromSeconds(destinationDelay), delegate
                            {
                                if (!SpecialAbilities.Exists(this))
                                {
                                    return;
                                }

                                Effects.PlaySound(adjustedLocation, targetMap, impactSound);
                                Effects.SendLocationParticles(EffectItem.Create(adjustedLocation, targetMap, EffectItem.DefaultDuration), 0x3709, 20, 20, impactHue, 0, 0, 0);

                                Queue m_Queue = new Queue();

                                nearbyMobiles = targetMap.GetMobilesInRange(adjustedLocation, 0);

                                foreach (Mobile mobile in nearbyMobiles)
                                {
                                    if (mobile == this)
                                    {
                                        continue;
                                    }
                                    if (!SpecialAbilities.MonsterCanDamage(this, mobile))
                                    {
                                        continue;
                                    }

                                    m_Queue.Enqueue(mobile);
                                }

                                nearbyMobiles.Free();

                                while (m_Queue.Count > 0)
                                {
                                    Mobile mobile = (Mobile)m_Queue.Dequeue();

                                    int damage = (int)(Math.Round((double)DamageMin / 5));

                                    if (mobile is BaseCreature)
                                    {
                                        damage *= 3;
                                    }

                                    else
                                    {
                                        if (Utility.GetDistance(Location, mobile.Location) <= 1)
                                        {
                                            damage = (int)(Math.Round((double)damage * .5));
                                        }
                                    }

                                    DoHarmful(mobile);

                                    new Blood().MoveToWorld(mobile.Location, mobile.Map);
                                    AOS.Damage(mobile, this, damage, 0, 100, 0, 0, 0);
                                }
                            });
                        });
                    }
                });
            });
        }
コード例 #6
0
ファイル: ChainLightning.cs プロジェクト: alucardxlx/Casiopia
        public void Target(IPoint3D p)
        {
            if (!Caster.CanSee(p))
            {
                Caster.SendLocalizedMessage(500237);                   // Target can not be seen.
            }
            else if (SpellHelper.CheckTown(p, Caster) && CheckSequence())
            {
                SpellHelper.Turn(Caster, p);

                if (p is Item)
                {
                    p = ((Item)p).GetWorldLocation();
                }

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

                Map map = Caster.Map;

                bool playerVsPlayer = false;

                if (map != null)
                {
                    IPooledEnumerable eable = map.GetMobilesInRange(new Point3D(p), 2);

                    foreach (Mobile m in eable)
                    {
                        if (Core.AOS && m == Caster)
                        {
                            continue;
                        }

                        if (SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false))
                        {
                            if (Core.AOS && !Caster.InLOS(m))
                            {
                                continue;
                            }

                            targets.Add(m);

                            if (m.Player)
                            {
                                playerVsPlayer = true;
                            }
                        }
                    }

                    eable.Free();
                }

                double damage;

                if (Core.AOS)
                {
                    damage = GetNewAosDamage(51, 1, 5, playerVsPlayer);
                }
                else
                {
                    //damage = Utility.Random( 30, 18 ); // 30 - 47
                    damage = Utility.Dice(4, 5, 26);                       // 30 - 46
                }
                if (targets.Count > 0)
                {
                    if (!(Caster is BaseCreature))
                    {
                        if (Core.AOS && targets.Count > 2)
                        {
                            damage = (damage * 2) / targets.Count;
                        }
                        else if (!Core.AOS)
                        {
                            damage /= targets.Count;
                        }
                    }

                    for (int i = 0; i < targets.Count; ++i)
                    {
                        Mobile m = targets[i];

                        double toDeal = damage;

                        if (!Core.AOS && CheckResisted(m))
                        {
                            toDeal *= 0.5;

                            m.SendLocalizedMessage(501783);                               // You feel yourself resisting magical energy.
                        }

                        toDeal *= GetDamageScalar(m);

                        //Caster.DoHarmful( m );
                        SpellHelper.Damage(this, m, toDeal, 0, 0, 0, 0, 100);
                        m.BoltEffect(0);
                    }
                }
                else
                {
                    Caster.PlaySound(0x29);
                }
            }

            FinishSequence();
        }
コード例 #7
0
        public bool SetFacing(Direction facing)
        {
            if (Parent != null || Map == null)
            {
                return(false);
            }

            if (Map != Map.Internal)
            {
                switch (facing)
                {
                case Direction.North: if (!CanFit(Location, Map, NorthId, facing, false))
                    {
                        return(false);
                    }
                    break;

                case Direction.East: if (!CanFit(Location, Map, EastId, facing, false))
                    {
                        return(false);
                    }
                    break;

                case Direction.South: if (!CanFit(Location, Map, SouthId, facing, false))
                    {
                        return(false);
                    }
                    break;

                case Direction.West: if (!CanFit(Location, Map, WestId, facing, false))
                    {
                        return(false);
                    }
                    break;
                }
            }

            Map.OnLeave(this);

            Direction old = Facing;

            _facing = facing;

            MultiComponentList mcl    = Components;
            List <IEntity>     toMove = new List <IEntity>();
            IPooledEnumerable  eable  = Map.GetObjectsInBounds(new Rectangle2D((X + mcl.Min.X), (Y + mcl.Min.Y), mcl.Width, mcl.Height));

            foreach (object obj in eable)
            {
                if (obj is Item && Contains((Item)obj))
                {
                    Item i = obj as Item;

                    if (i != this && i.Z >= Z)
                    {
                        toMove.Add(i);
                    }
                }
                else if (obj is Mobile && Contains((Mobile)obj))
                {
                    toMove.Add((Mobile)obj);
                    ((Mobile)obj).Direction = (Direction)((int)((Mobile)obj).Direction - (int)old + (int)facing);
                }
            }

            eable.Free();

            int count = (int)(Facing - old) & 0x7;

            count /= 2;

            for (int i = 0; i < toMove.Count; i++)
            {
                IEntity ent = toMove[i];

                if (ent is Item)
                {
                    ((Item)ent).Location = Rotate(ent.Location, count);
                }
                else if (ent is Mobile)
                {
                    ((Mobile)ent).Location = Rotate(ent.Location, count);
                }
            }

            switch (Facing)
            {
            case Direction.North: ItemID = NorthId; break;

            case Direction.East: ItemID = EastId; break;

            case Direction.South: ItemID = SouthId; break;

            case Direction.West: ItemID = WestId; break;
            }

            if (Shadow != null && !Shadow.Deleted)
            {
                Shadow.OnRotate(old, Facing);
            }

            Map.OnEnter(this);
            return(true);
        }
コード例 #8
0
        public static HousePlacementResult Check(Mobile from, int multiID, Point3D center, out ArrayList toMove)
        {
            // If this spot is considered valid, every item and mobile in this list will be moved under the house sign
            toMove = new ArrayList();

            Map map = from.Map;

            if (map == null || map == Map.Internal)
            {
                return(HousePlacementResult.BadLand);                // A house cannot go here
            }
            if (from.AccessLevel >= AccessLevel.GameMaster)
            {
                return(HousePlacementResult.Valid);                // Staff can place anywhere
            }
            if (map == Map.Ilshenar)
            {
                return(HousePlacementResult.BadRegion);                // No houses in Ilshenar
            }
            NoHousingRegion noHousingRegion = Region.Find(center, map) as NoHousingRegion;

            if (noHousingRegion != null)
            {
                return(HousePlacementResult.BadRegion);
            }

            // This holds data describing the internal structure of the house
            MultiComponentList mcl = MultiData.GetComponents(multiID);

            if (multiID >= 0x13EC && multiID < 0x1D00)
            {
                HouseFoundation.AddStairsTo(ref mcl);                   // this is a AOS house, add the stairs
            }
            // Location of the nortwest-most corner of the house
            Point3D start = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Min.Y, center.Z);

            // These are storage lists. They hold items and mobiles found in the map for further processing
            ArrayList items = new ArrayList(), mobiles = new ArrayList();

            // These are also storage lists. They hold location values indicating the yard and border locations.
            ArrayList yard = new ArrayList(), borders = new ArrayList();

            /* RULES:
             *
             * 1) All tiles which are around the -outside- of the foundation must not have anything impassable.
             * 2) No impassable object or land tile may come in direct contact with any part of the house.
             * 3) Five tiles from the front and back of the house must be completely clear of all house tiles.
             * 4) The foundation must rest flatly on a surface. Any bumps around the foundation are not allowed.
             * 5) No foundation tile may reside over terrain which is viewed as a road.
             */

            for (int x = 0; x < mcl.Width; ++x)
            {
                for (int y = 0; y < mcl.Height; ++y)
                {
                    int tileX = start.X + x;
                    int tileY = start.Y + y;

                    Tile[] addTiles = mcl.Tiles[x][y];

                    if (addTiles.Length == 0)
                    {
                        continue;                         // There are no tiles here, continue checking somewhere else
                    }
                    Point3D testPoint = new Point3D(tileX, tileY, center.Z);

                    Region reg = Region.Find(testPoint, map);

                    if (!reg.AllowHousing(from, testPoint))                         // Cannot place houses in dungeons, towns, treasure map areas etc
                    {
                        if (reg is TreasureRegion)
                        {
                            return(HousePlacementResult.BadRegionHidden);
                        }

                        return(HousePlacementResult.BadRegion);
                    }

                    Tile landTile = map.Tiles.GetLandTile(tileX, tileY);
                    int  landID   = landTile.ID & 0x3FFF;

                    Tile[] oldTiles = map.Tiles.GetStaticTiles(tileX, tileY, true);

                    Sector sector = map.GetSector(tileX, tileY);

                    items.Clear();

                    for (int i = 0; i < sector.Items.Count; ++i)
                    {
                        Item item = (Item)sector.Items[i];

                        if (item.Visible && item.X == tileX && item.Y == tileY)
                        {
                            items.Add(item);
                        }
                    }

                    mobiles.Clear();

                    for (int i = 0; i < sector.Mobiles.Count; ++i)
                    {
                        Mobile m = (Mobile)sector.Mobiles[i];

                        if (m.X == tileX && m.Y == tileY)
                        {
                            mobiles.Add(m);
                        }
                    }

                    int landStartZ = 0, landAvgZ = 0, landTopZ = 0;

                    map.GetAverageZ(tileX, tileY, ref landStartZ, ref landAvgZ, ref landTopZ);

                    bool hasFoundation = false;

                    for (int i = 0; i < addTiles.Length; ++i)
                    {
                        Tile addTile = addTiles[i];

                        if (addTile.ID == 0x4001)                           // Nodraw
                        {
                            continue;
                        }

                        TileFlag addTileFlags = TileData.ItemTable[addTile.ID & 0x3FFF].Flags;

                        bool isFoundation = (addTile.Z == 0 && (addTileFlags & TileFlag.Wall) != 0);
                        bool hasSurface   = false;

                        if (isFoundation)
                        {
                            hasFoundation = true;
                        }

                        int addTileZ   = center.Z + addTile.Z;
                        int addTileTop = addTileZ + addTile.Height;

                        if ((addTileFlags & TileFlag.Surface) != 0)
                        {
                            addTileTop += 16;
                        }

                        if (addTileTop > landStartZ && landAvgZ > addTileZ)
                        {
                            return(HousePlacementResult.BadLand);                            // Broke rule #2
                        }
                        if (isFoundation && ((TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Impassable) == 0) && landAvgZ == center.Z)
                        {
                            hasSurface = true;
                        }

                        for (int j = 0; j < oldTiles.Length; ++j)
                        {
                            Tile     oldTile = oldTiles[j];
                            ItemData id      = TileData.ItemTable[oldTile.ID & 0x3FFF];

                            if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)) && addTileTop > oldTile.Z && (oldTile.Z + id.CalcHeight) > addTileZ)
                            {
                                return(HousePlacementResult.BadStatic);                                // Broke rule #2
                            }

                            /*else if ( isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (oldTile.Z + id.CalcHeight) == center.Z )
                             *      hasSurface = true;*/
                        }

                        for (int j = 0; j < items.Count; ++j)
                        {
                            Item     item = (Item)items[j];
                            ItemData id   = item.ItemData;

                            if (addTileTop > item.Z && (item.Z + id.CalcHeight) > addTileZ)
                            {
                                if (item.Movable)
                                {
                                    toMove.Add(item);
                                }
                                else if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)))
                                {
                                    return(HousePlacementResult.BadItem);                                    // Broke rule #2
                                }
                            }

                            /*else if ( isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (item.Z + id.CalcHeight) == center.Z )
                             * {
                             *      hasSurface = true;
                             * }*/
                        }

                        if (isFoundation && !hasSurface)
                        {
                            return(HousePlacementResult.NoSurface);                            // Broke rule #4
                        }
                        for (int j = 0; j < mobiles.Count; ++j)
                        {
                            Mobile m = (Mobile)mobiles[j];

                            if (addTileTop > m.Z && (m.Z + 16) > addTileZ)
                            {
                                toMove.Add(m);
                            }
                        }
                    }

                    for (int i = 0; i < m_RoadIDs.Length; i += 2)
                    {
                        if (landID >= m_RoadIDs[i] && landID <= m_RoadIDs[i + 1])
                        {
                            return(HousePlacementResult.BadLand);                            // Broke rule #5
                        }
                    }

                    if (hasFoundation)
                    {
                        for (int xOffset = -1; xOffset <= 1; ++xOffset)
                        {
                            for (int yOffset = -YardSize; yOffset <= YardSize; ++yOffset)
                            {
                                Point2D yardPoint = new Point2D(tileX + xOffset, tileY + yOffset);

                                if (!yard.Contains(yardPoint))
                                {
                                    yard.Add(yardPoint);
                                }
                            }
                        }

                        for (int xOffset = -1; xOffset <= 1; ++xOffset)
                        {
                            for (int yOffset = -1; yOffset <= 1; ++yOffset)
                            {
                                if (xOffset == 0 && yOffset == 0)
                                {
                                    continue;
                                }

                                // To ease this rule, we will not add to the border list if the tile here is under a base floor (z<=8)

                                int vx = x + xOffset;
                                int vy = y + yOffset;

                                if (vx >= 0 && vx < mcl.Width && vy >= 0 && vy < mcl.Height)
                                {
                                    Tile[] breakTiles  = mcl.Tiles[vx][vy];
                                    bool   shouldBreak = false;

                                    for (int i = 0; !shouldBreak && i < breakTiles.Length; ++i)
                                    {
                                        Tile breakTile = breakTiles[i];

                                        if (breakTile.Height == 0 && breakTile.Z <= 8 && TileData.ItemTable[breakTile.ID & 0x3FFF].Surface)
                                        {
                                            shouldBreak = true;
                                        }
                                    }

                                    if (shouldBreak)
                                    {
                                        continue;
                                    }
                                }

                                Point2D borderPoint = new Point2D(tileX + xOffset, tileY + yOffset);

                                if (!borders.Contains(borderPoint))
                                {
                                    borders.Add(borderPoint);
                                }
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < borders.Count; ++i)
            {
                Point2D borderPoint = (Point2D)borders[i];

                Tile landTile = map.Tiles.GetLandTile(borderPoint.X, borderPoint.Y);
                int  landID   = landTile.ID & 0x3FFF;

                if ((TileData.LandTable[landID].Flags & TileFlag.Impassable) != 0)
                {
                    return(HousePlacementResult.BadLand);
                }

                for (int j = 0; j < m_RoadIDs.Length; j += 2)
                {
                    if (landID >= m_RoadIDs[j] && landID <= m_RoadIDs[j + 1])
                    {
                        return(HousePlacementResult.BadLand);                        // Broke rule #5
                    }
                }

                Tile[] tiles = map.Tiles.GetStaticTiles(borderPoint.X, borderPoint.Y, true);

                for (int j = 0; j < tiles.Length; ++j)
                {
                    Tile     tile = tiles[j];
                    ItemData id   = TileData.ItemTable[tile.ID & 0x3FFF];

                    if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (tile.Z + id.CalcHeight) > (center.Z + 2)))
                    {
                        return(HousePlacementResult.BadStatic);                        // Broke rule #1
                    }
                }

                Sector    sector      = map.GetSector(borderPoint.X, borderPoint.Y);
                ArrayList sectorItems = sector.Items;

                for (int j = 0; j < sectorItems.Count; ++j)
                {
                    Item item = (Item)sectorItems[j];

                    if (item.X != borderPoint.X || item.Y != borderPoint.Y || item.Movable)
                    {
                        continue;
                    }

                    ItemData id = item.ItemData;

                    if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (item.Z + id.CalcHeight) > (center.Z + 2)))
                    {
                        return(HousePlacementResult.BadItem);                        // Broke rule #1
                    }
                }
            }

            for (int i = 0; i < yard.Count; ++i)
            {
                Point2D yardPoint = (Point2D)yard[i];

                IPooledEnumerable eable = map.GetMultiTilesAt(yardPoint.X, yardPoint.Y);

                foreach (Tile[] tile in eable)
                {
                    for (int j = 0; j < tile.Length; ++j)
                    {
                        if ((TileData.ItemTable[tile[j].ID & 0x3FFF].Flags & (TileFlag.Impassable | TileFlag.Surface)) != 0)
                        {
                            eable.Free();
                            return(HousePlacementResult.BadStatic);                            // Broke rule #3
                        }
                    }
                }

                eable.Free();
            }

            return(HousePlacementResult.Valid);

            /*if ( blockedLand || blockedStatic || blockedItem )
             * {
             *      from.SendLocalizedMessage( 1043287 ); // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
             * }
             * else if ( !foundationHasSurface )
             * {
             *      from.SendMessage( "The house could not be created here.  Part of the foundation would not be on any surface." );
             * }
             * else
             * {
             *      BaseHouse house = GetHouse( from );
             *      house.MoveToWorld( center, from.Map );
             *      this.Delete();
             *
             *      for ( int i = 0; i < toMove.Count; ++i )
             *      {
             *              object o = toMove[i];
             *
             *              if ( o is Mobile )
             *                      ((Mobile)o).Location = house.BanLocation;
             *              else if ( o is Item )
             *                      ((Item)o).Location = house.BanLocation;
             *      }
             * }*/
        }
コード例 #9
0
ファイル: PoisonField.cs プロジェクト: proxeeus/UORebirth
                protected override void OnTick()
                {
                    if (m_Item.Deleted)
                    {
                        return;
                    }

                    if (!m_Item.Visible)
                    {
                        if (m_InLOS && m_CanFit)
                        {
                            m_Item.Visible = true;
                        }
                        else
                        {
                            m_Item.Delete();
                        }

                        if (!m_Item.Deleted)
                        {
                            m_Item.ProcessDelta();
                            Effects.SendLocationParticles(EffectItem.Create(m_Item.Location, m_Item.Map, EffectItem.DefaultDuration), 0x376A, 9, 10, 5040);
                        }
                    }
                    else if (DateTime.Now > m_Item.m_End)
                    {
                        m_Item.Delete();
                        Stop();
                    }
                    else
                    {
                        Map    map    = m_Item.Map;
                        Mobile caster = m_Item.m_Caster;

                        if (map != null && caster != null)
                        {
                            bool eastToWest         = (m_Item.ItemID == 0x3915);
                            IPooledEnumerable eable = map.GetMobilesInBounds(new Rectangle2D(m_Item.X - (eastToWest ? 0 : 1), m_Item.Y - (eastToWest ? 1 : 0), (eastToWest ? 1 : 2), (eastToWest ? 2 : 1)));;

                            foreach (Mobile m in eable)
                            {
                                if ((m.Z + 16) > m_Item.Z && (m_Item.Z + 12) > m.Z && SpellHelper.ValidIndirectTarget(caster, m) && caster.CanBeHarmful(m, false))
                                {
                                    m_Queue.Enqueue(m);
                                }
                            }

                            eable.Free();

                            while (m_Queue.Count > 0)
                            {
                                Mobile m = (Mobile)m_Queue.Dequeue();

                                caster.DoHarmful(m);

                                bool guarded = (m.Region is GuardedRegion && !((GuardedRegion)m.Region).IsDisabled());

                                if (!guarded && !m.CheckSkill(SkillName.MagicResist, 5.0, 45.0))                                     // CheckResistedEasy
                                {
                                    m.ApplyPoison(caster, Poison.Regular);
                                }
                                else
                                {
                                    m.SendLocalizedMessage(501783);                                       // You feel yourself resisting magical energy.
                                }
                                m.PlaySound(0x474);
                            }
                        }
                    }
                }
コード例 #10
0
        private static void Process(Map map, Rectangle2D[] regions)
        {
            m_ShopTable = new Hashtable();
            m_ShopList  = new ArrayList();

            World.Broadcast(0x35, true, "Generating vendor spawns for {0}, please wait.", map);

            for (int i = 0; i < regions.Length; ++i)
            {
                for (int x = 0; x < map.Width; ++x)
                {
                    for (int y = 0; y < map.Height; ++y)
                    {
                        CheckPoint(map, regions[i].X + x, regions[i].Y + y);
                    }
                }
            }

            for (int i = 0; i < m_ShopList.Count; ++i)
            {
                ShopInfo si = (ShopInfo)m_ShopList[i];

                int xTotal = 0;
                int yTotal = 0;

                bool hasSpawner = false;

                for (int j = 0; !hasSpawner && j < si.m_Floor.Count; ++j)
                {
                    Point2D fp = (Point2D)si.m_Floor[j];

                    xTotal += fp.X;
                    yTotal += fp.Y;

                    IPooledEnumerable eable = map.GetItemsInRange(new Point3D(fp.X, fp.Y, 0), 0);

                    foreach (Item item in eable)
                    {
                        if (item is Spawner)
                        {
                            hasSpawner = true;
                            break;
                        }
                    }

                    eable.Free();

                    if (hasSpawner)
                    {
                        break;
                    }
                }

                if (hasSpawner)
                {
                    continue;
                }

                int xAvg = xTotal / si.m_Floor.Count;
                int yAvg = yTotal / si.m_Floor.Count;

                ArrayList names = new ArrayList();
                ShopFlags flags = si.m_Flags;

                if ((flags & ShopFlags.Armor) != 0)
                {
                    names.Add("armorer");
                }

                if ((flags & ShopFlags.MetalWeapon) != 0)
                {
                    names.Add("weaponsmith");
                }

                if ((flags & ShopFlags.ArcheryWeapon) != 0)
                {
                    names.Add("bowyer");
                }

                if ((flags & ShopFlags.Scroll) != 0)
                {
                    names.Add("mage");
                }

                if ((flags & ShopFlags.Spellbook) != 0)
                {
                    names.Add("mage");
                }

                if ((flags & ShopFlags.Bread) != 0)
                {
                    names.Add("baker");
                }

                if ((flags & ShopFlags.Jewel) != 0)
                {
                    names.Add("jeweler");
                }

                if ((flags & ShopFlags.Potion) != 0)
                {
                    names.Add("herbalist");
                    names.Add("alchemist");
                    names.Add("mage");
                }

                if ((flags & ShopFlags.Reagent) != 0)
                {
                    names.Add("mage");
                    names.Add("herbalist");
                }

                if ((flags & ShopFlags.Clothes) != 0)
                {
                    names.Add("tailor");
                    names.Add("weaver");
                }

                for (int j = 0; j < names.Count; ++j)
                {
                    Point2D cp   = Point2D.Zero;
                    int     dist = 100000;
                    int     tz;

                    for (int k = 0; k < si.m_Floor.Count; ++k)
                    {
                        Point2D fp = (Point2D)si.m_Floor[k];

                        int rx = fp.X - xAvg;
                        int ry = fp.Y - yAvg;
                        int fd = (int)Math.Sqrt(rx * rx + ry * ry);

                        if (fd > 0 && fd < 5)
                        {
                            fd -= Utility.Random(10);
                        }

                        if (fd < dist && GetFloorZ(map, fp.X, fp.Y, out tz))
                        {
                            dist = fd;
                            cp   = fp;
                        }
                    }

                    if (cp == Point2D.Zero)
                    {
                        continue;
                    }

                    int z;

                    if (!GetFloorZ(map, cp.X, cp.Y, out z))
                    {
                        continue;
                    }

                    new Spawner(1, 1, 1, 0, 4, (string)names[j]).MoveToWorld(new Point3D(cp.X, cp.Y, z), map);
                }
            }

            World.Broadcast(0x35, true, "Generation complete. {0} spawners generated.", m_ShopList.Count);
        }
コード例 #11
0
ファイル: Campfire.cs プロジェクト: phpjunkie420/RunUO
        private void OnTick()
        {
            DateTime now = DateTime.Now;
            TimeSpan age = now - this.Created;

            if (age >= TimeSpan.FromSeconds(100.0))
            {
                this.Delete();
            }
            else if (age >= TimeSpan.FromSeconds(90.0))
            {
                this.Status = CampfireStatus.Off;
            }
            else if (age >= TimeSpan.FromSeconds(60.0))
            {
                this.Status = CampfireStatus.Extinguishing;
            }

            if (this.Status == CampfireStatus.Off || this.Deleted)
            {
                return;
            }

            foreach (CampfireEntry entry in new ArrayList(m_Entries))
            {
                if (!entry.Valid || entry.Player.NetState == null)
                {
                    RemoveEntry(entry);
                }
                else if (!entry.Safe && now - entry.Start >= TimeSpan.FromSeconds(30.0))
                {
                    entry.Safe = true;
                    entry.Player.SendAsciiMessage("The camp is now secure."); // The camp is now secure.
                }
                else
                {
                }
            }
            int Count = 0;
            IPooledEnumerable eable = this.GetItemsInRange(1);

            foreach (Object o in eable)
            {
                if (o is Campfire)
                {
                    Count++;
                }
            }
            eable.Free();

            eable = this.GetClientsInRange(SecureRange);

            foreach (NetState state in eable)
            {
                PlayerMobile pm = state.Mobile as PlayerMobile;

                if (pm != null && GetEntry(pm) == null)
                {
                    CampfireEntry entry = new CampfireEntry(pm, this);

                    m_Table[pm] = entry;
                    m_Entries.Add(entry);

                    pm.SendAsciiMessage("You feel it would take a few moments to secure your camp.");                       // You feel it would take a few moments to secure your camp.
                }

                if (pm != null && GetEntry(pm) != null && !GetEntry(pm).Safe)
                {
                    if (Utility.Random(1, Count) != Count)
                    {
                        eable.Free();
                        return;
                    }

                    if (pm.InRange(this, 1) && m_Starter != null && pm == m_Starter)
                    {
                        pm.CheckSkill(SkillName.Camping, 0.5);
                    }
                }
            }

            eable.Free();
        }
コード例 #12
0
        public void SpawnTentacle()
        {
            if (this.Combatant == null)
            {
                m_NextSpawn = DateTime.UtcNow + SpawnRate;
                return;
            }

            Map map = this.Map;

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

            IPooledEnumerable eable = this.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 != this.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      = this.Team;
                        if (spawn != this)
                        {
                            tent.Combatant = spawn;
                        }
                        break;
                    }
                }
            }

            m_NextSpawn = DateTime.UtcNow + SpawnRate;
        }
コード例 #13
0
        public void SetTimedEgg(Point3D location, Map map, EggType eggType)
        {
            int eggHue = Hue = Utility.RandomMinMax(2, 362);

            DecoyEasterEgg decoyEasterEgg = new DecoyEasterEgg();

            decoyEasterEgg.Hue = eggHue;
            decoyEasterEgg.MoveToWorld(location, map);

            int delayTime = Utility.RandomMinMax(1, 10);

            Effects.SendLocationParticles(EffectItem.Create(location, map, TimeSpan.FromSeconds(0.25)), 0x9B5, 10, delayTime * 25, eggHue, 0, 5029, 0);

            Timer.DelayCall(TimeSpan.FromSeconds(delayTime), delegate
            {
                if (decoyEasterEgg != null)
                {
                    if (!decoyEasterEgg.Deleted)
                    {
                        if (decoyEasterEgg.ParentEntity is PlayerMobile)
                        {
                            PlayerMobile pm_Owner = decoyEasterEgg.ParentEntity as PlayerMobile;

                            pm_Owner.SendMessage("The eggs you gathered appear to be some sort of decoy, and they crumble in your backpack...");
                            pm_Owner.SendSound(0x134);
                        }

                        decoyEasterEgg.Delete();
                    }
                }

                int radius = 2;

                int effectSound = 0;

                switch (eggType)
                {
                case EggType.Explosive: effectSound = 0x359; break;

                case EggType.Entangle: effectSound = 0x211; break;

                case EggType.Poison: effectSound = 0x22F; break;

                case EggType.Ice: effectSound = 0x64F; break;

                case EggType.Banish: effectSound = 0x655; break;

                case EggType.Gust: effectSound = 0x64C; break;

                case EggType.Bloody: effectSound = 0x62B; break;
                }

                Effects.PlaySound(location, map, effectSound);

                Dictionary <Point3D, double> m_ExplosionLocations = new Dictionary <Point3D, double>();

                m_ExplosionLocations.Add(location, 0);

                for (int a = 1; a < radius + 1; a++)
                {
                    m_ExplosionLocations.Add(new Point3D(location.X - a, location.Y - a, location.Z), a);
                    m_ExplosionLocations.Add(new Point3D(location.X, location.Y - a, location.Z), a);
                    m_ExplosionLocations.Add(new Point3D(location.X + a, location.Y - a, location.Z), a);
                    m_ExplosionLocations.Add(new Point3D(location.X + a, location.Y, location.Z), a);
                    m_ExplosionLocations.Add(new Point3D(location.X + a, location.Y + a, location.Z), a);
                    m_ExplosionLocations.Add(new Point3D(location.X, location.Y + a, location.Z), a);
                    m_ExplosionLocations.Add(new Point3D(location.X - a, location.Y + a, location.Z), a);
                    m_ExplosionLocations.Add(new Point3D(location.X - a, location.Y, location.Z), a);
                }

                foreach (KeyValuePair <Point3D, double> pair in m_ExplosionLocations)
                {
                    Timer.DelayCall(TimeSpan.FromSeconds(pair.Value * .25), delegate
                    {
                        switch (eggType)
                        {
                        case EggType.Explosive:
                            Effects.SendLocationParticles(EffectItem.Create(pair.Key, map, TimeSpan.FromSeconds(0.5)), 0x36BD, 20, 10, 5044);
                            break;

                        case EggType.Entangle:
                            radius = 3;
                            Effects.SendLocationParticles(EffectItem.Create(pair.Key, map, TimeSpan.FromSeconds(.5)), 0x3973, 10, 50, 5029);
                            break;

                        case EggType.Poison:
                            Effects.SendLocationParticles(EffectItem.Create(pair.Key, map, TimeSpan.FromSeconds(0.5)), 0x372A, 10, 20, 59, 0, 5029, 0);
                            break;

                        case EggType.Ice:
                            radius = 3;
                            Effects.SendLocationParticles(EffectItem.Create(pair.Key, map, TimeSpan.FromSeconds(0.25)), 0x3779, 10, 20, 1153, 0, 5029, 0);
                            break;

                        case EggType.Banish:
                            radius = 3;
                            Effects.SendLocationParticles(EffectItem.Create(pair.Key, map, TimeSpan.FromSeconds(.25)), 0x3763, 10, 20, 2199, 0, 5029, 0);
                            break;

                        case EggType.Gust:
                            radius = 4;
                            Effects.SendLocationParticles(EffectItem.Create(pair.Key, map, TimeSpan.FromSeconds(.25)), 0x1FB2, 10, 20, 0, 0, 5029, 0);
                            break;

                        case EggType.Bloody:
                            Effects.SendLocationParticles(EffectItem.Create(pair.Key, map, TimeSpan.FromSeconds(.25)), Utility.RandomList(0x1645, 0x122A, 0x122B, 0x122C, 0x122D, 0x122E, 0x122F), 10, 20, 0, 0, 5029, 0);
                            break;
                        }
                    });
                }

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

                IPooledEnumerable eable = map.GetMobilesInRange(location, radius);

                foreach (Mobile mobile in eable)
                {
                    if (mobile is EasterBunny)
                    {
                        continue;
                    }

                    if (!mobile.CanBeDamaged())
                    {
                        continue;
                    }

                    m_TargetsHit.Add(mobile);
                }

                eable.Free();

                int targets = m_TargetsHit.Count;

                for (int a = 0; a < targets; a++)
                {
                    double damage = 0;

                    Mobile mobile = m_TargetsHit[a];

                    if (mobile == null)
                    {
                        continue;
                    }
                    if (!mobile.Alive || mobile.Deleted)
                    {
                        continue;
                    }

                    switch (eggType)
                    {
                    case EggType.Explosive:
                        damage = (double)(Utility.RandomMinMax(20, 40));

                        if (mobile is BaseCreature)
                        {
                            damage *= 1.5;
                        }

                        AOS.Damage(mobile, (int)damage, 0, 100, 0, 0, 0);
                        break;

                    case EggType.Entangle:
                        if (mobile != null)
                        {
                            SpecialAbilities.EntangleSpecialAbility(1.0, null, mobile, 1, 10, -1, true, "", "You are held in place!", "-1");
                        }
                        break;

                    case EggType.Poison:
                        Poison poison = Poison.GetPoison(Utility.RandomMinMax(2, 4));
                        mobile.ApplyPoison(mobile, poison);
                        break;

                    case EggType.Ice:
                        damage = (double)(Utility.RandomMinMax(10, 20));

                        if (mobile is BaseCreature)
                        {
                            damage *= 1.5;
                        }

                        SpecialAbilities.CrippleSpecialAbility(1.0, null, mobile, .5, 10, -1, true, "", "A blast of ice has slowed your actions!", "-1");

                        AOS.Damage(mobile, (int)damage, 0, 100, 0, 0, 0);
                        break;

                    case EggType.Gust:
                        SpecialAbilities.KnockbackSpecialAbility(1.0, Location, null, mobile, 40, 8, -1, "", "A gust of wind knocks you off your feet!");
                        break;

                    case EggType.Banish:
                        SpecialAbilities.HinderSpecialAbility(1.0, null, mobile, 1.0, 5, false, -1, false, "", "You cannot move or speak!", "-1");

                        mobile.Squelched = true;
                        mobile.Hidden    = true;

                        Timer.DelayCall(TimeSpan.FromSeconds(5), delegate
                        {
                            if (mobile == null)
                            {
                                return;
                            }

                            mobile.Squelched = false;
                            mobile.Hidden    = false;
                        });
                        break;

                    case EggType.Bloody:
                        SpecialAbilities.BleedSpecialAbility(1.0, null, mobile, 40, 8.0, 0x44D, true, "", "You begin to bleed!", "-1");
                        break;
                    }
                }
            });
        }
コード例 #14
0
ファイル: NobleSacrifice.cs プロジェクト: zmazza/ServUO
        public override void OnCast()
        {
            if (CheckSequence())
            {
                List <Mobile>     targets = new List <Mobile>();
                IPooledEnumerable eable   = Caster.GetMobilesInRange(6);

                foreach (Mobile m in eable)
                {
                    if (m is BaseCreature || (m.Player && (m.Criminal || m.Murderer)))
                    {
                        continue;
                    }

                    if (Caster != m && m.InLOS(Caster) && Caster.CanBeBeneficial(m, false, true) && (!(m is IRepairableMobile) || ((IRepairableMobile)m).RepairResource == typeof(Items.Bandage)))
                    {
                        targets.Add(m);
                    }
                }
                eable.Free();

                Caster.PlaySound(0x244);
                Caster.FixedParticles(0x3709, 1, 30, 9965, 5, 7, EffectLayer.Waist);
                Caster.FixedParticles(0x376A, 1, 30, 9502, 5, 3, EffectLayer.Waist);

                /* Attempts to Resurrect, Cure and Heal all targets in a radius around the caster.
                 * If any target is successfully assisted, the Paladin's current
                 * Hit Points, Mana and Stamina are set to 1.
                 * Amount of damage healed is affected by the Caster's Karma, from 8 to 24 hit points.
                 */

                bool sacrifice = false;

                // TODO: Is there really a resurrection chance?
                double resChance = 0.1 + (0.9 * ((double)Caster.Karma / 10000));

                for (int i = 0; i < targets.Count; ++i)
                {
                    Mobile m = targets[i];

                    if (!m.Alive)
                    {
                        if (m.Region != null && m.Region.IsPartOf("Khaldun"))
                        {
                            Caster.SendLocalizedMessage(1010395); // The veil of death in this area is too strong and resists thy efforts to restore life.
                        }
                        else if (resChance > Utility.RandomDouble())
                        {
                            m.FixedParticles(0x375A, 1, 15, 5005, 5, 3, EffectLayer.Head);
                            m.CloseGump(typeof(ResurrectGump));
                            m.SendGump(new ResurrectGump(m, Caster));
                            sacrifice = true;
                        }
                    }
                    else
                    {
                        bool sendEffect = false;

                        if (m.Poisoned && m.CurePoison(Caster))
                        {
                            Caster.DoBeneficial(m);

                            if (Caster != m)
                            {
                                Caster.SendLocalizedMessage(1010058); // You have cured the target of all poisons!
                            }
                            m.SendLocalizedMessage(1010059);          // You have been cured of all poisons.
                            sendEffect = true;
                            sacrifice  = true;
                        }

                        if (m.Hits < m.HitsMax)
                        {
                            int toHeal = ComputePowerValue(10) + Utility.RandomMinMax(0, 2);

                            // TODO: Should caps be applied?
                            if (toHeal < 8)
                            {
                                toHeal = 8;
                            }
                            else if (toHeal > 24)
                            {
                                toHeal = 24;
                            }

                            Caster.DoBeneficial(m);
                            m.Heal(toHeal, Caster);
                            sendEffect = true;
                        }

                        if (m.RemoveStatMod("[Magic] Str Offset"))
                        {
                            sendEffect = true;
                        }

                        if (m.RemoveStatMod("[Magic] Dex Offset"))
                        {
                            sendEffect = true;
                        }

                        if (m.RemoveStatMod("[Magic] Int Offset"))
                        {
                            sendEffect = true;
                        }

                        if (m.Paralyzed)
                        {
                            m.Paralyzed = false;
                            sendEffect  = true;
                        }

                        if (EvilOmenSpell.TryEndEffect(m))
                        {
                            sendEffect = true;
                        }

                        if (StrangleSpell.RemoveCurse(m))
                        {
                            sendEffect = true;
                        }

                        if (CorpseSkinSpell.RemoveCurse(m))
                        {
                            sendEffect = true;
                        }

                        // TODO: Should this remove blood oath? Pain spike?

                        if (sendEffect)
                        {
                            m.FixedParticles(0x375A, 1, 15, 5005, 5, 3, EffectLayer.Head);
                            sacrifice = true;
                        }
                    }
                }

                if (sacrifice)
                {
                    Caster.PlaySound(Caster.Body.IsFemale ? 0x150 : 0x423);
                    Caster.Hits = 1;
                    Caster.Stam = 1;
                    Caster.Mana = 1;
                }
            }

            FinishSequence();
        }
コード例 #15
0
        public void Explode(Mobile from, bool direct, Point3D loc, Map map)
        {
            if (Deleted)
            {
                return;
            }

            Delete();

            for (int i = 0; m_Users != null && i < m_Users.Count; ++i)
            {
                Mobile      m    = (Mobile)m_Users[i];
                ThrowTarget targ = m.Target as ThrowTarget;

                if (targ != null && targ.Potion == this)
                {
                    Target.Cancel(m);
                }
            }

            if (map == null)
            {
                return;
            }

            Effects.PlaySound(loc, map, 0x207);
            Effects.SendLocationEffect(loc, map, 0x36BD, 20);

            int alchemyBonus = 0;

            if (direct)
            {
                alchemyBonus = (int)(from.Skills.Alchemy.Value / (Core.AOS ? 5 : 10));
            }

            IPooledEnumerable eable     = LeveledExplosion ? map.GetObjectsInRange(loc, ExplosionRange) : map.GetMobilesInRange(loc, ExplosionRange);
            ArrayList         toExplode = new ArrayList();

            int toDamage = 0;

            foreach (object o in eable)
            {
                if (o is Mobile)
                {
                    toExplode.Add(o);
                    ++toDamage;
                }
                else if (o is BaseExplosionPotion && o != this)
                {
                    toExplode.Add(o);
                }
            }

            eable.Free();

            int min = Scale(from, MinDamage);
            int max = Scale(from, MaxDamage);

            for (int i = 0; i < toExplode.Count; ++i)
            {
                object o = toExplode[i];

                if (o is Mobile)
                {
                    Mobile m = (Mobile)o;

                    if (from == null || (SpellHelper.ValidIndirectTarget(from, m) && from.CanBeHarmful(m, false)))
                    {
                        if (from != null)
                        {
                            from.DoHarmful(m);
                        }

                        int damage = Utility.RandomMinMax(min, max);

                        damage += alchemyBonus;

                        if (!Core.AOS && damage > 40)
                        {
                            damage = 40;
                        }
                        else if (Core.AOS && toDamage > 2)
                        {
                            damage /= toDamage - 1;
                        }

                        AOS.Damage(m, from, damage, 0, 100, 0, 0, 0);
                    }
                }
                else if (o is BaseExplosionPotion)
                {
                    BaseExplosionPotion pot = (BaseExplosionPotion)o;

                    pot.Explode(from, false, pot.GetWorldLocation(), pot.Map);
                }
            }
        }
コード例 #16
0
ファイル: Yamandon.cs プロジェクト: Evad-lab/ServUOX
        private void DoCounter(Mobile attacker)
        {
            if (Map == null)
            {
                return;
            }

            if (attacker is BaseCreature && ((BaseCreature)attacker).BardProvoked)
            {
                return;
            }

            if (0.2 > Utility.RandomDouble())
            {
                /* Counterattack with Hit Poison Area
                 * 20-25 damage, unresistable
                 * Lethal poison, 100% of the time
                 * Particle effect: Type: "2" From: "0x4061A107" To: "0x0" ItemId: "0x36BD" ItemIdName: "explosion" FromLocation: "(296 615, 17)" ToLocation: "(296 615, 17)" Speed: "1" Duration: "10" FixedDirection: "True" Explode: "False" Hue: "0xA6" RenderMode: "0x0" Effect: "0x1F78" ExplodeEffect: "0x1" ExplodeSound: "0x0" Serial: "0x4061A107" Layer: "255" Unknown: "0x0"
                 * Doesn't work on provoked monsters
                 */
                Mobile target = null;

                if (attacker is BaseCreature)
                {
                    Mobile m = ((BaseCreature)attacker).GetMaster();

                    if (m != null)
                    {
                        target = m;
                    }
                }

                if (target == null || !target.InRange(this, 18))
                {
                    target = attacker;
                }

                Animate(10, 4, 1, true, false, 0);

                ArrayList         targets = new ArrayList();
                IPooledEnumerable eable   = target.GetMobilesInRange(8);

                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))
                    {
                        targets.Add(m);
                    }
                    else if (m.Player && m.Alive)
                    {
                        targets.Add(m);
                    }
                }
                eable.Free();

                for (int i = 0; i < targets.Count; ++i)
                {
                    Mobile m = (Mobile)targets[i];

                    DoHarmful(m);

                    AOS.Damage(m, this, Utility.RandomMinMax(20, 25), true, 0, 0, 0, 100, 0);

                    m.FixedParticles(0x36BD, 1, 10, 0x1F78, 0xA6, 0, (EffectLayer)255);
                    m.ApplyPoison(this, Poison.Lethal);
                }
            }
        }
コード例 #17
0
        public static void CheckAnvilAndForge(Mobile from, int range, out bool anvil, out bool forge)
        {
            anvil = false;
            forge = false;

            Map map = from.Map;

            if (map == null)
            {
                return;
            }

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

            foreach (Item item in eable)
            {
                Type type = item.GetType();

                bool isAnvil = (type.IsDefined(typeofAnvil, false) || item.ItemID == 4015 || item.ItemID == 4016 || item.ItemID == 0x2DD5 || item.ItemID == 0x2DD6);
                bool isForge = (type.IsDefined(typeofForge, false) || item.ItemID == 4017 || (item.ItemID >= 6522 && item.ItemID <= 6569) || item.ItemID == 0x2DD8);

                if (isAnvil || isForge)
                {
                    if ((from.Z + 16) < item.Z || (item.Z + 16) < from.Z || !from.InLOS(item))
                    {
                        continue;
                    }

                    anvil = anvil || isAnvil;
                    forge = forge || isForge;

                    if (anvil && forge)
                    {
                        break;
                    }
                }
            }

            eable.Free();

            for (int x = -range; (!anvil || !forge) && x <= range; ++x)
            {
                for (int y = -range; (!anvil || !forge) && y <= range; ++y)
                {
                    StaticTile[] tiles = map.Tiles.GetStaticTiles(from.X + x, from.Y + y, true);

                    for (int i = 0; (!anvil || !forge) && i < tiles.Length; ++i)
                    {
                        int id = tiles[i].ID & 0x3FFF;

                        bool isAnvil = (id == 4015 || id == 4016 || id == 0x2DD5 || id == 0x2DD6);
                        bool isForge = (id == 4017 || (id >= 6522 && id <= 6569) || id == 0x2DD8);

                        if (isAnvil || isForge)
                        {
                            if ((from.Z + 16) < tiles[i].Z || (tiles[i].Z + 16) < from.Z || !from.InLOS(new Point3D(from.X + x, from.Y + y, tiles[i].Z + (tiles[i].Height / 2) + 1)))
                            {
                                continue;
                            }

                            anvil = anvil || isAnvil;
                            forge = forge || isForge;
                        }
                    }
                }
            }
        }
コード例 #18
0
ファイル: Travesty.cs プロジェクト: sector1337/ServUO
        public void ChangeBody()
        {
            List <Mobile> list = new List <Mobile>();

            IPooledEnumerable eable = Map.GetMobilesInRange(Location, 5);

            foreach (Mobile m in eable)
            {
                if (m.Player && m.AccessLevel == AccessLevel.Player && m.Alive)
                {
                    list.Add(m);
                }
            }

            eable.Free();

            if (list.Count == 0 || IsBodyMod)
            {
                return;
            }

            Mobile attacker = list[Utility.Random(list.Count)];

            BodyMod          = attacker.Body;
            HueMod           = attacker.Hue;
            NameMod          = attacker.Name;
            Female           = attacker.Female;
            Title            = "(Travesty)";
            HairItemID       = attacker.HairItemID;
            HairHue          = attacker.HairHue;
            FacialHairItemID = attacker.FacialHairItemID;
            FacialHairHue    = attacker.FacialHairHue;

            foreach (Item item in attacker.Items)
            {
                if (item.Layer < Layer.Mount &&
                    item.Layer != Layer.Backpack &&
                    item.Layer != Layer.Mount &&
                    item.Layer != Layer.Bank &&
                    item.Layer != Layer.Hair &&
                    item.Layer != Layer.Face &&
                    item.Layer != Layer.FacialHair)
                {
                    if (FindItemOnLayer(item.Layer) == null)
                    {
                        if (item is BaseRanged)
                        {
                            Item i = FindItemOnLayer(Layer.TwoHanded);

                            if (i != null)
                            {
                                i.Delete();
                            }

                            i = FindItemOnLayer(Layer.OneHanded);

                            if (i != null)
                            {
                                i.Delete();
                            }

                            AddItem(Loot.Construct(item.GetType()));
                        }
                        else
                        {
                            AddItem(new ClonedItem(item));
                        }
                    }
                }
            }

            if (attacker.Skills[SkillName.Swords].Value >= 50.0 || attacker.Skills[SkillName.Fencing].Value >= 50.0 || attacker.Skills[SkillName.Macing].Value >= 50.0)
            {
                ChangeAIType(AIType.AI_Melee);
            }

            if (attacker.Skills[SkillName.Archery].Value >= 50.0)
            {
                ChangeAIType(AIType.AI_Archer);
            }

            if (attacker.Skills[SkillName.Spellweaving].Value >= 50.0)
            {
                ChangeAIType(AIType.AI_Spellweaving);
            }

            if (attacker.Skills[SkillName.Mysticism].Value >= 50.0)
            {
                ChangeAIType(AIType.AI_Mystic);
            }

            if (attacker.Skills[SkillName.Magery].Value >= 50.0)
            {
                ChangeAIType(AIType.AI_Mage);
            }

            if (attacker.Skills[SkillName.Necromancy].Value >= 50.0)
            {
                ChangeAIType(AIType.AI_Necro);
            }

            if (attacker.Skills[SkillName.Ninjitsu].Value >= 50.0)
            {
                ChangeAIType(AIType.AI_Ninja);
            }

            if (attacker.Skills[SkillName.Bushido].Value >= 50.0)
            {
                ChangeAIType(AIType.AI_Samurai);
            }

            if (attacker.Skills[SkillName.Necromancy].Value >= 50.0 && attacker.Skills[SkillName.Magery].Value >= 50.0)
            {
                ChangeAIType(AIType.AI_NecroMage);
            }

            PlaySound(0x511);
            FixedParticles(0x376A, 1, 14, 5045, EffectLayer.Waist);

            m_NextBodyChange = DateTime.UtcNow + TimeSpan.FromSeconds(10.0);

            if (attacker.Skills[SkillName.Healing].Base > 20)
            {
                SetSpecialAbility(SpecialAbility.Heal);
            }

            if (attacker.Skills[SkillName.Discordance].Base > 50)
            {
                _CanDiscord = true;
            }

            if (attacker.Skills[SkillName.Peacemaking].Base > 50)
            {
                _CanPeace = true;
            }

            if (attacker.Skills[SkillName.Provocation].Base > 50)
            {
                _CanProvoke = true;
            }

            if (m_Timer != null)
            {
                m_Timer.Stop();
            }

            m_Timer = Timer.DelayCall(TimeSpan.FromMinutes(1.0), new TimerCallback(RestoreBody));
        }
コード例 #19
0
        public bool CanFit(Point3D p, Map map, int itemId, Direction dir, bool altitudeChange)
        {
            if (map == null || map == Map.Internal || Deleted)
            {
                return(false);
            }

            if ((p.Z + Mobile.Height) >= Map.TopZ)
            {
                return(false);
            }

            MultiComponentList mcl = MultiData.GetComponents(itemId);

            Shadow.Visible = true;

            for (int x = 0; x < mcl.Width; x++)
            {
                for (int y = 0; y < mcl.Height; y++)
                {
                    int tx = (p.X + mcl.Min.X + x);
                    int ty = (p.Y + mcl.Min.Y + y);

                    LandTile     landTile = map.Tiles.GetLandTile(tx, ty);
                    StaticTile[] statics  = map.Tiles.GetStaticTiles(tx, ty);

                    if ((landTile.Z + 2) == p.Z && (!altitudeChange || (altitudeChange && dir == Direction.Down)))
                    {
                        Shadow.Visible = false;
                    }

                    if (landTile.Z == p.Z && (!altitudeChange || (altitudeChange && dir == Direction.Down)))
                    {
                        return(false);
                    }

                    for (int i = 0; i < statics.Length; i++)
                    {
                        StaticTile t = statics[i];

                        if (t.Z > p.Z && (p.Z + Mobile.Height) > t.Z)  //if it's above, and our top would hit its bottom
                        {
                            return(false);
                        }
                        else if (t.Z < p.Z && (t.Z + t.Height) > p.Z)  //if it's below, and its top would hit our bottom
                        {
                            return(false);
                        }
                    }

                    object obj = map.GetTopSurface(p);

                    if (obj is LandTile)
                    {
                        LandTile t = (LandTile)obj;

                        if ((t.Z + t.Height) > p.Z)
                        {
                            return(false);
                        }
                    }
                    else if (obj is StaticTile)
                    {
                        StaticTile t = (StaticTile)obj;

                        if ((t.Z + t.Height) > p.Z)
                        {
                            return(false);
                        }
                    }
                    else if (obj is Item)
                    {
                        Item i = obj as Item;

                        if (i.GetWorldTop().Z > p.Z)
                        {
                            return(false);
                        }
                    }

                    if (mcl.Tiles[x][y].Length == 0 || Contains(tx, ty))
                    {
                        continue;
                    }

                    if (!map.CanFit(tx, ty, Z, 12, false, true, false))
                    {
                        return(false);
                    }
                }
            }

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

            foreach (Item i in eable)
            {
                if (i.ItemID >= 0x4000 || i.Z < p.Z || !i.Visible)
                {
                    continue;
                }

                int x = (i.X - p.X + mcl.Min.X);
                int y = (i.Y - p.Y + mcl.Min.Y);

                if (x >= 0 && x < mcl.Width && y >= 0 && y < mcl.Height && mcl.Tiles[x][y].Length == 0)
                {
                    continue;
                }
                else if (Contains(i))
                {
                    continue;
                }

                eable.Free();
                return(false);
            }

            eable.Free();

            return(true);
        }
コード例 #20
0
ファイル: Peacemaking.cs プロジェクト: Tauriella/ServUO-1
            protected override void OnTarget(Mobile from, object targeted)
            {
                from.RevealingAction();

                if (!(targeted is Mobile))
                {
                    from.SendLocalizedMessage(1049528);                     // You cannot calm that!
                }
                else if (!m_Instrument.IsChildOf(from.Backpack))
                {
                    from.SendLocalizedMessage(1062488);                     // The instrument you are trying to play is no longer in your backpack!
                }
                else
                {
                    m_SetSkillTime = false;

                    int masteryBonus = 0;

                    if (from is PlayerMobile)
                    {
                        masteryBonus = Spells.SkillMasteries.BardSpell.GetMasteryBonus((PlayerMobile)from, SkillName.Peacemaking);
                    }

                    if (targeted == from)
                    {
                        // Standard mode : reset combatants for everyone in the area
                        if (from.Player && !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 + (10000 - ((masteryBonus / 5) * 1000));
                        }
                        else if (!from.CheckSkill(SkillName.Peacemaking, 0.0, 120.0))
                        {
                            from.SendLocalizedMessage(500613);                             // You attempt to calm everyone, but fail.
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);

                            from.NextSkillTime = Core.TickCount + (10000 - ((masteryBonus / 5) * 1000));
                        }
                        else
                        {
                            from.NextSkillTime = Core.TickCount + 5000;
                            m_Instrument.PlayInstrumentWell(from);
                            m_Instrument.ConsumeUse(from);

                            Map map = from.Map;

                            if (map != null)
                            {
                                int range = BaseInstrument.GetBardRange(from, SkillName.Peacemaking);

                                bool calmed             = false;
                                IPooledEnumerable eable = from.GetMobilesInRange(range);

                                foreach (Mobile m in eable)
                                {
                                    if ((m is BaseCreature && ((BaseCreature)m).Uncalmable) ||
                                        (m is BaseCreature && ((BaseCreature)m).AreaPeaceImmune) || m == from || !from.CanBeHarmful(m, false))
                                    {
                                        continue;
                                    }

                                    calmed = true;

                                    m.SendLocalizedMessage(500616);                                     // You hear lovely music, and forget to continue battling!
                                    m.Combatant = null;
                                    m.Warmode   = false;

                                    if (m is BaseCreature && !((BaseCreature)m).BardPacified)
                                    {
                                        ((BaseCreature)m).Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(1.0));
                                    }
                                }
                                eable.Free();

                                if (!calmed)
                                {
                                    from.SendLocalizedMessage(1049648);                                     // You play hypnotic music, but there is nothing in range for you to calm.
                                }
                                else
                                {
                                    from.SendLocalizedMessage(500615);                                     // You play your hypnotic music, stopping the battle.
                                }
                            }
                        }
                    }
                    else
                    {
                        // Target mode : pacify a single target for a longer duration
                        Mobile targ = (Mobile)targeted;

                        if (!from.CanBeHarmful(targ, false))
                        {
                            from.SendLocalizedMessage(1049528);
                            m_SetSkillTime = true;
                        }
                        else if (targ is BaseCreature && ((BaseCreature)targ).Uncalmable)
                        {
                            from.SendLocalizedMessage(1049526);                             // You have no chance of calming that creature.
                            m_SetSkillTime = true;
                        }
                        else if (targ is BaseCreature && ((BaseCreature)targ).BardPacified)
                        {
                            from.SendLocalizedMessage(1049527);                             // That creature is already being calmed.
                            m_SetSkillTime = true;
                        }
                        else if (from.Player && !BaseInstrument.CheckMusicianship(from))
                        {
                            from.SendLocalizedMessage(500612);                             // You play poorly, and there is no effect.
                            from.NextSkillTime = Core.TickCount + 5000;
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);
                        }
                        else
                        {
                            double diff  = m_Instrument.GetDifficultyFor(targ) - 10.0;
                            double music = from.Skills[SkillName.Musicianship].Value;

                            if (music > 100.0)
                            {
                                diff -= (music - 100.0) * 0.5;
                            }

                            if (masteryBonus > 0)
                            {
                                diff -= (diff * ((double)masteryBonus / 100));
                            }

                            if (!from.CheckTargetSkill(SkillName.Peacemaking, targ, diff - 25.0, diff + 25.0))
                            {
                                from.SendLocalizedMessage(1049531);                                 // You attempt to calm your target, but fail.
                                m_Instrument.PlayInstrumentBadly(from);
                                m_Instrument.ConsumeUse(from);

                                from.NextSkillTime = Core.TickCount + (10000 - ((masteryBonus / 5) * 1000));
                            }
                            else
                            {
                                m_Instrument.PlayInstrumentWell(from);
                                m_Instrument.ConsumeUse(from);

                                from.NextSkillTime = Core.TickCount + (5000 - ((masteryBonus / 5) * 1000));

                                if (targ is BaseCreature)
                                {
                                    BaseCreature bc = (BaseCreature)targ;

                                    from.SendLocalizedMessage(1049532);                                     // You play hypnotic music, calming your target.

                                    targ.Combatant = null;
                                    targ.Warmode   = false;

                                    double seconds = 100 - (diff / 1.5);

                                    if (seconds > 120)
                                    {
                                        seconds = 120;
                                    }
                                    else if (seconds < 10)
                                    {
                                        seconds = 10;
                                    }

                                    bc.Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(seconds));

                                    #region Bard Mastery Quest
                                    if (from is PlayerMobile)
                                    {
                                        BaseQuest quest = QuestHelper.GetQuest((PlayerMobile)from, typeof(TheBeaconOfHarmonyQuest));

                                        if (quest != null)
                                        {
                                            foreach (BaseObjective objective in quest.Objectives)
                                            {
                                                objective.Update(bc);
                                            }
                                        }
                                    }
                                    #endregion
                                }
                                else
                                {
                                    from.SendLocalizedMessage(1049532);                                    // You play hypnotic music, calming your target.

                                    targ.SendLocalizedMessage(500616);                                     // You hear lovely music, and forget to continue battling!
                                    targ.Combatant = null;
                                    targ.Warmode   = false;
                                }
                            }
                        }
                    }
                }
            }
コード例 #21
0
        public Mobile FindDispelTarget(bool activeOnly)
        {
            if (m_Mobile.Deleted || m_Mobile.Int < 95 || CanDispel(m_Mobile) || m_Mobile.AutoDispel)
            {
                return(null);
            }

            if (activeOnly)
            {
                List <AggressorInfo> aggressed  = m_Mobile.Aggressed;
                List <AggressorInfo> aggressors = m_Mobile.Aggressors;

                Mobile active     = null;
                double activePrio = 0.0;

                Mobile comb = m_Mobile.Combatant as Mobile;

                if (comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && m_Mobile.InRange(comb, Core.ML ? 10 : 12) && CanDispel(comb))
                {
                    active     = comb;
                    activePrio = m_Mobile.GetDistanceToSqrt(comb);

                    if (activePrio <= 2)
                    {
                        return(active);
                    }
                }

                for (int i = 0; i < aggressed.Count; ++i)
                {
                    AggressorInfo info = aggressed[i];
                    Mobile        m    = info.Defender;

                    if (m != comb && m.Combatant == m_Mobile && m_Mobile.InRange(m, Core.ML ? 10 : 12) && CanDispel(m))
                    {
                        double prio = m_Mobile.GetDistanceToSqrt(m);

                        if (active == null || prio < activePrio)
                        {
                            active     = m;
                            activePrio = prio;

                            if (activePrio <= 2)
                            {
                                return(active);
                            }
                        }
                    }
                }

                for (int i = 0; i < aggressors.Count; ++i)
                {
                    AggressorInfo info = aggressors[i];
                    Mobile        m    = info.Attacker;

                    if (m != comb && m.Combatant == m_Mobile && m_Mobile.InRange(m, Core.ML ? 10 : 12) && CanDispel(m))
                    {
                        double prio = m_Mobile.GetDistanceToSqrt(m);

                        if (active == null || prio < activePrio)
                        {
                            active     = m;
                            activePrio = prio;

                            if (activePrio <= 2)
                            {
                                return(active);
                            }
                        }
                    }
                }

                return(active);
            }
            else
            {
                Map map = m_Mobile.Map;

                if (map != null)
                {
                    Mobile active = null, inactive = null;
                    double actPrio = 0.0, inactPrio = 0.0;

                    Mobile comb = m_Mobile.Combatant as Mobile;

                    if (comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && CanDispel(comb))
                    {
                        active  = inactive = comb;
                        actPrio = inactPrio = m_Mobile.GetDistanceToSqrt(comb);
                    }

                    IPooledEnumerable eable = m_Mobile.GetMobilesInRange(Core.ML ? 10 : 12);

                    foreach (Mobile m in eable)
                    {
                        if (m != m_Mobile && CanDispel(m))
                        {
                            double prio = m_Mobile.GetDistanceToSqrt(m);

                            if (!activeOnly && (inactive == null || prio < inactPrio))
                            {
                                inactive  = m;
                                inactPrio = prio;
                            }

                            if ((m_Mobile.Combatant == m || m.Combatant == m_Mobile) && (active == null || prio < actPrio))
                            {
                                active  = m;
                                actPrio = prio;
                            }
                        }
                    }

                    eable.Free();

                    return(active != null ? active : inactive);
                }
            }

            return(null);
        }
コード例 #22
0
        public void SpawnRatmen(Mobile target)
        {
            Map map = Map;

            if (map == null)
            {
                return;
            }

            int rats = 0;

            IPooledEnumerable eable = GetMobilesInRange(10);

            foreach (Mobile m in eable)
            {
                if (m is Ratman || m is RatmanArcher || m is RatmanMage)
                {
                    ++rats;
                }
            }

            eable.Free();

            if (rats < 16)
            {
                PlaySound(0x3D);

                int newRats = Utility.RandomMinMax(3, 6);

                for (int i = 0; i < newRats; ++i)
                {
                    BaseCreature rat;

                    switch (Utility.Random(5))
                    {
                    default:
                    case 0:
                    case 1:
                        rat = new Ratman();
                        break;

                    case 2:
                    case 3:
                        rat = new RatmanArcher();
                        break;

                    case 4:
                        rat = new RatmanMage();
                        break;
                    }

                    rat.Team = Team;

                    bool    validLocation = false;
                    Point3D loc           = Location;

                    for (int j = 0; !validLocation && j < 10; ++j)
                    {
                        int x = X + Utility.Random(3) - 1;
                        int y = Y + Utility.Random(3) - 1;
                        int z = map.GetAverageZ(x, y);

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

                    rat.IsChampionSpawn = true;
                    rat.MoveToWorld(loc, map);
                    rat.Combatant = target;
                }
            }
        }
コード例 #23
0
        public void Knockback()
        {
            if (!SpecialAbilities.Exists(Combatant))
            {
                return;
            }
            if (!SpecialAbilities.MonsterCanDamage(this, Combatant))
            {
                return;
            }

            Point3D targetLocation = Combatant.Location;
            Map     map            = Combatant.Map;

            double initialDelay = 1;
            double totalDelay   = 1 + initialDelay;

            Animate(14, 12, 1, true, false, 0);
            PlaySound(GetAngerSound());

            PublicOverheadMessage(MessageType.Regular, 0, false, "*lashes out violently*");

            SpecialAbilities.HinderSpecialAbility(1.0, null, this, 1.0, totalDelay, true, 0, false, "", "", "-1");

            m_AbilityInProgress  = true;
            m_NextAbilityAllowed = DateTime.UtcNow + GetNextAbilityDelay();

            m_NextKnockbackAllowed = DateTime.UtcNow + NextKnockbackDelay;

            Timer.DelayCall(TimeSpan.FromSeconds(totalDelay), delegate
            {
                if (!SpecialAbilities.Exists(this))
                {
                    return;
                }

                m_AbilityInProgress  = false;
                m_NextAbilityAllowed = DateTime.UtcNow + GetNextAbilityDelay();

                m_NextKnockbackAllowed = DateTime.UtcNow + NextKnockbackDelay;

                Combatant = null;
            });

            Timer.DelayCall(TimeSpan.FromSeconds(initialDelay), delegate
            {
                if (!SpecialAbilities.Exists(this))
                {
                    return;
                }

                double damage = (double)(Utility.RandomMinMax(DamageMin, DamageMax)) * 2;

                Queue m_Queue = new Queue();

                IPooledEnumerable nearbyMobiles = Map.GetMobilesInRange(targetLocation, 1);

                foreach (Mobile mobile in nearbyMobiles)
                {
                    if (mobile == this)
                    {
                        continue;
                    }
                    if (!SpecialAbilities.MonsterCanDamage(this, mobile))
                    {
                        continue;
                    }

                    m_Queue.Enqueue(mobile);
                }

                nearbyMobiles.Free();

                while (m_Queue.Count > 0)
                {
                    Mobile mobile = (Mobile)m_Queue.Dequeue();

                    if (mobile is BaseCreature)
                    {
                        damage *= 2;
                    }

                    SpecialAbilities.KnockbackSpecialAbility(1.0, Location, this, mobile, damage, 15, -1, "", "The beast flings you aside!");
                }
            });
        }
コード例 #24
0
            protected override void OnTarget(Mobile src, object targ)
            {
                bool foundAnyone = false;

                Point3D p;

                if (targ is Mobile)
                {
                    p = ((Mobile)targ).Location;
                }
                else if (targ is Item)
                {
                    p = ((Item)targ).Location;
                }
                else if (targ is IPoint3D)
                {
                    p = new Point3D((IPoint3D)targ);
                }
                else
                {
                    p = src.Location;
                }

                double srcSkill = src.Skills[SkillName.DetectHidden].Value;
                int    range    = (int)(srcSkill / 10.0);

                if (!src.CheckSkill(SkillName.DetectHidden, 0.0, 100.0))
                {
                    range /= 2;
                }

                BaseHouse house = BaseHouse.FindHouseAt(p, src.Map, 16);

                bool inHouse = (house != null && house.IsFriend(src));

                if (inHouse)
                {
                    range = 22;
                }

                if (range > 0)
                {
                    IPooledEnumerable inRange = src.Map.GetMobilesInRange(p, range);

                    foreach (Mobile trg in inRange)
                    {
                        if (trg.Hidden && src != trg)
                        {
                            double ss = srcSkill + Utility.Random(21) - 10;
                            double ts = trg.Skills[SkillName.Hiding].Value + Utility.Random(21) - 10;

                            if (src.AccessLevel >= trg.AccessLevel && (ss >= ts || (inHouse && house.IsInside(trg))))
                            {
                                if (trg is ShadowKnight && (trg.X != p.X || trg.Y != p.Y))
                                {
                                    continue;
                                }

                                trg.RevealingAction();
                                trg.SendLocalizedMessage(500814); // You have been revealed!
                                foundAnyone = true;
                            }
                        }
                    }

                    inRange.Free();

                    if (Faction.Find(src) != null)
                    {
                        IPooledEnumerable itemsInRange = src.Map.GetItemsInRange(p, range);

                        foreach (Item item in itemsInRange)
                        {
                            if (item is BaseFactionTrap)
                            {
                                BaseFactionTrap trap = (BaseFactionTrap)item;

                                if (src.CheckTargetSkill(SkillName.DetectHidden, trap, 80.0, 100.0))
                                {
                                    src.SendLocalizedMessage(1042712, true, " " + (trap.Faction == null ? "" : trap.Faction.Definition.FriendlyName)); // You reveal a trap placed by a faction:

                                    trap.Visible = true;
                                    trap.BeginConceal();

                                    foundAnyone = true;
                                }
                            }
                        }

                        itemsInRange.Free();
                    }
                }

                if (!foundAnyone)
                {
                    src.SendLocalizedMessage(500817); // You can see nothing hidden there.
                }
            }
コード例 #25
0
        public void FlameMark()
        {
            if (!SpecialAbilities.Exists(this))
            {
                return;
            }

            IPooledEnumerable nearbyMobiles = Map.GetMobilesInRange(Location, FlameMarkRange);

            int mobileCount = 0;

            foreach (Mobile mobile in nearbyMobiles)
            {
                if (mobile == this)
                {
                    continue;
                }
                if (!SpecialAbilities.MonsterCanDamage(this, mobile))
                {
                    continue;
                }
                if (!Map.InLOS(Location, mobile.Location))
                {
                    continue;
                }
                if (mobile.Hidden)
                {
                    continue;
                }

                mobileCount++;
            }

            nearbyMobiles.Free();
            nearbyMobiles = Map.GetMobilesInRange(Location, FlameMarkRange);

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

            foreach (Mobile mobile in nearbyMobiles)
            {
                if (mobile == this)
                {
                    continue;
                }
                if (!SpecialAbilities.MonsterCanDamage(this, mobile))
                {
                    continue;
                }
                if (!Map.InLOS(Location, mobile.Location))
                {
                    continue;
                }
                if (mobile.Hidden)
                {
                    continue;
                }
                if (Combatant != null)
                {
                    if (mobileCount > 1 && mobile == Combatant)
                    {
                        continue;
                    }
                }

                m_NearbyMobiles.Add(mobile);
            }

            nearbyMobiles.Free();

            if (m_NearbyMobiles.Count == 0)
            {
                return;
            }

            Mobile mobileTarget = m_NearbyMobiles[Utility.RandomMinMax(0, m_NearbyMobiles.Count - 1)];

            Point3D targetLocation = mobileTarget.Location;
            Map     targetMap      = mobileTarget.Map;

            double directionDelay = .25;
            double initialDelay   = 2;
            double totalDelay     = 1 + directionDelay + initialDelay;

            int maxRadius = 7;
            int radius    = 3 + (int)(Math.Ceiling((double)maxRadius * m_SpawnPercent));

            m_AbilityInProgress  = true;
            m_NextAbilityAllowed = DateTime.UtcNow + GetNextAbilityDelay();

            m_NextFlameMarkAllowed = DateTime.UtcNow + NextFlameMarkDelay;

            Timer.DelayCall(TimeSpan.FromSeconds(totalDelay), delegate
            {
                if (!SpecialAbilities.Exists(this))
                {
                    return;
                }

                m_AbilityInProgress  = false;
                m_NextAbilityAllowed = DateTime.UtcNow + GetNextAbilityDelay();

                m_NextFlameMarkAllowed = DateTime.UtcNow + NextFlameMarkDelay;
            });

            SpecialAbilities.HinderSpecialAbility(1.0, null, this, 1.0, totalDelay, true, 0, false, "", "", "-1");

            Direction = Utility.GetDirection(Location, targetLocation);

            Timer.DelayCall(TimeSpan.FromSeconds(directionDelay), delegate
            {
                if (!SpecialAbilities.Exists(this))
                {
                    return;
                }
                if (m_HealthIntervalAbilityInProgress)
                {
                    return;
                }

                Animate(29, 22, 1, true, false, 0);
                PlaySound(GetAngerSound());

                PublicOverheadMessage(MessageType.Regular, 0, false, "*points a mighty claw*");

                TimedStatic flamemark = new TimedStatic(6571, initialDelay);
                flamemark.Hue         = 2591;
                flamemark.Name        = "flamemark";
                flamemark.MoveToWorld(targetLocation, targetMap);

                Timer.DelayCall(TimeSpan.FromSeconds(initialDelay), delegate
                {
                    if (!SpecialAbilities.Exists(this))
                    {
                        return;
                    }

                    int damage = DamageMin;

                    int minRange = radius * -1;
                    int maxRange = radius;

                    int effectHue = 0;                                   //2590;

                    Effects.PlaySound(targetLocation, targetMap, 0x306); //0x1F3 //0x306 //0x309

                    for (int a = minRange; a < maxRange + 1; a++)
                    {
                        for (int b = minRange; b < maxRange + 1; b++)
                        {
                            Point3D newPoint = new Point3D(targetLocation.X + a, targetLocation.Y + b, targetLocation.Z);
                            SpellHelper.AdjustField(ref newPoint, targetMap, 12, false);

                            int distance = Utility.GetDistance(targetLocation, newPoint);

                            double effectChance = 1.0 - ((double)distance * .05);

                            if (Utility.RandomDouble() > effectChance)
                            {
                                continue;
                            }

                            Timer.DelayCall(TimeSpan.FromSeconds(distance * .10), delegate
                            {
                                if (!SpecialAbilities.Exists(this))
                                {
                                    return;
                                }

                                if (Utility.RandomDouble() <= .15)
                                {
                                    SingleFireField singleFireField = new SingleFireField(this, 0, 2, 30, 3, 5, false, false, true, -1, true);
                                    singleFireField.MoveToWorld(newPoint, targetMap);
                                }

                                Effects.PlaySound(newPoint, targetMap, Utility.RandomList(0x4F1, 0x5D8, 0x5DA, 0x580));
                                Effects.SendLocationParticles(EffectItem.Create(newPoint, targetMap, TimeSpan.FromSeconds(0.25)), 0x3709, 10, 30, effectHue, 0, 5029, 0);

                                IPooledEnumerable mobilesOnTile = targetMap.GetMobilesInRange(newPoint, 0);

                                Queue m_Queue = new Queue();

                                foreach (Mobile mobile in mobilesOnTile)
                                {
                                    if (mobile == this)
                                    {
                                        continue;
                                    }
                                    if (!SpecialAbilities.MonsterCanDamage(this, mobile))
                                    {
                                        continue;
                                    }

                                    m_Queue.Enqueue(mobile);
                                }

                                mobilesOnTile.Free();

                                while (m_Queue.Count > 0)
                                {
                                    Mobile mobile = (Mobile)m_Queue.Dequeue();

                                    if (mobile is BaseCreature)
                                    {
                                        damage *= 3;
                                    }

                                    new Blood().MoveToWorld(mobile.Location, mobile.Map);
                                    AOS.Damage(mobile, this, damage, 100, 0, 0, 0, 0);
                                }
                            });
                        }
                    }
                });
            });
        }
コード例 #26
0
ファイル: ShipTracking.cs プロジェクト: travismills82/TrueUO
        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);
            }
        }
コード例 #27
0
        public void Target(IPoint3D p)
        {
            if (!Caster.CanSee(p))
            {
                Caster.SendLocalizedMessage(500237);                   // Target can not be seen.
            }
            else if (SphereSpellTarget is BaseWand)
            {
                BaseWand bw = SphereSpellTarget as BaseWand;
                bw.RechargeWand(Caster, this);
            }
            else if (CheckSequence())
            {
                SpellHelper.GetSurfaceTop(ref p);

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

                Map    map          = Caster.Map;
                Mobile directTarget = p as Mobile;

                if (map != null)
                {
                    bool feluccaRules = (map.Rules == MapRules.FeluccaRules);

                    // You can target any living mobile directly, beneficial checks apply
                    if (directTarget != null && Caster.CanBeBeneficial(directTarget, false))
                    {
                        targets.Add(directTarget);
                    }

                    IPooledEnumerable eable = map.GetMobilesInRange(new Point3D(p), 2);

                    foreach (Mobile m in eable)
                    {
                        if (m == directTarget)
                        {
                            continue;
                        }

                        if (AreaCanTarget(m, feluccaRules))
                        {
                            targets.Add(m);
                        }
                    }

                    eable.Free();
                }

                Effects.PlaySound(p, Caster.Map, Sound);

                if (targets.Count > 0)
                {
                    int cured = 0;

                    for (int i = 0; i < targets.Count; ++i)
                    {
                        Mobile m = targets[i];

                        Caster.DoBeneficial(m);

                        Poison poison = m.Poison;

                        if (poison != null)
                        {
                            int chanceToCure = 10000 + (int)(Caster.Skills[SkillName.Magery].Value * 75) - ((poison.Level + 1) * 1750);
                            chanceToCure /= 100;

                            if (m.CurePoison(Caster))
                            {
                                ++cured;
                            }
                        }

                        //m.FixedParticles( 0x373A, 10, 15, 5012, EffectLayer.Waist );
                        m.PlaySound(Sound);
                    }

                    //if ( cured > 0 )
                    //	Caster.SendLocalizedMessage( 1010058 ); // You have cured the target of all poisons!
                }
            }

            FinishSequence();
        }
コード例 #28
0
        public void Target(IPoint3D p)
        {
            if (!Caster.CanSee(p))
            {
                Caster.SendLocalizedMessage(500237); // Target can not be seen.
            }
            else if (SpellHelper.CheckTown(p, Caster) && CheckSequence())
            {
                SpellHelper.Turn(Caster, p, 100);

                if (p is Item)
                {
                    p = ((Item)p).GetWorldLocation();
                }

                List <IDamageable> targets = new List <IDamageable>();

                Map map = Caster.Map;

                if (map != null)
                {
                    IPooledEnumerable eable = map.GetObjectsInRange(new Point3D(p), 2);

                    foreach (object o in eable)
                    {
                        IDamageable id = o as IDamageable;

                        if (id == null || (Core.AOS && id is Mobile && (Mobile)id == Caster))
                        {
                            continue;
                        }

                        if ((!(id is Mobile) || SpellHelper.ValidIndirectTarget(Caster, id as Mobile)) && Caster.CanBeHarmful(id, false))
                        {
                            if (Core.AOS && !Caster.InLOS(id))
                            {
                                continue;
                            }

                            targets.Add(id);
                        }
                    }

                    eable.Free();
                }

                double damage;

                if (targets.Count > 0)
                {
                    for (int i = 0; i < targets.Count; ++i)
                    {
                        IDamageable id = targets[i];
                        Mobile      m  = id as Mobile;

                        if (Core.AOS)
                        {
                            damage = GetNewAosDamage(51, 1, 5, id is PlayerMobile, id);
                        }
                        else
                        {
                            damage = Utility.Random(27, 22);
                        }

                        if (Core.AOS && targets.Count > 2)
                        {
                            damage = (damage * 2) / targets.Count;
                        }
                        else if (!Core.AOS)
                        {
                            damage /= targets.Count;
                        }

                        if (!Core.AOS && m != null && CheckResisted(m))
                        {
                            damage *= 0.5;

                            m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy.
                        }

                        Mobile source = Caster;

                        if (m != null)
                        {
                            SpellHelper.CheckReflect((int)Circle, ref source, ref m, SpellDamageType);
                            damage *= GetDamageScalar(m);
                        }

                        Caster.DoHarmful(m != null ? m : id);
                        SpellHelper.Damage(this, m != null ? m : id, damage, 0, 0, 0, 0, 100);

                        Effects.SendBoltEffect(id, true, 0, false);
                    }
                }
                else
                {
                    Caster.PlaySound(0x29);
                }

                targets.Clear();
                targets.TrimExcess();
            }

            FinishSequence();
        }
コード例 #29
0
        public static void Freeze(Mobile from, Map targetMap, Point3D start3d, Point3D end3d)
        {
            Hashtable mapTable = new Hashtable();

            if (start3d == NullP3D && end3d == NullP3D)
            {
                if (targetMap == null)
                {
                    CommandLogging.WriteLine(from, "{0} {1} invoking freeze for every item in every map", from.AccessLevel, CommandLogging.Format(from));
                }
                else
                {
                    CommandLogging.WriteLine(from, "{0} {1} invoking freeze for every item in {0}", from.AccessLevel, CommandLogging.Format(from), targetMap);
                }

                foreach (Item item in World.Items.Values)
                {
                    if (targetMap != null && item.Map != targetMap)
                    {
                        continue;
                    }

                    if (item.Parent != null)
                    {
                        continue;
                    }

                    if (item is Static || item is BaseFloor || item is BaseWall)
                    {
                        Map itemMap = item.Map;

                        if (itemMap == null || itemMap == Map.Internal)
                        {
                            continue;
                        }

                        Hashtable table = (Hashtable)mapTable[itemMap];

                        if (table == null)
                        {
                            mapTable[itemMap] = table = new Hashtable();
                        }

                        Point2D p = new Point2D(item.X >> 3, item.Y >> 3);

                        DeltaState state = (DeltaState)table[p];

                        if (state == null)
                        {
                            table[p] = state = new DeltaState(p);
                        }

                        state.m_List.Add(item);
                    }
                }
            }
            else if (targetMap != null)
            {
                Point2D start = targetMap.Bound(new Point2D(start3d)), end = targetMap.Bound(new Point2D(end3d));

                CommandLogging.WriteLine(from, "{0} {1} invoking freeze from {2} to {3} in {4}", from.AccessLevel, CommandLogging.Format(from), start, end, targetMap);

                IPooledEnumerable eable = targetMap.GetItemsInBounds(new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1));

                foreach (Item item in eable)
                {
                    if (item is Static || item is BaseFloor || item is BaseWall)
                    {
                        Map itemMap = item.Map;

                        if (itemMap == null || itemMap == Map.Internal)
                        {
                            continue;
                        }

                        Hashtable table = (Hashtable)mapTable[itemMap];

                        if (table == null)
                        {
                            mapTable[itemMap] = table = new Hashtable();
                        }

                        Point2D p = new Point2D(item.X >> 3, item.Y >> 3);

                        DeltaState state = (DeltaState)table[p];

                        if (state == null)
                        {
                            table[p] = state = new DeltaState(p);
                        }

                        state.m_List.Add(item);
                    }
                }

                eable.Free();
            }

            if (mapTable.Count == 0)
            {
                from.SendGump(new NoticeGump(1060637, 30720, "No freezable items were found.  Only the following item types are frozen:<br> - Static<br> - BaseFloor<br> - BaseWall", 0xFFC000, 320, 240, null, null));
                return;
            }

            bool badDataFile = false;

            int totalFrozen = 0;

            foreach (DictionaryEntry de in mapTable)
            {
                Map       map   = (Map)de.Key;
                Hashtable table = (Hashtable)de.Value;

                TileMatrix matrix = map.Tiles;

                using (FileStream idxStream = OpenWrite(matrix.IndexStream))
                {
                    using (FileStream mulStream = OpenWrite(matrix.DataStream))
                    {
                        if (idxStream == null || mulStream == null)
                        {
                            badDataFile = true;
                            continue;
                        }

                        BinaryReader idxReader = new BinaryReader(idxStream);

                        BinaryWriter idxWriter = new BinaryWriter(idxStream);
                        BinaryWriter mulWriter = new BinaryWriter(mulStream);

                        foreach (DeltaState state in table.Values)
                        {
                            int          oldTileCount;
                            StaticTile[] oldTiles = ReadStaticBlock(idxReader, mulStream, state.m_X, state.m_Y, matrix.BlockWidth, matrix.BlockHeight, out oldTileCount);

                            if (oldTileCount < 0)
                            {
                                continue;
                            }

                            int          newTileCount = 0;
                            StaticTile[] newTiles     = new StaticTile[state.m_List.Count];

                            for (int i = 0; i < state.m_List.Count; ++i)
                            {
                                Item item = state.m_List[i];

                                int xOffset = item.X - (state.m_X * 8);
                                int yOffset = item.Y - (state.m_Y * 8);

                                if (xOffset < 0 || xOffset >= 8 || yOffset < 0 || yOffset >= 8)
                                {
                                    continue;
                                }

                                StaticTile newTile = new StaticTile((ushort)item.ItemID, (byte)xOffset, (byte)yOffset, (sbyte)item.Z, (short)item.Hue);

                                newTiles[newTileCount++] = newTile;

                                item.Delete();

                                ++totalFrozen;
                            }

                            int mulPos = -1;
                            int length = -1;
                            int extra  = 0;

                            if ((oldTileCount + newTileCount) > 0)
                            {
                                mulWriter.Seek(0, SeekOrigin.End);

                                mulPos = (int)mulWriter.BaseStream.Position;
                                length = (oldTileCount + newTileCount) * 7;
                                extra  = 1;

                                for (int i = 0; i < oldTileCount; ++i)
                                {
                                    StaticTile toWrite = oldTiles[i];

                                    mulWriter.Write((ushort)toWrite.ID);
                                    mulWriter.Write((byte)toWrite.X);
                                    mulWriter.Write((byte)toWrite.Y);
                                    mulWriter.Write((sbyte)toWrite.Z);
                                    mulWriter.Write((short)toWrite.Hue);
                                }

                                for (int i = 0; i < newTileCount; ++i)
                                {
                                    StaticTile toWrite = newTiles[i];

                                    mulWriter.Write((ushort)toWrite.ID);
                                    mulWriter.Write((byte)toWrite.X);
                                    mulWriter.Write((byte)toWrite.Y);
                                    mulWriter.Write((sbyte)toWrite.Z);
                                    mulWriter.Write((short)toWrite.Hue);
                                }

                                mulWriter.Flush();
                            }

                            int idxPos = ((state.m_X * matrix.BlockHeight) + state.m_Y) * 12;

                            idxWriter.Seek(idxPos, SeekOrigin.Begin);
                            idxWriter.Write(mulPos);
                            idxWriter.Write(length);
                            idxWriter.Write(extra);

                            idxWriter.Flush();

                            matrix.SetStaticBlock(state.m_X, state.m_Y, null);
                        }
                    }
                }
            }

            if (totalFrozen == 0 && badDataFile)
            {
                from.SendGump(new NoticeGump(1060637, 30720, "Output data files could not be opened and the freeze operation has been aborted.<br><br>This probably means your server and client are using the same data files.  Instructions on how to resolve this can be found in the first warning window.", 0xFFC000, 320, 240, null, null));
            }
            else
            {
                from.SendGump(new NoticeGump(1060637, 30720, String.Format("Freeze operation completed successfully.<br><br>{0} item{1} frozen.<br><br>You must restart your client and update it's data files to see the changes.", totalFrozen, totalFrozen != 1 ? "s were" : " was"), 0xFFC000, 320, 240, null, null));
            }
        }
コード例 #30
0
        public void Target(IPoint3D p)
        {
            if (!Caster.CanSee(p))
            {
                Caster.SendLocalizedMessage(500237);                   // Target can not be seen.
            }
            else if (SpellHelper.CheckTown(p, Caster) && CheckSequence())
            {
                SpellHelper.Turn(Caster, p);

                if (p is Item)
                {
                    p = ((Item)p).GetWorldLocation();
                }

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

                Map map = Caster.Map;

                if (map != null)
                {
                    IPooledEnumerable eable = map.GetMobilesInRange(new Point3D(p), 2);

                    foreach (Mobile m in eable)
                    {
                        if (Caster != m && SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false))
                        {
                            targets.Add(m);
                        }
                    }

                    eable.Free();
                }

                double damage = Utility.Random(27, 22);

                if (targets.Count > 0)
                {
                    Effects.PlaySound(p, Caster.Map, 0x160);

                    damage /= targets.Count;

                    double toDeal;
                    for (int i = 0; i < targets.Count; ++i)
                    {
                        Mobile m = targets[i];

                        toDeal = damage;

                        if (CheckResisted(m))
                        {
                            damage *= 0.5;

                            m.SendLocalizedMessage(501783);                               // You feel yourself resisting magical energy.
                        }
                        toDeal *= GetDamageScalar(m);
                        Caster.DoHarmful(m);
                        SpellHelper.Damage(this, m, toDeal, 0, 100, 0, 0, 0);

                        Caster.MovingParticles(m, 0x36D4, 7, 0, false, true, 9501, 1, 0, 0x100);
                    }
                }
            }

            FinishSequence();
        }