Пример #1
0
 public static void Target( object o )
 {
     if ( o is Item )
     {
         Item item = (Item)o;
         TargetInfo info = new TargetInfo();
         info.Type = 0;
         info.Flags = 0;
         info.Serial = item.Serial;
         info.X = item.Position.X;
         info.Y = item.Position.Y;
         info.Z = item.Position.Z;
         info.Gfx = item.ItemID;
         Target( info );
     }
     else if ( o is Mobile )
     {
         Mobile m = (Mobile)o;
         TargetInfo info = new TargetInfo();
         info.Type = 0;
         info.Flags = 0;
         info.Serial = m.Serial;
         info.X = m.Position.X;
         info.Y = m.Position.Y;
         info.Z = m.Position.Z;
         info.Gfx = m.Body;
         Target( info );
     }
     else if ( o is Serial )
     {
         Target( (Serial)o );
     }
     else if ( o is TargetInfo )
     {
         Target( (TargetInfo)o );
     }
 }
Пример #2
0
 public TargetResponse( TargetInfo info )
     : base(0x6C, 19)
 {
     Write( (byte) info.Type );
     Write( (uint) info.TargID );
     Write( (byte) info.Flags );
     Write( (uint) info.Serial );
     Write( (ushort) info.X );
     Write( (ushort) info.Y );
     Write( (short) info.Z );
     Write( (ushort) info.Gfx );
 }
Пример #3
0
        public static void Target( Point3D pt, int gfx )
        {
            TargetInfo info = new TargetInfo();
            info.Type = 1;
            info.Flags = 0;
            info.Serial = 0;
            info.X = pt.X;
            info.Y = pt.Y;
            info.Z = pt.Z;
            info.Gfx = (ushort)(gfx & 0x3FFF);

            Target( info );
        }
Пример #4
0
        public static void Target( Serial s )
        {
            TargetInfo info = new TargetInfo();
            info.Type = 0;
            info.Flags = 0;
            info.Serial = s;

            if ( s.IsItem )
            {
                Item item = World.FindItem( s );
                if ( item != null )
                {
                    info.X = item.Position.X;
                    info.Y = item.Position.Y;
                    info.Z = item.Position.Z;
                    info.Gfx = item.ItemID;
                }
            }
            else if ( s.IsMobile )
            {
                Mobile m = World.FindMobile( s );
                if ( m != null )
                {
                    info.X = m.Position.X;
                    info.Y = m.Position.Y;
                    info.Z = m.Position.Z;
                    info.Gfx = m.Body;
                }
            }

            Target( info );
        }
Пример #5
0
        public static void Target( TargetInfo info )
        {
            if ( m_Intercept )
            {
                OneTimeResponse( info );
            }
            else if ( m_HasTarget )
            {
                info.TargID = m_CurrentID;
                m_LastGroundTarg = m_LastTarget = info;
                ClientCommunication.SendToServer( new TargetResponse( info ) );
            }

            CancelClientTarget();
            m_HasTarget = false;
        }
Пример #6
0
        public static void Target( Point3D pt )
        {
            TargetInfo info = new TargetInfo();
            info.Type = 1;
            info.Flags = 0;
            info.Serial = 0;
            info.X = pt.X;
            info.Y = pt.Y;
            info.Z = pt.Z;
            info.Gfx = 0;

            Target( info );
        }
Пример #7
0
        public static void SetLastTargetTo( Mobile m, byte flagType )
        {
            TargetInfo targ = new TargetInfo();
            m_LastGroundTarg = m_LastTarget = targ;

            if ( ( m_HasTarget && m_CurFlags == 1 ) || flagType == 1 )
                m_LastHarmTarg = targ;
            else if ( ( m_HasTarget && m_CurFlags == 2 ) || flagType == 2 )
                m_LastBeneTarg = targ;
            else if ( flagType == 0 )
                m_LastHarmTarg = m_LastBeneTarg = targ;

            targ.Type = 0;
            if ( m_HasTarget )
                targ.Flags = m_CurFlags;
            else
                targ.Flags = flagType;

            targ.Gfx = m.Body;
            targ.Serial = m.Serial;
            targ.X = m.Position.X;
            targ.Y = m.Position.Y;
            targ.Z = m.Position.Z;

            ClientCommunication.SendToClient( new ChangeCombatant( m ) );
            m_LastCombatant = m.Serial;
            World.Player.SendMessage( MsgLevel.Force, LocString.NewTargSet );

            bool wasSmart = Config.GetBool( "SmartLastTarget" );
            if ( wasSmart )
                Config.SetProperty( "SmartLastTarget", false );
            LastTarget();
            if ( wasSmart )
                Config.SetProperty( "SmartLastTarget", true );
            LastTargetChanged();
        }
Пример #8
0
        public static void NextTargetHumanoid()
        {
            ArrayList mobiles = World.MobilesInRange( 12 );
            ArrayList list = new ArrayList();

            foreach( Mobile mob in mobiles )
            {
                if ( mob.Body == 0x0190 || mob.Body == 0x0191 || mob.Body == 0x025D || mob.Body == 0x025E )
                    list.Add(mob);
            }

            if ( list.Count <= 0 )
            {
                World.Player.SendMessage( MsgLevel.Warning, LocString.TargNoOne );
                return;
            }

            TargetInfo targ = new TargetInfo();
            Mobile m = null, old = World.FindMobile(m_LastTarget == null ? Serial.Zero : m_LastTarget.Serial);

            for (int i=0;i<3;i++)
            {
                m_NextTargHumanoidIdx++;

                if ( m_NextTargHumanoidIdx >= list.Count )
                    m_NextTargHumanoidIdx = 0;

                m = (Mobile)list[m_NextTargHumanoidIdx];

                if ( m != null && m != World.Player && m != old )
                    break;
                else
                    m = null;
            }

            if ( m == null )
                m = old;

            if ( m == null )
            {
                World.Player.SendMessage( MsgLevel.Warning, LocString.TargNoOne );
                return;
            }

            m_LastGroundTarg = m_LastTarget = targ;

            m_LastHarmTarg = m_LastBeneTarg = targ;

            if ( m_HasTarget )
                targ.Flags = m_CurFlags;
            else
                targ.Type = 0;

            targ.Gfx = m.Body;
            targ.Serial = m.Serial;
            targ.X = m.Position.X;
            targ.Y = m.Position.Y;
            targ.Z = m.Position.Z;

            ClientCommunication.SendToClient( new ChangeCombatant( m ) );
            m_LastCombatant = m.Serial;
            World.Player.SendMessage( MsgLevel.Force, LocString.NewTargSet );

            /*if ( m_HasTarget )
            {
                DoLastTarget();
                ClearQueue();
            }*/
        }
Пример #9
0
        public static bool DoTargetSelf()
        {
            if ( World.Player == null )
                return false;

            if ( CheckHealPoisonTarg( m_CurrentID, World.Player.Serial ) )
                return false;

            CancelClientTarget();
            m_HasTarget = false;

            if ( m_Intercept )
            {
                TargetInfo targ = new TargetInfo();
                targ.Serial = World.Player.Serial;
                targ.Gfx = World.Player.Body;
                targ.Type = 0;
                targ.X = World.Player.Position.X;
                targ.Y = World.Player.Position.Y;
                targ.Z = World.Player.Position.Z;
                targ.TargID = LocalTargID;
                targ.Flags = 0;

                OneTimeResponse( targ );
            }
            else
            {
                ClientCommunication.SendToServer( new TargetResponse( m_CurrentID, World.Player ) );
            }

            return true;
        }
Пример #10
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;

            // 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

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

            m_FilterCancel.Clear();
        }
Пример #11
0
        private static void OnSetLastTarget( bool location, Serial serial, Point3D p, ushort gfxid )
        {
            if ( serial == World.Player.Serial )
            {
                OnSLTCancel();
                return;
            }

            m_LastBeneTarg = m_LastHarmTarg = m_LastGroundTarg = m_LastTarget = new TargetInfo();
            m_LastTarget.Flags = 0;
            m_LastTarget.Gfx = gfxid;
            m_LastTarget.Serial = serial;
            m_LastTarget.Type = (byte)(location ? 1 : 0);
            m_LastTarget.X = p.X;
            m_LastTarget.Y = p.Y;
            m_LastTarget.Z = p.Z;

            m_LTWasSet = true;

            World.Player.SendMessage( MsgLevel.Force, LocString.LTSet );
            if ( serial.IsMobile )
            {
                LastTargetChanged();
                ClientCommunication.SendToClient( new ChangeCombatant( serial ) );
                m_LastCombatant = serial;
            }
        }