SRL Archive - Research & Development Lounge

Makecompassreflection


Waddo

2008-07-25 12:29:13

Function Makecompassreflection(Direction:string;Accuracy:integer): Boolean;
{*******************************************************************
Function Makecompassreflection(Direction:string;Accuracy:integer): Boolean;
By: Waddo
Description: Rotates the camera using reflection
********************************************************************}
var
clientAngle,DirDeg,mark: integer;
left:boolean;
begin
case LowerCase(Direction) of
'n': DirDeg := 0;
'w': DirDeg := 90;
's': DirDeg := 180;
'e': DirDeg := 270;
end else
DirDeg := StrToInt(Direction);
ClientAngle:= (SmartGetFieldInt(0,CompassAngle) + SmartGetFieldInt(0,MapOffsetAngle)) mod 2048;
ClientAngle:=ClientAngle * 180 / 1024;
if ClientAngle=dirdeg then exit;
if (ClientAngle-DirDeg)>180 then
begin
left:=false;
keydown(vk_right);
end else
begin
left:=true;
keydown(vk_left);
end;
wait(1);
MarkTime(Mark);
repeat
clientAngle:= (SmartGetFieldInt(0,CompassAngle) + SmartGetFieldInt(0,MapOffsetAngle)) mod 2048;
clientangle:=clientAngle * 180 / 1024;
If left then
if clientangle>DirDeg then break;
if not left then
if clientangle<DirDeg then break;
If clientangle=dirDeg then break;
Wait(1);
until (TimeFromMark(Mark) > 14000) or ( ((clientangle>dirDeg-Accuracy) or (clientangle>dirDeg-Accuracy+360)) and (clientangle<dirDeg+Accuracy));
if left then
Keyup(vk_left)
else
keyup(vk_right);
if clientangle<>dirdeg then
Makecompassreflection(direction,0);
result:=clientangle=dirDeg;
end;

randy marsh

2008-07-25 12:33:29

waddo do u ever stop lol!

noidea

2008-07-25 12:36:19

LOL yea. You have been here half the time I have. Produced more scripts, more function/procedure then I will ever, and your an SRL member lol. This reflection stuff is amazing!

noidea

Waddo

2008-07-25 12:57:43

Thank you.
I find scripting addicting =]

jose89

2008-07-25 23:16:28

Line 16: [Error] (16:5): Identifier expected in script C:\Program Files\SCAR 3.15\includes\SRL\SRL\Misc\Reflection.Scar


how do i fix

Waddo

2008-07-26 05:38:14

you have to have the reflection include it is posted around a bit copy and paste it and save in includs ans reflection.scar

JuKKa

2008-07-26 05:52:00


function PerfectCompass(Direction: string): Boolean;
{*******************************************************************
function PerfectCompass(Direction: string): Boolean;
By: SRL and jukka
Description: Perfect compass using SMART and reflection
********************************************************************}
var
StartAngle, Angle, DirectionDeg, i: Extended;
Left: Boolean;
Mark: Integer;
begin
Result := False;
StartAngle := (GetMinimapAngleDeg);
if (StartAngle < 0) or (not LoggedIn) then Exit;
try
DirectionDeg := FixD(StrToFloat(Direction));
except
case LowerCase(Direction) of
'n': DirectionDeg := 0;
'w': DirectionDeg := 90;
's': DirectionDeg := 180;
'e': DirectionDeg := 270;
end;
end;
if (MinE(Abs(StartAngle - DirectionDeg), MinE(Abs(StartAngle - (DirectionDeg + 360)), Abs((StartAngle + 360) - DirectionDeg)))) <= 8.0 then
begin
Result := True;
Exit;
end;
Left := (Round((360 - StartAngle) + DirectionDeg) mod 360 > Round((StartAngle + 360) - DirectionDeg) mod 360);
if Left then
KeyDown(VK_LEFT)
else
KeyDown(VK_RIGHT);
Wait(10);
MarkTime(Mark);
repeat
Wait(1);
Angle:= GetMinimapAngleDeg;
if ((TimeFromMark(Mark) > 6000) and (i < 1.0)) or
((TimeFromMark(Mark) > 10000) and (i < 2.0)) or
((TimeFromMark(Mark) > 14000) and (i < 3.0)) then
begin
i := i + 1.0;
end;
until ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i))
or (TimeFromMark(Mark) > 14000)
or (Angle < 0);
if Left then
KeyUp(VK_Left)
else
KeyUp(VK_Right);
Wait(10);
Result := ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i));
end;

this one is better

Waddo

2008-07-26 06:08:11

Ok. . .Ok i know i cant impress any of you, you should be happy that i atleast try XD

Timer

2008-07-26 10:32:40

From: Waddo
Function Makecompassreflection(Direction:string;Accuracy:integer): Boolean;
{*******************************************************************
Function Makecompassreflection(Direction:string;Accuracy:integer): Boolean;
By: Waddo
Description: Rotates the camera using reflection
********************************************************************}
var
clientAngle,DirDeg,mark: integer;
left:boolean;
begin
case LowerCase(Direction) of
'n': DirDeg := 0;
'w': DirDeg := 90;
's': DirDeg := 180;
'e': DirDeg := 270;
end else
DirDeg := StrToInt(Direction);
ClientAngle:= (SmartGetFieldInt(0,CompassAngle) + SmartGetFieldInt(0,MapOffsetAngle)) mod 2048;
ClientAngle:=ClientAngle * 180 / 1024;
if ClientAngle=dirdeg then exit;
if (ClientAngle-DirDeg)>180 then
begin
left:=false;
keydown(vk_right);
end else
begin
left:=true;
keydown(vk_left);
end;
wait(1);
MarkTime(Mark);
repeat
clientAngle:= (SmartGetFieldInt(0,CompassAngle) + SmartGetFieldInt(0,MapOffsetAngle)) mod 2048;
clientangle:=clientAngle * 180 / 1024;
If left then
if clientangle>DirDeg then break;
if not left then
if clientangle<DirDeg then break;
If clientangle=dirDeg then break;
Wait(1);
until (TimeFromMark(Mark) > 14000) or ( ((clientangle>dirDeg-Accuracy) or (clientangle>dirDeg-Accuracy+360)) and (clientangle<dirDeg+Accuracy));
if left then
Keyup(vk_left)
else
keyup(vk_right);
if clientangle<>dirdeg then
Makecompassreflection(direction,0);
result:=clientangle=dirDeg;
end;


If accuracy was set to perfect, and north, it would be a never ending loop, the correct for north is -1… :)

How do I know? I made one! :p

chrisn2323

2008-07-26 11:43:28

so why was KYAB shot down so much?

Waddo

2008-07-26 13:52:17

Timer its how i have made it the accuracy is how close to the 90 degrees you put 6 and it gets with in 6 degrees then it auto fixes overshot

Timer

2008-07-26 14:01:28

Meh, ok… Sorry though, its not going in reflection.scar…
I made one like jukkas last night… SRLs edited for reflection… :p

sorry.

Waddo

2008-07-26 15:51:17

Np im making something better =] im just not very good at it =p