SRL Archive - SRL Suggestions

Aim Compass


weequ

2009-06-29 16:41:49

It would aim the compass to given coords in minimap :)


These are from Ultra cut n bank:
{*******************************************************************************
function CoordsToDegrees(x, y: integer): integer;
By: PriSoner
Description: Returns the direction in degrees (0 to 359) to a set of coordinates
relative to your players position on the screen and North.
(degrees are in reverse to the convention to stay compatible with
MakeCompass etc i.e. 0 = N, 90 = W, 180 = S & 270 = E)
*******************************************************************************}
function CoordsToDegrees(x, y: integer): integer;
var d: double;
begin
x := x - 260;
y := y - 160;
d := ArcTan2(y, x) * (180 div Pi) + 90;
if d < 0 then d := d + 360;
result := round(abs(d - 360) + rs_GetCompassAngleDegrees);
if result >= 360 then result := result - 360;
end;


procedure MakeCompassCoords(x, y: integer);
By: PriSoner
Description: Moves Compass so that target x & y coordinates are directly north
of your player.
*******************************************************************************}
procedure MakeCompassCoords(x, y: integer);
begin
MakeCompass(IntToStr(CoordsToDegrees(x, y)));
end;

MylesMadness

2009-06-29 17:20:14

So you posted someone elses code for no reason it seems?

Cazax

2009-06-29 20:03:07

function CoordsToDegrees(x, y: integer): integer;
var d: double;
begin
x := x - 260;
y := y - 160;
d := ArcTan2(y, x) * (180 div Pi) + 90;
if d < 0 then d := d + 360;
result := round(abs(d - 360) + rs_GetCompassAngleDegrees);
if result >= 360 then result := result - 360;
end;
Shortened to:
function CoordsToDegrees(x, y: integer): integer;
Begin
If Not rs_OnMinimap(X, Y) Then
Exit;
Result := (Round(Degrees(ArcTan2(Y - MMCY, X - MMCX))) + 90) - Round(rs_GetCompassAngleDegrees);
If (Result < 0) Then
Result := Result + 360;
End;

ShowerThoughts

2009-06-29 21:44:05

How do you know the "angle" of the coords?
Do you guys take the middle and then go through the point outside?

Quickmarch

2009-06-29 23:21:22

From: Hermen
How do you know the "angle" of the coords?
Do you guys take the middle and then go through the point outside?


The ArcTan2 function gets the angle…

weequ

2009-06-30 13:22:08

From: MylesMadness
So you posted someone elses code for no reason it seems?
Just to show you how PriSoner did it… Is there something wrong with it?

Daniel

2009-06-30 13:35:16

From: Cazax
function CoordsToDegrees(x, y: integer): integer;
var d: double;
begin
x := x - 260;
y := y - 160;
d := ArcTan2(y, x) * (180 div Pi) + 90;
if d < 0 then d := d + 360;
result := round(abs(d - 360) + rs_GetCompassAngleDegrees);
if result >= 360 then result := result - 360;
end;
Shortened to:
function CoordsToDegrees(x, y: integer): integer;
Begin
If Not rs_OnMinimap(X, Y) Then
Exit;
Result := (Round(Degrees(ArcTan2(Y - MMCY, X - MMCX))) + 90) - Round(rs_GetCompassAngleDegrees);
If (Result < 0) Then
Result := Result + 360;
End;


function CoordsToDegrees(x, y: integer): integer;
begin
if(not(rs_OnMinimap(X, Y))) then
Exit;
Result := (FixD(Round(Degrees(ArcTan2(Y - MMCY, X - MMCX))) + 90) - Round(rs_GetCompassAngleDegrees));
end;

Shortened even more :D

Sorry, but i haven't done that before and felt like doing it xD

Quickmarch

2009-06-30 14:50:36


function MakeCompassCoords(x, y: integer): Boolean;
begin
Result := MakeCompass(IntToStr(CoordsToDegrees(x, y)));
end;

Made it return a Boolean.

MylesMadness

2009-06-30 17:37:50

From: antti mies
Just to show you how PriSoner did it… Is there something wrong with it?
You posted a new topic showing off someones code that no one requested? Seems like something is wrong to me…

Home

2009-06-30 18:17:30

From: MylesMadness
You posted a new topic showing off someones code that no one requested? Seems like something is wrong to me…


Hmm, well i don't think that there is nothing wrong with that :) Because i think it is good if someone pops some good code up :)

Even if it is not own code :)


~Home

Griff

2009-07-01 07:44:14

From: MylesMadness
You posted a new topic showing off someones code that no one requested? Seems like something is wrong to me…


Sure, he might not get all the credit if this is used somehow, but there's nothing wrong with it I don't think.

Floor66

2009-07-01 09:09:37

[QUOTE=Dan's The Man;594051][highlight=scar]
function CoordsToDegrees(x, y: integer): integer;
begin
if(not(rs_OnMinimap(X, Y))) then
Exit;
Result := (FixD(Round(Degrees(ArcTan2(Y - MMCY, X - MMCX))) + 90) - Round(rs_GetCompassAngleDegrees));
end;[/highlight]

Shortened even more :D

Sorry, but i haven't done that before and felt like doing it xD

What's with the whole shortening atm lol. It only makes it less readable for me :rolleyes:

Da 0wner

2009-07-01 16:28:33

From: Home
Hmm, well i don't think that there is nothing wrong with that :) Because i think it is good if someone pops some good code up :)

Even if it is not own code :)


~Home


Lulz, double negative.

Home

2009-07-02 00:39:41

From: Da 0wner
Lulz, double negative.


I don't understand what you mean :(

Da 0wner

2009-07-02 02:06:41

Don't + nothing = a positive.

Daniel

2009-07-02 11:25:13

From: Floor66
What's with the whole shortening atm lol. It only makes it less readable for me :rolleyes:


I don't know, everyone else was doin' it so i joined in too :D

Naike

2009-07-03 01:07:13

From: Da 0wner
Lulz, double negative.


Don't make fun of someones grammar.
Where he lacks in english he makes up in niceness, you on the other hand…
Can't say it here, as I get infracted ;)

My point: Stop being childish..

MylesMadness

2009-07-03 01:15:15

From: N1ke!
Don't make fun of someones grammar.
Where he lacks in english he makes up in niceness, you on the other hand…
Can't say it here, as I get infracted ;)

My point: Stop being childish..
Hes a
~Myles