Пример #1
0
        public static int Build(Mobile from, Point3D start, Point3D end, ConstructorInfo ctor, object[] values, string[,] props, PropertyInfo[] realProps, ArrayList packs)
        {
            try
            {
                Map map = from.Map;

                int objectCount = (packs == null ? (((end.X - start.X) + 1) * ((end.Y - start.Y) + 1)) : packs.Count);

                if (objectCount >= 20)
                {
                    from.SendMessage("Constructing {0} objects, please wait.", objectCount);
                }

                bool sendError = true;

                StringBuilder sb = new StringBuilder();
                sb.Append("Serials: ");

                if (packs != null)
                {
                    for (int i = 0; i < packs.Count; ++i)
                    {
                        object built = Build(from, ctor, values, props, realProps, ref sendError);

                        if (built is IEntity)
                        {
                            sb.AppendFormat("0x{0:X}; ", ((IEntity)built).Serial.Value);
                        }
                        else
                        {
                            continue;
                        }

                        if (built is Item)
                        {
                            Container pack = (Container)packs[i];

                            pack.DropItem((Item)built);
                        }
                        else if (built is Mobile)
                        {
                            Mobile m = (Mobile)built;

                            m.MoveToWorld(new Point3D(start.X, start.Y, start.Z), map);
                        }
                    }
                }
                else
                {
                    for (int x = start.X; x <= end.X; ++x)
                    {
                        for (int y = start.Y; y <= end.Y; ++y)
                        {
                            object built = Build(from, ctor, values, props, realProps, ref sendError);

                            if (built is IEntity)
                            {
                                sb.AppendFormat("0x{0:X}; ", ((IEntity)built).Serial.Value);
                            }
                            else
                            {
                                continue;
                            }

                            if (built is Item)
                            {
                                Item item = (Item)built;

                                item.MoveToWorld(new Point3D(x, y, start.Z), map);
                            }
                            else if (built is Mobile)
                            {
                                Mobile m = (Mobile)built;

                                m.MoveToWorld(new Point3D(x, y, start.Z), map);
                            }
                        }
                    }
                }

                CommandLogging.WriteLine(from, sb.ToString());

                return(objectCount);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                return(0);
            }
        }
Пример #2
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();

                foreach (ConstructorInfo c in info)
                {
                    //if ( !c.IsDefined( typeof( ConstructableAttribute ), false ) ) continue;

                    ParameterInfo[] paramInfo = c.GetParameters();

                    if (paramInfo.Length == 0)
                    {
                        object[] objParams = new object[0];

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

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

                                    if (pack != null)
                                    {
                                        pack.DropItem(newItem);
                                    }
                                    else
                                    {
                                        newItem.MoveToWorld(from.Location, from.Map);
                                    }
                                }
                            }
                            from.SendMessage("Done");
                            done = true;
                        }
                        catch
                        {
                            from.SendMessage("Error!");
                            return;
                        }
                    }
                }

                if (!done)
                {
                    from.SendMessage("Unable to dupe.  Item must have a 0 parameter constructor.");
                }
            }
Пример #3
0
        public static void DeleteChar_WarningGumpCallback(Mobile from, bool okay, object state)
        {
            Mobile           mob       = (Mobile)state;
            NetState         ns        = mob.NetState;
            List <BaseHouse> houselist = BaseHouse.GetHouses(mob);
            List <Mobile>    mobs      = new List <Mobile>();

            int mobCount, houseCount;
            int itemCount = 0;

            if (!okay)
            {
                return;
            }

            CommandLogging.WriteLine(from, "{0} {1} deleting character {2}.", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(mob));

            foreach (Mobile m in World.Mobiles.Values)
            {
                if (m is BaseCreature)
                {
                    BaseCreature bc = (BaseCreature)m;
                    if ((bc.Controlled && bc.ControlMaster == mob) || (bc.Summoned && bc.SummonMaster == mob))
                    {
                        mobs.Add(bc);
                    }
                }
                else if (m is PlayerVendor)
                {
                    PlayerVendor pv = (PlayerVendor)m;
                    if (pv.Owner == mob)
                    {
                        mobs.Add(pv);
                    }
                }
            }

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

            houseCount = houselist.Count;
            for (int j = 0; j < houselist.Count; ++j)
            {
                BaseHouse house = (BaseHouse)houselist[j];

                List <Item> itemlist = house.GetItems();

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

                    if (item.IsLockedDown)
                    {
                        itemCount++;
                        item.Delete();
                    }
                    else if (item.IsSecure && item is BaseContainer)
                    {
                        BaseContainer con = (BaseContainer)itemlist[k];
                        itemCount += con.GetTotal(TotalType.Items) + 1; // +1 is the container itself
                        con.Delete();
                    }
                }
                itemlist.Clear();

                house.Delete();
            }
            houselist.Clear();

            from.SendMessage("{0} pet{3} and playervendor{3} and {1} house{4} with {2} item{5} inside deleted.", mobCount, houseCount, itemCount, mobCount != 1 ? "s" : "", houseCount != 1 ? "s" : "", itemCount != 1 ? "s" : "");
            mob.Say("I've been deleted!");

            if (ns != null)
            {
                ns.Dispose();
            }

            mob.Delete();

            from.SendMessage("Character has been disposed of thoughtfully.");
        }
Пример #4
0
        public static void Invoke(Mobile from, Point3D start, Point3D end, string[] args, ArrayList packs)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0} {1} building ", from.AccessLevel, CommandLogging.Format(from));

            if (start == end)
            {
                sb.AppendFormat("at {0} in {1}", start, from.Map);
            }
            else
            {
                sb.AppendFormat("from {0} to {1} in {2}", start, end, from.Map);
            }

            sb.Append(":");

            for (int i = 0; i < args.Length; ++i)
            {
                sb.AppendFormat(" \"{0}\"", args[i]);
            }

            CommandLogging.WriteLine(from, sb.ToString());

            string name = args[0];

            FixArgs(ref args);

            string[,] props = null;

            for (int i = 0; i < args.Length; ++i)
            {
                if (Insensitive.Equals(args[i], "set"))
                {
                    int remains = args.Length - i - 1;

                    if (remains >= 2)
                    {
                        props = new string[remains / 2, 2];

                        remains /= 2;

                        for (int 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;
                }
            }

            Type type = ScriptCompiler.FindTypeByName(name);

            if (type == null)
            {
                from.SendMessage("No type with that name was found.");
                return;
            }

            DateTime time = DateTime.Now;

            int built = BuildObjects(from, type, start, end, args, props, packs);

            if (built > 0)
            {
                from.SendMessage("{0} object{1} generated in {2:F1} seconds.", built, built != 1 ? "s" : "", (DateTime.Now - time).TotalSeconds);
            }
            else
            {
                SendUsage(type, from);
            }
        }
Пример #5
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Item.Deleted)
            {
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                return;
            }
            else if (!BaseCommand.IsAccessible(m_From, m_Item))
            {
                m_From.SendMessage("That is no longer accessible.");
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                return;
            }

            switch (info.ButtonID)
            {
            case 0:
            case 1:
            {
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                break;
            }

            case 2:                     // Properties
            {
                m_From.SendGump(new InterfaceItemGump(m_From, m_List, m_Page, m_Item));
                m_From.SendGump(new PropertiesGump(m_From, m_Item));
                break;
            }

            case 3:                     // Delete
            {
                CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel, CommandLogging.Format(m_From), CommandLogging.Format(m_Item));
                m_Item.Delete();
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                break;
            }

            case 4:                     // Go there
            {
                m_From.SendGump(new InterfaceItemGump(m_From, m_List, m_Page, m_Item));
                InvokeCommand(String.Format("Go {0}", m_Item.Serial.Value));
                break;
            }

            case 5:                     // Move to target
            {
                m_From.SendGump(new InterfaceItemGump(m_From, m_List, m_Page, m_Item));
                m_From.Target = new MoveTarget(m_Item);
                break;
            }

            case 6:                     // Bring to pack
            {
                Mobile owner = m_Item.RootParent as Mobile;

                if (owner != null && (owner.Map != null && owner.Map != Map.Internal) && !m_From.CanSee(owner))
                {
                    m_From.SendMessage("You can not get what you can not see.");
                }
                else if (owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && owner.AccessLevel >= m_From.AccessLevel)
                {
                    m_From.SendMessage("You can not get what you can not see.");
                }
                else
                {
                    m_From.SendGump(new InterfaceItemGump(m_From, m_List, m_Page, m_Item));
                    m_From.AddToBackpack(m_Item);
                }

                break;
            }
            }
        }
Пример #6
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Mobile.Deleted)
            {
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                return;
            }
            else if (!BaseCommand.IsAccessible(m_From, m_Mobile))
            {
                m_From.SendMessage("That is no longer accessible.");
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                return;
            }

            switch (info.ButtonID)
            {
            case 0:
            case 1:
            {
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                break;
            }

            case 2:                     // Properties
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));
                m_From.SendGump(new PropertiesGump(m_From, m_Mobile));
                break;
            }

            case 3:                     // Delete
            {
                if (!m_Mobile.Player)
                {
                    CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel, CommandLogging.Format(m_From), CommandLogging.Format(m_Mobile));
                    m_Mobile.Delete();
                    m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                }

                break;
            }

            case 4:                     // Go there
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));
                InvokeCommand(String.Format("Go {0}", m_Mobile.Serial.Value));
                break;
            }

            case 5:                     // Bring them here
            {
                if (m_From.Map == null || m_From.Map == Map.Internal)
                {
                    m_From.SendMessage("You cannot bring that person here.");
                }
                else
                {
                    m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));
                    m_Mobile.MoveToWorld(m_From.Location, m_From.Map);
                }

                break;
            }

            case 6:                     // Move to target
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));
                m_From.Target = new MoveTarget(m_Mobile);
                break;
            }

            case 7:                     // Kill
            {
                if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel)
                {
                    m_Mobile.Kill();
                }

                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));

                break;
            }

            case 8:                     // Res
            {
                if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel)
                {
                    m_Mobile.PlaySound(0x214);
                    m_Mobile.FixedEffect(0x376A, 10, 16);

                    m_Mobile.Resurrect();
                }

                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));

                break;
            }

            case 9:                     // Client
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));

                if (m_Mobile.NetState != null)
                {
                    m_From.SendGump(new ClientGump(m_From, m_Mobile.NetState));
                }

                break;
            }
            }
        }
Пример #7
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is Mobile)
                {
                    Mobile targ = (Mobile)targeted;
                    if (from != targ)
                    {
                        from.SendMessage("You may only set your own body to GM style.");
                    }

                    else
                    {
                        m_Mobile = from;

                        CommandLogging.WriteLine(from, "{0} {1} is assuming a GM body", from.AccessLevel, CommandLogging.Format(from));

                        Container pack = from.Backpack;

                        if (pack == null)
                        {
                            pack         = new Backpack();
                            pack.Movable = false;

                            from.AddItem(pack);
                        }

                        from.Body   = 0x190;
                        from.Fame   = 0;
                        from.Karma  = 0;
                        from.Kills  = 0;
                        from.Hidden = true;
                        from.Hits   = from.HitsMax;
                        from.Mana   = from.ManaMax;
                        from.Stam   = from.StamMax;

                        if (from.AccessLevel >= AccessLevel.GameMaster)
                        {
                            EquipItem(new StaffRing());
                            Spellbook book1 = new Spellbook((ulong)18446744073709551615);
                            Spellbook book2 = new NecromancerSpellbook((ulong)0xffff);
                            Spellbook book3 = new BookOfChivalry();

                            PackItem(book1);
                            PackItem(book2);
                            PackItem(book3);
                            PackItem(new EtherealHorse());

                            from.RawStr = 100;
                            from.RawDex = 100;
                            from.RawInt = 100;
                            from.Hits   = from.HitsMax;
                            from.Mana   = from.ManaMax;
                            from.Stam   = from.StamMax;

                            for (int i = 0; i < targ.Skills.Length; ++i)
                            {
                                targ.Skills[i].Base = 120;
                            }
                        }

                        if (from.AccessLevel == AccessLevel.Counselor)
                        {
                            EquipItem(new CounselorRobe());
                            EquipItem(new ThighBoots(3));
                            PackItem(new CounselorHide());
                            from.Title = "[Counselor]";
                            from.AddItem(new ShortHair(3));
                            from.AddItem(new Vandyke(3));
                        }

                        if (from.AccessLevel == AccessLevel.GameMaster)
                        {
                            EquipItem(new GMRobe());
                            EquipItem(new ThighBoots(39));
                            PackItem(new SeerHide(39));
                            from.Title = "[GM]";
                            from.AddItem(new ShortHair(39));
                            from.AddItem(new Vandyke(39));
                        }

                        if (from.AccessLevel == AccessLevel.Seer)
                        {
                            EquipItem(new SeerRobe());
                            EquipItem(new ThighBoots(467));
                            PackItem(new SeerHide());
                            from.Title = "[Seer]";
                            from.AddItem(new ShortHair(467));
                            from.AddItem(new Vandyke(467));
                        }

                        if (from.AccessLevel == AccessLevel.Administrator)
                        {
                            EquipItem(new AdminRobe());
                            EquipItem(new ThighBoots(1001));
                            PackItem(new AdminHide());
                            from.Title = "[Admin]";
                            from.AddItem(new ShortHair(1001));
                            from.AddItem(new Vandyke(1001));
                        }
                    }
                }
            }
Пример #8
0
 protected override void OnTarget(Mobile from, object o)
 {
     if (!(o is PlayerMobile) || o == null)
     {
         from.SendMessage("Invalid target, must be a player.");
     }
     else
     {
         Mobile   t  = (Mobile)o;
         NetState ns = t.NetState;
         if (t.Deleted || t.Map == Map.Internal)
         {
             from.SendMessage("Invalid target, must be an online player.");
         }
         else if (t.AccessLevel != AccessLevel.Player)
         {
             from.SendMessage("Invalid target, not AccessLevel.Player.");
         }
         else if (ns == null)
         {
             from.SendMessage("Invalid target, this player is either disconnected or logging out.");
         }
         else
         {
             Account acct = t.Account as Account;
             if (acct != null)
             {
                 string   s_LastAFKCheck = acct.GetTag("LastAFKCheck");
                 DateTime LastAFKCheck   = DateTime.Now.Subtract(TimeSpan.FromHours(5));
                 if (s_LastAFKCheck != null)
                 {
                     try
                     {
                         LastAFKCheck = DateTime.Parse(s_LastAFKCheck);
                     }
                     catch { };
                 }
                 else
                 {
                     LastAFKCheck = DateTime.Now.Subtract(TimeSpan.FromHours(5));
                 }
                 if (DateTime.Now - LastAFKCheck > TimeSpan.FromHours(4) || tForce)
                 {
                     t.CloseGump(typeof(AFKCheckGump));
                     t.SendGump(new AFKCheckGump(from, t, 0, MaxRetries, 0, MaxSeconds, null, tKick, tJail, MoveToLoc, MoveToMap, WebSite, null));
                     from.SendMessage(1150, "AFK check gump sent to {0}.", t.Name);
                     CommandLogging.WriteLine(from, "{0} {1} Issuing AFK Check to: {2} ", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(t));
                     acct.SetTag("LastAFKCheck", DateTime.Now.ToString());
                     acct.SetTag("LastAFKCheckBy", from.Name);
                 }
                 else
                 {
                     from.SendMessage(36, "Last AFKCheck under 4 hours.");
                     from.SendMessage(36, "Use FORCE option.");
                     from.SendGump(new AFKInfoGump(t));
                 }
             }
             else
             {
                 from.SendMessage("Invalid target, Account property = null!");
             }
         }
     }
 }
Пример #9
0
            protected override void OnTarget(Mobile from, object targ)
            {
                bool done = false;

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

                if (targ is Container)
                {
                    int Total_ItemCount = m_Amount * ((Container)targ).TotalItems;

                    if (Total_ItemCount > 1000)
                    {
                        from.SendMessage("You are trying to create {0} new items on the server!\nSafety Limit is 1000.", Total_ItemCount);
                        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;
                }

                try
                {
                    from.SendMessage("Duping {0}...", m_Amount);

                    for (int i = 0; i < m_Amount; i++)
                    {
                        InternalDupe((Item)targ, pack, from);
                    }

                    from.SendMessage("Done");
                    done = true;
                }
                catch
                {
                    from.SendMessage("Error!");
                    return;
                }

                if (!done)
                {
                    from.SendMessage("Unable to dupe. Item must have a 0 parameter constructor.");
                }
            }
Пример #10
0
            private static void InternalDupe(Item src, Container pack, Mobile from)
            {
                Type t = src.GetType();

                ConstructorInfo[] info = t.GetConstructors();

                foreach (ConstructorInfo c in info)
                {
                    ParameterInfo[] paramInfo = c.GetParameters();

                    if (paramInfo.Length == 0)
                    {
                        object[] objParams = new object[0];

                        object o = c.Invoke(objParams);

                        if (o != null && o is Item)
                        {
                            Item newItem = (Item)o;

                            CommandLogging.WriteLine(from, "{0} {1} duping successfull, new ItemID {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(newItem));

                            if (newItem is Container)
                            {
                                // If a container gets duplicated it needs to get emptied.
                                // ("BagOfReagents" problem, items which create content in the constructors have unwanted
                                // contents after duping under certain circumstances.)
                                Item[] found;

                                found = ((Container)newItem).FindItemsByType(typeof(Item), false);

                                for (int j = 0; j < found.Length; j++)
                                {
                                    found[j].Delete();
                                }
                                // end emptying

                                Item[] items = ((Container)src).FindItemsByType(typeof(Item), false);

                                for (int i = 0; i < items.Length; i++)
                                {
                                    CommandLogging.WriteLine(from, "{0} {1} duping child {2} of {3}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(items[i]), CommandLogging.Format(src));
                                    InternalDupe(items[i], (Container)newItem, from);
                                }
                            }

                            CopyProperties(newItem, src);

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

                            newItem.InvalidateProperties();
                        }
                        else
                        {
                            from.SendMessage("Target is not a valid item anymore or vanished before the dupe.");
                        }
                    }
                }
            }
Пример #11
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);

            ArrayList toDelete = new ArrayList();

            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 (object 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)
            {
                if (toDelete[i] is Item)
                {
                    ((Item)toDelete[i]).Delete();
                }
                else if (toDelete[i] is Mobile)
                {
                    ((Mobile)toDelete[i]).Delete();
                }
            }
        }