Exemplo n.º 1
0
            protected override void OnTarget(Mobile from, object targ)
            {
                bool done = false;

                if (!(targ is Item))
                {
                    from.SendMessage("You can only dupe items.");
                    return;
                }

                CommandLogging.WriteLine(from, "{0} {1} duping {2} (inBag={3}; amount={4})", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targ), m_InBag, m_Amount);

                Item      copy = (Item)targ;
                Container pack;

                if (m_InBag)
                {
                    if (copy.Parent is Container)
                    {
                        pack = (Container)copy.Parent;
                    }
                    else if (copy.Parent is Mobile)
                    {
                        pack = ((Mobile)copy.Parent).Backpack;
                    }
                    else
                    {
                        pack = null;
                    }
                }
                else
                {
                    pack = from.Backpack;
                }

                Type t = copy.GetType();

                //ConstructorInfo[] info = t.GetConstructors();

                ConstructorInfo c = t.GetConstructor(Type.EmptyTypes);

                if (c != null)
                {
                    try
                    {
                        from.SendMessage("Duping {0}...", m_Amount);
                        for (int i = 0; i < m_Amount; i++)
                        {
                            object o = c.Invoke(null);

                            if (o != null && o is Item)
                            {
                                Item newItem = (Item)o;
                                CopyProperties(newItem, copy);//copy.Dupe( item, copy.Amount );
                                copy.OnAfterDuped(newItem);
                                newItem.Parent = null;

                                if (pack != null)
                                {
                                    pack.DropItem(newItem);
                                }
                                else
                                {
                                    newItem.MoveToWorld(from.Location, from.Map);
                                }

                                newItem.InvalidateProperties();

                                CommandLogging.WriteLine(from, "{0} {1} duped {2} creating {3}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targ), CommandLogging.Format(newItem));
                            }
                        }
                        from.SendMessage("Done");
                        done = true;
                    }
                    catch
                    {
                        from.SendMessage("Error!");
                        return;
                    }
                }

                if (!done)
                {
                    from.SendMessage("Unable to dupe.  Item must have a 0 parameter constructor.");
                }
            }
Exemplo n.º 2
0
        public static void Invoke(Mobile from, Point3D start, Point3D end, string[] args, List <Container> packs = null, bool outline = false, bool mapAvg = false)
        {
            var b = new StringBuilder();

            b.AppendFormat("{0} {1} building ", from.AccessLevel, CommandLogging.Format(from));
            if (start == end)
            {
                b.AppendFormat("at {0} in {1}", start, from.Map);
            }
            else
            {
                b.AppendFormat("from {0} to {1} in {2}", start, end, from.Map);
            }
            b.Append(":");
            for (var i = 0; i < args.Length; ++i)
            {
                b.AppendFormat(" \"{0}\"", args[i]);
            }
            CommandLogging.WriteLine(from, b.ToString());
            var name = args[0];

            FixArgs(ref args);
            string[,] props = null;
            for (var i = 0; i < args.Length; ++i)
            {
                if (Insensitive.Equals(args[i], "set"))
                {
                    var remains = args.Length - i - 1;
                    if (remains >= 2)
                    {
                        props    = new string[remains / 2, 2];
                        remains /= 2;
                        for (var j = 0; j < remains; ++j)
                        {
                            props[j, 0] = args[i + (j * 2) + 1];
                            props[j, 1] = args[i + (j * 2) + 2];
                        }
                        FixSetString(ref args, i);
                    }
                    break;
                }
            }
            var type = ScriptCompiler.FindTypeByName(name);

            if (!IsEntity(type))
            {
                from.SendMessage("No type with that name was found.");
                return;
            }
            var time  = DateTime.UtcNow;
            var built = BuildObjects(from, type, start, end, args, props, packs, outline, mapAvg);

            if (built > 0)
            {
                from.SendMessage("{0} object{1} generated in {2:F1} seconds.", built, built != 1 ? "s" : string.Empty, (DateTime.UtcNow - time).TotalSeconds);
            }
            else
            {
                SendUsage(type, from);
            }
        }
Exemplo n.º 3
0
        public static void DoWipe(Mobile from, Map map, Point3D start, Point3D end, WipeType type)
        {
            CommandLogging.WriteLine(from, "{0} {1} wiping from {2} to {3} in {5} ({4})", from.AccessLevel, CommandLogging.Format(from), start, end, type, map);

            bool mobiles = ((type & WipeType.Mobiles) != 0);
            bool multis  = ((type & WipeType.Multis) != 0);
            bool items   = ((type & WipeType.Items) != 0);

            List <IEntity> toDelete = new List <IEntity>();

            Rectangle2D rect = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1);

            IPooledEnumerable eable;

            if ((items || multis) && mobiles)
            {
                eable = map.GetObjectsInBounds(rect);
            }
            else if (items || multis)
            {
                eable = map.GetItemsInBounds(rect);
            }
            else if (mobiles)
            {
                eable = map.GetMobilesInBounds(rect);
            }
            else
            {
                return;
            }

            foreach (IEntity obj in eable)
            {
                if (items && (obj is Item) && !((obj is BaseMulti) || (obj is HouseSign)))
                {
                    toDelete.Add(obj);
                }
                else if (multis && (obj is BaseMulti))
                {
                    toDelete.Add(obj);
                }
                else if (mobiles && (obj is Mobile) && !((Mobile)obj).Player)
                {
                    toDelete.Add(obj);
                }
            }

            eable.Free();

            for (int i = 0; i < toDelete.Count; ++i)
            {
                toDelete[i].Delete();
            }
        }