Exemplo n.º 1
0
        private void faceWithTimer(double face, Post.ArrowKeys key)
        {
            GSpellTimer timer = new GSpellTimer(face * 1000 * Math.PI);

            Post.ArrowKeyDown(Memory.WindowHandle, key);
            timer.Reset();
            while (!timer.isReady)
            {
                Thread.Sleep(1);
            }
            Post.ArrowKeyUp(Memory.WindowHandle, key);
        }
Exemplo n.º 2
0
        public bool MoveToUnit(GUnit Target, int distance)
        {
            //Start by facing


            faceUnit(Target);
            GLocation posP   = objectList.LocalPlayer.Location;
            GLocation oldPos = objectList.LocalPlayer.Location;
            GLocation posT   = Target.Location;
            double    dist   = posP.distanceFrom(posT);

            Post.ArrowKeyDown(Memory.WindowHandle, Post.ArrowKeys.Up);


            double      oldX          = posT.X;
            double      oldY          = posT.Y;
            GSpellTimer timer         = new GSpellTimer(1 * 10000 * 2);
            GSpellTimer FaceTimer     = new GSpellTimer(500);
            GSpellTimer timerWaypoint = new GSpellTimer(1 * 10000 * 45); //45 secondes max

            while (dist > distance && !timerWaypoint.isReady)
            {
                if (shouldBreak)
                {
                    break;
                }
                posP = objectList.LocalPlayer.Location;
                posT = Target.Location;
                dist = posP.distanceFrom(posT);

                if (FaceTimer.isReady)
                {
                    facePOSMove(Target.Location);
                    FaceTimer.Reset();
                }
                if (posP.distanceFrom(oldPos) < 2 && timer.isReady)
                {
                    releaseKeys();
                    doSomethingCrazy();
                    timer.Reset();
                    timerWaypoint.Reset();
                    faceUnit(Target);
                    Post.ArrowKeyDown(Memory.WindowHandle, Post.ArrowKeys.Up);
                }
                else if (timer.isReady)
                {
                    oldPos = objectList.LocalPlayer.Location;
                    timer.Reset();
                }
                Thread.Sleep(10);
            }
            if (timerWaypoint.isReady && dist > distance)
            {
                SendConsole("Can't Reach Target", ConsoleLvl.Low);

                Post.ArrowKeyUp(Memory.WindowHandle, Post.ArrowKeys.Up);
                return(false);
            }
            else
            {
                if (dist > distance)
                {
                    SendConsole("Target Reached >> " + Target.Name, ConsoleLvl.Medium);
                    SendConsole("Distance From T :  " + dist, ConsoleLvl.High);
                    SendConsole("Min Dist :  " + distance + " > ratio : " + Math.Abs((distance - dist) * 100 / distance).ToString() + "%", ConsoleLvl.High);
                }
                Post.ArrowKeyUp(Memory.WindowHandle, Post.ArrowKeys.Up);
                faceUnit(Target);
                return(true);
            }
        }
Exemplo n.º 3
0
        public bool FollowMain(ulong GuidTarget, int disctance, GPlayer main)
        {
            //Start by facing
            //go to main stuveu
            if ((main.Location.X != oldLocation.X || main.Location.Y != oldLocation.Y || main.Location.Z != oldLocation.Z || objectList.LocalPlayer.Location.distanceFrom(main.Location) > disctance) && BotHub.follow == true)
            {
                oldLocation = main.Location;
                GUnit TargetObject = main;

                faceUnit(TargetObject);
                GLocation posP   = objectList.LocalPlayer.Location;
                GLocation oldPos = objectList.LocalPlayer.Location;
                GLocation posT   = main.Location;
                double    dist   = posP.distanceFrom(posT);
                Post.ArrowKeyDown(Memory.WindowHandle, Post.ArrowKeys.Up);
                int         lastFace  = 15;
                bool        alerted   = false;
                double      oldX      = posT.X;
                double      oldY      = posT.Y;
                GSpellTimer facetimer = new GSpellTimer(1 * 1000);

                GSpellTimer timer         = new GSpellTimer(1 * 1000 * 10);
                GSpellTimer timerWaypoint = new GSpellTimer(1 * 1000 * 45);
                while (dist > disctance && CurrentBot.Ismain == false && BotHub.follow == true)
                {
                    if (shouldBreak)
                    {
                        break;
                    }
                    posP = objectList.LocalPlayer.Location;
                    posT = TargetObject.Location;
                    dist = posP.distanceFrom(posT);
                    if (facetimer.isReady)
                    {
                        faceUnit(TargetObject);
                        facetimer.Reset();
                    }
                    float angle = negativeAngle((float)Math.Atan2((double)(posT.Y - posP.Y), (double)(posT.X - posP.X)));
                    if (timer.isReady)
                    {
                        if (posP.distanceFrom(oldPos) < 2)
                        {
                            if (!alerted)
                            {
                                //objectList.Form.logSystem("Think we are stuck");
                                SendConsole("Think I'm stuck", ConsoleLvl.Medium);
                                //objectList.Form.logSystem("Trying something funny, hang on");
                                KeyHelper.SendKey("Common.Jump");
                                Thread.Sleep(1000);
                                alerted = true;
                            }
                            else
                            {
                                releaseKeys();
                                doSomethingCrazy();

                                timerWaypoint.Reset();
                                faceUnit(TargetObject);
                                Post.ArrowKeyDown(Memory.WindowHandle, Post.ArrowKeys.Up);
                            }
                        }
                        else
                        {
                            oldPos = objectList.LocalPlayer.Location;
                        }
                        timer.Reset();
                    }

                    CurrentBot.ActionList.Sort();

                    Thread.Sleep(10);
                }
                if (timerWaypoint.isReady && dist > disctance)
                {
                    SendConsole("Move to unit timed out", ConsoleLvl.High);
                    Post.ArrowKeyUp(Memory.WindowHandle, Post.ArrowKeys.Up);
                    return(false);
                }
                Post.ArrowKeyUp(Memory.WindowHandle, Post.ArrowKeys.Up);
                faceUnit(TargetObject);
            }
            else
            {
                // SendConsole("Bug ?", ConsoleLvl.High);
            }
            return(true);
        }
Exemplo n.º 4
0
        public bool MoveToLocation(GLocation position, double distance, bool patrol)
        {
            GSpellTimer timer         = new GSpellTimer(1 * 1000 * 30);
            GSpellTimer timerWaypoint = new GSpellTimer(1 * 1000 * 45);
            GSpellTimer facetimer     = new GSpellTimer(3 * 1000);


            if (distance > 45)
            {
                timerWaypoint = new GSpellTimer(1 * 1000 * 65);
            }

            if (distance < 45 && distance > 40)
            {
                timerWaypoint = new GSpellTimer(1 * 1000 * 60);
            }

            if (distance < 40 && distance > 35)
            {
                timerWaypoint = new GSpellTimer(1 * 1000 * 55);
            }

            if (distance < 35 && distance > 30)
            {
                timerWaypoint = new GSpellTimer(1 * 1000 * 55);
            }

            GLocation posP     = objectList.LocalPlayer.Location;
            GLocation oldPos   = objectList.LocalPlayer.Location;
            double    dist     = posP.distanceFrom(position);
            double    lastFace = dist;

            if ((!startedpatrol && patrol == true) || patrol == false)
            {
                Post.ArrowKeyDown(Memory.WindowHandle, Post.ArrowKeys.Up);
                startedpatrol = true;
            }
            bool faced35 = false;
            bool alerted = false;

            facePOSMove(position);
            //&& !timerWaypoint.isReady
            while (dist > distance)
            {
                posP = objectList.LocalPlayer.Location;
                dist = posP.distanceFrom(position);

                if (shouldBreak)
                {
                    break;
                }

                if (posP.distanceFrom(oldPos) > 2)
                {
                    oldPos = objectList.LocalPlayer.Location;
                    timer.Reset();
                }



                if (posP.distanceFrom(oldPos) < 2 && timer.isReady)
                {
                    if (!alerted)
                    {
                        //objectList.Form.logSystem("Think we are stuck");
                        //objectList.Form.logSystem("Trying something funny, hang on");
                        alerted = true;
                    }


                    releaseKeys();
                    doSomethingCrazy();
                    timer.Reset();
                    timerWaypoint.Reset();
                    facePOS(position);
                    Post.ArrowKeyDown(Memory.WindowHandle, Post.ArrowKeys.Up);
                }

                if (facetimer.isReady)
                {
                    facePOSMove(position);
                    facetimer.Reset();
                }


                Thread.Sleep(1);
            }

            if (timerWaypoint.isReady && dist > distance)
            {
                SendConsole("Error Time Expired", ConsoleLvl.Low);
                Post.ArrowKeyUp(Memory.WindowHandle, Post.ArrowKeys.Up);
                facePOS(position);
                return(false);
            }

            if (patrol == false || shouldBreak)
            {
                Post.ArrowKeyUp(Memory.WindowHandle, Post.ArrowKeys.Up);
                facePOS(position);
            }
            return(true);
        }