Пример #1
0
 public ThrowTarget(ThrowableItem throwableItem) : base(throwableItem.m_Range, true, TargetFlags.None)
 {
     m_ThrowableItem = throwableItem;
 }
Пример #2
0
        public void Explode(Mobile from, Point3D loc, Map map, bool detonatenearby)
        {
            if (Deleted)
            {
                return;
            }

            if (!m_MoveOnUse)
            {
                loc = target;
            }

            if ((m_DeleteOnUse && !EventItem) || (EventItem && EventItemConsume))
            {
                Consume();
            }
            else
            {
                if (m_DeleteOnUse)
                {
                    Mobile m;
                    if (m_Users != null && m_Users[0] is Mobile)
                    {
                        m = (Mobile)m_Users[0];
                    }
                    else
                    {
                        m = from;
                    }

                    if (RootParentEntity != m)
                    {
                        m.AddToBackpack(this);
                    }
                }

                m_Timer = null;
            }

            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.ThrowableItem == this)
                {
                    Target.Cancel(m);
                }
            }

            if (map == null)
            {
                return;
            }

            if (m_DetonationSound > 0)
            {
                Effects.PlaySound(loc, map, m_DetonationSound);
            }

            if (m_DetonationEffect > 0 && m_DetonationEffectDuration > 0)
            {
                if (m_BlastRadius > 0)
                {
                    ArrayList effects = new ArrayList();

                    int startX = loc.X - m_BlastRadius;
                    int startY = loc.Y - m_BlastRadius;
                    int endX   = loc.X + m_BlastRadius + 1;
                    int endY   = loc.Y + m_BlastRadius + 1;

                    Point2D start = new Point2D(startX, startY);
                    Point2D end   = new Point2D(endX, endY);

                    Rectangle2D rect = new Rectangle2D(start, end);

                    Point2D point;

                    for (int x = rect.Start.X; x < rect.End.X; ++x)
                    {
                        for (int y = rect.Start.Y; y < rect.End.Y; ++y)
                        {
                            point = new Point2D(x, y);
                            if (!effects.Contains(point))
                            {
                                effects.Add(point);
                            }
                        }
                    }

                    if (effects.Count < 500)
                    {
                        Point3D location;

                        foreach (Point2D p in effects)
                        {
                            location = new Point3D(p.X, p.Y, loc.Z + 2);
                            Effects.SendLocationEffect(location, map, m_DetonationEffect, m_DetonationEffectDuration, m_DetonationEffectHue - 1, 0);
                        }
                    }
                    else
                    {
                        PublicOverheadMessage(MessageType.Regular, 0x3B2, true, "Too big blast radius to create effects");
                        return;
                    }

                    effects.Clear();
                }
                else
                {
                    Effects.SendLocationEffect(loc, map, m_DetonationEffect, m_DetonationEffectDuration, m_DetonationEffectHue - 1, 0);
                }
            }

            if (m_TargetItemID > 0)
            {
                if (m_BlastRadius > 0)
                {
                    Point2D   point;
                    ArrayList effects = new ArrayList();

                    int startX = loc.X - m_BlastRadius;
                    int startY = loc.Y - m_BlastRadius;
                    int endX   = loc.X + m_BlastRadius + 1;
                    int endY   = loc.Y + m_BlastRadius + 1;

                    Point2D start = new Point2D(startX, startY);
                    Point2D end   = new Point2D(endX, endY);

                    Rectangle2D rect = new Rectangle2D(start, end);

                    for (int x = rect.Start.X; x < rect.End.X; ++x)
                    {
                        for (int y = rect.Start.Y; y < rect.End.Y; ++y)
                        {
                            point = new Point2D(x, y);
                            if (!effects.Contains(point))
                            {
                                effects.Add(point);
                            }
                        }
                    }

                    if (effects.Count < 500)
                    {
                        foreach (Point2D p in effects)
                        {
                            new ThrowableItemTargetItem(m_TargetItemDuration, m_TargetItemID)
                            {
                                Name      = m_TargetItemName,
                                Hue       = m_TargetItemHue,
                                MinDamage = m_TargetItemMinDamage,
                                MaxDamage = m_TargetItemMaxDamage,
                                Location  = new Point3D(p.X, p.Y, loc.Z + 2),
                                Map       = Map
                            };
                        }
                        if (m_MoveOnUse)
                        {
                            Location = new Point3D(X, Y, loc.Z + 2);
                        }
                    }
                    else
                    {
                        PublicOverheadMessage(MessageType.Regular, 0x3B2, true, "Too big blast radius to create target items");
                        return;
                    }

                    effects.Clear();
                }
                else
                {
                    new ThrowableItemTargetItem(m_TargetItemDuration, m_TargetItemID)
                    {
                        Name      = m_TargetItemName,
                        Hue       = m_TargetItemHue,
                        MinDamage = m_TargetItemMinDamage,
                        MaxDamage = m_TargetItemMaxDamage,
                        Location  = loc,
                        Map       = Map
                    };
                }
            }

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

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

            eable.Free();

            int min = m_MinDamage;
            int max = m_MaxDamage;

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

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

                    if (m_MaxDamage > 0)
                    {
                        GuardedRegion reg = (GuardedRegion)Region.Find(m.Location, m.Map).GetRegion(typeof(GuardedRegion));

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

                                int damage = Utility.RandomMinMax(min, max);
                                AOS.Damage(m, from, damage, 0, 100, 0, 0, 0);
                            }
                        }

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

                                int damage = Utility.RandomMinMax(min, max);
                                AOS.Damage(m, from, damage, 0, 100, 0, 0, 0);
                            }
                        }
                    }
                }

                else if (o is ThrowableItem && detonatenearby)
                {
                    ThrowableItem throwable = (ThrowableItem)o;
                    Mobile        m;

                    if (throwable.m_Users != null && throwable.m_Users[0] is Mobile)
                    {
                        m = (Mobile)throwable.m_Users[0];
                    }
                    else
                    {
                        m = from;
                    }

                    target = throwable.GetWorldLocation();
                    throwable.Explode(m, throwable.GetWorldLocation(), throwable.Map, false);
                }
            }
        }
Пример #3
0
 public ThrowTarget(ThrowableItem throwableItem) : base(throwableItem.m_Range, true, TargetFlags.None)
 {
     m_ThrowableItem = throwableItem;
 }