Exemple #1
0
        public void AfficherVisiblePour(Mobile obs)
        {
            alentours[obs] = DetectionStatus.Visible;

            if (Utility.InUpdateRange(obs, mobile))
            {
                NetState ns = obs.NetState;
                if (ns != null)
                {
                    if (obs.CanSee(mobile))
                    {
                        obs.Send(MobileIncoming.Create(ns, obs, mobile));
                        if (ObjectPropertyList.Enabled)
                        {
                            ns.Send(mobile.OPLPacket);

                            foreach (Item item in mobile.Items)
                            {
                                ns.Send(item.OPLPacket);
                            }
                        }

                        // On test un gain de skill seulement en cas de reussite pour eviter que le joueur sache
                        // que son jet a echoue a cause d'un gain de skill.
                        obs.CheckSkill(SkillName.Detection, 0);

                        obs.SendMessage("Vous détectez la présence de {0}", mobile.GetNameUsedBy(obs));
                    }
                    else
                    {
                        ns.Send(mobile.RemovePacket);
                    }
                }
            }
        }
Exemple #2
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (from is PlayerMobile && targeted is Mobile)
                {
                    PlayerMobile pm   = (PlayerMobile)from;
                    Mobile       targ = (Mobile)targeted;

                    if (targ.AccessLevel <= from.AccessLevel)
                    {
                        List <Mobile> list = pm.VisibilityList;

                        if (list.Contains(targ))
                        {
                            list.Remove(targ);
                            from.SendMessage("{0} has been removed from your visibility list.", targ.Name);
                        }
                        else
                        {
                            list.Add(targ);
                            from.SendMessage("{0} has been added to your visibility list.", targ.Name);
                        }

                        if (Utility.InUpdateRange(targ, from))
                        {
                            NetState ns = targ.NetState;

                            if (ns != null)
                            {
                                if (targ.CanSee(from))
                                {
                                    ns.Send(MobileIncoming.Create(ns, targ, from));

                                    if (ObjectPropertyList.Enabled)
                                    {
                                        ns.Send(from.OPLPacket);

                                        foreach (Item item in from.Items)
                                        {
                                            ns.Send(item.OPLPacket);
                                        }
                                    }
                                }
                                else
                                {
                                    ns.Send(from.RemovePacket);
                                }
                            }
                        }
                    }
                    else
                    {
                        from.SendMessage("They can already see you!");
                    }
                }
                else
                {
                    from.SendMessage("Add only mobiles to your visibility list.");
                }
            }
Exemple #3
0
            protected override void OnTick()
            {
                ++m_Count;

                if (m_Count == 1 && target != null)
                {
                    target.Frozen           = false;
                    target.SolidHueOverride = -1;
                    target.Blessed          = false;
                    m_Medusa.RemoveAffectedMobiles(target);

                    if (target is BaseCreature && !((BaseCreature)target).Summoned && ((BaseCreature)target).GetMaster() != null)
                    {
                        ((BaseCreature)target).GetMaster().SendLocalizedMessage(1113285, null, 43); // Beware! A statue of your pet has been created!
                    }
                    BuffInfo.RemoveBuff(target, BuffIcon.MedusaStone);
                }
                else if (m_Count == 2 && clone != null)
                {
                    clone.SolidHueOverride = -1;
                    clone.Frozen           = clone.Blessed = false;
                    int    dist    = 12;
                    Mobile closest = null;

                    IPooledEnumerable eable = clone.GetMobilesInRange(12);
                    foreach (Mobile m in eable)
                    {
                        int d = (int)clone.GetDistanceToSqrt(m.Location);

                        if (m != null && m is PlayerMobile || (m is BaseCreature && ((BaseCreature)m).GetMaster() is PlayerMobile))
                        {
                            if (m.NetState != null)
                            {
                                m.Send(new RemoveMobile(clone));
                                m.NetState.Send(MobileIncoming.Create(m.NetState, m, clone));
                                m.SendLocalizedMessage(1112767); // Medusa releases one of the petrified creatures!!
                            }

                            if (d < dist)
                            {
                                dist    = d;
                                closest = m;
                            }
                        }
                    }
                    eable.Free();

                    if (closest != null)
                    {
                        clone.Combatant = closest;
                    }
                }
                else
                {
                    Stop();
                }
            }
Exemple #4
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (from is PlayerMobile pm && targeted is Mobile targ)
                {
                    if (targ.AccessLevel <= pm.AccessLevel)
                    {
                        var list = pm.VisibilityList;

                        if (list.Contains(targ))
                        {
                            list.Remove(targ);
                            pm.SendMessage("{0} has been removed from your visibility list.", targ.Name);
                        }
                        else
                        {
                            list.Add(targ);
                            pm.SendMessage("{0} has been added to your visibility list.", targ.Name);
                        }

                        if (Utility.InUpdateRange(targ, from))
                        {
                            var ns = targ.NetState;

                            if (ns != null)
                            {
                                if (targ.CanSee(pm))
                                {
                                    ns.Send(MobileIncoming.Create(ns, targ, pm));

                                    pm.SendOPLPacketTo(ns);

                                    foreach (var item in pm.Items)
                                    {
                                        item.SendOPLPacketTo(ns);
                                    }
                                }
                                else
                                {
                                    ns.SendRemoveEntity(pm.Serial);
                                }
                            }
                        }
                    }
                    else
                    {
                        pm.SendMessage("They can already see you!");
                    }
                }
Exemple #5
0
        private static void DyeTarget(Serial target, ushort hue)
        {
            UOEntity targetObject = WorldEx.GetEntity(target);

            if (targetObject == null)
            {
                return;
            }

            Packet packet;

            if (targetObject is Item)
            {
                if (((Item)targetObject).Container is Mobile)
                {
                    packet = new EquipmentItem((Item)targetObject, hue, ((Mobile)((Item)targetObject).Container).Serial);
                }
                else
                {
                    packet = new ContainerItem((Item)targetObject);
                    packet.Seek(-2, SeekOrigin.End);
                    packet.Write(hue);
                }
            }
            else if (targetObject is Mobile)
            {
                Item mount = ((Mobile)targetObject).GetItemOnLayer(Layer.Mount);
                if (mount != null)
                {
                    packet = new EquipmentItem(mount, hue, targetObject.Serial);
                }
                else
                {
                    packet = new MobileIncoming((Mobile)targetObject);
                    packet.Seek(15, SeekOrigin.Begin);
                    packet.Write(hue);
                }
            }
            else
            {
                return;
            }
            WorldEx.SendToClient(packet);
        }
        private static bool OnMobileIncoming(ref byte[] packet, ref int length)
        {
            bool useNewIncoming = Engine.ClientVersion == null || Engine.ClientVersion >= new Version(7, 0, 33, 1);

            PacketReader reader = new PacketReader(packet, length, false);

            int            serial    = reader.ReadInt32();
            ItemCollection container = new ItemCollection(serial);

            Mobile mobile = serial == Engine.Player?.Serial ? Engine.Player : Engine.GetOrCreateMobile(serial);

            mobile.ID = reader.ReadInt16();
            mobile.X  = reader.ReadInt16();
            mobile.Y  = reader.ReadInt16();
            mobile.Z  = reader.ReadSByte();
            //TODO Removed & 0x07 to not strip running flag, think of better solution
            mobile.Direction = (Direction)reader.ReadByte();
            mobile.Hue       = reader.ReadUInt16();
            mobile.Status    = (MobileStatus)reader.ReadByte();
            mobile.Notoriety = (Notoriety)reader.ReadByte();

            for ( ;;)
            {
                int itemSerial = reader.ReadInt32();

                if (itemSerial == 0)
                {
                    break;
                }

                Item item = Engine.GetOrCreateItem(itemSerial);
                item.Owner = serial;
                item.ID    = reader.ReadUInt16();
                item.Layer = (Layer)reader.ReadByte();

                if (useNewIncoming)
                {
                    item.Hue = reader.ReadUInt16();
                }
                else
                {
                    if ((item.ID & 0x8000) != 0)
                    {
                        item.ID ^= 0x8000;
                        item.Hue = reader.ReadUInt16();
                    }
                }

                container.Add(item);
            }

            mobile.Equipment.Clear();
            mobile.Equipment.Add(container.GetItems());

            foreach (Item item in container.GetItems())
            {
                mobile.SetLayer(item.Layer, item.Serial);
            }

            try
            {
                if (Options.CurrentOptions.RehueFriends &&
                    Options.CurrentOptions.Friends.Any(e => e.Serial == serial && e.Serial != Engine.Player.Serial))
                {
                    MobileIncoming newPacket =
                        new MobileIncoming(mobile, container, Options.CurrentOptions.RehueFriendsHue);

                    packet = newPacket.ToArray();
                    length = packet.Length;

                    return(false);
                }
            }
            catch (InvalidOperationException e)
            {
                Console.WriteLine(e.ToString());
            }

            if (!Engine.RehueList.CheckMobileIncoming(mobile, container))
            {
                return(false);
            }

            Engine.IncomingQueue.Enqueue(new Packet(packet, length));
            return(true);
        }
Exemple #7
0
        public void TestMobileIncoming(int hairItemId, int hairHue, int facialHairItemId, int facialHairHue)
        {
            var beholder = new Mobile(0x1)
            {
                Name = "Random Mobile 1"
            };

            beholder.DefaultMobileInit();

            var beheld = new Mobile(0x2)
            {
                Name = "Random Mobile 2"
            };

            beheld.DefaultMobileInit();
            beheld.AddItem(
                new Item((Serial)0x1000)
            {
                Layer = Layer.OneHanded
            }
                );

            // Test Dupe
            beheld.AddItem(
                new Item((Serial)0x1001)
            {
                Layer = Layer.OneHanded
            }
                );

            beheld.HairItemID       = hairItemId;
            beheld.HairHue          = hairHue;
            beheld.FacialHairItemID = facialHairItemId;
            beheld.FacialHairHue    = facialHairHue;

            var data = new MobileIncoming(beholder, beheld).Compile();

            Span <bool> layers = stackalloc bool[256];

#if NO_LOCAL_INIT
            layers.Clear();
#endif

            var items = beheld.Items;
            var count = items.Count;

            if (beheld.HairItemID > 0)
            {
                count++;
            }

            if (beheld.FacialHairItemID > 0)
            {
                count++;
            }

            var length = 23 + count * 9; // Max Size

            Span <byte> expectedData = stackalloc byte[length];
            var         pos          = 0;

            expectedData.Write(ref pos, (byte)0x78);
            pos += 2; // Length

            var isSolidHue = beheld.SolidHueOverride >= 0;

            expectedData.Write(ref pos, beheld.Serial);
            expectedData.Write(ref pos, (ushort)beheld.Body);
            expectedData.Write(ref pos, (ushort)beheld.X);
            expectedData.Write(ref pos, (ushort)beheld.Y);
            expectedData.Write(ref pos, (byte)beheld.Z);
            expectedData.Write(ref pos, (byte)beheld.Direction);
            expectedData.Write(ref pos, (ushort)(isSolidHue ? beheld.SolidHueOverride : beheld.Hue));
            expectedData.Write(ref pos, (byte)beheld.GetPacketFlags());
            expectedData.Write(ref pos, (byte)Notoriety.Compute(beholder, beheld));

            byte layer;

            for (var i = 0; i < items.Count; i++)
            {
                var item = items[i];

                layer = (byte)item.Layer;

                if (!item.Deleted && !layers[layer] && beholder.CanSee(item))
                {
                    layers[layer] = true;

                    expectedData.Write(ref pos, item.Serial);
                    expectedData.Write(ref pos, (ushort)(item.ItemID & 0xFFFF));
                    expectedData.Write(ref pos, layer);
                    expectedData.Write(ref pos, (ushort)(isSolidHue ? beheld.SolidHueOverride : item.Hue));
                }
            }

            layer = (byte)Layer.Hair;
            var itemId = beheld.HairItemID & 0xFFFF;

            if (itemId > 0 && !layers[layer])
            {
                expectedData.Write(ref pos, HairInfo.FakeSerial(beheld));
                expectedData.Write(ref pos, (ushort)itemId);
                expectedData.Write(ref pos, layer);
                expectedData.Write(ref pos, (ushort)(isSolidHue ? beheld.SolidHueOverride : beheld.HairHue));
            }

            layer  = (byte)Layer.FacialHair;
            itemId = beheld.FacialHairItemID & 0xFFFF;

            if (itemId > 0 && !layers[layer])
            {
                expectedData.Write(ref pos, FacialHairInfo.FakeSerial(beheld));
                expectedData.Write(ref pos, (ushort)itemId);
                expectedData.Write(ref pos, layer);
                expectedData.Write(ref pos, (ushort)(isSolidHue ? beheld.SolidHueOverride : beheld.FacialHairHue));
            }

#if NO_LOCAL_INIT
            expectedData.Write(ref pos, 0); // Zero serial, terminate list
#else
            pos += 4;
#endif

            expectedData.Slice(1, 2).Write((ushort)pos); // Length
            expectedData = expectedData.Slice(0, pos);

            AssertThat.Equal(data, expectedData);
        }
Exemple #8
0
        public static void PushNotoriety(Mobile from, Mobile to, bool aggressor)
        {
            BaseCreature bc_From = from as BaseCreature;
            PlayerMobile pm_From = from as PlayerMobile;

            BaseCreature bc_To = to as BaseCreature;
            PlayerMobile pm_To = to as PlayerMobile;

            PlayerMobile pm_First  = null;
            PlayerMobile pm_Second = null;

            if (from == null || to == null)
            {
                return;
            }

            if (pm_From != null)
            {
                pm_First = pm_From;
            }

            if (bc_From != null)
            {
                if (bc_From.Controlled && bc_From.ControlMaster is PlayerMobile)
                {
                    pm_First = bc_From.ControlMaster as PlayerMobile;
                }
            }

            if (pm_To != null)
            {
                pm_Second = pm_To;
            }

            if (bc_To != null)
            {
                if (bc_To.Controlled && bc_To.ControlMaster is PlayerMobile)
                {
                    pm_Second = bc_To.ControlMaster as PlayerMobile;
                }
            }

            //First Player is Online
            if (pm_First != null)
            {
                if (pm_First.NetState != null)
                {
                    List <Mobile> m_Viewables = new List <Mobile>();

                    if (pm_First.AllFollowers.Count > 0)
                    {
                        foreach (Mobile follower in pm_First.AllFollowers)
                        {
                            if (follower != null)
                            {
                                m_Viewables.Add(follower);
                            }
                        }
                    }

                    if (pm_Second != null)
                    {
                        m_Viewables.Add(pm_Second);

                        if (pm_Second.AllFollowers.Count > 0)
                        {
                            foreach (Mobile follower in pm_Second.AllFollowers)
                            {
                                if (follower != null)
                                {
                                    m_Viewables.Add(follower);
                                }
                            }
                        }
                    }

                    if (bc_To != null)
                    {
                        m_Viewables.Add(bc_To);
                    }

                    //Update Data for All Things Viewable By This Player
                    foreach (Mobile mobile in m_Viewables)
                    {
                        if (mobile != null)
                        {
                            if (pm_First.CanSee(mobile))
                            {
                                pm_First.NetState.Send(MobileIncoming.Create(pm_First.NetState, pm_First, mobile));
                            }
                        }
                    }
                }
            }

            //Second Player is Online:
            if (pm_Second != null && pm_Second != pm_First)
            {
                if (pm_Second.NetState != null)
                {
                    List <Mobile> m_Viewables = new List <Mobile>();

                    if (pm_Second.AllFollowers.Count > 0)
                    {
                        foreach (Mobile follower in pm_Second.AllFollowers)
                        {
                            if (follower != null)
                            {
                                m_Viewables.Add(follower);
                            }
                        }
                    }

                    if (pm_First != null)
                    {
                        m_Viewables.Add(pm_First);

                        if (pm_First.AllFollowers.Count > 0)
                        {
                            foreach (Mobile follower in pm_First.AllFollowers)
                            {
                                if (follower != null)
                                {
                                    m_Viewables.Add(follower);
                                }
                            }
                        }
                    }

                    if (bc_From != null)
                    {
                        m_Viewables.Add(bc_From);
                    }

                    //Update Data for All Things Viewable By This Player
                    foreach (Mobile mobile in m_Viewables)
                    {
                        if (mobile != null)
                        {
                            if (pm_Second.CanSee(mobile))
                            {
                                pm_Second.NetState.Send(MobileIncoming.Create(pm_Second.NetState, pm_Second, mobile));
                            }
                        }
                    }
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Analyzes packet and saves it, if its part of the loot.
        /// </summary>
        /// <param name="packet">Packet</param>
        public void AnalyzePacket(Packet packet)
        {
            if (packet is MobileIncoming)
            {
                MobileIncoming p = (MobileIncoming)packet;

                if (!m_Mobiles.ContainsKey(p.Serial))
                {
                    Mobile m = new Mobile(p.Serial);
                    m.Body      = p.ModelId;
                    m.Hue       = (int)p.Hue;
                    m.Notoriety = (Notoriety)p.Notoriety;
                    m.Female    = (p.Flag & 0x2) == 1 ? true : false;
                    m.Blessed   = (p.Flag & 0x8) == 1 ? true : false;

                    m_Mobiles.Add(p.Serial, m);
                }
                else
                {
                    Mobile m = m_Mobiles[p.Serial];

                    m.Body      = p.ModelId;
                    m.Hue       = (int)p.Hue;
                    m.Notoriety = (Notoriety)p.Notoriety;
                    m.Female    = (p.Flag & 0x2) == 1 ? true : false;
                    m.Blessed   = (p.Flag & 0x8) == 1 ? true : false;
                }
            }

            /*else if ( packet is MobileStat )
             * {
             *      MobileStat p = (MobileStat) packet;
             *
             *      if ( m_Mobiles.ContainsKey( p.Serial ) )
             *      {
             *              Mobile m = m_Mobiles[ p.Serial ];
             *
             *              if ( m.Name == null )
             *                      m.Name = p.Name;
             *      }
             * }*/
            else if (packet is DeathAnimation)
            {
                DeathAnimation p = (DeathAnimation)packet;

                if (m_Mobiles.ContainsKey(p.Serial))
                {
                    Mobile m = m_Mobiles[p.Serial];

                    if (m.Corpse == 0)
                    {
                        m.Corpse = p.Corpse;

                        if (!m_Corpses.ContainsKey(p.Corpse))
                        {
                            m_Corpses.Add(p.Corpse, m);
                        }
                    }
                }
            }
            else if (packet is ContainerContentUpdate)
            {
                ContainerContentUpdate p = (ContainerContentUpdate)packet;

                if (m_Corpses.ContainsKey(p.ContSerial))
                {
                    Mobile m = m_Corpses[p.ContSerial];

                    if (m.CorpseContainer == 0)
                    {
                        m.CorpseContainer = p.Serial;
                        m_Filter.AddMobile(m.Name);

                        if (!m_CorpseContainers.ContainsKey(p.Serial))
                        {
                            m_CorpseContainers.Add(p.Serial, m);
                        }
                    }
                }
            }
            else if (packet is ContainerContent)
            {
                ContainerContent p = (ContainerContent)packet;

                foreach (ContainerContent.ContainedItem i in p.Items)
                {
                    if (m_CorpseContainers.ContainsKey(i.ContSerial))
                    {
                        Mobile m = m_CorpseContainers[i.ContSerial];

                        if (!m.Loot.ContainsKey(i.Serial))
                        {
                            Item item;

                            if (!m_Items.ContainsKey(i.Serial))
                            {
                                item = new Item(i.Serial);
                                m_Items.Add(i.Serial, item);
                            }
                            else
                            {
                                item = m_Items[i.Serial];
                            }

                            item.ItemID = i.ItemId;
                            item.Hue    = i.Hue;
                            item.Amount = i.Amount;

                            m.Loot.Add(i.Serial, item);
                        }
                    }
                }
            }
            else if (packet is ObjectProperties)
            {
                ObjectProperties p = (ObjectProperties)packet;

                if (m_Corpses.ContainsKey(p.Serial))
                {
                    Mobile m = m_Corpses[p.Serial];

                    if (m.CorpseName == null && p.Properties.Length > 0)
                    {
                        ObjectProperties.Property prop = p.Properties[0];
                        m.CorpseName = LocalizedList.Construct(prop.Number, prop.Arguments);
                    }
                }
                else if (m_Mobiles.ContainsKey(p.Serial))
                {
                    Mobile m = m_Mobiles[p.Serial];

                    if (p.Properties.Length > 0)
                    {
                        m.Name = LocalizedList.Construct(p.Properties[0].Number, p.Properties[0].Arguments);
                    }
                }
                else
                {
                    Item item;

                    if (!m_Items.ContainsKey(p.Serial))
                    {
                        item = new Item(p.Serial);
                        m_Items.Add(p.Serial, item);
                    }
                    else
                    {
                        item = m_Items[p.Serial];
                    }

                    if (item.Name != null)
                    {
                        return;
                    }

                    for (int i = 0; i < p.Properties.Length; i++)
                    {
                        ObjectProperties.Property prop = p.Properties[i];

                        item.ParseProperty(i, prop.Number, prop.Arguments);
                    }
                }
            }
        }
        public void Process(byte[] packet, Account a)
        {
            //a.TcpClient.NoDelay = true;
            //a.TcpClient.Client.DontFragment = true;
            //a.TcpClient.Client.NoDelay = false;
            //a.TcpClient.Client.SendBufferSize = 74;
            //a.TcpClient.LingerState = new LingerOption(false, 0);
            //a.TcpClient.SendTimeout = 0;
            //a.TcpClient.Client.SendTimeout = 0;
            //a.TcpClient.Client.LingerState = new LingerOption(false, 0);
            try
            {
                switch (packet[0])
                {
                case 0x80:
                    ServerList serverList = new ServerList();
                    serverList.Build();
                    //serverList.Send(a.TcpClient);
                    a.NetworkStream.Write(serverList.Data, 0, serverList.PacketSize);
                    break;

                case 0xA0:
                    if (a.TcpClient.Client.LocalEndPoint != null)
                    {
                        IPAddress     addr          = ((IPEndPoint)a.TcpClient.Client.LocalEndPoint).Address;
                        Int16         port          = Int16.Parse(((IPEndPoint)a.TcpClient.Client.LocalEndPoint).Port.ToString());
                        ServerConnect serverConnect = new ServerConnect(addr, port, a.AccountID)
                        {
                            GameServerIp =
                                IPAddress.Parse(
                                    ((IPEndPoint)a.TcpClient.Client.RemoteEndPoint).Address.ToString())
                        };
                        serverConnect.Build();
                        a.NetworkStream.Write(serverConnect.Data, 0, serverConnect.PacketSize);
                    }
                    break;

                case 0x91:
                    a.LoadChars();
                    CharacterList characterList = new CharacterList(a.CharList);

                    characterList.Build();

                    a.NetworkStream.Write(characterList.Data, 0, characterList.PacketSize);
                    break;

                case 0x5D:
                    ClientVersion clientVersion = new ClientVersion();
                    clientVersion.Build();
                    clientVersion.Compress();
                    clientVersion.Send(a.NetworkStream);
                    break;



                case 0xBD:

                    UOPackets.ServerPackets.LoginConfirm loginConfirm = new UOPackets.ServerPackets.LoginConfirm();
                    loginConfirm.Body         = 400;
                    loginConfirm.Direction131 = Direction13.North;
                    loginConfirm.X            = 2520;
                    loginConfirm.Y            = 521;
                    loginConfirm.Z            = 0;
                    loginConfirm.MapHeight    = 4096;
                    loginConfirm.MapWidth     = 7168;
                    loginConfirm.Serial       = 2420;
                    loginConfirm.Build();
                    loginConfirm.Compress();

                    loginConfirm.Send(a.NetworkStream);


                    MapChange mapChange = new MapChange();
                    mapChange.MapId = Map102.felucca;
                    mapChange.Build();
                    mapChange.Compress();

                    mapChange.Send(a.NetworkStream);


                    MapPatches mapPatches = new MapPatches();
                    mapPatches.MapsCount = 4;
                    mapPatches.Build();
                    mapPatches.Compress();

                    mapPatches.Send(a.NetworkStream);


                    SeasonChange seasonChange = new SeasonChange();
                    seasonChange.Season750    = Season75.summer;
                    seasonChange.PlayMusic761 = PlayMusic76.yes;
                    seasonChange.Build();
                    seasonChange.Compress();

                    seasonChange.Send(a.NetworkStream);


                    Int16             feat = 0x00;
                    SupportedFeatures supportedFeatures = new SupportedFeatures();
                    feat  = (Int16)Flags73.enablethirddownfeatures;
                    feat += (Int16)Flags73.enableT2Afeatureschatbuttonregions;
                    feat += (Int16)Flags73.enableMLfeatureselvenracespellsskills;
                    feat += (Int16)Flags73.enableAOSfeaturesskillsspellsmapfightbook;
                    feat += (Int16)Flags73.enablerenaissancefeatures;
                    feat += (Int16)Flags73.enableLBRfeaturesskillsmap;
                    supportedFeatures.Flags730 = feat;
                    supportedFeatures.Build();
                    supportedFeatures.Compress();

                    supportedFeatures.Send(a.NetworkStream);


                    MobileUpdate mobileUpdate = new MobileUpdate();
                    mobileUpdate.Direction163 = Direction16.North;
                    mobileUpdate.Flags151     = Flags15.WarMode;
                    mobileUpdate.Hue          = 33770;
                    mobileUpdate.X            = 2520;
                    mobileUpdate.Y            = 521;
                    mobileUpdate.Z            = 0;
                    mobileUpdate.Serial       = 2420;
                    mobileUpdate.Body         = 400;
                    mobileUpdate.Build();
                    mobileUpdate.Compress();

                    mobileUpdate.Send(a.NetworkStream);
                    mobileUpdate.Send(a.NetworkStream);


                    GlobalLight globalLight = new GlobalLight();
                    globalLight.LightLevel240 = LightLevel24.Bright;
                    globalLight.Build();
                    globalLight.Compress();

                    globalLight.Send(a.NetworkStream);


                    Infravision infraVision = new Infravision();
                    infraVision.Active = 0x00;
                    infraVision.Serial = 2420;
                    infraVision.Build();
                    infraVision.Compress();

                    infraVision.Send(a.NetworkStream);


                    mobileUpdate.Send(a.NetworkStream);



                    //TODO: Pegar tudo do BD
                    MobileIncoming mobileIncoming = new MobileIncoming();
                    mobileIncoming.Body         = 400;
                    mobileIncoming.Direction490 = (Direction49)((short)(Direction49.Running) + (short)(Direction49.Up));
                    mobileIncoming.Flags501     = Flags50.Hidden;
                    mobileIncoming.Notoriety512 = Notoriety51.Canbeattacked;
                    mobileIncoming.Serial       = 2420;
                    mobileIncoming.X            = 2520;
                    mobileIncoming.Y            = 521;
                    mobileIncoming.Z            = 0;
                    mobileIncoming.Hue          = 0x83ea;
                    mobileIncoming.Items3.Add(new Items()
                    {
                        ItemSerial = 0x40000380, ItemID = 0x0e7c, ItemLayer = ItemLayer8.Bank, ItemHue = 0x00
                    });
                    mobileIncoming.Items3.Add(new Items()
                    {
                        ItemSerial = 0x7fffd62f, ItemID = 0xa03b, ItemLayer = ItemLayer8.Hair, ItemHue = 0x044e
                    });
                    mobileIncoming.Items3.Add(new Items()
                    {
                        ItemSerial = 0x66666666, ItemID = 0xa03b, ItemLayer = ItemLayer8.Hair, ItemHue = 0x044e
                    });
                    mobileIncoming.Build();
                    mobileIncoming.Compress();

                    mobileIncoming.Send(a.NetworkStream);


                    MobileStatus mobileStatus = new MobileStatus();
                    mobileStatus.Serial              = 2420;
                    mobileStatus.Name                = "lokis                         ".ToCharArray();
                    mobileStatus.HitPoints           = 0x50;
                    mobileStatus.MaximumHitPoints    = 0x50;
                    mobileStatus.AllowNameChange50   = AllowNameChange5.no;
                    mobileStatus.SupportedFeatures61 = SupportedFeatures6.MLattributes;
                    mobileStatus.Gender              = 0x00;
                    mobileStatus.Strength            = 0x3c;
                    mobileStatus.Dexterity           = 0x0a;
                    mobileStatus.Intelligence        = 0x0a;
                    mobileStatus.Stamina             = 0x0a;
                    mobileStatus.MaximumStamina      = 0x0a;
                    mobileStatus.Mana                = 0x0a;
                    mobileStatus.MaximumMana         = 0x0a;
                    mobileStatus.Gold                = 0;
                    mobileStatus.ArmorRating         = 0;
                    mobileStatus.Weight              = 0x0e;
                    mobileStatus.MaximumWeight       = 0x0136;
                    mobileStatus.Race72              = Race7.Human;
                    mobileStatus.StatCap             = 0xe1;
                    mobileStatus.Followers           = 0;
                    mobileStatus.MaximumFollowers    = 5;
                    mobileStatus.FireResistance      = 0;
                    mobileStatus.ColdResistance      = 0;
                    mobileStatus.PoisonResistance    = 0;
                    mobileStatus.EnergyResistance    = 0;
                    mobileStatus.Luck                = 0;
                    mobileStatus.MinimumWeaponDamage = 1;
                    mobileStatus.MaximumWeaponDamage = 5;
                    mobileStatus.TithingPoints       = 0;
                    mobileStatus.Build();
                    mobileStatus.Compress();

                    mobileStatus.Send(a.NetworkStream);


                    WarMode warMode = new WarMode();
                    warMode.Warmode = 0x00;
                    warMode.Build();
                    warMode.Compress();

                    warMode.Send(a.NetworkStream);


                    OPLInfo oplInfo2 = new OPLInfo();
                    oplInfo2.Serial = 2420;
                    oplInfo2.Hash   = 0x400f9705;
                    oplInfo2.Build();
                    oplInfo2.Compress();
                    oplInfo2.Send(a.NetworkStream);


                    //mobileIncoming.Send(a.TcpClient);

                    OPLInfo oplInfo = new OPLInfo();
                    //oplInfo.Serial = 2420;
                    oplInfo.Serial = 0x40013082;
                    //oplInfo.Hash = 0x4301baee;
                    oplInfo.Hash = 0x400f9705;
                    oplInfo.Build();
                    oplInfo.Compress();

                    oplInfo.Send(a.NetworkStream);
                    oplInfo2.Send(a.NetworkStream);


                    supportedFeatures.Send(a.NetworkStream);
                    mobileUpdate.Send(a.NetworkStream);
                    mobileStatus.Send(a.NetworkStream);
                    warMode.Send(a.NetworkStream);
                    mobileIncoming.Send(a.NetworkStream);

                    //oplInfo2.Send(a.NetworkStream);

                    LoginConfirmed loginConfirmed = new LoginConfirmed();
                    loginConfirmed.Build();
                    loginConfirmed.Compress();

                    loginConfirmed.Send(a.NetworkStream);


                    GameTime gameTime = new GameTime();
                    gameTime.Hour   = Convert.ToByte(DateTime.Now.Hour);
                    gameTime.Minute = Convert.ToByte(DateTime.Now.Minute);
                    gameTime.Second = Convert.ToByte(DateTime.Now.Second);
                    gameTime.Build();
                    gameTime.Compress();

                    gameTime.Send(a.NetworkStream);


                    seasonChange.Send(a.NetworkStream);


                    mapChange.Send(a.NetworkStream);


                    /*globalLight.Send(a.NetworkStream);
                     * infraVision.Send(a.NetworkStream);
                     * gameTime.Send(a.NetworkStream);
                     *
                     * DisplayPaperdoll displayPaperdoll = new DisplayPaperdoll();
                     * displayPaperdoll.Flags550 = Flags55.CanLift;
                     * displayPaperdoll.Serial = 400;
                     * displayPaperdoll.Text = "lokis, Apprentice smith                                    ".ToCharArray();
                     * displayPaperdoll.Build();
                     * displayPaperdoll.Compress();
                     *
                     *
                     * displayPaperdoll.Send(a.NetworkStream);
                     *
                     * oplInfo.Send(a.NetworkStream);
                     *
                     * //break;
                     *
                     * //case 0xD6:
                     * globalLight = new GlobalLight();
                     * globalLight.LightLevel240 = LightLevel24.Bright;
                     * globalLight.Build();
                     * globalLight.Compress();
                     *
                     * infraVision = new Infravision();
                     * infraVision.Active = 0x00;
                     * infraVision.Serial = 2420;
                     * infraVision.Build();
                     * infraVision.Compress();
                     *
                     * mapChange = new MapChange();
                     * mapChange.MapId = Map102.felucca;
                     * mapChange.Build();
                     * mapChange.Compress();
                     *
                     * mapChange.Send(a.NetworkStream);
                     * infraVision.Send(a.NetworkStream);
                     * globalLight.Send(a.NetworkStream);
                     *
                     *
                     * mobileUpdate.Send(a.NetworkStream);
                     * mobileStatus.Send(a.NetworkStream);
                     *
                     * warMode.Send(a.NetworkStream);
                     * mobileIncoming.Send(a.NetworkStream);
                     * oplInfo.Send(a.NetworkStream);
                     *
                     * SkillsUpdate skillsUpdate = new SkillsUpdate();
                     * skillsUpdate.ListType220 = ListType22.capped;
                     *
                     *
                     * for (int i = 0; i < 55; i++)
                     * {
                     *  Random rand = new Random();
                     *  Int16 skillBaseValue = 100;
                     *  Int16 skillCappedValue = 100;
                     *  Int16 skillValue = 100;
                     *
                     *  skillsUpdate.Skills.Add(new Skills() { SkillID = (SkillName)i, LockStatus = 0x00, SkillBaseValue = skillBaseValue, SkillCappedValue = skillCappedValue, SkillValue = skillValue });
                     * }
                     *
                     * skillsUpdate.Build();
                     * skillsUpdate.Compress();
                     * skillsUpdate.Send(a.NetworkStream);*/


                    DisplayPaperdoll displayPaperdoll = new DisplayPaperdoll();
                    displayPaperdoll.Flags550 = Flags55.CanLift;
                    displayPaperdoll.Serial   = 2420;
                    displayPaperdoll.Text     = "LoKiS, Apprentice smith";
                    displayPaperdoll.Build();
                    displayPaperdoll.Compress();


                    displayPaperdoll.Send(a.NetworkStream);

                    break;

                case 0x34:

                    SkillsUpdate skillsUpdate = new SkillsUpdate();
                    skillsUpdate.ListType220 = ListType22.capped;


                    for (int i = 0; i < 55; i++)
                    {
                        Random rand             = new Random();
                        Int16  skillBaseValue   = 100;
                        Int16  skillCappedValue = 100;
                        Int16  skillValue       = 100;

                        skillsUpdate.Skills.Add(new Skills()
                        {
                            SkillID = (SkillName)i + 1, LockStatus = 0x00, SkillBaseValue = skillBaseValue, SkillCappedValue = skillCappedValue, SkillValue = skillValue
                        });
                    }

                    skillsUpdate.Build();
                    skillsUpdate.Compress();
                    skillsUpdate.Send(a.NetworkStream);

                    break;

                case 0x02:
                    MovementAccepted movAccepted = new MovementAccepted();

                    movAccepted.Sequence = packet[2];
                    movAccepted.Status   = 0x03;
                    movAccepted.Build();
                    movAccepted.Compress();

                    movAccepted.Send(a.NetworkStream);



                    /*AsciiMessage asciiMessage = new AsciiMessage();
                     * asciiMessage.Serial = 0xFFFFFFFF;
                     * asciiMessage.Hue = 0x3b2;
                     * asciiMessage.Graphic = 0xFFFF;
                     * asciiMessage.Font = 3;
                     * asciiMessage.Name = "PELUPELUPELUPELUPELUPELUPELUU".ToCharArray();
                     * asciiMessage.TextMessage = "PELUDO";
                     * asciiMessage.MessageType140 = MessageType14.System;
                     * asciiMessage.Build();
                     * asciiMessage.Compress();
                     * asciiMessage.Send(a.NetworkStream);*/



                    /* Pacotes
                     * 5D - PlayCharacter CS
                     * BD - ClientVersion SC
                     * BD - ClientVersion CS
                     * 1B - LoginConfirm SC
                     * 34 - MobileQuery CS
                     * BD - ClientVersion CS
                     * BF.05 - ScreenSize CS
                     * BF.0B - ClientLanguage CS
                     * BF.0F - ClientInfo CS
                     * BF.08 - MapChange SC
                     * BF.18 - MapPatches SC
                     * BC - SeasonChange SC
                     * B9 - SupportedFeatures SC
                     * 20 - MobileUpdate SC
                     * 20 - MobileUpdate SC
                     * 4F - GlobalBright SC
                     * 4E - Infravision SC
                     * 20 - MobileUpdate SC
                     * 78 - MobileIncoming SC
                     * 11 - MobileStatus SC
                     * 72 - Warmode SC
                     * 78 - MobileIncoming SC
                     * DC - OPLInfo SC
                     * B9 - SupportedFeatures SC
                     * 20 - MobileUpdate SC
                     * 11 - MobileStatus SC
                     * 72 - Warmode SC
                     * 78 - MobileIncoming SC
                     * 55 - LoginConfirmed SC
                     * 06 - DoubleClick CS
                     * 5B - GameTime SC
                     * BC - SeasonChange SC
                     * BF - MapChange SC
                     * 4F - GlobalBright SC
                     * 4E - Infravision SC
                     * AE - UnicodeMessage SC
                     * D6 - BatchQueryProperties CS
                     * 1C - AsciiMessage SC
                     * 3A - SkillsUpdate SC
                     * 88 - DisplayPaperdoll SC
                     * DC - OPLInfo SC
                     * D6 - BatchQueryProperties CS
                     * BF.24 - Unknown CS
                     */

                    /* Ordem da DoLogin():
                     * LoginConfirm -
                     * MapChange -
                     * SeasonChange -
                     * SupportedFeatures -
                     * MobileUpdate-
                     * MobileUpdate-
                     * MobileUpdate-
                     * MobileIncoming
                     * MobileStatus -
                     * SetWarMode -
                     * SupportedFeatures -
                     * MobileUpdate -
                     * MobileStatus -
                     * MobileIncoming
                     * LoginComplete -
                     * CurrentTime
                     * SeasonChange -
                     * MapChange-
                     * LoginEventArgs
                     */
                    /*
                     * LoginConfirm loginConfirm = new LoginConfirm( a.CharList[0] );
                     * loginConfirm.Build();
                     * loginConfirm.Send(a.TcpClient);
                     *
                     *
                     * UOPackets.ServerPackets.LoginConfirm loginConfirm = new UOPackets.ServerPackets.LoginConfirm();
                     * loginConfirm.Body = 0;
                     * loginConfirm.Direction131 = Direction13.North;
                     * loginConfirm.X = 2520;
                     * loginConfirm.Y = 521;
                     * loginConfirm.Z = 0;
                     *
                     *
                     *
                     * //a.TcpClient.Client.Send(loginConfirm.Data, 0, loginConfirm.PacketSize, SocketFlags.None);
                     *
                     * CharacterMapChange characterMapChange = new CharacterMapChange(0x01);
                     * characterMapChange.Build();
                     * Subcommands subCommands = new Subcommands(characterMapChange);
                     * subCommands.Build();
                     *
                     * characterMapChange.Send(a.TcpClient);
                     * //a.TcpClient.Client.Send(characterMapChange.Data, 0, characterMapChange.PacketSize, SocketFlags.None);
                     *
                     * UOPackets.ServerPackets.SeasonChange seasonChange = new UOPackets.ServerPackets.SeasonChange();
                     * seasonChange.PlayMusic761 = PlayMusic76.yes;
                     * seasonChange.Season750 = Season75.summer;
                     * seasonChange.Build();
                     * seasonChange.Compress();
                     * seasonChange.Send(a.TcpClient);
                     *
                     * UOPackets.ServerPackets.SupportedFeatures supportedFeatures = new UOPackets.ServerPackets.SupportedFeatures();
                     * supportedFeatures.Flags730 = Flags73.enableAOSfeaturesskillsspellsmapfightbook;
                     * supportedFeatures.Build();
                     * supportedFeatures.Compress();
                     * supportedFeatures.Send(a.TcpClient);
                     *
                     * UOPackets.ServerPackets.MobileUpdate mobileUpdate = new UOPackets.ServerPackets.MobileUpdate();
                     * mobileUpdate.Body = 0;
                     * mobileUpdate.Direction163 = Direction16.North;
                     * mobileUpdate.Flags151 = 0;
                     * mobileUpdate.Hue = 0;
                     * mobileUpdate.X = 2520;
                     * mobileUpdate.Y = 521;
                     * mobileUpdate.Z = 0;
                     * mobileUpdate.Serial = 0;
                     * mobileUpdate.Build();
                     * mobileUpdate.Compress();
                     * mobileUpdate.Send(a.TcpClient);
                     * mobileUpdate.Send(a.TcpClient);
                     * mobileUpdate.Send(a.TcpClient);
                     *
                     *
                     * UOPackets.ServerPackets.MobileStatus mobileStatus = new UOPackets.ServerPackets.MobileStatus();
                     * mobileStatus.Serial = 0;
                     * mobileStatus.Name = "teste".ToCharArray();
                     * mobileStatus.HitPoints = 100;
                     * mobileStatus.MaximumHitPoints = 100;
                     * mobileStatus.AllowNameChange50 = AllowNameChange5.yes;
                     * mobileStatus.SupportedFeatures61 = SupportedFeatures6.AOSattributes;
                     * mobileStatus.Gender = 0;
                     * mobileStatus.Strength = 100;
                     * mobileStatus.Dexterity = 100;
                     * mobileStatus.Intelligence = 100;
                     * mobileStatus.Stamina = 100;
                     * mobileStatus.MaximumStamina = 100;
                     * mobileStatus.Mana = 100;
                     * mobileStatus.MaximumMana = 100;
                     * mobileStatus.Gold = 500;
                     * mobileStatus.ArmorRating = 100;
                     * mobileStatus.Weight = 50;
                     * mobileStatus.StatCap = 300;
                     * mobileStatus.Followers = 0;
                     * mobileStatus.MaximumFollowers = 6;
                     * mobileStatus.FireResistance = 0;
                     * mobileStatus.ColdResistance = 0;
                     * mobileStatus.PoisonResistance = 0;
                     * mobileStatus.EnergyResistance = 0;
                     * mobileStatus.Luck = 0;
                     * mobileStatus.MinimumWeaponDamage = 0;
                     * mobileStatus.MaximumWeaponDamage = 100;
                     * mobileStatus.TithingPoints = 0;
                     * mobileStatus.Build();
                     * mobileStatus.Compress();
                     * mobileStatus.Send(a.TcpClient);
                     *
                     *
                     * UOPackets.ServerPackets.WarMode setWarMode = new UOPackets.ServerPackets.WarMode();
                     * setWarMode.Warmode = 0;
                     * setWarMode.Build();
                     * setWarMode.Compress();
                     * setWarMode.Send(a.TcpClient);
                     *
                     *
                     * supportedFeatures.Send(a.TcpClient);
                     * mobileUpdate.Send(a.TcpClient);
                     * mobileStatus.Send(a.TcpClient);
                     *
                     *
                     * UOPackets.LoginComplete loginComplete = new LoginComplete();
                     * loginComplete.Build();
                     * loginComplete.Send(a.TcpClient);
                     *
                     *
                     * seasonChange.Send(a.TcpClient);
                     * UOPackets.ServerPackets.MapChange mapChange = new UOPackets.ServerPackets.MapChange();
                     * mapChange.Build();
                     * mapChange.Send(a.TcpClient);
                     *
                     *
                     *
                     *
                     * //ClientFeatures clientFeatures = new ClientFeatures();
                     * //clientFeatures.Build();
                     *
                     * //a.TcpClient.Client.Send(clientFeatures.m_Data, 0, clientFeatures.PacketSize, SocketFlags.None);
                     * /*
                     * CharacterWarmode characterWarmode = new CharacterWarmode();
                     * characterWarmode.Build();
                     *
                     * a.TcpClient.Client.Send( characterWarmode.Data, 0, characterWarmode.PacketSize, SocketFlags.None );
                     *
                     *
                     *
                     * a.TcpClient.Client.Send(subCommands.Data, 0, subCommands.PacketSize, SocketFlags.None);
                     *
                     *
                     * CharacterSync characterSync = new CharacterSync(a.CharList[0]);
                     * characterSync.Build();
                     *
                     * a.TcpClient.Client.Send(characterSync.Data, 0, characterSync.PacketSize, SocketFlags.None);
                     *
                     * LoginComplete loginComplete = new LoginComplete();
                     * loginComplete.Build();
                     *
                     * a.TcpClient.Client.Send(loginComplete.Data, 0, loginComplete.PacketSize, SocketFlags.None);
                     *
                     */
                    break;
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemple #11
0
        /// <summary>
        /// Analyzes packet and saves it, if it is related to vendors.
        /// </summary>
        /// <param name="packet">Packet.</param>
        public void AnalyzePacket(Packet packet)
        {
            if (packet is MobileIncoming)
            {
                MobileIncoming p = (MobileIncoming)packet;

                if (!m_Vendors.ContainsKey(p.Serial) && p.Notoriety == Notoriety.Invulnerable)
                {
                    Vendor m = new Vendor(p.Serial);
                    m.Body      = p.ModelId;
                    m.Hue       = (int)p.Hue;
                    m.Notoriety = (Notoriety)p.Notoriety;
                    m.Female    = (p.Flag & 0x2) == 1 ? true : false;
                    m.Blessed   = (p.Flag & 0x8) == 1 ? true : false;

                    foreach (MobileIncoming.EquipInfo i in p.Equipment)
                    {
                        Item item = new Item(i.Serial);
                        item.ItemID = i.ItemId;
                        item.Layer  = (Layer)i.Layer;
                        item.Hue    = i.Hue;
                        m.Items.Add(item);
                        m_Items.Add(i.Serial, item);

                        if (item.Layer == Layer.ShopBuy)
                        {
                            m_Shops.Add(item.Serial, m);
                        }
                    }

                    m_Vendors.Add(p.Serial, m);
                }
            }
            else if (packet is ContainerContent)
            {
                ContainerContent p = (ContainerContent)packet;

                foreach (ContainerContent.ContainedItem i in p.Items)
                {
                    if (m_Shops.ContainsKey(i.ContSerial))
                    {
                        Vendor m = m_Shops[i.ContSerial];

                        if (!m.Shop.ContainsKey(i.Serial))
                        {
                            VendorItem item = new VendorItem(i.Serial);

                            if (!m_Items.ContainsKey(i.Serial))
                            {
                                m_Items.Add(i.Serial, item);
                            }

                            item.ItemID = i.ItemId;
                            item.Hue    = i.Hue;
                            item.Amount = i.Amount;

                            m.Shop.Add(i.Serial, item);
                        }
                    }
                }
            }
            else if (packet is BuyInfo)
            {
                BuyInfo p = (BuyInfo)packet;

                if (m_Shops.ContainsKey(p.VendorSerial))
                {
                    m_Prices  = new int[p.ItemCount];
                    m_Counter = 0;

                    for (int i = 0; i < p.ItemCount; i++)
                    {
                        m_Prices[i] = p.List[i].Price;
                    }
                }
            }
            else if (packet is ObjectProperties)
            {
                ObjectProperties p = (ObjectProperties)packet;

                if (m_Items.ContainsKey(p.Serial))
                {
                    Item item = m_Items[p.Serial];

                    if (item.Name != null)
                    {
                        return;
                    }

                    for (int i = 0; i < p.Properties.Length; i++)
                    {
                        ObjectProperties.Property prop = p.Properties[i];
                        item.ParseProperty(i, prop.Number, prop.Arguments);
                    }

                    if (item is VendorItem && m_Prices != null && m_Counter < m_Prices.Length)
                    {
                        ((VendorItem)item).SellPrice = m_Prices[m_Counter++];
                    }
                }
                else if (m_Vendors.ContainsKey(p.Serial))
                {
                    Mobile m = m_Vendors[p.Serial];

                    if (m.Name == null && p.Properties.Length > 0)
                    {
                        m.Name = LocalizedList.Construct(p.Properties[0].Number, p.Properties[0].Arguments);
                    }
                }
            }
        }
Exemple #12
0
        public void Process(byte[] packet, Account a)
        {
            try
            {
                switch (packet[0])
                {
                case 0x80:
                    ServerList serverList = new ServerList();
                    serverList.Build();
                    a.NetworkStream.Write(serverList.Data, 0, serverList.PacketSize);
                    break;

                case 0xA0:

                    if (a.TcpClient.Client.LocalEndPoint != null)
                    {
                        IPAddress     addr          = ((IPEndPoint)a.TcpClient.Client.LocalEndPoint).Address;
                        Int16         port          = Int16.Parse(((IPEndPoint)a.TcpClient.Client.LocalEndPoint).Port.ToString());
                        ServerConnect serverConnect = new ServerConnect(addr, port, a.AccountID)
                        {
                            GameServerIp = IPAddress.Parse(((IPEndPoint)a.TcpClient.Client.RemoteEndPoint).Address.ToString())
                        };
                        serverConnect.Build();
                        a.NetworkStream.Write(serverConnect.Data, 0, serverConnect.PacketSize);
                    }
                    break;

                case 0x91:
                    a.LoadChars();
                    CharacterList characterList = new CharacterList(a.CharList);

                    characterList.Build();

                    a.NetworkStream.Write(characterList.Data, 0, characterList.PacketSize);
                    break;

                case 0x5D:
                    ClientVersion clientVersion = new ClientVersion();
                    clientVersion.Build();
                    clientVersion.Compress();
                    clientVersion.Send(a.NetworkStream);
                    break;

                case 0xBD:

                    UOPackets.ServerPackets.LoginConfirm loginConfirm = new UOPackets.ServerPackets.LoginConfirm();
                    loginConfirm.Body         = 400;
                    loginConfirm.Direction131 = Direction13.North;
                    loginConfirm.X            = 2520;
                    loginConfirm.Y            = 521;
                    loginConfirm.Z            = 0;
                    loginConfirm.MapHeight    = 4096;
                    loginConfirm.MapWidth     = 7168;
                    loginConfirm.Serial       = 2420;
                    loginConfirm.Build();
                    loginConfirm.Compress();

                    loginConfirm.Send(a.NetworkStream);

                    MapChange mapChange = new MapChange();
                    mapChange.MapId = Map102.felucca;
                    mapChange.Build();
                    mapChange.Compress();

                    mapChange.Send(a.NetworkStream);

                    MapPatches mapPatches = new MapPatches();
                    mapPatches.MapsCount = 4;
                    mapPatches.Build();
                    mapPatches.Compress();

                    mapPatches.Send(a.NetworkStream);

                    SeasonChange seasonChange = new SeasonChange();
                    seasonChange.Season750    = Season75.summer;
                    seasonChange.PlayMusic761 = PlayMusic76.yes;
                    seasonChange.Build();
                    seasonChange.Compress();

                    seasonChange.Send(a.NetworkStream);

                    Int16             feat = 0x00;
                    SupportedFeatures supportedFeatures = new SupportedFeatures();
                    feat  = (Int16)Flags73.enablethirddownfeatures;
                    feat += (Int16)Flags73.enableT2Afeatureschatbuttonregions;
                    feat += (Int16)Flags73.enableMLfeatureselvenracespellsskills;
                    feat += (Int16)Flags73.enableAOSfeaturesskillsspellsmapfightbook;
                    feat += (Int16)Flags73.enablerenaissancefeatures;
                    feat += (Int16)Flags73.enableLBRfeaturesskillsmap;
                    supportedFeatures.Flags730 = feat;
                    supportedFeatures.Build();
                    supportedFeatures.Compress();

                    supportedFeatures.Send(a.NetworkStream);

                    MobileUpdate mobileUpdate = new MobileUpdate();
                    mobileUpdate.Direction163 = Direction16.North;
                    mobileUpdate.Flags151     = Flags15.WarMode;
                    mobileUpdate.Hue          = 33770;
                    mobileUpdate.X            = 2520;
                    mobileUpdate.Y            = 521;
                    mobileUpdate.Z            = 0;
                    mobileUpdate.Serial       = 2420;
                    mobileUpdate.Body         = 400;
                    mobileUpdate.Build();
                    mobileUpdate.Compress();

                    mobileUpdate.Send(a.NetworkStream);
                    mobileUpdate.Send(a.NetworkStream);

                    GlobalLight globalLight = new GlobalLight();
                    globalLight.LightLevel240 = LightLevel24.Bright;
                    globalLight.Build();
                    globalLight.Compress();

                    globalLight.Send(a.NetworkStream);

                    Infravision infraVision = new Infravision();
                    infraVision.Active = 0x00;
                    infraVision.Serial = 2420;
                    infraVision.Build();
                    infraVision.Compress();

                    infraVision.Send(a.NetworkStream);

                    mobileUpdate.Send(a.NetworkStream);

                    //TODO: Pegar tudo do BD
                    MobileIncoming mobileIncoming = new MobileIncoming();
                    mobileIncoming.Body         = 400;
                    mobileIncoming.Direction490 = (Direction49)((short)(Direction49.Running) + (short)(Direction49.Up));
                    mobileIncoming.Flags501     = Flags50.Hidden;
                    mobileIncoming.Notoriety512 = Notoriety51.Canbeattacked;
                    mobileIncoming.Serial       = 2420;
                    mobileIncoming.X            = 2520;
                    mobileIncoming.Y            = 521;
                    mobileIncoming.Z            = 0;
                    mobileIncoming.Hue          = 0x83ea;
                    mobileIncoming.Items3.Add(new Item()
                    {
                        ItemSerial = 0x40000380, ItemID = 0x0e7c, ItemLayer = ItemLayer8.Bank, ItemHue = 0x00
                    });
                    mobileIncoming.Items3.Add(new Item()
                    {
                        ItemSerial = 0x7fffd62f, ItemID = 0xa03b, ItemLayer = ItemLayer8.Hair, ItemHue = 0x044e
                    });
                    mobileIncoming.Items3.Add(new Item()
                    {
                        ItemSerial = 0x66666666, ItemID = 0xa03b, ItemLayer = ItemLayer8.Hair, ItemHue = 0x044e
                    });
                    mobileIncoming.Items3.Add(new Item()
                    {
                        ItemSerial = 0x40000223, ItemID = 0xe75,
                        ItemLayer  = ItemLayer8.Backpack, ItemHue = 0x00
                    });
                    mobileIncoming.Build();
                    mobileIncoming.Compress();

                    mobileIncoming.Send(a.NetworkStream);

                    MobileStatus mobileStatus = new MobileStatus();
                    mobileStatus.Serial              = 2420;
                    mobileStatus.Name                = "lokis                         ".ToCharArray();
                    mobileStatus.HitPoints           = 0x50;
                    mobileStatus.MaximumHitPoints    = 0x50;
                    mobileStatus.AllowNameChange50   = AllowNameChange5.no;
                    mobileStatus.SupportedFeatures61 = SupportedFeatures6.MLattributes;
                    mobileStatus.Gender              = 0x00;
                    mobileStatus.Strength            = 0x3c;
                    mobileStatus.Dexterity           = 0x0a;
                    mobileStatus.Intelligence        = 0x0a;
                    mobileStatus.Stamina             = 0x0a;
                    mobileStatus.MaximumStamina      = 0x0a;
                    mobileStatus.Mana                = 0x0a;
                    mobileStatus.MaximumMana         = 0x0a;
                    mobileStatus.Gold                = 0;
                    mobileStatus.ArmorRating         = 0;
                    mobileStatus.Weight              = 0x0e;
                    mobileStatus.MaximumWeight       = 0x0136;
                    mobileStatus.Race72              = Race7.Human;
                    mobileStatus.StatCap             = 0xe1;
                    mobileStatus.Followers           = 0;
                    mobileStatus.MaximumFollowers    = 5;
                    mobileStatus.FireResistance      = 0;
                    mobileStatus.ColdResistance      = 0;
                    mobileStatus.PoisonResistance    = 0;
                    mobileStatus.EnergyResistance    = 0;
                    mobileStatus.Luck                = 0;
                    mobileStatus.MinimumWeaponDamage = 1;
                    mobileStatus.MaximumWeaponDamage = 5;
                    mobileStatus.TithingPoints       = 0;
                    mobileStatus.Build();
                    mobileStatus.Compress();

                    mobileStatus.Send(a.NetworkStream);

                    WarMode warMode = new WarMode();
                    warMode.Warmode = 0x00;
                    warMode.Build();
                    warMode.Compress();

                    warMode.Send(a.NetworkStream);

                    OPLInfo oplInfo2 = new OPLInfo();
                    oplInfo2.Serial = 2420;
                    oplInfo2.Hash   = 0x400f9705;
                    oplInfo2.Build();
                    oplInfo2.Compress();
                    oplInfo2.Send(a.NetworkStream);


                    //mobileIncoming.Send(a.TcpClient);

                    OPLInfo oplInfo = new OPLInfo();
                    //oplInfo.Serial = 2420;
                    oplInfo.Serial = 0x40013082;
                    //oplInfo.Hash = 0x4301baee;
                    oplInfo.Hash = 0x400f9705;
                    oplInfo.Build();
                    oplInfo.Compress();

                    oplInfo.Send(a.NetworkStream);
                    oplInfo2.Send(a.NetworkStream);

                    supportedFeatures.Send(a.NetworkStream);
                    mobileUpdate.Send(a.NetworkStream);
                    mobileStatus.Send(a.NetworkStream);
                    warMode.Send(a.NetworkStream);
                    mobileIncoming.Send(a.NetworkStream);

                    LoginConfirmed loginConfirmed = new LoginConfirmed();
                    loginConfirmed.Build();
                    loginConfirmed.Compress();

                    loginConfirmed.Send(a.NetworkStream);

                    GameTime gameTime = new GameTime();
                    gameTime.Hour   = Convert.ToByte(DateTime.Now.Hour);
                    gameTime.Minute = Convert.ToByte(DateTime.Now.Minute);
                    gameTime.Second = Convert.ToByte(DateTime.Now.Second);
                    gameTime.Build();
                    gameTime.Compress();

                    gameTime.Send(a.NetworkStream);

                    seasonChange.Send(a.NetworkStream);

                    mapChange.Send(a.NetworkStream);

                    DisplayPaperdoll displayPaperdoll = new DisplayPaperdoll();
                    displayPaperdoll.Flags550 = Flags55.CanLift;
                    displayPaperdoll.Serial   = 2420;
                    displayPaperdoll.Text     = "LoKiS, Apprentice smith";
                    displayPaperdoll.Build();
                    displayPaperdoll.Compress();

                    displayPaperdoll.Send(a.NetworkStream);

                    break;

                case 0x34:

                    SkillsUpdate skillsUpdate = new SkillsUpdate();
                    skillsUpdate.ListType220 = ListType22.capped;

                    Random rand = new Random();
                    for (int i = 0; i < 55; i++)
                    {
                        rand = new Random(new Random().Next() * rand.Next() * DateTime.Now.Millisecond);
                        Int16 skillBaseValue   = (short)rand.Next(1, 500);
                        Int16 skillCappedValue = (short)rand.Next(501, 1000);
                        Int16 skillValue       = (short)rand.Next(skillBaseValue, skillCappedValue);

                        //skillsUpdate.Skills.Add(new UOPackets.Skill() { SkillID = (SkillName)i+1, LockStatus = 0x00, SkillBaseValue = skillBaseValue, SkillCappedValue = skillCappedValue, SkillValue = skillValue });
                    }

                    skillsUpdate.Build();
                    skillsUpdate.Compress();
                    skillsUpdate.Send(a.NetworkStream);

                    break;

                case 0x02:
                    MovementAccepted movAccepted = new MovementAccepted();

                    movAccepted.Sequence = packet[2];
                    movAccepted.Status   = 0x03;
                    movAccepted.Build();
                    movAccepted.Compress();

                    movAccepted.Send(a.NetworkStream);

                    break;

                case 0x06:
                    //Ask the server if we can use an object (double click).
                    //5 bytes
                    //from client
                    //byte	ID (06)
                    //dword	Item Serial

                    UOPackets.ClientPackets.UseRequest useRequest = new UOPackets.ClientPackets.UseRequest();



                    //useRequest.

                    break;
                }
            }
            catch (Exception ex)
            {
            }
        }