Beispiel #1
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is Mobile)
                {
                    CommandLogging.WriteLine(from, "{0} {1} dismounting {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targeted));

                    Mobile targ = (Mobile)targeted;

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

                        if (item is IMountItem)
                        {
                            IMount mount = ((IMountItem)item).Mount;

                            if (mount != null)
                            {
                                mount.Rider = null;
                            }

                            if (targ.Items.IndexOf(item) == -1)
                            {
                                --i;
                            }
                        }
                    }

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

                        if (item.Layer == Layer.Mount)
                        {
                            item.Delete();
                            --i;
                        }
                    }
                }
            }
Beispiel #2
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is Mobile)
                {
                    Mobile targ = (Mobile)targeted;

                    if (targ.NetState != null)
                    {
                        CommandLogging.WriteLine(from, "{0} {1} opening client menu of {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targeted));
                        from.SendGump(new ClientGump(from, targ.NetState));
                    }
                }
            }
Beispiel #3
0
        private static void PlaySound(Mobile m, int index, bool toAll)
        {
            Map map = m.Map;

            if (map == null)
            {
                return;
            }

            CommandLogging.WriteLine(m, "{0} {1} playing sound {2} (toAll={3})", m.AccessLevel, CommandLogging.Format(m), index, toAll);

            Packet p = new PlaySound(index, m.Location);

            p.Acquire();

            foreach (NetState state in m.GetClientsInRange(12))
            {
                if (toAll || state.Mobile.CanSee(m))
                {
                    state.Send(p);
                }
            }

            p.Release();
        }
Beispiel #4
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is Mobile)
                {
                    Mobile m = (Mobile)targeted;

                    BankBox box = (m.Player ? m.BankBox : m.FindBankNoCreate());

                    if (box != null)
                    {
                        CommandLogging.WriteLine(from, "{0} {1} opening bank box of {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targeted));

                        if (from == targeted)
                        {
                            box.Open();
                        }
                        else
                        {
                            box.DisplayTo(from);
                        }
                    }
                    else
                    {
                        from.SendMessage("They have no bank box.");
                    }
                }
            }
Beispiel #5
0
                public EquipMenu(Mobile from, Mobile m, ItemListEntry[] entries) : base("Equipment", entries)
                {
                    m_Mobile = m;

                    CommandLogging.WriteLine(from, "{0} {1} viewing equipment of {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(m));
                }
Beispiel #6
0
 public override void OnResponse(NetState state, int index)
 {
     if (index == 0)
     {
         CommandLogging.WriteLine(state.Mobile, "{0} {1} moving equipment item {2} of {3}", state.Mobile.AccessLevel, CommandLogging.Format(state.Mobile), CommandLogging.Format(m_Item), CommandLogging.Format(m_Mobile));
         state.Mobile.Target = new MoveTarget(m_Item);
     }
     else if (index == 1)
     {
         CommandLogging.WriteLine(state.Mobile, "{0} {1} deleting equipment item {2} of {3}", state.Mobile.AccessLevel, CommandLogging.Format(state.Mobile), CommandLogging.Format(m_Item), CommandLogging.Format(m_Mobile));
         m_Item.Delete();
     }
     else if (index == 2)
     {
         CommandLogging.WriteLine(state.Mobile, "{0} {1} opening properties for equipment item {2} of {3}", state.Mobile.AccessLevel, CommandLogging.Format(state.Mobile), CommandLogging.Format(m_Item), CommandLogging.Format(m_Mobile));
         state.Mobile.SendGump(new PropertiesGump(state.Mobile, m_Item));
     }
 }
Beispiel #7
0
        public static void ClearFacet_OnCommand(CommandEventArgs e)
        {
            Map map = e.Mobile.Map;

            if (map == null || map == Map.Internal)
            {
                e.Mobile.SendMessage("You may not run that command here.");
                return;
            }

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

            foreach (Item item in World.Items.Values)
            {
                if (item.Map == map && item.Parent == null)
                {
                    list.Add(item);
                }
            }

            foreach (Mobile m in World.Mobiles.Values)
            {
                if (m.Map == map && !m.Player)
                {
                    list.Add(m);
                }
            }

            if (list.Count > 0)
            {
                CommandLogging.WriteLine(e.Mobile, "{0} {1} starting facet clear of {2} ({3} object{4})", e.Mobile.AccessLevel, CommandLogging.Format(e.Mobile), map, list.Count, list.Count == 1 ? "" : "s");

                e.Mobile.SendGump(
                    new WarningGump(1060635, 30720,
                                    String.Format("You are about to delete {0} object{1} from this facet.  Do you really wish to continue?",
                                                  list.Count, list.Count == 1 ? "" : "s"),
                                    0xFFC000, 360, 260, new WarningGumpCallback(DeleteList_Callback), list));
            }
            else
            {
                e.Mobile.SendMessage("There were no objects found to delete.");
            }
        }
Beispiel #8
0
        public static void GetFollowers_OnTarget(Mobile from, object obj)
        {
            if (obj is PlayerMobile)
            {
                PlayerMobile  master = (PlayerMobile)obj;
                List <Mobile> pets   = master.AllFollowers;

                if (pets.Count > 0)
                {
                    CommandLogging.WriteLine(from, "{0} {1} getting all followers of {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(master));

                    from.SendMessage("That player has {0} pet{1}.", pets.Count, pets.Count != 1 ? "s" : "");

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

                        if (pet is IMount)
                        {
                            ((IMount)pet).Rider = null; // make sure it's dismounted
                        }
                        pet.MoveToWorld(from.Location, from.Map);
                    }
                }
                else
                {
                    from.SendMessage("There were no pets found for that player.");
                }
            }
            else if (obj is Mobile && ((Mobile)obj).Player)
            {
                Mobile    master = (Mobile)obj;
                ArrayList pets   = new ArrayList();

                foreach (Mobile m in World.Mobiles.Values)
                {
                    if (m is BaseCreature)
                    {
                        BaseCreature bc = (BaseCreature)m;

                        if ((bc.Controlled && bc.ControlMaster == master) || (bc.Summoned && bc.SummonMaster == master))
                        {
                            pets.Add(bc);
                        }
                    }
                }

                if (pets.Count > 0)
                {
                    CommandLogging.WriteLine(from, "{0} {1} getting all followers of {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(master));

                    from.SendMessage("That player has {0} pet{1}.", pets.Count, pets.Count != 1 ? "s" : "");

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

                        if (pet is IMount)
                        {
                            ((IMount)pet).Rider = null; // make sure it's dismounted
                        }
                        pet.MoveToWorld(from.Location, from.Map);
                    }
                }
                else
                {
                    from.SendMessage("There were no pets found for that player.");
                }
            }
            else
            {
                from.BeginTarget(-1, false, TargetFlags.None, new TargetCallback(GetFollowers_OnTarget));
                from.SendMessage("That is not a player. Try again.");
            }
        }
Beispiel #9
0
        public static void DeleteList_Callback(Mobile from, bool okay, object state)
        {
            if (okay)
            {
                List <IEntity> list = (List <IEntity>)state;

                CommandLogging.WriteLine(from, "{0} {1} deleting {2} object{3}", from.AccessLevel, CommandLogging.Format(from), list.Count, list.Count == 1 ? "" : "s");

                NetState.Pause();

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

                NetState.Resume();

                from.SendMessage("You have deleted {0} object{1}.", list.Count, list.Count == 1 ? "" : "s");
            }
            else
            {
                from.SendMessage("You have chosen not to delete those objects.");
            }
        }
Beispiel #10
0
 public static int Build(Mobile from, Point3D start, Point3D end, ConstructorInfo ctor, object[] values, string[,] props, PropertyInfo[] realProps, List <Container> packs, bool outline = false, bool mapAvg = false)
 {
     try
     {
         var map    = from.Map;
         var width  = end.X - start.X + 1;
         var height = end.Y - start.Y + 1;
         if (outline && (width < 3 || height < 3))
         {
             outline = false;
         }
         var objectCount = packs != null ? packs.Count : outline ? (width + height - 2) * 2 : width * height;
         if (objectCount >= 20)
         {
             from.SendMessage("Constructing {0} objects, please wait.", objectCount);
         }
         var sendError = true;
         var b         = new StringBuilder();
         b.Append("Serials: ");
         if (packs != null)
         {
             for (var i = 0; i < packs.Count; ++i)
             {
                 var built = Build(from, ctor, values, props, realProps, ref sendError);
                 b.AppendFormat("0x{0:X}; ", built.Serial.Value);
                 if (built is Item)
                 {
                     var pack = packs[i];
                     pack.DropItem((Item)built);
                 }
                 else if (built is Mobile m)
                 {
                     m.MoveToWorld(new Point3D(start.X, start.Y, start.Z), map);
                 }
             }
         }
         else
         {
             var z = start.Z;
             for (var x = start.X; x <= end.X; ++x)
             {
                 for (var y = start.Y; y <= end.Y; ++y)
                 {
                     if (outline && x != start.X && x != end.X && y != start.Y && y != end.Y)
                     {
                         continue;
                     }
                     if (mapAvg)
                     {
                         z = map.GetAverageZ(x, y);
                     }
                     var built = Build(from, ctor, values, props, realProps, ref sendError);
                     b.AppendFormat("0x{0:X}; ", built.Serial.Value);
                     if (built is Item item)
                     {
                         item.MoveToWorld(new Point3D(x, y, z), map);
                     }
                     else if (built is Mobile m)
                     {
                         m.MoveToWorld(new Point3D(x, y, z), map);
                     }
                 }
             }
         }
         CommandLogging.WriteLine(from, b.ToString());
         return(objectCount);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(0);
     }
 }
Beispiel #11
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);
            }
        }
Beispiel #12
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.");
                }
            }
Beispiel #13
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();
            }
        }