Register for your free account! | Forgot your password?

Go Back   elitepvpers > Aion > Aion Main - Discussions / Questions
You last visited: Today at 21:24

  • Please register to post and access all features, it's quick, easy and FREE!

 

Calculating Rotation For X,Y in AION

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Sep 2009
Posts: 8
Received Thanks: 3
Calculating Rotation For X,Y in AION

I am working on a program that takes two coords from the game (X and Y, Z not relevent), and calculates how far point A (current position) is from point B (target position). However, i am having problems calculating which direction the object on point A needs to be facing (in degrees) to get to point B. I know there is some formula for this, however, I'm clueless.

So lets say my current position in the game is X-996 and Y-1071 currently facing a value of 100 (from what i see rotation is measured on a -180 to 180 scale, north being -90, east being 180, south being 90 and west being 0) and my target location is X-985 Y-1133, how would i go about calculating the rotation at which i need to be facing in order to reach my target position?

Below is the function i am currently using, that doesnt seem to work. what it does is grabs the coords from the objects current position then reads "waypoints" or pre-defined target positions from the text file. after that it tries to calculate the rotation (which is wrong) and then moves in that position towards the target position.

Code:
Func _Turn()
    Local $Cur_Coords = _GetCoords()
    Local $Next_Coords = StringSplit(FileReadLine(@ScriptDir & "\waypoints.txt",$Cur_Waypoint), ",") ;split x, y, z, map
 
    ;-------------------------------------------
    Local $PosX = $Cur_Coords[0]-$Next_Coords[1];x
    Local $PosY = $Cur_Coords[1]-$Next_Coords[2];y
 
                $Next_Rot = _ATan2($Next_Coords[2] - $Cur_Coords[1], $Next_Coords[1] - $Cur_Coords[0]) * 180 / $Pi
 
 
    GUICtrlSetData($Input6, $Next_Coords[1])
    GUICtrlSetData($Input7, $Next_Coords[2])
    GUICtrlSetData($Input10, Floor($Next_Rot))
 
        $Cur_Rot = _GetRotation()
 
        If $Next_Rot = $Cur_Rot Then Return $Next_Rot
 
        While $Cur_Rot <> $Next_Rot And $Run
                $Cur_Rot = _GetRotation()
                _MouseMovePlus()
                GUICtrlSetData($Input5, Floor($Cur_Rot))
        WEnd
 
    Return $Next_Rot
EndFunc
any help much appreciated



nod43 is offline  
Old   #2
 
elite*gold: 0
Join Date: Mar 2006
Posts: 495
Received Thanks: 205
here's a code i used for another game's navigation bot, it's in C# but you can probably convert it to AutoIT.

Quote:
private void FacePositionXZ(double H, Double ToleranceH)
{
double RH = 180;

while (Math.Abs(RH) > ToleranceH)
{
RH = Math.Abs(H - PositionDegree);

if (PositionDegree() > H)
RH = 360 - RH;

if (RH > 180)
RH = RH - 360;

if (RH < -ToleranceH)
{
Aion.SendLeftArrow;
System.Threading.Thread.Sleep(100);
}
else if (RH > ToleranceH)
{
Aion.SendRightArrow;
System.Threading.Thread.Sleep(100);
}

System.Threading.Thread.Sleep(100);

}
}
this is to calculate the heading towards the waypoint,

Quote:
public double HeadingToPosXZ(double X, double Z)
{
X = X - CharacterX;
Z = Z - CharacterZ;
double p = 180 * Math.Atan2(X, Z) / Math.PI;

if (Z < 0)
return p + 360;
else
return p;

}

P.S.: why don't you two just contribute your pointer/offset findings to the community in thread? :/
no need to keep it for yourself really.


Hikkikomori is offline  
Old   #3
 
elite*gold: 0
Join Date: Apr 2009
Posts: 10
Received Thanks: 2
Let's hear it for a useful math major!

It is highly recommended that you make east = 0 degrees, because that's assumed as you do things such as sine, cosine, and tangent. I'm not going to bother assuming east = 180 degrees, sorry.

For your reference:
East = 0
North = 90
West = 180
South = 270

If whatever you're doing is in radians, post here and I'll get back to you. Or just learn this:
180 degrees = pi radians




Let's get to it!

Quote:
So lets say my current position in the game is X-996 and Y-1071 currently facing a value of 100 (from what i see rotation is measured on a -180 to 180 scale, north being -90, east being 180, south being 90 and west being 0) and my target location is X-985 Y-1133, how would i go about calculating the rotation at which i need to be facing in order to reach my target position?
Let us denote the start position as (X1, Y1) and the end positions as (X2, Y2).

Then the angle formed with the closest horizontal axis, assuming the line "x = X1" is the horizontal axis, is:

arctan((Y2-Y1)/(X2-X1))

And there's more to teach you but I'm a tad tired. You probably won't be getting angles that make immediate sense to you, just remember, I'm talking about the angle formed with the closest horizontal axis. Sounds weird, but think about it.


EDIT: Blech forgot to post this earlier today, the above poster beat me to it. **** skee doop.

EDIT EDIT: Blech, Aion assumes west = 0 degrees. Not much of a hacker nowadays, ****.
Statistician is offline  
Old   #4
 
elite*gold: 0
Join Date: May 2006
Posts: 10
Received Thanks: 0
Something like:

function degreePoints(x1, y1, x2, y2){

if ((x2 - x1) == 0) {
if (y2 > y1) {
radian = 0;
} else {
radian = Pi;
}
} else {
if (x2 > x1){
radian = Pi / 2 - aTan((y2 - y1) / (x2 - x1));
} else {
radian = Pi * 1.5 - aTan((y2 - y1) / (x2 - x1));
}
}

degree = rad2Degree(radian);
return degree;

}

But you'd still have to convert from -90 being north to 90 being north which isn't hard just add 180 and subtract 360 if over 360.


MetalSlug is offline  
Old   #5
 
elite*gold: 20
Join Date: Feb 2007
Posts: 3,080
Received Thanks: 4,290
Code:
$diff = sqrt((($ownx1 - $targetx)^2) + (($owny1 - $targety)^2))
$erg = Round($diff)
Return $erg


kknb is offline  
Reply



« Previous Thread | Next Thread »

Similar Threads
Calculating Height, Z axis
Yo yo, Any of you got experiences with implementing correct moving system in Kal by packets? What is the best way to calculate it correctly? I...
36 Replies - Kal Online
Calculating damage
How do you can calculate silkroad damage? not average damage. but every factor like how accesory change that damage? how other buff attack buff...
10 Replies - SRO Ask the Experts
Calculating Eudemon checksum
Hi all, i was wondering if anyone knew what the function is that EO uses to calculate the chksum field in the cq_eudemon table? I tried to find it...
1 Replies - EO PServer Hosting
Calculating Atack or MAtack
Sometimes you wanted know the atack of an trojan and him dont told you? with thats easy guide, you just need open him equipaments window&#33; "JUST...
4 Replies - CO2 Guides & Templates
Calculating Hours of Pkp
Ever have a black name or more than 30 pk points? This is how to calculate The total time u will have to wait for those &#39;awful&#39; pk points to get off....
15 Replies - CO2 Guides & Templates



All times are GMT +2. The time now is 21:24.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy
Copyright ©2017 elitepvpers All Rights Reserved.