[Help] Coding Autowalk/Need good C++ Coder

05/03/2012 00:57 iktov2#1
Ok hello,

I have found a way to make an auto-walk function using the World Character coordinates. I found the GoTo Coords that get set everytime you click a new spot to walk to, and I found the function that actually makes the character walk. So now I can manually set the coords that I want to walk to, and then make the character walk.

Now I am trying to figure a way to "record" a set of waypoints into an Array or Vector. Such as turn a Bool on called "Record", when the Record Bool is on it will record a new WP into the Array/Vector every time I left click until I turn the Record Bool off. So if I walk to 5 places while the Record bool is turned off, have it say each of the 5 waypoints into the Array.

I am just not sure how to save each new waypoint into the array, so that it adds each new one in.
05/03/2012 12:23 Mr_Troy22#2
Define: (kinda obvious, but meh)
Code:
std::vector<TS2VECTOR> v_Waypoints;
This is what you wanted:
Code:
v_Waypoints.push_back( NEWWAYPOINT );
To clear the vector:
Code:
v_Waypoints.clear( );
Use a certain waypoint FROM the vector:
Code:
v_Waypoints[i]
i being the #th waypoint minus 1 (1 = 0, 2 = 1, etc. (array alike))

I never use arrays, so I don't know how it works for arrays.

this page is very useful : [Only registered and activated users can see links. Click Here To Register...]

You'll also have to hook the walking function, which shouldn't be hard.
05/07/2012 07:27 iktov2#3
Ok nevermind I think I got it working. I found an example on the site you posted showing something like this:

Code:
struct Coordinate
{
    double x, y;

    Coordiate(double paramx, double paramy) : x(paramx), y(paramy) {}
};

std::vector<Coordinate> coords;

Went ahead and set it up like this:

Code:
struct Coordinate
{
    float x, y;
	Coordinate(float paramx, float paramy) : x(paramx), y(paramy) {}
};
vector<Coordinate> coords;

if(record)
	  {
		  if(GetAsyncKeyState(VK_LBUTTON) &1)
		  {
		       coords.push_back(Coordinate(Player->GoX, Player->GoY));
		  }
	  }
for(int i = 0; i < coords.size(); i++)
		  {
			  Player->GoX = coords[i].x;
			  Player->GoY = coords[i].y;
		  }
Seems to work ok so far, but I only tested it quickly with a keybind.
05/07/2012 19:46 Mr_Troy22#4
Quote:
Originally Posted by iktov2 View Post
Ok nevermind I think I got it working. I found an example on the site you posted showing something like this:

Code:
struct Coordinate
{
    double x, y;

    Coordiate(double paramx, double paramy) : x(paramx), y(paramy) {}
};

std::vector<Coordinate> coords;

Went ahead and set it up like this:

Code:
struct Coordinate
{
    float x, y;
	Coordinate(float paramx, float paramy) : x(paramx), y(paramy) {}
};
vector<Coordinate> coords;

if(record)
	  {
		  if(GetAsyncKeyState(VK_LBUTTON) &1)
		  {
		       coords.push_back(Coordinate(Player->GoX, Player->GoY));
		  }
	  }
for(int i = 0; i < coords.size(); i++)
		  {
			  Player->GoX = coords[i].x;
			  Player->GoY = coords[i].y;
		  }
Seems to work ok so far, but I only tested it quickly with a keybind.
Does that walking function work with screen coordinates?
05/07/2012 21:12 iktov2#5
No 3d world coords.

If you look at the player struct(11E1B18) +B3(xcoord), there are 6 coord addresses. X,Z,Y, and then Goto X,Z,Y. The GoTo Coords get filled when you click on the ground somewhere with the coordinates that your character is currently walking to. So if you overwrite those Coordiantes manually and then trigger the walk function somehow, your character will automatically walk to the coords that are held in the GoTo addresses.

So basically you can just overwrite those addresses with any coords you want to walk to and then click somewhere on the ground and it will walk to the coords that you set instead of where you clicked.

Having troubles setting up my walk function to work the way I want it to. I wonder if you have any idea how to make it work efficiently.

The below code will just constantly reset the GoTo coords before the character has a chance to walk to the last ones. I need to make it only call the Player->Gox = coords[x].x one time, wait until the character has reached its destination, run my mob check+attack, then go back and set the next coord in the vector.
Code:
for(int x = 0; x < coords.size(); x++)
{	  	
	Player->GoX = coords[x].x;
        Player->GoY = coords[x].y;
	Walk();
	Sleep(250);
}

I have tried something like this:

Code:
for(int x = 0; x < coords.size(); x++)
{	
      if(Player->Action = Standing && moncount < 2)
      {  	
	Player->GoX = coords[x].x;
        Player->GoY = coords[x].y;
	Walk();
	Sleep(250);
       }
      else if(moncount >= 2)
       {
           attack();
       }
}
}
So the above is supposed to check weather the player is standing still(not already walking) and if there is less than 2 mobs in attack range. If both of those conditions are true, then set the next waypoint to walk to. This way once it sets the next coordinate the character will now be walking and it won't set a new coordinate until the player is standing still again(reached the current waypoint). It works however, for some strange reason when I use this method, it will only use the last 2 waypoints in the vector.

There must be some more efficient way to make it check if the character reached its current destination before setting a new one. Any thoughts?
05/08/2012 14:22 Wazapoo#6
You could check the distance between you and the point where you are walking to like this:

Code:
for(int x = 0; x < coords.size(); x++)
{    
      float difX = Player->X - Player->GoX;
      float difY = Player->Y - Player->GoY;
      //no need to check vertically so no Z
      float dist = sqrtf(difX * difX + difY * difY);
      if(dist <= CLOSE_ENOUGH_DISTANCE && moncount < 2)
      {  	
	Player->GoX = coords[x].x;
        Player->GoY = coords[x].y;
	Walk();
	Sleep(250);
       }
      else if(moncount >= 2)
       {
           attack();
       }
}
}
Like this the char doesnt have to stop always before walking to the next target spot so it walks much smoother.
05/08/2012 18:18 iktov2#7
Aha, yea I tried that one already.

For some strange reason it when I do that it decides to ignore the all waypoints stored in my vector other than the First and Last(or the last 2, or the first and 3rd?)I dont know, its weird..

So if I save 8 waypoints in my vector for it to walk to, it will only walk between the last 2 stored in the vector. I am completely stumped as to why.

Code:
         float wpx, wpy;
                  for(int x = 0; x < coords.size(); x++)
                  {    
                      wpx = Player->X - Player->GoX; //Player coord & coord being moved to
                      wpy = Player->Y - Player->GoY;
                     
                      float dist = sqrt((wpx * wpx) + (wpy * wpy));

                      if(dist <= 1)
                      {
                          Player->GoX = coords[x].x;
                          Player->GoY = coords[x].y;
                          Walk(); 
                      } 
                  }
05/09/2012 15:41 Wazapoo#8
I dont really see the logic inside the for loop, it counts the x from 0 to the last stored point, thats okay, but inside the loop it checks the distance between you and the point. If its smaller or equal to 1 it will walk to the next point, but if the distance was larger than 1, it will still increment x by 1 and that way skipping 1 point totally.

Code:
float wpx, wpy, dist;
for(int x = 0; x < coords.size(); x++)
{       
    do
    {
        wpx = Player->X - Player->GoX;
        wpy = Player->Y - Player->GoY;
                     
        dist = sqrt((wpx * wpx) + (wpy * wpy));

        Sleep(25);
    } while(dist > 1.0f); //so long that the dist is larger than 1 it sleeps 25ms and checks then again

    Player->GoX = coords[x].x;
    Player->GoY = coords[x].y;
    Walk(); 
}
05/12/2012 09:16 ts2dropper#9
nice codes...
I made on my program like this. already my bot using this and make money in cave.
1. set Source X and Y
2. Set target X and Y
3. Command walk to target XY

this is enough...