I start with the Sleep to make sure my player position variables have a chance to update. tries is just a quick stuck check i made for testing, I'm not sure of a better way to handle that part atm. Don't mind the attack() function..
What i do is use curX to store my player position mtX[] is an array of x coords I want to walk to in order. So, I check where I am and subtract mtX[mt] to get how many spaces i need to move in game. Then i just use this random calcution I made after a stupid amount of test time.
WS is a RECT type that holds my screen size.
Code: Select all
int x = ((WS.right/17-1)*(mtX[mt]-curX-2)+(WS.right/2));
For some reason I'm getting a ton of crazy jumping around and stuff that is no where close to where i need to be and i'm not sure why.
Code: Select all
void movePlayer(int mtX[], int mtY[], int delay)
{
Sleep(400);
int curX = memReadInt(playerX);
int curY = memReadInt(playerY);
if (tries < 3)
{
if(tries <= 2)
attack(250);
if((curX - mtX[mt]) < 3 and (curX - mtX[mt]) > -3 and (curY - mtY[mt]) < 3 and (curY - mtY[mt]) > -3)
{
tries = 0;
if(mt > (sizeof(desX) / sizeof(desX[0])-2))
mt = 1;
else
mt++;
}
//Sleep(300);
int x = ((WS.right/17-1)*(mtX[mt]-curX)+(WS.right/2));
int y = ((WS.bottom/13-1)*(mtY[mt]-curY)+(WS.bottom/2));
cout<<"MT: " << mt << " curX: " << curX << " mtX[mt]: " << mtX[mt] << " curY: " << curY << " mtY[mt]: " << mtY[mt] << " tries: " << tries << endl;
moveMouse(x, y, 1);
pressKey(castTrans, 50);
leftClick(50);
tries++;
}else{
//Sleep(300);
int x = ((WS.right/17-1)*(mtX[mt]-curX-2)+(WS.right/2));
int y = ((WS.bottom/13-1)*(mtY[mt]-curY-2)+(WS.bottom/2));
cout<<"MT: " << mt << " curX: " << curX << " mtX[mt]: " << mtX[mt] << " curY: " << curY << " mtY[mt]: " << mtY[mt] << " tries: " << tries << endl;
moveMouse(x, y, 1);
pressKey(castTrans, 50);
leftClick(50);
tries = 0;
}
}