Blog hacked, all images gone, without it this thread does not make sense, sorry.
Blog hacked, all images gone, without it this thread does not make sense, sorry.
Last edited by naa; 05-28-2009 at 02:15 PM.
Just flew over it, looks good. While the timer thing might be better at performance / laggy computers, comparing your current facing with the needed one 'at all times' would still be more accurate than timers, or am I terribly wrong here? Also, as I read it, you can only turn while not moving, is that right? Aka: reaching waypoint -> stand still -> turn -> walk to new waypoint? By always comparing your current facing with the needed one, you could be walking forward and turning at the same time while still finding the right facing to reach your new waypoint, thus looking more 'human'. As I said, I didn't look that much into it so you might have that checked, sorry if that's the case. I'm quite tired and my eyes are dying, but is that 1 * pi/2 at the bottom for 270°? Not that it was that important, just letting you know.
Also, mind pming me the link of your blog?
The code that I "attached" is only showing how to face, i got some other code to (not attached) that uses that face code together with movement code. With that code I can get the char to move like a normal player, I am simply running forward while calling the facing function if the mob has moved more that 5 yards from its position last time i did a face. That way i can get the player to "hit" the mob even if the mob moves around.
I did not include the movement code as it needs some more work, stuck detector etc.
This is not a perfect way to face/move but as I do not want to edit the memory (facing etc) of wow I found this to be the second best way to control my char.
And you can easily face while moving
PM'ed you a link to my blog, but it is really not very interesting atm as I haven't been posting anything besides this since December.
Edit: Ups you are right, I made an error when drawing the circle, fixed it.
Last edited by naa; 02-02-2009 at 10:12 AM.
Or you can use SetFacing, alot easier or even better up you could use clicktomove for all the movement it's really nice
Code:PlayerInfo pInfo = new PlayerInfo(_process); if (Radians != true) { Angle = Angle * PI / 180; } uint pAngle = wow.AllocateMemory(0x4); wow.WriteFloat(pAngle, Angle); wow.Asm.Clear(); wow.Asm.AddLine("mov EDX, [{0}]", 0x011CA310); //Start UpdateCurMgr wow.Asm.AddLine("mov EDX, [EDX+{0}]", 0x000028A4); wow.Asm.AddLine("FS mov EAX, [0x2C]"); wow.Asm.AddLine("mov EAX, [EAX]"); wow.Asm.AddLine("add EAX, 8"); wow.Asm.AddLine("mov [EAX], EDX"); // End UpdateCurMgr wow.Asm.AddLine("mov ecx, {0}", pInfo.GetLocalPlayer()); wow.Asm.AddLine("push {0}", pAngle); wow.Asm.AddLine("call {0}", 0x006705E0); wow.Asm.AddLine("retn"); wow.Asm.AddLine("add esp, 0x8"); wow.Asm.InjectAndExecute(wow.AllocateMemory());
Thanks for the release but:
Update your highly accurate timer ^^ it's 40ms off!
static int FullTurnTimeStill = 1960; //Time to turn do a full turn (2PI) while standing still
static int FullTurnTimeRunning = 2650; //Time to turn to do a full turn while running
As someone said before, your algorithm doesn't work if you want to turn while running, but it's possible ^ gogo
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding
"I cried a little earlier when I had to poop" - Sku
Oh dammit, guess I need to update the code for my highly accurate timer then :P
Guess i will need to come up with some new code to solve the problem with moving and still rotation.
Anyway thanks for pointing out the errors i made.
This is what I do:
Forgot to say, LocalPlayer.XPosition and LocalPlayer.YPosition etc. are actually read from memory when you access them, so they are always up to date.Code:public static void AdjustYaw(PlayerObject LocalPlayer, double LocationX, double LocationY) { string turnDirectionHorizontal; double l, r; // get the angle we need to turn to horizontally double horizontalAngle = Math.Atan2(LocationY - LocalPlayer.YPosition, LocationX - LocalPlayer.XPosition); if (horizontalAngle < 0) horizontalAngle = (Math.PI * 2) + horizontalAngle; // should we turn left or right? if (LocalPlayer.Rotation > horizontalAngle) { // we do have to turn past north if we are turning left l = (2 * Math.PI) - LocalPlayer.Rotation + horizontalAngle; // we dont have to turn past north if we are turning right r = LocalPlayer.Rotation - horizontalAngle; } else { // we dont have to turn past north if we are turning left l = horizontalAngle - LocalPlayer.Rotation; // we do have to turn past north if we are turning right r = LocalPlayer.Rotation + (2 * Math.PI) - horizontalAngle; } // choose whichever is fastest if (l < r) turnDirectionHorizontal = "left"; else turnDirectionHorizontal = "right"; // start adjusting if (turnDirectionHorizontal == "left") KeyboardControl.KeyDown(TurnLeftKey); else KeyboardControl.KeyDown(TurnRightKey); bool turnKeyDown = true; while (turnKeyDown == true) { // refresh our variables (so if we are flying while turning etc we should still turn to the target) horizontalAngle = Math.Atan2(LocationY - LocalPlayer.YPosition, LocationX - LocalPlayer.XPosition); if (horizontalAngle < 0) horizontalAngle = (Math.PI * 2) + horizontalAngle; // horizontal check if (DifferenceBetween(LocalPlayer.Rotation, horizontalAngle) < 0.0872664626) // 5 degrees { if (turnDirectionHorizontal == "left") KeyboardControl.KeyUp(TurnLeftKey); else KeyboardControl.KeyUp(TurnRightKey); turnKeyDown = false; } } }
Last edited by jbrauman; 02-02-2009 at 08:05 PM.
Look, I am easily confused. dont mess with me!
why do you adjust the stack after your retn statement!? I assume that add instruction never happens!?
Edit: (cuz peeps get grumpy w/ 2 posts in a row on same thread)
Hrm, I just tried adding this code to my CWowObject ... to basically no effect
It's calling the function fine, but seems to be bailing out early. Is there magic "patching" that has to happen to convince this function to actually... do stuff?Code:void SetFacing(float Angle) { __asm { mov ecx, this push Angle mov eax, 0x006705E0 ; CInputControl_SetFacing call eax } }
Last edited by Sillyboy72; 02-03-2009 at 02:09 AM.
You're not alone Sillyboy ^^
Tried that SetFacing Snippet as soon as I saw it, thinking it would be an awesome improvement for the movement - but somehow simply nothing happens. No crash.. just nothing.
Are we missing something? I tried suspending WoW's Thread, but that doesn't seem to have an effect either.
Same. I'm not sure I'm doing it right though, never done any injection O_O
// get the angle we need to turn to horizontally
float horizontalAngle = (float)Math.Atan2(LocationY - LocalPlayer.YPosition, LocationX - LocalPlayer.XPosition);
if (horizontalAngle < 0)
horizontalAngle = (float)((Math.PI * 2) + horizontalAngle);
// inject that shit!
wow.Asm.Clear();
wow.Asm.AddLine("mov EDX, [{0}]", 0x011CA310);
wow.Asm.AddLine("mov EDX, [EDX+{0}]", 0x000028A4);
wow.Asm.AddLine("FS mov EAX, [0x2C]");
wow.Asm.AddLine("mov EAX, [EAX]");
wow.Asm.AddLine("add EAX, 8");
wow.Asm.AddLine("mov [EAX], EDX");
wow.Asm.AddLine("mov ecx, {0}", LocalPlayer.BaseAddress);
uint pAngle = wow.AllocateMemory(0x4);
wow.WriteFloat(pAngle, horizontalAngle);
wow.Asm.AddLine("push {0}", pAngle);
wow.Asm.AddLine("call {0}", 0x006705E0);
wow.Asm.AddLine("retn");
wow.Asm.AddLine("add esp, 0x8");
wow.Asm.InjectAndExecute(wow.AllocateMemory());
The code i used to set my facing with before i made the code above:
The localPlayerObject is the player object found by the GUID of the localPlayer.Code:public void facing(float angle) { if ((angle >= 0f) && (angle <= 2*Math.PI) { this.Memory.WriteFloat(getLocalPlayerObject() + 0x7dc, angle); } } public void facing(GUnit LocalPlayer, GUnit TargetObject) { this.facing(LocalPlayer.getPosition(), TargetObject.getPosition()); } public void facing(GLocation localPlayerPosition, GLocation targetPosition) { float angle = (float) Math.Atan2((double) (targetPosition.Y - localPlayerPosition.Y), (double) (targetPosition.X - localPlayerPosition.X)); //if the turning angle is negative if (angle < 0) //add the maximum possible angle (PI x 2) to normalize the negative angle angle += (float)(Math.PI * 2); this.facing(angle); }
The code makes you instantly face the angle you set.