예제 #1
0
        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();
        }
예제 #2
0
파일: CraftedTrap.cs 프로젝트: KairiL/runuo
        public override void OnTrigger(Mobile from)
        {
            int       sdiBonus = 0;
            int       damage   = 0;
            ArrayList targets  = new ArrayList();
            //uncomment this if you want staff to be immune to traps
            //if (from.AccessLevel > AccessLevel.Player)
            //    return;

            int ManaLoss = ScaleMana(ManaCost);

            if (TrapOwner == null)
            {
                this.Delete();
                return;
            }

            if (TrapOwner != null && TrapOwner.Player && TrapOwner.CanBeHarmful(from, false) &&
                from != TrapOwner && SpellHelper.ValidIndirectTarget(TrapOwner, (Mobile)from) &&
                (!(from is BaseCreature) || ((BaseCreature)from).ControlMaster != TrapOwner))
            {
                if (!(TrapOwner.InRange(Location, 25)) || TrapOwner.Map != Map || TrapOwner.Map == Map.Internal)
                {
                    this.UsesRemaining -= 1;
                    return;
                }
                if (TrapOwner.Mana >= ManaLoss)
                {
                    TrapOwner.Mana -= ManaLoss;
                }
                else
                {
                    ManaLoss      -= TrapOwner.Mana;
                    TrapOwner.Mana = 0;
                    TrapOwner.Damage(ManaLoss);
                }
            }
            else
            {
                return;
            }

            if (this.Visible == false)
            {
                this.Visible = true;
            }

            int MinDamage = 20 * (TrapPower / 100);
            int MaxDamage = 30 * (TrapPower / 100);


            if (MinDamage < 5)
            {
                MinDamage = 5;
            }

            if (MaxDamage < 10)
            {
                MaxDamage = 10;
            }
            if (from.Alive)
            {
                IPooledEnumerable eable = this.Map.GetMobilesInRange(new Point3D(from.Location), DamageRange);

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

                if ((from != TrapOwner && SpellHelper.ValidIndirectTarget(TrapOwner, (Mobile)from) && TrapOwner.CanBeHarmful(from, false)) && from.InLOS(this))  //yes, intentional double hit to triggerer
                {
                    targets.Add(from);
                }

                if (targets.Count > 0)
                {
                    for (int i = 0; i < targets.Count; ++i)
                    {
                        Mobile m = (Mobile)targets[i];
                        if (DamageScalar != 0)
                        {
                            sdiBonus  = AosAttributes.GetValue(TrapOwner, AosAttribute.SpellDamage);
                            sdiBonus += ArcaneEmpowermentSpell.GetSpellBonus(TrapOwner, (m.Player && TrapOwner.Player));

                            // PvP spell damage increase cap of 15% from an item’s magic property
                            if ((m.Player && TrapOwner.Player) && (sdiBonus > 15 + (int)(TrapOwner.Skills[SkillName.Inscribe].Value / 10)))
                            {
                                sdiBonus = 15 + (int)(TrapOwner.Skills[SkillName.Inscribe].Value / 10);
                            }
                            sdiBonus += (int)(TrapOwner.Skills[SkillName.Inscribe].Value / 10);

                            TrapOwner.DoHarmful(m);
                            MinDamage = MinDamage * (100 + sdiBonus) / 100;
                            MaxDamage = MaxDamage * (100 + sdiBonus) / 100;
                            switch (m_DamageType)
                            {
                            case "Physical":
                                damage = AOS.Damage(m, TrapOwner, (int)(DamageScalar * Utility.RandomMinMax(MinDamage, MaxDamage)), 100, 0, 0, 0, 0);
                                break;

                            case "Fire":
                                damage = AOS.Damage(m, TrapOwner, (int)(DamageScalar * Utility.RandomMinMax(MinDamage, MaxDamage)), 0, 100, 0, 0, 0);
                                break;

                            case "Cold":
                                damage = AOS.Damage(m, TrapOwner, (int)(DamageScalar * Utility.RandomMinMax(MinDamage, MaxDamage)), 0, 0, 100, 0, 0);
                                break;

                            case "Poison":
                                damage = AOS.Damage(m, TrapOwner, (int)(DamageScalar * Utility.RandomMinMax(MinDamage, MaxDamage)), 0, 0, 0, 100, 0);
                                break;

                            case "Energy":
                                damage = AOS.Damage(m, TrapOwner, (int)(DamageScalar * Utility.RandomMinMax(MinDamage, MaxDamage)), 0, 0, 0, 0, 100);
                                break;
                            }
                            SpellHelper.DoLeech(damage, TrapOwner, m);
                            if (PointDest != Point3D.Zero && TrapOwner.Player)
                            {
                                Teleport(m);
                            }
                        }
                        if (Poison != null)
                        {
                            m.ApplyPoison(m, m_Poison);
                            TrapOwner.DoHarmful(m);
                        }

                        if (ParalyzeTime > 0)
                        {
                            TrapOwner.DoHarmful(m);
                            if (m.Player)
                            {
                                m.Paralyze(TimeSpan.FromSeconds(ParalyzeTime - (m.Skills.MagicResist.Value / 12) / 4));
                            }
                            else
                            {
                                m.Paralyze(TimeSpan.FromSeconds(ParalyzeTime - (m.Skills.MagicResist.Value / 12)));
                            }
                        }
                    }

                    if (TrapOwner.Alive)
                    {
                        this.UsesRemaining -= 1;
                    }
                    else
                    {
                        UsesRemaining -= 10;
                    }

                    if (this.UsesRemaining <= 0)
                    {
                        this.Delete();
                    }
                }
            }
        }
예제 #3
0
        public void Target(IPoint3D p, Item item)
        {
            if (!Caster.CanSee(p))
            {
                Caster.SendLocalizedMessage(500237); // Target can not be seen.
            }
            else if (SpellHelper.CheckTown(p, Caster) && (item != null || CheckSequence()))
            {
                if (item != null)
                {
                    if (item is MaskOfKhalAnkur)
                    {
                        ((MaskOfKhalAnkur)item).Charges--;
                    }

                    if (item is PendantOfKhalAnkur)
                    {
                        ((PendantOfKhalAnkur)item).Charges--;
                    }
                }

                SpellHelper.Turn(Caster, p);

                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)
                {
                    Effects.PlaySound(p, Caster.Map, 0x160);

                    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.
                        }

                        IDamageable source = Caster;
                        IDamageable target = id;

                        if (SpellHelper.CheckReflect((int)Circle, ref source, ref target, SpellDamageType))
                        {
                            Timer.DelayCall(TimeSpan.FromSeconds(.5), () =>
                            {
                                source.MovingParticles(target, 0x36D4, 7, 0, false, true, 9501, 1, 0, 0x100);
                            });
                        }

                        if (m != null)
                        {
                            damage *= GetDamageScalar(m);
                        }

                        Caster.DoHarmful(id);
                        SpellHelper.Damage(this, target, damage, 0, 100, 0, 0, 0);

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

                ColUtility.Free(targets);
            }

            FinishSequence();
        }
예제 #4
0
        public virtual bool CanMoveTo(Point3D p, Map map)
        {
            //don't allow the carpet to travel to places where you can't recall to
            if (!Server.Spells.SpellHelper.CheckTravel(map, p, Server.Spells.TravelCheckType.RecallTo))
            {
                return(false);
            }

            int zcheck = p.Z + _Extrema.Start.Z;

            for (int i = p.X + _Extrema.Start.X; i < p.X + _Extrema.End.X; i++)
            {
                for (int j = p.Y + _Extrema.Start.Y; j < p.Y + _Extrema.End.Y; j++)
                {
                    //first check the map and see if there is a problem there
                    if (map.GetAverageZ(i, j) >= zcheck)
                    {
                        return(false);
                    }

                    //check if the map tile is considered a "no fly tile"
                    int tileid = map.Tiles.GetLandTile(i, j).ID;

                    foreach (int nomovetile in NoMoveTiles)
                    {
                        if (nomovetile == tileid)
                        {
                            return(false);
                        }
                    }

                    //next check for multi's

                    //3rd parameter "true" checks multi's as well.
                    StaticTile[] tiles = map.Tiles.GetStaticTiles(i, j, true);



                    //check all static tiles
                    foreach (StaticTile tile in tiles)
                    {
                        if (tile.Z + tile.Height >= zcheck)
                        {
                            return(false);
                        }
                    }
                }
            }


            //finally, check for items and mobiles

            Rectangle2D destrect2d = new Rectangle2D(new Point2D(p.X + _Extrema.Start.X, p.Y + _Extrema.Start.Y), new Point2D(p.X + _Extrema.End.X, p.Y + _Extrema.End.Y));

            IPooledEnumerable ie = map.GetMobilesInBounds(destrect2d);

            foreach (Mobile m in ie)
            {
                //ignore mobiles already inside the addon
                if (Contains(m))
                {
                    continue;
                }
                //mobiles have a height of about 14?
                if (m.Z + 14 >= zcheck && m.Z < p.Z + _Extrema.End.Z)
                {
                    return(false);
                }
            }
            ie.Free();

            ie = map.GetItemsInBounds(destrect2d);

            foreach (Item item in ie)
            {
                //ignore items already in the addon, or that are part of the addon
                if (Contains(item) || item is MovableAddonComponent && _Components.IndexOf((MovableAddonComponent)item) != -1)
                {
                    continue;
                }

                ItemData itemData = TileData.ItemTable[item.ItemID & 0x3FFF];
                TileFlag flags    = itemData.Flags;

                //if the item is defined as impassible
                if ((flags & TileFlag.Impassable) != 0)
                {
                    int height = itemData.CalcHeight + 1;

                    //this forces it so you can't overlap movable addon components!
                    if (item is MovableAddonComponent)
                    {
                        height = 20;
                    }

                    if (item.Z + height >= zcheck && item.Z < p.Z + _Extrema.End.Z)
                    {
                        return(false);
                    }
                }
            }
            ie.Free();

            return(true);
        }
예제 #5
0
파일: Shadowlord.cs 프로젝트: pallop/Servuo
        public override void DrainLife()
        {
            if (this.Map == null)
            {
                return;
            }

            ArrayList         list  = new ArrayList();
            int               count = 0;
            IPooledEnumerable eable = GetMobilesInRange(20);

            foreach (Mobile m in eable)
            {
                if (m == this || !this.CanBeHarmful(m))
                {
                    if (m is DarkWisp)
                    {
                        count++;
                    }
                    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();

            foreach (Mobile m in list)
            {
                this.DoHarmful(m);

                m.FixedParticles(0x374A, 10, 15, 5013, 0x496, 0, EffectLayer.Waist);
                m.PlaySound(0x231);

                m.SendMessage("You feel the life drain out of you!");

                int toDrain = count * 10;

                this.Hits += toDrain;
                (new DarkWisp()).MoveToWorld(new Point3D(this.Location), this.Map);
                int teleportchance = Hits / HitsMax;

                if (teleportchance < Utility.RandomDouble() && m.Alive)
                {
                    switch (Utility.Random(6))
                    {
                    case 0: m.MoveToWorld(new Point3D(6431, 1664, 0), this.Map); break;

                    case 1: m.MoveToWorld(new Point3D(6432, 1634, 0), this.Map); break;

                    case 2: m.MoveToWorld(new Point3D(6401, 1657, 0), this.Map); break;

                    case 3: m.MoveToWorld(new Point3D(6401, 1637, 0), this.Map); break;

                    default: m.MoveToWorld(new Point3D(this.Location), this.Map); break;
                    }
                }

                m.Damage(toDrain, this);
            }
        }
예제 #6
0
        public void Target(IPoint3D p)
        {
            if (!this.Caster.CanSee(p))
            {
                this.Caster.SendLocalizedMessage(500237); // Target can not be seen.
            }
            else if (this.CheckSequence())
            {
                SpellHelper.Turn(this.Caster, p);

                SpellHelper.GetSurfaceTop(ref p);

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

                Map map = this.Caster.Map;

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

                    foreach (Mobile m in eable)
                    {
                        if (m is BaseCreature && (m as BaseCreature).IsDispellable && this.Caster.CanBeHarmful(m, false))
                        {
                            targets.Add(m);
                        }
                    }

                    eable.Free();
                }

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

                    BaseCreature bc = m as BaseCreature;

                    if (bc == null)
                    {
                        continue;
                    }

                    double dispelChance = (50.0 + ((100 * (this.Caster.Skills.Magery.Value - bc.GetDispelDifficulty())) / (bc.DispelFocus * 2))) / 100;

                    if (dispelChance > Utility.RandomDouble())
                    {
                        Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x3728, 8, 20, 5042);
                        Effects.PlaySound(m, m.Map, 0x201);

                        m.Delete();
                    }
                    else
                    {
                        this.Caster.DoHarmful(m);

                        m.FixedEffect(0x3779, 10, 20);
                    }
                }
            }

            this.FinishSequence();
        }
예제 #7
0
        public void CheckGuardCandidate(Mobile m, bool autoCallGuards)
        {
            if (IsDisabled())
            {
                return;
            }

            if (IsGuardCandidate(m))
            {
                GuardTimer timer = null;
                m_GuardCandidates.TryGetValue(m, out timer);

                if (autoCallGuards)
                {
                    MakeGuard(m);

                    if (timer != null)
                    {
                        timer.Stop();
                        m_GuardCandidates.Remove(m);
                        m.SendLocalizedMessage(502276); // Guards can no longer be called on you.
                    }
                }
                else if (timer == null)
                {
                    timer = new GuardTimer(m, m_GuardCandidates);
                    timer.Start();

                    m_GuardCandidates[m] = timer;
                    m.SendLocalizedMessage(502275); // Guards can now be called on you!

                    Map map = m.Map;

                    if (map != null)
                    {
                        Mobile fakeCall = null;
                        double prio     = 0.0;

                        IPooledEnumerable eable = m.GetMobilesInRange(8);

                        foreach (Mobile v in eable)
                        {
                            if (!v.Player && v != m && !IsGuardCandidate(v) &&
                                ((v is BaseCreature) ? ((BaseCreature)v).IsHumanInTown() : (v.Body.IsHuman && v.Region.IsPartOf(this))))
                            {
                                double dist = m.GetDistanceToSqrt(v);

                                if (fakeCall == null || dist < prio)
                                {
                                    fakeCall = v;
                                    prio     = dist;
                                }
                            }
                        }

                        eable.Free();

                        if (fakeCall != null)
                        {
                            fakeCall.Say(Utility.RandomList(1007037, 501603, 1013037, 1013038, 1013039, 1013041, 1013042, 1013043, 1013052));
                            MakeGuard(m);
                            timer.Stop();
                            m_GuardCandidates.Remove(m);
                            m.SendLocalizedMessage(502276); // Guards can no longer be called on you.
                        }
                    }
                }
                else
                {
                    timer.Stop();
                    timer.Start();
                }
            }
        }
예제 #8
0
        public void NotifyLocationChangeOnSmooth(Mobile mobile, Point3D oldLocation)
        {
            Map     map         = mobile.Map;
            Point3D newLocation = mobile.Location;

            if (map != null)
            {
                // First, send a remove message to everyone who can no longer see us. (inOldRange && !inNewRange)
                Packet removeThis = null;

                IPooledEnumerable eable = map.GetClientsInRange(oldLocation);

                foreach (NetState ns in eable)
                {
                    if (ns != mobile.NetState && !Utility.InUpdateRange(newLocation, ns.Mobile.Location))
                    {
                        if (removeThis == null)
                        {
                            removeThis = mobile.RemovePacket;
                        }

                        ns.Send(removeThis);
                    }
                }

                eable.Free();

                NetState ourState = mobile.NetState;

                // Check to see if we are attached to a client
                if (ourState != null)
                {
                    eable = mobile.Map.GetObjectsInRange(newLocation, Core.GlobalMaxUpdateRange);

                    // We are attached to a client, so it's a bit more complex. We need to send new items and people to ourself, and ourself to other clients
                    foreach (object o in eable)
                    {
                        if (o is Item)
                        {
                            Item item = (Item)o;

                            if (item.NoMoveHS)
                            {
                                continue;
                            }

                            int     range = item.GetUpdateRange(mobile);
                            Point3D loc   = item.Location;

                            if (/*!Utility.InRange(oldLocation, loc, range) && */ Utility.InRange(newLocation, loc, range) && mobile.CanSee(item))
                            {
                                item.SendInfoTo(ourState);
                            }
                        }
                        else if (o != mobile && o is Mobile)
                        {
                            Mobile m = (Mobile)o;

                            if (m.NoMoveHS)
                            {
                                continue;
                            }

                            if (!Utility.InUpdateRange(newLocation, m.Location))
                            {
                                continue;
                            }

                            bool inOldRange = Utility.InUpdateRange(oldLocation, m.Location);

                            if (!inOldRange && m.NetState != null && m.CanSee(mobile))
                            {
                                m.NetState.Send(new MobileIncoming(m, mobile));

                                if (mobile.Poison != null)
                                {
                                    m.NetState.Send(new HealthbarPoison(mobile));
                                }

                                if (mobile.Blessed || mobile.YellowHealthbar)
                                {
                                    m.NetState.Send(new HealthbarYellow(mobile));
                                }

                                if (mobile.IsDeadBondedPet)
                                {
                                    m.NetState.Send(new BondedStatus(0, mobile.Serial, 1));
                                }

                                if (ObjectPropertyList.Enabled)
                                {
                                    m.NetState.Send(m.OPLPacket);
                                }
                            }

                            if (!inOldRange && mobile.CanSee(m))
                            {
                                ourState.Send(new MobileIncoming(mobile, m));

                                if (m.Poisoned)
                                {
                                    ourState.Send(new HealthbarPoison(m));
                                }

                                if (m.Blessed || m.YellowHealthbar)
                                {
                                    ourState.Send(new HealthbarYellow(m));
                                }

                                if (m.IsDeadBondedPet)
                                {
                                    ourState.Send(new BondedStatus(0, mobile.Serial, 1));
                                }

                                if (ObjectPropertyList.Enabled)
                                {
                                    ourState.Send(m.OPLPacket);
                                }
                            }
                        }
                    }

                    eable.Free();
                }
                else
                {
                    if (mobile == null)
                    {
                        return;
                    }

                    eable = mobile.Map.GetClientsInRange(newLocation);

                    // We're not attached to a client, so simply send an Incoming
                    foreach (NetState ns in eable)
                    {
                        if (mobile.NoMoveHS)
                        {
                            continue;
                        }

                        if (Utility.InUpdateRange(oldLocation, ns.Mobile.Location) && ns.Mobile.CanSee(mobile))
                        {
                            if (ns.StygianAbyss)
                            {
                                ns.Send(new MobileIncoming(ns.Mobile, mobile));

                                if (mobile.Poison != null)
                                {
                                    ns.Send(new HealthbarPoison(mobile));
                                }

                                if (mobile.Blessed || mobile.YellowHealthbar)
                                {
                                    ns.Send(new HealthbarYellow(mobile));
                                }
                            }
                            else
                            {
                                ns.Send(new MobileIncomingOld(ns.Mobile, mobile));
                            }

                            if (mobile.IsDeadBondedPet)
                            {
                                ns.Send(new BondedStatus(0, mobile.Serial, 1));
                            }

                            if (ObjectPropertyList.Enabled)
                            {
                                ns.Send(mobile.OPLPacket);
                            }
                        }
                    }

                    eable.Free();
                }
            }
        }
예제 #9
0
        public bool CanFit(Point3D loc, Map map, int itemID)
        {
            if (map == null || map == Map.Internal || Deleted)
            {
                return(false);
            }

            MultiComponentList newComponents = MultiData.GetComponents(itemID);

            for (int x = 0; x < newComponents.Width; ++x)
            {
                for (int y = 0; y < newComponents.Height; ++y)
                {
                    if (itemID <= 0x20 && itemID >= 0x18)
                    {
                        if (_facing == Direction.North)
                        {
                            if ((x >= 0) && (x <= 4))
                            {
                                continue;
                            }
                            if ((x >= newComponents.Width - 5) && (x < newComponents.Width))
                            {
                                continue;
                            }
                        }
                        else if (_facing == Direction.South)
                        {
                            if ((x >= 0) && (x <= 4))
                            {
                                continue;
                            }
                            if ((x >= newComponents.Width - 5) && (x < newComponents.Width))
                            {
                                continue;
                            }
                        }
                        else if (_facing == Direction.East)
                        {
                            if ((y >= 0) && (y <= 4))
                            {
                                continue;
                            }
                            if ((y >= newComponents.Height - 5) && (y < newComponents.Height))
                            {
                                continue;
                            }
                        }
                        else
                        {
                            if ((y >= 0) && (y <= 4))
                            {
                                continue;
                            }
                            if ((y >= newComponents.Height - 5) && (y < newComponents.Height))
                            {
                                continue;
                            }
                        }
                    }

                    int tx = loc.X + newComponents.Min.X + x;
                    int ty = loc.Y + newComponents.Min.Y + y;

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

                    bool isWalkable = false;

                    // landTile check
                    LandTile landTile = map.Tiles.GetLandTile(tx, ty);
                    if (landTile.Z == loc.Z && IsEnabledLandID(landTile.ID))
                    {
                        isWalkable = true;
                    }

                    // staticTiles check
                    foreach (StaticTile tile in map.Tiles.GetStaticTiles(tx, ty, true))
                    {
                        if (IsEnabledStaticID(tile.ID) && (tile.Z == loc.Z))
                        {
                            isWalkable = true;
                        }
                        else if (!IsEnabledStaticID(tile.ID) && (tile.Z >= loc.Z))//else if (!isBridgeEnabledTile(tile, loc.Z, maxMultiZ))
                        {
                            return(false);
                        }
                    }

                    if (!isWalkable)
                    {
                        return(false);
                    }
                }
            }


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

            foreach (Item item in eable)
            {
                if (item is BaseSmoothMulti || item.ItemID > TileData.MaxItemValue || item.Z < loc.Z || !item.Visible)
                {
                    continue;
                }

                int x = item.X - loc.X + newComponents.Min.X;
                int y = item.Y - loc.Y + newComponents.Min.Y;

                if (x >= 0 && x < newComponents.Width && y >= 0 && y < newComponents.Height && newComponents.Tiles[x][y].Length == 0)
                {
                    continue;
                }
                else if (IsOnBoard(item))
                {
                    continue;
                }

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

            eable.Free();

            return(true);
        }
예제 #10
0
    public static void LiveFreeze(Mobile from, Map targetMap, Point3D start3d, Point3D end3d)
    {
      Dictionary<Point2D, List<Item>> ItemsByBlockLocation = new Dictionary<Point2D, List<Item>>();
      if (targetMap != null && start3d != NullP3D && end3d != NullP3D)
      {
        Point2D start = targetMap.Bound(new Point2D(start3d));
        Point2D end = targetMap.Bound(new Point2D(end3d));
        IPooledEnumerable eable = targetMap.GetItemsInBounds(new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1));

        Console.WriteLine(string.Format("Invoking live freeze from {0},{1} to {2},{3}", start.X, start.Y, end.X, end.Y));

        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;

            Point2D p = new Point2D(item.X >> 3, item.Y >> 3);
            if (!(ItemsByBlockLocation.ContainsKey(p)))
            {
              ItemsByBlockLocation.Add(p, new List<Item>());
            }
            ItemsByBlockLocation[p].Add(item);
          }
        }

        eable.Free();
      }
      else
      {
        from.SendMessage("That was not a proper area. Please retarget and reissue the command.");
        return;
      }

      TileMatrix matrix = targetMap.Tiles;
      foreach (KeyValuePair<Point2D, List<Item>> kvp in ItemsByBlockLocation)
      {
        StaticTile[][][] blockOfTiles = matrix.GetStaticBlock(kvp.Key.X, kvp.Key.Y);
        Dictionary<Point2D, List<StaticTile>> newBlockStatics = new Dictionary<Point2D, List<StaticTile>>();

        foreach (Item item in kvp.Value)
        {
          int xOffset = item.X - (kvp.Key.X * 8);
          int yOffset = item.Y - (kvp.Key.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);
          Point2D refPoint = new Point2D(xOffset, yOffset);

          if (!(newBlockStatics.ContainsKey(refPoint)))
          {
            newBlockStatics.Add(refPoint, new List<StaticTile>());
          }

          newBlockStatics[refPoint].Add(newTile);
          item.Delete();
        }

        for (int i = 0; i < blockOfTiles.Length; i++)
          for (int j = 0; j < blockOfTiles[i].Length; j++)
            for (int k = 0; k < blockOfTiles[i][j].Length; k++)
            {
              Point2D refPoint = new Point2D(i, j);
              if (!(newBlockStatics.ContainsKey(refPoint)))
              {
                newBlockStatics.Add(refPoint, new List<StaticTile>());
              }

              newBlockStatics[refPoint].Add(blockOfTiles[i][j][k]);
            }

        StaticTile[][][] newblockOfTiles = new StaticTile[8][][];

        for (int i = 0; i < 8; i++)
        {
          newblockOfTiles[i] = new StaticTile[8][];
          for (int j = 0; j < 8; j++)
          {
            Point2D p = new Point2D(i, j);
            int length = 0;
            if (newBlockStatics.ContainsKey(p))
            {
              length = newBlockStatics[p].Count;
            }
            newblockOfTiles[i][j] = new StaticTile[length];
            for (int k = 0; k < length; k++)
            {
              if (newBlockStatics.ContainsKey(p))
              {
                newblockOfTiles[i][j][k] = newBlockStatics[p][k];
              }
            }
          }
        }

        matrix.SetStaticBlock(kvp.Key.X, kvp.Key.Y, newblockOfTiles);
        int blockNum = ((kvp.Key.X * matrix.BlockHeight) + kvp.Key.Y);

        List<Mobile> candidates = new List<Mobile>();
        int bX = kvp.Key.X * 8;
        int bY = kvp.Key.Y * 8;

        IPooledEnumerable eable = targetMap.GetMobilesInRange(new Point3D(bX, bY, 0));

        foreach (Mobile m in eable)
        {
          if (m.Player)
          {
            candidates.Add(m);
          }
        }
        eable.Free();

        CRC.InvalidateBlockCRC(targetMap.MapID, blockNum);
        foreach (Mobile m in candidates)
        {
          m.Send(new UpdateStaticsPacket(new Point2D(kvp.Key.X, kvp.Key.Y), m));
        }
        MapChangeTracker.MarkStaticsBlockForSave(targetMap.MapID, kvp.Key);
      }
    }
예제 #11
0
        public void Target(IPoint3D p)
        {
            if (!this.Caster.CanSee(p))
            {
                this.Caster.SendLocalizedMessage(500237); // Target can not be seen.
            }
            else if (SpellHelper.CheckTown(p, this.Caster) && this.CheckSequence())
            {
                SpellHelper.Turn(this.Caster, p);

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

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

                Map map = this.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 == this.Caster))
                        {
                            continue;
                        }

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

                            targets.Add(id);
                        }
                    }

                    eable.Free();
                }

                double damage;

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

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

                        if (Core.AOS)
                        {
                            damage = this.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 && this.CheckResisted(m))
                        {
                            damage *= 0.5;

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

                        if (m != null)
                        {
                            damage *= this.GetDamageScalar(m);
                        }

                        this.Caster.DoHarmful(id);
                        SpellHelper.Damage(this, id, damage, 0, 100, 0, 0, 0);

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

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

            this.FinishSequence();
        }
예제 #12
0
        public void Target(IPoint3D p)
        {
            IPoint3D orig = p;
            Map      map  = Caster.Map;

            SpellHelper.GetSurfaceTop(ref p);

            Point3D from = Caster.Location;
            Point3D to   = new Point3D(p);

            if (Factions.Sigil.ExistsOn(Caster))
            {
                Caster.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil.
            }
            else if (Server.Misc.WeightOverloading.IsOverloaded(Caster))
            {
                Caster.SendLocalizedMessage(502359, "", 0x22); // Thou art too encumbered to move.
            }
            else if (!SpellHelper.CheckTravel(Caster, TravelCheckType.TeleportFrom))
            {
            }
            else if (!SpellHelper.CheckTravel(Caster, map, to, TravelCheckType.TeleportTo))
            {
            }
            else if (map == null || !map.CanSpawnMobile(p.X, p.Y, p.Z))
            {
                Caster.SendLocalizedMessage(501942); // That location is blocked.
            }
            else if (SpellHelper.CheckMulti(to, map))
            {
                Caster.SendLocalizedMessage(502831); // Cannot teleport to that spot.
            }
            else if (Region.Find(to, map).GetRegion(typeof(HouseRegion)) != null)
            {
                Caster.SendLocalizedMessage(502829); // Cannot teleport to that spot.
            }
            else if (CheckSequence())
            {
                SpellHelper.Turn(Caster, orig);

                Mobile m = Caster;

                m.Location = to;
                m.ProcessDelta();

                if (m.Player)
                {
                    Effects.SendLocationParticles(EffectItem.Create(from, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023);
                    Effects.SendLocationParticles(EffectItem.Create(to, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023);
                }
                else
                {
                    m.FixedParticles(0x376A, 9, 32, 0x13AF, EffectLayer.Waist);
                }

                m.PlaySound(0x1FE);

                IPooledEnumerable eable = m.GetItemsInRange(0);

                foreach (Item item in eable)
                {
                    if (item is Server.Spells.Fifth.PoisonFieldSpell.InternalItem || item is Server.Spells.Fourth.FireFieldSpell.FireFieldItem)
                    {
                        item.OnMoveOver(m);
                    }
                }

                eable.Free();
            }

            FinishSequence();
        }
예제 #13
0
        public override void OnCast()
        {
            if (SpellHelper.CheckTown(Caster, Caster) && CheckSequence())
            {
                ArrayList targets = new ArrayList();

                Map map = Caster.Map;

                if (map != null)
                {
                    IPooledEnumerable eable = Caster.GetMobilesInRange(1 + (int)(Caster.Skills[SkillName.Magery].Value / 15.0));
                    foreach (Mobile m in eable)
                    {
                        if (Caster != m && SpellHelper.ValidIndirectTarget(Caster, m) && Caster.CanBeHarmful(m, false) && (!Core.AOS || Caster.InLOS(m)))
                        {
                            targets.Add(m);
                        }
                    }
                    eable.Free();
                }

                Caster.PlaySound(0x2F3);

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

                    int damage;

                    if (Core.AOS)
                    {
                        damage = m.Hits / 2;

                        if (m.Player)
                        {
                            damage += Utility.RandomMinMax(0, 15);
                        }

                        if (damage < 15)
                        {
                            damage = 15;
                        }
                        else if (damage > 100)
                        {
                            damage = 100;
                        }
                    }
                    else
                    {
                        damage = (m.Hits * 6) / 10;

                        if (!m.Player && damage < 10)
                        {
                            damage = 10;
                        }
                        else if (damage > 75)
                        {
                            damage = 75;
                        }
                    }

                    Caster.DoHarmful(m);
                    SpellHelper.Damage(TimeSpan.Zero, m, Caster, damage, 100, 0, 0, 0, 0);
                }
            }

            FinishSequence();
        }
예제 #14
0
        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);

                    bool chargeUsed = false;

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

                        if (m.BeginAction(typeof(ProtectionSpell)))
                        {
                            if (m.Player)
                            {
                                Caster.DoBeneficial(m);
                            }

                            m.VirtualArmorMod += val;
                            new InternalTimer(m, Caster, val).Start();

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

                            if (enhancedSpellcast)
                            {
                                chargeUsed = true;
                            }

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

                            if (enhancedSpellcast)
                            {
                                m.FixedParticles(0x375A, 9, 40, 5027, spellHue, 0, EffectLayer.Waist);
                                m.PlaySound(0x1F7);
                            }

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

                    if (chargeUsed)
                    {
                        if (Caster.FindItemOnLayer(Layer.OneHanded) is EnhancedSpellbook)
                        {
                            EnhancedSpellbook spellbook = Caster.FindItemOnLayer(Layer.OneHanded) as EnhancedSpellbook;

                            if (spellbook != null)
                            {
                                spellbook.OnSpellCast(Caster);
                            }
                        }
                    }
                }
            }

            FinishSequence();
        }
예제 #15
0
        public void Target(IPoint3D p)
        {
            if (!Caster.CanSee(p))
            {
                Caster.SendAsciiMessage("Target is not in line of sight.");
                DoFizzle();
            }
            else if (SphereSpellTarget is BaseWand)
            {
                BaseWand bw = SphereSpellTarget as BaseWand;
                bw.RechargeWand(Caster, this);
            }
            else if (/*SpellHelper.CheckTown(p, Caster) && */ CheckSequence())
            {
                SpellHelper.GetSurfaceTop(ref p);

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

                bool eastToWest;

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

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

                int itemID = eastToWest ? 0x3915 : 0x3922;

                TimeSpan duration = TimeSpan.FromSeconds(3 + (Caster.Skills.Magery.Fixed / 25));


                List <InternalItem> itemList = new List <InternalItem>();

                for (int i = -3; i <= 3; ++i)
                {
                    Point3D loc = new Point3D(eastToWest ? p.X + i : p.X, eastToWest ? p.Y : p.Y + i, p.Z);

                    IPooledEnumerable eable = Caster.Map.GetMobilesInRange(loc, 0);

                    foreach (Mobile m in eable)
                    {
                        if (m.AccessLevel != AccessLevel.Player || !m.Alive || (m is PlayerMobile && ((PlayerMobile)m).Young))
                        {
                            continue;
                        }

                        //Taran: The whole field counts as a harmful action, not just the target
                        if (m.Location.Z - loc.Z < 18 && m.Location.Z - loc.Z > -10)
                        {
                            Caster.DoHarmful(m);
                        }
                    }

                    InternalItem item = new InternalItem(itemID, loc, Caster, Caster.Map, duration, i);
                    itemList.Add(item);
                }

                if (SphereSpellTarget is Mobile)
                {
                    InternalItem castItem = new InternalItem(itemID, (SphereSpellTarget as Mobile).Location, Caster, Caster.Map, duration, 3);
                    castItem.OnMoveOver(SphereSpellTarget as Mobile);
                    //Caster.DoHarmful(SphereSpellTarget as Mobile); - This check is now made for each field tile

                    castItem.Delete();
                }

                if (itemList.Count > 0)
                {
                    new SoundTimer(itemList, 517).Start();
                }

                FinishSequence();
            }
        }
예제 #16
0
        public static TimeSpan OnUse(Mobile m)
        {
            if (m.Spell != null)
            {
                m.SendLocalizedMessage(501238); // You are busy doing something else and cannot hide.
                return(TimeSpan.FromSeconds(1.0));
            }

            if (Server.Engines.VvV.ManaSpike.UnderEffects(m))
            {
                return(TimeSpan.FromSeconds(1.0));
            }

            if (m.Target != null)
            {
                Targeting.Target.Cancel(m);
            }

            double bonus = 0.0;

            BaseHouse house = BaseHouse.FindHouseAt(m);

            if (house != null && house.IsFriend(m))
            {
                bonus = 100.0;
            }

            //int range = 18 - (int)(m.Skills[SkillName.Hiding].Value / 10);
            int skill = Math.Min(100, (int)m.Skills[SkillName.Hiding].Value);
            int range = Math.Min((int)((100 - skill) / 2) + 8, 18);     //Cap of 18 not OSI-exact, intentional difference

            bool badCombat = (!m_CombatOverride && m.Combatant is Mobile && m.InRange(m.Combatant.Location, range) && ((Mobile)m.Combatant).InLOS(m.Combatant));
            bool ok        = (!badCombat /*&& m.CheckSkill( SkillName.Hiding, 0.0 - bonus, 100.0 - bonus )*/);

            if (ok)
            {
                if (!m_CombatOverride)
                {
                    IPooledEnumerable eable = m.GetMobilesInRange(range);

                    foreach (Mobile check in eable)
                    {
                        if (check.InLOS(m) && check.Combatant == m)
                        {
                            badCombat = true;
                            ok        = false;
                            break;
                        }
                    }

                    eable.Free();
                }

                ok = (!badCombat && m.CheckSkill(SkillName.Hiding, 0.0 - bonus, 100.0 - bonus));
            }

            if (badCombat)
            {
                m.RevealingAction();

                m.LocalOverheadMessage(MessageType.Regular, 0x22, 501237); // You can't seem to hide right now.

                return(TimeSpan.Zero);
                //return TimeSpan.FromSeconds(1.0);
            }
            else
            {
                if (ok)
                {
                    m.Hidden  = true;
                    m.Warmode = false;
                    Server.Spells.Sixth.InvisibilitySpell.RemoveTimer(m);
                    Server.Items.InvisibilityPotion.RemoveTimer(m);
                    m.LocalOverheadMessage(MessageType.Regular, 0x1F4, 501240); // You have hidden yourself well.
                }
                else
                {
                    m.RevealingAction();

                    m.LocalOverheadMessage(MessageType.Regular, 0x22, 501241); // You can't seem to hide here.
                }

                return(TimeSpan.FromSeconds(10.0));
            }
        }
예제 #17
0
        public void Explode(Mobile from, bool direct, Point3D loc, Map map)
        {
            if (Deleted)
            {
                return;
            }

            Consume();

            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, 0x307);

            Effects.SendLocationEffect(loc, map, 0x36B0, 9, 10, 0, 0);
            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;
                }
            }

            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)
                    {
                        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);
                }
            }
        }
예제 #18
0
            protected override void OnTick()
            {
                Corpse toChannel = null;

                IPooledEnumerable eable = Caster.GetObjectsInRange(3);

                foreach (object objs in eable)
                {
                    if (objs is Corpse && !((Corpse)objs).Channeled && !((Corpse)objs).Animated)
                    {
                        toChannel = (Corpse)objs;
                        break;
                    }
                    else if (objs is Server.Engines.Khaldun.SageHumbolt)
                    {
                        if (((Server.Engines.Khaldun.SageHumbolt)objs).OnSpiritSpeak(Caster))
                        {
                            eable.Free();
                            SpiritSpeak.Remove(Caster);
                            Stop();
                            return;
                        }
                    }
                }

                eable.Free();

                int max, min, mana, number;

                if (toChannel != null)
                {
                    min    = 1 + (int)(Caster.Skills[SkillName.SpiritSpeak].Value * 0.25);
                    max    = min + 4;
                    mana   = 0;
                    number = 1061287; // You channel energy from a nearby corpse to heal your wounds.
                }
                else
                {
                    min    = 1 + (int)(Caster.Skills[SkillName.SpiritSpeak].Value * 0.25);
                    max    = min + 4;
                    mana   = 10;
                    number = 1061286; // You channel your own spiritual energy to heal your wounds.
                }

                if (Caster.Mana < mana)
                {
                    Caster.SendLocalizedMessage(1061285); // You lack the mana required to use this skill.
                }
                else
                {
                    Caster.CheckSkill(SkillName.SpiritSpeak, 0.0, 120.0);

                    if (Utility.RandomDouble() > (Caster.Skills[SkillName.SpiritSpeak].Value / 100.0))
                    {
                        Caster.SendLocalizedMessage(502443); // You fail your attempt at contacting the netherworld.
                    }
                    else
                    {
                        if (toChannel != null)
                        {
                            toChannel.Channeled = true;
                            toChannel.Hue       = 0x835;
                        }

                        Caster.Mana -= mana;
                        Caster.SendLocalizedMessage(number);

                        if (min > max)
                        {
                            min = max;
                        }

                        Caster.Hits += Utility.RandomMinMax(min, max);

                        Caster.FixedParticles(0x375A, 1, 15, 9501, 2100, 4, EffectLayer.Waist);
                    }
                }

                SpiritSpeak.Remove(Caster);
                Stop();
            }
예제 #19
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);
        }
예제 #20
0
            protected override void OnTick()
            {
                if (m_Owner.Deleted)
                {
                    Stop();
                    return;
                }

                Map map = m_Owner.Map;

                if (map == null)
                {
                    return;
                }

                if (0.25 < Utility.RandomDouble())
                {
                    return;
                }

                Mobile toTeleport = null;

                IPooledEnumerable eable = m_Owner.GetMobilesInRange(16);

                foreach (Mobile m in eable)
                {
                    if (m != m_Owner && m.Player && m_Owner.CanBeHarmful(m) && m_Owner.CanSee(m))
                    {
                        toTeleport = m;
                        break;
                    }
                }
                eable.Free();

                if (toTeleport != null)
                {
                    int offset = Utility.Random(8) * 2;

                    Point3D to = m_Owner.Location;

                    for (int i = 0; i < m_Offsets.Length; i += 2)
                    {
                        int x = m_Owner.X + m_Offsets[(offset + i) % m_Offsets.Length];
                        int y = m_Owner.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length];

                        if (map.CanSpawnMobile(x, y, m_Owner.Z))
                        {
                            to = new Point3D(x, y, m_Owner.Z);
                            break;
                        }
                        else
                        {
                            int z = map.GetAverageZ(x, y);

                            if (map.CanSpawnMobile(x, y, z))
                            {
                                to = new Point3D(x, y, z);
                                break;
                            }
                        }
                    }

                    Mobile m = toTeleport;

                    Point3D from = m.Location;

                    m.Location = to;

                    Server.Spells.SpellHelper.Turn(m_Owner, toTeleport);
                    Server.Spells.SpellHelper.Turn(toTeleport, m_Owner);

                    m.ProcessDelta();

                    Effects.SendLocationParticles(EffectItem.Create(from, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023);
                    Effects.SendLocationParticles(EffectItem.Create(to, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023);

                    m.PlaySound(0x1FE);

                    m_Owner.Combatant = toTeleport;
                }
            }
예제 #21
0
        public override void OnThink()
        {
            if (this.m_NextSpawn <= DateTime.Now && this.m_Spawns != null && this.m_Spawns.Count < 5)
            {
                EvilBunny rabbit = new EvilBunny();
                rabbit.MoveToWorld(this.Location, this.Map);
                this.m_Spawns.Add(rabbit);
                this.m_NextSpawn = DateTime.Now + TimeSpan.FromSeconds(45.0);
            }

            if (this.m_NextAbility < DateTime.Now)
            {
                if (this.Hits < this.HitsMaxSeed && this.Combatant == null && this.Mana > 10)
                {
                    this.Hits         += Utility.Random(30, 40);
                    this.Mana         -= 10;
                    this.m_NextAbility = DateTime.Now + TimeSpan.FromSeconds(5.0);
                }
                if (this.Combatant != null)
                {
                    if (this.Hits < this.HitsMaxSeed / 2 && this.Mana >= 10)
                    {
                        this.Hits += Utility.Random(40, 50);
                        this.Mana -= 10;
                        this.Say("Spirit of the woods, ease my pain.");
                        this.m_NextAbility = DateTime.Now + TimeSpan.FromSeconds(5.0);
                    }

                    else if (this.Combatant.Hits < this.Combatant.HitsMax / 2 && this.Mana >= 15)
                    {
                        this.Say("Guardians of Gaia, bring forth your grasping hands.");
                        Blood blood = new Blood();
                        blood.ItemID             = 3391;
                        blood.Name               = "Grasping Roots";
                        this.Combatant.Paralyzed = true;
                        this.Mana         -= 15;
                        this.m_NextAbility = DateTime.Now + TimeSpan.FromSeconds(10.0);
                    }

                    else if (this.Mana >= 30)
                    {
                        this.Say("Gaia, bring forth your wrath!");
                        ArrayList         alist = new ArrayList();
                        IPooledEnumerable eable = this.Map.GetMobilesInRange(this.Location, 10);
                        foreach (Mobile m in eable)
                        {
                            alist.Add(m);
                        }
                        eable.Free();
                        this.PlaySound(518);
                        this.m_NextAbility = DateTime.Now + TimeSpan.FromSeconds(15.0);
                        Effects.SendLocationParticles(EffectItem.Create(this.Location, this.Map, TimeSpan.FromSeconds(10.0)), 0x37CC, 1, 50, 2101, 7, 9909, 0);
                        if (alist.Count > 0)
                        {
                            for (int i = 0; i < alist.Count; i++)
                            {
                                Mobile m = (Mobile)alist[i];
                                if (m is EvilBunny)
                                {
                                }
                                else
                                {
                                    AOS.Damage(m, this, Utility.Random(15, 20), 100, 0, 0, 0, 0);
                                    m.BoltEffect(2);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #22
0
        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 BaseWeapon)
                        {
                            var crItem = Server.Engines.Craft.CraftItem.GetCraftItem(item.GetType(), true);

                            if (crItem != null)
                            {
                                // Is this necessary? Was this check already done?
                                Item i = FindItemOnLayer(Layer.TwoHanded);

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

                                i = FindItemOnLayer(Layer.OneHanded);

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

                                AddItem(Loot.Construct(crItem.ItemType));
                            }
                            else
                            {
                                AddItem(new ClonedItem(item));
                            }
                        }
                        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), RestoreBody);
        }
예제 #23
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) ||
                               item.ItemID == 0xA531 || item.ItemID == 0xA535;

                if (!isAnvil && !isForge)
                {
                    continue;
                }

                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;

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

                        if (!isAnvil && !isForge)
                        {
                            continue;
                        }

                        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;
                    }
                }
            }
        }
예제 #24
0
        public override void OnThink()
        {
            base.OnThink();

            if (Combatant != null && DateTime.UtcNow > m_NextMeteorRainAllowed && DateTime.UtcNow > m_NextAbilityAllowed)
            {
                double spawnPercent = (double)intervalCount / (double)totalIntervals;

                int meteors = 30 + (int)(Math.Ceiling(50 * spawnPercent));

                int loops = (int)(Math.Ceiling((double)meteors / 10));

                double stationaryDelay = loops + 2.5;

                m_NextMeteorRainAllowed = DateTime.UtcNow + NextMeteorRainDelay + TimeSpan.FromSeconds(stationaryDelay);
                m_NextAbilityAllowed    = DateTime.UtcNow + NextAbilityAllowedDelay + TimeSpan.FromSeconds(stationaryDelay);

                PlaySound(GetAngerSound());

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

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

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

                PublicOverheadMessage(MessageType.Regular, 0, false, "*rains down hellfire*");

                Point3D location = Location;
                Map     map      = Map;

                Timer.DelayCall(TimeSpan.FromSeconds(1.0), delegate
                {
                    if (this == null)
                    {
                        return;
                    }
                    if (this.Deleted)
                    {
                        return;
                    }

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

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

                            PlaySound(GetAngerSound());
                            Effects.PlaySound(location, map, 0x5CF);
                        });
                    }

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

                            Point3D meteorLocation = new Point3D(location.X + Utility.RandomMinMax(-8, 8), location.Y + Utility.RandomMinMax(-8, 8), location.Z);

                            IEntity startLocation = new Entity(Serial.Zero, new Point3D(meteorLocation.X - 1, meteorLocation.Y - 1, meteorLocation.Z + 100), map);
                            IEntity endLocation   = new Entity(Serial.Zero, new Point3D(meteorLocation.X, meteorLocation.Y, meteorLocation.Z + 5), map);

                            int particleSpeed = 8 + (int)(Math.Round(8 * (double)spawnPercent));

                            Effects.SendMovingParticles(startLocation, endLocation, 0x36D4, particleSpeed, 0, false, false, 2613, 0, 9501, 0, 0, 0x100);

                            double impactDelay = .75 - (.375 * spawnPercent);

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

                                Effects.PlaySound(endLocation, map, 0x56E);
                                Effects.SendLocationParticles(endLocation, 0x3709, 10, 20, 2613, 0, 5029, 0);

                                Blood rocks  = new Blood();
                                rocks.Name   = "rocks";
                                rocks.Hue    = 2615;
                                rocks.ItemID = Utility.RandomList(4967, 4970, 4973);

                                Point3D rockLocation = new Point3D(meteorLocation.X, meteorLocation.Y, meteorLocation.Z);

                                rocks.MoveToWorld(rockLocation, map);

                                double firefieldChance = .20 + (.20 * spawnPercent);

                                if (Utility.RandomDouble() <= firefieldChance)
                                {
                                    Timer.DelayCall(TimeSpan.FromSeconds(.25), delegate
                                    {
                                        SingleFireField singleFireField = new SingleFireField(null, 2613, 1, 30, 3, 5, false, false, true, -1, true);
                                        singleFireField.MoveToWorld(rockLocation, map);
                                    });
                                }

                                IPooledEnumerable mobilesOnTile = map.GetMobilesInRange(meteorLocation, 1);

                                Queue m_Queue = new Queue();

                                foreach (Mobile mobile in mobilesOnTile)
                                {
                                    if (!mobile.CanBeDamaged() || !mobile.Alive || mobile.AccessLevel > AccessLevel.Player)
                                    {
                                        continue;
                                    }

                                    bool validTarget = false;

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

                                    if (pm_Target != null)
                                    {
                                        validTarget = true;
                                    }

                                    if (bc_Target != null)
                                    {
                                        if (bc_Target.Controlled && bc_Target.ControlMaster is PlayerMobile)
                                        {
                                            validTarget = true;
                                        }
                                    }

                                    if (validTarget)
                                    {
                                        m_Queue.Enqueue(mobile);
                                    }
                                }

                                mobilesOnTile.Free();

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

                                    double damage = Utility.RandomMinMax((int)(Math.Round((double)DamageMin / 2)), DamageMin);

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

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

                return;
            }

            if (Combatant != null && DateTime.UtcNow > m_NextFireBlastAllowed && DateTime.UtcNow > m_NextAbilityAllowed)
            {
                if (Combatant.Alive && !Combatant.Hidden && InLOS(Combatant) && GetDistanceToSqrt(Combatant) <= 12)
                {
                    m_NextFireBlastAllowed = DateTime.UtcNow + NextFireBlastDelay;
                    m_NextAbilityAllowed   = DateTime.UtcNow + NextAbilityAllowedDelay;

                    double effectTime      = 1.5;
                    double actionsCooldown = 3;

                    PlaySound(GetAngerSound());

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

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

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

                    int itemId  = 0x573E;
                    int itemHue = 0;

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

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

                        Effects.PlaySound(targetLocation, map, 0x5FC);

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

                        Effects.SendMovingParticles(startLocation, endLocation, 0x36D4, 8, 0, false, false, 2613, 0, 9501, 0, 0, 0x100);

                        double distance         = GetDistanceToSqrt(targetLocation);
                        double destinationDelay = (double)distance * .06;

                        Timer.DelayCall(TimeSpan.FromSeconds(destinationDelay), delegate
                        {
                            double spawnPercent = (double)intervalCount / (double)totalIntervals;

                            Effects.PlaySound(targetLocation, map, 0x357);

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

                            m_ExplosionLocations.Add(targetLocation, 0);

                            int radius = 2 + (int)(Math.Ceiling(6 * spawnPercent));

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

                            for (int a = minRange; a < maxRange; a++)
                            {
                                for (int b = minRange; b < maxRange; b++)
                                {
                                    Point3D explosionPoint = new Point3D(targetLocation.X + a, targetLocation.Y + b, targetLocation.Z);

                                    int distanceFromCenter = Utility.GetDistance(targetLocation, explosionPoint);

                                    double fireburstChance = .25 + (.25 * spawnPercent);

                                    if (Utility.RandomDouble() <= fireburstChance)
                                    {
                                        if (!m_ExplosionLocations.ContainsKey(explosionPoint))
                                        {
                                            m_ExplosionLocations.Add(explosionPoint, distance);
                                        }
                                    }
                                }
                            }

                            foreach (KeyValuePair <Point3D, double> pair in m_ExplosionLocations)
                            {
                                Timer.DelayCall(TimeSpan.FromSeconds(pair.Value * .10), delegate
                                {
                                    Point3D explosionLocation = pair.Key;
                                    SpellHelper.AdjustField(ref explosionLocation, map, 12, false);

                                    Effects.PlaySound(pair.Key, map, 0x56D);
                                    Effects.SendLocationParticles(EffectItem.Create(explosionLocation, map, TimeSpan.FromSeconds(0.5)), 0x36BD, 20, 10, 2613, 0, 5044, 0);

                                    IPooledEnumerable mobilesOnTile = map.GetMobilesInRange(pair.Key, 0);

                                    Queue m_Queue = new Queue();

                                    foreach (Mobile mobile in mobilesOnTile)
                                    {
                                        if (!mobile.CanBeDamaged() || !mobile.Alive || mobile.AccessLevel > AccessLevel.Player)
                                        {
                                            continue;
                                        }

                                        bool validTarget = false;

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

                                        if (pm_Target != null)
                                        {
                                            validTarget = true;
                                        }

                                        if (bc_Target != null)
                                        {
                                            if (bc_Target.Controlled && bc_Target.ControlMaster is PlayerMobile)
                                            {
                                                validTarget = true;
                                            }
                                        }

                                        if (validTarget)
                                        {
                                            m_Queue.Enqueue(mobile);
                                        }
                                    }

                                    mobilesOnTile.Free();

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

                                        double damage = DamageMin;

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

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

                return;
            }

            if (Utility.RandomDouble() < .01 && DateTime.UtcNow > m_NextAIChangeAllowed)
            {
                Effects.PlaySound(Location, Map, GetAngerSound());

                switch (Utility.RandomMinMax(1, 5))
                {
                case 1:
                    DictCombatTargetingWeight[CombatTargetingWeight.Player]           = 0;
                    DictCombatTargetingWeight[CombatTargetingWeight.Closest]          = 0;
                    DictCombatTargetingWeight[CombatTargetingWeight.HighestHitPoints] = 0;
                    DictCombatTargetingWeight[CombatTargetingWeight.LowestHitPoints]  = 0;
                    break;

                case 2:
                    DictCombatTargetingWeight[CombatTargetingWeight.Player]           = 10;
                    DictCombatTargetingWeight[CombatTargetingWeight.Closest]          = 0;
                    DictCombatTargetingWeight[CombatTargetingWeight.HighestHitPoints] = 0;
                    DictCombatTargetingWeight[CombatTargetingWeight.LowestHitPoints]  = 0;
                    break;

                case 3:
                    DictCombatTargetingWeight[CombatTargetingWeight.Player]           = 0;
                    DictCombatTargetingWeight[CombatTargetingWeight.Closest]          = 10;
                    DictCombatTargetingWeight[CombatTargetingWeight.HighestHitPoints] = 0;
                    DictCombatTargetingWeight[CombatTargetingWeight.LowestHitPoints]  = 0;
                    break;

                case 4:
                    DictCombatTargetingWeight[CombatTargetingWeight.Player]           = 0;
                    DictCombatTargetingWeight[CombatTargetingWeight.Closest]          = 0;
                    DictCombatTargetingWeight[CombatTargetingWeight.HighestHitPoints] = 10;
                    DictCombatTargetingWeight[CombatTargetingWeight.LowestHitPoints]  = 0;
                    break;

                case 5:
                    DictCombatTargetingWeight[CombatTargetingWeight.Player]           = 0;
                    DictCombatTargetingWeight[CombatTargetingWeight.Closest]          = 0;
                    DictCombatTargetingWeight[CombatTargetingWeight.HighestHitPoints] = 0;
                    DictCombatTargetingWeight[CombatTargetingWeight.LowestHitPoints]  = 10;
                    break;
                }

                m_NextAIChangeAllowed = DateTime.UtcNow + NextAIChangeDelay;
            }
        }
예제 #25
0
        public override bool AquireFocusMob(int iRange, FightMode acqType, bool bPlayerOnly, bool bFacFriend, bool bFacFoe)
        {
            if (m_Mobile.Deleted)
            {
                return(false);
            }

            if (m_Mobile.BardProvoked)
            {
                if (m_Mobile.BardTarget == null || m_Mobile.BardTarget.Deleted)
                {
                    m_Mobile.FocusMob = null;
                    return(false);
                }
                else
                {
                    m_Mobile.FocusMob = m_Mobile.BardTarget;
                    return(m_Mobile.FocusMob != null);
                }
            }
            else if (m_Mobile.Controled)
            {
                if (m_Mobile.ControlTarget == null || m_Mobile.ControlTarget.Deleted)
                {
                    m_Mobile.FocusMob = null;
                    return(false);
                }
                else
                {
                    m_Mobile.FocusMob = m_Mobile.ControlTarget;
                    return(m_Mobile.FocusMob != null);
                }
            }

            if (acqType == FightMode.None)
            {
                m_Mobile.FocusMob = null;
                return(false);
            }

            if (acqType == FightMode.Agressor && m_Mobile.Aggressors.Count == 0 && m_Mobile.Aggressed.Count == 0)
            {
                m_Mobile.FocusMob = null;
                return(false);
            }

            Map map = m_Mobile.Map;

            if (map != null)
            {
                Mobile newFocusMob = null;
                double val         = double.MinValue;

                IPooledEnumerable eable = map.GetMobilesInRange(m_Mobile.Location, iRange);

                foreach (Mobile m in eable)
                {
                    bool bCheckIt = false;

                    //
                    // Basic check
                    //
                    if ((bPlayerOnly && m.Player) || !bPlayerOnly)
                    {
                        if (m.AccessLevel == AccessLevel.Player && m.Alive && !m.Blessed && !m.Deleted && m != m_Mobile && m_Mobile.CanSee(m))
                        {
                            bCheckIt = true;
                        }
                    }

                    if (bCheckIt && !m_Mobile.Controled && m_Mobile.Summoned && m_Mobile.SummonMaster != null)
                    {
                        bCheckIt = (m != m_Mobile.SummonMaster);
                    }

                    //
                    // Team check
                    //
                    if (bCheckIt)                       // alrealy passed the others tests
                    {
                        bCheckIt = ((bFacFriend && m_Mobile.IsFriend(m)) || (bFacFoe && m_Mobile.IsEnemy(m)));
                    }

                    if (bCheckIt && bFacFoe && !bFacFriend && m_Mobile.Summoned && !m_Mobile.Controled && m_Mobile.SummonMaster != null)
                    {
                        bCheckIt = Server.Spells.SpellHelper.ValidIndirectTarget(m_Mobile.SummonMaster, m);
                    }

                    if (bCheckIt)
                    {
                        if (acqType == FightMode.Agressor || acqType == FightMode.Evil)
                        {
                            bCheckIt = false;

                            for (int a = 0; !bCheckIt && a < m_Mobile.Aggressors.Count; ++a)
                            {
                                bCheckIt = (((AggressorInfo)m_Mobile.Aggressors[a]).Attacker == m);
                            }

                            for (int a = 0; !bCheckIt && a < m_Mobile.Aggressed.Count; ++a)
                            {
                                bCheckIt = (((AggressorInfo)m_Mobile.Aggressed[a]).Defender == m);
                            }

                            if (acqType == FightMode.Evil && !bCheckIt)
                            {
                                bCheckIt = (m.Karma < 0);
                            }
                        }
                    }

                    if (bCheckIt)
                    {
                        double theirVal = m_Mobile.GetValueFrom(m, acqType, bPlayerOnly);

                        if (theirVal > val && m_Mobile.InLOS(m))
                        {
                            newFocusMob = m;
                            val         = theirVal;
                        }
                    }
                }

                eable.Free();

                m_Mobile.FocusMob = newFocusMob;
            }

            return(m_Mobile.FocusMob != null);
        }
예제 #26
0
        public override bool OnMoveOver(Mobile m)
        {
            if (m.AccessLevel > AccessLevel.Player)
            {
                return(base.OnMoveOver(m));
            }

            bool hasCreds = m.FindItemOnLayer(Layer.Neck) is DetectiveCredentials;
            bool canCross = hasCreds;

            if (!canCross)
            {
                IPooledEnumerable eable = m.Map.GetItemsInRange(m.Location, 0);

                foreach (Item item in eable)
                {
                    if (item is KhaldunCampBlocker)
                    {
                        eable.Free();
                        return(base.OnMoveOver(m));
                    }
                }
                eable.Free();

                if (X == 5991 && Y == 3749)
                {
                    CheckGuard(m, false);
                    return(false);
                }

                Direction moving = Utility.GetDirection(m, this);

                switch (Position)
                {
                case 0:
                    canCross = moving == Direction.North || moving == Direction.Up || moving == Direction.West; break;

                case 1:
                case 2:
                    canCross = moving == Direction.North || moving == Direction.Up || moving == Direction.Right; break;

                case 3:
                    canCross = moving == Direction.South || moving == Direction.Down || moving == Direction.East; break;

                case 4:
                    canCross = moving == Direction.West || moving == Direction.Up || moving == Direction.Left; break;

                case 5:
                    canCross = moving == Direction.North || moving == Direction.Right || moving == Direction.North; break;
                }
            }

            if (!canCross)
            {
                CheckGuard(m, false);
                return(false);
            }

            if (hasCreds)
            {
                CheckGuard(m, true);
            }

            return(base.OnMoveOver(m));
        }
예제 #27
0
파일: CraftedTrap.cs 프로젝트: KairiL/runuo
        public bool Teleport(Mobile from)
        {
            if (Factions.Sigil.ExistsOn(from))
            {
                from.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil.
                return(false);
            }
            else if (Server.Misc.WeightOverloading.IsOverloaded(from))
            {
                from.SendLocalizedMessage(502359, "", 0x22); // Thou art too encumbered to move.
                return(false);
            }
            else if (!SpellHelper.CheckTravel(from, TravelCheckType.TeleportFrom))
            {
                return(false);
            }
            else if (!SpellHelper.CheckTravel(from, MapDest, PointDest, TravelCheckType.TeleportTo))
            {
                return(false);
            }
            else if (MapDest == null)
            {
                from.SendLocalizedMessage(501942); // That location is blocked.
                return(false);
            }
            else if (SpellHelper.CheckMulti(PointDest, MapDest))
            {
                from.SendLocalizedMessage(502831); // Cannot teleport to that spot.
                return(false);
            }
            else
            {
                Mobile m = from;

                bool sendEffect = (!m.Hidden || m.AccessLevel == AccessLevel.Player);
                if (sendEffect)
                {
                    Effects.SendLocationParticles(EffectItem.Create(Location, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023);
                    Effects.SendLocationParticles(EffectItem.Create(PointDest, m.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023);
                }
                else
                {
                    m.FixedParticles(0x376A, 9, 32, 0x13AF, EffectLayer.Waist);
                }

                m.PlaySound(0x1FE);

                IPooledEnumerable eable = m.GetItemsInRange(0);

                foreach (Item item in eable)
                {
                    if (item is Server.Spells.Sixth.ParalyzeFieldSpell.InternalItem || item is Server.Spells.Fifth.PoisonFieldSpell.InternalItem || item is Server.Spells.Fourth.FireFieldSpell.FireFieldItem)
                    {
                        item.OnMoveOver(m);
                    }
                }

                eable.Free();

                DoTeleport(m);
                m.ProcessDelta();
                return(true);
            }
        }
예제 #28
0
            protected override void OnTick()
            {
                if (m_ItemList.Count > 0)
                {
                    InternalItem playFrom;

                    do
                    {
                        if (m_ItemList.Count > 1)
                        {
                            playFrom = m_ItemList[Utility.Random(m_ItemList.Count)];
                        }
                        else
                        {
                            playFrom = m_ItemList[0];
                        }

                        if (playFrom.Deleted)
                        {
                            m_ItemList.Remove(playFrom);
                        }
                    } while (m_ItemList.Count > 0 && playFrom.Deleted);

                    if (!playFrom.Deleted)
                    {
                        bool playSound = false;
                        foreach (InternalItem i in m_ItemList)
                        {
                            IPooledEnumerable ipe = i.GetMobilesInRange(0);
                            foreach (Mobile m in ipe)
                            {
                                if (m.AccessLevel != AccessLevel.Player || !m.Alive || (m is PlayerMobile && ((PlayerMobile)m).Young))
                                {
                                    continue;
                                }

                                i.OnMoveOver(m);
                                if (!playSound)
                                {
                                    playSound = true;
                                }
                            }

                            ipe.Free();
                        }

                        if (playSound)
                        {
                            IPooledEnumerable ipe = playFrom.GetMobilesInRange(12);
                            foreach (Mobile m in ipe)
                            {
                                m.PlaySound(m_SoundId);
                            }

                            ipe.Free();
                        }

                        new SoundTimer(m_ItemList, m_SoundId).Start();
                    }
                }
            }
예제 #29
0
        public Mobile FindDispelTarget(bool activeOnly)
        {
            if (m_Mobile.Deleted || m_Mobile.Int < 95 || CanDispel(m_Mobile) || m_Mobile.AutoDispel)
            {
                return(null);
            }

            if (activeOnly)
            {
                var aggressed  = m_Mobile.Aggressed;
                var 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, 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, 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, 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(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);
        }
예제 #30
0
        protected override bool OnMove(Direction d)
        {
            if (m_ChargeInProgress)
            {
                if (Utility.RandomDouble() <= .15)
                {
                    Effects.PlaySound(Location, Map, 0x2F4);

                    int effectHue = 0;

                    DeDOSElectricField electricField = new DeDOSElectricField(this, effectHue, 1, 20, 3, 5, false, false, true, -1, true);
                    electricField.MoveToWorld(Location, Map);
                }

                m_NextChargeAllowed = DateTime.UtcNow + NextChargeDelay;

                Queue m_Queue = new Queue();

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

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

                    m_Queue.Enqueue(mobile);
                }

                nearbyMobiles.Free();

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

                    m_Trampled.Add(mobile);

                    Effects.PlaySound(Location, Map, Utility.RandomList(0x3BB, 0x3BA, 0x3B9));
                    Effects.PlaySound(mobile.Location, mobile.Map, mobile.GetHurtSound());

                    double damage = DamageMin;

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

                    new Blood().MoveToWorld(mobile.Location, mobile.Map);

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

                    if (mobile is PlayerMobile)
                    {
                        mobile.Animate(21, 6, 1, true, false, 0);
                    }

                    else if (mobile is BaseCreature)
                    {
                        BaseCreature bc_Creature = mobile as BaseCreature;

                        if (bc_Creature.IsHighSeasBodyType)
                        {
                            bc_Creature.Animate(2, 14, 1, true, false, 0);
                        }

                        else if (bc_Creature.Body != null)
                        {
                            if (bc_Creature.Body.IsHuman)
                            {
                                bc_Creature.Animate(21, 6, 1, true, false, 0);
                            }

                            else
                            {
                                bc_Creature.Animate(2, 4, 1, true, false, 0);
                            }
                        }
                    }

                    SpecialAbilities.HinderSpecialAbility(1.0, this, mobile, 1.0, 1, false, -1, false, "", "You have been trampled and can't move!", "-1");
                }

                CheckChargeResolved();
            }

            Effects.PlaySound(Location, Map, Utility.RandomList(0x12E, 0x12D));

            return(base.OnMove(d));
        }