Example #1
0
        public static void Read(PacketReader p)
        {
            Serial ser  = p.ReadUInt32();
            ushort zero = p.ReadUInt16();
            int    hash = p.ReadInt32();

            object old = m_Entries[ser];

            if (old is ObjectPropertyList)
            {
                if (((ObjectPropertyList)old).ServerHash + 0x40000000 == hash)
                {
                    return;
                }
            }

            ArrayList props = new ArrayList();

            while (true)
            {
                int num = p.ReadInt32();
                if (num == 0 || num == -1)
                {
                    break;
                }

                short  argLen = p.ReadInt16();
                string args   = String.Empty;

                if (argLen > 0)
                {
                    args = p.ReadUnicodeString(argLen >> 1);
                }

                props.Add(new ObjectProperty(num, args));
            }

            ObjectPropertyList list;

            m_Entries[ser] = list = new ObjectPropertyList(ser, hash, props);
            if (old is ObjectPropertyList)
            {
                list.Add(((ObjectPropertyList)old).MyProps);
            }
        }
Example #2
0
        internal void Read(PacketReader p)
        {
            var property_list = new List <OPLEntry>();


            p.Seek(5, System.IO.SeekOrigin.Begin); // seek to packet data

            p.ReadUInt32();                        // serial
            p.ReadByte();                          // 0
            p.ReadByte();                          // 0
            m_Hash = p.ReadInt32();

            m_StringNums.Clear();
            m_StringNums.AddRange(m_DefaultStringNums);

            while (p.Position < p.Length)
            {
                int num = p.ReadInt32();
                if (num == 0)
                {
                    break;
                }

                m_StringNums.Remove(num);

                short  bytes = p.ReadInt16();
                string args  = string.Empty;
                if (bytes > 0)
                {
                    args = p.ReadUnicodeStringBE(bytes >> 1);
                }

                if (property_list.Any(e => e.Number == num))
                {
                    continue;
                }
                else
                {
                    property_list.Add(new OPLEntry(num, args));
                }
            }

            m_Content = property_list;
        }
Example #3
0
        private static void MobileStatInfo(PacketReader pvSrc)
        {
            Serial serial = pvSrc.ReadUInt32();

            if (World.Player == null || serial != World.Player.Serial)
            {
                return;
            }
            PlayerData p = World.Player;

            p.HitsMax = pvSrc.ReadUInt16();
            p.Hits    = pvSrc.ReadUInt16();

            p.ManaMax = pvSrc.ReadUInt16();
            p.Mana    = pvSrc.ReadUInt16();

            p.StamMax = pvSrc.ReadUInt16();
            p.Stam    = pvSrc.ReadUInt16();
        }
Example #4
0
        private static void RemoveObject(PacketReader p)
        {
            Serial serial = p.ReadUInt32();

            if (serial.IsMobile)
            {
                Mobile m = World.FindMobile(serial);
                if (m != null && m != World.Player)
                {
                    m.Remove();
                }
            }
            else if (serial.IsItem)
            {
                Item i = World.FindItem(serial);
                if (i != null)
                {
                    i.Remove();
                }
            }
        }
Example #5
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 #6
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 #7
0
        private static void NewTarget(PacketReader p, PacketHandlerEventArgs args)
        {
            bool prevAllowGround  = m_AllowGround;
            uint prevID           = m_CurrentID;
            byte prevFlags        = m_CurFlags;
            bool prevClientTarget = m_ClientTarget;

            m_AllowGround = p.ReadBoolean(); // allow ground
            m_CurrentID   = p.ReadUInt32();  // target uid
            m_CurFlags    = p.ReadByte();    // flags
            // the rest of the packet is 0s

            // check for a server cancel command
            if (!m_AllowGround && m_CurrentID == 0 && m_CurFlags == 3)
            {
                m_HasTarget      = false;
                m_FromGrabHotKey = false;

                m_ClientTarget = false;
                if (m_Intercept)
                {
                    EndIntercept();
                    World.Player.SendMessage(MsgLevel.Error, LocString.OTTCancel);
                }

                return;
            }

            if (Spell.LastCastTime + TimeSpan.FromSeconds(3.0) > DateTime.UtcNow &&
                Spell.LastCastTime + TimeSpan.FromSeconds(0.5) <= DateTime.UtcNow && m_SpellTargID == 0)
            {
                m_SpellTargID = m_CurrentID;
            }

            m_HasTarget    = true;
            m_ClientTarget = false;

            if (m_QueueTarget == null && Macros.MacroManager.AcceptActions &&
                MacroManager.Action(new WaitForTargetAction()))
            {
                args.Block = true;
            }
            else if (m_QueueTarget != null && m_QueueTarget())
            {
                ClearQueue();
                args.Block = true;
            }

            if (args.Block)
            {
                if (prevClientTarget)
                {
                    m_AllowGround = prevAllowGround;
                    m_CurrentID   = prevID;
                    m_CurFlags    = prevFlags;

                    m_ClientTarget = true;

                    if (!m_Intercept)
                    {
                        CancelClientTarget();
                    }
                }
            }
            else
            {
                m_ClientTarget = true;

                if (m_Intercept)
                {
                    if (m_OnCancel != null)
                    {
                        m_OnCancel();
                    }
                    EndIntercept();
                    World.Player.SendMessage(MsgLevel.Error, LocString.OTTCancel);

                    m_FilterCancel.Add((uint)prevID);
                }
            }
        }
Example #8
0
        private static void TargetResponse(PacketReader p, PacketHandlerEventArgs args)
        {
            TargetInfo info = new TargetInfo
            {
                Type   = p.ReadByte(),
                TargID = p.ReadUInt32(),
                Flags  = p.ReadByte(),
                Serial = p.ReadUInt32(),
                X      = p.ReadUInt16(),
                Y      = p.ReadUInt16(),
                Z      = p.ReadInt16(),
                Gfx    = p.ReadUInt16()
            };

            m_ClientTarget = false;

            OverheadTargetMessage(info);

            // check for cancel
            if (info.X == 0xFFFF && info.X == 0xFFFF && (info.Serial <= 0 || info.Serial >= 0x80000000))
            {
                m_HasTarget      = false;
                m_FromGrabHotKey = false;

                if (m_Intercept)
                {
                    args.Block = true;
                    Timer.DelayedCallbackState(TimeSpan.Zero, m_OneTimeRespCallback, info).Start();
                    EndIntercept();

                    if (m_PreviousID != 0)
                    {
                        m_CurrentID   = m_PreviousID;
                        m_AllowGround = m_PreviousGround;
                        m_CurFlags    = m_PrevFlags;

                        m_PreviousID = 0;

                        ResendTarget();
                    }
                }
                else if (m_FilterCancel.Contains((uint)info.TargID) || info.TargID == LocalTargID)
                {
                    args.Block = true;
                }

                m_FilterCancel.Clear();
                return;
            }

            ClearQueue();

            if (m_Intercept)
            {
                if (info.TargID == LocalTargID)
                {
                    Timer.DelayedCallbackState(TimeSpan.Zero, m_OneTimeRespCallback, info).Start();

                    m_HasTarget      = false;
                    m_FromGrabHotKey = false;
                    args.Block       = true;

                    if (m_PreviousID != 0)
                    {
                        m_CurrentID   = m_PreviousID;
                        m_AllowGround = m_PreviousGround;
                        m_CurFlags    = m_PrevFlags;

                        m_PreviousID = 0;

                        ResendTarget();
                    }

                    m_FilterCancel.Clear();

                    return;
                }
                else
                {
                    EndIntercept();
                }
            }

            m_HasTarget = false;

            if (CheckHealPoisonTarg(m_CurrentID, info.Serial))
            {
                ResendTarget();
                args.Block = true;
            }

            if (info.Serial != World.Player.Serial)
            {
                if (info.Serial.IsValid)
                {
                    // only let lasttarget be a non-ground target

                    m_LastTarget = info;
                    if (info.Flags == 1)
                    {
                        m_LastHarmTarg = info;
                    }
                    else if (info.Flags == 2)
                    {
                        m_LastBeneTarg = info;
                    }

                    LastTargetChanged();
                    LastBeneficialTargetChanged();
                    LastHarmfulTargetChanged();
                }

                m_LastGroundTarg = info; // ground target is the true last target

                if (Macros.MacroManager.AcceptActions)
                {
                    MacroManager.Action(new AbsoluteTargetAction(info));
                }
            }
            else
            {
                if (Macros.MacroManager.AcceptActions)
                {
                    KeyData hk = HotKey.Get((int)LocString.TargetSelf);
                    if (hk != null)
                    {
                        MacroManager.Action(new HotKeyAction(hk));
                    }
                    else
                    {
                        MacroManager.Action(new AbsoluteTargetAction(info));
                    }
                }
            }

            if (World.Player.LastSpell == 52 && !GateTimer.Running)
            {
                GateTimer.Start();
            }

            m_FilterCancel.Clear();
        }
Example #9
0
        private static void TargetResponse(PacketReader p, PacketHandlerEventArgs args)
        {
            m_NoShowTarget = false;

            TargetInfo info = new TargetInfo
            {
                Type   = p.ReadByte(),
                TargID = p.ReadUInt32(),
                Flags  = p.ReadByte(),
                Serial = p.ReadUInt32(),
                X      = p.ReadUInt16(),
                Y      = p.ReadUInt16(),
                Z      = p.ReadInt16(),
                Gfx    = p.ReadUInt16()
            };

            m_ClientTarget = false;

            if (RazorEnhanced.ScriptRecorder.OnRecord)
            {
                RazorEnhanced.ScriptRecorder.Record_Target(info);
            }

            if (info.Serial != 0 && info.Serial.IsMobile)
            {
                RazorEnhanced.Target.TargetMessage(info.Serial, false);
            }

            // check for cancel
            if (info.X == 0xFFFF && info.X == 0xFFFF && (info.Serial <= 0 || info.Serial >= 0x80000000))
            {
                m_HasTarget = false;

                if (m_Intercept)
                {
                    args.Block = true;
                    Timer.DelayedCallbackState(TimeSpan.Zero, m_OneTimeRespCallback, info).Start();
                    EndIntercept();

                    if (m_PreviousID != 0)
                    {
                        m_CurrentID   = m_PreviousID;
                        m_AllowGround = m_PreviousGround;
                        m_CurFlags    = m_PrevFlags;

                        m_PreviousID = 0;

                        ResendTarget();
                    }
                }
                else if (m_FilterCancel.Contains((uint)info.TargID) || info.TargID == LocalTargID)
                {
                    args.Block = true;
                }

                m_FilterCancel.Clear();
                return;
            }

            ClearQueue();

            if (m_Intercept)
            {
                if (info.TargID == LocalTargID)
                {
                    Timer.DelayedCallbackState(TimeSpan.Zero, m_OneTimeRespCallback, info).Start();

                    m_HasTarget = false;
                    args.Block  = true;

                    if (m_PreviousID != 0)
                    {
                        m_CurrentID   = m_PreviousID;
                        m_AllowGround = m_PreviousGround;
                        m_CurFlags    = m_PrevFlags;

                        m_PreviousID = 0;

                        ResendTarget();
                    }

                    m_FilterCancel.Clear();

                    return;
                }
                else
                {
                    EndIntercept();
                }
            }

            m_HasTarget = false;

            if (CheckHealPoisonTarg(m_CurrentID, info.Serial))
            {
                ResendTarget();
                args.Block = true;
            }

            if (info.Serial != World.Player.Serial)
            {
                if (info.Serial.IsValid)
                {
                    // only let lasttarget be a non-ground target

                    m_LastTarget = info;
                    if (info.Flags == 1)
                    {
                        m_LastHarmTarg = info;
                    }
                    else if (info.Flags == 2)
                    {
                        m_LastBeneTarg = info;
                    }

                    LastTargetChanged();
                }

                m_LastGroundTarg = info;                 // ground target is the true last target
            }

            m_FilterCancel.Clear();
        }
Example #10
0
 private static void PersonalLight(PacketReader p)
 {
     p.ReadUInt32();             // serial
     World.Player.LocalLightLevel = p.ReadSByte();
 }
Example #11
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 #12
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();
        }
Example #13
0
        private static void TargetResponse(PacketReader p, PacketHandlerEventArgs args)
        {
            TargetInfo info = new TargetInfo();

            info.Type   = p.ReadByte();
            info.TargID = p.ReadUInt32();
            info.Flags  = p.ReadByte();
            info.Serial = p.ReadUInt32();
            info.X      = p.ReadUInt16();
            info.Y      = p.ReadUInt16();
            info.Z      = p.ReadInt16();
            info.Gfx    = p.ReadUInt16();

            m_ClientTarget = false;

            //if (Config.GetBool("ShowAttackTargetOverhead"))
            //{
            //    Mobile m = World.FindMobile(info.Serial);

            //    if (m != null)
            //    {
            //        if (FriendsAgent.IsFriend(m))
            //        {
            //            World.Player.OverheadMessage(63, $"Target: {m.Name}");
            //        }
            //        else
            //        {
            //            World.Player.OverheadMessage(m.GetNotorietyColorInt(), $"Target: {m.Name}");
            //        }
            //    }
            //}

            // check for cancel
            if (info.X == 0xFFFF && info.X == 0xFFFF && (info.Serial <= 0 || info.Serial >= 0x80000000))
            {
                m_HasTarget = false;

                m_FilterCancel.Clear();
                return;
            }

            ClearQueue();

            m_HasTarget = false;



            if (info.Serial != World.Player.Serial)
            {
                if (info.Serial.IsValid)
                {
                    // only let lasttarget be a non-ground target

                    m_LastTarget = info;
                    if (info.Flags == 1)
                    {
                        m_LastHarmTarg = info;
                    }
                    else if (info.Flags == 2)
                    {
                        m_LastBeneTarg = info;
                    }

                    LastTargetChanged();
                }

                m_LastGroundTarg = info; // ground target is the true last target
            }
            else
            {
            }
        }