[Guide] How to find the angle of your character to your desired target

12/27/2012 01:59 168Atomica#1
Hello guys,

For those who are eager to put Autoit into action for use with CABAL, you would be glad with this post.

Lots of people PMed me on how did I manage to rotate my character so that it faces the right direction when botting.

I do that using trigonometry! (oh no)

But don't run away - yet
Complicated as it seems, it is just this function in AutoIt that does the magic.

Code:
_Degree(_ATan2($targetY - $currentY, $targetX - $currentX)
the return value of that function is the angle between your current position and your target position.

But hey, how would I know my current location?
See my siggy

Ok, but how would I know the target location?
Huh? Just go there and record the coordinates!

Oh sorry, one last question. How would I know how long to press the 'a' for left or 'd' for right to rotate my character?
Good question.
Based on my experiments, one full character rotation is approx 7560 ms. Ok, I will not make you dizzy with computation.
Here is the code:

Code:
Func _rotateLeft($ntimes)
	AutoItSetOption("SendKeyDownDelay", $ntimes * 21)
	Send("a")
EndFunc   ;==>_rotateLeft
What it does is hold 'a' for a period of 21ms per degree - (assuming 1 degree is 21 ms hold of the key - then 360 degrees = 7560 ms. )

As an example, if you got 45 as a result of the _Degree function above, then call _rotateLeft(45)

The code for rotation to the right is just as simple
Code:
Func _rotateRight($ntimes)
	AutoItSetOption("SendKeyDownDelay", $ntimes * 21)
	Send("d")
EndFunc   ;==>_rotateRight
I hope this post is not confusing as it seems. I made it as simple as possible so others could learn.

Leechers will be confused. Learners will benefit from this post. Happy holidays!

UPDATE---Example:
If your current coordinate is (10,22) and you want to bot at location (100,120)
[Only registered and activated users can see links. Click Here To Register...]
Degrees returns 47
we just need to call _rotateLeft(47) to rotate our character
12/27/2012 11:43 majead123#2
At last! ;) there you go!
04/07/2024 20:56 wladorvir#3
It's old thread but it doesn't really matter since movement didn't change in this game since that time. I'm not sure how it suppose to work because you don't know where you look at initial moment. What if your character is turned back to target location?