Exemple #1
0
        //Поворот камеры

        public void turnCorner(EsoWindow esoWindow, String addrText, IntPtr processHandle, String targetCorner)
        {
            Point cursorPosition = new Point();

            esoWindow.GetCursorPos(out cursorPosition);

            var    buffer = new byte[8];
            var    addr   = long.Parse(addrText, NumberStyles.HexNumber);
            IntPtr bytesRead;
            var    result = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);

            NumberFormatInfo nfi = new NumberFormatInfo();

            nfi.NumberDecimalSeparator = ",";                           //Задаем запятую, как разделитель между числом и дробной частью

            double trgCorner     = Convert.ToDouble(targetCorner, nfi); //Целевой угол
            double acturalCorner = BitConverter.ToDouble(buffer, 0);    //текущий угол
            double counterCorner = 0;                                   //Счетчик, на сколько повернулся угол
            double lenghtCorner;                                        //Длина, на которую надо повернуть угол
            double previousCorner;                                      //Предыдущее значение угла
            bool   rotationCorner;                                      //Определяем, куда поворачивать. True - вперед, False - назад

            if (trgCorner > acturalCorner)
            {
                lenghtCorner   = trgCorner - acturalCorner;
                rotationCorner = true;
            }
            else
            {
                lenghtCorner   = acturalCorner - trgCorner;
                rotationCorner = false;
            }

            if (rotationCorner)
            {
                result         = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);
                previousCorner = BitConverter.ToDouble(buffer, 0);

                while (lenghtCorner > counterCorner)
                {
                    if (Form1.stopAction)
                    {
                        break;
                    }
                    esoWindow.SetCursorPos(cursorPosition.X - 3, cursorPosition.Y);
                    result         = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);
                    counterCorner  = BitConverter.ToDouble(buffer, 0) - previousCorner + counterCorner;
                    previousCorner = BitConverter.ToDouble(buffer, 0);
                    Thread.Sleep(10);
                }
            }
            else
            {
                result         = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);
                previousCorner = BitConverter.ToDouble(buffer, 0);

                while (lenghtCorner > counterCorner)
                {
                    if (Form1.stopAction)
                    {
                        break;
                    }
                    esoWindow.SetCursorPos(cursorPosition.X + 3, cursorPosition.Y);
                    result         = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);
                    counterCorner  = previousCorner - BitConverter.ToDouble(buffer, 0) + counterCorner;
                    previousCorner = BitConverter.ToDouble(buffer, 0);
                    Thread.Sleep(10);
                }
            }
        }
Exemple #2
0
        public void turnCornerVer2(EsoWindow esoWindow, String addrText, IntPtr processHandle, String targetCorner)
        {
            Point cursorPosition = new Point();

            esoWindow.GetCursorPos(out cursorPosition);

            var    buffer = new byte[8];
            var    addr   = long.Parse(addrText, NumberStyles.HexNumber);
            IntPtr bytesRead;
            var    result = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);

            NumberFormatInfo nfi = new NumberFormatInfo();

            nfi.NumberDecimalSeparator = ",";                           //Задаем запятую, как разделитель между числом и дробной частью

            double trgCorner     = Convert.ToDouble(targetCorner, nfi); //Целевой угол
            double acturalCorner = BitConverter.ToDouble(buffer, 0);    //текущий угол
            double previousCorner;                                      //Предыдущее значение угла
            double targetDistance;                                      //Количество градусов, на которое нужно повернуть взгляд
            double coveredDistance;                                     //пройденное количесто градусов угла

            if (trgCorner > acturalCorner)                              //Целевой угол больше текущего
            {
                if ((trgCorner - acturalCorner) < 180)                  //Если разница меньше 180, то поворачиваем по часовой стрелке
                {
                    result          = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);
                    previousCorner  = BitConverter.ToDouble(buffer, 0);
                    targetDistance  = trgCorner - acturalCorner;
                    coveredDistance = 0;
                    while (targetDistance > coveredDistance)
                    {
                        if (Form1.stopAction)
                        {
                            return;
                        }
                        esoWindow.SetCursorPos(cursorPosition.X - 3, cursorPosition.Y);
                        result          = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);
                        coveredDistance = BitConverter.ToDouble(buffer, 0) - previousCorner + coveredDistance;
                        previousCorner  = BitConverter.ToDouble(buffer, 0);
                        Thread.Sleep(10);
                    }
                }
                else //Если разница больше 180, то поворачиваем против часовой стрелки
                {
                    result          = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);
                    previousCorner  = BitConverter.ToDouble(buffer, 0);
                    targetDistance  = CornerDistance(trgCorner, acturalCorner);
                    coveredDistance = 0;
                    while (targetDistance > coveredDistance)
                    {
                        if (Form1.stopAction)
                        {
                            return;
                        }
                        esoWindow.SetCursorPos(cursorPosition.X + 3, cursorPosition.Y);
                        result          = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);
                        coveredDistance = CornerDistance(BitConverter.ToDouble(buffer, 0), previousCorner) + coveredDistance;
                        previousCorner  = BitConverter.ToDouble(buffer, 0);
                        Thread.Sleep(10);
                    }
                }
            }
            else //Целевой угол меньше текущего
            {
                if ((acturalCorner - trgCorner) < 180) //Если разница меньше 180, то поворачиваем против часовой стрелки
                {
                    result          = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);
                    previousCorner  = BitConverter.ToDouble(buffer, 0);
                    targetDistance  = acturalCorner - trgCorner;
                    coveredDistance = 0;
                    while (targetDistance > coveredDistance)
                    {
                        if (Form1.stopAction)
                        {
                            return;
                        }
                        esoWindow.SetCursorPos(cursorPosition.X + 3, cursorPosition.Y);
                        result          = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);
                        coveredDistance = previousCorner - BitConverter.ToDouble(buffer, 0) + coveredDistance;
                        previousCorner  = BitConverter.ToDouble(buffer, 0);
                        Thread.Sleep(10);
                    }
                }
                else //Если разница больше 180, то поворачиваем по часовой стрелке
                {
                    result          = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);
                    previousCorner  = BitConverter.ToDouble(buffer, 0);
                    targetDistance  = CornerDistance(acturalCorner, trgCorner);
                    coveredDistance = 0;
                    while (targetDistance > coveredDistance)
                    {
                        if (Form1.stopAction)
                        {
                            return;
                        }
                        esoWindow.SetCursorPos(cursorPosition.X - 3, cursorPosition.Y);
                        result          = esoWindow.ReadProcessMemory(processHandle, new IntPtr(addr), buffer, (uint)buffer.Length, out bytesRead);
                        coveredDistance = CornerDistance(BitConverter.ToDouble(buffer, 0), previousCorner) + coveredDistance;
                        previousCorner  = BitConverter.ToDouble(buffer, 0);
                        Thread.Sleep(10);
                    }
                }
            }
        }