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

            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));
                }

                ScriptManager.AddToScript(info.Serial == Serial.Zero
                    ? $"target 0x0 {info.X} {info.Y} {info.Z}"
                    : $"target {info.Serial}");


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

                        ScriptManager.AddToScript($"hotkey '{hk.DispName}'");
                    }
                    else
                    {
                        MacroManager.Action(new AbsoluteTargetAction(info));

                        ScriptManager.AddToScript($"target {info.Serial}");
                    }
                }
            }

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

            m_FilterCancel.Clear();
        }