Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Aion
You last visited: Today at 21:45

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

Advertisement



Calculating Rotation For X,Y in AION

Discussion on Calculating Rotation For X,Y in AION within the Aion forum part of the MMORPGs category.

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 09/21/2009, 11:37   #2
 
Hikkikomori's Avatar
 
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 09/21/2009, 21:59   #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 09/21/2009, 22:29   #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 09/23/2009, 18:47   #5
 
elite*gold: 20
Join Date: Feb 2007
Posts: 3,080
Received Thanks: 4,294
Code:
$diff = sqrt((($ownx1 - $targetx)^2) + (($owny1 - $targety)^2))
$erg = Round($diff)
Return $erg
kknb is offline  
Reply


Similar Threads Similar Threads
Calculating Height, Z axis
06/07/2010 - Kal Online - 36 Replies
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 am doing like that. Calculating step in X axis and Y axis. Then calculate Z step like that. MoveZ = CurrentPlayerZ - GetHeight(CurrentPlayerX+MoveX, CurrentPlayerY+MoveY); Ofcourse its not complete thinking as every step must be reversed by multiplying it by -1. Calculated CoordZ must be multiplyed by 10. Given X and Y arguments to GetHeight...
Calculating damage
05/11/2009 - Silkroad Online - 10 Replies
How do you can calculate silkroad damage? not average damage. but every factor like how accesory change that damage? how other buff attack buff change it? how the damage change when it hits more that 1 target?
Calculating Eudemon checksum
04/04/2008 - EO PServer Hosting - 1 Replies
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 in the source code, but came up blank. Any help is appreciated :)
Calculating Atack or MAtack
05/04/2007 - CO2 Guides & Templates - 4 Replies
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! "JUST 1 percent error" TROJAN ATACK: The follow instructions is both used to lower and higher atack:
Calculating Hours of Pkp
11/23/2006 - CO2 Guides & Templates - 15 Replies
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 'awful' pk points to get off. 1. Multiply # of pk points by 6. (EX- 100pkp X 6 =600) 2. Divide that number by 60. (EX- 600 / 60) 3. The end number will be the # of hours it will take to get your pkp off.



All times are GMT +1. The time now is 21:45.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.