Example #1
0
        private static void MobileUpdate(PacketReader p)
        {
            if (World.Player == null)
            {
                return;
            }

            Serial serial = p.ReadUInt32();
            Mobile m      = World.FindMobile(serial);

            if (m == null)
            {
                World.AddMobile(m = new Mobile(serial));
            }
            m.Body = (ushort)(p.ReadUInt16() + p.ReadSByte());
            m.Hue  = p.ReadUInt16();
            bool wasPoisoned = m.Poisoned;

            m.ProcessPacketFlags(p.ReadByte());

            ushort x = p.ReadUInt16();
            ushort y = p.ReadUInt16();

            p.ReadUInt16();             //always 0?
            m.Direction = (Direction)p.ReadByte();
            m.Position  = new Point3D(x, y, p.ReadSByte());

            Item.UpdateContainers();
        }
Example #2
0
        private static void EquipmentUpdate(PacketReader p)
        {
            Serial serial = p.ReadUInt32();

            Item i = World.FindItem(serial);

            if (i == null)
            {
                World.AddItem(i = new Item(serial));
                Item.UpdateContainers();
            }

            if (World.Player != null && World.Player.Holding == i)
            {
                World.Player.Holding = null;
            }

            ushort iid = p.ReadUInt16();

            i.ItemID = (ushort)(iid + p.ReadSByte()); // signed, itemID offset
            i.Layer  = p.ReadByte();
            Serial ser = p.ReadUInt32();              // cont must be set after hue (for counters)

            i.Hue = p.ReadUInt16();

            i.Container = ser;
        }
Example #3
0
        private static void MobileMoving(PacketReader p)
        {
            Mobile m = World.FindMobile(p.ReadUInt32());

            if (m != null)
            {
                m.Body     = p.ReadUInt16();
                m.Position = new Point3D(p.ReadUInt16(), p.ReadUInt16(), p.ReadSByte());

                if (Utility.Distance(World.Player.Position, m.Position) > 18)
                {
                    World.RemoveMobile(m);
                    return;
                }

                m.Direction = (Direction)p.ReadByte();
                m.Hue       = p.ReadUInt16();
                bool wasPoisoned = m.Poisoned;
                m.ProcessPacketFlags(p.ReadByte());
                byte oldNoto = m.Notoriety;
                m.Notoriety = p.ReadByte();
            }
        }
Example #4
0
        private static void MobileMoving(PacketReader p, PacketHandlerEventArgs args)
        {
            Mobile m = World.FindMobile(p.ReadUInt32());

            if (m != null && m.Notoriety == (byte)m_Type && m_Type != AutoTargType.none)
            {
                Point3D oldPos = m.Position;
                Point3D newPos = new Point3D(p.ReadUInt16(), p.ReadUInt16(), p.ReadSByte());

                int dist    = Utility.Distance(World.Player.Position, newPos);
                int oldDist = Utility.Distance(World.Player.Position, oldPos);
                int range   = 15;
                if (Config.GetBool("RangeCheckLT"))
                {
                    range = Config.GetInt("LTRange");
                }

                if (oldDist > dist && oldDist > range && dist <= range)
                {
                    Targeting.SetLastTargetTo(m);
                    World.Player.SendMessage(MsgLevel.Force, "New target acquired.");
                }
            }
        }
Example #5
0
 private static void PersonalLight(PacketReader p)
 {
     p.ReadUInt32();             // serial
     World.Player.LocalLightLevel = p.ReadSByte();
 }
Example #6
0
        private static void WorldItem(PacketReader p)
        {
            Item item;
            uint serial = p.ReadUInt32();

            item = World.FindItem(serial & 0x7FFFFFFF);
            if (item == null)
            {
                World.AddItem(item = new Item(serial & 0x7FFFFFFF));
            }

            item.Container = null;
            if (World.Player.Holding == item)
            {
                World.Player.Holding = null;
            }

            ushort itemID = p.ReadUInt16();

            item.ItemID = (ushort)(itemID & 0x7FFF);

            if ((serial & 0x80000000) != 0)
            {
                item.Amount = p.ReadUInt16();
            }
            else
            {
                item.Amount = 0;
            }

            if ((itemID & 0x8000) != 0)
            {
                item.ItemID = (ushort)(item.ItemID + p.ReadSByte());
            }

            ushort x = p.ReadUInt16();
            ushort y = p.ReadUInt16();

            if ((x & 0x8000) != 0)
            {
                item.Direction = p.ReadByte();
            }
            else
            {
                item.Direction = 0;
            }

            short z = p.ReadSByte();

            item.Position = new Point3D(x & 0x3FFF, y & 0x3FFF, z);

            if ((y & 0x8000) != 0)
            {
                item.Hue = p.ReadUInt16();
            }
            else
            {
                item.Hue = 0;
            }

            byte flags = 0;

            if ((y & 0x4000) != 0)
            {
                flags = p.ReadByte();
            }

            item.ProcessPacketFlags(flags);

            Item.UpdateContainers();
        }
Example #7
0
        private static void MobileIncoming(PacketReader p)
        {
            Serial  serial   = p.ReadUInt32();
            ushort  body     = p.ReadUInt16();
            Point3D position = new Point3D(p.ReadUInt16(), p.ReadUInt16(), p.ReadSByte());

            if (Utility.Distance(World.Player.Position, position) > 18)
            {
                return;
            }

            Mobile m = World.FindMobile(serial);

            if (m == null)
            {
                World.AddMobile(m = new Mobile(serial));
            }

            bool wasHidden = !m.Visible;

            m.Body      = body;
            m.Position  = position;
            m.Direction = (Direction)p.ReadByte();
            m.Hue       = p.ReadUInt16();
            bool wasPoisoned = m.Poisoned;

            m.ProcessPacketFlags(p.ReadByte());
            byte oldNoto = m.Notoriety;

            m.Notoriety = p.ReadByte();

            while (true)
            {
                serial = p.ReadUInt32();
                if (!serial.IsItem)
                {
                    break;
                }

                Item item = World.FindItem(serial);
                if (item == null)
                {
                    World.AddItem(item = new Item(serial));
                }

                if (World.Player.Holding == item)
                {
                    World.Player.Holding = null;
                }

                ushort id = p.ReadUInt16();
                item.ItemID = (ushort)(id & 0x3FFF);
                item.Layer  = p.ReadByte();

                if ((id & 0x8000) != 0)
                {
                    item.Hue = p.ReadUInt16();
                }
                else
                {
                    item.Hue = 0;
                }

                item.Container = m;
            }
            Item.UpdateContainers();
        }