SRL Archive - Help and Support

Error with SCAR function?


lordsaturn

2008-10-30 21:33:33

My function seems to exit after it gets to the line with ToCartOffset in it.


program New;
{.include srl/srl.scar}

procedure MMClick(x, y, rR, rT: integer);
var
P: PPoint;
T: TPoint;
begin
if not rs_OnMinimap(x, y) then Exit;
P := ToPolarOffset(Point(x, y), Point(MMCX, MMCY));
case Random(2) of
0: P.r := P.r + Random(rR+1);
1: P.r := P.r - Random(rR+1);
end;
case Random(2) of
0: P.t := P.t + Random(rT+1);
1: P.t := P.t - Random(rT+1);
end;
writeln('1');
T := ToCartOffset(P, Point(MMCX, MMCY));
writeln('2');
Mouse(T.x, T.y, 0, 0, True);
end;

begin
setupsrl;
mmclick(670, 71, 5, 2);
end.

I don't understand?

Claymore

2008-10-30 22:46:28

Possible these



case Random(1) of
etc...


0 counts as well.

Now may you please tell what the frick this function does?

lordsaturn

2008-10-31 00:58:12

From: Deathscytex
Possible these



case Random(1) of
etc...


0 counts as well.

Now may you please tell what the frick this function does?



It's a click with randomization in relation to the polar coordinate plane around the minimap center rather than the cartesian coordinate plane. But that's not the point i'm trying to make. If you run that block of code, it wont even move the mouse, nor print '2'. It will simply exit after it hits the line with the function ToCartOffset.


Also I don't understand what you are trying to say about 0 count?

Laur€ns

2008-10-31 02:06:16

He mans; Case Random(3) counts as 0,1,2 and 3.

Naum

2008-10-31 06:04:28

I'd check this:

 if not rs_OnMinimap(x, y) then Exit;
Its the only thing which could be causing the problem ;)

NiCbaZ

2008-10-31 07:05:02

No its not as, it WriteLn's out ('1');

lordsaturn

2008-10-31 11:53:22

From: Laur€ns
He mans; Case Random(3) counts as 0,1,2 and 3.


No it doesn't, Random(3) will only result 0, 1, or 2; never 3.

A G E N T

2008-11-01 21:59:37

Very strange… even manually putting in values for r and theta doesn't work.
Even more strangely, doing this:

procedure MMClick(x, y, rR, rT: integer);
var
P: PPoint;
T : TPoint;
begin
if not rs_OnMinimap(x, y) then Exit;
P := ToPolarOffset(Point(x, y), Point(MMCX, MMCY));
case Random(2) of
0: P.r := P.r + Random(rR+1);
1: P.r := P.r - Random(rR+1);
end;
case Random(2) of
0: P.t := P.t + Random(rT+1);
1: P.t := P.t - Random(rT+1);
end;
try
T := ToCartOffset(P, Point(MMCX, MMCY));
finally
Writeln('failed');
end;
Mouse(T.x, T.y, 0, 0, True);
end;
Will return
[Runtime Error] : Invalid Type in line 26 in script
When mouse() uses that point - instead of the expected 0,0.

:/ Completely baffled.

bullzeye95

2008-11-02 09:21:17

procedure MMClick(x, y, rR, rT: integer);
var
P: PPoint;
begin
if not rs_OnMinimap(x, y) then Exit;
P := ToPolarOffset(Point(x, y), Point(MMCX, MMCY));
case Random(2) of
0: P.r := P.r + Random(rR+1);
1: P.r := P.r - Random(rR+1);
end;
case Random(2) of
0: P.t := P.t + Random(rT+1);
1: P.t := P.t - Random(rT+1);
end;
Mouse(ToCartOffset(P, Point(MMCX, MMCY)).x, ToCartOffset(P, Point(MMCX, MMCY)).y, 0, 0, True);
end;
Weird bug. But fixed.

lordsaturn

2008-11-02 19:31:25

From: bullzeye95
procedure MMClick(x, y, rR, rT: integer);
var
P: PPoint;
begin
if not rs_OnMinimap(x, y) then Exit;
P := ToPolarOffset(Point(x, y), Point(MMCX, MMCY));
case Random(2) of
0: P.r := P.r + Random(rR+1);
1: P.r := P.r - Random(rR+1);
end;
case Random(2) of
0: P.t := P.t + Random(rT+1);
1: P.t := P.t - Random(rT+1);
end;
Mouse(ToCartOffset(P, Point(MMCX, MMCY)).x, ToCartOffset(P, Point(MMCX, MMCY)).y, 0, 0, True);
end;
Weird bug. But fixed.



Thanks bullzeye, I guess it fails when you try and store it to a variable?
Maybe someone should inform freddy about this?

Nava2

2008-11-02 21:22:49

var
P: PPoint;

Wtf is a PPoint? Could THAT be your error? :)

ZephyrsFury

2008-11-02 21:48:41

From: Nava2
var
P: PPoint;

Wtf is a PPoint? Could THAT be your error? :)



type
PPoint = record
R, T: Extended;
end;

A PPoint is a type similar to a TPoint but is based on the polar coordinate system (with Radius and Angle (Theta)) instead of x and y.