Exemplo n.º 1
0
            private static void IncomingPackets_EquippedMobAddedEvent(int client, Mobile mobile, ItemCollection equipment)
            {
                ClientInfo ci;

                if (ClientInfoCollection.GetClient(client, out ci))
                {
                    foreach (Item i in equipment.GetItems())
                    {
                        mobile.SetLayer((int)i.Layer, i.Serial);
                        ci.Items.Add(i);
                    }
                    PlayerMobile p = ci.Player;
                    if (p != null && mobile.Serial == p.Serial)
                    {
                        p.Status       = mobile.myStatus;
                        p.ID           = mobile.myID;
                        p.X            = mobile.myX;
                        p.Y            = mobile.myY;
                        p.Z            = mobile.myZ;
                        p.Direction    = mobile.myDirection;
                        p.Hue          = mobile.myHue;
                        p.Notoriety    = mobile.myNotoriety;
                        p.myLayerArray = mobile.myLayerArray;
                    }
                    else
                    {
                        //mobile.Equipment = equipment;
                        ci.Mobiles.Add(mobile);
                    }
                }
            }
Exemplo n.º 2
0
        /// <summary>
        /// Send array of System.Window.Forms.Keys to client as keypresses.  Restores and activates window.
        /// </summary>
        /// <param name="client">Target client.</param>
        /// <param name="keys">System.Window.Forms.Keys to send.</param>
        /// <returns>True if all keys were successfully sent.</returns>
        public static bool SendKeys(int client, Keys[] keys)
        {
            if (keys.Length == 0)
            {
                return(false);
            }
            ClientInfo ci;

            if (ClientInfoCollection.GetClient(client, out ci))
            {
                NativeMethods.INPUT[]    inputs = new NativeMethods.INPUT[keys.Length * 2];
                NativeMethods.KEYBDINPUT kbi    = new NativeMethods.KEYBDINPUT();

                if (!ci.PrepareWindowForInput())
                {
                    ci.DetachFromWindow();
                    return(false);
                }

                for (int x = 0; x < keys.Length; x++)
                {
                    kbi.dwFlags               = 0;
                    kbi.wVk                   = (ushort)keys[x];
                    inputs[x * 2].mkhi.ki     = kbi;
                    inputs[x * 2].type        = NativeMethods.INPUT_KEYBOARD;
                    kbi.dwFlags               = NativeMethods.KEYEVENTF_KEYUP;
                    inputs[x * 2 + 1].mkhi.ki = kbi;
                    inputs[x * 2 + 1].type    = NativeMethods.INPUT_KEYBOARD;
                }
                uint success = NativeMethods.SendInput((uint)inputs.Length, inputs, Marshal.SizeOf(inputs[0]));
                ci.DetachFromWindow();
                return(success == inputs.Length);
            }
            return(false);
        }
Exemplo n.º 3
0
            private static void IncomingPackets_MobileUpdatedEvent(int client, int serial, int ID, int hue, int status, int x, int y, int z, int direction)
            {
                Mobile m;

                if (ClientInfoCollection.GetMobile(client, serial, out m))
                {
                    m.ID        = ID;
                    m.X         = x;
                    m.Y         = y;
                    m.Z         = z;
                    m.Direction = direction;
                    m.Hue       = hue;
                    m.Status    = status;
                }
                else
                {
                    ClientInfo ci;
                    if (ClientInfoCollection.GetClient(client, out ci))
                    {
                        PlayerMobile p = ci.Player;
                        if (p != null && p.Serial == serial)
                        {
                            p.ID        = ID;
                            p.X         = x;
                            p.Y         = y;
                            p.Z         = z;
                            p.Direction = direction;
                            p.Hue       = hue;
                            p.Status    = status;
                        }
                    }
                }
            }
Exemplo n.º 4
0
        public static void Target(int client, Item item)
        {
            ClientInfo ci;

            if (item != null && ClientInfoCollection.GetClient(client, out ci))
            {
                byte[] packet = new byte[19];
                packet[0]  = 0x6C;
                packet[1]  = 0x00;
                packet[2]  = (byte)(ci.TargetID >> 24);
                packet[3]  = (byte)(ci.TargetID >> 16);
                packet[4]  = (byte)(ci.TargetID >> 8);
                packet[5]  = (byte)(ci.TargetID);
                packet[7]  = (byte)(item.Serial >> 24);
                packet[8]  = (byte)(item.Serial >> 16);
                packet[9]  = (byte)(item.Serial >> 8);
                packet[10] = (byte)(item.Serial);
                packet[11] = (byte)(item.X >> 8);
                packet[12] = (byte)item.X;
                packet[13] = (byte)(item.Y >> 8);
                packet[14] = (byte)item.Y;
                //packet[15] = (byte)(item.Z >> 8);
                packet[16] = (byte)item.Z;
                packet[17] = (byte)(item.ID >> 8);
                packet[18] = (byte)item.ID;
                SendPacketToServer(client, packet);
                Macro.SetTargetCursor(client, false);
            }
        }
Exemplo n.º 5
0
        public static void Target(int client, StaticTile staticTile)
        {
            ClientInfo ci;

            if (staticTile != null && ClientInfoCollection.GetClient(client, out ci))
            {
                int    x      = staticTile.X;
                int    y      = staticTile.Y;
                int    z      = staticTile.Z;
                int    ID     = staticTile.ID;
                byte[] packet = new byte[19];
                packet[0]  = 0x6C;
                packet[1]  = 0x01;
                packet[2]  = (byte)(ci.TargetID >> 24);
                packet[3]  = (byte)(ci.TargetID >> 16);
                packet[4]  = (byte)(ci.TargetID >> 8);
                packet[5]  = (byte)(ci.TargetID);
                packet[11] = (byte)(staticTile.X >> 8);
                packet[12] = (byte)staticTile.X;
                packet[13] = (byte)(staticTile.Y >> 8);
                packet[14] = (byte)staticTile.Y;
                //packet[15] = (byte)(staticTile.Z >> 8);
                packet[16] = (byte)staticTile.Z;
                packet[17] = (byte)(staticTile.ID >> 8);
                packet[18] = (byte)staticTile.ID;
                SendPacketToServer(client, packet);
                Macro.SetTargetCursor(client, false);
            }
        }
Exemplo n.º 6
0
        public static void Target(int client, Mobile mobile)
        {
            PlayerMobile pm;

            if (mobile != null && ClientInfoCollection.GetPlayer(client, out pm))
            {
                byte[] packet = new byte[19];
                packet[0]  = 0x6C;
                packet[1]  = 0x00;
                packet[2]  = (byte)(pm.Serial >> 24);
                packet[3]  = (byte)(pm.Serial >> 16);
                packet[4]  = (byte)(pm.Serial >> 8);
                packet[5]  = (byte)(pm.Serial);
                packet[7]  = (byte)(mobile.Serial >> 24);
                packet[8]  = (byte)(mobile.Serial >> 16);
                packet[9]  = (byte)(mobile.Serial >> 8);
                packet[10] = (byte)(mobile.Serial);
                packet[11] = (byte)(mobile.X >> 8);
                packet[12] = (byte)mobile.X;
                packet[13] = (byte)(mobile.Y >> 8);
                packet[14] = (byte)mobile.Y;
                //packet[15] = (byte)(mobile.Z >> 8);
                packet[16] = (byte)mobile.Z;
                packet[17] = (byte)(mobile.ID >> 8);
                packet[18] = (byte)mobile.ID;
                SendPacketToServer(client, packet);
                Macro.SetTargetCursor(client, false);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Send text to client as keypresses.  Restores and activates window.
        /// </summary>
        /// <param name="client">Target client.</param>
        /// <param name="text">String to send.</param>
        /// <returns>True if all text was successfully sent.</returns>
        public static bool SendText(int client, string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(false);
            }
            ClientInfo ci;

            if (ClientInfoCollection.GetClient(client, out ci))
            {
                if (!ci.PrepareWindowForInput())
                {
                    ci.DetachFromWindow();
                    return(false);
                }
                Win32.INPUT[]    inputs = new Win32.INPUT[text.Length * 2];
                Win32.KEYBDINPUT kbi    = new Win32.KEYBDINPUT();
                for (int x = 0; x < text.Length; x++)
                {
                    kbi.wScan                 = text[x];
                    kbi.dwFlags               = Win32.KEYEVENTF_UNICODE;
                    inputs[x * 2].mkhi.ki     = kbi;
                    inputs[x * 2].type        = Win32.INPUT_KEYBOARD;
                    kbi.dwFlags               = Win32.KEYEVENTF_KEYUP | Win32.KEYEVENTF_UNICODE;
                    inputs[x * 2 + 1].mkhi.ki = kbi;
                    inputs[x * 2 + 1].type    = Win32.INPUT_KEYBOARD;
                }
                uint success = Win32.SendInput((uint)inputs.Length, inputs, Marshal.SizeOf(inputs[0]));
                ci.DetachFromWindow();
                return(success == inputs.Length);
            }
            return(false);
        }
Exemplo n.º 8
0
            private static void ServerInstance_FunctionPointerEvent(int clientID, uint address, FunctionType functionType)
            {
                int        clientIndex = GetClient(clientID);
                ClientInfo ci;

                if (ClientInfoCollection.GetClient(clientIndex, out ci))
                {
                    switch (functionType)
                    {
                    case FunctionType.Receive:
                        ci.RecvFunctionPointer = (IntPtr)address;
                        ClientHook.InstallRecvHook(ci);
#if DEBUG
                        Log.LogMessage(clientID, "Recv function pointer = 0x" + address.ToString("X"));
#endif
                        break;

                    case FunctionType.Send:
                        ci.SendFunctionPointer = (IntPtr)address;
                        ClientHook.InstallSendHook(ci);
#if DEBUG
                        Log.LogMessage(clientID, "Send function pointer = 0x" + address.ToString("X"));
#endif
                        break;
                    }
                }
            }
Exemplo n.º 9
0
            private static void OutgoingPackets_MoveRequestedEvent(int client, int direction, int sequence)
            {
                ClientInfo ci;

                if (ClientInfoCollection.GetClient(client, out ci))
                {
                    ci.SetSequence(sequence, direction);
                }
            }
Exemplo n.º 10
0
        /// <summary>
        /// Remove all keyboard macros from the specified client.
        /// </summary>
        public static void ClearKeyboardMacros(int client)
        {
            ClientInfo ci;

            if (ClientInfoCollection.GetClient(client, out ci))
            {
                ci.HotKeyList.ClearKeys();
            }
        }
Exemplo n.º 11
0
            private static void IncomingPackets_MobileNameEvent(int client, int serial, string name)
            {
                Mobile m;

                if (ClientInfoCollection.GetMobile(client, serial, out m))
                {
                    m.Name = name;
                }
            }
Exemplo n.º 12
0
        public static void ClearRecvFilter(int client, byte packetID)
        {
            ClientInfo ci;

            if (ClientInfoCollection.GetClient(client, out ci))
            {
                Network.SendCommand(ci.IPCServerIndex, Command.ClearRecvFilter);
            }
        }
Exemplo n.º 13
0
            private static void IncomingPackets_UnicodeTextEvent(int client, JournalEntry journalEntry)
            {
                ClientInfo ci;

                if (ClientInfoCollection.GetClient(client, out ci))
                {
                    ci.Journal.Write(journalEntry);
                }
            }
Exemplo n.º 14
0
            private static void IncomingPackets_InternalAttackTargetEvent(int client, int serial)
            {
                ClientInfo ci;

                if (ClientInfoCollection.GetClient(client, out ci))
                {
                    ci.CurrentAttackTarget = serial;
                }
            }
Exemplo n.º 15
0
        public static void AddGumpResponseFilter(int client, uint serial, uint gumpid)
        {
            ClientInfo ci;

            if (ClientInfoCollection.GetClient(client, out ci))
            {
                Network.SendCommand(ci.IPCServerIndex, Command.AddGumpResponseFilter, (int)serial, (int)gumpid, 0);
            }
        }
Exemplo n.º 16
0
            private static void IncomingPackets_InternalCloseGumpEvent(int client, int gumpID, int buttonID)
            {
                ClientInfo ci;

                if (ClientInfoCollection.GetClient(client, out ci))
                {
                    ci.GenericGumps.Remove(gumpID);
                }
            }
Exemplo n.º 17
0
        /// <summary>
        /// Pause until target packet is received.
        /// </summary>
        /// <param name="client">Target client.</param>
        /// <param name="timeout">Timeout in milliseconds, -1 is infinite.</param>
        public static void WaitForTarget(int client, int timeout)
        {
            ClientInfo ci;

            if (ClientInfoCollection.GetClient(client, out ci))
            {
                ci.WaitForTarget(timeout);
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Send packet directly to client's packet receive function.
        /// </summary>
        /// <param name="client">Target client.</param>
        /// <param name="packet">Raw packets to send.</param>
        public static void SendPacketToClient(int client, byte[] packet)
        {
            ClientInfo ci;

            if (ClientInfoCollection.GetClient(client, out ci))
            {
                Network.SendCommand(ci.IPCServerIndex, Command.SendPacket, ci.ClientSendCaveAddress.ToInt32(), (byte)PacketType.Client, packet);
            }
        }
Exemplo n.º 19
0
            private static void IncomingPackets_SkillListEvent(int client, SkillInfo[] skills)
            {
                ClientInfo ci;

                if (ClientInfoCollection.GetClient(client, out ci))
                {
                    ci.Skills = skills;
                }
            }
Exemplo n.º 20
0
            private static void IncomingPackets_TargetEvent(int client, int targetType)
            {
                ClientInfo ci;

                if (ClientInfoCollection.GetClient(client, out ci))
                {
                    ci.TargetReceived();
                }
            }
Exemplo n.º 21
0
        /// <summary>
        /// Read memory from specified client.  Amount to read is determined by buffer size.
        /// </summary>
        /// <param name="address">Address of memory to read.</param>
        /// <param name="buffer">Destination for memory read from process.</param>
        public static bool ReadClientMemory(int client, IntPtr address, byte[] buffer)
        {
            ClientInfo ci;

            if (ClientInfoCollection.GetClient(client, out ci))
            {
                return(Memory.Read(ci.Handle, address, buffer, false));
            }
            return(false);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Get skill information for a specific skill from the specified UO client.
        /// </summary>
        public static SkillInfo GetSkillInfo(int client, Skill skill)
        {
            ClientInfo ci;

            if (ClientInfoCollection.GetClient(client, out ci))
            {
                return(ci.GetSkillInfo((int)skill));
            }
            return(null);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Add keyboard macro to specified client.
        /// </summary>
        /// <param name="keys">Keys associated with the macro.</param>
        /// <param name="callback">A delegate to be called whenever the specified key combination is pressed.</param>
        /// <returns>True on success.</returns>
        public static bool AddKeyboardMacro(int client, Keys[] keys, KeyPressCallback callback)
        {
            ClientInfo ci;

            if (ClientInfoCollection.GetClient(client, out ci))
            {
                return(ci.HotKeyList.AddKeys(keys, callback));
            }
            return(false);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Get current skill information for the specified UO client.
        /// </summary>
        public static SkillInfo[] GetSkills(int client)
        {
            ClientInfo ci;

            if (ClientInfoCollection.GetClient(client, out ci))
            {
                return(ci.Skills);
            }
            return(null);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Sets cursor to normal and sends target cancel packet to server.
        /// Has the same effect as pressing Esc.
        /// </summary>
        /// <param name="client">Target client.</param>
        public static void CancelTargetCursor(int client)
        {
            ClientInfo ci;

            if (ClientInfoCollection.GetClient(client, out ci))
            {
                Memory.Write(ci.Handle, ci.CursorAddress, dwordZero, true);
                MacroEx.SendPacketToServer(client, myCancelTargetPacket);
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Get current attack target for the specified client.
        /// </summary>
        /// <param name="client">Target client.</param>
        /// <returns>0 if no target, -1 on error.</returns>
        public static int GetAttackTarget(int client)
        {
            ClientInfo ci;

            if (ClientInfoCollection.GetClient(client, out ci))
            {
                return(ci.CurrentAttackTarget);
            }
            return(-1);
        }
Exemplo n.º 27
0
        internal static void Event(int client, byte param1, byte param2, string param3)
        {
            ClientInfo ci;

            if (!ClientInfoCollection.GetClient(client, out ci))
            {
                throw new ApplicationException("Unable to retrieve client info for client " + client + ".");
            }
            Assembler.Execute(ci, param1, param2, param3);
        }
Exemplo n.º 28
0
            private static void IncomingPackets_PropertiesEvent(int client, int serial, string name, Property[] properties, string propertyText)
            {
                ClientInfoCollection.UpdateProperties(client, serial, name, properties, propertyText);
                ClientInfo ci;

                if (ClientInfoCollection.GetClient(client, out ci))
                {
                    ci.PropertiesReceived(serial);
                }
            }
Exemplo n.º 29
0
            private static void OutgoingPackets_SkillLockChangedEvent(int client, int skillID, LockStatus lockStatus)
            {
                ClientInfo ci;

                if (ClientInfoCollection.GetClient(client, out ci))
                {
                    SkillInfo si = ci.GetSkillInfo(skillID);
                    si.LockStatus = lockStatus;
                }
            }
Exemplo n.º 30
0
            private static void OutgoingPackets_InternalGumpButtonPressedEvent(int client, int serial, int gumpID, int buttonID, int[] switches)
            {
                ClientInfo ci;

                if (ClientInfoCollection.GetClient(client, out ci))
                {
                    ci.OnGumpAction(serial, gumpID, buttonID, switches);
                    ci.GenericGumps.Remove(gumpID);
                }
            }