Esempio n. 1
0
        public GUnit GetNearestHostile(GLocation Location, ulong ExcludeGUID)
        {
            int       counter     = 0;
            double    closestUnit = 9999999;
            GLocation location    = Location;
            GUnit     unit;
            GUnit     returnUnit = null;

            while (GuidList.Count > counter)
            {
                if (ObjectList[GuidList[counter]].Type.Equals((int)eObjectType.G_UNIT))
                {
                    unit = new GUnit(this, ObjectList[GuidList[counter]].ObjectPointer);
                    if (location.distanceFrom(unit.Location) < closestUnit && !unit.IsTagged && unit.GUID != ExcludeGUID)
                    {
                        returnUnit  = unit;
                        closestUnit = location.distanceFrom(unit.Location);
                    }
                }
                counter++;
            }
            if (returnUnit != null)
            {
                return(returnUnit);
            }
            return(null);
        }
Esempio n. 2
0
        private void tface(object b)
        {
            GLocation position            = ((GUnit)b).Location;
            GLocation localPlayerPosition = objectList.LocalPlayer.Location;
            //Find the facing we need to get
            float wowFacing = negativeAngle((float)Math.Atan2((double)(position.Y - localPlayerPosition.Y), (double)(position.X - localPlayerPosition.X)));

            float face;
            //Lets calculate the new facing against out current facing
            float angle = negativeAngle(wowFacing - objectList.LocalPlayer.Facing);

            if (angle < Math.PI && angle > (Math.PI / 4))
            {
                //The position we want to face is reached fastest by turning to the left
                face = negativeAngle((wowFacing - objectList.LocalPlayer.Facing));
                faceWithTimer(face, Post.ArrowKeys.Left);
            }
            else if (angle >= Math.PI && angle < (7 * Math.PI / 4))
            {
                //Lets turn to the right
                face = negativeAngle((objectList.LocalPlayer.Facing - wowFacing));
                //Console.WriteLine("Right is the shortest way, lets face");
                faceWithTimer(face, Post.ArrowKeys.Right);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Find the closest unit that is targeting the specified GUID: Exclude the the second GUID.
        /// </summary>
        public GUnit FindUnitByTarget(ulong TargetGUID, ulong ExcludeGUID)
        {
            int       counter     = 0;
            double    closestUnit = 9999999;
            GLocation location    = localPlayer.Location;
            GUnit     unit;
            GUnit     returnUnit = null;

            while (GuidList.Count > counter)
            {
                if (ObjectList[GuidList[counter]].Type.Equals((int)eObjectType.G_UNIT))
                {
                    unit = new GUnit(this, ObjectList[GuidList[counter]].ObjectPointer);
                    if (unit.TargetGUID.Equals(TargetGUID) || unit.TargetGUID != ExcludeGUID)
                    {
                        if (location.distanceFrom(unit.Location) < closestUnit)
                        {
                            returnUnit  = unit;
                            closestUnit = location.distanceFrom(unit.Location);
                        }
                    }
                }
                counter++;
            }
            if (returnUnit != null)
            {
                return(returnUnit);
            }
            return(null);
        }
Esempio n. 4
0
        public List <GUnit> getUnitsInRange(int range)
        {
            int          counter  = 0;
            List <GUnit> toReturn = new List <GUnit>();
            GUnit        unit;
            GLocation    location = localPlayer.Location;

            while (GuidList.Count > counter)
            {
                if (ObjectList[GuidList[counter]].Type.Equals((int)eObjectType.G_UNIT))
                {
                    unit = new GUnit(this, ObjectList[GuidList[counter]].ObjectPointer);
                    if (location.distanceFrom(unit.Location) < range && !unit.IsDead)
                    {
                        toReturn.Add(unit);
                    }
                }
                counter++;
            }
            if (toReturn.Count != 0)
            {
                return(toReturn);
            }
            return(null);
        }
Esempio n. 5
0
        /// <summary>
        /// Returns the distance to the closest waypoint
        /// </summary>
        public double GetDistanceTo(GLocation location)
        {
            GLocation wayPointPos = Waypoints[0];

            distance = location.distanceFrom(wayPointPos);

            i = 0;
            while (Waypoints.Count > i)
            {
                wayPointPos = Waypoints[i];
                if (location.distanceFrom(wayPointPos) < distance)
                {
                    distance = location.distanceFrom(wayPointPos);
                }
                i++;
            }
            return(Math.Round(distance, 2));
        }
Esempio n. 6
0
        public void facePOSMove(GLocation position)
        {
            GLocation localPlayerPosition = objectList.LocalPlayer.Location;
            //Find the facing we need to get
            float wowFacing = negativeAngle((float)Math.Atan2((double)(position.Y - localPlayerPosition.Y), (double)(position.X - localPlayerPosition.X)));

            float face;

            //Lets calculate the new facing against out current facing
            if (negativeAngle(wowFacing - objectList.LocalPlayer.Facing) < Math.PI)
            {
                //The position we want to face is reached fastest by turning to the left
                face = negativeAngle((wowFacing - objectList.LocalPlayer.Facing));

                if (face > 1.2)
                {
                    //objectList.Form.logSystem("We should not run while facing");
                    Post.ArrowKeyUp(Memory.WindowHandle, Post.ArrowKeys.Up);
                    faceWithTimer(face, Post.ArrowKeys.Left);
                    Post.ArrowKeyDown(Memory.WindowHandle, Post.ArrowKeys.Up);
                }
                else
                {
                    faceWithTimer(face, Post.ArrowKeys.Left);
                }
            }
            else
            {
                //Lets turn to the right
                face = negativeAngle((objectList.LocalPlayer.Facing - wowFacing));
                //Console.WriteLine("Right is the shortest way, lets face");
                if (face > 1.2)
                {
                    //objectList.Form.logSystem("We should not run while facing");
                    Post.ArrowKeyUp(Memory.WindowHandle, Post.ArrowKeys.Up);
                    faceWithTimer(face, Post.ArrowKeys.Right);
                    Post.ArrowKeyDown(Memory.WindowHandle, Post.ArrowKeys.Up);
                }
                else
                {
                    faceWithTimer(face, Post.ArrowKeys.Right);
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Get the waypoint closest to the location
        /// </summary>
        public GLocation getClosestWaypoint(GLocation location)
        {
            if (Waypoints.Count == 0)
            {
                throw new Exception("No waypoints loaded");
            }
            GLocation closestPos = Waypoints[0];

            distance = location.distanceFrom(closestPos);
            i        = 0;
            while (Waypoints.Count > i)
            {
                GLocation wayPointPos = Waypoints[i];

                if (location.distanceFrom(wayPointPos) < distance)
                {
                    distance   = location.distanceFrom(wayPointPos);
                    closestPos = wayPointPos;
                }
                i++;
            }
            return(closestPos);
        }
Esempio n. 8
0
        /// <summary>
        /// Returns a list with Waypoints sorted after distance to the location
        /// </summary>
        public List <GLocation> getListSortedAfterDistance(GLocation location)
        {
            if (Waypoints.Count == 0)
            {
                return(null);
            }

            returnList = new List <GLocation>();

            GLocation closestPosition = getClosestWaypoint(location);

            i = 0;
            while (Waypoints.Count > i)
            {
                GLocation wayPointPos = Waypoints[i];

                if (closestPosition.Equals(wayPointPos))
                {
                    placeInList = i;
                }
                i++;
            }

            i = 0;
            h = placeInList;
            while (Waypoints.Count > placeInList && h < Waypoints.Count)
            {
                returnList.Add(Waypoints[h]);
                h++;
            }
            while (i < placeInList)
            {
                returnList.Add(Waypoints[i]);
                i++;
            }
            return(returnList);
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
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);
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
 public bool MoveToLocation(GLocation position)
 {
     return(MoveToLocation(position, 1, false));
 }
Esempio n. 13
0
        public void loadFile(string fileName)
        {
            filename = fileName;
            doc      = new XmlDocument();
            doc.Load(fileName);

            XmlElement elm = doc.DocumentElement;

            if (elm.Name.Equals("ProfileGroup"))
            {
                groupProfile = true;
            }
            else
            {
                //Load min and max level
                XmlNodeList MinLevel = doc.GetElementsByTagName("MinLevel");
                LevelMinVar = Convert.ToInt32(MinLevel[0].ChildNodes[0].Value);
                XmlNodeList MaxLevel = doc.GetElementsByTagName("MaxLevel");
                LevelMaxVar = Convert.ToInt32(MaxLevel[0].ChildNodes[0].Value);

                //Load factions
                XmlNodeList Faction = doc.GetElementsByTagName("Factions");

                foreach (XmlNode faction in Faction)
                {
                    string temp = faction.ChildNodes[0].Value;

                    string[] split = temp.Split(new Char[] { ' ' });

                    foreach (string f in split)
                    {
                        factions.Add(Convert.ToDouble(f));
                    }
                }

                //Load PauseAtWaypoint
                XmlNodeList PauseAt = doc.GetElementsByTagName("PauseAtWaypoint");

                foreach (XmlNode at in PauseAt)
                {
                    string temp          = at.ChildNodes[0].Value;
                    string CorrectString = temp.Replace(".", ",");

                    string[] split = CorrectString.Split(new Char[] { ' ' });
                    if (!split.Count().Equals(1))
                    {
                        PauseAtWaypoint = new GLocation((float)Convert.ToDouble(split[0]), (float)Convert.ToDouble(split[1]), (float)Convert.ToDouble(split[2]));
                    }
                    else
                    {
                        PauseAtWaypoint = new GLocation(0, 0, 0);
                    }
                }
                //Load How Long
                XmlNodeList Long = doc.GetElementsByTagName("HowLong");
                HowLong = Convert.ToInt32(Long[0].ChildNodes[0].Value);



                //Load waypoints
                XmlNodeList Waypoint = doc.GetElementsByTagName("Waypoint");
                int         i        = -1;
                foreach (XmlNode point in Waypoint)
                {
                    i++;
                    string temp          = point.ChildNodes[0].Value;
                    string CorrectString = temp.Replace(".", ",");

                    string   xyz   = CorrectString;
                    string[] split = xyz.Split(new Char[] { ' ' });
                    if (split.Length > 2)
                    {
                        GLocation wayPointPos = new GLocation((float)Convert.ToDouble((split[0])), (float)Convert.ToDouble((split[1])), (float)Convert.ToDouble((split[2])));
                        Waypoints.Add(wayPointPos);
                    }
                    else
                    {
                        GLocation wayPointPos = new GLocation((float)Convert.ToDouble((split[0])), (float)Convert.ToDouble((split[1])), (float)Convert.ToDouble((0)));
                        Waypoints.Add(wayPointPos);
                    }
                }
                //lastWaypoint
            }
        }
Esempio n. 14
0
 public void addSingleWayPoint(GLocation position)
 {
 }
Esempio n. 15
0
 public double distanceFrom(GLocation pos)
 {
     return(Math.Sqrt((Math.Pow((double)(this.X - pos.X), 2.0) + Math.Pow((double)(this.Y - pos.Y), 2.0)) + Math.Pow((double)(this.Z - pos.Z), 2.0)));
 }