Beispiel #1
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();
        }
Beispiel #2
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();
        }
Beispiel #3
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();
        }
Beispiel #4
0
        private static void Skills(PacketReader p)
        {
            if (World.Player == null)
            {
                return;
            }

            byte type = p.ReadByte();

            switch (type)
            {
            case 0x02:                    //list (with caps, 3.0.8 and up)
            {
                int i;
                while ((i = p.ReadUInt16()) > 0)
                {
                    if (i > 0 && i <= Skill.Count)
                    {
                        Skill skill = World.Player.Skills[i - 1];

                        skill.FixedValue = p.ReadUInt16();
                        skill.FixedBase  = p.ReadUInt16();
                        skill.Lock       = (LockType)p.ReadByte();
                        skill.FixedCap   = p.ReadUInt16();
                    }
                    else
                    {
                        p.Seek(7, SeekOrigin.Current);
                    }
                }
                break;
            }

            case 0xDF:                    //change (with cap, new clients)
            {
                int i = p.ReadUInt16();

                if (i >= 0 && i < Skill.Count)
                {
                    Skill skill = World.Player.Skills[i];

                    skill.FixedValue = p.ReadUInt16();
                    skill.FixedBase  = p.ReadUInt16();
                    skill.Lock       = (LockType)p.ReadByte();
                    skill.FixedCap   = p.ReadUInt16();
                }
                break;
            }

            case 0x00:                     // list (without caps, older clients)
            {
                int i;
                while ((i = p.ReadUInt16()) > 0)
                {
                    if (i > 0 && i <= Skill.Count)
                    {
                        Skill skill = World.Player.Skills[i - 1];

                        skill.FixedValue = p.ReadUInt16();
                        skill.FixedBase  = p.ReadUInt16();
                        skill.Lock       = (LockType)p.ReadByte();
                        skill.FixedCap   = 100;                              //p.ReadUInt16();
                    }
                    else
                    {
                        p.Seek(5, SeekOrigin.Current);
                    }
                }
                break;
            }

            case 0xFF:                    //change (without cap, older clients)
            {
                int i = p.ReadUInt16();

                if (i >= 0 && i < Skill.Count)
                {
                    Skill skill = World.Player.Skills[i];

                    skill.FixedValue = p.ReadUInt16();
                    skill.FixedBase  = p.ReadUInt16();
                    skill.Lock       = (LockType)p.ReadByte();
                    skill.FixedCap   = 100;
                }
                break;
            }
            }
        }
Beispiel #5
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();
        }
Beispiel #6
0
 private static void ServerChange(PacketReader p)
 {
     World.Player.Position = new Point3D(p.ReadUInt16(), p.ReadUInt16(), p.ReadInt16());
 }
Beispiel #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();
        }
Beispiel #8
0
        private static void MobileStatus(PacketReader p)
        {
            Serial serial = p.ReadUInt32();
            Mobile m      = World.FindMobile(serial);

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

            m.Name = p.ReadString(30);

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

            p.ReadBoolean();            //CanBeRenamed

            byte type = p.ReadByte();

            if (m == World.Player && type != 0x00)
            {
                PlayerData player = (PlayerData)m;

                player.Female = p.ReadBoolean();

                player.Str = p.ReadUInt16();
                player.Dex = p.ReadUInt16();
                player.Int = p.ReadUInt16();

                player.Stam    = p.ReadUInt16();
                player.StamMax = p.ReadUInt16();
                player.Mana    = p.ReadUInt16();
                player.ManaMax = p.ReadUInt16();

                player.Gold   = p.ReadUInt32();
                player.AR     = p.ReadUInt16();             // ar / physical resist
                player.Weight = p.ReadUInt16();

                if (type == 0x03 || type == 0x04)
                {
                    player.StatCap      = p.ReadUInt16();
                    player.Followers    = p.ReadByte();
                    player.FollowersMax = p.ReadByte();

                    if (type == 0x04)
                    {
                        /*m_Stream.Write( (short) beheld.FireResistance ); // Fire
                         * m_Stream.Write( (short) beheld.ColdResistance ); // Cold
                         * m_Stream.Write( (short) beheld.PoisonResistance ); // Poison
                         * m_Stream.Write( (short) beheld.EnergyResistance ); // Energy
                         * m_Stream.Write( (short) 0 ); // Luck
                         * m_Stream.Write( (short) 0 ); // Damage min
                         * m_Stream.Write( (short) 0 ); // Damage max*/
                        p.Seek(14, SeekOrigin.Current);
                        player.Tithe = p.ReadInt32();
                    }
                }
            }
        }
Beispiel #9
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
            {
            }
        }