Exemplo n.º 1
0
        private static void OneTimeResponse(object state)
        {
            TargetInfo info = state as TargetInfo;

            if (info != null)
            {
                if ((info.X == 0xFFFF && info.X == 0xFFFF) && (info.Serial == 0 || info.Serial >= 0x80000000))
                {
                    if (m_OnCancel != null)
                    {
                        m_OnCancel();
                    }
                }
                else
                {
                    if (Macros.MacroManager.AcceptActions)
                    {
                        MacroManager.Action(new AbsoluteTargetAction(info));
                    }

                    if (m_OnTarget != null)
                    {
                        m_OnTarget(info.Type == 1 ? true : false, info.Serial, new Point3D(info.X, info.Y, info.Z),
                                   info.Gfx);
                    }
                }
            }

            EndIntercept();
        }
Exemplo n.º 2
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);
                }
            }
        }
Exemplo n.º 3
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();
        }