Made a small c# form just to test. could someone look it over:
Code:
float player_x = 1; // Just rnd, for testing
float player_y = 1; // Just rnd, for testing
float target_x = 4; // Just rnd, for testing
float target_y = 4; // Just rnd, for testing
float facing = (float)0.5718; // Player facing NW-ish direction on wowminimap!
public float GetAngle(float x, float y)
{
float dx = x - player_x;
float dy = y - player_y;
float result = (float)Math.Atan2(dy, dx);
result = (float)(180 * (result / Math.PI));
return result;
}
public float RadianToDegree(float rad)
{
float result = (float)((180 * (rad / Math.PI)));
if (rad < 0)
result += 180;
return result;
}
public void ShowMessage()
{
//MessageBox.Show("Facing angle: " + RadianToDegree(facing));
//MessageBox.Show("Point angle: " + GetAngle(target_x, target_y));
float degre_to_turn = (RadianToDegree(facing) + GetAngle(target_x, target_y));
if( degre_to_turn < 180 )
MessageBox.Show("Turn RIGHT: " + degre_to_turn);
else
MessageBox.Show("Turn LEFT: " + degre_to_turn);
}
// OUTPUT(for these values):
// Turn RIGHT: 77.76173