I was able to find memory area that holds info how character is facing. Its saved as radians and I wrote function that converts it to degrees and truncates decimal part off.
So now I can use it like:
Code:
While(Angle(value) != ValueWeWant) {
PressKeyToTurnCharacterAround();
ReadMemoryProcess(handle, charfacing, ValueWeWant ... ); // To read current value
}
You got the idea. So character turns around until it's facing to way we want it to. That works pretty well, I will still implement it.
But now I ran into problems again; Coordinate values ( x,y,z ) that I read from memory are negative. They are like:
X-Value: -10044.5
Y-Value: -3065.41
Z-Value: -707.753
All of them are float datatypes.
Code:
float x, y, z;
ReadProcessMemory(kahva, (LPVOID) X_VALUE, &x, sizeof(x), NULL);
ReadProcessMemory(kahva, (LPVOID) Y_VALUE, &y, sizeof(y), NULL);
ReadProcessMemory(kahva, (LPVOID) Z_VALUE, &z, sizeof(z), NULL);
So, whats wrong then? Well, when I'm making an while loop like this:
Code:
while(x != -10124)
{
ReadProcessMemory(kahva, (LPVOID) X_VALUE, &x, sizeof(x), NULL);
cout << x << endl;
keybd_event( 0x57,0,KEYEVENTF_EXTENDEDKEY | 0,0 ); // W Down
Sleep(1000);
keybd_event( 0x57,0,KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,0 ); // W Up
}
Then I manually walk with my character to X-value: -10124; nothing happens 0.o May this be caused becouse size of value X in memory is too big for Float datatype or what?
Hopefully someone is interested enough to help