예제 #1
0
파일: Engine.cs 프로젝트: Skinny1001/PlayUO
 public static void SendDelayedPacket(int delay, params Packet[] packets)
 {
     if (RealGMPrivs)
     {
         delay = 0;
     }
     Timer timer = new Timer(new OnTick(Engine.DelayedPackets_OnTick), delay, 1);
     timer.SetTag("Packets", packets);
     timer.Start(false);
 }
예제 #2
0
파일: Engine.cs 프로젝트: Skinny1001/PlayUO
        public static void commandEntered(string cmd)
        {
            if ((cmd.Length > 0) && !m_SayMacro)
            {
                m_LastCommand = cmd;
            }
            if (m_Prompt != null)
            {
                m_Prompt.OnReturn(cmd);
                m_Prompt = null;
            }
            else
            {
                cmd = cmd.Trim();
                if (cmd.Length > 0)
                {
                    int count = m_Plugins.Count;
                    for (int i = 0; i < count; i++)
                    {
                        Plugin plugin = (Plugin) m_Plugins[i];
                        if (plugin.OnCommandEntered(cmd))
                        {
                            return;
                        }
                    }
                    if (cmd.StartsWith("--") && UOAM.Connected)
                    {
                        UOAM.Chat(cmd.Substring(2));
                    }
                    else if (!cmd.StartsWith("/"))
                    {
                        if (!cmd.StartsWith(". "))
                        {
                            Network.Send(new PUnicodeSpeech(cmd));
                        }
                        else
                        {
                            object obj2;
                            string[] strArray = cmd.Substring(". ".Length).Split(new char[] { ' ' });
                            if (((strArray.Length > 0) && ((obj2 = strArray[0].ToLower()) != null)) && ((obj2 = <PrivateImplementationDetails>.$$method0x60008d2-1[obj2]) != null))
                            {
                                switch (((int) obj2))
                                {
                                    case 0:
                                    {
                                        Gump g = Gumps.FindGumpByGUID("Volume");
                                        if (g != null)
                                        {
                                            Gumps.Destroy(g);
                                            break;
                                        }
                                        Gumps.Desktop.Children.Add(new GVolumeControl());
                                        break;
                                    }
                                    case 1:
                                    {
                                        int num4 = 0;
                                        try
                                        {
                                            if (strArray.Length > 1)
                                            {
                                                num4 = Convert.ToInt32(strArray[1]);
                                            }
                                        }
                                        catch
                                        {
                                            num4 = 0;
                                        }
                                        if (num4 < 1)
                                        {
                                            AddTextMessage("Usage: DefaultRegs <amount>");
                                        }
                                        else
                                        {
                                            World.CharData.DefaultRegs = num4;
                                            AddTextMessage(string.Format("Default reagent amount changed to {0}.", num4));
                                        }
                                        break;
                                    }
                                    case 2:
                                    {
                                        bool flag = !World.CharData.AlwaysRun;
                                        if ((strArray.Length <= 1) || !(strArray[0].ToLower() == "on"))
                                        {
                                            if ((strArray.Length > 1) && (strArray[0].ToLower() == "off"))
                                            {
                                                flag = false;
                                            }
                                        }
                                        else
                                        {
                                            flag = true;
                                        }
                                        World.CharData.AlwaysRun = flag;
                                        return;
                                    }
                                    case 3:
                                        TargetHandler = new SetRegBagTargetHandler();
                                        AddTextMessage("Target your destination reagent container.");
                                        break;

                                    case 4:
                                        TargetHandler = new SetRegStockTargetHandler();
                                        AddTextMessage("Target your source reagent container.");
                                        break;

                                    case 5:
                                    {
                                        int num5 = 0;
                                        foreach (Mobile mobile2 in World.Mobiles.Values)
                                        {
                                            if ((World.InRange(mobile2) && mobile2.Visible) && mobile2.m_IsFactionGuard)
                                            {
                                                mobile2.QueryStats();
                                                mobile2.OpenStatus(false);
                                                if (mobile2.StatusBar != null)
                                                {
                                                    mobile2.StatusBar.Gump.X = (GameX + 10) + ((num5 / 6) * (mobile2.StatusBar.Gump.Width + 10));
                                                    mobile2.StatusBar.Gump.Y = (GameY + 10) + ((num5 % 6) * (mobile2.StatusBar.Gump.Height + 10));
                                                    num5++;
                                                }
                                            }
                                        }
                                        break;
                                    }
                                    case 6:
                                    {
                                        Mobile player = World.Player;
                                        if (player != null)
                                        {
                                            for (int j = 0; j < Multis.Items.Count; j++)
                                            {
                                                Item item = (Item) Multis.Items[j];
                                                if (item.InWorld && item.IsMulti)
                                                {
                                                    CustomMultiEntry customMulti = CustomMultiLoader.GetCustomMulti(item.Serial, item.Revision);
                                                    Multi m = null;
                                                    if (customMulti != null)
                                                    {
                                                        m = customMulti.Multi;
                                                    }
                                                    if (m == null)
                                                    {
                                                        m = item.Multi;
                                                    }
                                                    if ((m != null) && Multis.IsInMulti(item, m, player.X, player.Y, player.Z))
                                                    {
                                                        ArrayList dataStore = GetDataStore();
                                                        foreach (Mobile mobile4 in World.Mobiles.Values)
                                                        {
                                                            switch (mobile4.Notoriety)
                                                            {
                                                                case Notoriety.Attackable:
                                                                case Notoriety.Criminal:
                                                                case Notoriety.Enemy:
                                                                case Notoriety.Murderer:
                                                                    if ((((mobile4 != player) && !mobile4.Flags[MobileFlag.YellowHits]) && (!mobile4.m_IsFriend && mobile4.Visible)) && World.InRange(mobile4))
                                                                    {
                                                                        int xReal = mobile4.XReal;
                                                                        int yReal = mobile4.YReal;
                                                                        int zReal = mobile4.ZReal;
                                                                        if (Multis.RunUO_IsInside(item, m, xReal, yReal, zReal))
                                                                        {
                                                                            dataStore.Add(mobile4);
                                                                        }
                                                                    }
                                                                    break;
                                                            }
                                                        }
                                                        if (dataStore.Count > 0)
                                                        {
                                                            dataStore.Sort(TargetSorter.Comparer);
                                                            Mobile mobile5 = (Mobile) dataStore[0];
                                                            Network.Send(new PUnicodeSpeech("; i ban thee"));
                                                            Network.Send(new PTarget_Spoof(0, -559038737, ServerTargetFlags.None, mobile5.Serial, mobile5.X, mobile5.Y, mobile5.Z, mobile5.Body));
                                                            PacketHandlers.m_CancelTarget = true;
                                                        }
                                                        ReleaseDataStore(dataStore);
                                                        break;
                                                    }
                                                }
                                            }
                                            break;
                                        }
                                        break;
                                    }
                                    case 7:
                                    {
                                        if (strArray.Length != 2)
                                        {
                                            break;
                                        }
                                        int level = m_Multis.m_Level;
                                        switch (strArray[1].ToLower())
                                        {
                                            case "0":
                                            case "5":
                                            case "off":
                                                level = 5;
                                                break;

                                            case "1":
                                                level = 1;
                                                break;

                                            case "2":
                                                level = 2;
                                                break;

                                            case "3":
                                                level = 3;
                                                break;

                                            case "4":
                                                level = 4;
                                                break;

                                            case "up":
                                                level++;
                                                break;

                                            case "down":
                                                level--;
                                                break;
                                        }
                                        if (level > 5)
                                        {
                                            level = 5;
                                        }
                                        else if (level < 1)
                                        {
                                            level = 1;
                                        }
                                        if (m_Multis.m_Level != level)
                                        {
                                            m_Multis.m_Level = level;
                                            Map.Invalidate();
                                        }
                                        return;
                                    }
                                    case 8:
                                    {
                                        int defaultRegs = World.CharData.DefaultRegs;
                                        try
                                        {
                                            if (strArray.Length > 1)
                                            {
                                                defaultRegs = Convert.ToInt32(strArray[1]);
                                            }
                                        }
                                        catch
                                        {
                                            defaultRegs = World.CharData.DefaultRegs;
                                        }
                                        Item stock = World.CharData.Stock;
                                        Item regBag = World.CharData.RegBag;
                                        if ((stock != null) && (regBag != null))
                                        {
                                            MakeRegsTargetHandler.Transfer(stock, regBag, defaultRegs);
                                        }
                                        else
                                        {
                                            TargetHandler = new MakeRegsTargetHandler(defaultRegs, stock, regBag);
                                            if (stock == null)
                                            {
                                                AddTextMessage("Target your source reagent container.");
                                            }
                                            else
                                            {
                                                AddTextMessage("Target your destination reagent container.");
                                            }
                                        }
                                        break;
                                    }
                                    case 9:
                                        if (m_QamList.Count <= 0)
                                        {
                                            AddTextMessage("There are no item movements currently queued.");
                                            break;
                                        }
                                        m_QamList.Clear();
                                        if (m_QamTimer != null)
                                        {
                                            m_QamTimer.Stop();
                                        }
                                        m_QamTimer = null;
                                        AddTextMessage("The item movement queue has been cleared.");
                                        break;

                                    case 10:
                                        TargetHandler = new FriendTargetHandler();
                                        AddTextMessage("Target the player to toggle friendship status.", DefaultFont, Hues.Load(0x59));
                                        break;

                                    case 11:
                                        World.CharData.AutoPickup = !World.CharData.AutoPickup;
                                        AddTextMessage(World.CharData.AutoPickup ? "You like good stuff." : "You hate things.");
                                        break;

                                    case 12:
                                        World.CharData.Archery = !World.CharData.Archery;
                                        AddTextMessage(World.CharData.Archery ? "You are an archer." : "You aren't an archer.");
                                        break;

                                    case 13:
                                        World.CharData.LootGold = !World.CharData.LootGold;
                                        AddTextMessage(World.CharData.LootGold ? "You like gold." : "You hate gold.");
                                        break;

                                    case 14:
                                    {
                                        Mobile mob = World.Player;
                                        if (mob != null)
                                        {
                                            string mobilePath = Macros.GetMobilePath(mob);
                                            string path = FileManager.BasePath(string.Format("Data/Plugins/Macros/{0}.txt", mobilePath));
                                            string str8 = "Macros";
                                            string str9 = FileManager.BasePath(string.Format("Data/Plugins/Macros/{0}.txt", str8));
                                            if (GMacroEditorForm.IsOpen)
                                            {
                                                AddTextMessage("Close the macro editor before running this command.");
                                            }
                                            else if (File.Exists(path))
                                            {
                                                AddTextMessage("Macro definitions unique to your character were already found.");
                                            }
                                            else if (!File.Exists(str9))
                                            {
                                                AddTextMessage("No default macro definnitions were found.");
                                            }
                                            else
                                            {
                                                File.Copy(str9, path);
                                                Macros.Load();
                                                AddTextMessage("Default macro definitions have been copied. Any macro changes you make will now be unique to this character.");
                                            }
                                            break;
                                        }
                                        break;
                                    }
                                    case 15:
                                        TargetHandler = new NullTargetHandler();
                                        break;

                                    case 0x10:
                                    {
                                        Mobile p = World.Player;
                                        if (p != null)
                                        {
                                            bool flag2 = false;
                                            foreach (Mobile mobile8 in World.Mobiles.Values)
                                            {
                                                if (mobile8.InSquareRange(p, 8) && ((mobile8.Body == 400) || (mobile8.Body == 0x191)))
                                                {
                                                    Item item4 = mobile8.FindEquip(Layer.Shoes);
                                                    if (((item4 != null) && (item4.Hue == 0)) && (((item4.ID == 0x1711) || (item4.ID == 0x170b)) || (item4.ID == 0x170c)))
                                                    {
                                                        item4 = mobile8.FindEquip(Layer.TwoHanded);
                                                        if (((item4 != null) && (item4.Hue == 0)) && (((item4.ID == 0xe89) || (item4.ID == 0xe8a)) || ((item4.ID == 0xe81) || (item4.ID == 0xe82))))
                                                        {
                                                            m_ContextQueue = 0x17d7;
                                                            m_BuyHorse = mobile8;
                                                            Network.Send(new PPopupRequest(mobile8));
                                                            mobile8.AddTextMessage("Vendor", "Buying horse.", DefaultFont, Hues.Load(0x59), false);
                                                            flag2 = true;
                                                            break;
                                                        }
                                                    }
                                                }
                                            }
                                            if (!flag2)
                                            {
                                                AddTextMessage("Vendor not found.", DefaultFont, Hues.Load(0x26));
                                            }
                                            return;
                                        }
                                        break;
                                    }
                                    case 0x11:
                                    {
                                        Item item5 = World.FindItem(new PlayerDistanceValidator(new ItemIDValidator(new int[] { 0xf6c }), 1));
                                        if (item5 != null)
                                        {
                                            item5.Use();
                                            item5.AddTextMessage("Moongate", "Using.", DefaultFont, Hues.Load(0x59), false);
                                            break;
                                        }
                                        AddTextMessage("Moongate not found.", DefaultFont, Hues.Load(0x26));
                                        break;
                                    }
                                    case 0x12:
                                    {
                                        Gump drag = Gumps.Drag;
                                        if (!(drag is GDraggedItem))
                                        {
                                            m_LeapFrog = null;
                                            AddTextMessage("You are not holding an item. Leapfrog cleared.");
                                            break;
                                        }
                                        m_LeapFrog = ((GDraggedItem) drag).Item;
                                        AddTextMessage("Item set.");
                                        break;
                                    }
                                    case 0x13:
                                    {
                                        IItemValidator check = new PlayerDistanceValidator(new ItemIDValidator(new int[] { 0x2006 }), 2);
                                        Item[] itemArray = World.FindItems(check);
                                        ArrayList list2 = new ArrayList();
                                        AosAppraiser instance = LootAppraiser.Instance;
                                        for (int k = 0; k < itemArray.Length; k++)
                                        {
                                            Item item6 = itemArray[k];
                                            if ((item6.LastTextHue == null) || ((item6.LastTextHue.HueID() & 0x7fff) != 0x59))
                                            {
                                                AosAppraiser.m_BlueCorpse = false;
                                                ArrayList items = item6.Items;
                                                for (int n = 0; n < items.Count; n++)
                                                {
                                                    Item item7 = (Item) items[n];
                                                    Appraisal appraisal = instance.Appraise(item7);
                                                    if (appraisal != null)
                                                    {
                                                        list2.Add(appraisal);
                                                    }
                                                }
                                            }
                                        }
                                        if (list2.Count > 0)
                                        {
                                            list2.Sort();
                                            Appraisal appraisal2 = (Appraisal) list2[0];
                                            Item item8 = appraisal2.Item;
                                            ObjectPropertyList propertyList = item8.PropertyList;
                                            string text = null;
                                            if (propertyList.Properties.Length > 0)
                                            {
                                                text = propertyList.Properties[0].Text;
                                            }
                                            if ((text == null) || (text == ""))
                                            {
                                                text = Localization.GetString(0xf9060 + (item8.ID & 0x3fff));
                                            }
                                            string str11 = string.Format("Looting {0}.", text);
                                            if (list2.Count > 1)
                                            {
                                                str11 = string.Format("{0} There are {1} other valued item{2} to loot.", str11, list2.Count - 1, (list2.Count == 2) ? "" : "s");
                                            }
                                            AddTextMessage(str11, DefaultFont, Hues.Load(0x35));
                                            Mobile mobile9 = World.Player;
                                            if (mobile9 != null)
                                            {
                                                Network.Send(new PPickupItem(item8, item8.Amount));
                                                Network.Send(new PDropItem(item8.Serial, -1, -1, 0, mobile9.Serial));
                                            }
                                        }
                                        else
                                        {
                                            AddTextMessage("Nothing was found to loot.", DefaultFont, Hues.Load(0x22));
                                        }
                                        break;
                                    }
                                    case 20:
                                    {
                                        IItemValidator validator2 = new PlayerDistanceValidator(new ItemIDValidator(new int[] { 0x2006 }), 2);
                                        Item[] itemArray2 = World.FindItems(validator2);
                                        ArrayList list5 = new ArrayList();
                                        AosAppraiser appraiser2 = LootAppraiser.Instance;
                                        for (int num14 = 0; num14 < itemArray2.Length; num14++)
                                        {
                                            Item item9 = itemArray2[num14];
                                            if ((item9.LastTextHue != null) && ((item9.LastTextHue.HueID() & 0x7fff) == 0x59))
                                            {
                                                AosAppraiser.m_BlueCorpse = true;
                                            }
                                            else
                                            {
                                                AosAppraiser.m_BlueCorpse = false;
                                            }
                                            ArrayList list6 = item9.Items;
                                            for (int num15 = 0; num15 < list6.Count; num15++)
                                            {
                                                Item item10 = (Item) list6[num15];
                                                Appraisal appraisal3 = appraiser2.Appraise(item10);
                                                if ((appraisal3 != null) && !appraisal3.IsWorthless)
                                                {
                                                    list5.Add(appraisal3);
                                                }
                                            }
                                        }
                                        if (list5.Count > 0)
                                        {
                                            list5.Sort();
                                            Appraisal appraisal4 = (Appraisal) list5[0];
                                            Item item11 = appraisal4.Item;
                                            ObjectPropertyList list7 = item11.PropertyList;
                                            string str12 = null;
                                            if (list7.Properties.Length > 0)
                                            {
                                                str12 = list7.Properties[0].Text;
                                            }
                                            if ((str12 == null) || (str12 == ""))
                                            {
                                                str12 = Localization.GetString(0xf9060 + (item11.ID & 0x3fff));
                                            }
                                            string str13 = string.Format("Looting {0}.", str12);
                                            if (list5.Count > 1)
                                            {
                                                str13 = string.Format("{0} There are {1} other valued item{2} to loot.", str13, list5.Count - 1, (list5.Count == 2) ? "" : "s");
                                            }
                                            AddTextMessage(str13, DefaultFont, Hues.Load(0x35));
                                            Mobile mobile10 = World.Player;
                                            if (mobile10 != null)
                                            {
                                                Network.Send(new PPickupItem(item11, item11.Amount));
                                                Network.Send(new PDropItem(item11.Serial, -1, -1, 0, mobile10.Serial));
                                            }
                                        }
                                        else
                                        {
                                            AddTextMessage("Nothing was found to loot.", DefaultFont, Hues.Load(0x22));
                                        }
                                        break;
                                    }
                                    case 0x15:
                                    {
                                        IPAddress address;
                                        int num16;
                                        if (strArray.Length != 5)
                                        {
                                            AddTextMessage("Usage: uoam <name> <password> <address> <port>");
                                            break;
                                        }
                                        string username = strArray[1];
                                        string password = strArray[2];
                                        try
                                        {
                                            address = IPAddress.Parse(strArray[3]);
                                            num16 = Convert.ToInt32(strArray[4]);
                                        }
                                        catch
                                        {
                                            AddTextMessage("Usage: uoam <name> <password> <address> <port>");
                                            break;
                                        }
                                        UOAM.Connect(username, password, address, num16);
                                        break;
                                    }
                                    case 0x16:
                                    {
                                        MapPackage cache = Map.GetCache();
                                        if (cache.cells != null)
                                        {
                                            Mobile mobile11 = World.Player;
                                            if (mobile11 != null)
                                            {
                                                int num17 = mobile11.X - cache.CellX;
                                                int num18 = mobile11.Y - cache.CellY;
                                                if (((num17 >= 0) && (num17 < cache.cells.GetLength(0))) && ((num18 >= 0) && (num18 < cache.cells.GetLength(1))))
                                                {
                                                    ArrayList list8 = cache.cells[num17, num18];
                                                    if (list8 != null)
                                                    {
                                                        if (list8.Count <= 0)
                                                        {
                                                            AddTextMessage("Nothing there.");
                                                            break;
                                                        }
                                                        ICell cell = (ICell) list8[list8.Count - 1];
                                                        if (!(cell is MobileCell))
                                                        {
                                                            if (cell is DynamicItem)
                                                            {
                                                                Target(((DynamicItem) cell).m_Item);
                                                            }
                                                            else if (cell is StaticItem)
                                                            {
                                                                Target(new StaticTarget(mobile11.X, mobile11.Y, ((StaticItem) cell).m_Z, ((StaticItem) cell).m_RealID, ((StaticItem) cell).m_RealID, ((StaticItem) cell).m_Hue));
                                                            }
                                                            else if (cell is LandTile)
                                                            {
                                                                Target(new LandTarget(mobile11.X, mobile11.Y, ((LandTile) cell).m_Z));
                                                            }
                                                            break;
                                                        }
                                                        Target(((MobileCell) cell).m_Mobile);
                                                    }
                                                }
                                            }
                                        }
                                        break;
                                    }
                                    case 0x17:
                                        m_AlternateFont = !m_AlternateFont;
                                        AddTextMessage(string.Format("Alternate font is now {0}.", m_AlternateFont ? "on" : "off"));
                                        break;

                                    case 0x18:
                                    {
                                        bool flag3 = !m_Sounds.Enabled;
                                        try
                                        {
                                            flag3 = strArray[1].ToLower() != "off";
                                        }
                                        catch
                                        {
                                            flag3 = !m_Sounds.Enabled;
                                        }
                                        m_Sounds.Enabled = flag3;
                                        AddTextMessage(string.Format("Sounds are now {0}.", flag3 ? "on" : "off"));
                                        break;
                                    }
                                    case 0x19:
                                    {
                                        bool flag4 = !World.CharData.QueueTargets;
                                        try
                                        {
                                            flag4 = strArray[1].ToLower() != "off";
                                        }
                                        catch
                                        {
                                            flag4 = !World.CharData.QueueTargets;
                                        }
                                        World.CharData.QueueTargets = flag4;
                                        AddTextMessage(string.Format("Target queueing is now {0}.", flag4 ? "on" : "off"));
                                        break;
                                    }
                                    case 0x1a:
                                    {
                                        IEnumerator enumerator = World.Mobiles.Values.GetEnumerator();
                                        int num19 = 0;
                                        while (enumerator.MoveNext())
                                        {
                                            Mobile current = (Mobile) enumerator.Current;
                                            if (((current.Visible && (current.Notoriety == Notoriety.Murderer)) && (!current.Human && !current.Ghost)) && World.InRange(current))
                                            {
                                                Timer timer = new Timer(new OnTick(Engine.DelayedPackets_OnTick), num19++ * 0x4e2, 1);
                                                timer.SetTag("Packets", new Packet[] { new PAttackRequest(current) });
                                                timer.Start(false);
                                            }
                                        }
                                        break;
                                    }
                                    case 0x1b:
                                        TargetHandler = new MoveTargetHandler();
                                        AddTextMessage("Target one of the items to move.");
                                        break;

                                    case 0x1c:
                                        TargetHandler = new OverrideHueTargetHandler(0x489, "Inflame request canceled.");
                                        AddTextMessage("Target an item.");
                                        break;

                                    case 0x1d:
                                        TargetHandler = new OverrideHueTargetHandler(-1, "Douse request canceled.");
                                        AddTextMessage("Target an item.");
                                        break;

                                    case 30:
                                    {
                                        NotoQueryType on = (NotoQueryType) ((1 + World.CharData.NotoQuery) % 3);
                                        try
                                        {
                                            switch (strArray[1].ToLower())
                                            {
                                                case "on":
                                                    on = NotoQueryType.On;
                                                    break;

                                                case "off":
                                                    on = NotoQueryType.Off;
                                                    break;

                                                case "smart":
                                                    on = NotoQueryType.Smart;
                                                    break;
                                            }
                                        }
                                        catch
                                        {
                                        }
                                        World.CharData.NotoQuery = on;
                                        AddTextMessage(string.Format("Notoriety query is now {0}.", on.ToString().ToLower()));
                                        break;
                                    }
                                    case 0x1f:
                                        Network.Send(new PWrestleDisarm());
                                        break;

                                    case 0x20:
                                        Network.Send(new PWrestleStun());
                                        break;

                                    case 0x21:
                                    {
                                        bool flag5 = !GFader.Fade;
                                        try
                                        {
                                            flag5 = strArray[1].ToLower() != "off";
                                        }
                                        catch
                                        {
                                            flag5 = !GFader.Fade;
                                        }
                                        GFader.Fade = flag5;
                                        AddTextMessage(string.Format("Interface fading is now {0}.", flag5 ? "on" : "off"));
                                        break;
                                    }
                                    case 0x22:
                                        TargetHandler = new DragToBagTargetHandler(false);
                                        AddTextMessage("Target one of the items to move.");
                                        break;

                                    case 0x23:
                                        TargetHandler = new DragToBagTargetHandler(true);
                                        AddTextMessage("Target one of the items to click and move.");
                                        break;

                                    case 0x24:
                                    {
                                        int xOffset = 0;
                                        int yOffset = 0;
                                        if ((strArray.Length == 3) || (strArray.Length == 1))
                                        {
                                            if (strArray.Length == 3)
                                            {
                                                try
                                                {
                                                    xOffset = Convert.ToInt32(strArray[1]);
                                                }
                                                catch
                                                {
                                                }
                                                try
                                                {
                                                    yOffset = Convert.ToInt32(strArray[2]);
                                                }
                                                catch
                                                {
                                                }
                                            }
                                            TargetHandler = new BringToTargetHandler(xOffset, yOffset);
                                            AddTextMessage("Target the destination item.");
                                        }
                                        else
                                        {
                                            AddTextMessage("Format: bringto [x y]");
                                        }
                                        break;
                                    }
                                    case 0x25:
                                        Ignore();
                                        break;

                                    case 0x26:
                                        TargetHandler = new RemoveTargetHandler();
                                        AddTextMessage("Remove what?");
                                        break;

                                    case 0x27:
                                        TargetHandler = new StackTargetHandler();
                                        AddTextMessage("Target the destination item.");
                                        break;

                                    case 40:
                                        TargetHandler = new RegDropTargetHandler();
                                        AddTextMessage("Target the destination container.");
                                        break;

                                    case 0x29:
                                        TargetHandler = new TurnTargetHandler();
                                        AddTextMessage("Turn to where?");
                                        break;

                                    case 0x2a:
                                    {
                                        bool flag6 = !NewConfig.SmoothWalk;
                                        try
                                        {
                                            flag6 = strArray[1].ToLower() != "off";
                                        }
                                        catch
                                        {
                                            flag6 = !NewConfig.SmoothWalk;
                                        }
                                        NewConfig.SmoothWalk = flag6;
                                        AddTextMessage(string.Format("Smooth walking is now {0}.", flag6 ? "on" : "off"));
                                        break;
                                    }
                                    case 0x2b:
                                    {
                                        int num22 = 100;
                                        try
                                        {
                                            num22 = Convert.ToInt32(cmd.Split(new char[] { ' ' })[1]);
                                        }
                                        catch
                                        {
                                            num22 = 100;
                                        }
                                        Timer timer2 = new Timer(new OnTick(Engine.TimeRefresh_OnTick), 1, 1);
                                        timer2.SetTag("Frames", num22);
                                        timer2.Start(false);
                                        break;
                                    }
                                    case 0x2c:
                                    {
                                        string str16 = null;
                                        try
                                        {
                                            str16 = strArray[1];
                                        }
                                        catch
                                        {
                                            AddTextMessage("Format: music <on | off | stop>");
                                            break;
                                        }
                                        switch (str16.ToLower())
                                        {
                                            case "on":
                                                NewConfig.PlayMusic = true;
                                                return;

                                            case "off":
                                                NewConfig.PlayMusic = false;
                                                Music.Stop();
                                                return;

                                            case "stop":
                                                Music.Stop();
                                                return;
                                        }
                                        AddTextMessage("Format: music <on | off | stop>");
                                        break;
                                    }
                                    case 0x2d:
                                        TargetHandler = new TraceTargetHandler();
                                        AddTextMessage("Target the dynamic item or mobile to trace.");
                                        break;

                                    case 0x2e:
                                        TargetHandler = new ExportTargetHandler();
                                        AddTextMessage("Target the first location of a bounding box.");
                                        break;

                                    case 0x2f:
                                    {
                                        if (!GMPrivs)
                                        {
                                            AddTextMessage("You do not have access to this command.");
                                            break;
                                        }
                                        string str17 = null;
                                        try
                                        {
                                            str17 = strArray[1];
                                        }
                                        catch
                                        {
                                            AddTextMessage("Format: ack <number>");
                                            break;
                                        }
                                        try
                                        {
                                            m_WalkAckSync = Convert.ToInt32(str17);
                                        }
                                        catch
                                        {
                                            AddTextMessage("Format: ack <number>");
                                            break;
                                        }
                                        AddTextMessage(string.Format("Maximum outstanding walk requests: {0}", m_WalkAckSync));
                                        break;
                                    }
                                    case 0x30:
                                    {
                                        if (!GMPrivs)
                                        {
                                            AddTextMessage("You do not have access to this command.");
                                            break;
                                        }
                                        string str18 = null;
                                        try
                                        {
                                            str18 = strArray[1];
                                        }
                                        catch
                                        {
                                            AddTextMessage("Format: runspeed <number>");
                                            break;
                                        }
                                        try
                                        {
                                            m_RunSpeed = ((float) Convert.ToInt32(str18)) / 1000f;
                                        }
                                        catch
                                        {
                                            AddTextMessage("Format: runspeed <number>");
                                            break;
                                        }
                                        AddTextMessage(string.Format("Run speed set to: {0} seconds", m_RunSpeed));
                                        break;
                                    }
                                    case 0x31:
                                    {
                                        if (!GMPrivs)
                                        {
                                            AddTextMessage("You do not have access to this command.");
                                            break;
                                        }
                                        string str19 = null;
                                        try
                                        {
                                            str19 = strArray[1];
                                        }
                                        catch
                                        {
                                            AddTextMessage("Format: walkspeed <number>");
                                            break;
                                        }
                                        try
                                        {
                                            m_WalkSpeed = ((float) Convert.ToInt32(str19)) / 1000f;
                                        }
                                        catch
                                        {
                                            AddTextMessage("Format: walkspeed <number>");
                                            break;
                                        }
                                        AddTextMessage(string.Format("Walk speed set to: {0} seconds", m_WalkSpeed));
                                        break;
                                    }
                                    case 50:
                                    {
                                        if (!GMPrivs)
                                        {
                                            AddTextMessage("You do not have access to this command.");
                                            break;
                                        }
                                        string str20 = null;
                                        try
                                        {
                                            str20 = strArray[1];
                                        }
                                        catch
                                        {
                                        }
                                        if (str20 == "on")
                                        {
                                            m_Weather = true;
                                            AddTextMessage("Weather turned on.");
                                        }
                                        else if (str20 == "off")
                                        {
                                            m_Weather = false;
                                            PacketHandlers.ClearWeather();
                                            AddTextMessage("Weather turned off.");
                                        }
                                        else
                                        {
                                            m_Weather = !m_Weather;
                                            if (!m_Weather)
                                            {
                                                PacketHandlers.ClearWeather();
                                            }
                                            AddTextMessage(string.Format("Weather turned {0}.", m_Weather ? "on" : "off"));
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        switch (Party.State)
                        {
                            case PartyState.Alone:
                                if (!cmd.ToLower().StartsWith("/add"))
                                {
                                    AddTextMessage(string.Format("Note to self: {0}", cmd.Substring(1)), DefaultFont, Hues.Load(0x3b2));
                                    break;
                                }
                                Network.Send(new PParty_AddMember());
                                break;

                            case PartyState.Joining:
                            {
                                string str2 = cmd.ToLower();
                                if (!str2.StartsWith("/accept"))
                                {
                                    if (str2.StartsWith("/decline"))
                                    {
                                        Network.Send(new PParty_Decline(Party.Leader));
                                    }
                                    else
                                    {
                                        AddTextMessage("Use '/accept' or '/decline'.", DefaultFont, Hues.Load(0x3b2));
                                    }
                                    break;
                                }
                                Network.Send(new PParty_Accept(Party.Leader));
                                break;
                            }
                            case PartyState.Joined:
                            {
                                string str3 = cmd.ToLower();
                                if (!Party.IsLeader || !str3.StartsWith("/add"))
                                {
                                    if (Party.IsLeader && str3.StartsWith("/rem"))
                                    {
                                        Network.Send(new PParty_RemoveMember());
                                    }
                                    else if (str3.StartsWith("/quit"))
                                    {
                                        Network.Send(new PParty_Quit());
                                    }
                                    else if (str3.StartsWith("/loot on"))
                                    {
                                        Network.Send(new PParty_SetCanLoot(true));
                                    }
                                    else if (str3.StartsWith("/loot off"))
                                    {
                                        Network.Send(new PParty_SetCanLoot(false));
                                    }
                                    else if (str3.StartsWith("/loot"))
                                    {
                                        AddTextMessage("Use '/loot on' or '/loot off'.");
                                    }
                                    else if (Party.Members.Length > 1)
                                    {
                                        if ((cmd.Length >= 2) && char.IsDigit(cmd, 1))
                                        {
                                            try
                                            {
                                                int index = Convert.ToInt32(cmd.Substring(1, 1)) - 1;
                                                if ((index >= 0) && (index < Party.Members.Length))
                                                {
                                                    if (index == Party.Index)
                                                    {
                                                        AddTextMessage(string.Format("Note to self: {0}", cmd.Substring(2)), DefaultFont, Hues.Load(0x3b2));
                                                    }
                                                    else
                                                    {
                                                        string str4;
                                                        Mobile mobile = World.Player;
                                                        if (((mobile == null) || ((str4 = mobile.Name) == null)) || ((str4 = str4.Trim()).Length <= 0))
                                                        {
                                                            str4 = "You";
                                                        }
                                                        AddTextMessage(string.Format("<{0}> {1}", str4, cmd.Substring(2)), DefaultFont, Hues.Load(World.CharData.WhisperHue));
                                                        Network.Send(new PParty_PrivateMessage(Party.Members[index], cmd.Substring(2)));
                                                    }
                                                    break;
                                                }
                                            }
                                            catch
                                            {
                                            }
                                        }
                                        Network.Send(new PParty_PublicMessage(cmd.Substring(1)));
                                    }
                                    else
                                    {
                                        AddTextMessage(string.Format("Note to self: {0}", cmd.Substring(1)), DefaultFont, Hues.Load(0x3b2));
                                    }
                                    break;
                                }
                                Network.Send(new PParty_AddMember());
                                break;
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
파일: Engine.cs 프로젝트: Skinny1001/PlayUO
 public static void MouseMoveQueue()
 {
     if (m_EventOk)
     {
         MouseEventArgs lastMouseArgs = m_LastMouseArgs;
         m_MouseMoved = false;
         pointingDir = GetDirection(lastMouseArgs.X, lastMouseArgs.Y, ref m_dMouse);
         if ((m_xMouse != lastMouseArgs.X) || (m_yMouse != lastMouseArgs.Y))
         {
             m_Redraw = true;
         }
         m_xMouse = lastMouseArgs.X;
         m_yMouse = lastMouseArgs.Y;
         if (!Gumps.MouseMove(lastMouseArgs.X, lastMouseArgs.Y, lastMouseArgs.Button))
         {
             if (!m_Locked && amMoving)
             {
                 GObjectProperties.Hide();
                 if (m_PopupDelay != null)
                 {
                     m_PopupDelay.Stop();
                 }
                 m_PopupDelay = null;
                 movingDir = pointingDir;
             }
             else if (amMoving && m_Ingame)
             {
                 GObjectProperties.Hide();
                 if (m_PopupDelay != null)
                 {
                     m_PopupDelay.Stop();
                 }
                 m_PopupDelay = null;
             }
             else if (Gumps.Drag != null)
             {
                 GObjectProperties.Hide();
                 if (m_PopupDelay != null)
                 {
                     m_PopupDelay.Stop();
                 }
                 m_PopupDelay = null;
             }
             else if ((lastMouseArgs.Button == MouseButtons.None) && (World.Serial != 0))
             {
                 if (Features.AOS)
                 {
                     short tileX = 0;
                     short tileY = 0;
                     ICell cell = Renderer.FindTileFromXY(m_xMouse, m_yMouse, ref tileX, ref tileY, true);
                     if ((World.Player.Flags[MobileFlag.Warmode] && (cell != null)) && (cell.CellType == typeof(MobileCell)))
                     {
                         m_Highlight = ((MobileCell) cell).m_Mobile;
                     }
                     else
                     {
                         m_Highlight = null;
                     }
                     if (cell is DynamicItem)
                     {
                         Item item = ((DynamicItem) cell).m_Item;
                         if (item.Flags[ItemFlag.CanMove] || (Map.GetWeight(item.ID) < 0xff))
                         {
                             if (item.PropertyList == null)
                             {
                                 item.QueryProperties();
                                 GObjectProperties.Hide();
                                 if (m_PopupDelay != null)
                                 {
                                     m_PopupDelay.Stop();
                                 }
                                 m_PopupDelay = null;
                             }
                             else if ((GObjectProperties.Instance == null) || (GObjectProperties.Instance.Object != item))
                             {
                                 if (m_PopupDelay == null)
                                 {
                                     m_PopupDelay = new Timer(new OnTick(Engine.PopupDelay_OnTick), 250);
                                     m_PopupDelay.SetTag("object", item);
                                     m_PopupDelay.Start(false);
                                 }
                                 else
                                 {
                                     m_PopupDelay.SetTag("object", item);
                                 }
                             }
                         }
                         else
                         {
                             GObjectProperties.Hide();
                             if (m_PopupDelay != null)
                             {
                                 m_PopupDelay.Stop();
                             }
                             m_PopupDelay = null;
                         }
                     }
                     else if (cell is MobileCell)
                     {
                         Mobile mobile = ((MobileCell) cell).m_Mobile;
                         if (mobile.PropertyList == null)
                         {
                             mobile.QueryProperties();
                             GObjectProperties.Hide();
                             if (m_PopupDelay != null)
                             {
                                 m_PopupDelay.Stop();
                             }
                             m_PopupDelay = null;
                         }
                         else if ((GObjectProperties.Instance == null) || (GObjectProperties.Instance.Object != mobile))
                         {
                             if (m_PopupDelay == null)
                             {
                                 m_PopupDelay = new Timer(new OnTick(Engine.PopupDelay_OnTick), 250);
                                 m_PopupDelay.SetTag("object", mobile);
                                 m_PopupDelay.Start(false);
                             }
                             else
                             {
                                 m_PopupDelay.SetTag("object", mobile);
                             }
                         }
                     }
                     else
                     {
                         GObjectProperties.Hide();
                         if (m_PopupDelay != null)
                         {
                             m_PopupDelay.Stop();
                         }
                         m_PopupDelay = null;
                     }
                 }
             }
             else if ((lastMouseArgs.Button == MouseButtons.Left) && m_Ingame)
             {
                 GObjectProperties.Hide();
                 if (m_PopupDelay != null)
                 {
                     m_PopupDelay.Stop();
                 }
                 m_PopupDelay = null;
                 if (m_LastDown > 0)
                 {
                     short num3 = 0;
                     short num4 = 0;
                     ICell cell2 = Renderer.FindTileFromXY(m_xMouse, m_yMouse, ref num3, ref num4, true);
                     if (m_LastDown < 0x40000000)
                     {
                         if (((cell2 == null) || (cell2.CellType != typeof(MobileCell))) || ((((MobileCell) cell2).m_Mobile.Serial != m_LastDown) || ((m_LastDownPoint ^ new Point(m_xMouse, m_yMouse)) >= 2)))
                         {
                             Mobile mobile2 = World.FindMobile(m_LastDown);
                             if (mobile2 != null)
                             {
                                 mobile2.QueryStats();
                                 mobile2.OpenStatus(true);
                             }
                             m_LastDown = 0;
                         }
                     }
                     else if (((cell2 == null) || (cell2.CellType != typeof(DynamicItem))) || ((((DynamicItem) cell2).Serial != m_LastDown) || ((m_LastDownPoint ^ new Point(m_xMouse, m_yMouse)) >= 2)))
                     {
                         Mobile player = World.Player;
                         if ((player != null) && !player.Ghost)
                         {
                             Item item2 = World.FindItem(m_LastDown);
                             if (item2 != null)
                             {
                                 Gump gump = item2.OnBeginDrag();
                                 if (gump.GetType() == typeof(GDragAmount))
                                 {
                                     ((GDragAmount) gump).ToDestroy = item2;
                                 }
                                 else
                                 {
                                     item2.RestoreInfo = new RestoreInfo(item2);
                                     World.Remove(item2);
                                 }
                             }
                         }
                         m_LastDown = 0;
                     }
                 }
                 else if (m_LastDown == -1)
                 {
                     short num5 = 0;
                     short num6 = 0;
                     Renderer.ResetHitTest();
                     ICell cell3 = Renderer.FindTileFromXY(m_xMouse, m_yMouse, ref num5, ref num6, false);
                     m_LastDownPoint = new Point(m_xMouse, m_yMouse);
                     if ((cell3 != null) && (cell3.GetType() == typeof(MobileCell)))
                     {
                         m_LastDown = ((MobileCell) cell3).m_Mobile.Serial;
                     }
                     else if ((cell3 != null) && (cell3.GetType() == typeof(DynamicItem)))
                     {
                         Item item3 = ((DynamicItem) cell3).m_Item;
                         if (item3 != null)
                         {
                             if ((Map.GetWeight(item3.ID) < 0xff) || item3.Flags[ItemFlag.CanMove])
                             {
                                 m_LastDown = ((DynamicItem) cell3).Serial;
                             }
                             else
                             {
                                 m_LastDown = -1;
                             }
                         }
                         else
                         {
                             m_LastDown = -1;
                         }
                     }
                 }
             }
             else if ((!m_Locked && amMoving) && (!amMoving || !m_Ingame))
             {
                 GObjectProperties.Hide();
                 if (m_PopupDelay != null)
                 {
                     m_PopupDelay.Stop();
                 }
                 m_PopupDelay = null;
                 amMoving = false;
             }
             else if (!m_Locked && amMoving)
             {
                 GObjectProperties.Hide();
                 if (m_PopupDelay != null)
                 {
                     m_PopupDelay.Stop();
                 }
                 m_PopupDelay = null;
                 movingDir = pointingDir;
             }
             else
             {
                 GObjectProperties.Hide();
                 if (m_PopupDelay != null)
                 {
                     m_PopupDelay.Stop();
                 }
                 m_PopupDelay = null;
             }
         }
     }
 }
예제 #4
0
 private static void CharacterList(PacketReader pvSrc)
 {
     bool flag;
     byte num = pvSrc.ReadByte();
     Cursor.Hourglass = false;
     Engine.CharacterCount = num;
     string[] strArray = Engine.CharacterNames = new string[5];
     int num2 = 0;
     for (int i = 0; i < 5; i++)
     {
         Engine.CharacterNames[i] = strArray[i] = pvSrc.ReadString(60);
         if (strArray[i].Length > 0)
         {
             num2++;
         }
     }
     pvSrc.ReadString(60);
     int num4 = pvSrc.ReadByte();
     while (--num4 >= 0)
     {
         byte num5 = pvSrc.ReadByte();
         string str = pvSrc.ReadString(0x1f);
         string str2 = pvSrc.ReadString(0x1f);
     }
     if (!pvSrc.Finished)
     {
         int num6 = pvSrc.ReadInt32();
         Engine.ServerFeatures.SingleChar = (num6 & 4) != 0;
         Engine.ServerFeatures.ContextMenus = (num6 & 8) != 0;
         Engine.ServerFeatures.AOS = (num6 & 0x20) != 0;
         if ((num6 & 4) != 0)
         {
             flag = num2 < 1;
         }
         else
         {
             flag = num2 < 5;
         }
     }
     else
     {
         flag = num2 < 5;
     }
     if (Engine.m_QuickLogin)
     {
         CharacterProfile charProfile = Engine.m_QuickEntry.CharProfile;
         if (charProfile != null)
         {
             ShardProfile shard = charProfile.Shard;
             for (int j = 0; j < 5; j++)
             {
                 string name = Engine.CharacterNames[j];
                 if (name.Length > 0)
                 {
                     CharacterProfile profile3 = null;
                     for (int k = 0; (profile3 == null) && (k < shard.Characters.Length); k++)
                     {
                         if (shard.Characters[k].Index == j)
                         {
                             profile3 = shard.Characters[k];
                         }
                     }
                     if (profile3 != null)
                     {
                         profile3.Name = name;
                     }
                     else
                     {
                         shard.AddCharacter(new CharacterProfile(shard, name, j));
                     }
                 }
                 else
                 {
                     CharacterProfile character = null;
                     for (int m = 0; (character == null) && (m < shard.Characters.Length); m++)
                     {
                         if (shard.Characters[m].Index == j)
                         {
                             character = shard.Characters[m];
                         }
                     }
                     if (character != null)
                     {
                         shard.RemoveCharacter(character);
                     }
                 }
             }
             Array.Sort(shard.Characters, new CharacterComparer());
             Timer timer = new Timer(new OnTick(PacketHandlers.Update_OnTick), 0, 1);
             timer.SetTag("shard", shard);
             timer.Start(false);
         }
         QuickLogin.Add(Engine.m_QuickEntry);
         Network.Send(new PCharSelect(Engine.m_QuickEntry.CharName, Engine.m_QuickEntry.CharID));
         if (Animations.IsLoading)
         {
             Gumps.Desktop.Children.Clear();
             xGumps.Display("AnimationLoad");
             do
             {
                 Engine.DrawNow();
             }
             while (!Animations.WaitLoading());
         }
         Gumps.Desktop.Children.Clear();
         xGumps.Display("EnterBritannia");
         Engine.DrawNow();
     }
     else
     {
         xGumps.SetVariable("CharSlotAvailable", flag ? "1" : "0");
         Gumps.Desktop.Children.Clear();
         xGumps.Display("CharacterList");
         int index = 0;
         int num11 = 0;
         while (index < 5)
         {
             if (strArray[index].Length > 0)
             {
                 xGumps.SetVariable("CharName", strArray[index]);
                 xGumps.SetVariable("CharDisplayIndex", num11++.ToString());
                 xGumps.SetVariable("CharIndex", index.ToString());
                 xGumps.Display("CharacterEntry", "CharacterList");
             }
             index++;
         }
     }
 }