I still can't figure it out >.<

05/14/2012 03:19 denominator#1
Code:
case "/record":
                            {

                                if (Recording)
                                {
                                    Recording = false;
                                    ShowMessage("Finished Recording");
                                }
                                else
                                {
                                    Recording = true;
                                    ActivePath = new Paths();
                                    ActivePath._Map = _Map;
                                    ActivePath.Desc = "Custom";
                                    ActivePath.ID = 0;
                                    ActivePath.myPoints.Add(new MyPoint(0, MakeCoord(X, Y)));
                                    ActivePoint = null;
                                    ShowMessage("Recording path! Jump to add points");
                                }
                                if (Recording)
                                {
                                    if (_autoHunter.Enabled)
                                    {
                                        _autoHunter.Enabled = false;
                                        ShowMessage("Do not record while hunting! Stopped bot");
                                    }
                                    
                                        ushort PID = (ushort)(ActivePath.myPoints.Count);
                                        ActivePath.myPoints.Add(new MyPoint(PID, MakeCoord(ToX, ToY)));
                                        ShowMessage("added " + ToX + "," + ToY);
                                    
                                }
                            }

                            break;
Code:
        public ushort pathX;
        public ushort pathY;
        public ushort ToX;
        public ushort ToY;
        private ushort _Map, _X, _Y;
Code:
        public ushort X
        {
            get { return _X; }
            set { PrevX = _X; _X = value; }// Form.OutX.Text = Convert.ToString(_X); }
        }
        public ushort Y
        {
            get { return _Y; }
            set { PrevY = _Y; _Y = value; }// Form.OutY.Text = Convert.ToString(_Y); }
        }
        public bool Recording = false;
        public Paths ActivePath = null;
        public MyPoint ActivePoint = null;
        public List<Coord> path = new List<Coord>();
        public Coord To;
Code:
        public List<PathFinderNode> _paths = new List<PathFinderNode>();
        public ushort PrevX, PrevY;
        public static int pathIndex = 9999999;
        public static bool fimPath = true;
Code:
public static MyPoint SetPoint(ushort Id, Coord Where)
        {
            MyPoint P = new MyPoint(Id, Where);
            return P;
        }

        public static Coord newCoord(ushort X, ushort Y)
        {
            Coord Z = new Coord();
            Z.X = X;
            Z.Y = Y;
            return Z;
        }

        public static int Distance(ushort X, ushort Y, ushort ToX, ushort ToY)
        {
            int XDist = Math.Abs(X - ToX);
            int YDist = Math.Abs(Y - ToY);
            if (XDist > YDist)
                return XDist;
            else
                return YDist;
        }

        public static bool VerificaDistancia(Client C, ushort toX, ushort toY)
        {
            int distan = Distance(C.X, C.Y, toX, toY);
            int disMax = 17;

            if (distan > disMax)
            {

                ushort novoX = C.X;
                ushort novoY = C.Y;

                Random r = new Random();
                int imove = r.Next(5, disMax);

                if (C.X < toX)
                    novoX = (ushort)(novoX + imove);
                else
                    novoX = (ushort)(novoX - imove);

                if (C.Y < toY)
                    novoY = (ushort)(novoY + imove);
                else
                    novoY = (ushort)(novoY - imove);


            }
            return true;
        }

        public class Paths
        {
            public ushort ID;
            public ushort _Map;
            public string Desc;
            public List<MyPoint> myPoints = new List<MyPoint>();
        }

        public static Coord MakeCoord(ushort X, ushort Y)
        {
            Coord Z = new Coord();
            Z.X = X;
            Z.Y = Y;
            return Z;
        }

        public struct Coord
        {
            public ushort X, Y;
        }

        public class MyPoint
        {
            public Coord coord;
            public ushort Id;

            public MyPoint(ushort PID, Coord C)
            {
                Id = PID;
                coord = C;
            }
        }
The above is all in Client.cs and the code at the bottom is in AutoHunter.cs

Code:
protected override void Update()
        {

            List<Entity> targets = Client.Screen.GetAllEntities()
                .Where((e) =>
                    !e.IsPlayer &&
                    !e.Name.Contains("Guard") &&
                    e.Position.Distance(Client.Player.Position) < 18)
                .OrderBy((e) => e.Position.Distance(Client.Player.Position))
                .ToList();

            if (targets.Count > 0)
            {


                Entity target = targets[0];

                if ((ActivePath != null) && (targets == null))
                {
                    ushort pathX;
                    ushort pathY;

                    if (pathIndex == 9999999)
                        pathIndex = ActivePath.myPoints.Count - 1;

                    pathX = ActivePath.myPoints[pathIndex].coord.X;
                    pathY = ActivePath.myPoints[pathIndex].coord.Y;


                    

                    if (pathIndex >= ActivePath.myPoints.Count - 1)
                        fimPath = true;
                    if (pathIndex <= 1)
                        fimPath = false;

                    if (fimPath)
                        pathIndex--;
                    else
                        pathIndex++;

                }
                Client.Jump(target.Position);
                Client.Attack(target.Id);
                Client.RefreshPosition();
                Thread.Sleep(800);
            }
            
            }
Code:
#region Public

        public List<Coord> path = new List<Coord>();
        public Paths ActivePath = null;
        public static int pathIndex = 9999999;
        public static bool fimPath = true;
        public static MyPoint SetPoint(ushort Id, Coord Where)
        {
            MyPoint P = new MyPoint(Id, Where);
            return P;
        }

        public static Coord newCoord(ushort X, ushort Y)
        {
            Coord Z = new Coord();
            Z.X = X;
            Z.Y = Y;
            return Z;
        }

        public class Paths
        {
            public ushort Id;
            public ushort MapId;
            public string Desc;
            public List<MyPoint> myPoints = new List<MyPoint>();
        }

        public static Coord MakeCoord(ushort X, ushort Y)
        {
            Coord Z = new Coord();
            Z.X = X;
            Z.Y = Y;
            return Z;
        }

        public struct Coord
        {
            public ushort X, Y;
        }

        public class MyPoint
        {
            public Coord coord;
            public ushort Id;

            public MyPoint(ushort PTID, Coord C)
            {
                Id = PTID;
                coord = C;
            }
        }                             
        #endregion
I actually don't have any errors except it just doesn't add the point to point and just spews out "added " + ToX + "," + ToY Except ToX and ToY result in 0,0?

Should I add a new class and take the first parts out and add them to a new class? I mean the stuff I added to Client.cs.
05/14/2012 05:01 Santa#2
My guess would be that your never setting ToX or ToY to your characters cordinates. If your just trying to make a simple path recording system half of that stuff is not needed.

Also i don't understand how your recording new points. If you do "/record" is sets record to true/false and also records a point. Do you do /record for every point you want to add? Maybe i missed it or something but seems like It would be recording it to a new path every other time?
05/14/2012 05:07 denominator#3
No last time I used it all I had to do was /record then jump to the points and when finished in the little pattern then click /record again and it stops the recording. Then you /ahunt and it starts the hunt in the little pattern you created or at least it used to in AlchemyProxy.
05/14/2012 06:14 Santa#4
Again, unless I'm missing part of your code, this doesn't record when you jump. This records your current point when you initialize your path recording and goes no further. I don't suggest taking large code snippets from Alchemy unless you fully understand what it all does. Even if you did, it wouldn't take long to clean it up and write it yourself so you are familiar with it.
05/14/2012 06:33 denominator#5
Nope no code missing that I know of, I have to agree about the taking from Alchemy though, worked pretty well for that but just won't for this and the code was pretty much the same apart from a few things different that I've corrected as best I could so that it doesn't actually throw any errors but I'm assuming it's probably just conflicting somewhere.

I don't know it's 5:31 here so I'm going to get some sleep I think and will have another look tomorrow night after I have got back home. Been getting my ass out of the house rather than just being a boring fuck and staying in messing with the computer all the time lol.
05/14/2012 13:17 I don't have a username#6
Have you ever heard about debugging?
05/14/2012 13:46 Korvacs#7
Quote:
Originally Posted by denominator View Post
Nope no code missing that I know of, I have to agree about the taking from Alchemy though, worked pretty well for that but just won't for this and the code was pretty much the same apart from a few things different that I've corrected as best I could so that it doesn't actually throw any errors but I'm assuming it's probably just conflicting somewhere.
There's your problem right there, you have taken code which you dont understand, changed it to fix things which you thought were broken and have ended up breaking it.

If there was ever an argument for not copying and pasting code this would be it.
05/14/2012 13:59 _DreadNought_#8
Code:
!e.Name.Contains("Guard") &&
What if the players name contains guard? Thats a very popular error around here.
05/14/2012 14:53 I don't have a username#9
If a players name is MyGuard, troololol
05/14/2012 16:07 shitboi#10
Quote:
Originally Posted by _DreadNought_ View Post
Code:
!e.Name.Contains("Guard") &&
What if the players name contains guard? Thats a very popular error around here.
How should that be handled ?
05/14/2012 17:43 bone-you#11
Quote:
Originally Posted by shitboi View Post
How should that be handled ?
2 ways. You can keep track of all entities and whether they are player or npc, or you can do a full name check against the "Guard" names and not whether it contains it.
05/14/2012 18:04 denominator#12
Code:
!e.Name.Contains("Guard") &&
was ALREADY part of the code before I tried adding the pathfinder >.< WITHOUT it the normal hunt will attack or try to attack guards lol . Jeez I guess nobody has even bothered to look at the V2 of hooking???

Here is the ORIGINAL code

Code:
protected override void Update()
        {

            List<Entity> targets = Client.Screen.GetAllEntities()
                .Where((e) =>
                    !e.IsPlayer &&
                    !e.Name.Contains("Guard") &&
                    e.Position.Distance(Client.Player.Position) < 18)
                .OrderBy((e) => e.Position.Distance(Client.Player.Position))
                .ToList();

            if (targets.Count > 0)
            {


                Entity target = targets[0];

                Client.Jump(target.Position);
                Client.Attack(target.Id);
                Client.RefreshPosition();
                Thread.Sleep(800);

            }
            }
05/14/2012 18:11 IAmHawtness#13
Quote:
Originally Posted by _DreadNought_ View Post
Code:
!e.Name.Contains("Guard") &&
What if the players name contains guard? Thats a very popular error around here.
Quote:
Originally Posted by I don't have a username View Post
If a players name is MyGuard, troololol
It's an auto hunter for monsters, I think
05/14/2012 18:23 pro4never#14
While it's not really a big deal.... I feel a lot of sticklers would cringe at the amount of negative logic used in all your checks.

Instead of Not IsPlayer... just do an IsValidMonster check. Negative logic should be avoided in most cases. It causes debugging to be more of a pain and can really confuse you during some late night coding sessions. Plus it's just rather bad form.
05/14/2012 19:14 IAmHawtness#15
Quote:
Originally Posted by pro4never View Post
While it's not really a big deal.... I feel a lot of sticklers would cringe at the amount of negative logic used in all your checks.

Instead of Not IsPlayer... just do an IsValidMonster check. Negative logic should be avoided in most cases. It causes debugging to be more of a pain and can really confuse you during some late night coding sessions. Plus it's just rather bad form.
If you're talking about a "IsValidMonster" property on the Entity class, I highly disagree. Why would that logic belong to the Entity class? It has absolutely no place there IMO.

Sorry if I misunderstood you