![]() |
|
WASD Calculation - Printable Version +- LCKB (https://lckb.dev/forum) +-- Forum: ** OLD LCKB DATABASE ** (https://lckb.dev/forum/forumdisplay.php?fid=109) +--- Forum: Programmers Gateway (https://lckb.dev/forum/forumdisplay.php?fid=196) +---- Forum: Coders Talk (https://lckb.dev/forum/forumdisplay.php?fid=192) +---- Thread: WASD Calculation (/showthread.php?tid=3730) |
- fabi202cool - 06-27-2014 Hello Guys, maybe a few of the Old Members remeber my release of a WASD-Movement addon for EP1 back in 2012. Now I have seen that there still a few people are interested in this, and my DLL is sometimes randomly crashing the game. So I decided to show you how it works to do it better ![]() Basically its very simple: At first I read out the current XYZ Position and very important: the direction of viewing (the rotation of the player). In the next step I calculate the values from the rotation with trigonometric functions, fortunalety our values are in the perfect size for a smooth movement (only 0-4 Steps in the LastChaos Coordination system). At next I add our calculated XY-Values to the current Player Coordinates, we got at Step 1 and write it into the "RunTo-Coordinates", this are the same Values that are set, when you click at some point of the Map. Actually I doesnt remember if you have to set the 1 (Look in the code) to let the client know that the coordinates are changed, that your player is running to these, or if it just stands for the Map-Layer and the Player starts automatically running when the coordinates are changed - you are allowed to find it out ![]() //Prepare Addresses Base = *(int*)(BaseAddress); PlayerBase = *(int*)(Base + 0x1C); PlayerBase = *(int*)(PlayerBase + 0x10); PlayerBase = *(int*)(PlayerBase + 0x4); ... if(GetAsyncKeyState(RunKey)) { //Get Values rotation = *(float*)(PlayerBase + 0xE84); cxpos = *(float*)(PlayerBase + 0x54); cypos = *(float*)(PlayerBase + 0x5C); czpos = *(float*)(PlayerBase + 0x58); //Calculate Position newr = ((float)rotation - 90) * PI / (float)180; newx = cxpos - cos(newr); newy = cypos + sin(newr); //Apply New Position *(float*)(PlayerBase + 0xE08) = newx; *(float*)(PlayerBase + 0xE10) = newy; *(float*)(PlayerBase + 0xE0C) = czpos; *(int*)(PlayerBase + 0xE44) = 1; } I hope you enjoy it ![]() PS: Maybe "WASD" is the wrong description for it, because it depends on just one key for running and the arrow keys to rotate, but I hope its ok ![]() |