SRL Archive - SRL Archives

[Divi] Procedure SetCompass(Direction:String);


JuKKa

2007-04-27 14:43:19

::::::::::NEW UPDATE::::::::::
It now takes the shortest way!

procedure SetCompass(Direction: String);
var
Angle,DirectionDeg: Extended;
var
WhichKey: Integer;
begin
case Direction of
'n': DirectionDeg := 0;
'w': DirectionDeg := 90;
'e': DirectionDeg := 270;
's': DirectionDeg := 180;
end
Angle:= rs_GetCompassAngleDegrees;
if Angle = DirectionDeg then exit;

if Angle > 180 then
WhichKey := VK_RIGHT;

if Angle < 180 then
WhichKey := VK_LEFT;

KeyDown(WhichKey)
repeat
if not loggedin then break;
Angle:= rs_GetCompassAngleDegrees;
wait(1);
until(Angle = DirectionDeg);
KeyUp(WhichKey)
end;

its perfect (for me)

request from nielsie:


procedure SetCompassDegrees(Degre: Extended);
var
Angle: Extended;
begin
KeyDown(VK_RIGHT)
repeat
if not loggedin then break;
Angle:= rs_GetCompassAngleDegrees;
wait(1);
until(Angle = Degre);
KeyUp(VK_Right)
end;

havent tested in game but should work..

nielsie95

2007-04-27 14:52:29

Yup works here perfectly too. It would be great if you could make it turn to the degrees you set (like SetCompass(255)). :)

JuKKa

2007-04-27 15:05:54

well, i could do that too, if u want to..

nielsie95

2007-04-27 15:15:15

I also tried to modify it myself and got the same as you have, but that doesn't work for me :(. It keeps rotating.

Infantry001

2007-04-27 17:29:06

Works great! I tested it, and it got almost the same minimap view every time. But one thing; does it always get a consistent MM view? Cuz sometimes, the minimap and compass are misaligned.

Boreas

2007-04-27 17:45:27

untested

procedure SetCompass(Direction: String);
var
Angle,DirectionDeg: Extended;
begin
KeyDown(VK_RIGHT)
try
DirectionDeg := strtofloat(Direction);
except
case Direction of
'n': DirectionDeg := 0;
'w': DirectionDeg := 90;
'e': DirectionDeg := 270;
's': DirectionDeg := 180;
end
end;
repeat
if not loggedin then break;
Angle:= rs_GetCompassAngleDegrees;
wait(1);
until(Angle = DirectionDeg);
KeyUp(VK_Right)
end;

Bobarkinator

2007-04-27 18:59:25

I'm guessing this is just more accurate then makecompass and perfect north?

Smartzkid

2007-04-27 19:02:13

Far more accurate.

n3ss3s

2007-04-28 13:53:39

Suomalaista laatutyötä :D

(in english: Finnish quality-work)

JuKKa

2007-05-06 05:42:46

From: n3ss3s
Suomalaista laatutyötä :D

(in english: Finnish quality-work)


lol

grindisbest

2007-05-28 21:13:08

Works great!! Can I use it in my scripts?

Abyssal

2007-05-28 21:59:52

Tsk tsk standards…

procedure SetCompass(Direction: string);
var
Angle,DirectionDeg: Extended;
WhichKey: Integer;
begin
case Direction of
'n': DirectionDeg:= 0;
'w': DirectionDeg:= 90;
'e': DirectionDeg:= 270;
's': DirectionDeg:= 180;
end
Angle:= rs_GetCompassAngleDegrees;
if(Angle = DirectionDeg)then
Exit;
if(Angle > 180)then
WhichKey:= VK_RIGHT;
if(Angle < 180)then
WhichKey:= VK_LEFT;
KeyDown(WhichKey)
repeat
if(not(LoggedIn))then
Break;
Angle:= rs_GetCompassAngleDegrees;
Wait(1);
until(Angle = DirectionDeg);
KeyUp(WhichKey)
end;

nielsie95

2007-05-29 09:03:41

I fixed yours and Boreas a bit up. It takes the shortest way, and can be set to any angle. Use it as SetCompass('n') or SetCompass('10'):


program New;
{.Include SRL/SRL.SCAR}

procedure SetCompass(Direction: String);
var
StartAngle, Angle, DirectionDeg, i: Extended; Left: Boolean; Mark: LongInt;
begin
StartAngle := (rs_GetCompassAngleDegrees);
try
begin
if StrToFloat(Direction) > 360 then DirectionDeg := strtofloat(Direction) - 360 else
DirectionDeg := strtofloat(Direction);
end;
except
case LowerCase(Direction) of
'n': DirectionDeg := 0;
'w': DirectionDeg := 90;
'e': DirectionDeg := 270;
's': DirectionDeg := 180;
end
end;
if ((360 - StartAngle + DirectionDeg) > 180) and ((360 - StartAngle + DirectionDeg) < 360) then Left := True;
if Left then KeyDown(VK_LEFT) else KeyDown(VK_RIGHT);
MarkTime(Mark);
repeat
//if not loggedin then break;
Angle:= rs_GetCompassAngleDegrees;
wait(1);
if (TimeFromMark(Mark) mod 8500) = 0 then i := i +1;
if TimeFromMark(Mark) > 30000 then Break;
until (Angle > (DirectionDeg -(4 +i))) and (Angle < (DirectionDeg +(4 +i)));
if Left then KeyUp(VK_Left) else KeyUp(VK_Right);
end;

begin
activateClient;
SetCompass('59');
WriteLn(FloatToStr(rs_GetCompassAngleDegrees));
end.