Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 17:21

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



I still can't figure it out >.<

Discussion on I still can't figure it out >.< within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2010
Posts: 940
Received Thanks: 76
I still can't figure it out >.<

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.
denominator is offline  
Old 05/14/2012, 05:01   #2
 
elite*gold: 80
Join Date: Sep 2007
Posts: 642
Received Thanks: 168
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?
Santa is offline  
Old 05/14/2012, 05:07   #3
 
elite*gold: 0
Join Date: Aug 2010
Posts: 940
Received Thanks: 76
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.
denominator is offline  
Old 05/14/2012, 06:14   #4
 
elite*gold: 80
Join Date: Sep 2007
Posts: 642
Received Thanks: 168
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.
Santa is offline  
Thanks
1 User
Old 05/14/2012, 06:33   #5
 
elite*gold: 0
Join Date: Aug 2010
Posts: 940
Received Thanks: 76
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 *** out of the house rather than just being a boring **** and staying in messing with the computer all the time lol.
denominator is offline  
Old 05/14/2012, 13:17   #6
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Have you ever heard about debugging?
I don't have a username is offline  
Old 05/14/2012, 13:46   #7


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,125
Received Thanks: 2,518
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.
Korvacs is offline  
Old 05/14/2012, 13:59   #8
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,224
Received Thanks: 868
Code:
!e.Name.Contains("Guard") &&
What if the players name contains guard? Thats a very popular error around here.
_DreadNought_ is offline  
Thanks
1 User
Old 05/14/2012, 14:53   #9
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
If a players name is MyGuard, troololol
I don't have a username is offline  
Old 05/14/2012, 16:07   #10
 
elite*gold: 0
Join Date: Jun 2006
Posts: 457
Received Thanks: 67
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 ?
shitboi is offline  
Old 05/14/2012, 17:43   #11
 
bone-you's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 1,491
Received Thanks: 536
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.
bone-you is offline  
Old 05/14/2012, 18:04   #12
 
elite*gold: 0
Join Date: Aug 2010
Posts: 940
Received Thanks: 76
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);

            }
            }
denominator is offline  
Old 05/14/2012, 18:11   #13
 
elite*gold: 20
Join Date: Aug 2007
Posts: 1,749
Received Thanks: 2,198
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
IAmHawtness is offline  
Thanks
2 Users
Old 05/14/2012, 18:23   #14
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,377
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.
pro4never is offline  
Old 05/14/2012, 19:14   #15
 
elite*gold: 20
Join Date: Aug 2007
Posts: 1,749
Received Thanks: 2,198
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
IAmHawtness is offline  
Reply


Similar Threads Similar Threads
Help me to figure it out please !!!??
03/16/2011 - Aion - 3 Replies
How can a gladiator use shield defense + slaughter "bug" , please if any 1 know it tell me or pm in the forum. here is a video that guy's using it : YouTube - Aion Gladiator Level 55 Dual Wielding Duels Please as soon as possible .. Thanks .
Please Help me i can't figure this out :s
09/30/2010 - Silkroad Online - 3 Replies
Hello everyone , Please i can't play silkroad on my new laptop , when i lunch silkroad.exe nothing happens for like 30 sec then this message pops up : http://img833.imageshack.us/img833/5170/errory.pn g Please help me :s , Sbot doesn't work either , when i press Login the little message appears but it doesn't progress , like if it couldn't connect to the bot server , then a message apears in the bot in red : " Error- failed to connect" I have Windows 7 on my laptop if that could help.
Anybody figure out . . .
03/18/2010 - Archlord - 9 Replies
How to trade unique accessories now, even though they are "bound". Just wondering if it is possible.
could someone figure this out?
12/05/2009 - Grand Chase - 5 Replies
YouTube - EXP Hack in progress this guy seemse to be doing a exp hack and monster lvl hack.... could someone please tell me how to do this?
Let's figure out the +1s
06/18/2006 - Conquer Online 2 - 28 Replies
From here on out, everyone please post any statistics they can on +1 drops. This includes item type, dura, sockets, lvl, quality, blessed, etc. Also post the times, we're going to bust down this +1 non-sense. Thanks for your help, -einhornchen



All times are GMT +2. The time now is 17:21.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.